]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/extend.texi
re PR c/59708 (clang-compatible checked arithmetic builtins)
[thirdparty/gcc.git] / gcc / doc / extend.texi
1 @c Copyright (C) 1988-2014 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 * Label Attributes:: Specifying attributes on labels.
59 * Attribute Syntax:: Formal syntax for attributes.
60 * Function Prototypes:: Prototype declarations and old-style definitions.
61 * C++ Comments:: C++ comments are recognized.
62 * Dollar Signs:: Dollar sign is allowed in identifiers.
63 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
64 * Variable Attributes:: Specifying attributes of variables.
65 * Type Attributes:: Specifying attributes of types.
66 * Alignment:: Inquiring about the alignment of a type or variable.
67 * Inline:: Defining inline functions (as fast as macros).
68 * Volatiles:: What constitutes an access to a volatile object.
69 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
70 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
71 * Incomplete Enums:: @code{enum foo;}, with details to follow.
72 * Function Names:: Printable strings which are the name of the current
73 function.
74 * Return Address:: Getting the return or frame address of a function.
75 * Vector Extensions:: Using vector instructions through built-in functions.
76 * Offsetof:: Special syntax for implementing @code{offsetof}.
77 * __sync Builtins:: Legacy built-in functions for atomic memory access.
78 * __atomic Builtins:: Atomic built-in functions with memory model.
79 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
80 arithmetic overflow checking.
81 * x86 specific memory model extensions for transactional memory:: x86 memory models.
82 * Object Size Checking:: Built-in functions for limited buffer overflow
83 checking.
84 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
85 * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
86 * Other Builtins:: Other built-in functions.
87 * Target Builtins:: Built-in functions specific to particular targets.
88 * Target Format Checks:: Format checks specific to particular targets.
89 * Pragmas:: Pragmas accepted by GCC.
90 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
91 * Thread-Local:: Per-thread variables.
92 * Binary constants:: Binary constants using the @samp{0b} prefix.
93 @end menu
94
95 @node Statement Exprs
96 @section Statements and Declarations in Expressions
97 @cindex statements inside expressions
98 @cindex declarations inside expressions
99 @cindex expressions containing statements
100 @cindex macros, statements in expressions
101
102 @c the above section title wrapped and causes an underfull hbox.. i
103 @c changed it from "within" to "in". --mew 4feb93
104 A compound statement enclosed in parentheses may appear as an expression
105 in GNU C@. This allows you to use loops, switches, and local variables
106 within an expression.
107
108 Recall that a compound statement is a sequence of statements surrounded
109 by braces; in this construct, parentheses go around the braces. For
110 example:
111
112 @smallexample
113 (@{ int y = foo (); int z;
114 if (y > 0) z = y;
115 else z = - y;
116 z; @})
117 @end smallexample
118
119 @noindent
120 is a valid (though slightly more complex than necessary) expression
121 for the absolute value of @code{foo ()}.
122
123 The last thing in the compound statement should be an expression
124 followed by a semicolon; the value of this subexpression serves as the
125 value of the entire construct. (If you use some other kind of statement
126 last within the braces, the construct has type @code{void}, and thus
127 effectively no value.)
128
129 This feature is especially useful in making macro definitions ``safe'' (so
130 that they evaluate each operand exactly once). For example, the
131 ``maximum'' function is commonly defined as a macro in standard C as
132 follows:
133
134 @smallexample
135 #define max(a,b) ((a) > (b) ? (a) : (b))
136 @end smallexample
137
138 @noindent
139 @cindex side effects, macro argument
140 But this definition computes either @var{a} or @var{b} twice, with bad
141 results if the operand has side effects. In GNU C, if you know the
142 type of the operands (here taken as @code{int}), you can define
143 the macro safely as follows:
144
145 @smallexample
146 #define maxint(a,b) \
147 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
148 @end smallexample
149
150 Embedded statements are not allowed in constant expressions, such as
151 the value of an enumeration constant, the width of a bit-field, or
152 the initial value of a static variable.
153
154 If you don't know the type of the operand, you can still do this, but you
155 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
156
157 In G++, the result value of a statement expression undergoes array and
158 function pointer decay, and is returned by value to the enclosing
159 expression. For instance, if @code{A} is a class, then
160
161 @smallexample
162 A a;
163
164 (@{a;@}).Foo ()
165 @end smallexample
166
167 @noindent
168 constructs a temporary @code{A} object to hold the result of the
169 statement expression, and that is used to invoke @code{Foo}.
170 Therefore the @code{this} pointer observed by @code{Foo} is not the
171 address of @code{a}.
172
173 In a statement expression, any temporaries created within a statement
174 are destroyed at that statement's end. This makes statement
175 expressions inside macros slightly different from function calls. In
176 the latter case temporaries introduced during argument evaluation are
177 destroyed at the end of the statement that includes the function
178 call. In the statement expression case they are destroyed during
179 the statement expression. For instance,
180
181 @smallexample
182 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
183 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
184
185 void foo ()
186 @{
187 macro (X ());
188 function (X ());
189 @}
190 @end smallexample
191
192 @noindent
193 has different places where temporaries are destroyed. For the
194 @code{macro} case, the temporary @code{X} is destroyed just after
195 the initialization of @code{b}. In the @code{function} case that
196 temporary is destroyed when the function returns.
197
198 These considerations mean that it is probably a bad idea to use
199 statement expressions of this form in header files that are designed to
200 work with C++. (Note that some versions of the GNU C Library contained
201 header files using statement expressions that lead to precisely this
202 bug.)
203
204 Jumping into a statement expression with @code{goto} or using a
205 @code{switch} statement outside the statement expression with a
206 @code{case} or @code{default} label inside the statement expression is
207 not permitted. Jumping into a statement expression with a computed
208 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
209 Jumping out of a statement expression is permitted, but if the
210 statement expression is part of a larger expression then it is
211 unspecified which other subexpressions of that expression have been
212 evaluated except where the language definition requires certain
213 subexpressions to be evaluated before or after the statement
214 expression. In any case, as with a function call, the evaluation of a
215 statement expression is not interleaved with the evaluation of other
216 parts of the containing expression. For example,
217
218 @smallexample
219 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
220 @end smallexample
221
222 @noindent
223 calls @code{foo} and @code{bar1} and does not call @code{baz} but
224 may or may not call @code{bar2}. If @code{bar2} is called, it is
225 called after @code{foo} and before @code{bar1}.
226
227 @node Local Labels
228 @section Locally Declared Labels
229 @cindex local labels
230 @cindex macros, local labels
231
232 GCC allows you to declare @dfn{local labels} in any nested block
233 scope. A local label is just like an ordinary label, but you can
234 only reference it (with a @code{goto} statement, or by taking its
235 address) within the block in which it is declared.
236
237 A local label declaration looks like this:
238
239 @smallexample
240 __label__ @var{label};
241 @end smallexample
242
243 @noindent
244 or
245
246 @smallexample
247 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
248 @end smallexample
249
250 Local label declarations must come at the beginning of the block,
251 before any ordinary declarations or statements.
252
253 The label declaration defines the label @emph{name}, but does not define
254 the label itself. You must do this in the usual way, with
255 @code{@var{label}:}, within the statements of the statement expression.
256
257 The local label feature is useful for complex macros. If a macro
258 contains nested loops, a @code{goto} can be useful for breaking out of
259 them. However, an ordinary label whose scope is the whole function
260 cannot be used: if the macro can be expanded several times in one
261 function, the label is multiply defined in that function. A
262 local label avoids this problem. For example:
263
264 @smallexample
265 #define SEARCH(value, array, target) \
266 do @{ \
267 __label__ found; \
268 typeof (target) _SEARCH_target = (target); \
269 typeof (*(array)) *_SEARCH_array = (array); \
270 int i, j; \
271 int value; \
272 for (i = 0; i < max; i++) \
273 for (j = 0; j < max; j++) \
274 if (_SEARCH_array[i][j] == _SEARCH_target) \
275 @{ (value) = i; goto found; @} \
276 (value) = -1; \
277 found:; \
278 @} while (0)
279 @end smallexample
280
281 This could also be written using a statement expression:
282
283 @smallexample
284 #define SEARCH(array, target) \
285 (@{ \
286 __label__ found; \
287 typeof (target) _SEARCH_target = (target); \
288 typeof (*(array)) *_SEARCH_array = (array); \
289 int i, j; \
290 int value; \
291 for (i = 0; i < max; i++) \
292 for (j = 0; j < max; j++) \
293 if (_SEARCH_array[i][j] == _SEARCH_target) \
294 @{ value = i; goto found; @} \
295 value = -1; \
296 found: \
297 value; \
298 @})
299 @end smallexample
300
301 Local label declarations also make the labels they declare visible to
302 nested functions, if there are any. @xref{Nested Functions}, for details.
303
304 @node Labels as Values
305 @section Labels as Values
306 @cindex labels as values
307 @cindex computed gotos
308 @cindex goto with computed label
309 @cindex address of a label
310
311 You can get the address of a label defined in the current function
312 (or a containing function) with the unary operator @samp{&&}. The
313 value has type @code{void *}. This value is a constant and can be used
314 wherever a constant of that type is valid. For example:
315
316 @smallexample
317 void *ptr;
318 /* @r{@dots{}} */
319 ptr = &&foo;
320 @end smallexample
321
322 To use these values, you need to be able to jump to one. This is done
323 with the computed goto statement@footnote{The analogous feature in
324 Fortran is called an assigned goto, but that name seems inappropriate in
325 C, where one can do more than simply store label addresses in label
326 variables.}, @code{goto *@var{exp};}. For example,
327
328 @smallexample
329 goto *ptr;
330 @end smallexample
331
332 @noindent
333 Any expression of type @code{void *} is allowed.
334
335 One way of using these constants is in initializing a static array that
336 serves as a jump table:
337
338 @smallexample
339 static void *array[] = @{ &&foo, &&bar, &&hack @};
340 @end smallexample
341
342 @noindent
343 Then you can select a label with indexing, like this:
344
345 @smallexample
346 goto *array[i];
347 @end smallexample
348
349 @noindent
350 Note that this does not check whether the subscript is in bounds---array
351 indexing in C never does that.
352
353 Such an array of label values serves a purpose much like that of the
354 @code{switch} statement. The @code{switch} statement is cleaner, so
355 use that rather than an array unless the problem does not fit a
356 @code{switch} statement very well.
357
358 Another use of label values is in an interpreter for threaded code.
359 The labels within the interpreter function can be stored in the
360 threaded code for super-fast dispatching.
361
362 You may not use this mechanism to jump to code in a different function.
363 If you do that, totally unpredictable things happen. The best way to
364 avoid this is to store the label address only in automatic variables and
365 never pass it as an argument.
366
367 An alternate way to write the above example is
368
369 @smallexample
370 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
371 &&hack - &&foo @};
372 goto *(&&foo + array[i]);
373 @end smallexample
374
375 @noindent
376 This is more friendly to code living in shared libraries, as it reduces
377 the number of dynamic relocations that are needed, and by consequence,
378 allows the data to be read-only.
379 This alternative with label differences is not supported for the AVR target,
380 please use the first approach for AVR programs.
381
382 The @code{&&foo} expressions for the same label might have different
383 values if the containing function is inlined or cloned. If a program
384 relies on them being always the same,
385 @code{__attribute__((__noinline__,__noclone__))} should be used to
386 prevent inlining and cloning. If @code{&&foo} is used in a static
387 variable initializer, inlining and cloning is forbidden.
388
389 @node Nested Functions
390 @section Nested Functions
391 @cindex nested functions
392 @cindex downward funargs
393 @cindex thunks
394
395 A @dfn{nested function} is a function defined inside another function.
396 Nested functions are supported as an extension in GNU C, but are not
397 supported by GNU C++.
398
399 The nested function's name is local to the block where it is defined.
400 For example, here we define a nested function named @code{square}, and
401 call it twice:
402
403 @smallexample
404 @group
405 foo (double a, double b)
406 @{
407 double square (double z) @{ return z * z; @}
408
409 return square (a) + square (b);
410 @}
411 @end group
412 @end smallexample
413
414 The nested function can access all the variables of the containing
415 function that are visible at the point of its definition. This is
416 called @dfn{lexical scoping}. For example, here we show a nested
417 function which uses an inherited variable named @code{offset}:
418
419 @smallexample
420 @group
421 bar (int *array, int offset, int size)
422 @{
423 int access (int *array, int index)
424 @{ return array[index + offset]; @}
425 int i;
426 /* @r{@dots{}} */
427 for (i = 0; i < size; i++)
428 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
429 @}
430 @end group
431 @end smallexample
432
433 Nested function definitions are permitted within functions in the places
434 where variable definitions are allowed; that is, in any block, mixed
435 with the other declarations and statements in the block.
436
437 It is possible to call the nested function from outside the scope of its
438 name by storing its address or passing the address to another function:
439
440 @smallexample
441 hack (int *array, int size)
442 @{
443 void store (int index, int value)
444 @{ array[index] = value; @}
445
446 intermediate (store, size);
447 @}
448 @end smallexample
449
450 Here, the function @code{intermediate} receives the address of
451 @code{store} as an argument. If @code{intermediate} calls @code{store},
452 the arguments given to @code{store} are used to store into @code{array}.
453 But this technique works only so long as the containing function
454 (@code{hack}, in this example) does not exit.
455
456 If you try to call the nested function through its address after the
457 containing function exits, all hell breaks loose. If you try
458 to call it after a containing scope level exits, and if it refers
459 to some of the variables that are no longer in scope, you may be lucky,
460 but it's not wise to take the risk. If, however, the nested function
461 does not refer to anything that has gone out of scope, you should be
462 safe.
463
464 GCC implements taking the address of a nested function using a technique
465 called @dfn{trampolines}. This technique was described in
466 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
467 C++ Conference Proceedings, October 17-21, 1988).
468
469 A nested function can jump to a label inherited from a containing
470 function, provided the label is explicitly declared in the containing
471 function (@pxref{Local Labels}). Such a jump returns instantly to the
472 containing function, exiting the nested function that did the
473 @code{goto} and any intermediate functions as well. Here is an example:
474
475 @smallexample
476 @group
477 bar (int *array, int offset, int size)
478 @{
479 __label__ failure;
480 int access (int *array, int index)
481 @{
482 if (index > size)
483 goto failure;
484 return array[index + offset];
485 @}
486 int i;
487 /* @r{@dots{}} */
488 for (i = 0; i < size; i++)
489 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
490 /* @r{@dots{}} */
491 return 0;
492
493 /* @r{Control comes here from @code{access}
494 if it detects an error.} */
495 failure:
496 return -1;
497 @}
498 @end group
499 @end smallexample
500
501 A nested function always has no linkage. Declaring one with
502 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
503 before its definition, use @code{auto} (which is otherwise meaningless
504 for function declarations).
505
506 @smallexample
507 bar (int *array, int offset, int size)
508 @{
509 __label__ failure;
510 auto int access (int *, int);
511 /* @r{@dots{}} */
512 int access (int *array, int index)
513 @{
514 if (index > size)
515 goto failure;
516 return array[index + offset];
517 @}
518 /* @r{@dots{}} */
519 @}
520 @end smallexample
521
522 @node Constructing Calls
523 @section Constructing Function Calls
524 @cindex constructing calls
525 @cindex forwarding calls
526
527 Using the built-in functions described below, you can record
528 the arguments a function received, and call another function
529 with the same arguments, without knowing the number or types
530 of the arguments.
531
532 You can also record the return value of that function call,
533 and later return that value, without knowing what data type
534 the function tried to return (as long as your caller expects
535 that data type).
536
537 However, these built-in functions may interact badly with some
538 sophisticated features or other extensions of the language. It
539 is, therefore, not recommended to use them outside very simple
540 functions acting as mere forwarders for their arguments.
541
542 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
543 This built-in function returns a pointer to data
544 describing how to perform a call with the same arguments as are passed
545 to the current function.
546
547 The function saves the arg pointer register, structure value address,
548 and all registers that might be used to pass arguments to a function
549 into a block of memory allocated on the stack. Then it returns the
550 address of that block.
551 @end deftypefn
552
553 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
554 This built-in function invokes @var{function}
555 with a copy of the parameters described by @var{arguments}
556 and @var{size}.
557
558 The value of @var{arguments} should be the value returned by
559 @code{__builtin_apply_args}. The argument @var{size} specifies the size
560 of the stack argument data, in bytes.
561
562 This function returns a pointer to data describing
563 how to return whatever value is returned by @var{function}. The data
564 is saved in a block of memory allocated on the stack.
565
566 It is not always simple to compute the proper value for @var{size}. The
567 value is used by @code{__builtin_apply} to compute the amount of data
568 that should be pushed on the stack and copied from the incoming argument
569 area.
570 @end deftypefn
571
572 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
573 This built-in function returns the value described by @var{result} from
574 the containing function. You should specify, for @var{result}, a value
575 returned by @code{__builtin_apply}.
576 @end deftypefn
577
578 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
579 This built-in function represents all anonymous arguments of an inline
580 function. It can be used only in inline functions that are always
581 inlined, never compiled as a separate function, such as those using
582 @code{__attribute__ ((__always_inline__))} or
583 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
584 It must be only passed as last argument to some other function
585 with variable arguments. This is useful for writing small wrapper
586 inlines for variable argument functions, when using preprocessor
587 macros is undesirable. For example:
588 @smallexample
589 extern int myprintf (FILE *f, const char *format, ...);
590 extern inline __attribute__ ((__gnu_inline__)) int
591 myprintf (FILE *f, const char *format, ...)
592 @{
593 int r = fprintf (f, "myprintf: ");
594 if (r < 0)
595 return r;
596 int s = fprintf (f, format, __builtin_va_arg_pack ());
597 if (s < 0)
598 return s;
599 return r + s;
600 @}
601 @end smallexample
602 @end deftypefn
603
604 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
605 This built-in function returns the number of anonymous arguments of
606 an inline function. It can be used only in inline functions that
607 are always inlined, never compiled as a separate function, such
608 as those using @code{__attribute__ ((__always_inline__))} or
609 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
610 For example following does link- or run-time checking of open
611 arguments for optimized code:
612 @smallexample
613 #ifdef __OPTIMIZE__
614 extern inline __attribute__((__gnu_inline__)) int
615 myopen (const char *path, int oflag, ...)
616 @{
617 if (__builtin_va_arg_pack_len () > 1)
618 warn_open_too_many_arguments ();
619
620 if (__builtin_constant_p (oflag))
621 @{
622 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
623 @{
624 warn_open_missing_mode ();
625 return __open_2 (path, oflag);
626 @}
627 return open (path, oflag, __builtin_va_arg_pack ());
628 @}
629
630 if (__builtin_va_arg_pack_len () < 1)
631 return __open_2 (path, oflag);
632
633 return open (path, oflag, __builtin_va_arg_pack ());
634 @}
635 #endif
636 @end smallexample
637 @end deftypefn
638
639 @node Typeof
640 @section Referring to a Type with @code{typeof}
641 @findex typeof
642 @findex sizeof
643 @cindex macros, types of arguments
644
645 Another way to refer to the type of an expression is with @code{typeof}.
646 The syntax of using of this keyword looks like @code{sizeof}, but the
647 construct acts semantically like a type name defined with @code{typedef}.
648
649 There are two ways of writing the argument to @code{typeof}: with an
650 expression or with a type. Here is an example with an expression:
651
652 @smallexample
653 typeof (x[0](1))
654 @end smallexample
655
656 @noindent
657 This assumes that @code{x} is an array of pointers to functions;
658 the type described is that of the values of the functions.
659
660 Here is an example with a typename as the argument:
661
662 @smallexample
663 typeof (int *)
664 @end smallexample
665
666 @noindent
667 Here the type described is that of pointers to @code{int}.
668
669 If you are writing a header file that must work when included in ISO C
670 programs, write @code{__typeof__} instead of @code{typeof}.
671 @xref{Alternate Keywords}.
672
673 A @code{typeof} construct can be used anywhere a typedef name can be
674 used. For example, you can use it in a declaration, in a cast, or inside
675 of @code{sizeof} or @code{typeof}.
676
677 The operand of @code{typeof} is evaluated for its side effects if and
678 only if it is an expression of variably modified type or the name of
679 such a type.
680
681 @code{typeof} is often useful in conjunction with
682 statement expressions (@pxref{Statement Exprs}).
683 Here is how the two together can
684 be used to define a safe ``maximum'' macro which operates on any
685 arithmetic type and evaluates each of its arguments exactly once:
686
687 @smallexample
688 #define max(a,b) \
689 (@{ typeof (a) _a = (a); \
690 typeof (b) _b = (b); \
691 _a > _b ? _a : _b; @})
692 @end smallexample
693
694 @cindex underscores in variables in macros
695 @cindex @samp{_} in variables in macros
696 @cindex local variables in macros
697 @cindex variables, local, in macros
698 @cindex macros, local variables in
699
700 The reason for using names that start with underscores for the local
701 variables is to avoid conflicts with variable names that occur within the
702 expressions that are substituted for @code{a} and @code{b}. Eventually we
703 hope to design a new form of declaration syntax that allows you to declare
704 variables whose scopes start only after their initializers; this will be a
705 more reliable way to prevent such conflicts.
706
707 @noindent
708 Some more examples of the use of @code{typeof}:
709
710 @itemize @bullet
711 @item
712 This declares @code{y} with the type of what @code{x} points to.
713
714 @smallexample
715 typeof (*x) y;
716 @end smallexample
717
718 @item
719 This declares @code{y} as an array of such values.
720
721 @smallexample
722 typeof (*x) y[4];
723 @end smallexample
724
725 @item
726 This declares @code{y} as an array of pointers to characters:
727
728 @smallexample
729 typeof (typeof (char *)[4]) y;
730 @end smallexample
731
732 @noindent
733 It is equivalent to the following traditional C declaration:
734
735 @smallexample
736 char *y[4];
737 @end smallexample
738
739 To see the meaning of the declaration using @code{typeof}, and why it
740 might be a useful way to write, rewrite it with these macros:
741
742 @smallexample
743 #define pointer(T) typeof(T *)
744 #define array(T, N) typeof(T [N])
745 @end smallexample
746
747 @noindent
748 Now the declaration can be rewritten this way:
749
750 @smallexample
751 array (pointer (char), 4) y;
752 @end smallexample
753
754 @noindent
755 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
756 pointers to @code{char}.
757 @end itemize
758
759 In GNU C, but not GNU C++, you may also declare the type of a variable
760 as @code{__auto_type}. In that case, the declaration must declare
761 only one variable, whose declarator must just be an identifier, the
762 declaration must be initialized, and the type of the variable is
763 determined by the initializer; the name of the variable is not in
764 scope until after the initializer. (In C++, you should use C++11
765 @code{auto} for this purpose.) Using @code{__auto_type}, the
766 ``maximum'' macro above could be written as:
767
768 @smallexample
769 #define max(a,b) \
770 (@{ __auto_type _a = (a); \
771 __auto_type _b = (b); \
772 _a > _b ? _a : _b; @})
773 @end smallexample
774
775 Using @code{__auto_type} instead of @code{typeof} has two advantages:
776
777 @itemize @bullet
778 @item Each argument to the macro appears only once in the expansion of
779 the macro. This prevents the size of the macro expansion growing
780 exponentially when calls to such macros are nested inside arguments of
781 such macros.
782
783 @item If the argument to the macro has variably modified type, it is
784 evaluated only once when using @code{__auto_type}, but twice if
785 @code{typeof} is used.
786 @end itemize
787
788 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
789 a more limited extension that permitted one to write
790
791 @smallexample
792 typedef @var{T} = @var{expr};
793 @end smallexample
794
795 @noindent
796 with the effect of declaring @var{T} to have the type of the expression
797 @var{expr}. This extension does not work with GCC 3 (versions between
798 3.0 and 3.2 crash; 3.2.1 and later give an error). Code that
799 relies on it should be rewritten to use @code{typeof}:
800
801 @smallexample
802 typedef typeof(@var{expr}) @var{T};
803 @end smallexample
804
805 @noindent
806 This works with all versions of GCC@.
807
808 @node Conditionals
809 @section Conditionals with Omitted Operands
810 @cindex conditional expressions, extensions
811 @cindex omitted middle-operands
812 @cindex middle-operands, omitted
813 @cindex extensions, @code{?:}
814 @cindex @code{?:} extensions
815
816 The middle operand in a conditional expression may be omitted. Then
817 if the first operand is nonzero, its value is the value of the conditional
818 expression.
819
820 Therefore, the expression
821
822 @smallexample
823 x ? : y
824 @end smallexample
825
826 @noindent
827 has the value of @code{x} if that is nonzero; otherwise, the value of
828 @code{y}.
829
830 This example is perfectly equivalent to
831
832 @smallexample
833 x ? x : y
834 @end smallexample
835
836 @cindex side effect in @code{?:}
837 @cindex @code{?:} side effect
838 @noindent
839 In this simple case, the ability to omit the middle operand is not
840 especially useful. When it becomes useful is when the first operand does,
841 or may (if it is a macro argument), contain a side effect. Then repeating
842 the operand in the middle would perform the side effect twice. Omitting
843 the middle operand uses the value already computed without the undesirable
844 effects of recomputing it.
845
846 @node __int128
847 @section 128-bit integers
848 @cindex @code{__int128} data types
849
850 As an extension the integer scalar type @code{__int128} is supported for
851 targets which have an integer mode wide enough to hold 128 bits.
852 Simply write @code{__int128} for a signed 128-bit integer, or
853 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
854 support in GCC for expressing an integer constant of type @code{__int128}
855 for targets with @code{long long} integer less than 128 bits wide.
856
857 @node Long Long
858 @section Double-Word Integers
859 @cindex @code{long long} data types
860 @cindex double-word arithmetic
861 @cindex multiprecision arithmetic
862 @cindex @code{LL} integer suffix
863 @cindex @code{ULL} integer suffix
864
865 ISO C99 supports data types for integers that are at least 64 bits wide,
866 and as an extension GCC supports them in C90 mode and in C++.
867 Simply write @code{long long int} for a signed integer, or
868 @code{unsigned long long int} for an unsigned integer. To make an
869 integer constant of type @code{long long int}, add the suffix @samp{LL}
870 to the integer. To make an integer constant of type @code{unsigned long
871 long int}, add the suffix @samp{ULL} to the integer.
872
873 You can use these types in arithmetic like any other integer types.
874 Addition, subtraction, and bitwise boolean operations on these types
875 are open-coded on all types of machines. Multiplication is open-coded
876 if the machine supports a fullword-to-doubleword widening multiply
877 instruction. Division and shifts are open-coded only on machines that
878 provide special support. The operations that are not open-coded use
879 special library routines that come with GCC@.
880
881 There may be pitfalls when you use @code{long long} types for function
882 arguments without function prototypes. If a function
883 expects type @code{int} for its argument, and you pass a value of type
884 @code{long long int}, confusion results because the caller and the
885 subroutine disagree about the number of bytes for the argument.
886 Likewise, if the function expects @code{long long int} and you pass
887 @code{int}. The best way to avoid such problems is to use prototypes.
888
889 @node Complex
890 @section Complex Numbers
891 @cindex complex numbers
892 @cindex @code{_Complex} keyword
893 @cindex @code{__complex__} keyword
894
895 ISO C99 supports complex floating data types, and as an extension GCC
896 supports them in C90 mode and in C++. GCC also supports complex integer data
897 types which are not part of ISO C99. You can declare complex types
898 using the keyword @code{_Complex}. As an extension, the older GNU
899 keyword @code{__complex__} is also supported.
900
901 For example, @samp{_Complex double x;} declares @code{x} as a
902 variable whose real part and imaginary part are both of type
903 @code{double}. @samp{_Complex short int y;} declares @code{y} to
904 have real and imaginary parts of type @code{short int}; this is not
905 likely to be useful, but it shows that the set of complex types is
906 complete.
907
908 To write a constant with a complex data type, use the suffix @samp{i} or
909 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
910 has type @code{_Complex float} and @code{3i} has type
911 @code{_Complex int}. Such a constant always has a pure imaginary
912 value, but you can form any complex value you like by adding one to a
913 real constant. This is a GNU extension; if you have an ISO C99
914 conforming C library (such as the GNU C Library), and want to construct complex
915 constants of floating type, you should include @code{<complex.h>} and
916 use the macros @code{I} or @code{_Complex_I} instead.
917
918 @cindex @code{__real__} keyword
919 @cindex @code{__imag__} keyword
920 To extract the real part of a complex-valued expression @var{exp}, write
921 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
922 extract the imaginary part. This is a GNU extension; for values of
923 floating type, you should use the ISO C99 functions @code{crealf},
924 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
925 @code{cimagl}, declared in @code{<complex.h>} and also provided as
926 built-in functions by GCC@.
927
928 @cindex complex conjugation
929 The operator @samp{~} performs complex conjugation when used on a value
930 with a complex type. This is a GNU extension; for values of
931 floating type, you should use the ISO C99 functions @code{conjf},
932 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
933 provided as built-in functions by GCC@.
934
935 GCC can allocate complex automatic variables in a noncontiguous
936 fashion; it's even possible for the real part to be in a register while
937 the imaginary part is on the stack (or vice versa). Only the DWARF 2
938 debug info format can represent this, so use of DWARF 2 is recommended.
939 If you are using the stabs debug info format, GCC describes a noncontiguous
940 complex variable as if it were two separate variables of noncomplex type.
941 If the variable's actual name is @code{foo}, the two fictitious
942 variables are named @code{foo$real} and @code{foo$imag}. You can
943 examine and set these two fictitious variables with your debugger.
944
945 @node Floating Types
946 @section Additional Floating Types
947 @cindex additional floating types
948 @cindex @code{__float80} data type
949 @cindex @code{__float128} data type
950 @cindex @code{w} floating point suffix
951 @cindex @code{q} floating point suffix
952 @cindex @code{W} floating point suffix
953 @cindex @code{Q} floating point suffix
954
955 As an extension, GNU C supports additional floating
956 types, @code{__float80} and @code{__float128} to support 80-bit
957 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
958 Support for additional types includes the arithmetic operators:
959 add, subtract, multiply, divide; unary arithmetic operators;
960 relational operators; equality operators; and conversions to and from
961 integer and other floating types. Use a suffix @samp{w} or @samp{W}
962 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
963 for @code{_float128}. You can declare complex types using the
964 corresponding internal complex type, @code{XCmode} for @code{__float80}
965 type and @code{TCmode} for @code{__float128} type:
966
967 @smallexample
968 typedef _Complex float __attribute__((mode(TC))) _Complex128;
969 typedef _Complex float __attribute__((mode(XC))) _Complex80;
970 @end smallexample
971
972 Not all targets support additional floating-point types. @code{__float80}
973 and @code{__float128} types are supported on i386, x86_64 and IA-64 targets.
974 The @code{__float128} type is supported on hppa HP-UX targets.
975
976 @node Half-Precision
977 @section Half-Precision Floating Point
978 @cindex half-precision floating point
979 @cindex @code{__fp16} data type
980
981 On ARM targets, GCC supports half-precision (16-bit) floating point via
982 the @code{__fp16} type. You must enable this type explicitly
983 with the @option{-mfp16-format} command-line option in order to use it.
984
985 ARM supports two incompatible representations for half-precision
986 floating-point values. You must choose one of the representations and
987 use it consistently in your program.
988
989 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
990 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
991 There are 11 bits of significand precision, approximately 3
992 decimal digits.
993
994 Specifying @option{-mfp16-format=alternative} selects the ARM
995 alternative format. This representation is similar to the IEEE
996 format, but does not support infinities or NaNs. Instead, the range
997 of exponents is extended, so that this format can represent normalized
998 values in the range of @math{2^{-14}} to 131008.
999
1000 The @code{__fp16} type is a storage format only. For purposes
1001 of arithmetic and other operations, @code{__fp16} values in C or C++
1002 expressions are automatically promoted to @code{float}. In addition,
1003 you cannot declare a function with a return value or parameters
1004 of type @code{__fp16}.
1005
1006 Note that conversions from @code{double} to @code{__fp16}
1007 involve an intermediate conversion to @code{float}. Because
1008 of rounding, this can sometimes produce a different result than a
1009 direct conversion.
1010
1011 ARM provides hardware support for conversions between
1012 @code{__fp16} and @code{float} values
1013 as an extension to VFP and NEON (Advanced SIMD). GCC generates
1014 code using these hardware instructions if you compile with
1015 options to select an FPU that provides them;
1016 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1017 in addition to the @option{-mfp16-format} option to select
1018 a half-precision format.
1019
1020 Language-level support for the @code{__fp16} data type is
1021 independent of whether GCC generates code using hardware floating-point
1022 instructions. In cases where hardware support is not specified, GCC
1023 implements conversions between @code{__fp16} and @code{float} values
1024 as library calls.
1025
1026 @node Decimal Float
1027 @section Decimal Floating Types
1028 @cindex decimal floating types
1029 @cindex @code{_Decimal32} data type
1030 @cindex @code{_Decimal64} data type
1031 @cindex @code{_Decimal128} data type
1032 @cindex @code{df} integer suffix
1033 @cindex @code{dd} integer suffix
1034 @cindex @code{dl} integer suffix
1035 @cindex @code{DF} integer suffix
1036 @cindex @code{DD} integer suffix
1037 @cindex @code{DL} integer suffix
1038
1039 As an extension, GNU C supports decimal floating types as
1040 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1041 floating types in GCC will evolve as the draft technical report changes.
1042 Calling conventions for any target might also change. Not all targets
1043 support decimal floating types.
1044
1045 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1046 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1047 @code{float}, @code{double}, and @code{long double} whose radix is not
1048 specified by the C standard but is usually two.
1049
1050 Support for decimal floating types includes the arithmetic operators
1051 add, subtract, multiply, divide; unary arithmetic operators;
1052 relational operators; equality operators; and conversions to and from
1053 integer and other floating types. Use a suffix @samp{df} or
1054 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1055 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1056 @code{_Decimal128}.
1057
1058 GCC support of decimal float as specified by the draft technical report
1059 is incomplete:
1060
1061 @itemize @bullet
1062 @item
1063 When the value of a decimal floating type cannot be represented in the
1064 integer type to which it is being converted, the result is undefined
1065 rather than the result value specified by the draft technical report.
1066
1067 @item
1068 GCC does not provide the C library functionality associated with
1069 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1070 @file{wchar.h}, which must come from a separate C library implementation.
1071 Because of this the GNU C compiler does not define macro
1072 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1073 the technical report.
1074 @end itemize
1075
1076 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1077 are supported by the DWARF 2 debug information format.
1078
1079 @node Hex Floats
1080 @section Hex Floats
1081 @cindex hex floats
1082
1083 ISO C99 supports floating-point numbers written not only in the usual
1084 decimal notation, such as @code{1.55e1}, but also numbers such as
1085 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1086 supports this in C90 mode (except in some cases when strictly
1087 conforming) and in C++. In that format the
1088 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1089 mandatory. The exponent is a decimal number that indicates the power of
1090 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1091 @tex
1092 $1 {15\over16}$,
1093 @end tex
1094 @ifnottex
1095 1 15/16,
1096 @end ifnottex
1097 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1098 is the same as @code{1.55e1}.
1099
1100 Unlike for floating-point numbers in the decimal notation the exponent
1101 is always required in the hexadecimal notation. Otherwise the compiler
1102 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1103 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1104 extension for floating-point constants of type @code{float}.
1105
1106 @node Fixed-Point
1107 @section Fixed-Point Types
1108 @cindex fixed-point types
1109 @cindex @code{_Fract} data type
1110 @cindex @code{_Accum} data type
1111 @cindex @code{_Sat} data type
1112 @cindex @code{hr} fixed-suffix
1113 @cindex @code{r} fixed-suffix
1114 @cindex @code{lr} fixed-suffix
1115 @cindex @code{llr} fixed-suffix
1116 @cindex @code{uhr} fixed-suffix
1117 @cindex @code{ur} fixed-suffix
1118 @cindex @code{ulr} fixed-suffix
1119 @cindex @code{ullr} fixed-suffix
1120 @cindex @code{hk} fixed-suffix
1121 @cindex @code{k} fixed-suffix
1122 @cindex @code{lk} fixed-suffix
1123 @cindex @code{llk} fixed-suffix
1124 @cindex @code{uhk} fixed-suffix
1125 @cindex @code{uk} fixed-suffix
1126 @cindex @code{ulk} fixed-suffix
1127 @cindex @code{ullk} fixed-suffix
1128 @cindex @code{HR} fixed-suffix
1129 @cindex @code{R} fixed-suffix
1130 @cindex @code{LR} fixed-suffix
1131 @cindex @code{LLR} fixed-suffix
1132 @cindex @code{UHR} fixed-suffix
1133 @cindex @code{UR} fixed-suffix
1134 @cindex @code{ULR} fixed-suffix
1135 @cindex @code{ULLR} fixed-suffix
1136 @cindex @code{HK} fixed-suffix
1137 @cindex @code{K} fixed-suffix
1138 @cindex @code{LK} fixed-suffix
1139 @cindex @code{LLK} fixed-suffix
1140 @cindex @code{UHK} fixed-suffix
1141 @cindex @code{UK} fixed-suffix
1142 @cindex @code{ULK} fixed-suffix
1143 @cindex @code{ULLK} fixed-suffix
1144
1145 As an extension, GNU C supports fixed-point types as
1146 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1147 types in GCC will evolve as the draft technical report changes.
1148 Calling conventions for any target might also change. Not all targets
1149 support fixed-point types.
1150
1151 The fixed-point types are
1152 @code{short _Fract},
1153 @code{_Fract},
1154 @code{long _Fract},
1155 @code{long long _Fract},
1156 @code{unsigned short _Fract},
1157 @code{unsigned _Fract},
1158 @code{unsigned long _Fract},
1159 @code{unsigned long long _Fract},
1160 @code{_Sat short _Fract},
1161 @code{_Sat _Fract},
1162 @code{_Sat long _Fract},
1163 @code{_Sat long long _Fract},
1164 @code{_Sat unsigned short _Fract},
1165 @code{_Sat unsigned _Fract},
1166 @code{_Sat unsigned long _Fract},
1167 @code{_Sat unsigned long long _Fract},
1168 @code{short _Accum},
1169 @code{_Accum},
1170 @code{long _Accum},
1171 @code{long long _Accum},
1172 @code{unsigned short _Accum},
1173 @code{unsigned _Accum},
1174 @code{unsigned long _Accum},
1175 @code{unsigned long long _Accum},
1176 @code{_Sat short _Accum},
1177 @code{_Sat _Accum},
1178 @code{_Sat long _Accum},
1179 @code{_Sat long long _Accum},
1180 @code{_Sat unsigned short _Accum},
1181 @code{_Sat unsigned _Accum},
1182 @code{_Sat unsigned long _Accum},
1183 @code{_Sat unsigned long long _Accum}.
1184
1185 Fixed-point data values contain fractional and optional integral parts.
1186 The format of fixed-point data varies and depends on the target machine.
1187
1188 Support for fixed-point types includes:
1189 @itemize @bullet
1190 @item
1191 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1192 @item
1193 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1194 @item
1195 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1196 @item
1197 binary shift operators (@code{<<}, @code{>>})
1198 @item
1199 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1200 @item
1201 equality operators (@code{==}, @code{!=})
1202 @item
1203 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1204 @code{<<=}, @code{>>=})
1205 @item
1206 conversions to and from integer, floating-point, or fixed-point types
1207 @end itemize
1208
1209 Use a suffix in a fixed-point literal constant:
1210 @itemize
1211 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1212 @code{_Sat short _Fract}
1213 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1214 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1215 @code{_Sat long _Fract}
1216 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1217 @code{_Sat long long _Fract}
1218 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1219 @code{_Sat unsigned short _Fract}
1220 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1221 @code{_Sat unsigned _Fract}
1222 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1223 @code{_Sat unsigned long _Fract}
1224 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1225 and @code{_Sat unsigned long long _Fract}
1226 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1227 @code{_Sat short _Accum}
1228 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1229 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1230 @code{_Sat long _Accum}
1231 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1232 @code{_Sat long long _Accum}
1233 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1234 @code{_Sat unsigned short _Accum}
1235 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1236 @code{_Sat unsigned _Accum}
1237 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1238 @code{_Sat unsigned long _Accum}
1239 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1240 and @code{_Sat unsigned long long _Accum}
1241 @end itemize
1242
1243 GCC support of fixed-point types as specified by the draft technical report
1244 is incomplete:
1245
1246 @itemize @bullet
1247 @item
1248 Pragmas to control overflow and rounding behaviors are not implemented.
1249 @end itemize
1250
1251 Fixed-point types are supported by the DWARF 2 debug information format.
1252
1253 @node Named Address Spaces
1254 @section Named Address Spaces
1255 @cindex Named Address Spaces
1256
1257 As an extension, GNU C supports named address spaces as
1258 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1259 address spaces in GCC will evolve as the draft technical report
1260 changes. Calling conventions for any target might also change. At
1261 present, only the AVR, SPU, M32C, and RL78 targets support address
1262 spaces other than the generic address space.
1263
1264 Address space identifiers may be used exactly like any other C type
1265 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1266 document for more details.
1267
1268 @anchor{AVR Named Address Spaces}
1269 @subsection AVR Named Address Spaces
1270
1271 On the AVR target, there are several address spaces that can be used
1272 in order to put read-only data into the flash memory and access that
1273 data by means of the special instructions @code{LPM} or @code{ELPM}
1274 needed to read from flash.
1275
1276 Per default, any data including read-only data is located in RAM
1277 (the generic address space) so that non-generic address spaces are
1278 needed to locate read-only data in flash memory
1279 @emph{and} to generate the right instructions to access this data
1280 without using (inline) assembler code.
1281
1282 @table @code
1283 @item __flash
1284 @cindex @code{__flash} AVR Named Address Spaces
1285 The @code{__flash} qualifier locates data in the
1286 @code{.progmem.data} section. Data is read using the @code{LPM}
1287 instruction. Pointers to this address space are 16 bits wide.
1288
1289 @item __flash1
1290 @itemx __flash2
1291 @itemx __flash3
1292 @itemx __flash4
1293 @itemx __flash5
1294 @cindex @code{__flash1} AVR Named Address Spaces
1295 @cindex @code{__flash2} AVR Named Address Spaces
1296 @cindex @code{__flash3} AVR Named Address Spaces
1297 @cindex @code{__flash4} AVR Named Address Spaces
1298 @cindex @code{__flash5} AVR Named Address Spaces
1299 These are 16-bit address spaces locating data in section
1300 @code{.progmem@var{N}.data} where @var{N} refers to
1301 address space @code{__flash@var{N}}.
1302 The compiler sets the @code{RAMPZ} segment register appropriately
1303 before reading data by means of the @code{ELPM} instruction.
1304
1305 @item __memx
1306 @cindex @code{__memx} AVR Named Address Spaces
1307 This is a 24-bit address space that linearizes flash and RAM:
1308 If the high bit of the address is set, data is read from
1309 RAM using the lower two bytes as RAM address.
1310 If the high bit of the address is clear, data is read from flash
1311 with @code{RAMPZ} set according to the high byte of the address.
1312 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1313
1314 Objects in this address space are located in @code{.progmemx.data}.
1315 @end table
1316
1317 @b{Example}
1318
1319 @smallexample
1320 char my_read (const __flash char ** p)
1321 @{
1322 /* p is a pointer to RAM that points to a pointer to flash.
1323 The first indirection of p reads that flash pointer
1324 from RAM and the second indirection reads a char from this
1325 flash address. */
1326
1327 return **p;
1328 @}
1329
1330 /* Locate array[] in flash memory */
1331 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1332
1333 int i = 1;
1334
1335 int main (void)
1336 @{
1337 /* Return 17 by reading from flash memory */
1338 return array[array[i]];
1339 @}
1340 @end smallexample
1341
1342 @noindent
1343 For each named address space supported by avr-gcc there is an equally
1344 named but uppercase built-in macro defined.
1345 The purpose is to facilitate testing if respective address space
1346 support is available or not:
1347
1348 @smallexample
1349 #ifdef __FLASH
1350 const __flash int var = 1;
1351
1352 int read_var (void)
1353 @{
1354 return var;
1355 @}
1356 #else
1357 #include <avr/pgmspace.h> /* From AVR-LibC */
1358
1359 const int var PROGMEM = 1;
1360
1361 int read_var (void)
1362 @{
1363 return (int) pgm_read_word (&var);
1364 @}
1365 #endif /* __FLASH */
1366 @end smallexample
1367
1368 @noindent
1369 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1370 locates data in flash but
1371 accesses to these data read from generic address space, i.e.@:
1372 from RAM,
1373 so that you need special accessors like @code{pgm_read_byte}
1374 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1375 together with attribute @code{progmem}.
1376
1377 @noindent
1378 @b{Limitations and caveats}
1379
1380 @itemize
1381 @item
1382 Reading across the 64@tie{}KiB section boundary of
1383 the @code{__flash} or @code{__flash@var{N}} address spaces
1384 shows undefined behavior. The only address space that
1385 supports reading across the 64@tie{}KiB flash segment boundaries is
1386 @code{__memx}.
1387
1388 @item
1389 If you use one of the @code{__flash@var{N}} address spaces
1390 you must arrange your linker script to locate the
1391 @code{.progmem@var{N}.data} sections according to your needs.
1392
1393 @item
1394 Any data or pointers to the non-generic address spaces must
1395 be qualified as @code{const}, i.e.@: as read-only data.
1396 This still applies if the data in one of these address
1397 spaces like software version number or calibration lookup table are intended to
1398 be changed after load time by, say, a boot loader. In this case
1399 the right qualification is @code{const} @code{volatile} so that the compiler
1400 must not optimize away known values or insert them
1401 as immediates into operands of instructions.
1402
1403 @item
1404 The following code initializes a variable @code{pfoo}
1405 located in static storage with a 24-bit address:
1406 @smallexample
1407 extern const __memx char foo;
1408 const __memx void *pfoo = &foo;
1409 @end smallexample
1410
1411 @noindent
1412 Such code requires at least binutils 2.23, see
1413 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1414
1415 @end itemize
1416
1417 @subsection M32C Named Address Spaces
1418 @cindex @code{__far} M32C Named Address Spaces
1419
1420 On the M32C target, with the R8C and M16C CPU variants, variables
1421 qualified with @code{__far} are accessed using 32-bit addresses in
1422 order to access memory beyond the first 64@tie{}Ki bytes. If
1423 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1424 effect.
1425
1426 @subsection RL78 Named Address Spaces
1427 @cindex @code{__far} RL78 Named Address Spaces
1428
1429 On the RL78 target, variables qualified with @code{__far} are accessed
1430 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1431 addresses. Non-far variables are assumed to appear in the topmost
1432 64@tie{}KiB of the address space.
1433
1434 @subsection SPU Named Address Spaces
1435 @cindex @code{__ea} SPU Named Address Spaces
1436
1437 On the SPU target variables may be declared as
1438 belonging to another address space by qualifying the type with the
1439 @code{__ea} address space identifier:
1440
1441 @smallexample
1442 extern int __ea i;
1443 @end smallexample
1444
1445 @noindent
1446 The compiler generates special code to access the variable @code{i}.
1447 It may use runtime library
1448 support, or generate special machine instructions to access that address
1449 space.
1450
1451 @node Zero Length
1452 @section Arrays of Length Zero
1453 @cindex arrays of length zero
1454 @cindex zero-length arrays
1455 @cindex length-zero arrays
1456 @cindex flexible array members
1457
1458 Zero-length arrays are allowed in GNU C@. They are very useful as the
1459 last element of a structure that is really a header for a variable-length
1460 object:
1461
1462 @smallexample
1463 struct line @{
1464 int length;
1465 char contents[0];
1466 @};
1467
1468 struct line *thisline = (struct line *)
1469 malloc (sizeof (struct line) + this_length);
1470 thisline->length = this_length;
1471 @end smallexample
1472
1473 In ISO C90, you would have to give @code{contents} a length of 1, which
1474 means either you waste space or complicate the argument to @code{malloc}.
1475
1476 In ISO C99, you would use a @dfn{flexible array member}, which is
1477 slightly different in syntax and semantics:
1478
1479 @itemize @bullet
1480 @item
1481 Flexible array members are written as @code{contents[]} without
1482 the @code{0}.
1483
1484 @item
1485 Flexible array members have incomplete type, and so the @code{sizeof}
1486 operator may not be applied. As a quirk of the original implementation
1487 of zero-length arrays, @code{sizeof} evaluates to zero.
1488
1489 @item
1490 Flexible array members may only appear as the last member of a
1491 @code{struct} that is otherwise non-empty.
1492
1493 @item
1494 A structure containing a flexible array member, or a union containing
1495 such a structure (possibly recursively), may not be a member of a
1496 structure or an element of an array. (However, these uses are
1497 permitted by GCC as extensions.)
1498 @end itemize
1499
1500 GCC versions before 3.0 allowed zero-length arrays to be statically
1501 initialized, as if they were flexible arrays. In addition to those
1502 cases that were useful, it also allowed initializations in situations
1503 that would corrupt later data. Non-empty initialization of zero-length
1504 arrays is now treated like any case where there are more initializer
1505 elements than the array holds, in that a suitable warning about ``excess
1506 elements in array'' is given, and the excess elements (all of them, in
1507 this case) are ignored.
1508
1509 Instead GCC allows static initialization of flexible array members.
1510 This is equivalent to defining a new structure containing the original
1511 structure followed by an array of sufficient size to contain the data.
1512 E.g.@: in the following, @code{f1} is constructed as if it were declared
1513 like @code{f2}.
1514
1515 @smallexample
1516 struct f1 @{
1517 int x; int y[];
1518 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1519
1520 struct f2 @{
1521 struct f1 f1; int data[3];
1522 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1523 @end smallexample
1524
1525 @noindent
1526 The convenience of this extension is that @code{f1} has the desired
1527 type, eliminating the need to consistently refer to @code{f2.f1}.
1528
1529 This has symmetry with normal static arrays, in that an array of
1530 unknown size is also written with @code{[]}.
1531
1532 Of course, this extension only makes sense if the extra data comes at
1533 the end of a top-level object, as otherwise we would be overwriting
1534 data at subsequent offsets. To avoid undue complication and confusion
1535 with initialization of deeply nested arrays, we simply disallow any
1536 non-empty initialization except when the structure is the top-level
1537 object. For example:
1538
1539 @smallexample
1540 struct foo @{ int x; int y[]; @};
1541 struct bar @{ struct foo z; @};
1542
1543 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1544 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1545 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1546 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1547 @end smallexample
1548
1549 @node Empty Structures
1550 @section Structures With No Members
1551 @cindex empty structures
1552 @cindex zero-size structures
1553
1554 GCC permits a C structure to have no members:
1555
1556 @smallexample
1557 struct empty @{
1558 @};
1559 @end smallexample
1560
1561 The structure has size zero. In C++, empty structures are part
1562 of the language. G++ treats empty structures as if they had a single
1563 member of type @code{char}.
1564
1565 @node Variable Length
1566 @section Arrays of Variable Length
1567 @cindex variable-length arrays
1568 @cindex arrays of variable length
1569 @cindex VLAs
1570
1571 Variable-length automatic arrays are allowed in ISO C99, and as an
1572 extension GCC accepts them in C90 mode and in C++. These arrays are
1573 declared like any other automatic arrays, but with a length that is not
1574 a constant expression. The storage is allocated at the point of
1575 declaration and deallocated when the block scope containing the declaration
1576 exits. For
1577 example:
1578
1579 @smallexample
1580 FILE *
1581 concat_fopen (char *s1, char *s2, char *mode)
1582 @{
1583 char str[strlen (s1) + strlen (s2) + 1];
1584 strcpy (str, s1);
1585 strcat (str, s2);
1586 return fopen (str, mode);
1587 @}
1588 @end smallexample
1589
1590 @cindex scope of a variable length array
1591 @cindex variable-length array scope
1592 @cindex deallocating variable length arrays
1593 Jumping or breaking out of the scope of the array name deallocates the
1594 storage. Jumping into the scope is not allowed; you get an error
1595 message for it.
1596
1597 @cindex variable-length array in a structure
1598 As an extension, GCC accepts variable-length arrays as a member of
1599 a structure or a union. For example:
1600
1601 @smallexample
1602 void
1603 foo (int n)
1604 @{
1605 struct S @{ int x[n]; @};
1606 @}
1607 @end smallexample
1608
1609 @cindex @code{alloca} vs variable-length arrays
1610 You can use the function @code{alloca} to get an effect much like
1611 variable-length arrays. The function @code{alloca} is available in
1612 many other C implementations (but not in all). On the other hand,
1613 variable-length arrays are more elegant.
1614
1615 There are other differences between these two methods. Space allocated
1616 with @code{alloca} exists until the containing @emph{function} returns.
1617 The space for a variable-length array is deallocated as soon as the array
1618 name's scope ends. (If you use both variable-length arrays and
1619 @code{alloca} in the same function, deallocation of a variable-length array
1620 also deallocates anything more recently allocated with @code{alloca}.)
1621
1622 You can also use variable-length arrays as arguments to functions:
1623
1624 @smallexample
1625 struct entry
1626 tester (int len, char data[len][len])
1627 @{
1628 /* @r{@dots{}} */
1629 @}
1630 @end smallexample
1631
1632 The length of an array is computed once when the storage is allocated
1633 and is remembered for the scope of the array in case you access it with
1634 @code{sizeof}.
1635
1636 If you want to pass the array first and the length afterward, you can
1637 use a forward declaration in the parameter list---another GNU extension.
1638
1639 @smallexample
1640 struct entry
1641 tester (int len; char data[len][len], int len)
1642 @{
1643 /* @r{@dots{}} */
1644 @}
1645 @end smallexample
1646
1647 @cindex parameter forward declaration
1648 The @samp{int len} before the semicolon is a @dfn{parameter forward
1649 declaration}, and it serves the purpose of making the name @code{len}
1650 known when the declaration of @code{data} is parsed.
1651
1652 You can write any number of such parameter forward declarations in the
1653 parameter list. They can be separated by commas or semicolons, but the
1654 last one must end with a semicolon, which is followed by the ``real''
1655 parameter declarations. Each forward declaration must match a ``real''
1656 declaration in parameter name and data type. ISO C99 does not support
1657 parameter forward declarations.
1658
1659 @node Variadic Macros
1660 @section Macros with a Variable Number of Arguments.
1661 @cindex variable number of arguments
1662 @cindex macro with variable arguments
1663 @cindex rest argument (in macro)
1664 @cindex variadic macros
1665
1666 In the ISO C standard of 1999, a macro can be declared to accept a
1667 variable number of arguments much as a function can. The syntax for
1668 defining the macro is similar to that of a function. Here is an
1669 example:
1670
1671 @smallexample
1672 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1673 @end smallexample
1674
1675 @noindent
1676 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1677 such a macro, it represents the zero or more tokens until the closing
1678 parenthesis that ends the invocation, including any commas. This set of
1679 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1680 wherever it appears. See the CPP manual for more information.
1681
1682 GCC has long supported variadic macros, and used a different syntax that
1683 allowed you to give a name to the variable arguments just like any other
1684 argument. Here is an example:
1685
1686 @smallexample
1687 #define debug(format, args...) fprintf (stderr, format, args)
1688 @end smallexample
1689
1690 @noindent
1691 This is in all ways equivalent to the ISO C example above, but arguably
1692 more readable and descriptive.
1693
1694 GNU CPP has two further variadic macro extensions, and permits them to
1695 be used with either of the above forms of macro definition.
1696
1697 In standard C, you are not allowed to leave the variable argument out
1698 entirely; but you are allowed to pass an empty argument. For example,
1699 this invocation is invalid in ISO C, because there is no comma after
1700 the string:
1701
1702 @smallexample
1703 debug ("A message")
1704 @end smallexample
1705
1706 GNU CPP permits you to completely omit the variable arguments in this
1707 way. In the above examples, the compiler would complain, though since
1708 the expansion of the macro still has the extra comma after the format
1709 string.
1710
1711 To help solve this problem, CPP behaves specially for variable arguments
1712 used with the token paste operator, @samp{##}. If instead you write
1713
1714 @smallexample
1715 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1716 @end smallexample
1717
1718 @noindent
1719 and if the variable arguments are omitted or empty, the @samp{##}
1720 operator causes the preprocessor to remove the comma before it. If you
1721 do provide some variable arguments in your macro invocation, GNU CPP
1722 does not complain about the paste operation and instead places the
1723 variable arguments after the comma. Just like any other pasted macro
1724 argument, these arguments are not macro expanded.
1725
1726 @node Escaped Newlines
1727 @section Slightly Looser Rules for Escaped Newlines
1728 @cindex escaped newlines
1729 @cindex newlines (escaped)
1730
1731 Recently, the preprocessor has relaxed its treatment of escaped
1732 newlines. Previously, the newline had to immediately follow a
1733 backslash. The current implementation allows whitespace in the form
1734 of spaces, horizontal and vertical tabs, and form feeds between the
1735 backslash and the subsequent newline. The preprocessor issues a
1736 warning, but treats it as a valid escaped newline and combines the two
1737 lines to form a single logical line. This works within comments and
1738 tokens, as well as between tokens. Comments are @emph{not} treated as
1739 whitespace for the purposes of this relaxation, since they have not
1740 yet been replaced with spaces.
1741
1742 @node Subscripting
1743 @section Non-Lvalue Arrays May Have Subscripts
1744 @cindex subscripting
1745 @cindex arrays, non-lvalue
1746
1747 @cindex subscripting and function values
1748 In ISO C99, arrays that are not lvalues still decay to pointers, and
1749 may be subscripted, although they may not be modified or used after
1750 the next sequence point and the unary @samp{&} operator may not be
1751 applied to them. As an extension, GNU C allows such arrays to be
1752 subscripted in C90 mode, though otherwise they do not decay to
1753 pointers outside C99 mode. For example,
1754 this is valid in GNU C though not valid in C90:
1755
1756 @smallexample
1757 @group
1758 struct foo @{int a[4];@};
1759
1760 struct foo f();
1761
1762 bar (int index)
1763 @{
1764 return f().a[index];
1765 @}
1766 @end group
1767 @end smallexample
1768
1769 @node Pointer Arith
1770 @section Arithmetic on @code{void}- and Function-Pointers
1771 @cindex void pointers, arithmetic
1772 @cindex void, size of pointer to
1773 @cindex function pointers, arithmetic
1774 @cindex function, size of pointer to
1775
1776 In GNU C, addition and subtraction operations are supported on pointers to
1777 @code{void} and on pointers to functions. This is done by treating the
1778 size of a @code{void} or of a function as 1.
1779
1780 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1781 and on function types, and returns 1.
1782
1783 @opindex Wpointer-arith
1784 The option @option{-Wpointer-arith} requests a warning if these extensions
1785 are used.
1786
1787 @node Initializers
1788 @section Non-Constant Initializers
1789 @cindex initializers, non-constant
1790 @cindex non-constant initializers
1791
1792 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1793 automatic variable are not required to be constant expressions in GNU C@.
1794 Here is an example of an initializer with run-time varying elements:
1795
1796 @smallexample
1797 foo (float f, float g)
1798 @{
1799 float beat_freqs[2] = @{ f-g, f+g @};
1800 /* @r{@dots{}} */
1801 @}
1802 @end smallexample
1803
1804 @node Compound Literals
1805 @section Compound Literals
1806 @cindex constructor expressions
1807 @cindex initializations in expressions
1808 @cindex structures, constructor expression
1809 @cindex expressions, constructor
1810 @cindex compound literals
1811 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1812
1813 ISO C99 supports compound literals. A compound literal looks like
1814 a cast containing an initializer. Its value is an object of the
1815 type specified in the cast, containing the elements specified in
1816 the initializer; it is an lvalue. As an extension, GCC supports
1817 compound literals in C90 mode and in C++, though the semantics are
1818 somewhat different in C++.
1819
1820 Usually, the specified type is a structure. Assume that
1821 @code{struct foo} and @code{structure} are declared as shown:
1822
1823 @smallexample
1824 struct foo @{int a; char b[2];@} structure;
1825 @end smallexample
1826
1827 @noindent
1828 Here is an example of constructing a @code{struct foo} with a compound literal:
1829
1830 @smallexample
1831 structure = ((struct foo) @{x + y, 'a', 0@});
1832 @end smallexample
1833
1834 @noindent
1835 This is equivalent to writing the following:
1836
1837 @smallexample
1838 @{
1839 struct foo temp = @{x + y, 'a', 0@};
1840 structure = temp;
1841 @}
1842 @end smallexample
1843
1844 You can also construct an array, though this is dangerous in C++, as
1845 explained below. If all the elements of the compound literal are
1846 (made up of) simple constant expressions, suitable for use in
1847 initializers of objects of static storage duration, then the compound
1848 literal can be coerced to a pointer to its first element and used in
1849 such an initializer, as shown here:
1850
1851 @smallexample
1852 char **foo = (char *[]) @{ "x", "y", "z" @};
1853 @end smallexample
1854
1855 Compound literals for scalar types and union types are
1856 also allowed, but then the compound literal is equivalent
1857 to a cast.
1858
1859 As a GNU extension, GCC allows initialization of objects with static storage
1860 duration by compound literals (which is not possible in ISO C99, because
1861 the initializer is not a constant).
1862 It is handled as if the object is initialized only with the bracket
1863 enclosed list if the types of the compound literal and the object match.
1864 The initializer list of the compound literal must be constant.
1865 If the object being initialized has array type of unknown size, the size is
1866 determined by compound literal size.
1867
1868 @smallexample
1869 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1870 static int y[] = (int []) @{1, 2, 3@};
1871 static int z[] = (int [3]) @{1@};
1872 @end smallexample
1873
1874 @noindent
1875 The above lines are equivalent to the following:
1876 @smallexample
1877 static struct foo x = @{1, 'a', 'b'@};
1878 static int y[] = @{1, 2, 3@};
1879 static int z[] = @{1, 0, 0@};
1880 @end smallexample
1881
1882 In C, a compound literal designates an unnamed object with static or
1883 automatic storage duration. In C++, a compound literal designates a
1884 temporary object, which only lives until the end of its
1885 full-expression. As a result, well-defined C code that takes the
1886 address of a subobject of a compound literal can be undefined in C++.
1887 For instance, if the array compound literal example above appeared
1888 inside a function, any subsequent use of @samp{foo} in C++ has
1889 undefined behavior because the lifetime of the array ends after the
1890 declaration of @samp{foo}. As a result, the C++ compiler now rejects
1891 the conversion of a temporary array to a pointer.
1892
1893 As an optimization, the C++ compiler sometimes gives array compound
1894 literals longer lifetimes: when the array either appears outside a
1895 function or has const-qualified type. If @samp{foo} and its
1896 initializer had elements of @samp{char *const} type rather than
1897 @samp{char *}, or if @samp{foo} were a global variable, the array
1898 would have static storage duration. But it is probably safest just to
1899 avoid the use of array compound literals in code compiled as C++.
1900
1901 @node Designated Inits
1902 @section Designated Initializers
1903 @cindex initializers with labeled elements
1904 @cindex labeled elements in initializers
1905 @cindex case labels in initializers
1906 @cindex designated initializers
1907
1908 Standard C90 requires the elements of an initializer to appear in a fixed
1909 order, the same as the order of the elements in the array or structure
1910 being initialized.
1911
1912 In ISO C99 you can give the elements in any order, specifying the array
1913 indices or structure field names they apply to, and GNU C allows this as
1914 an extension in C90 mode as well. This extension is not
1915 implemented in GNU C++.
1916
1917 To specify an array index, write
1918 @samp{[@var{index}] =} before the element value. For example,
1919
1920 @smallexample
1921 int a[6] = @{ [4] = 29, [2] = 15 @};
1922 @end smallexample
1923
1924 @noindent
1925 is equivalent to
1926
1927 @smallexample
1928 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1929 @end smallexample
1930
1931 @noindent
1932 The index values must be constant expressions, even if the array being
1933 initialized is automatic.
1934
1935 An alternative syntax for this that has been obsolete since GCC 2.5 but
1936 GCC still accepts is to write @samp{[@var{index}]} before the element
1937 value, with no @samp{=}.
1938
1939 To initialize a range of elements to the same value, write
1940 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
1941 extension. For example,
1942
1943 @smallexample
1944 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1945 @end smallexample
1946
1947 @noindent
1948 If the value in it has side-effects, the side-effects happen only once,
1949 not for each initialized field by the range initializer.
1950
1951 @noindent
1952 Note that the length of the array is the highest value specified
1953 plus one.
1954
1955 In a structure initializer, specify the name of a field to initialize
1956 with @samp{.@var{fieldname} =} before the element value. For example,
1957 given the following structure,
1958
1959 @smallexample
1960 struct point @{ int x, y; @};
1961 @end smallexample
1962
1963 @noindent
1964 the following initialization
1965
1966 @smallexample
1967 struct point p = @{ .y = yvalue, .x = xvalue @};
1968 @end smallexample
1969
1970 @noindent
1971 is equivalent to
1972
1973 @smallexample
1974 struct point p = @{ xvalue, yvalue @};
1975 @end smallexample
1976
1977 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1978 @samp{@var{fieldname}:}, as shown here:
1979
1980 @smallexample
1981 struct point p = @{ y: yvalue, x: xvalue @};
1982 @end smallexample
1983
1984 Omitted field members are implicitly initialized the same as objects
1985 that have static storage duration.
1986
1987 @cindex designators
1988 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1989 @dfn{designator}. You can also use a designator (or the obsolete colon
1990 syntax) when initializing a union, to specify which element of the union
1991 should be used. For example,
1992
1993 @smallexample
1994 union foo @{ int i; double d; @};
1995
1996 union foo f = @{ .d = 4 @};
1997 @end smallexample
1998
1999 @noindent
2000 converts 4 to a @code{double} to store it in the union using
2001 the second element. By contrast, casting 4 to type @code{union foo}
2002 stores it into the union as the integer @code{i}, since it is
2003 an integer. (@xref{Cast to Union}.)
2004
2005 You can combine this technique of naming elements with ordinary C
2006 initialization of successive elements. Each initializer element that
2007 does not have a designator applies to the next consecutive element of the
2008 array or structure. For example,
2009
2010 @smallexample
2011 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2012 @end smallexample
2013
2014 @noindent
2015 is equivalent to
2016
2017 @smallexample
2018 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2019 @end smallexample
2020
2021 Labeling the elements of an array initializer is especially useful
2022 when the indices are characters or belong to an @code{enum} type.
2023 For example:
2024
2025 @smallexample
2026 int whitespace[256]
2027 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2028 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2029 @end smallexample
2030
2031 @cindex designator lists
2032 You can also write a series of @samp{.@var{fieldname}} and
2033 @samp{[@var{index}]} designators before an @samp{=} to specify a
2034 nested subobject to initialize; the list is taken relative to the
2035 subobject corresponding to the closest surrounding brace pair. For
2036 example, with the @samp{struct point} declaration above:
2037
2038 @smallexample
2039 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2040 @end smallexample
2041
2042 @noindent
2043 If the same field is initialized multiple times, it has the value from
2044 the last initialization. If any such overridden initialization has
2045 side-effect, it is unspecified whether the side-effect happens or not.
2046 Currently, GCC discards them and issues a warning.
2047
2048 @node Case Ranges
2049 @section Case Ranges
2050 @cindex case ranges
2051 @cindex ranges in case statements
2052
2053 You can specify a range of consecutive values in a single @code{case} label,
2054 like this:
2055
2056 @smallexample
2057 case @var{low} ... @var{high}:
2058 @end smallexample
2059
2060 @noindent
2061 This has the same effect as the proper number of individual @code{case}
2062 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2063
2064 This feature is especially useful for ranges of ASCII character codes:
2065
2066 @smallexample
2067 case 'A' ... 'Z':
2068 @end smallexample
2069
2070 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2071 it may be parsed wrong when you use it with integer values. For example,
2072 write this:
2073
2074 @smallexample
2075 case 1 ... 5:
2076 @end smallexample
2077
2078 @noindent
2079 rather than this:
2080
2081 @smallexample
2082 case 1...5:
2083 @end smallexample
2084
2085 @node Cast to Union
2086 @section Cast to a Union Type
2087 @cindex cast to a union
2088 @cindex union, casting to a
2089
2090 A cast to union type is similar to other casts, except that the type
2091 specified is a union type. You can specify the type either with
2092 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2093 a constructor, not a cast, and hence does not yield an lvalue like
2094 normal casts. (@xref{Compound Literals}.)
2095
2096 The types that may be cast to the union type are those of the members
2097 of the union. Thus, given the following union and variables:
2098
2099 @smallexample
2100 union foo @{ int i; double d; @};
2101 int x;
2102 double y;
2103 @end smallexample
2104
2105 @noindent
2106 both @code{x} and @code{y} can be cast to type @code{union foo}.
2107
2108 Using the cast as the right-hand side of an assignment to a variable of
2109 union type is equivalent to storing in a member of the union:
2110
2111 @smallexample
2112 union foo u;
2113 /* @r{@dots{}} */
2114 u = (union foo) x @equiv{} u.i = x
2115 u = (union foo) y @equiv{} u.d = y
2116 @end smallexample
2117
2118 You can also use the union cast as a function argument:
2119
2120 @smallexample
2121 void hack (union foo);
2122 /* @r{@dots{}} */
2123 hack ((union foo) x);
2124 @end smallexample
2125
2126 @node Mixed Declarations
2127 @section Mixed Declarations and Code
2128 @cindex mixed declarations and code
2129 @cindex declarations, mixed with code
2130 @cindex code, mixed with declarations
2131
2132 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2133 within compound statements. As an extension, GNU C also allows this in
2134 C90 mode. For example, you could do:
2135
2136 @smallexample
2137 int i;
2138 /* @r{@dots{}} */
2139 i++;
2140 int j = i + 2;
2141 @end smallexample
2142
2143 Each identifier is visible from where it is declared until the end of
2144 the enclosing block.
2145
2146 @node Function Attributes
2147 @section Declaring Attributes of Functions
2148 @cindex function attributes
2149 @cindex declaring attributes of functions
2150 @cindex functions that never return
2151 @cindex functions that return more than once
2152 @cindex functions that have no side effects
2153 @cindex functions in arbitrary sections
2154 @cindex functions that behave like malloc
2155 @cindex @code{volatile} applied to function
2156 @cindex @code{const} applied to function
2157 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2158 @cindex functions with non-null pointer arguments
2159 @cindex functions that are passed arguments in registers on the 386
2160 @cindex functions that pop the argument stack on the 386
2161 @cindex functions that do not pop the argument stack on the 386
2162 @cindex functions that have different compilation options on the 386
2163 @cindex functions that have different optimization options
2164 @cindex functions that are dynamically resolved
2165
2166 In GNU C, you declare certain things about functions called in your program
2167 which help the compiler optimize function calls and check your code more
2168 carefully.
2169
2170 The keyword @code{__attribute__} allows you to specify special
2171 attributes when making a declaration. This keyword is followed by an
2172 attribute specification inside double parentheses. The following
2173 attributes are currently defined for functions on all targets:
2174 @code{aligned}, @code{alloc_size}, @code{alloc_align}, @code{assume_aligned},
2175 @code{noreturn}, @code{returns_twice}, @code{noinline}, @code{noclone},
2176 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2177 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2178 @code{no_instrument_function}, @code{no_split_stack},
2179 @code{section}, @code{constructor},
2180 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2181 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2182 @code{warn_unused_result}, @code{nonnull},
2183 @code{returns_nonnull}, @code{gnu_inline},
2184 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2185 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2186 @code{no_sanitize_undefined}, @code{no_reorder}, @code{bnd_legacy},
2187 @code{bnd_instrument},
2188 @code{error} and @code{warning}.
2189 Several other attributes are defined for functions on particular
2190 target systems. Other attributes, including @code{section} are
2191 supported for variables declarations (@pxref{Variable Attributes}),
2192 labels (@pxref{Label Attributes})
2193 and for types (@pxref{Type Attributes}).
2194
2195 GCC plugins may provide their own attributes.
2196
2197 You may also specify attributes with @samp{__} preceding and following
2198 each keyword. This allows you to use them in header files without
2199 being concerned about a possible macro of the same name. For example,
2200 you may use @code{__noreturn__} instead of @code{noreturn}.
2201
2202 @xref{Attribute Syntax}, for details of the exact syntax for using
2203 attributes.
2204
2205 @table @code
2206 @c Keep this table alphabetized by attribute name. Treat _ as space.
2207
2208 @item alias ("@var{target}")
2209 @cindex @code{alias} attribute
2210 The @code{alias} attribute causes the declaration to be emitted as an
2211 alias for another symbol, which must be specified. For instance,
2212
2213 @smallexample
2214 void __f () @{ /* @r{Do something.} */; @}
2215 void f () __attribute__ ((weak, alias ("__f")));
2216 @end smallexample
2217
2218 @noindent
2219 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2220 mangled name for the target must be used. It is an error if @samp{__f}
2221 is not defined in the same translation unit.
2222
2223 Not all target machines support this attribute.
2224
2225 @item aligned (@var{alignment})
2226 @cindex @code{aligned} attribute
2227 This attribute specifies a minimum alignment for the function,
2228 measured in bytes.
2229
2230 You cannot use this attribute to decrease the alignment of a function,
2231 only to increase it. However, when you explicitly specify a function
2232 alignment this overrides the effect of the
2233 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2234 function.
2235
2236 Note that the effectiveness of @code{aligned} attributes may be
2237 limited by inherent limitations in your linker. On many systems, the
2238 linker is only able to arrange for functions to be aligned up to a
2239 certain maximum alignment. (For some linkers, the maximum supported
2240 alignment may be very very small.) See your linker documentation for
2241 further information.
2242
2243 The @code{aligned} attribute can also be used for variables and fields
2244 (@pxref{Variable Attributes}.)
2245
2246 @item alloc_size
2247 @cindex @code{alloc_size} attribute
2248 The @code{alloc_size} attribute is used to tell the compiler that the
2249 function return value points to memory, where the size is given by
2250 one or two of the functions parameters. GCC uses this
2251 information to improve the correctness of @code{__builtin_object_size}.
2252
2253 The function parameter(s) denoting the allocated size are specified by
2254 one or two integer arguments supplied to the attribute. The allocated size
2255 is either the value of the single function argument specified or the product
2256 of the two function arguments specified. Argument numbering starts at
2257 one.
2258
2259 For instance,
2260
2261 @smallexample
2262 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2263 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2264 @end smallexample
2265
2266 @noindent
2267 declares that @code{my_calloc} returns memory of the size given by
2268 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2269 of the size given by parameter 2.
2270
2271 @item alloc_align
2272 @cindex @code{alloc_align} attribute
2273 The @code{alloc_align} attribute is used to tell the compiler that the
2274 function return value points to memory, where the returned pointer minimum
2275 alignment is given by one of the functions parameters. GCC uses this
2276 information to improve pointer alignment analysis.
2277
2278 The function parameter denoting the allocated alignment is specified by
2279 one integer argument, whose number is the argument of the attribute.
2280 Argument numbering starts at one.
2281
2282 For instance,
2283
2284 @smallexample
2285 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2286 @end smallexample
2287
2288 @noindent
2289 declares that @code{my_memalign} returns memory with minimum alignment
2290 given by parameter 1.
2291
2292 @item assume_aligned
2293 @cindex @code{assume_aligned} attribute
2294 The @code{assume_aligned} attribute is used to tell the compiler that the
2295 function return value points to memory, where the returned pointer minimum
2296 alignment is given by the first argument.
2297 If the attribute has two arguments, the second argument is misalignment offset.
2298
2299 For instance
2300
2301 @smallexample
2302 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2303 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2304 @end smallexample
2305
2306 @noindent
2307 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2308 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2309 to 8.
2310
2311 @item always_inline
2312 @cindex @code{always_inline} function attribute
2313 Generally, functions are not inlined unless optimization is specified.
2314 For functions declared inline, this attribute inlines the function
2315 independent of any restrictions that otherwise apply to inlining.
2316 Failure to inline such a function is diagnosed as an error.
2317 Note that if such a function is called indirectly the compiler may
2318 or may not inline it depending on optimization level and a failure
2319 to inline an indirect call may or may not be diagnosed.
2320
2321 @item gnu_inline
2322 @cindex @code{gnu_inline} function attribute
2323 This attribute should be used with a function that is also declared
2324 with the @code{inline} keyword. It directs GCC to treat the function
2325 as if it were defined in gnu90 mode even when compiling in C99 or
2326 gnu99 mode.
2327
2328 If the function is declared @code{extern}, then this definition of the
2329 function is used only for inlining. In no case is the function
2330 compiled as a standalone function, not even if you take its address
2331 explicitly. Such an address becomes an external reference, as if you
2332 had only declared the function, and had not defined it. This has
2333 almost the effect of a macro. The way to use this is to put a
2334 function definition in a header file with this attribute, and put
2335 another copy of the function, without @code{extern}, in a library
2336 file. The definition in the header file causes most calls to the
2337 function to be inlined. If any uses of the function remain, they
2338 refer to the single copy in the library. Note that the two
2339 definitions of the functions need not be precisely the same, although
2340 if they do not have the same effect your program may behave oddly.
2341
2342 In C, if the function is neither @code{extern} nor @code{static}, then
2343 the function is compiled as a standalone function, as well as being
2344 inlined where possible.
2345
2346 This is how GCC traditionally handled functions declared
2347 @code{inline}. Since ISO C99 specifies a different semantics for
2348 @code{inline}, this function attribute is provided as a transition
2349 measure and as a useful feature in its own right. This attribute is
2350 available in GCC 4.1.3 and later. It is available if either of the
2351 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2352 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2353 Function is As Fast As a Macro}.
2354
2355 In C++, this attribute does not depend on @code{extern} in any way,
2356 but it still requires the @code{inline} keyword to enable its special
2357 behavior.
2358
2359 @item artificial
2360 @cindex @code{artificial} function attribute
2361 This attribute is useful for small inline wrappers that if possible
2362 should appear during debugging as a unit. Depending on the debug
2363 info format it either means marking the function as artificial
2364 or using the caller location for all instructions within the inlined
2365 body.
2366
2367 @item bank_switch
2368 @cindex interrupt handler functions
2369 When added to an interrupt handler with the M32C port, causes the
2370 prologue and epilogue to use bank switching to preserve the registers
2371 rather than saving them on the stack.
2372
2373 @item flatten
2374 @cindex @code{flatten} function attribute
2375 Generally, inlining into a function is limited. For a function marked with
2376 this attribute, every call inside this function is inlined, if possible.
2377 Whether the function itself is considered for inlining depends on its size and
2378 the current inlining parameters.
2379
2380 @item error ("@var{message}")
2381 @cindex @code{error} function attribute
2382 If this attribute is used on a function declaration and a call to such a function
2383 is not eliminated through dead code elimination or other optimizations, an error
2384 that includes @var{message} is diagnosed. This is useful
2385 for compile-time checking, especially together with @code{__builtin_constant_p}
2386 and inline functions where checking the inline function arguments is not
2387 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2388 While it is possible to leave the function undefined and thus invoke
2389 a link failure, when using this attribute the problem is diagnosed
2390 earlier and with exact location of the call even in presence of inline
2391 functions or when not emitting debugging information.
2392
2393 @item warning ("@var{message}")
2394 @cindex @code{warning} function attribute
2395 If this attribute is used on a function declaration and a call to such a function
2396 is not eliminated through dead code elimination or other optimizations, a warning
2397 that includes @var{message} is diagnosed. This is useful
2398 for compile-time checking, especially together with @code{__builtin_constant_p}
2399 and inline functions. While it is possible to define the function with
2400 a message in @code{.gnu.warning*} section, when using this attribute the problem
2401 is diagnosed earlier and with exact location of the call even in presence
2402 of inline functions or when not emitting debugging information.
2403
2404 @item cdecl
2405 @cindex functions that do pop the argument stack on the 386
2406 @opindex mrtd
2407 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2408 assume that the calling function pops off the stack space used to
2409 pass arguments. This is
2410 useful to override the effects of the @option{-mrtd} switch.
2411
2412 @item const
2413 @cindex @code{const} function attribute
2414 Many functions do not examine any values except their arguments, and
2415 have no effects except the return value. Basically this is just slightly
2416 more strict class than the @code{pure} attribute below, since function is not
2417 allowed to read global memory.
2418
2419 @cindex pointer arguments
2420 Note that a function that has pointer arguments and examines the data
2421 pointed to must @emph{not} be declared @code{const}. Likewise, a
2422 function that calls a non-@code{const} function usually must not be
2423 @code{const}. It does not make sense for a @code{const} function to
2424 return @code{void}.
2425
2426 The attribute @code{const} is not implemented in GCC versions earlier
2427 than 2.5. An alternative way to declare that a function has no side
2428 effects, which works in the current version and in some older versions,
2429 is as follows:
2430
2431 @smallexample
2432 typedef int intfn ();
2433
2434 extern const intfn square;
2435 @end smallexample
2436
2437 @noindent
2438 This approach does not work in GNU C++ from 2.6.0 on, since the language
2439 specifies that the @samp{const} must be attached to the return value.
2440
2441 @item constructor
2442 @itemx destructor
2443 @itemx constructor (@var{priority})
2444 @itemx destructor (@var{priority})
2445 @cindex @code{constructor} function attribute
2446 @cindex @code{destructor} function attribute
2447 The @code{constructor} attribute causes the function to be called
2448 automatically before execution enters @code{main ()}. Similarly, the
2449 @code{destructor} attribute causes the function to be called
2450 automatically after @code{main ()} completes or @code{exit ()} is
2451 called. Functions with these attributes are useful for
2452 initializing data that is used implicitly during the execution of
2453 the program.
2454
2455 You may provide an optional integer priority to control the order in
2456 which constructor and destructor functions are run. A constructor
2457 with a smaller priority number runs before a constructor with a larger
2458 priority number; the opposite relationship holds for destructors. So,
2459 if you have a constructor that allocates a resource and a destructor
2460 that deallocates the same resource, both functions typically have the
2461 same priority. The priorities for constructor and destructor
2462 functions are the same as those specified for namespace-scope C++
2463 objects (@pxref{C++ Attributes}).
2464
2465 These attributes are not currently implemented for Objective-C@.
2466
2467 @item deprecated
2468 @itemx deprecated (@var{msg})
2469 @cindex @code{deprecated} attribute.
2470 The @code{deprecated} attribute results in a warning if the function
2471 is used anywhere in the source file. This is useful when identifying
2472 functions that are expected to be removed in a future version of a
2473 program. The warning also includes the location of the declaration
2474 of the deprecated function, to enable users to easily find further
2475 information about why the function is deprecated, or what they should
2476 do instead. Note that the warnings only occurs for uses:
2477
2478 @smallexample
2479 int old_fn () __attribute__ ((deprecated));
2480 int old_fn ();
2481 int (*fn_ptr)() = old_fn;
2482 @end smallexample
2483
2484 @noindent
2485 results in a warning on line 3 but not line 2. The optional @var{msg}
2486 argument, which must be a string, is printed in the warning if
2487 present.
2488
2489 The @code{deprecated} attribute can also be used for variables and
2490 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2491
2492 @item disinterrupt
2493 @cindex @code{disinterrupt} attribute
2494 On Epiphany and MeP targets, this attribute causes the compiler to emit
2495 instructions to disable interrupts for the duration of the given
2496 function.
2497
2498 @item dllexport
2499 @cindex @code{__declspec(dllexport)}
2500 On Microsoft Windows targets and Symbian OS targets the
2501 @code{dllexport} attribute causes the compiler to provide a global
2502 pointer to a pointer in a DLL, so that it can be referenced with the
2503 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
2504 name is formed by combining @code{_imp__} and the function or variable
2505 name.
2506
2507 You can use @code{__declspec(dllexport)} as a synonym for
2508 @code{__attribute__ ((dllexport))} for compatibility with other
2509 compilers.
2510
2511 On systems that support the @code{visibility} attribute, this
2512 attribute also implies ``default'' visibility. It is an error to
2513 explicitly specify any other visibility.
2514
2515 In previous versions of GCC, the @code{dllexport} attribute was ignored
2516 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2517 had been used. The default behavior now is to emit all dllexported
2518 inline functions; however, this can cause object file-size bloat, in
2519 which case the old behavior can be restored by using
2520 @option{-fno-keep-inline-dllexport}.
2521
2522 The attribute is also ignored for undefined symbols.
2523
2524 When applied to C++ classes, the attribute marks defined non-inlined
2525 member functions and static data members as exports. Static consts
2526 initialized in-class are not marked unless they are also defined
2527 out-of-class.
2528
2529 For Microsoft Windows targets there are alternative methods for
2530 including the symbol in the DLL's export table such as using a
2531 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2532 the @option{--export-all} linker flag.
2533
2534 @item dllimport
2535 @cindex @code{__declspec(dllimport)}
2536 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2537 attribute causes the compiler to reference a function or variable via
2538 a global pointer to a pointer that is set up by the DLL exporting the
2539 symbol. The attribute implies @code{extern}. On Microsoft Windows
2540 targets, the pointer name is formed by combining @code{_imp__} and the
2541 function or variable name.
2542
2543 You can use @code{__declspec(dllimport)} as a synonym for
2544 @code{__attribute__ ((dllimport))} for compatibility with other
2545 compilers.
2546
2547 On systems that support the @code{visibility} attribute, this
2548 attribute also implies ``default'' visibility. It is an error to
2549 explicitly specify any other visibility.
2550
2551 Currently, the attribute is ignored for inlined functions. If the
2552 attribute is applied to a symbol @emph{definition}, an error is reported.
2553 If a symbol previously declared @code{dllimport} is later defined, the
2554 attribute is ignored in subsequent references, and a warning is emitted.
2555 The attribute is also overridden by a subsequent declaration as
2556 @code{dllexport}.
2557
2558 When applied to C++ classes, the attribute marks non-inlined
2559 member functions and static data members as imports. However, the
2560 attribute is ignored for virtual methods to allow creation of vtables
2561 using thunks.
2562
2563 On the SH Symbian OS target the @code{dllimport} attribute also has
2564 another affect---it can cause the vtable and run-time type information
2565 for a class to be exported. This happens when the class has a
2566 dllimported constructor or a non-inline, non-pure virtual function
2567 and, for either of those two conditions, the class also has an inline
2568 constructor or destructor and has a key function that is defined in
2569 the current translation unit.
2570
2571 For Microsoft Windows targets the use of the @code{dllimport}
2572 attribute on functions is not necessary, but provides a small
2573 performance benefit by eliminating a thunk in the DLL@. The use of the
2574 @code{dllimport} attribute on imported variables was required on older
2575 versions of the GNU linker, but can now be avoided by passing the
2576 @option{--enable-auto-import} switch to the GNU linker. As with
2577 functions, using the attribute for a variable eliminates a thunk in
2578 the DLL@.
2579
2580 One drawback to using this attribute is that a pointer to a
2581 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2582 address. However, a pointer to a @emph{function} with the
2583 @code{dllimport} attribute can be used as a constant initializer; in
2584 this case, the address of a stub function in the import lib is
2585 referenced. On Microsoft Windows targets, the attribute can be disabled
2586 for functions by setting the @option{-mnop-fun-dllimport} flag.
2587
2588 @item eightbit_data
2589 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2590 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2591 variable should be placed into the eight-bit data section.
2592 The compiler generates more efficient code for certain operations
2593 on data in the eight-bit data area. Note the eight-bit data area is limited to
2594 256 bytes of data.
2595
2596 You must use GAS and GLD from GNU binutils version 2.7 or later for
2597 this attribute to work correctly.
2598
2599 @item exception
2600 @cindex exception handler functions
2601 Use this attribute on the NDS32 target to indicate that the specified function
2602 is an exception handler. The compiler will generate corresponding sections
2603 for use in an exception handler.
2604
2605 @item exception_handler
2606 @cindex exception handler functions on the Blackfin processor
2607 Use this attribute on the Blackfin to indicate that the specified function
2608 is an exception handler. The compiler generates function entry and
2609 exit sequences suitable for use in an exception handler when this
2610 attribute is present.
2611
2612 @item externally_visible
2613 @cindex @code{externally_visible} attribute.
2614 This attribute, attached to a global variable or function, nullifies
2615 the effect of the @option{-fwhole-program} command-line option, so the
2616 object remains visible outside the current compilation unit.
2617
2618 If @option{-fwhole-program} is used together with @option{-flto} and
2619 @command{gold} is used as the linker plugin,
2620 @code{externally_visible} attributes are automatically added to functions
2621 (not variable yet due to a current @command{gold} issue)
2622 that are accessed outside of LTO objects according to resolution file
2623 produced by @command{gold}.
2624 For other linkers that cannot generate resolution file,
2625 explicit @code{externally_visible} attributes are still necessary.
2626
2627 @item far
2628 @cindex functions that handle memory bank switching
2629 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2630 use a calling convention that takes care of switching memory banks when
2631 entering and leaving a function. This calling convention is also the
2632 default when using the @option{-mlong-calls} option.
2633
2634 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2635 to call and return from a function.
2636
2637 On 68HC11 the compiler generates a sequence of instructions
2638 to invoke a board-specific routine to switch the memory bank and call the
2639 real function. The board-specific routine simulates a @code{call}.
2640 At the end of a function, it jumps to a board-specific routine
2641 instead of using @code{rts}. The board-specific return routine simulates
2642 the @code{rtc}.
2643
2644 On MeP targets this causes the compiler to use a calling convention
2645 that assumes the called function is too far away for the built-in
2646 addressing modes.
2647
2648 @item fast_interrupt
2649 @cindex interrupt handler functions
2650 Use this attribute on the M32C and RX ports to indicate that the specified
2651 function is a fast interrupt handler. This is just like the
2652 @code{interrupt} attribute, except that @code{freit} is used to return
2653 instead of @code{reit}.
2654
2655 @item fastcall
2656 @cindex functions that pop the argument stack on the 386
2657 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2658 pass the first argument (if of integral type) in the register ECX and
2659 the second argument (if of integral type) in the register EDX@. Subsequent
2660 and other typed arguments are passed on the stack. The called function
2661 pops the arguments off the stack. If the number of arguments is variable all
2662 arguments are pushed on the stack.
2663
2664 @item thiscall
2665 @cindex functions that pop the argument stack on the 386
2666 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2667 pass the first argument (if of integral type) in the register ECX.
2668 Subsequent and other typed arguments are passed on the stack. The called
2669 function pops the arguments off the stack.
2670 If the number of arguments is variable all arguments are pushed on the
2671 stack.
2672 The @code{thiscall} attribute is intended for C++ non-static member functions.
2673 As a GCC extension, this calling convention can be used for C functions
2674 and for static member methods.
2675
2676 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2677 @cindex @code{format} function attribute
2678 @opindex Wformat
2679 The @code{format} attribute specifies that a function takes @code{printf},
2680 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2681 should be type-checked against a format string. For example, the
2682 declaration:
2683
2684 @smallexample
2685 extern int
2686 my_printf (void *my_object, const char *my_format, ...)
2687 __attribute__ ((format (printf, 2, 3)));
2688 @end smallexample
2689
2690 @noindent
2691 causes the compiler to check the arguments in calls to @code{my_printf}
2692 for consistency with the @code{printf} style format string argument
2693 @code{my_format}.
2694
2695 The parameter @var{archetype} determines how the format string is
2696 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2697 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2698 @code{strfmon}. (You can also use @code{__printf__},
2699 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2700 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2701 @code{ms_strftime} are also present.
2702 @var{archetype} values such as @code{printf} refer to the formats accepted
2703 by the system's C runtime library,
2704 while values prefixed with @samp{gnu_} always refer
2705 to the formats accepted by the GNU C Library. On Microsoft Windows
2706 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2707 @file{msvcrt.dll} library.
2708 The parameter @var{string-index}
2709 specifies which argument is the format string argument (starting
2710 from 1), while @var{first-to-check} is the number of the first
2711 argument to check against the format string. For functions
2712 where the arguments are not available to be checked (such as
2713 @code{vprintf}), specify the third parameter as zero. In this case the
2714 compiler only checks the format string for consistency. For
2715 @code{strftime} formats, the third parameter is required to be zero.
2716 Since non-static C++ methods have an implicit @code{this} argument, the
2717 arguments of such methods should be counted from two, not one, when
2718 giving values for @var{string-index} and @var{first-to-check}.
2719
2720 In the example above, the format string (@code{my_format}) is the second
2721 argument of the function @code{my_print}, and the arguments to check
2722 start with the third argument, so the correct parameters for the format
2723 attribute are 2 and 3.
2724
2725 @opindex ffreestanding
2726 @opindex fno-builtin
2727 The @code{format} attribute allows you to identify your own functions
2728 that take format strings as arguments, so that GCC can check the
2729 calls to these functions for errors. The compiler always (unless
2730 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2731 for the standard library functions @code{printf}, @code{fprintf},
2732 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2733 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2734 warnings are requested (using @option{-Wformat}), so there is no need to
2735 modify the header file @file{stdio.h}. In C99 mode, the functions
2736 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2737 @code{vsscanf} are also checked. Except in strictly conforming C
2738 standard modes, the X/Open function @code{strfmon} is also checked as
2739 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2740 @xref{C Dialect Options,,Options Controlling C Dialect}.
2741
2742 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2743 recognized in the same context. Declarations including these format attributes
2744 are parsed for correct syntax, however the result of checking of such format
2745 strings is not yet defined, and is not carried out by this version of the
2746 compiler.
2747
2748 The target may also provide additional types of format checks.
2749 @xref{Target Format Checks,,Format Checks Specific to Particular
2750 Target Machines}.
2751
2752 @item format_arg (@var{string-index})
2753 @cindex @code{format_arg} function attribute
2754 @opindex Wformat-nonliteral
2755 The @code{format_arg} attribute specifies that a function takes a format
2756 string for a @code{printf}, @code{scanf}, @code{strftime} or
2757 @code{strfmon} style function and modifies it (for example, to translate
2758 it into another language), so the result can be passed to a
2759 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2760 function (with the remaining arguments to the format function the same
2761 as they would have been for the unmodified string). For example, the
2762 declaration:
2763
2764 @smallexample
2765 extern char *
2766 my_dgettext (char *my_domain, const char *my_format)
2767 __attribute__ ((format_arg (2)));
2768 @end smallexample
2769
2770 @noindent
2771 causes the compiler to check the arguments in calls to a @code{printf},
2772 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2773 format string argument is a call to the @code{my_dgettext} function, for
2774 consistency with the format string argument @code{my_format}. If the
2775 @code{format_arg} attribute had not been specified, all the compiler
2776 could tell in such calls to format functions would be that the format
2777 string argument is not constant; this would generate a warning when
2778 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2779 without the attribute.
2780
2781 The parameter @var{string-index} specifies which argument is the format
2782 string argument (starting from one). Since non-static C++ methods have
2783 an implicit @code{this} argument, the arguments of such methods should
2784 be counted from two.
2785
2786 The @code{format_arg} attribute allows you to identify your own
2787 functions that modify format strings, so that GCC can check the
2788 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2789 type function whose operands are a call to one of your own function.
2790 The compiler always treats @code{gettext}, @code{dgettext}, and
2791 @code{dcgettext} in this manner except when strict ISO C support is
2792 requested by @option{-ansi} or an appropriate @option{-std} option, or
2793 @option{-ffreestanding} or @option{-fno-builtin}
2794 is used. @xref{C Dialect Options,,Options
2795 Controlling C Dialect}.
2796
2797 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2798 @code{NSString} reference for compatibility with the @code{format} attribute
2799 above.
2800
2801 The target may also allow additional types in @code{format-arg} attributes.
2802 @xref{Target Format Checks,,Format Checks Specific to Particular
2803 Target Machines}.
2804
2805 @item function_vector
2806 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2807 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2808 function should be called through the function vector. Calling a
2809 function through the function vector reduces code size, however;
2810 the function vector has a limited size (maximum 128 entries on the H8/300
2811 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2812
2813 On SH2A targets, this attribute declares a function to be called using the
2814 TBR relative addressing mode. The argument to this attribute is the entry
2815 number of the same function in a vector table containing all the TBR
2816 relative addressable functions. For correct operation the TBR must be setup
2817 accordingly to point to the start of the vector table before any functions with
2818 this attribute are invoked. Usually a good place to do the initialization is
2819 the startup routine. The TBR relative vector table can have at max 256 function
2820 entries. The jumps to these functions are generated using a SH2A specific,
2821 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
2822 from GNU binutils version 2.7 or later for this attribute to work correctly.
2823
2824 Please refer the example of M16C target, to see the use of this
2825 attribute while declaring a function,
2826
2827 In an application, for a function being called once, this attribute
2828 saves at least 8 bytes of code; and if other successive calls are being
2829 made to the same function, it saves 2 bytes of code per each of these
2830 calls.
2831
2832 On M16C/M32C targets, the @code{function_vector} attribute declares a
2833 special page subroutine call function. Use of this attribute reduces
2834 the code size by 2 bytes for each call generated to the
2835 subroutine. The argument to the attribute is the vector number entry
2836 from the special page vector table which contains the 16 low-order
2837 bits of the subroutine's entry address. Each vector table has special
2838 page number (18 to 255) that is used in @code{jsrs} instructions.
2839 Jump addresses of the routines are generated by adding 0x0F0000 (in
2840 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2841 2-byte addresses set in the vector table. Therefore you need to ensure
2842 that all the special page vector routines should get mapped within the
2843 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2844 (for M32C).
2845
2846 In the following example 2 bytes are saved for each call to
2847 function @code{foo}.
2848
2849 @smallexample
2850 void foo (void) __attribute__((function_vector(0x18)));
2851 void foo (void)
2852 @{
2853 @}
2854
2855 void bar (void)
2856 @{
2857 foo();
2858 @}
2859 @end smallexample
2860
2861 If functions are defined in one file and are called in another file,
2862 then be sure to write this declaration in both files.
2863
2864 This attribute is ignored for R8C target.
2865
2866 @item ifunc ("@var{resolver}")
2867 @cindex @code{ifunc} attribute
2868 The @code{ifunc} attribute is used to mark a function as an indirect
2869 function using the STT_GNU_IFUNC symbol type extension to the ELF
2870 standard. This allows the resolution of the symbol value to be
2871 determined dynamically at load time, and an optimized version of the
2872 routine can be selected for the particular processor or other system
2873 characteristics determined then. To use this attribute, first define
2874 the implementation functions available, and a resolver function that
2875 returns a pointer to the selected implementation function. The
2876 implementation functions' declarations must match the API of the
2877 function being implemented, the resolver's declaration is be a
2878 function returning pointer to void function returning void:
2879
2880 @smallexample
2881 void *my_memcpy (void *dst, const void *src, size_t len)
2882 @{
2883 @dots{}
2884 @}
2885
2886 static void (*resolve_memcpy (void)) (void)
2887 @{
2888 return my_memcpy; // we'll just always select this routine
2889 @}
2890 @end smallexample
2891
2892 @noindent
2893 The exported header file declaring the function the user calls would
2894 contain:
2895
2896 @smallexample
2897 extern void *memcpy (void *, const void *, size_t);
2898 @end smallexample
2899
2900 @noindent
2901 allowing the user to call this as a regular function, unaware of the
2902 implementation. Finally, the indirect function needs to be defined in
2903 the same translation unit as the resolver function:
2904
2905 @smallexample
2906 void *memcpy (void *, const void *, size_t)
2907 __attribute__ ((ifunc ("resolve_memcpy")));
2908 @end smallexample
2909
2910 Indirect functions cannot be weak, and require a recent binutils (at
2911 least version 2.20.1), and GNU C library (at least version 2.11.1).
2912
2913 @item interrupt
2914 @cindex interrupt handler functions
2915 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2916 m68k, MeP, MIPS, MSP430, RL78, RX and Xstormy16 ports to indicate that
2917 the specified function is an
2918 interrupt handler. The compiler generates function entry and exit
2919 sequences suitable for use in an interrupt handler when this attribute
2920 is present. With Epiphany targets it may also generate a special section with
2921 code to initialize the interrupt vector table.
2922
2923 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2924 and SH processors can be specified via the @code{interrupt_handler} attribute.
2925
2926 Note, on the ARC, you must specify the kind of interrupt to be handled
2927 in a parameter to the interrupt attribute like this:
2928
2929 @smallexample
2930 void f () __attribute__ ((interrupt ("ilink1")));
2931 @end smallexample
2932
2933 Permissible values for this parameter are: @w{@code{ilink1}} and
2934 @w{@code{ilink2}}.
2935
2936 Note, on the AVR, the hardware globally disables interrupts when an
2937 interrupt is executed. The first instruction of an interrupt handler
2938 declared with this attribute is a @code{SEI} instruction to
2939 re-enable interrupts. See also the @code{signal} function attribute
2940 that does not insert a @code{SEI} instruction. If both @code{signal} and
2941 @code{interrupt} are specified for the same function, @code{signal}
2942 is silently ignored.
2943
2944 Note, for the ARM, you can specify the kind of interrupt to be handled by
2945 adding an optional parameter to the interrupt attribute like this:
2946
2947 @smallexample
2948 void f () __attribute__ ((interrupt ("IRQ")));
2949 @end smallexample
2950
2951 @noindent
2952 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2953 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2954
2955 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2956 may be called with a word-aligned stack pointer.
2957
2958 Note, for the MSP430 you can provide an argument to the interrupt
2959 attribute which specifies a name or number. If the argument is a
2960 number it indicates the slot in the interrupt vector table (0 - 31) to
2961 which this handler should be assigned. If the argument is a name it
2962 is treated as a symbolic name for the vector slot. These names should
2963 match up with appropriate entries in the linker script. By default
2964 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2965 @code{reset} for vector 31 are recognised.
2966
2967 You can also use the following function attributes to modify how
2968 normal functions interact with interrupt functions:
2969
2970 @table @code
2971 @item critical
2972 @cindex @code{critical} attribute
2973 Critical functions disable interrupts upon entry and restore the
2974 previous interrupt state upon exit. Critical functions cannot also
2975 have the @code{naked} or @code{reentrant} attributes. They can have
2976 the @code{interrupt} attribute.
2977
2978 @item reentrant
2979 @cindex @code{reentrant} attribute
2980 Reentrant functions disable interrupts upon entry and enable them
2981 upon exit. Reentrant functions cannot also have the @code{naked}
2982 or @code{critical} attributes. They can have the @code{interrupt}
2983 attribute.
2984
2985 @item wakeup
2986 @cindex @code{wakeup} attribute
2987 This attribute only applies to interrupt functions. It is silently
2988 ignored if applied to a non-interrupt function. A wakeup interrupt
2989 function will rouse the processor from any low-power state that it
2990 might be in when the function exits.
2991
2992 @end table
2993
2994 On Epiphany targets one or more optional parameters can be added like this:
2995
2996 @smallexample
2997 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2998 @end smallexample
2999
3000 Permissible values for these parameters are: @w{@code{reset}},
3001 @w{@code{software_exception}}, @w{@code{page_miss}},
3002 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3003 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3004 Multiple parameters indicate that multiple entries in the interrupt
3005 vector table should be initialized for this function, i.e.@: for each
3006 parameter @w{@var{name}}, a jump to the function is emitted in
3007 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
3008 entirely, in which case no interrupt vector table entry is provided.
3009
3010 Note, on Epiphany targets, interrupts are enabled inside the function
3011 unless the @code{disinterrupt} attribute is also specified.
3012
3013 On Epiphany targets, you can also use the following attribute to
3014 modify the behavior of an interrupt handler:
3015 @table @code
3016 @item forwarder_section
3017 @cindex @code{forwarder_section} attribute
3018 The interrupt handler may be in external memory which cannot be
3019 reached by a branch instruction, so generate a local memory trampoline
3020 to transfer control. The single parameter identifies the section where
3021 the trampoline is placed.
3022 @end table
3023
3024 The following examples are all valid uses of these attributes on
3025 Epiphany targets:
3026 @smallexample
3027 void __attribute__ ((interrupt)) universal_handler ();
3028 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3029 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3030 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3031 fast_timer_handler ();
3032 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
3033 external_dma_handler ();
3034 @end smallexample
3035
3036 On MIPS targets, you can use the following attributes to modify the behavior
3037 of an interrupt handler:
3038 @table @code
3039 @item use_shadow_register_set
3040 @cindex @code{use_shadow_register_set} attribute
3041 Assume that the handler uses a shadow register set, instead of
3042 the main general-purpose registers.
3043
3044 @item keep_interrupts_masked
3045 @cindex @code{keep_interrupts_masked} attribute
3046 Keep interrupts masked for the whole function. Without this attribute,
3047 GCC tries to reenable interrupts for as much of the function as it can.
3048
3049 @item use_debug_exception_return
3050 @cindex @code{use_debug_exception_return} attribute
3051 Return using the @code{deret} instruction. Interrupt handlers that don't
3052 have this attribute return using @code{eret} instead.
3053 @end table
3054
3055 You can use any combination of these attributes, as shown below:
3056 @smallexample
3057 void __attribute__ ((interrupt)) v0 ();
3058 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
3059 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
3060 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
3061 void __attribute__ ((interrupt, use_shadow_register_set,
3062 keep_interrupts_masked)) v4 ();
3063 void __attribute__ ((interrupt, use_shadow_register_set,
3064 use_debug_exception_return)) v5 ();
3065 void __attribute__ ((interrupt, keep_interrupts_masked,
3066 use_debug_exception_return)) v6 ();
3067 void __attribute__ ((interrupt, use_shadow_register_set,
3068 keep_interrupts_masked,
3069 use_debug_exception_return)) v7 ();
3070 @end smallexample
3071
3072 On NDS32 target, this attribute is to indicate that the specified function
3073 is an interrupt handler. The compiler will generate corresponding sections
3074 for use in an interrupt handler. You can use the following attributes
3075 to modify the behavior:
3076 @table @code
3077 @item nested
3078 @cindex @code{nested} attribute
3079 This interrupt service routine is interruptible.
3080 @item not_nested
3081 @cindex @code{not_nested} attribute
3082 This interrupt service routine is not interruptible.
3083 @item nested_ready
3084 @cindex @code{nested_ready} attribute
3085 This interrupt service routine is interruptible after @code{PSW.GIE}
3086 (global interrupt enable) is set. This allows interrupt service routine to
3087 finish some short critical code before enabling interrupts.
3088 @item save_all
3089 @cindex @code{save_all} attribute
3090 The system will help save all registers into stack before entering
3091 interrupt handler.
3092 @item partial_save
3093 @cindex @code{partial_save} attribute
3094 The system will help save caller registers into stack before entering
3095 interrupt handler.
3096 @end table
3097
3098 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
3099 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
3100 that must end with @code{RETB} instead of @code{RETI}).
3101
3102 On RX targets, you may specify one or more vector numbers as arguments
3103 to the attribute, as well as naming an alternate table name.
3104 Parameters are handled sequentially, so one handler can be assigned to
3105 multiple entries in multiple tables. One may also pass the magic
3106 string @code{"$default"} which causes the function to be used for any
3107 unfilled slots in the current table.
3108
3109 This example shows a simple assignment of a function to one vector in
3110 the default table (note that preprocessor macros may be used for
3111 chip-specific symbolic vector names):
3112 @smallexample
3113 void __attribute__ ((interrupt (5))) txd1_handler ();
3114 @end smallexample
3115
3116 This example assigns a function to two slots in the default table
3117 (using preprocessor macros defined elsewhere) and makes it the default
3118 for the @code{dct} table:
3119 @smallexample
3120 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
3121 txd1_handler ();
3122 @end smallexample
3123
3124 @item interrupt_handler
3125 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
3126 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
3127 indicate that the specified function is an interrupt handler. The compiler
3128 generates function entry and exit sequences suitable for use in an
3129 interrupt handler when this attribute is present.
3130
3131 @item interrupt_thread
3132 @cindex interrupt thread functions on fido
3133 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3134 that the specified function is an interrupt handler that is designed
3135 to run as a thread. The compiler omits generate prologue/epilogue
3136 sequences and replaces the return instruction with a @code{sleep}
3137 instruction. This attribute is available only on fido.
3138
3139 @item isr
3140 @cindex interrupt service routines on ARM
3141 Use this attribute on ARM to write Interrupt Service Routines. This is an
3142 alias to the @code{interrupt} attribute above.
3143
3144 @item kspisusp
3145 @cindex User stack pointer in interrupts on the Blackfin
3146 When used together with @code{interrupt_handler}, @code{exception_handler}
3147 or @code{nmi_handler}, code is generated to load the stack pointer
3148 from the USP register in the function prologue.
3149
3150 @item l1_text
3151 @cindex @code{l1_text} function attribute
3152 This attribute specifies a function to be placed into L1 Instruction
3153 SRAM@. The function is put into a specific section named @code{.l1.text}.
3154 With @option{-mfdpic}, function calls with a such function as the callee
3155 or caller uses inlined PLT.
3156
3157 @item l2
3158 @cindex @code{l2} function attribute
3159 On the Blackfin, this attribute specifies a function to be placed into L2
3160 SRAM. The function is put into a specific section named
3161 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3162 an inlined PLT.
3163
3164 @item leaf
3165 @cindex @code{leaf} function attribute
3166 Calls to external functions with this attribute must return to the current
3167 compilation unit only by return or by exception handling. In particular, leaf
3168 functions are not allowed to call callback function passed to it from the current
3169 compilation unit or directly call functions exported by the unit or longjmp
3170 into the unit. Leaf function might still call functions from other compilation
3171 units and thus they are not necessarily leaf in the sense that they contain no
3172 function calls at all.
3173
3174 The attribute is intended for library functions to improve dataflow analysis.
3175 The compiler takes the hint that any data not escaping the current compilation unit can
3176 not be used or modified by the leaf function. For example, the @code{sin} function
3177 is a leaf function, but @code{qsort} is not.
3178
3179 Note that leaf functions might invoke signals and signal handlers might be
3180 defined in the current compilation unit and use static variables. The only
3181 compliant way to write such a signal handler is to declare such variables
3182 @code{volatile}.
3183
3184 The attribute has no effect on functions defined within the current compilation
3185 unit. This is to allow easy merging of multiple compilation units into one,
3186 for example, by using the link-time optimization. For this reason the
3187 attribute is not allowed on types to annotate indirect calls.
3188
3189 @item long_call/medium_call/short_call
3190 @cindex indirect calls on ARC
3191 @cindex indirect calls on ARM
3192 @cindex indirect calls on Epiphany
3193 These attributes specify how a particular function is called on
3194 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3195 These attributes override the
3196 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3197 and @option{-mmedium-calls} (@pxref{ARC Options})
3198 command-line switches and @code{#pragma long_calls} settings. For ARM, the
3199 @code{long_call} attribute indicates that the function might be far
3200 away from the call site and require a different (more expensive)
3201 calling sequence. The @code{short_call} attribute always places
3202 the offset to the function from the call site into the @samp{BL}
3203 instruction directly.
3204
3205 For ARC, a function marked with the @code{long_call} attribute is
3206 always called using register-indirect jump-and-link instructions,
3207 thereby enabling the called function to be placed anywhere within the
3208 32-bit address space. A function marked with the @code{medium_call}
3209 attribute will always be close enough to be called with an unconditional
3210 branch-and-link instruction, which has a 25-bit offset from
3211 the call site. A function marked with the @code{short_call}
3212 attribute will always be close enough to be called with a conditional
3213 branch-and-link instruction, which has a 21-bit offset from
3214 the call site.
3215
3216 @item longcall/shortcall
3217 @cindex functions called via pointer on the RS/6000 and PowerPC
3218 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3219 indicates that the function might be far away from the call site and
3220 require a different (more expensive) calling sequence. The
3221 @code{shortcall} attribute indicates that the function is always close
3222 enough for the shorter calling sequence to be used. These attributes
3223 override both the @option{-mlongcall} switch and, on the RS/6000 and
3224 PowerPC, the @code{#pragma longcall} setting.
3225
3226 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3227 calls are necessary.
3228
3229 @item long_call/near/far
3230 @cindex indirect calls on MIPS
3231 These attributes specify how a particular function is called on MIPS@.
3232 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3233 command-line switch. The @code{long_call} and @code{far} attributes are
3234 synonyms, and cause the compiler to always call
3235 the function by first loading its address into a register, and then using
3236 the contents of that register. The @code{near} attribute has the opposite
3237 effect; it specifies that non-PIC calls should be made using the more
3238 efficient @code{jal} instruction.
3239
3240 @item malloc
3241 @cindex @code{malloc} attribute
3242 This tells the compiler that a function is @code{malloc}-like, i.e.,
3243 that the pointer @var{P} returned by the function cannot alias any
3244 other pointer valid when the function returns, and moreover no
3245 pointers to valid objects occur in any storage addressed by @var{P}.
3246
3247 Using this attribute can improve optimization. Functions like
3248 @code{malloc} and @code{calloc} have this property because they return
3249 a pointer to uninitialized or zeroed-out storage. However, functions
3250 like @code{realloc} do not have this property, as they can return a
3251 pointer to storage containing pointers.
3252
3253 @item mips16/nomips16
3254 @cindex @code{mips16} attribute
3255 @cindex @code{nomips16} attribute
3256
3257 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3258 function attributes to locally select or turn off MIPS16 code generation.
3259 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3260 while MIPS16 code generation is disabled for functions with the
3261 @code{nomips16} attribute. These attributes override the
3262 @option{-mips16} and @option{-mno-mips16} options on the command line
3263 (@pxref{MIPS Options}).
3264
3265 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3266 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3267 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
3268 may interact badly with some GCC extensions such as @code{__builtin_apply}
3269 (@pxref{Constructing Calls}).
3270
3271 @item micromips/nomicromips
3272 @cindex @code{micromips} attribute
3273 @cindex @code{nomicromips} attribute
3274
3275 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3276 function attributes to locally select or turn off microMIPS code generation.
3277 A function with the @code{micromips} attribute is emitted as microMIPS code,
3278 while microMIPS code generation is disabled for functions with the
3279 @code{nomicromips} attribute. These attributes override the
3280 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3281 (@pxref{MIPS Options}).
3282
3283 When compiling files containing mixed microMIPS and non-microMIPS code, the
3284 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3285 command line,
3286 not that within individual functions. Mixed microMIPS and non-microMIPS code
3287 may interact badly with some GCC extensions such as @code{__builtin_apply}
3288 (@pxref{Constructing Calls}).
3289
3290 @item model (@var{model-name})
3291 @cindex function addressability on the M32R/D
3292 @cindex variable addressability on the IA-64
3293
3294 On the M32R/D, use this attribute to set the addressability of an
3295 object, and of the code generated for a function. The identifier
3296 @var{model-name} is one of @code{small}, @code{medium}, or
3297 @code{large}, representing each of the code models.
3298
3299 Small model objects live in the lower 16MB of memory (so that their
3300 addresses can be loaded with the @code{ld24} instruction), and are
3301 callable with the @code{bl} instruction.
3302
3303 Medium model objects may live anywhere in the 32-bit address space (the
3304 compiler generates @code{seth/add3} instructions to load their addresses),
3305 and are callable with the @code{bl} instruction.
3306
3307 Large model objects may live anywhere in the 32-bit address space (the
3308 compiler generates @code{seth/add3} instructions to load their addresses),
3309 and may not be reachable with the @code{bl} instruction (the compiler
3310 generates the much slower @code{seth/add3/jl} instruction sequence).
3311
3312 On IA-64, use this attribute to set the addressability of an object.
3313 At present, the only supported identifier for @var{model-name} is
3314 @code{small}, indicating addressability via ``small'' (22-bit)
3315 addresses (so that their addresses can be loaded with the @code{addl}
3316 instruction). Caveat: such addressing is by definition not position
3317 independent and hence this attribute must not be used for objects
3318 defined by shared libraries.
3319
3320 @item ms_abi/sysv_abi
3321 @cindex @code{ms_abi} attribute
3322 @cindex @code{sysv_abi} attribute
3323
3324 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3325 to indicate which calling convention should be used for a function. The
3326 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3327 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3328 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
3329 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
3330
3331 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3332 requires the @option{-maccumulate-outgoing-args} option.
3333
3334 @item callee_pop_aggregate_return (@var{number})
3335 @cindex @code{callee_pop_aggregate_return} attribute
3336
3337 On 32-bit i?86-*-* targets, you can use this attribute to control how
3338 aggregates are returned in memory. If the caller is responsible for
3339 popping the hidden pointer together with the rest of the arguments, specify
3340 @var{number} equal to zero. If callee is responsible for popping the
3341 hidden pointer, specify @var{number} equal to one.
3342
3343 The default i386 ABI assumes that the callee pops the
3344 stack for hidden pointer. However, on 32-bit i386 Microsoft Windows targets,
3345 the compiler assumes that the
3346 caller pops the stack for hidden pointer.
3347
3348 @item ms_hook_prologue
3349 @cindex @code{ms_hook_prologue} attribute
3350
3351 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3352 this function attribute to make GCC generate the ``hot-patching'' function
3353 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3354 and newer.
3355
3356 @item hotpatch [(@var{prologue-halfwords})]
3357 @cindex @code{hotpatch} attribute
3358
3359 On S/390 System z targets, you can use this function attribute to
3360 make GCC generate a ``hot-patching'' function prologue. The
3361 @code{hotpatch} has no effect on funtions that are explicitly
3362 inline. If the @option{-mhotpatch} or @option{-mno-hotpatch}
3363 command-line option is used at the same time, the @code{hotpatch}
3364 attribute takes precedence. If an argument is given, the maximum
3365 allowed value is 1000000.
3366
3367 @item naked
3368 @cindex function without a prologue/epilogue code
3369 This attribute is available on the ARM, AVR, MCORE, MSP430, NDS32,
3370 RL78, RX and SPU ports. It allows the compiler to construct the
3371 requisite function declaration, while allowing the body of the
3372 function to be assembly code. The specified function will not have
3373 prologue/epilogue sequences generated by the compiler. Only Basic
3374 @code{asm} statements can safely be included in naked functions
3375 (@pxref{Basic Asm}). While using Extended @code{asm} or a mixture of
3376 Basic @code{asm} and ``C'' code may appear to work, they cannot be
3377 depended upon to work reliably and are not supported.
3378
3379 @item near
3380 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3381 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3382 use the normal calling convention based on @code{jsr} and @code{rts}.
3383 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3384 option.
3385
3386 On MeP targets this attribute causes the compiler to assume the called
3387 function is close enough to use the normal calling convention,
3388 overriding the @option{-mtf} command-line option.
3389
3390 @item nesting
3391 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3392 Use this attribute together with @code{interrupt_handler},
3393 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3394 entry code should enable nested interrupts or exceptions.
3395
3396 @item nmi_handler
3397 @cindex NMI handler functions on the Blackfin processor
3398 Use this attribute on the Blackfin to indicate that the specified function
3399 is an NMI handler. The compiler generates function entry and
3400 exit sequences suitable for use in an NMI handler when this
3401 attribute is present.
3402
3403 @item nocompression
3404 @cindex @code{nocompression} attribute
3405 On MIPS targets, you can use the @code{nocompression} function attribute
3406 to locally turn off MIPS16 and microMIPS code generation. This attribute
3407 overrides the @option{-mips16} and @option{-mmicromips} options on the
3408 command line (@pxref{MIPS Options}).
3409
3410 @item no_instrument_function
3411 @cindex @code{no_instrument_function} function attribute
3412 @opindex finstrument-functions
3413 If @option{-finstrument-functions} is given, profiling function calls are
3414 generated at entry and exit of most user-compiled functions.
3415 Functions with this attribute are not so instrumented.
3416
3417 @item no_split_stack
3418 @cindex @code{no_split_stack} function attribute
3419 @opindex fsplit-stack
3420 If @option{-fsplit-stack} is given, functions have a small
3421 prologue which decides whether to split the stack. Functions with the
3422 @code{no_split_stack} attribute do not have that prologue, and thus
3423 may run with only a small amount of stack space available.
3424
3425 @item noinline
3426 @cindex @code{noinline} function attribute
3427 This function attribute prevents a function from being considered for
3428 inlining.
3429 @c Don't enumerate the optimizations by name here; we try to be
3430 @c future-compatible with this mechanism.
3431 If the function does not have side-effects, there are optimizations
3432 other than inlining that cause function calls to be optimized away,
3433 although the function call is live. To keep such calls from being
3434 optimized away, put
3435 @smallexample
3436 asm ("");
3437 @end smallexample
3438
3439 @noindent
3440 (@pxref{Extended Asm}) in the called function, to serve as a special
3441 side-effect.
3442
3443 @item noclone
3444 @cindex @code{noclone} function attribute
3445 This function attribute prevents a function from being considered for
3446 cloning---a mechanism that produces specialized copies of functions
3447 and which is (currently) performed by interprocedural constant
3448 propagation.
3449
3450 @item nonnull (@var{arg-index}, @dots{})
3451 @cindex @code{nonnull} function attribute
3452 The @code{nonnull} attribute specifies that some function parameters should
3453 be non-null pointers. For instance, the declaration:
3454
3455 @smallexample
3456 extern void *
3457 my_memcpy (void *dest, const void *src, size_t len)
3458 __attribute__((nonnull (1, 2)));
3459 @end smallexample
3460
3461 @noindent
3462 causes the compiler to check that, in calls to @code{my_memcpy},
3463 arguments @var{dest} and @var{src} are non-null. If the compiler
3464 determines that a null pointer is passed in an argument slot marked
3465 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3466 is issued. The compiler may also choose to make optimizations based
3467 on the knowledge that certain function arguments will never be null.
3468
3469 If no argument index list is given to the @code{nonnull} attribute,
3470 all pointer arguments are marked as non-null. To illustrate, the
3471 following declaration is equivalent to the previous example:
3472
3473 @smallexample
3474 extern void *
3475 my_memcpy (void *dest, const void *src, size_t len)
3476 __attribute__((nonnull));
3477 @end smallexample
3478
3479 @item no_reorder
3480 @cindex @code{no_reorder} function or variable attribute
3481 Do not reorder functions or variables marked @code{no_reorder}
3482 against each other or top level assembler statements the executable.
3483 The actual order in the program will depend on the linker command
3484 line. Static variables marked like this are also not removed.
3485 This has a similar effect
3486 as the @option{-fno-toplevel-reorder} option, but only applies to the
3487 marked symbols.
3488
3489 @item returns_nonnull
3490 @cindex @code{returns_nonnull} function attribute
3491 The @code{returns_nonnull} attribute specifies that the function
3492 return value should be a non-null pointer. For instance, the declaration:
3493
3494 @smallexample
3495 extern void *
3496 mymalloc (size_t len) __attribute__((returns_nonnull));
3497 @end smallexample
3498
3499 @noindent
3500 lets the compiler optimize callers based on the knowledge
3501 that the return value will never be null.
3502
3503 @item noreturn
3504 @cindex @code{noreturn} function attribute
3505 A few standard library functions, such as @code{abort} and @code{exit},
3506 cannot return. GCC knows this automatically. Some programs define
3507 their own functions that never return. You can declare them
3508 @code{noreturn} to tell the compiler this fact. For example,
3509
3510 @smallexample
3511 @group
3512 void fatal () __attribute__ ((noreturn));
3513
3514 void
3515 fatal (/* @r{@dots{}} */)
3516 @{
3517 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3518 exit (1);
3519 @}
3520 @end group
3521 @end smallexample
3522
3523 The @code{noreturn} keyword tells the compiler to assume that
3524 @code{fatal} cannot return. It can then optimize without regard to what
3525 would happen if @code{fatal} ever did return. This makes slightly
3526 better code. More importantly, it helps avoid spurious warnings of
3527 uninitialized variables.
3528
3529 The @code{noreturn} keyword does not affect the exceptional path when that
3530 applies: a @code{noreturn}-marked function may still return to the caller
3531 by throwing an exception or calling @code{longjmp}.
3532
3533 Do not assume that registers saved by the calling function are
3534 restored before calling the @code{noreturn} function.
3535
3536 It does not make sense for a @code{noreturn} function to have a return
3537 type other than @code{void}.
3538
3539 The attribute @code{noreturn} is not implemented in GCC versions
3540 earlier than 2.5. An alternative way to declare that a function does
3541 not return, which works in the current version and in some older
3542 versions, is as follows:
3543
3544 @smallexample
3545 typedef void voidfn ();
3546
3547 volatile voidfn fatal;
3548 @end smallexample
3549
3550 @noindent
3551 This approach does not work in GNU C++.
3552
3553 @item nothrow
3554 @cindex @code{nothrow} function attribute
3555 The @code{nothrow} attribute is used to inform the compiler that a
3556 function cannot throw an exception. For example, most functions in
3557 the standard C library can be guaranteed not to throw an exception
3558 with the notable exceptions of @code{qsort} and @code{bsearch} that
3559 take function pointer arguments. The @code{nothrow} attribute is not
3560 implemented in GCC versions earlier than 3.3.
3561
3562 @item nosave_low_regs
3563 @cindex @code{nosave_low_regs} attribute
3564 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3565 function should not save and restore registers R0..R7. This can be used on SH3*
3566 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3567 interrupt handlers.
3568
3569 @item optimize
3570 @cindex @code{optimize} function attribute
3571 The @code{optimize} attribute is used to specify that a function is to
3572 be compiled with different optimization options than specified on the
3573 command line. Arguments can either be numbers or strings. Numbers
3574 are assumed to be an optimization level. Strings that begin with
3575 @code{O} are assumed to be an optimization option, while other options
3576 are assumed to be used with a @code{-f} prefix. You can also use the
3577 @samp{#pragma GCC optimize} pragma to set the optimization options
3578 that affect more than one function.
3579 @xref{Function Specific Option Pragmas}, for details about the
3580 @samp{#pragma GCC optimize} pragma.
3581
3582 This can be used for instance to have frequently-executed functions
3583 compiled with more aggressive optimization options that produce faster
3584 and larger code, while other functions can be compiled with less
3585 aggressive options.
3586
3587 @item OS_main/OS_task
3588 @cindex @code{OS_main} AVR function attribute
3589 @cindex @code{OS_task} AVR function attribute
3590 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3591 do not save/restore any call-saved register in their prologue/epilogue.
3592
3593 The @code{OS_main} attribute can be used when there @emph{is
3594 guarantee} that interrupts are disabled at the time when the function
3595 is entered. This saves resources when the stack pointer has to be
3596 changed to set up a frame for local variables.
3597
3598 The @code{OS_task} attribute can be used when there is @emph{no
3599 guarantee} that interrupts are disabled at that time when the function
3600 is entered like for, e@.g@. task functions in a multi-threading operating
3601 system. In that case, changing the stack pointer register is
3602 guarded by save/clear/restore of the global interrupt enable flag.
3603
3604 The differences to the @code{naked} function attribute are:
3605 @itemize @bullet
3606 @item @code{naked} functions do not have a return instruction whereas
3607 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3608 @code{RETI} return instruction.
3609 @item @code{naked} functions do not set up a frame for local variables
3610 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3611 as needed.
3612 @end itemize
3613
3614 @item pcs
3615 @cindex @code{pcs} function attribute
3616
3617 The @code{pcs} attribute can be used to control the calling convention
3618 used for a function on ARM. The attribute takes an argument that specifies
3619 the calling convention to use.
3620
3621 When compiling using the AAPCS ABI (or a variant of it) then valid
3622 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3623 order to use a variant other than @code{"aapcs"} then the compiler must
3624 be permitted to use the appropriate co-processor registers (i.e., the
3625 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3626 For example,
3627
3628 @smallexample
3629 /* Argument passed in r0, and result returned in r0+r1. */
3630 double f2d (float) __attribute__((pcs("aapcs")));
3631 @end smallexample
3632
3633 Variadic functions always use the @code{"aapcs"} calling convention and
3634 the compiler rejects attempts to specify an alternative.
3635
3636 @item pure
3637 @cindex @code{pure} function attribute
3638 Many functions have no effects except the return value and their
3639 return value depends only on the parameters and/or global variables.
3640 Such a function can be subject
3641 to common subexpression elimination and loop optimization just as an
3642 arithmetic operator would be. These functions should be declared
3643 with the attribute @code{pure}. For example,
3644
3645 @smallexample
3646 int square (int) __attribute__ ((pure));
3647 @end smallexample
3648
3649 @noindent
3650 says that the hypothetical function @code{square} is safe to call
3651 fewer times than the program says.
3652
3653 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3654 Interesting non-pure functions are functions with infinite loops or those
3655 depending on volatile memory or other system resource, that may change between
3656 two consecutive calls (such as @code{feof} in a multithreading environment).
3657
3658 The attribute @code{pure} is not implemented in GCC versions earlier
3659 than 2.96.
3660
3661 @item hot
3662 @cindex @code{hot} function attribute
3663 The @code{hot} attribute on a function is used to inform the compiler that
3664 the function is a hot spot of the compiled program. The function is
3665 optimized more aggressively and on many targets it is placed into a special
3666 subsection of the text section so all hot functions appear close together,
3667 improving locality.
3668
3669 When profile feedback is available, via @option{-fprofile-use}, hot functions
3670 are automatically detected and this attribute is ignored.
3671
3672 The @code{hot} attribute on functions is not implemented in GCC versions
3673 earlier than 4.3.
3674
3675 @item cold
3676 @cindex @code{cold} function attribute
3677 The @code{cold} attribute on functions is used to inform the compiler that
3678 the function is unlikely to be executed. The function is optimized for
3679 size rather than speed and on many targets it is placed into a special
3680 subsection of the text section so all cold functions appear close together,
3681 improving code locality of non-cold parts of program. The paths leading
3682 to calls of cold functions within code are marked as unlikely by the branch
3683 prediction mechanism. It is thus useful to mark functions used to handle
3684 unlikely conditions, such as @code{perror}, as cold to improve optimization
3685 of hot functions that do call marked functions in rare occasions.
3686
3687 When profile feedback is available, via @option{-fprofile-use}, cold functions
3688 are automatically detected and this attribute is ignored.
3689
3690 The @code{cold} attribute on functions is not implemented in GCC versions
3691 earlier than 4.3.
3692
3693 @item no_sanitize_address
3694 @itemx no_address_safety_analysis
3695 @cindex @code{no_sanitize_address} function attribute
3696 The @code{no_sanitize_address} attribute on functions is used
3697 to inform the compiler that it should not instrument memory accesses
3698 in the function when compiling with the @option{-fsanitize=address} option.
3699 The @code{no_address_safety_analysis} is a deprecated alias of the
3700 @code{no_sanitize_address} attribute, new code should use
3701 @code{no_sanitize_address}.
3702
3703 @item no_sanitize_undefined
3704 @cindex @code{no_sanitize_undefined} function attribute
3705 The @code{no_sanitize_undefined} attribute on functions is used
3706 to inform the compiler that it should not check for undefined behavior
3707 in the function when compiling with the @option{-fsanitize=undefined} option.
3708
3709 @item bnd_legacy
3710 @cindex @code{bnd_legacy} function attribute
3711 The @code{bnd_legacy} attribute on functions is used to inform
3712 compiler that function should not be instrumented when compiled
3713 with @option{-fcheck-pointer-bounds} option.
3714
3715 @item bnd_instrument
3716 @cindex @code{bnd_instrument} function attribute
3717 The @code{bnd_instrument} attribute on functions is used to inform
3718 compiler that function should be instrumented when compiled
3719 with @option{-fchkp-instrument-marked-only} option.
3720
3721 @item regparm (@var{number})
3722 @cindex @code{regparm} attribute
3723 @cindex functions that are passed arguments in registers on the 386
3724 On the Intel 386, the @code{regparm} attribute causes the compiler to
3725 pass arguments number one to @var{number} if they are of integral type
3726 in registers EAX, EDX, and ECX instead of on the stack. Functions that
3727 take a variable number of arguments continue to be passed all of their
3728 arguments on the stack.
3729
3730 Beware that on some ELF systems this attribute is unsuitable for
3731 global functions in shared libraries with lazy binding (which is the
3732 default). Lazy binding sends the first call via resolving code in
3733 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3734 per the standard calling conventions. Solaris 8 is affected by this.
3735 Systems with the GNU C Library version 2.1 or higher
3736 and FreeBSD are believed to be
3737 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
3738 disabled with the linker or the loader if desired, to avoid the
3739 problem.)
3740
3741 @item reset
3742 @cindex reset handler functions
3743 Use this attribute on the NDS32 target to indicate that the specified function
3744 is a reset handler. The compiler will generate corresponding sections
3745 for use in a reset handler. You can use the following attributes
3746 to provide extra exception handling:
3747 @table @code
3748 @item nmi
3749 @cindex @code{nmi} attribute
3750 Provide a user-defined function to handle NMI exception.
3751 @item warm
3752 @cindex @code{warm} attribute
3753 Provide a user-defined function to handle warm reset exception.
3754 @end table
3755
3756 @item sseregparm
3757 @cindex @code{sseregparm} attribute
3758 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3759 causes the compiler to pass up to 3 floating-point arguments in
3760 SSE registers instead of on the stack. Functions that take a
3761 variable number of arguments continue to pass all of their
3762 floating-point arguments on the stack.
3763
3764 @item force_align_arg_pointer
3765 @cindex @code{force_align_arg_pointer} attribute
3766 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3767 applied to individual function definitions, generating an alternate
3768 prologue and epilogue that realigns the run-time stack if necessary.
3769 This supports mixing legacy codes that run with a 4-byte aligned stack
3770 with modern codes that keep a 16-byte stack for SSE compatibility.
3771
3772 @item renesas
3773 @cindex @code{renesas} attribute
3774 On SH targets this attribute specifies that the function or struct follows the
3775 Renesas ABI.
3776
3777 @item resbank
3778 @cindex @code{resbank} attribute
3779 On the SH2A target, this attribute enables the high-speed register
3780 saving and restoration using a register bank for @code{interrupt_handler}
3781 routines. Saving to the bank is performed automatically after the CPU
3782 accepts an interrupt that uses a register bank.
3783
3784 The nineteen 32-bit registers comprising general register R0 to R14,
3785 control register GBR, and system registers MACH, MACL, and PR and the
3786 vector table address offset are saved into a register bank. Register
3787 banks are stacked in first-in last-out (FILO) sequence. Restoration
3788 from the bank is executed by issuing a RESBANK instruction.
3789
3790 @item returns_twice
3791 @cindex @code{returns_twice} attribute
3792 The @code{returns_twice} attribute tells the compiler that a function may
3793 return more than one time. The compiler ensures that all registers
3794 are dead before calling such a function and emits a warning about
3795 the variables that may be clobbered after the second return from the
3796 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3797 The @code{longjmp}-like counterpart of such function, if any, might need
3798 to be marked with the @code{noreturn} attribute.
3799
3800 @item saveall
3801 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3802 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3803 all registers except the stack pointer should be saved in the prologue
3804 regardless of whether they are used or not.
3805
3806 @item save_volatiles
3807 @cindex save volatile registers on the MicroBlaze
3808 Use this attribute on the MicroBlaze to indicate that the function is
3809 an interrupt handler. All volatile registers (in addition to non-volatile
3810 registers) are saved in the function prologue. If the function is a leaf
3811 function, only volatiles used by the function are saved. A normal function
3812 return is generated instead of a return from interrupt.
3813
3814 @item break_handler
3815 @cindex break handler functions
3816 Use this attribute on the MicroBlaze ports to indicate that
3817 the specified function is an break handler. The compiler generates function
3818 entry and exit sequences suitable for use in an break handler when this
3819 attribute is present. The return from @code{break_handler} is done through
3820 the @code{rtbd} instead of @code{rtsd}.
3821
3822 @smallexample
3823 void f () __attribute__ ((break_handler));
3824 @end smallexample
3825
3826 @item section ("@var{section-name}")
3827 @cindex @code{section} function attribute
3828 Normally, the compiler places the code it generates in the @code{text} section.
3829 Sometimes, however, you need additional sections, or you need certain
3830 particular functions to appear in special sections. The @code{section}
3831 attribute specifies that a function lives in a particular section.
3832 For example, the declaration:
3833
3834 @smallexample
3835 extern void foobar (void) __attribute__ ((section ("bar")));
3836 @end smallexample
3837
3838 @noindent
3839 puts the function @code{foobar} in the @code{bar} section.
3840
3841 Some file formats do not support arbitrary sections so the @code{section}
3842 attribute is not available on all platforms.
3843 If you need to map the entire contents of a module to a particular
3844 section, consider using the facilities of the linker instead.
3845
3846 @item sentinel
3847 @cindex @code{sentinel} function attribute
3848 This function attribute ensures that a parameter in a function call is
3849 an explicit @code{NULL}. The attribute is only valid on variadic
3850 functions. By default, the sentinel is located at position zero, the
3851 last parameter of the function call. If an optional integer position
3852 argument P is supplied to the attribute, the sentinel must be located at
3853 position P counting backwards from the end of the argument list.
3854
3855 @smallexample
3856 __attribute__ ((sentinel))
3857 is equivalent to
3858 __attribute__ ((sentinel(0)))
3859 @end smallexample
3860
3861 The attribute is automatically set with a position of 0 for the built-in
3862 functions @code{execl} and @code{execlp}. The built-in function
3863 @code{execle} has the attribute set with a position of 1.
3864
3865 A valid @code{NULL} in this context is defined as zero with any pointer
3866 type. If your system defines the @code{NULL} macro with an integer type
3867 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3868 with a copy that redefines NULL appropriately.
3869
3870 The warnings for missing or incorrect sentinels are enabled with
3871 @option{-Wformat}.
3872
3873 @item short_call
3874 See @code{long_call/short_call}.
3875
3876 @item shortcall
3877 See @code{longcall/shortcall}.
3878
3879 @item signal
3880 @cindex interrupt handler functions on the AVR processors
3881 Use this attribute on the AVR to indicate that the specified
3882 function is an interrupt handler. The compiler generates function
3883 entry and exit sequences suitable for use in an interrupt handler when this
3884 attribute is present.
3885
3886 See also the @code{interrupt} function attribute.
3887
3888 The AVR hardware globally disables interrupts when an interrupt is executed.
3889 Interrupt handler functions defined with the @code{signal} attribute
3890 do not re-enable interrupts. It is save to enable interrupts in a
3891 @code{signal} handler. This ``save'' only applies to the code
3892 generated by the compiler and not to the IRQ layout of the
3893 application which is responsibility of the application.
3894
3895 If both @code{signal} and @code{interrupt} are specified for the same
3896 function, @code{signal} is silently ignored.
3897
3898 @item sp_switch
3899 @cindex @code{sp_switch} attribute
3900 Use this attribute on the SH to indicate an @code{interrupt_handler}
3901 function should switch to an alternate stack. It expects a string
3902 argument that names a global variable holding the address of the
3903 alternate stack.
3904
3905 @smallexample
3906 void *alt_stack;
3907 void f () __attribute__ ((interrupt_handler,
3908 sp_switch ("alt_stack")));
3909 @end smallexample
3910
3911 @item stdcall
3912 @cindex functions that pop the argument stack on the 386
3913 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3914 assume that the called function pops off the stack space used to
3915 pass arguments, unless it takes a variable number of arguments.
3916
3917 @item syscall_linkage
3918 @cindex @code{syscall_linkage} attribute
3919 This attribute is used to modify the IA-64 calling convention by marking
3920 all input registers as live at all function exits. This makes it possible
3921 to restart a system call after an interrupt without having to save/restore
3922 the input registers. This also prevents kernel data from leaking into
3923 application code.
3924
3925 @item target
3926 @cindex @code{target} function attribute
3927 The @code{target} attribute is used to specify that a function is to
3928 be compiled with different target options than specified on the
3929 command line. This can be used for instance to have functions
3930 compiled with a different ISA (instruction set architecture) than the
3931 default. You can also use the @samp{#pragma GCC target} pragma to set
3932 more than one function to be compiled with specific target options.
3933 @xref{Function Specific Option Pragmas}, for details about the
3934 @samp{#pragma GCC target} pragma.
3935
3936 For instance on a 386, you could compile one function with
3937 @code{target("sse4.1,arch=core2")} and another with
3938 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3939 compiling the first function with @option{-msse4.1} and
3940 @option{-march=core2} options, and the second function with
3941 @option{-msse4a} and @option{-march=amdfam10} options. It is up to the
3942 user to make sure that a function is only invoked on a machine that
3943 supports the particular ISA it is compiled for (for example by using
3944 @code{cpuid} on 386 to determine what feature bits and architecture
3945 family are used).
3946
3947 @smallexample
3948 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3949 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3950 @end smallexample
3951
3952 You can either use multiple
3953 strings to specify multiple options, or separate the options
3954 with a comma (@samp{,}).
3955
3956 The @code{target} attribute is presently implemented for
3957 i386/x86_64, PowerPC, and Nios II targets only.
3958 The options supported are specific to each target.
3959
3960 On the 386, the following options are allowed:
3961
3962 @table @samp
3963 @item abm
3964 @itemx no-abm
3965 @cindex @code{target("abm")} attribute
3966 Enable/disable the generation of the advanced bit instructions.
3967
3968 @item aes
3969 @itemx no-aes
3970 @cindex @code{target("aes")} attribute
3971 Enable/disable the generation of the AES instructions.
3972
3973 @item default
3974 @cindex @code{target("default")} attribute
3975 @xref{Function Multiversioning}, where it is used to specify the
3976 default function version.
3977
3978 @item mmx
3979 @itemx no-mmx
3980 @cindex @code{target("mmx")} attribute
3981 Enable/disable the generation of the MMX instructions.
3982
3983 @item pclmul
3984 @itemx no-pclmul
3985 @cindex @code{target("pclmul")} attribute
3986 Enable/disable the generation of the PCLMUL instructions.
3987
3988 @item popcnt
3989 @itemx no-popcnt
3990 @cindex @code{target("popcnt")} attribute
3991 Enable/disable the generation of the POPCNT instruction.
3992
3993 @item sse
3994 @itemx no-sse
3995 @cindex @code{target("sse")} attribute
3996 Enable/disable the generation of the SSE instructions.
3997
3998 @item sse2
3999 @itemx no-sse2
4000 @cindex @code{target("sse2")} attribute
4001 Enable/disable the generation of the SSE2 instructions.
4002
4003 @item sse3
4004 @itemx no-sse3
4005 @cindex @code{target("sse3")} attribute
4006 Enable/disable the generation of the SSE3 instructions.
4007
4008 @item sse4
4009 @itemx no-sse4
4010 @cindex @code{target("sse4")} attribute
4011 Enable/disable the generation of the SSE4 instructions (both SSE4.1
4012 and SSE4.2).
4013
4014 @item sse4.1
4015 @itemx no-sse4.1
4016 @cindex @code{target("sse4.1")} attribute
4017 Enable/disable the generation of the sse4.1 instructions.
4018
4019 @item sse4.2
4020 @itemx no-sse4.2
4021 @cindex @code{target("sse4.2")} attribute
4022 Enable/disable the generation of the sse4.2 instructions.
4023
4024 @item sse4a
4025 @itemx no-sse4a
4026 @cindex @code{target("sse4a")} attribute
4027 Enable/disable the generation of the SSE4A instructions.
4028
4029 @item fma4
4030 @itemx no-fma4
4031 @cindex @code{target("fma4")} attribute
4032 Enable/disable the generation of the FMA4 instructions.
4033
4034 @item xop
4035 @itemx no-xop
4036 @cindex @code{target("xop")} attribute
4037 Enable/disable the generation of the XOP instructions.
4038
4039 @item lwp
4040 @itemx no-lwp
4041 @cindex @code{target("lwp")} attribute
4042 Enable/disable the generation of the LWP instructions.
4043
4044 @item ssse3
4045 @itemx no-ssse3
4046 @cindex @code{target("ssse3")} attribute
4047 Enable/disable the generation of the SSSE3 instructions.
4048
4049 @item cld
4050 @itemx no-cld
4051 @cindex @code{target("cld")} attribute
4052 Enable/disable the generation of the CLD before string moves.
4053
4054 @item fancy-math-387
4055 @itemx no-fancy-math-387
4056 @cindex @code{target("fancy-math-387")} attribute
4057 Enable/disable the generation of the @code{sin}, @code{cos}, and
4058 @code{sqrt} instructions on the 387 floating-point unit.
4059
4060 @item fused-madd
4061 @itemx no-fused-madd
4062 @cindex @code{target("fused-madd")} attribute
4063 Enable/disable the generation of the fused multiply/add instructions.
4064
4065 @item ieee-fp
4066 @itemx no-ieee-fp
4067 @cindex @code{target("ieee-fp")} attribute
4068 Enable/disable the generation of floating point that depends on IEEE arithmetic.
4069
4070 @item inline-all-stringops
4071 @itemx no-inline-all-stringops
4072 @cindex @code{target("inline-all-stringops")} attribute
4073 Enable/disable inlining of string operations.
4074
4075 @item inline-stringops-dynamically
4076 @itemx no-inline-stringops-dynamically
4077 @cindex @code{target("inline-stringops-dynamically")} attribute
4078 Enable/disable the generation of the inline code to do small string
4079 operations and calling the library routines for large operations.
4080
4081 @item align-stringops
4082 @itemx no-align-stringops
4083 @cindex @code{target("align-stringops")} attribute
4084 Do/do not align destination of inlined string operations.
4085
4086 @item recip
4087 @itemx no-recip
4088 @cindex @code{target("recip")} attribute
4089 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
4090 instructions followed an additional Newton-Raphson step instead of
4091 doing a floating-point division.
4092
4093 @item arch=@var{ARCH}
4094 @cindex @code{target("arch=@var{ARCH}")} attribute
4095 Specify the architecture to generate code for in compiling the function.
4096
4097 @item tune=@var{TUNE}
4098 @cindex @code{target("tune=@var{TUNE}")} attribute
4099 Specify the architecture to tune for in compiling the function.
4100
4101 @item fpmath=@var{FPMATH}
4102 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
4103 Specify which floating-point unit to use. The
4104 @code{target("fpmath=sse,387")} option must be specified as
4105 @code{target("fpmath=sse+387")} because the comma would separate
4106 different options.
4107 @end table
4108
4109 On the PowerPC, the following options are allowed:
4110
4111 @table @samp
4112 @item altivec
4113 @itemx no-altivec
4114 @cindex @code{target("altivec")} attribute
4115 Generate code that uses (does not use) AltiVec instructions. In
4116 32-bit code, you cannot enable AltiVec instructions unless
4117 @option{-mabi=altivec} is used on the command line.
4118
4119 @item cmpb
4120 @itemx no-cmpb
4121 @cindex @code{target("cmpb")} attribute
4122 Generate code that uses (does not use) the compare bytes instruction
4123 implemented on the POWER6 processor and other processors that support
4124 the PowerPC V2.05 architecture.
4125
4126 @item dlmzb
4127 @itemx no-dlmzb
4128 @cindex @code{target("dlmzb")} attribute
4129 Generate code that uses (does not use) the string-search @samp{dlmzb}
4130 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4131 generated by default when targeting those processors.
4132
4133 @item fprnd
4134 @itemx no-fprnd
4135 @cindex @code{target("fprnd")} attribute
4136 Generate code that uses (does not use) the FP round to integer
4137 instructions implemented on the POWER5+ processor and other processors
4138 that support the PowerPC V2.03 architecture.
4139
4140 @item hard-dfp
4141 @itemx no-hard-dfp
4142 @cindex @code{target("hard-dfp")} attribute
4143 Generate code that uses (does not use) the decimal floating-point
4144 instructions implemented on some POWER processors.
4145
4146 @item isel
4147 @itemx no-isel
4148 @cindex @code{target("isel")} attribute
4149 Generate code that uses (does not use) ISEL instruction.
4150
4151 @item mfcrf
4152 @itemx no-mfcrf
4153 @cindex @code{target("mfcrf")} attribute
4154 Generate code that uses (does not use) the move from condition
4155 register field instruction implemented on the POWER4 processor and
4156 other processors that support the PowerPC V2.01 architecture.
4157
4158 @item mfpgpr
4159 @itemx no-mfpgpr
4160 @cindex @code{target("mfpgpr")} attribute
4161 Generate code that uses (does not use) the FP move to/from general
4162 purpose register instructions implemented on the POWER6X processor and
4163 other processors that support the extended PowerPC V2.05 architecture.
4164
4165 @item mulhw
4166 @itemx no-mulhw
4167 @cindex @code{target("mulhw")} attribute
4168 Generate code that uses (does not use) the half-word multiply and
4169 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4170 These instructions are generated by default when targeting those
4171 processors.
4172
4173 @item multiple
4174 @itemx no-multiple
4175 @cindex @code{target("multiple")} attribute
4176 Generate code that uses (does not use) the load multiple word
4177 instructions and the store multiple word instructions.
4178
4179 @item update
4180 @itemx no-update
4181 @cindex @code{target("update")} attribute
4182 Generate code that uses (does not use) the load or store instructions
4183 that update the base register to the address of the calculated memory
4184 location.
4185
4186 @item popcntb
4187 @itemx no-popcntb
4188 @cindex @code{target("popcntb")} attribute
4189 Generate code that uses (does not use) the popcount and double-precision
4190 FP reciprocal estimate instruction implemented on the POWER5
4191 processor and other processors that support the PowerPC V2.02
4192 architecture.
4193
4194 @item popcntd
4195 @itemx no-popcntd
4196 @cindex @code{target("popcntd")} attribute
4197 Generate code that uses (does not use) the popcount instruction
4198 implemented on the POWER7 processor and other processors that support
4199 the PowerPC V2.06 architecture.
4200
4201 @item powerpc-gfxopt
4202 @itemx no-powerpc-gfxopt
4203 @cindex @code{target("powerpc-gfxopt")} attribute
4204 Generate code that uses (does not use) the optional PowerPC
4205 architecture instructions in the Graphics group, including
4206 floating-point select.
4207
4208 @item powerpc-gpopt
4209 @itemx no-powerpc-gpopt
4210 @cindex @code{target("powerpc-gpopt")} attribute
4211 Generate code that uses (does not use) the optional PowerPC
4212 architecture instructions in the General Purpose group, including
4213 floating-point square root.
4214
4215 @item recip-precision
4216 @itemx no-recip-precision
4217 @cindex @code{target("recip-precision")} attribute
4218 Assume (do not assume) that the reciprocal estimate instructions
4219 provide higher-precision estimates than is mandated by the powerpc
4220 ABI.
4221
4222 @item string
4223 @itemx no-string
4224 @cindex @code{target("string")} attribute
4225 Generate code that uses (does not use) the load string instructions
4226 and the store string word instructions to save multiple registers and
4227 do small block moves.
4228
4229 @item vsx
4230 @itemx no-vsx
4231 @cindex @code{target("vsx")} attribute
4232 Generate code that uses (does not use) vector/scalar (VSX)
4233 instructions, and also enable the use of built-in functions that allow
4234 more direct access to the VSX instruction set. In 32-bit code, you
4235 cannot enable VSX or AltiVec instructions unless
4236 @option{-mabi=altivec} is used on the command line.
4237
4238 @item friz
4239 @itemx no-friz
4240 @cindex @code{target("friz")} attribute
4241 Generate (do not generate) the @code{friz} instruction when the
4242 @option{-funsafe-math-optimizations} option is used to optimize
4243 rounding a floating-point value to 64-bit integer and back to floating
4244 point. The @code{friz} instruction does not return the same value if
4245 the floating-point number is too large to fit in an integer.
4246
4247 @item avoid-indexed-addresses
4248 @itemx no-avoid-indexed-addresses
4249 @cindex @code{target("avoid-indexed-addresses")} attribute
4250 Generate code that tries to avoid (not avoid) the use of indexed load
4251 or store instructions.
4252
4253 @item paired
4254 @itemx no-paired
4255 @cindex @code{target("paired")} attribute
4256 Generate code that uses (does not use) the generation of PAIRED simd
4257 instructions.
4258
4259 @item longcall
4260 @itemx no-longcall
4261 @cindex @code{target("longcall")} attribute
4262 Generate code that assumes (does not assume) that all calls are far
4263 away so that a longer more expensive calling sequence is required.
4264
4265 @item cpu=@var{CPU}
4266 @cindex @code{target("cpu=@var{CPU}")} attribute
4267 Specify the architecture to generate code for when compiling the
4268 function. If you select the @code{target("cpu=power7")} attribute when
4269 generating 32-bit code, VSX and AltiVec instructions are not generated
4270 unless you use the @option{-mabi=altivec} option on the command line.
4271
4272 @item tune=@var{TUNE}
4273 @cindex @code{target("tune=@var{TUNE}")} attribute
4274 Specify the architecture to tune for when compiling the function. If
4275 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4276 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4277 compilation tunes for the @var{CPU} architecture, and not the
4278 default tuning specified on the command line.
4279 @end table
4280
4281 When compiling for Nios II, the following options are allowed:
4282
4283 @table @samp
4284 @item custom-@var{insn}=@var{N}
4285 @itemx no-custom-@var{insn}
4286 @cindex @code{target("custom-@var{insn}=@var{N}")} attribute
4287 @cindex @code{target("no-custom-@var{insn}")} attribute
4288 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4289 custom instruction with encoding @var{N} when generating code that uses
4290 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4291 the custom instruction @var{insn}.
4292 These target attributes correspond to the
4293 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4294 command-line options, and support the same set of @var{insn} keywords.
4295 @xref{Nios II Options}, for more information.
4296
4297 @item custom-fpu-cfg=@var{name}
4298 @cindex @code{target("custom-fpu-cfg=@var{name}")} attribute
4299 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4300 command-line option, to select a predefined set of custom instructions
4301 named @var{name}.
4302 @xref{Nios II Options}, for more information.
4303 @end table
4304
4305 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
4306 function that has different target options than the caller, unless the
4307 callee has a subset of the target options of the caller. For example
4308 a function declared with @code{target("sse3")} can inline a function
4309 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4310
4311 @item tiny_data
4312 @cindex tiny data section on the H8/300H and H8S
4313 Use this attribute on the H8/300H and H8S to indicate that the specified
4314 variable should be placed into the tiny data section.
4315 The compiler generates more efficient code for loads and stores
4316 on data in the tiny data section. Note the tiny data area is limited to
4317 slightly under 32KB of data.
4318
4319 @item trap_exit
4320 @cindex @code{trap_exit} attribute
4321 Use this attribute on the SH for an @code{interrupt_handler} to return using
4322 @code{trapa} instead of @code{rte}. This attribute expects an integer
4323 argument specifying the trap number to be used.
4324
4325 @item trapa_handler
4326 @cindex @code{trapa_handler} attribute
4327 On SH targets this function attribute is similar to @code{interrupt_handler}
4328 but it does not save and restore all registers.
4329
4330 @item unused
4331 @cindex @code{unused} attribute.
4332 This attribute, attached to a function, means that the function is meant
4333 to be possibly unused. GCC does not produce a warning for this
4334 function.
4335
4336 @item used
4337 @cindex @code{used} attribute.
4338 This attribute, attached to a function, means that code must be emitted
4339 for the function even if it appears that the function is not referenced.
4340 This is useful, for example, when the function is referenced only in
4341 inline assembly.
4342
4343 When applied to a member function of a C++ class template, the
4344 attribute also means that the function is instantiated if the
4345 class itself is instantiated.
4346
4347 @item vector
4348 @cindex @code{vector} attribute
4349 This RX attribute is similar to the @code{interrupt} attribute, including its
4350 parameters, but does not make the function an interrupt-handler type
4351 function (i.e. it retains the normal C function calling ABI). See the
4352 @code{interrupt} attribute for a description of its arguments.
4353
4354 @item version_id
4355 @cindex @code{version_id} attribute
4356 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4357 symbol to contain a version string, thus allowing for function level
4358 versioning. HP-UX system header files may use function level versioning
4359 for some system calls.
4360
4361 @smallexample
4362 extern int foo () __attribute__((version_id ("20040821")));
4363 @end smallexample
4364
4365 @noindent
4366 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4367
4368 @item visibility ("@var{visibility_type}")
4369 @cindex @code{visibility} attribute
4370 This attribute affects the linkage of the declaration to which it is attached.
4371 There are four supported @var{visibility_type} values: default,
4372 hidden, protected or internal visibility.
4373
4374 @smallexample
4375 void __attribute__ ((visibility ("protected")))
4376 f () @{ /* @r{Do something.} */; @}
4377 int i __attribute__ ((visibility ("hidden")));
4378 @end smallexample
4379
4380 The possible values of @var{visibility_type} correspond to the
4381 visibility settings in the ELF gABI.
4382
4383 @table @dfn
4384 @c keep this list of visibilities in alphabetical order.
4385
4386 @item default
4387 Default visibility is the normal case for the object file format.
4388 This value is available for the visibility attribute to override other
4389 options that may change the assumed visibility of entities.
4390
4391 On ELF, default visibility means that the declaration is visible to other
4392 modules and, in shared libraries, means that the declared entity may be
4393 overridden.
4394
4395 On Darwin, default visibility means that the declaration is visible to
4396 other modules.
4397
4398 Default visibility corresponds to ``external linkage'' in the language.
4399
4400 @item hidden
4401 Hidden visibility indicates that the entity declared has a new
4402 form of linkage, which we call ``hidden linkage''. Two
4403 declarations of an object with hidden linkage refer to the same object
4404 if they are in the same shared object.
4405
4406 @item internal
4407 Internal visibility is like hidden visibility, but with additional
4408 processor specific semantics. Unless otherwise specified by the
4409 psABI, GCC defines internal visibility to mean that a function is
4410 @emph{never} called from another module. Compare this with hidden
4411 functions which, while they cannot be referenced directly by other
4412 modules, can be referenced indirectly via function pointers. By
4413 indicating that a function cannot be called from outside the module,
4414 GCC may for instance omit the load of a PIC register since it is known
4415 that the calling function loaded the correct value.
4416
4417 @item protected
4418 Protected visibility is like default visibility except that it
4419 indicates that references within the defining module bind to the
4420 definition in that module. That is, the declared entity cannot be
4421 overridden by another module.
4422
4423 @end table
4424
4425 All visibilities are supported on many, but not all, ELF targets
4426 (supported when the assembler supports the @samp{.visibility}
4427 pseudo-op). Default visibility is supported everywhere. Hidden
4428 visibility is supported on Darwin targets.
4429
4430 The visibility attribute should be applied only to declarations that
4431 would otherwise have external linkage. The attribute should be applied
4432 consistently, so that the same entity should not be declared with
4433 different settings of the attribute.
4434
4435 In C++, the visibility attribute applies to types as well as functions
4436 and objects, because in C++ types have linkage. A class must not have
4437 greater visibility than its non-static data member types and bases,
4438 and class members default to the visibility of their class. Also, a
4439 declaration without explicit visibility is limited to the visibility
4440 of its type.
4441
4442 In C++, you can mark member functions and static member variables of a
4443 class with the visibility attribute. This is useful if you know a
4444 particular method or static member variable should only be used from
4445 one shared object; then you can mark it hidden while the rest of the
4446 class has default visibility. Care must be taken to avoid breaking
4447 the One Definition Rule; for example, it is usually not useful to mark
4448 an inline method as hidden without marking the whole class as hidden.
4449
4450 A C++ namespace declaration can also have the visibility attribute.
4451
4452 @smallexample
4453 namespace nspace1 __attribute__ ((visibility ("protected")))
4454 @{ /* @r{Do something.} */; @}
4455 @end smallexample
4456
4457 This attribute applies only to the particular namespace body, not to
4458 other definitions of the same namespace; it is equivalent to using
4459 @samp{#pragma GCC visibility} before and after the namespace
4460 definition (@pxref{Visibility Pragmas}).
4461
4462 In C++, if a template argument has limited visibility, this
4463 restriction is implicitly propagated to the template instantiation.
4464 Otherwise, template instantiations and specializations default to the
4465 visibility of their template.
4466
4467 If both the template and enclosing class have explicit visibility, the
4468 visibility from the template is used.
4469
4470 @item vliw
4471 @cindex @code{vliw} attribute
4472 On MeP, the @code{vliw} attribute tells the compiler to emit
4473 instructions in VLIW mode instead of core mode. Note that this
4474 attribute is not allowed unless a VLIW coprocessor has been configured
4475 and enabled through command-line options.
4476
4477 @item warn_unused_result
4478 @cindex @code{warn_unused_result} attribute
4479 The @code{warn_unused_result} attribute causes a warning to be emitted
4480 if a caller of the function with this attribute does not use its
4481 return value. This is useful for functions where not checking
4482 the result is either a security problem or always a bug, such as
4483 @code{realloc}.
4484
4485 @smallexample
4486 int fn () __attribute__ ((warn_unused_result));
4487 int foo ()
4488 @{
4489 if (fn () < 0) return -1;
4490 fn ();
4491 return 0;
4492 @}
4493 @end smallexample
4494
4495 @noindent
4496 results in warning on line 5.
4497
4498 @item weak
4499 @cindex @code{weak} attribute
4500 The @code{weak} attribute causes the declaration to be emitted as a weak
4501 symbol rather than a global. This is primarily useful in defining
4502 library functions that can be overridden in user code, though it can
4503 also be used with non-function declarations. Weak symbols are supported
4504 for ELF targets, and also for a.out targets when using the GNU assembler
4505 and linker.
4506
4507 @item weakref
4508 @itemx weakref ("@var{target}")
4509 @cindex @code{weakref} attribute
4510 The @code{weakref} attribute marks a declaration as a weak reference.
4511 Without arguments, it should be accompanied by an @code{alias} attribute
4512 naming the target symbol. Optionally, the @var{target} may be given as
4513 an argument to @code{weakref} itself. In either case, @code{weakref}
4514 implicitly marks the declaration as @code{weak}. Without a
4515 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4516 @code{weakref} is equivalent to @code{weak}.
4517
4518 @smallexample
4519 static int x() __attribute__ ((weakref ("y")));
4520 /* is equivalent to... */
4521 static int x() __attribute__ ((weak, weakref, alias ("y")));
4522 /* and to... */
4523 static int x() __attribute__ ((weakref));
4524 static int x() __attribute__ ((alias ("y")));
4525 @end smallexample
4526
4527 A weak reference is an alias that does not by itself require a
4528 definition to be given for the target symbol. If the target symbol is
4529 only referenced through weak references, then it becomes a @code{weak}
4530 undefined symbol. If it is directly referenced, however, then such
4531 strong references prevail, and a definition is required for the
4532 symbol, not necessarily in the same translation unit.
4533
4534 The effect is equivalent to moving all references to the alias to a
4535 separate translation unit, renaming the alias to the aliased symbol,
4536 declaring it as weak, compiling the two separate translation units and
4537 performing a reloadable link on them.
4538
4539 At present, a declaration to which @code{weakref} is attached can
4540 only be @code{static}.
4541
4542 @end table
4543
4544 You can specify multiple attributes in a declaration by separating them
4545 by commas within the double parentheses or by immediately following an
4546 attribute declaration with another attribute declaration.
4547
4548 @cindex @code{#pragma}, reason for not using
4549 @cindex pragma, reason for not using
4550 Some people object to the @code{__attribute__} feature, suggesting that
4551 ISO C's @code{#pragma} should be used instead. At the time
4552 @code{__attribute__} was designed, there were two reasons for not doing
4553 this.
4554
4555 @enumerate
4556 @item
4557 It is impossible to generate @code{#pragma} commands from a macro.
4558
4559 @item
4560 There is no telling what the same @code{#pragma} might mean in another
4561 compiler.
4562 @end enumerate
4563
4564 These two reasons applied to almost any application that might have been
4565 proposed for @code{#pragma}. It was basically a mistake to use
4566 @code{#pragma} for @emph{anything}.
4567
4568 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4569 to be generated from macros. In addition, a @code{#pragma GCC}
4570 namespace is now in use for GCC-specific pragmas. However, it has been
4571 found convenient to use @code{__attribute__} to achieve a natural
4572 attachment of attributes to their corresponding declarations, whereas
4573 @code{#pragma GCC} is of use for constructs that do not naturally form
4574 part of the grammar. @xref{Pragmas,,Pragmas Accepted by GCC}.
4575
4576 @node Label Attributes
4577 @section Label Attributes
4578 @cindex Label Attributes
4579
4580 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
4581 details of the exact syntax for using attributes. Other attributes are
4582 available for functions (@pxref{Function Attributes}), variables
4583 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
4584
4585 This example uses the @code{cold} label attribute to indicate the
4586 @code{ErrorHandling} branch is unlikely to be taken and that the
4587 @code{ErrorHandling} label is unused:
4588
4589 @smallexample
4590
4591 asm goto ("some asm" : : : : NoError);
4592
4593 /* This branch (the fallthru from the asm) is less commonly used */
4594 ErrorHandling:
4595 __attribute__((cold, unused)); /* Semi-colon is required here */
4596 printf("error\n");
4597 return 0;
4598
4599 NoError:
4600 printf("no error\n");
4601 return 1;
4602 @end smallexample
4603
4604 @table @code
4605 @item unused
4606 @cindex @code{unused} label attribute
4607 This feature is intended for program-generated code that may contain
4608 unused labels, but which is compiled with @option{-Wall}. It is
4609 not normally appropriate to use in it human-written code, though it
4610 could be useful in cases where the code that jumps to the label is
4611 contained within an @code{#ifdef} conditional.
4612
4613 @item hot
4614 @cindex @code{hot} label attribute
4615 The @code{hot} attribute on a label is used to inform the compiler that
4616 the path following the label is more likely than paths that are not so
4617 annotated. This attribute is used in cases where @code{__builtin_expect}
4618 cannot be used, for instance with computed goto or @code{asm goto}.
4619
4620 The @code{hot} attribute on labels is not implemented in GCC versions
4621 earlier than 4.8.
4622
4623 @item cold
4624 @cindex @code{cold} label attribute
4625 The @code{cold} attribute on labels is used to inform the compiler that
4626 the path following the label is unlikely to be executed. This attribute
4627 is used in cases where @code{__builtin_expect} cannot be used, for instance
4628 with computed goto or @code{asm goto}.
4629
4630 The @code{cold} attribute on labels is not implemented in GCC versions
4631 earlier than 4.8.
4632
4633 @end table
4634
4635 @node Attribute Syntax
4636 @section Attribute Syntax
4637 @cindex attribute syntax
4638
4639 This section describes the syntax with which @code{__attribute__} may be
4640 used, and the constructs to which attribute specifiers bind, for the C
4641 language. Some details may vary for C++ and Objective-C@. Because of
4642 infelicities in the grammar for attributes, some forms described here
4643 may not be successfully parsed in all cases.
4644
4645 There are some problems with the semantics of attributes in C++. For
4646 example, there are no manglings for attributes, although they may affect
4647 code generation, so problems may arise when attributed types are used in
4648 conjunction with templates or overloading. Similarly, @code{typeid}
4649 does not distinguish between types with different attributes. Support
4650 for attributes in C++ may be restricted in future to attributes on
4651 declarations only, but not on nested declarators.
4652
4653 @xref{Function Attributes}, for details of the semantics of attributes
4654 applying to functions. @xref{Variable Attributes}, for details of the
4655 semantics of attributes applying to variables. @xref{Type Attributes},
4656 for details of the semantics of attributes applying to structure, union
4657 and enumerated types.
4658 @xref{Label Attributes}, for details of the semantics of attributes
4659 applying to labels.
4660
4661 An @dfn{attribute specifier} is of the form
4662 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
4663 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4664 each attribute is one of the following:
4665
4666 @itemize @bullet
4667 @item
4668 Empty. Empty attributes are ignored.
4669
4670 @item
4671 A word (which may be an identifier such as @code{unused}, or a reserved
4672 word such as @code{const}).
4673
4674 @item
4675 A word, followed by, in parentheses, parameters for the attribute.
4676 These parameters take one of the following forms:
4677
4678 @itemize @bullet
4679 @item
4680 An identifier. For example, @code{mode} attributes use this form.
4681
4682 @item
4683 An identifier followed by a comma and a non-empty comma-separated list
4684 of expressions. For example, @code{format} attributes use this form.
4685
4686 @item
4687 A possibly empty comma-separated list of expressions. For example,
4688 @code{format_arg} attributes use this form with the list being a single
4689 integer constant expression, and @code{alias} attributes use this form
4690 with the list being a single string constant.
4691 @end itemize
4692 @end itemize
4693
4694 An @dfn{attribute specifier list} is a sequence of one or more attribute
4695 specifiers, not separated by any other tokens.
4696
4697 @subsubheading Label Attributes
4698
4699 In GNU C, an attribute specifier list may appear after the colon following a
4700 label, other than a @code{case} or @code{default} label. GNU C++ only permits
4701 attributes on labels if the attribute specifier is immediately
4702 followed by a semicolon (i.e., the label applies to an empty
4703 statement). If the semicolon is missing, C++ label attributes are
4704 ambiguous, as it is permissible for a declaration, which could begin
4705 with an attribute list, to be labelled in C++. Declarations cannot be
4706 labelled in C90 or C99, so the ambiguity does not arise there.
4707
4708 @subsubheading Type Attributes
4709
4710 An attribute specifier list may appear as part of a @code{struct},
4711 @code{union} or @code{enum} specifier. It may go either immediately
4712 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4713 the closing brace. The former syntax is preferred.
4714 Where attribute specifiers follow the closing brace, they are considered
4715 to relate to the structure, union or enumerated type defined, not to any
4716 enclosing declaration the type specifier appears in, and the type
4717 defined is not complete until after the attribute specifiers.
4718 @c Otherwise, there would be the following problems: a shift/reduce
4719 @c conflict between attributes binding the struct/union/enum and
4720 @c binding to the list of specifiers/qualifiers; and "aligned"
4721 @c attributes could use sizeof for the structure, but the size could be
4722 @c changed later by "packed" attributes.
4723
4724
4725 @subsubheading All other attributes
4726
4727 Otherwise, an attribute specifier appears as part of a declaration,
4728 counting declarations of unnamed parameters and type names, and relates
4729 to that declaration (which may be nested in another declaration, for
4730 example in the case of a parameter declaration), or to a particular declarator
4731 within a declaration. Where an
4732 attribute specifier is applied to a parameter declared as a function or
4733 an array, it should apply to the function or array rather than the
4734 pointer to which the parameter is implicitly converted, but this is not
4735 yet correctly implemented.
4736
4737 Any list of specifiers and qualifiers at the start of a declaration may
4738 contain attribute specifiers, whether or not such a list may in that
4739 context contain storage class specifiers. (Some attributes, however,
4740 are essentially in the nature of storage class specifiers, and only make
4741 sense where storage class specifiers may be used; for example,
4742 @code{section}.) There is one necessary limitation to this syntax: the
4743 first old-style parameter declaration in a function definition cannot
4744 begin with an attribute specifier, because such an attribute applies to
4745 the function instead by syntax described below (which, however, is not
4746 yet implemented in this case). In some other cases, attribute
4747 specifiers are permitted by this grammar but not yet supported by the
4748 compiler. All attribute specifiers in this place relate to the
4749 declaration as a whole. In the obsolescent usage where a type of
4750 @code{int} is implied by the absence of type specifiers, such a list of
4751 specifiers and qualifiers may be an attribute specifier list with no
4752 other specifiers or qualifiers.
4753
4754 At present, the first parameter in a function prototype must have some
4755 type specifier that is not an attribute specifier; this resolves an
4756 ambiguity in the interpretation of @code{void f(int
4757 (__attribute__((foo)) x))}, but is subject to change. At present, if
4758 the parentheses of a function declarator contain only attributes then
4759 those attributes are ignored, rather than yielding an error or warning
4760 or implying a single parameter of type int, but this is subject to
4761 change.
4762
4763 An attribute specifier list may appear immediately before a declarator
4764 (other than the first) in a comma-separated list of declarators in a
4765 declaration of more than one identifier using a single list of
4766 specifiers and qualifiers. Such attribute specifiers apply
4767 only to the identifier before whose declarator they appear. For
4768 example, in
4769
4770 @smallexample
4771 __attribute__((noreturn)) void d0 (void),
4772 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4773 d2 (void)
4774 @end smallexample
4775
4776 @noindent
4777 the @code{noreturn} attribute applies to all the functions
4778 declared; the @code{format} attribute only applies to @code{d1}.
4779
4780 An attribute specifier list may appear immediately before the comma,
4781 @code{=} or semicolon terminating the declaration of an identifier other
4782 than a function definition. Such attribute specifiers apply
4783 to the declared object or function. Where an
4784 assembler name for an object or function is specified (@pxref{Asm
4785 Labels}), the attribute must follow the @code{asm}
4786 specification.
4787
4788 An attribute specifier list may, in future, be permitted to appear after
4789 the declarator in a function definition (before any old-style parameter
4790 declarations or the function body).
4791
4792 Attribute specifiers may be mixed with type qualifiers appearing inside
4793 the @code{[]} of a parameter array declarator, in the C99 construct by
4794 which such qualifiers are applied to the pointer to which the array is
4795 implicitly converted. Such attribute specifiers apply to the pointer,
4796 not to the array, but at present this is not implemented and they are
4797 ignored.
4798
4799 An attribute specifier list may appear at the start of a nested
4800 declarator. At present, there are some limitations in this usage: the
4801 attributes correctly apply to the declarator, but for most individual
4802 attributes the semantics this implies are not implemented.
4803 When attribute specifiers follow the @code{*} of a pointer
4804 declarator, they may be mixed with any type qualifiers present.
4805 The following describes the formal semantics of this syntax. It makes the
4806 most sense if you are familiar with the formal specification of
4807 declarators in the ISO C standard.
4808
4809 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4810 D1}, where @code{T} contains declaration specifiers that specify a type
4811 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4812 contains an identifier @var{ident}. The type specified for @var{ident}
4813 for derived declarators whose type does not include an attribute
4814 specifier is as in the ISO C standard.
4815
4816 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4817 and the declaration @code{T D} specifies the type
4818 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4819 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4820 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4821
4822 If @code{D1} has the form @code{*
4823 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4824 declaration @code{T D} specifies the type
4825 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4826 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4827 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4828 @var{ident}.
4829
4830 For example,
4831
4832 @smallexample
4833 void (__attribute__((noreturn)) ****f) (void);
4834 @end smallexample
4835
4836 @noindent
4837 specifies the type ``pointer to pointer to pointer to pointer to
4838 non-returning function returning @code{void}''. As another example,
4839
4840 @smallexample
4841 char *__attribute__((aligned(8))) *f;
4842 @end smallexample
4843
4844 @noindent
4845 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4846 Note again that this does not work with most attributes; for example,
4847 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4848 is not yet supported.
4849
4850 For compatibility with existing code written for compiler versions that
4851 did not implement attributes on nested declarators, some laxity is
4852 allowed in the placing of attributes. If an attribute that only applies
4853 to types is applied to a declaration, it is treated as applying to
4854 the type of that declaration. If an attribute that only applies to
4855 declarations is applied to the type of a declaration, it is treated
4856 as applying to that declaration; and, for compatibility with code
4857 placing the attributes immediately before the identifier declared, such
4858 an attribute applied to a function return type is treated as
4859 applying to the function type, and such an attribute applied to an array
4860 element type is treated as applying to the array type. If an
4861 attribute that only applies to function types is applied to a
4862 pointer-to-function type, it is treated as applying to the pointer
4863 target type; if such an attribute is applied to a function return type
4864 that is not a pointer-to-function type, it is treated as applying
4865 to the function type.
4866
4867 @node Function Prototypes
4868 @section Prototypes and Old-Style Function Definitions
4869 @cindex function prototype declarations
4870 @cindex old-style function definitions
4871 @cindex promotion of formal parameters
4872
4873 GNU C extends ISO C to allow a function prototype to override a later
4874 old-style non-prototype definition. Consider the following example:
4875
4876 @smallexample
4877 /* @r{Use prototypes unless the compiler is old-fashioned.} */
4878 #ifdef __STDC__
4879 #define P(x) x
4880 #else
4881 #define P(x) ()
4882 #endif
4883
4884 /* @r{Prototype function declaration.} */
4885 int isroot P((uid_t));
4886
4887 /* @r{Old-style function definition.} */
4888 int
4889 isroot (x) /* @r{??? lossage here ???} */
4890 uid_t x;
4891 @{
4892 return x == 0;
4893 @}
4894 @end smallexample
4895
4896 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
4897 not allow this example, because subword arguments in old-style
4898 non-prototype definitions are promoted. Therefore in this example the
4899 function definition's argument is really an @code{int}, which does not
4900 match the prototype argument type of @code{short}.
4901
4902 This restriction of ISO C makes it hard to write code that is portable
4903 to traditional C compilers, because the programmer does not know
4904 whether the @code{uid_t} type is @code{short}, @code{int}, or
4905 @code{long}. Therefore, in cases like these GNU C allows a prototype
4906 to override a later old-style definition. More precisely, in GNU C, a
4907 function prototype argument type overrides the argument type specified
4908 by a later old-style definition if the former type is the same as the
4909 latter type before promotion. Thus in GNU C the above example is
4910 equivalent to the following:
4911
4912 @smallexample
4913 int isroot (uid_t);
4914
4915 int
4916 isroot (uid_t x)
4917 @{
4918 return x == 0;
4919 @}
4920 @end smallexample
4921
4922 @noindent
4923 GNU C++ does not support old-style function definitions, so this
4924 extension is irrelevant.
4925
4926 @node C++ Comments
4927 @section C++ Style Comments
4928 @cindex @code{//}
4929 @cindex C++ comments
4930 @cindex comments, C++ style
4931
4932 In GNU C, you may use C++ style comments, which start with @samp{//} and
4933 continue until the end of the line. Many other C implementations allow
4934 such comments, and they are included in the 1999 C standard. However,
4935 C++ style comments are not recognized if you specify an @option{-std}
4936 option specifying a version of ISO C before C99, or @option{-ansi}
4937 (equivalent to @option{-std=c90}).
4938
4939 @node Dollar Signs
4940 @section Dollar Signs in Identifier Names
4941 @cindex $
4942 @cindex dollar signs in identifier names
4943 @cindex identifier names, dollar signs in
4944
4945 In GNU C, you may normally use dollar signs in identifier names.
4946 This is because many traditional C implementations allow such identifiers.
4947 However, dollar signs in identifiers are not supported on a few target
4948 machines, typically because the target assembler does not allow them.
4949
4950 @node Character Escapes
4951 @section The Character @key{ESC} in Constants
4952
4953 You can use the sequence @samp{\e} in a string or character constant to
4954 stand for the ASCII character @key{ESC}.
4955
4956 @node Variable Attributes
4957 @section Specifying Attributes of Variables
4958 @cindex attribute of variables
4959 @cindex variable attributes
4960
4961 The keyword @code{__attribute__} allows you to specify special
4962 attributes of variables or structure fields. This keyword is followed
4963 by an attribute specification inside double parentheses. Some
4964 attributes are currently defined generically for variables.
4965 Other attributes are defined for variables on particular target
4966 systems. Other attributes are available for functions
4967 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for
4968 types (@pxref{Type Attributes}).
4969 Other front ends might define more attributes
4970 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4971
4972 You may also specify attributes with @samp{__} preceding and following
4973 each keyword. This allows you to use them in header files without
4974 being concerned about a possible macro of the same name. For example,
4975 you may use @code{__aligned__} instead of @code{aligned}.
4976
4977 @xref{Attribute Syntax}, for details of the exact syntax for using
4978 attributes.
4979
4980 @table @code
4981 @cindex @code{aligned} attribute
4982 @item aligned (@var{alignment})
4983 This attribute specifies a minimum alignment for the variable or
4984 structure field, measured in bytes. For example, the declaration:
4985
4986 @smallexample
4987 int x __attribute__ ((aligned (16))) = 0;
4988 @end smallexample
4989
4990 @noindent
4991 causes the compiler to allocate the global variable @code{x} on a
4992 16-byte boundary. On a 68040, this could be used in conjunction with
4993 an @code{asm} expression to access the @code{move16} instruction which
4994 requires 16-byte aligned operands.
4995
4996 You can also specify the alignment of structure fields. For example, to
4997 create a double-word aligned @code{int} pair, you could write:
4998
4999 @smallexample
5000 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5001 @end smallexample
5002
5003 @noindent
5004 This is an alternative to creating a union with a @code{double} member,
5005 which forces the union to be double-word aligned.
5006
5007 As in the preceding examples, you can explicitly specify the alignment
5008 (in bytes) that you wish the compiler to use for a given variable or
5009 structure field. Alternatively, you can leave out the alignment factor
5010 and just ask the compiler to align a variable or field to the
5011 default alignment for the target architecture you are compiling for.
5012 The default alignment is sufficient for all scalar types, but may not be
5013 enough for all vector types on a target that supports vector operations.
5014 The default alignment is fixed for a particular target ABI.
5015
5016 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5017 which is the largest alignment ever used for any data type on the
5018 target machine you are compiling for. For example, you could write:
5019
5020 @smallexample
5021 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5022 @end smallexample
5023
5024 The compiler automatically sets the alignment for the declared
5025 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5026 often make copy operations more efficient, because the compiler can
5027 use whatever instructions copy the biggest chunks of memory when
5028 performing copies to or from the variables or fields that you have
5029 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5030 may change depending on command-line options.
5031
5032 When used on a struct, or struct member, the @code{aligned} attribute can
5033 only increase the alignment; in order to decrease it, the @code{packed}
5034 attribute must be specified as well. When used as part of a typedef, the
5035 @code{aligned} attribute can both increase and decrease alignment, and
5036 specifying the @code{packed} attribute generates a warning.
5037
5038 Note that the effectiveness of @code{aligned} attributes may be limited
5039 by inherent limitations in your linker. On many systems, the linker is
5040 only able to arrange for variables to be aligned up to a certain maximum
5041 alignment. (For some linkers, the maximum supported alignment may
5042 be very very small.) If your linker is only able to align variables
5043 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5044 in an @code{__attribute__} still only provides you with 8-byte
5045 alignment. See your linker documentation for further information.
5046
5047 The @code{aligned} attribute can also be used for functions
5048 (@pxref{Function Attributes}.)
5049
5050 @item cleanup (@var{cleanup_function})
5051 @cindex @code{cleanup} attribute
5052 The @code{cleanup} attribute runs a function when the variable goes
5053 out of scope. This attribute can only be applied to auto function
5054 scope variables; it may not be applied to parameters or variables
5055 with static storage duration. The function must take one parameter,
5056 a pointer to a type compatible with the variable. The return value
5057 of the function (if any) is ignored.
5058
5059 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5060 is run during the stack unwinding that happens during the
5061 processing of the exception. Note that the @code{cleanup} attribute
5062 does not allow the exception to be caught, only to perform an action.
5063 It is undefined what happens if @var{cleanup_function} does not
5064 return normally.
5065
5066 @item common
5067 @itemx nocommon
5068 @cindex @code{common} attribute
5069 @cindex @code{nocommon} attribute
5070 @opindex fcommon
5071 @opindex fno-common
5072 The @code{common} attribute requests GCC to place a variable in
5073 ``common'' storage. The @code{nocommon} attribute requests the
5074 opposite---to allocate space for it directly.
5075
5076 These attributes override the default chosen by the
5077 @option{-fno-common} and @option{-fcommon} flags respectively.
5078
5079 @item deprecated
5080 @itemx deprecated (@var{msg})
5081 @cindex @code{deprecated} attribute
5082 The @code{deprecated} attribute results in a warning if the variable
5083 is used anywhere in the source file. This is useful when identifying
5084 variables that are expected to be removed in a future version of a
5085 program. The warning also includes the location of the declaration
5086 of the deprecated variable, to enable users to easily find further
5087 information about why the variable is deprecated, or what they should
5088 do instead. Note that the warning only occurs for uses:
5089
5090 @smallexample
5091 extern int old_var __attribute__ ((deprecated));
5092 extern int old_var;
5093 int new_fn () @{ return old_var; @}
5094 @end smallexample
5095
5096 @noindent
5097 results in a warning on line 3 but not line 2. The optional @var{msg}
5098 argument, which must be a string, is printed in the warning if
5099 present.
5100
5101 The @code{deprecated} attribute can also be used for functions and
5102 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
5103
5104 @item mode (@var{mode})
5105 @cindex @code{mode} attribute
5106 This attribute specifies the data type for the declaration---whichever
5107 type corresponds to the mode @var{mode}. This in effect lets you
5108 request an integer or floating-point type according to its width.
5109
5110 You may also specify a mode of @code{byte} or @code{__byte__} to
5111 indicate the mode corresponding to a one-byte integer, @code{word} or
5112 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5113 or @code{__pointer__} for the mode used to represent pointers.
5114
5115 @item packed
5116 @cindex @code{packed} attribute
5117 The @code{packed} attribute specifies that a variable or structure field
5118 should have the smallest possible alignment---one byte for a variable,
5119 and one bit for a field, unless you specify a larger value with the
5120 @code{aligned} attribute.
5121
5122 Here is a structure in which the field @code{x} is packed, so that it
5123 immediately follows @code{a}:
5124
5125 @smallexample
5126 struct foo
5127 @{
5128 char a;
5129 int x[2] __attribute__ ((packed));
5130 @};
5131 @end smallexample
5132
5133 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5134 @code{packed} attribute on bit-fields of type @code{char}. This has
5135 been fixed in GCC 4.4 but the change can lead to differences in the
5136 structure layout. See the documentation of
5137 @option{-Wpacked-bitfield-compat} for more information.
5138
5139 @item section ("@var{section-name}")
5140 @cindex @code{section} variable attribute
5141 Normally, the compiler places the objects it generates in sections like
5142 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5143 or you need certain particular variables to appear in special sections,
5144 for example to map to special hardware. The @code{section}
5145 attribute specifies that a variable (or function) lives in a particular
5146 section. For example, this small program uses several specific section names:
5147
5148 @smallexample
5149 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5150 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5151 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5152 int init_data __attribute__ ((section ("INITDATA")));
5153
5154 main()
5155 @{
5156 /* @r{Initialize stack pointer} */
5157 init_sp (stack + sizeof (stack));
5158
5159 /* @r{Initialize initialized data} */
5160 memcpy (&init_data, &data, &edata - &data);
5161
5162 /* @r{Turn on the serial ports} */
5163 init_duart (&a);
5164 init_duart (&b);
5165 @}
5166 @end smallexample
5167
5168 @noindent
5169 Use the @code{section} attribute with
5170 @emph{global} variables and not @emph{local} variables,
5171 as shown in the example.
5172
5173 You may use the @code{section} attribute with initialized or
5174 uninitialized global variables but the linker requires
5175 each object be defined once, with the exception that uninitialized
5176 variables tentatively go in the @code{common} (or @code{bss}) section
5177 and can be multiply ``defined''. Using the @code{section} attribute
5178 changes what section the variable goes into and may cause the
5179 linker to issue an error if an uninitialized variable has multiple
5180 definitions. You can force a variable to be initialized with the
5181 @option{-fno-common} flag or the @code{nocommon} attribute.
5182
5183 Some file formats do not support arbitrary sections so the @code{section}
5184 attribute is not available on all platforms.
5185 If you need to map the entire contents of a module to a particular
5186 section, consider using the facilities of the linker instead.
5187
5188 @item shared
5189 @cindex @code{shared} variable attribute
5190 On Microsoft Windows, in addition to putting variable definitions in a named
5191 section, the section can also be shared among all running copies of an
5192 executable or DLL@. For example, this small program defines shared data
5193 by putting it in a named section @code{shared} and marking the section
5194 shareable:
5195
5196 @smallexample
5197 int foo __attribute__((section ("shared"), shared)) = 0;
5198
5199 int
5200 main()
5201 @{
5202 /* @r{Read and write foo. All running
5203 copies see the same value.} */
5204 return 0;
5205 @}
5206 @end smallexample
5207
5208 @noindent
5209 You may only use the @code{shared} attribute along with @code{section}
5210 attribute with a fully-initialized global definition because of the way
5211 linkers work. See @code{section} attribute for more information.
5212
5213 The @code{shared} attribute is only available on Microsoft Windows@.
5214
5215 @item tls_model ("@var{tls_model}")
5216 @cindex @code{tls_model} attribute
5217 The @code{tls_model} attribute sets thread-local storage model
5218 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5219 overriding @option{-ftls-model=} command-line switch on a per-variable
5220 basis.
5221 The @var{tls_model} argument should be one of @code{global-dynamic},
5222 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5223
5224 Not all targets support this attribute.
5225
5226 @item unused
5227 This attribute, attached to a variable, means that the variable is meant
5228 to be possibly unused. GCC does not produce a warning for this
5229 variable.
5230
5231 @item used
5232 This attribute, attached to a variable with the static storage, means that
5233 the variable must be emitted even if it appears that the variable is not
5234 referenced.
5235
5236 When applied to a static data member of a C++ class template, the
5237 attribute also means that the member is instantiated if the
5238 class itself is instantiated.
5239
5240 @item vector_size (@var{bytes})
5241 This attribute specifies the vector size for the variable, measured in
5242 bytes. For example, the declaration:
5243
5244 @smallexample
5245 int foo __attribute__ ((vector_size (16)));
5246 @end smallexample
5247
5248 @noindent
5249 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5250 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5251 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5252
5253 This attribute is only applicable to integral and float scalars,
5254 although arrays, pointers, and function return values are allowed in
5255 conjunction with this construct.
5256
5257 Aggregates with this attribute are invalid, even if they are of the same
5258 size as a corresponding scalar. For example, the declaration:
5259
5260 @smallexample
5261 struct S @{ int a; @};
5262 struct S __attribute__ ((vector_size (16))) foo;
5263 @end smallexample
5264
5265 @noindent
5266 is invalid even if the size of the structure is the same as the size of
5267 the @code{int}.
5268
5269 @item selectany
5270 The @code{selectany} attribute causes an initialized global variable to
5271 have link-once semantics. When multiple definitions of the variable are
5272 encountered by the linker, the first is selected and the remainder are
5273 discarded. Following usage by the Microsoft compiler, the linker is told
5274 @emph{not} to warn about size or content differences of the multiple
5275 definitions.
5276
5277 Although the primary usage of this attribute is for POD types, the
5278 attribute can also be applied to global C++ objects that are initialized
5279 by a constructor. In this case, the static initialization and destruction
5280 code for the object is emitted in each translation defining the object,
5281 but the calls to the constructor and destructor are protected by a
5282 link-once guard variable.
5283
5284 The @code{selectany} attribute is only available on Microsoft Windows
5285 targets. You can use @code{__declspec (selectany)} as a synonym for
5286 @code{__attribute__ ((selectany))} for compatibility with other
5287 compilers.
5288
5289 @item weak
5290 The @code{weak} attribute is described in @ref{Function Attributes}.
5291
5292 @item dllimport
5293 The @code{dllimport} attribute is described in @ref{Function Attributes}.
5294
5295 @item dllexport
5296 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5297
5298 @end table
5299
5300 @anchor{AVR Variable Attributes}
5301 @subsection AVR Variable Attributes
5302
5303 @table @code
5304 @item progmem
5305 @cindex @code{progmem} AVR variable attribute
5306 The @code{progmem} attribute is used on the AVR to place read-only
5307 data in the non-volatile program memory (flash). The @code{progmem}
5308 attribute accomplishes this by putting respective variables into a
5309 section whose name starts with @code{.progmem}.
5310
5311 This attribute works similar to the @code{section} attribute
5312 but adds additional checking. Notice that just like the
5313 @code{section} attribute, @code{progmem} affects the location
5314 of the data but not how this data is accessed.
5315
5316 In order to read data located with the @code{progmem} attribute
5317 (inline) assembler must be used.
5318 @smallexample
5319 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5320 #include <avr/pgmspace.h>
5321
5322 /* Locate var in flash memory */
5323 const int var[2] PROGMEM = @{ 1, 2 @};
5324
5325 int read_var (int i)
5326 @{
5327 /* Access var[] by accessor macro from avr/pgmspace.h */
5328 return (int) pgm_read_word (& var[i]);
5329 @}
5330 @end smallexample
5331
5332 AVR is a Harvard architecture processor and data and read-only data
5333 normally resides in the data memory (RAM).
5334
5335 See also the @ref{AVR Named Address Spaces} section for
5336 an alternate way to locate and access data in flash memory.
5337
5338 @item io
5339 @itemx io (@var{addr})
5340 Variables with the @code{io} attribute are used to address
5341 memory-mapped peripherals in the io address range.
5342 If an address is specified, the variable
5343 is assigned that address, and the value is interpreted as an
5344 address in the data address space.
5345 Example:
5346
5347 @smallexample
5348 volatile int porta __attribute__((io (0x22)));
5349 @end smallexample
5350
5351 The address specified in the address in the data address range.
5352
5353 Otherwise, the variable it is not assigned an address, but the
5354 compiler will still use in/out instructions where applicable,
5355 assuming some other module assigns an address in the io address range.
5356 Example:
5357
5358 @smallexample
5359 extern volatile int porta __attribute__((io));
5360 @end smallexample
5361
5362 @item io_low
5363 @itemx io_low (@var{addr})
5364 This is like the @code{io} attribute, but additionally it informs the
5365 compiler that the object lies in the lower half of the I/O area,
5366 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5367 instructions.
5368
5369 @item address
5370 @itemx address (@var{addr})
5371 Variables with the @code{address} attribute are used to address
5372 memory-mapped peripherals that may lie outside the io address range.
5373
5374 @smallexample
5375 volatile int porta __attribute__((address (0x600)));
5376 @end smallexample
5377
5378 @end table
5379
5380 @subsection Blackfin Variable Attributes
5381
5382 Three attributes are currently defined for the Blackfin.
5383
5384 @table @code
5385 @item l1_data
5386 @itemx l1_data_A
5387 @itemx l1_data_B
5388 @cindex @code{l1_data} variable attribute
5389 @cindex @code{l1_data_A} variable attribute
5390 @cindex @code{l1_data_B} variable attribute
5391 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5392 Variables with @code{l1_data} attribute are put into the specific section
5393 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5394 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5395 attribute are put into the specific section named @code{.l1.data.B}.
5396
5397 @item l2
5398 @cindex @code{l2} variable attribute
5399 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5400 Variables with @code{l2} attribute are put into the specific section
5401 named @code{.l2.data}.
5402 @end table
5403
5404 @subsection M32R/D Variable Attributes
5405
5406 One attribute is currently defined for the M32R/D@.
5407
5408 @table @code
5409 @item model (@var{model-name})
5410 @cindex variable addressability on the M32R/D
5411 Use this attribute on the M32R/D to set the addressability of an object.
5412 The identifier @var{model-name} is one of @code{small}, @code{medium},
5413 or @code{large}, representing each of the code models.
5414
5415 Small model objects live in the lower 16MB of memory (so that their
5416 addresses can be loaded with the @code{ld24} instruction).
5417
5418 Medium and large model objects may live anywhere in the 32-bit address space
5419 (the compiler generates @code{seth/add3} instructions to load their
5420 addresses).
5421 @end table
5422
5423 @anchor{MeP Variable Attributes}
5424 @subsection MeP Variable Attributes
5425
5426 The MeP target has a number of addressing modes and busses. The
5427 @code{near} space spans the standard memory space's first 16 megabytes
5428 (24 bits). The @code{far} space spans the entire 32-bit memory space.
5429 The @code{based} space is a 128-byte region in the memory space that
5430 is addressed relative to the @code{$tp} register. The @code{tiny}
5431 space is a 65536-byte region relative to the @code{$gp} register. In
5432 addition to these memory regions, the MeP target has a separate 16-bit
5433 control bus which is specified with @code{cb} attributes.
5434
5435 @table @code
5436
5437 @item based
5438 Any variable with the @code{based} attribute is assigned to the
5439 @code{.based} section, and is accessed with relative to the
5440 @code{$tp} register.
5441
5442 @item tiny
5443 Likewise, the @code{tiny} attribute assigned variables to the
5444 @code{.tiny} section, relative to the @code{$gp} register.
5445
5446 @item near
5447 Variables with the @code{near} attribute are assumed to have addresses
5448 that fit in a 24-bit addressing mode. This is the default for large
5449 variables (@code{-mtiny=4} is the default) but this attribute can
5450 override @code{-mtiny=} for small variables, or override @code{-ml}.
5451
5452 @item far
5453 Variables with the @code{far} attribute are addressed using a full
5454 32-bit address. Since this covers the entire memory space, this
5455 allows modules to make no assumptions about where variables might be
5456 stored.
5457
5458 @item io
5459 @itemx io (@var{addr})
5460 Variables with the @code{io} attribute are used to address
5461 memory-mapped peripherals. If an address is specified, the variable
5462 is assigned that address, else it is not assigned an address (it is
5463 assumed some other module assigns an address). Example:
5464
5465 @smallexample
5466 int timer_count __attribute__((io(0x123)));
5467 @end smallexample
5468
5469 @item cb
5470 @itemx cb (@var{addr})
5471 Variables with the @code{cb} attribute are used to access the control
5472 bus, using special instructions. @code{addr} indicates the control bus
5473 address. Example:
5474
5475 @smallexample
5476 int cpu_clock __attribute__((cb(0x123)));
5477 @end smallexample
5478
5479 @end table
5480
5481 @anchor{i386 Variable Attributes}
5482 @subsection i386 Variable Attributes
5483
5484 Two attributes are currently defined for i386 configurations:
5485 @code{ms_struct} and @code{gcc_struct}
5486
5487 @table @code
5488 @item ms_struct
5489 @itemx gcc_struct
5490 @cindex @code{ms_struct} attribute
5491 @cindex @code{gcc_struct} attribute
5492
5493 If @code{packed} is used on a structure, or if bit-fields are used,
5494 it may be that the Microsoft ABI lays out the structure differently
5495 than the way GCC normally does. Particularly when moving packed
5496 data between functions compiled with GCC and the native Microsoft compiler
5497 (either via function call or as data in a file), it may be necessary to access
5498 either format.
5499
5500 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5501 compilers to match the native Microsoft compiler.
5502
5503 The Microsoft structure layout algorithm is fairly simple with the exception
5504 of the bit-field packing.
5505 The padding and alignment of members of structures and whether a bit-field
5506 can straddle a storage-unit boundary are determine by these rules:
5507
5508 @enumerate
5509 @item Structure members are stored sequentially in the order in which they are
5510 declared: the first member has the lowest memory address and the last member
5511 the highest.
5512
5513 @item Every data object has an alignment requirement. The alignment requirement
5514 for all data except structures, unions, and arrays is either the size of the
5515 object or the current packing size (specified with either the
5516 @code{aligned} attribute or the @code{pack} pragma),
5517 whichever is less. For structures, unions, and arrays,
5518 the alignment requirement is the largest alignment requirement of its members.
5519 Every object is allocated an offset so that:
5520
5521 @smallexample
5522 offset % alignment_requirement == 0
5523 @end smallexample
5524
5525 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5526 unit if the integral types are the same size and if the next bit-field fits
5527 into the current allocation unit without crossing the boundary imposed by the
5528 common alignment requirements of the bit-fields.
5529 @end enumerate
5530
5531 MSVC interprets zero-length bit-fields in the following ways:
5532
5533 @enumerate
5534 @item If a zero-length bit-field is inserted between two bit-fields that
5535 are normally coalesced, the bit-fields are not coalesced.
5536
5537 For example:
5538
5539 @smallexample
5540 struct
5541 @{
5542 unsigned long bf_1 : 12;
5543 unsigned long : 0;
5544 unsigned long bf_2 : 12;
5545 @} t1;
5546 @end smallexample
5547
5548 @noindent
5549 The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
5550 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5551
5552 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5553 alignment of the zero-length bit-field is greater than the member that follows it,
5554 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5555
5556 For example:
5557
5558 @smallexample
5559 struct
5560 @{
5561 char foo : 4;
5562 short : 0;
5563 char bar;
5564 @} t2;
5565
5566 struct
5567 @{
5568 char foo : 4;
5569 short : 0;
5570 double bar;
5571 @} t3;
5572 @end smallexample
5573
5574 @noindent
5575 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5576 Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
5577 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5578 of the structure.
5579
5580 Taking this into account, it is important to note the following:
5581
5582 @enumerate
5583 @item If a zero-length bit-field follows a normal bit-field, the type of the
5584 zero-length bit-field may affect the alignment of the structure as whole. For
5585 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5586 normal bit-field, and is of type short.
5587
5588 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5589 still affect the alignment of the structure:
5590
5591 @smallexample
5592 struct
5593 @{
5594 char foo : 6;
5595 long : 0;
5596 @} t4;
5597 @end smallexample
5598
5599 @noindent
5600 Here, @code{t4} takes up 4 bytes.
5601 @end enumerate
5602
5603 @item Zero-length bit-fields following non-bit-field members are ignored:
5604
5605 @smallexample
5606 struct
5607 @{
5608 char foo;
5609 long : 0;
5610 char bar;
5611 @} t5;
5612 @end smallexample
5613
5614 @noindent
5615 Here, @code{t5} takes up 2 bytes.
5616 @end enumerate
5617 @end table
5618
5619 @subsection PowerPC Variable Attributes
5620
5621 Three attributes currently are defined for PowerPC configurations:
5622 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5623
5624 For full documentation of the struct attributes please see the
5625 documentation in @ref{i386 Variable Attributes}.
5626
5627 For documentation of @code{altivec} attribute please see the
5628 documentation in @ref{PowerPC Type Attributes}.
5629
5630 @subsection SPU Variable Attributes
5631
5632 The SPU supports the @code{spu_vector} attribute for variables. For
5633 documentation of this attribute please see the documentation in
5634 @ref{SPU Type Attributes}.
5635
5636 @subsection Xstormy16 Variable Attributes
5637
5638 One attribute is currently defined for xstormy16 configurations:
5639 @code{below100}.
5640
5641 @table @code
5642 @item below100
5643 @cindex @code{below100} attribute
5644
5645 If a variable has the @code{below100} attribute (@code{BELOW100} is
5646 allowed also), GCC places the variable in the first 0x100 bytes of
5647 memory and use special opcodes to access it. Such variables are
5648 placed in either the @code{.bss_below100} section or the
5649 @code{.data_below100} section.
5650
5651 @end table
5652
5653 @node Type Attributes
5654 @section Specifying Attributes of Types
5655 @cindex attribute of types
5656 @cindex type attributes
5657
5658 The keyword @code{__attribute__} allows you to specify special
5659 attributes of @code{struct} and @code{union} types when you define
5660 such types. This keyword is followed by an attribute specification
5661 inside double parentheses. Eight attributes are currently defined for
5662 types: @code{aligned}, @code{packed}, @code{transparent_union},
5663 @code{unused}, @code{deprecated}, @code{visibility}, @code{may_alias}
5664 and @code{bnd_variable_size}. Other attributes are defined for
5665 functions (@pxref{Function Attributes}), labels (@pxref{Label
5666 Attributes}) and for variables (@pxref{Variable Attributes}).
5667
5668 You may also specify any one of these attributes with @samp{__}
5669 preceding and following its keyword. This allows you to use these
5670 attributes in header files without being concerned about a possible
5671 macro of the same name. For example, you may use @code{__aligned__}
5672 instead of @code{aligned}.
5673
5674 You may specify type attributes in an enum, struct or union type
5675 declaration or definition, or for other types in a @code{typedef}
5676 declaration.
5677
5678 For an enum, struct or union type, you may specify attributes either
5679 between the enum, struct or union tag and the name of the type, or
5680 just past the closing curly brace of the @emph{definition}. The
5681 former syntax is preferred.
5682
5683 @xref{Attribute Syntax}, for details of the exact syntax for using
5684 attributes.
5685
5686 @table @code
5687 @cindex @code{aligned} attribute
5688 @item aligned (@var{alignment})
5689 This attribute specifies a minimum alignment (in bytes) for variables
5690 of the specified type. For example, the declarations:
5691
5692 @smallexample
5693 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5694 typedef int more_aligned_int __attribute__ ((aligned (8)));
5695 @end smallexample
5696
5697 @noindent
5698 force the compiler to ensure (as far as it can) that each variable whose
5699 type is @code{struct S} or @code{more_aligned_int} is allocated and
5700 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
5701 variables of type @code{struct S} aligned to 8-byte boundaries allows
5702 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5703 store) instructions when copying one variable of type @code{struct S} to
5704 another, thus improving run-time efficiency.
5705
5706 Note that the alignment of any given @code{struct} or @code{union} type
5707 is required by the ISO C standard to be at least a perfect multiple of
5708 the lowest common multiple of the alignments of all of the members of
5709 the @code{struct} or @code{union} in question. This means that you @emph{can}
5710 effectively adjust the alignment of a @code{struct} or @code{union}
5711 type by attaching an @code{aligned} attribute to any one of the members
5712 of such a type, but the notation illustrated in the example above is a
5713 more obvious, intuitive, and readable way to request the compiler to
5714 adjust the alignment of an entire @code{struct} or @code{union} type.
5715
5716 As in the preceding example, you can explicitly specify the alignment
5717 (in bytes) that you wish the compiler to use for a given @code{struct}
5718 or @code{union} type. Alternatively, you can leave out the alignment factor
5719 and just ask the compiler to align a type to the maximum
5720 useful alignment for the target machine you are compiling for. For
5721 example, you could write:
5722
5723 @smallexample
5724 struct S @{ short f[3]; @} __attribute__ ((aligned));
5725 @end smallexample
5726
5727 Whenever you leave out the alignment factor in an @code{aligned}
5728 attribute specification, the compiler automatically sets the alignment
5729 for the type to the largest alignment that is ever used for any data
5730 type on the target machine you are compiling for. Doing this can often
5731 make copy operations more efficient, because the compiler can use
5732 whatever instructions copy the biggest chunks of memory when performing
5733 copies to or from the variables that have types that you have aligned
5734 this way.
5735
5736 In the example above, if the size of each @code{short} is 2 bytes, then
5737 the size of the entire @code{struct S} type is 6 bytes. The smallest
5738 power of two that is greater than or equal to that is 8, so the
5739 compiler sets the alignment for the entire @code{struct S} type to 8
5740 bytes.
5741
5742 Note that although you can ask the compiler to select a time-efficient
5743 alignment for a given type and then declare only individual stand-alone
5744 objects of that type, the compiler's ability to select a time-efficient
5745 alignment is primarily useful only when you plan to create arrays of
5746 variables having the relevant (efficiently aligned) type. If you
5747 declare or use arrays of variables of an efficiently-aligned type, then
5748 it is likely that your program also does pointer arithmetic (or
5749 subscripting, which amounts to the same thing) on pointers to the
5750 relevant type, and the code that the compiler generates for these
5751 pointer arithmetic operations is often more efficient for
5752 efficiently-aligned types than for other types.
5753
5754 The @code{aligned} attribute can only increase the alignment; but you
5755 can decrease it by specifying @code{packed} as well. See below.
5756
5757 Note that the effectiveness of @code{aligned} attributes may be limited
5758 by inherent limitations in your linker. On many systems, the linker is
5759 only able to arrange for variables to be aligned up to a certain maximum
5760 alignment. (For some linkers, the maximum supported alignment may
5761 be very very small.) If your linker is only able to align variables
5762 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5763 in an @code{__attribute__} still only provides you with 8-byte
5764 alignment. See your linker documentation for further information.
5765
5766 @item packed
5767 This attribute, attached to @code{struct} or @code{union} type
5768 definition, specifies that each member (other than zero-width bit-fields)
5769 of the structure or union is placed to minimize the memory required. When
5770 attached to an @code{enum} definition, it indicates that the smallest
5771 integral type should be used.
5772
5773 @opindex fshort-enums
5774 Specifying this attribute for @code{struct} and @code{union} types is
5775 equivalent to specifying the @code{packed} attribute on each of the
5776 structure or union members. Specifying the @option{-fshort-enums}
5777 flag on the line is equivalent to specifying the @code{packed}
5778 attribute on all @code{enum} definitions.
5779
5780 In the following example @code{struct my_packed_struct}'s members are
5781 packed closely together, but the internal layout of its @code{s} member
5782 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5783 be packed too.
5784
5785 @smallexample
5786 struct my_unpacked_struct
5787 @{
5788 char c;
5789 int i;
5790 @};
5791
5792 struct __attribute__ ((__packed__)) my_packed_struct
5793 @{
5794 char c;
5795 int i;
5796 struct my_unpacked_struct s;
5797 @};
5798 @end smallexample
5799
5800 You may only specify this attribute on the definition of an @code{enum},
5801 @code{struct} or @code{union}, not on a @code{typedef} that does not
5802 also define the enumerated type, structure or union.
5803
5804 @item transparent_union
5805 @cindex @code{transparent_union} attribute
5806
5807 This attribute, attached to a @code{union} type definition, indicates
5808 that any function parameter having that union type causes calls to that
5809 function to be treated in a special way.
5810
5811 First, the argument corresponding to a transparent union type can be of
5812 any type in the union; no cast is required. Also, if the union contains
5813 a pointer type, the corresponding argument can be a null pointer
5814 constant or a void pointer expression; and if the union contains a void
5815 pointer type, the corresponding argument can be any pointer expression.
5816 If the union member type is a pointer, qualifiers like @code{const} on
5817 the referenced type must be respected, just as with normal pointer
5818 conversions.
5819
5820 Second, the argument is passed to the function using the calling
5821 conventions of the first member of the transparent union, not the calling
5822 conventions of the union itself. All members of the union must have the
5823 same machine representation; this is necessary for this argument passing
5824 to work properly.
5825
5826 Transparent unions are designed for library functions that have multiple
5827 interfaces for compatibility reasons. For example, suppose the
5828 @code{wait} function must accept either a value of type @code{int *} to
5829 comply with POSIX, or a value of type @code{union wait *} to comply with
5830 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
5831 @code{wait} would accept both kinds of arguments, but it would also
5832 accept any other pointer type and this would make argument type checking
5833 less useful. Instead, @code{<sys/wait.h>} might define the interface
5834 as follows:
5835
5836 @smallexample
5837 typedef union __attribute__ ((__transparent_union__))
5838 @{
5839 int *__ip;
5840 union wait *__up;
5841 @} wait_status_ptr_t;
5842
5843 pid_t wait (wait_status_ptr_t);
5844 @end smallexample
5845
5846 @noindent
5847 This interface allows either @code{int *} or @code{union wait *}
5848 arguments to be passed, using the @code{int *} calling convention.
5849 The program can call @code{wait} with arguments of either type:
5850
5851 @smallexample
5852 int w1 () @{ int w; return wait (&w); @}
5853 int w2 () @{ union wait w; return wait (&w); @}
5854 @end smallexample
5855
5856 @noindent
5857 With this interface, @code{wait}'s implementation might look like this:
5858
5859 @smallexample
5860 pid_t wait (wait_status_ptr_t p)
5861 @{
5862 return waitpid (-1, p.__ip, 0);
5863 @}
5864 @end smallexample
5865
5866 @item unused
5867 When attached to a type (including a @code{union} or a @code{struct}),
5868 this attribute means that variables of that type are meant to appear
5869 possibly unused. GCC does not produce a warning for any variables of
5870 that type, even if the variable appears to do nothing. This is often
5871 the case with lock or thread classes, which are usually defined and then
5872 not referenced, but contain constructors and destructors that have
5873 nontrivial bookkeeping functions.
5874
5875 @item deprecated
5876 @itemx deprecated (@var{msg})
5877 The @code{deprecated} attribute results in a warning if the type
5878 is used anywhere in the source file. This is useful when identifying
5879 types that are expected to be removed in a future version of a program.
5880 If possible, the warning also includes the location of the declaration
5881 of the deprecated type, to enable users to easily find further
5882 information about why the type is deprecated, or what they should do
5883 instead. Note that the warnings only occur for uses and then only
5884 if the type is being applied to an identifier that itself is not being
5885 declared as deprecated.
5886
5887 @smallexample
5888 typedef int T1 __attribute__ ((deprecated));
5889 T1 x;
5890 typedef T1 T2;
5891 T2 y;
5892 typedef T1 T3 __attribute__ ((deprecated));
5893 T3 z __attribute__ ((deprecated));
5894 @end smallexample
5895
5896 @noindent
5897 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
5898 warning is issued for line 4 because T2 is not explicitly
5899 deprecated. Line 5 has no warning because T3 is explicitly
5900 deprecated. Similarly for line 6. The optional @var{msg}
5901 argument, which must be a string, is printed in the warning if
5902 present.
5903
5904 The @code{deprecated} attribute can also be used for functions and
5905 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5906
5907 @item may_alias
5908 Accesses through pointers to types with this attribute are not subject
5909 to type-based alias analysis, but are instead assumed to be able to alias
5910 any other type of objects.
5911 In the context of section 6.5 paragraph 7 of the C99 standard,
5912 an lvalue expression
5913 dereferencing such a pointer is treated like having a character type.
5914 See @option{-fstrict-aliasing} for more information on aliasing issues.
5915 This extension exists to support some vector APIs, in which pointers to
5916 one vector type are permitted to alias pointers to a different vector type.
5917
5918 Note that an object of a type with this attribute does not have any
5919 special semantics.
5920
5921 Example of use:
5922
5923 @smallexample
5924 typedef short __attribute__((__may_alias__)) short_a;
5925
5926 int
5927 main (void)
5928 @{
5929 int a = 0x12345678;
5930 short_a *b = (short_a *) &a;
5931
5932 b[1] = 0;
5933
5934 if (a == 0x12345678)
5935 abort();
5936
5937 exit(0);
5938 @}
5939 @end smallexample
5940
5941 @noindent
5942 If you replaced @code{short_a} with @code{short} in the variable
5943 declaration, the above program would abort when compiled with
5944 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5945 above in recent GCC versions.
5946
5947 @item visibility
5948 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5949 applied to class, struct, union and enum types. Unlike other type
5950 attributes, the attribute must appear between the initial keyword and
5951 the name of the type; it cannot appear after the body of the type.
5952
5953 Note that the type visibility is applied to vague linkage entities
5954 associated with the class (vtable, typeinfo node, etc.). In
5955 particular, if a class is thrown as an exception in one shared object
5956 and caught in another, the class must have default visibility.
5957 Otherwise the two shared objects are unable to use the same
5958 typeinfo node and exception handling will break.
5959
5960 @item designated_init
5961 This attribute may only be applied to structure types. It indicates
5962 that any initialization of an object of this type must use designated
5963 initializers rather than positional initializers. The intent of this
5964 attribute is to allow the programmer to indicate that a structure's
5965 layout may change, and that therefore relying on positional
5966 initialization will result in future breakage.
5967
5968 GCC emits warnings based on this attribute by default; use
5969 @option{-Wno-designated-init} to suppress them.
5970
5971 @item bnd_variable_size
5972 When applied to a structure field, this attribute tells Pointer
5973 Bounds Checker that the size of this field should not be computed
5974 using static type information. It may be used to mark variable
5975 sized static array fields placed at the end of a structure.
5976
5977 @smallexample
5978 struct S
5979 @{
5980 int size;
5981 char data[1];
5982 @}
5983 S *p = (S *)malloc (sizeof(S) + 100);
5984 p->data[10] = 0; //Bounds violation
5985 @end smallexample
5986
5987 By using an attribute for a field we may avoid bound violation
5988 we most probably do not want to see:
5989
5990 @smallexample
5991 struct S
5992 @{
5993 int size;
5994 char data[1] __attribute__((bnd_variable_size));
5995 @}
5996 S *p = (S *)malloc (sizeof(S) + 100);
5997 p->data[10] = 0; //OK
5998 @end smallexample
5999
6000 @end table
6001
6002 To specify multiple attributes, separate them by commas within the
6003 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6004 packed))}.
6005
6006 @subsection ARM Type Attributes
6007
6008 On those ARM targets that support @code{dllimport} (such as Symbian
6009 OS), you can use the @code{notshared} attribute to indicate that the
6010 virtual table and other similar data for a class should not be
6011 exported from a DLL@. For example:
6012
6013 @smallexample
6014 class __declspec(notshared) C @{
6015 public:
6016 __declspec(dllimport) C();
6017 virtual void f();
6018 @}
6019
6020 __declspec(dllexport)
6021 C::C() @{@}
6022 @end smallexample
6023
6024 @noindent
6025 In this code, @code{C::C} is exported from the current DLL, but the
6026 virtual table for @code{C} is not exported. (You can use
6027 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6028 most Symbian OS code uses @code{__declspec}.)
6029
6030 @anchor{MeP Type Attributes}
6031 @subsection MeP Type Attributes
6032
6033 Many of the MeP variable attributes may be applied to types as well.
6034 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6035 @code{far} attributes may be applied to either. The @code{io} and
6036 @code{cb} attributes may not be applied to types.
6037
6038 @anchor{i386 Type Attributes}
6039 @subsection i386 Type Attributes
6040
6041 Two attributes are currently defined for i386 configurations:
6042 @code{ms_struct} and @code{gcc_struct}.
6043
6044 @table @code
6045
6046 @item ms_struct
6047 @itemx gcc_struct
6048 @cindex @code{ms_struct}
6049 @cindex @code{gcc_struct}
6050
6051 If @code{packed} is used on a structure, or if bit-fields are used
6052 it may be that the Microsoft ABI packs them differently
6053 than GCC normally packs them. Particularly when moving packed
6054 data between functions compiled with GCC and the native Microsoft compiler
6055 (either via function call or as data in a file), it may be necessary to access
6056 either format.
6057
6058 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
6059 compilers to match the native Microsoft compiler.
6060 @end table
6061
6062 @anchor{PowerPC Type Attributes}
6063 @subsection PowerPC Type Attributes
6064
6065 Three attributes currently are defined for PowerPC configurations:
6066 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6067
6068 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6069 attributes please see the documentation in @ref{i386 Type Attributes}.
6070
6071 The @code{altivec} attribute allows one to declare AltiVec vector data
6072 types supported by the AltiVec Programming Interface Manual. The
6073 attribute requires an argument to specify one of three vector types:
6074 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6075 and @code{bool__} (always followed by unsigned).
6076
6077 @smallexample
6078 __attribute__((altivec(vector__)))
6079 __attribute__((altivec(pixel__))) unsigned short
6080 __attribute__((altivec(bool__))) unsigned
6081 @end smallexample
6082
6083 These attributes mainly are intended to support the @code{__vector},
6084 @code{__pixel}, and @code{__bool} AltiVec keywords.
6085
6086 @anchor{SPU Type Attributes}
6087 @subsection SPU Type Attributes
6088
6089 The SPU supports the @code{spu_vector} attribute for types. This attribute
6090 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6091 Language Extensions Specification. It is intended to support the
6092 @code{__vector} keyword.
6093
6094 @node Alignment
6095 @section Inquiring on Alignment of Types or Variables
6096 @cindex alignment
6097 @cindex type alignment
6098 @cindex variable alignment
6099
6100 The keyword @code{__alignof__} allows you to inquire about how an object
6101 is aligned, or the minimum alignment usually required by a type. Its
6102 syntax is just like @code{sizeof}.
6103
6104 For example, if the target machine requires a @code{double} value to be
6105 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
6106 This is true on many RISC machines. On more traditional machine
6107 designs, @code{__alignof__ (double)} is 4 or even 2.
6108
6109 Some machines never actually require alignment; they allow reference to any
6110 data type even at an odd address. For these machines, @code{__alignof__}
6111 reports the smallest alignment that GCC gives the data type, usually as
6112 mandated by the target ABI.
6113
6114 If the operand of @code{__alignof__} is an lvalue rather than a type,
6115 its value is the required alignment for its type, taking into account
6116 any minimum alignment specified with GCC's @code{__attribute__}
6117 extension (@pxref{Variable Attributes}). For example, after this
6118 declaration:
6119
6120 @smallexample
6121 struct foo @{ int x; char y; @} foo1;
6122 @end smallexample
6123
6124 @noindent
6125 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6126 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6127
6128 It is an error to ask for the alignment of an incomplete type.
6129
6130
6131 @node Inline
6132 @section An Inline Function is As Fast As a Macro
6133 @cindex inline functions
6134 @cindex integrating function code
6135 @cindex open coding
6136 @cindex macros, inline alternative
6137
6138 By declaring a function inline, you can direct GCC to make
6139 calls to that function faster. One way GCC can achieve this is to
6140 integrate that function's code into the code for its callers. This
6141 makes execution faster by eliminating the function-call overhead; in
6142 addition, if any of the actual argument values are constant, their
6143 known values may permit simplifications at compile time so that not
6144 all of the inline function's code needs to be included. The effect on
6145 code size is less predictable; object code may be larger or smaller
6146 with function inlining, depending on the particular case. You can
6147 also direct GCC to try to integrate all ``simple enough'' functions
6148 into their callers with the option @option{-finline-functions}.
6149
6150 GCC implements three different semantics of declaring a function
6151 inline. One is available with @option{-std=gnu89} or
6152 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6153 on all inline declarations, another when
6154 @option{-std=c99}, @option{-std=c11},
6155 @option{-std=gnu99} or @option{-std=gnu11}
6156 (without @option{-fgnu89-inline}), and the third
6157 is used when compiling C++.
6158
6159 To declare a function inline, use the @code{inline} keyword in its
6160 declaration, like this:
6161
6162 @smallexample
6163 static inline int
6164 inc (int *a)
6165 @{
6166 return (*a)++;
6167 @}
6168 @end smallexample
6169
6170 If you are writing a header file to be included in ISO C90 programs, write
6171 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
6172
6173 The three types of inlining behave similarly in two important cases:
6174 when the @code{inline} keyword is used on a @code{static} function,
6175 like the example above, and when a function is first declared without
6176 using the @code{inline} keyword and then is defined with
6177 @code{inline}, like this:
6178
6179 @smallexample
6180 extern int inc (int *a);
6181 inline int
6182 inc (int *a)
6183 @{
6184 return (*a)++;
6185 @}
6186 @end smallexample
6187
6188 In both of these common cases, the program behaves the same as if you
6189 had not used the @code{inline} keyword, except for its speed.
6190
6191 @cindex inline functions, omission of
6192 @opindex fkeep-inline-functions
6193 When a function is both inline and @code{static}, if all calls to the
6194 function are integrated into the caller, and the function's address is
6195 never used, then the function's own assembler code is never referenced.
6196 In this case, GCC does not actually output assembler code for the
6197 function, unless you specify the option @option{-fkeep-inline-functions}.
6198 Some calls cannot be integrated for various reasons (in particular,
6199 calls that precede the function's definition cannot be integrated, and
6200 neither can recursive calls within the definition). If there is a
6201 nonintegrated call, then the function is compiled to assembler code as
6202 usual. The function must also be compiled as usual if the program
6203 refers to its address, because that can't be inlined.
6204
6205 @opindex Winline
6206 Note that certain usages in a function definition can make it unsuitable
6207 for inline substitution. Among these usages are: variadic functions, use of
6208 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6209 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6210 and nested functions (@pxref{Nested Functions}). Using @option{-Winline}
6211 warns when a function marked @code{inline} could not be substituted,
6212 and gives the reason for the failure.
6213
6214 @cindex automatic @code{inline} for C++ member fns
6215 @cindex @code{inline} automatic for C++ member fns
6216 @cindex member fns, automatically @code{inline}
6217 @cindex C++ member fns, automatically @code{inline}
6218 @opindex fno-default-inline
6219 As required by ISO C++, GCC considers member functions defined within
6220 the body of a class to be marked inline even if they are
6221 not explicitly declared with the @code{inline} keyword. You can
6222 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6223 Options,,Options Controlling C++ Dialect}.
6224
6225 GCC does not inline any functions when not optimizing unless you specify
6226 the @samp{always_inline} attribute for the function, like this:
6227
6228 @smallexample
6229 /* @r{Prototype.} */
6230 inline void foo (const char) __attribute__((always_inline));
6231 @end smallexample
6232
6233 The remainder of this section is specific to GNU C90 inlining.
6234
6235 @cindex non-static inline function
6236 When an inline function is not @code{static}, then the compiler must assume
6237 that there may be calls from other source files; since a global symbol can
6238 be defined only once in any program, the function must not be defined in
6239 the other source files, so the calls therein cannot be integrated.
6240 Therefore, a non-@code{static} inline function is always compiled on its
6241 own in the usual fashion.
6242
6243 If you specify both @code{inline} and @code{extern} in the function
6244 definition, then the definition is used only for inlining. In no case
6245 is the function compiled on its own, not even if you refer to its
6246 address explicitly. Such an address becomes an external reference, as
6247 if you had only declared the function, and had not defined it.
6248
6249 This combination of @code{inline} and @code{extern} has almost the
6250 effect of a macro. The way to use it is to put a function definition in
6251 a header file with these keywords, and put another copy of the
6252 definition (lacking @code{inline} and @code{extern}) in a library file.
6253 The definition in the header file causes most calls to the function
6254 to be inlined. If any uses of the function remain, they refer to
6255 the single copy in the library.
6256
6257 @node Volatiles
6258 @section When is a Volatile Object Accessed?
6259 @cindex accessing volatiles
6260 @cindex volatile read
6261 @cindex volatile write
6262 @cindex volatile access
6263
6264 C has the concept of volatile objects. These are normally accessed by
6265 pointers and used for accessing hardware or inter-thread
6266 communication. The standard encourages compilers to refrain from
6267 optimizations concerning accesses to volatile objects, but leaves it
6268 implementation defined as to what constitutes a volatile access. The
6269 minimum requirement is that at a sequence point all previous accesses
6270 to volatile objects have stabilized and no subsequent accesses have
6271 occurred. Thus an implementation is free to reorder and combine
6272 volatile accesses that occur between sequence points, but cannot do
6273 so for accesses across a sequence point. The use of volatile does
6274 not allow you to violate the restriction on updating objects multiple
6275 times between two sequence points.
6276
6277 Accesses to non-volatile objects are not ordered with respect to
6278 volatile accesses. You cannot use a volatile object as a memory
6279 barrier to order a sequence of writes to non-volatile memory. For
6280 instance:
6281
6282 @smallexample
6283 int *ptr = @var{something};
6284 volatile int vobj;
6285 *ptr = @var{something};
6286 vobj = 1;
6287 @end smallexample
6288
6289 @noindent
6290 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6291 that the write to @var{*ptr} occurs by the time the update
6292 of @var{vobj} happens. If you need this guarantee, you must use
6293 a stronger memory barrier such as:
6294
6295 @smallexample
6296 int *ptr = @var{something};
6297 volatile int vobj;
6298 *ptr = @var{something};
6299 asm volatile ("" : : : "memory");
6300 vobj = 1;
6301 @end smallexample
6302
6303 A scalar volatile object is read when it is accessed in a void context:
6304
6305 @smallexample
6306 volatile int *src = @var{somevalue};
6307 *src;
6308 @end smallexample
6309
6310 Such expressions are rvalues, and GCC implements this as a
6311 read of the volatile object being pointed to.
6312
6313 Assignments are also expressions and have an rvalue. However when
6314 assigning to a scalar volatile, the volatile object is not reread,
6315 regardless of whether the assignment expression's rvalue is used or
6316 not. If the assignment's rvalue is used, the value is that assigned
6317 to the volatile object. For instance, there is no read of @var{vobj}
6318 in all the following cases:
6319
6320 @smallexample
6321 int obj;
6322 volatile int vobj;
6323 vobj = @var{something};
6324 obj = vobj = @var{something};
6325 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6326 obj = (@var{something}, vobj = @var{anotherthing});
6327 @end smallexample
6328
6329 If you need to read the volatile object after an assignment has
6330 occurred, you must use a separate expression with an intervening
6331 sequence point.
6332
6333 As bit-fields are not individually addressable, volatile bit-fields may
6334 be implicitly read when written to, or when adjacent bit-fields are
6335 accessed. Bit-field operations may be optimized such that adjacent
6336 bit-fields are only partially accessed, if they straddle a storage unit
6337 boundary. For these reasons it is unwise to use volatile bit-fields to
6338 access hardware.
6339
6340 @node Using Assembly Language with C
6341 @section How to Use Inline Assembly Language in C Code
6342
6343 GCC provides various extensions that allow you to embed assembler within
6344 C code.
6345
6346 @menu
6347 * Basic Asm:: Inline assembler with no operands.
6348 * Extended Asm:: Inline assembler with operands.
6349 * Constraints:: Constraints for @code{asm} operands
6350 * Asm Labels:: Specifying the assembler name to use for a C symbol.
6351 * Explicit Reg Vars:: Defining variables residing in specified registers.
6352 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
6353 @end menu
6354
6355 @node Basic Asm
6356 @subsection Basic Asm --- Assembler Instructions with No Operands
6357 @cindex basic @code{asm}
6358
6359 The @code{asm} keyword allows you to embed assembler instructions within
6360 C code.
6361
6362 @example
6363 asm [ volatile ] ( AssemblerInstructions )
6364 @end example
6365
6366 To create headers compatible with ISO C, write @code{__asm__} instead of
6367 @code{asm} (@pxref{Alternate Keywords}).
6368
6369 By definition, a Basic @code{asm} statement is one with no operands.
6370 @code{asm} statements that contain one or more colons (used to delineate
6371 operands) are considered to be Extended (for example, @code{asm("int $3")}
6372 is Basic, and @code{asm("int $3" : )} is Extended). @xref{Extended Asm}.
6373
6374 @subsubheading Qualifiers
6375 @emph{volatile}
6376 @*
6377 This optional qualifier has no effect. All Basic @code{asm} blocks are
6378 implicitly volatile.
6379
6380 @subsubheading Parameters
6381 @emph{AssemblerInstructions}
6382 @*
6383 This is a literal string that specifies the assembler code. The string can
6384 contain any instructions recognized by the assembler, including directives.
6385 GCC does not parse the assembler instructions themselves and
6386 does not know what they mean or even whether they are valid assembler input.
6387 The compiler copies it verbatim to the assembly language output file, without
6388 processing dialects or any of the "%" operators that are available with
6389 Extended @code{asm}. This results in minor differences between Basic
6390 @code{asm} strings and Extended @code{asm} templates. For example, to refer to
6391 registers you might use %%eax in Extended @code{asm} and %eax in Basic
6392 @code{asm}.
6393
6394 You may place multiple assembler instructions together in a single @code{asm}
6395 string, separated by the characters normally used in assembly code for the
6396 system. A combination that works in most places is a newline to break the
6397 line, plus a tab character (written as "\n\t").
6398 Some assemblers allow semicolons as a line separator. However,
6399 note that some assembler dialects use semicolons to start a comment.
6400
6401 Do not expect a sequence of @code{asm} statements to remain perfectly
6402 consecutive after compilation. If certain instructions need to remain
6403 consecutive in the output, put them in a single multi-instruction asm
6404 statement. Note that GCC's optimizers can move @code{asm} statements
6405 relative to other code, including across jumps.
6406
6407 @code{asm} statements may not perform jumps into other @code{asm} statements.
6408 GCC does not know about these jumps, and therefore cannot take
6409 account of them when deciding how to optimize. Jumps from @code{asm} to C
6410 labels are only supported in Extended @code{asm}.
6411
6412 @subsubheading Remarks
6413 Using Extended @code{asm} will typically produce smaller, safer, and more
6414 efficient code, and in most cases it is a better solution. When writing
6415 inline assembly language outside of C functions, however, you must use Basic
6416 @code{asm}. Extended @code{asm} statements have to be inside a C function.
6417 Functions declared with the @code{naked} attribute also require Basic
6418 @code{asm} (@pxref{Function Attributes}).
6419
6420 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
6421 assembly code when optimizing. This can lead to unexpected duplicate
6422 symbol errors during compilation if your assembly code defines symbols or
6423 labels.
6424
6425 Safely accessing C data and calling functions from Basic @code{asm} is more
6426 complex than it may appear. To access C data, it is better to use Extended
6427 @code{asm}.
6428
6429 Since GCC does not parse the AssemblerInstructions, it has no
6430 visibility of any symbols it references. This may result in GCC discarding
6431 those symbols as unreferenced.
6432
6433 Unlike Extended @code{asm}, all Basic @code{asm} blocks are implicitly
6434 volatile. @xref{Volatile}. Similarly, Basic @code{asm} blocks are not treated
6435 as though they used a "memory" clobber (@pxref{Clobbers}).
6436
6437 All Basic @code{asm} blocks use the assembler dialect specified by the
6438 @option{-masm} command-line option. Basic @code{asm} provides no
6439 mechanism to provide different assembler strings for different dialects.
6440
6441 Here is an example of Basic @code{asm} for i386:
6442
6443 @example
6444 /* Note that this code will not compile with -masm=intel */
6445 #define DebugBreak() asm("int $3")
6446 @end example
6447
6448 @node Extended Asm
6449 @subsection Extended Asm - Assembler Instructions with C Expression Operands
6450 @cindex @code{asm} keyword
6451 @cindex extended @code{asm}
6452 @cindex assembler instructions
6453
6454 The @code{asm} keyword allows you to embed assembler instructions within C
6455 code. With Extended @code{asm} you can read and write C variables from
6456 assembler and perform jumps from assembler code to C labels.
6457
6458 @example
6459 @ifhtml
6460 asm [volatile] ( AssemblerTemplate : [OutputOperands] [ : [InputOperands] [ : [Clobbers] ] ] )
6461
6462 asm [volatile] goto ( AssemblerTemplate : : [InputOperands] : [Clobbers] : GotoLabels )
6463 @end ifhtml
6464 @ifnothtml
6465 asm [volatile] ( AssemblerTemplate
6466 : [OutputOperands]
6467 [ : [InputOperands]
6468 [ : [Clobbers] ] ])
6469
6470 asm [volatile] goto ( AssemblerTemplate
6471 :
6472 : [InputOperands]
6473 : [Clobbers]
6474 : GotoLabels)
6475 @end ifnothtml
6476 @end example
6477
6478 To create headers compatible with ISO C, write @code{__asm__} instead of
6479 @code{asm} and @code{__volatile__} instead of @code{volatile}
6480 (@pxref{Alternate Keywords}). There is no alternate for @code{goto}.
6481
6482 By definition, Extended @code{asm} is an @code{asm} statement that contains
6483 operands. To separate the classes of operands, you use colons. Basic
6484 @code{asm} statements contain no colons. (So, for example,
6485 @code{asm("int $3")} is Basic @code{asm}, and @code{asm("int $3" : )} is
6486 Extended @code{asm}. @pxref{Basic Asm}.)
6487
6488 @subsubheading Qualifiers
6489 @emph{volatile}
6490 @*
6491 The typical use of Extended @code{asm} statements is to manipulate input
6492 values to produce output values. However, your @code{asm} statements may
6493 also produce side effects. If so, you may need to use the @code{volatile}
6494 qualifier to disable certain optimizations. @xref{Volatile}.
6495
6496 @emph{goto}
6497 @*
6498 This qualifier informs the compiler that the @code{asm} statement may
6499 perform a jump to one of the labels listed in the GotoLabels section.
6500 @xref{GotoLabels}.
6501
6502 @subsubheading Parameters
6503 @emph{AssemblerTemplate}
6504 @*
6505 This is a literal string that contains the assembler code. It is a
6506 combination of fixed text and tokens that refer to the input, output,
6507 and goto parameters. @xref{AssemblerTemplate}.
6508
6509 @emph{OutputOperands}
6510 @*
6511 A comma-separated list of the C variables modified by the instructions in the
6512 AssemblerTemplate. @xref{OutputOperands}.
6513
6514 @emph{InputOperands}
6515 @*
6516 A comma-separated list of C expressions read by the instructions in the
6517 AssemblerTemplate. @xref{InputOperands}.
6518
6519 @emph{Clobbers}
6520 @*
6521 A comma-separated list of registers or other values changed by the
6522 AssemblerTemplate, beyond those listed as outputs. @xref{Clobbers}.
6523
6524 @emph{GotoLabels}
6525 @*
6526 When you are using the @code{goto} form of @code{asm}, this section contains
6527 the list of all C labels to which the AssemblerTemplate may jump.
6528 @xref{GotoLabels}.
6529
6530 @subsubheading Remarks
6531 The @code{asm} statement allows you to include assembly instructions directly
6532 within C code. This may help you to maximize performance in time-sensitive
6533 code or to access assembly instructions that are not readily available to C
6534 programs.
6535
6536 Note that Extended @code{asm} statements must be inside a function. Only
6537 Basic @code{asm} may be outside functions (@pxref{Basic Asm}).
6538 Functions declared with the @code{naked} attribute also require Basic
6539 @code{asm} (@pxref{Function Attributes}).
6540
6541 While the uses of @code{asm} are many and varied, it may help to think of an
6542 @code{asm} statement as a series of low-level instructions that convert input
6543 parameters to output parameters. So a simple (if not particularly useful)
6544 example for i386 using @code{asm} might look like this:
6545
6546 @example
6547 int src = 1;
6548 int dst;
6549
6550 asm ("mov %1, %0\n\t"
6551 "add $1, %0"
6552 : "=r" (dst)
6553 : "r" (src));
6554
6555 printf("%d\n", dst);
6556 @end example
6557
6558 This code will copy @var{src} to @var{dst} and add 1 to @var{dst}.
6559
6560 @anchor{Volatile}
6561 @subsubsection Volatile
6562 @cindex volatile @code{asm}
6563 @cindex @code{asm} volatile
6564
6565 GCC's optimizers sometimes discard @code{asm} statements if they determine
6566 there is no need for the output variables. Also, the optimizers may move
6567 code out of loops if they believe that the code will always return the same
6568 result (i.e. none of its input values change between calls). Using the
6569 @code{volatile} qualifier disables these optimizations. @code{asm} statements
6570 that have no output operands are implicitly volatile.
6571
6572 Examples:
6573
6574 This i386 code demonstrates a case that does not use (or require) the
6575 @code{volatile} qualifier. If it is performing assertion checking, this code
6576 uses @code{asm} to perform the validation. Otherwise, @var{dwRes} is
6577 unreferenced by any code. As a result, the optimizers can discard the
6578 @code{asm} statement, which in turn removes the need for the entire
6579 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
6580 isn't needed you allow the optimizers to produce the most efficient code
6581 possible.
6582
6583 @example
6584 void DoCheck(uint32_t dwSomeValue)
6585 @{
6586 uint32_t dwRes;
6587
6588 // Assumes dwSomeValue is not zero.
6589 asm ("bsfl %1,%0"
6590 : "=r" (dwRes)
6591 : "r" (dwSomeValue)
6592 : "cc");
6593
6594 assert(dwRes > 3);
6595 @}
6596 @end example
6597
6598 The next example shows a case where the optimizers can recognize that the input
6599 (@var{dwSomeValue}) never changes during the execution of the function and can
6600 therefore move the @code{asm} outside the loop to produce more efficient code.
6601 Again, using @code{volatile} disables this type of optimization.
6602
6603 @example
6604 void do_print(uint32_t dwSomeValue)
6605 @{
6606 uint32_t dwRes;
6607
6608 for (uint32_t x=0; x < 5; x++)
6609 @{
6610 // Assumes dwSomeValue is not zero.
6611 asm ("bsfl %1,%0"
6612 : "=r" (dwRes)
6613 : "r" (dwSomeValue)
6614 : "cc");
6615
6616 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
6617 @}
6618 @}
6619 @end example
6620
6621 The following example demonstrates a case where you need to use the
6622 @code{volatile} qualifier. It uses the i386 RDTSC instruction, which reads
6623 the computer's time-stamp counter. Without the @code{volatile} qualifier,
6624 the optimizers might assume that the @code{asm} block will always return the
6625 same value and therefore optimize away the second call.
6626
6627 @example
6628 uint64_t msr;
6629
6630 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
6631 "shl $32, %%rdx\n\t" // Shift the upper bits left.
6632 "or %%rdx, %0" // 'Or' in the lower bits.
6633 : "=a" (msr)
6634 :
6635 : "rdx");
6636
6637 printf("msr: %llx\n", msr);
6638
6639 // Do other work...
6640
6641 // Reprint the timestamp
6642 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
6643 "shl $32, %%rdx\n\t" // Shift the upper bits left.
6644 "or %%rdx, %0" // 'Or' in the lower bits.
6645 : "=a" (msr)
6646 :
6647 : "rdx");
6648
6649 printf("msr: %llx\n", msr);
6650 @end example
6651
6652 GCC's optimizers will not treat this code like the non-volatile code in the
6653 earlier examples. They do not move it out of loops or omit it on the
6654 assumption that the result from a previous call is still valid.
6655
6656 Note that the compiler can move even volatile @code{asm} instructions relative
6657 to other code, including across jump instructions. For example, on many
6658 targets there is a system register that controls the rounding mode of
6659 floating-point operations. Setting it with a volatile @code{asm}, as in the
6660 following PowerPC example, will not work reliably.
6661
6662 @example
6663 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
6664 sum = x + y;
6665 @end example
6666
6667 The compiler may move the addition back before the volatile @code{asm}. To
6668 make it work as expected, add an artificial dependency to the @code{asm} by
6669 referencing a variable in the subsequent code, for example:
6670
6671 @example
6672 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
6673 sum = x + y;
6674 @end example
6675
6676 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
6677 assembly code when optimizing. This can lead to unexpected duplicate symbol
6678 errors during compilation if your asm code defines symbols or labels. Using %=
6679 (@pxref{AssemblerTemplate}) may help resolve this problem.
6680
6681 @anchor{AssemblerTemplate}
6682 @subsubsection Assembler Template
6683 @cindex @code{asm} assembler template
6684
6685 An assembler template is a literal string containing assembler instructions.
6686 The compiler will replace any references to inputs, outputs, and goto labels
6687 in the template, and then output the resulting string to the assembler. The
6688 string can contain any instructions recognized by the assembler, including
6689 directives. GCC does not parse the assembler instructions
6690 themselves and does not know what they mean or even whether they are valid
6691 assembler input. However, it does count the statements
6692 (@pxref{Size of an asm}).
6693
6694 You may place multiple assembler instructions together in a single @code{asm}
6695 string, separated by the characters normally used in assembly code for the
6696 system. A combination that works in most places is a newline to break the
6697 line, plus a tab character to move to the instruction field (written as
6698 "\n\t"). Some assemblers allow semicolons as a line separator. However, note
6699 that some assembler dialects use semicolons to start a comment.
6700
6701 Do not expect a sequence of @code{asm} statements to remain perfectly
6702 consecutive after compilation, even when you are using the @code{volatile}
6703 qualifier. If certain instructions need to remain consecutive in the output,
6704 put them in a single multi-instruction asm statement.
6705
6706 Accessing data from C programs without using input/output operands (such as
6707 by using global symbols directly from the assembler template) may not work as
6708 expected. Similarly, calling functions directly from an assembler template
6709 requires a detailed understanding of the target assembler and ABI.
6710
6711 Since GCC does not parse the AssemblerTemplate, it has no visibility of any
6712 symbols it references. This may result in GCC discarding those symbols as
6713 unreferenced unless they are also listed as input, output, or goto operands.
6714
6715 GCC can support multiple assembler dialects (for example, GCC for i386
6716 supports "att" and "intel" dialects) for inline assembler. In builds that
6717 support this capability, the @option{-masm} option controls which dialect
6718 GCC uses as its default. The hardware-specific documentation for the
6719 @option{-masm} option contains the list of supported dialects, as well as the
6720 default dialect if the option is not specified. This information may be
6721 important to understand, since assembler code that works correctly when
6722 compiled using one dialect will likely fail if compiled using another.
6723
6724 @subsubheading Using braces in @code{asm} templates
6725
6726 If your code needs to support multiple assembler dialects (for example, if
6727 you are writing public headers that need to support a variety of compilation
6728 options), use constructs of this form:
6729
6730 @example
6731 @{ dialect0 | dialect1 | dialect2... @}
6732 @end example
6733
6734 This construct outputs 'dialect0' when using dialect #0 to compile the code,
6735 'dialect1' for dialect #1, etc. If there are fewer alternatives within the
6736 braces than the number of dialects the compiler supports, the construct
6737 outputs nothing.
6738
6739 For example, if an i386 compiler supports two dialects (att, intel), an
6740 assembler template such as this:
6741
6742 @example
6743 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
6744 @end example
6745
6746 would produce the output:
6747
6748 @example
6749 For att: "btl %[Offset],%[Base] ; jc %l2"
6750 For intel: "bt %[Base],%[Offset]; jc %l2"
6751 @end example
6752
6753 Using that same compiler, this code:
6754
6755 @example
6756 "xchg@{l@}\t@{%%@}ebx, %1"
6757 @end example
6758
6759 would produce
6760
6761 @example
6762 For att: "xchgl\t%%ebx, %1"
6763 For intel: "xchg\tebx, %1"
6764 @end example
6765
6766 There is no support for nesting dialect alternatives. Also, there is no
6767 ``escape'' for an open brace (@{), so do not use open braces in an Extended
6768 @code{asm} template other than as a dialect indicator.
6769
6770 @subsubheading Other format strings
6771
6772 In addition to the tokens described by the input, output, and goto operands,
6773 there are a few special cases:
6774
6775 @itemize
6776 @item
6777 "%%" outputs a single "%" into the assembler code.
6778
6779 @item
6780 "%=" outputs a number that is unique to each instance of the @code{asm}
6781 statement in the entire compilation. This option is useful when creating local
6782 labels and referring to them multiple times in a single template that
6783 generates multiple assembler instructions.
6784
6785 @end itemize
6786
6787 @anchor{OutputOperands}
6788 @subsubsection Output Operands
6789 @cindex @code{asm} output operands
6790
6791 An @code{asm} statement has zero or more output operands indicating the names
6792 of C variables modified by the assembler code.
6793
6794 In this i386 example, @var{old} (referred to in the template string as
6795 @code{%0}) and @var{*Base} (as @code{%1}) are outputs and @var{Offset}
6796 (@code{%2}) is an input:
6797
6798 @example
6799 bool old;
6800
6801 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
6802 "sbb %0,%0" // Use the CF to calculate old.
6803 : "=r" (old), "+rm" (*Base)
6804 : "Ir" (Offset)
6805 : "cc");
6806
6807 return old;
6808 @end example
6809
6810 Operands use this format:
6811
6812 @example
6813 [ [asmSymbolicName] ] "constraint" (cvariablename)
6814 @end example
6815
6816 @emph{asmSymbolicName}
6817 @*
6818
6819 When not using asmSymbolicNames, use the (zero-based) position of the operand
6820 in the list of operands in the assembler template. For example if there are
6821 three output operands, use @code{%0} in the template to refer to the first,
6822 @code{%1} for the second, and @code{%2} for the third. When using an
6823 asmSymbolicName, reference it by enclosing the name in square brackets
6824 (i.e. @code{%[Value]}). The scope of the name is the @code{asm} statement
6825 that contains the definition. Any valid C variable name is acceptable,
6826 including names already defined in the surrounding code. No two operands
6827 within the same @code{asm} statement can use the same symbolic name.
6828
6829 @emph{constraint}
6830 @*
6831 Output constraints must begin with either @code{"="} (a variable overwriting an
6832 existing value) or @code{"+"} (when reading and writing). When using
6833 @code{"="}, do not assume the location will contain the existing value (except
6834 when tying the variable to an input; @pxref{InputOperands,,Input Operands}).
6835
6836 After the prefix, there must be one or more additional constraints
6837 (@pxref{Constraints}) that describe where the value resides. Common
6838 constraints include @code{"r"} for register and @code{"m"} for memory.
6839 When you list more than one possible location (for example @code{"=rm"}), the
6840 compiler chooses the most efficient one based on the current context. If you
6841 list as many alternates as the @code{asm} statement allows, you will permit
6842 the optimizers to produce the best possible code. If you must use a specific
6843 register, but your Machine Constraints do not provide sufficient
6844 control to select the specific register you want, Local Reg Vars may provide
6845 a solution (@pxref{Local Reg Vars}).
6846
6847 @emph{cvariablename}
6848 @*
6849 Specifies the C variable name of the output (enclosed by parentheses). Accepts
6850 any (non-constant) variable within scope.
6851
6852 Remarks:
6853
6854 The total number of input + output + goto operands has a limit of 30. Commas
6855 separate the operands. When the compiler selects the registers to use to
6856 represent the output operands, it will not use any of the clobbered registers
6857 (@pxref{Clobbers}).
6858
6859 Output operand expressions must be lvalues. The compiler cannot check whether
6860 the operands have data types that are reasonable for the instruction being
6861 executed. For output expressions that are not directly addressable (for
6862 example a bit-field), the constraint must allow a register. In that case, GCC
6863 uses the register as the output of the @code{asm}, and then stores that
6864 register into the output.
6865
6866 Unless an output operand has the '@code{&}' constraint modifier
6867 (@pxref{Modifiers}), GCC may allocate it in the same register as an unrelated
6868 input operand, on the assumption that the assembler code will consume its
6869 inputs before producing outputs. This assumption may be false if the assembler
6870 code actually consists of more than one instruction. In this case, use
6871 '@code{&}' on each output operand that must not overlap an input.
6872
6873 The same problem can occur if one output parameter (@var{a}) allows a register
6874 constraint and another output parameter (@var{b}) allows a memory constraint.
6875 The code generated by GCC to access the memory address in @var{b} can contain
6876 registers which @emph{might} be shared by @var{a}, and GCC considers those
6877 registers to be inputs to the asm. As above, GCC assumes that such input
6878 registers are consumed before any outputs are written. This assumption may
6879 result in incorrect behavior if the asm writes to @var{a} before using
6880 @var{b}. Combining the `@code{&}' constraint with the register constraint
6881 ensures that modifying @var{a} will not affect what address is referenced by
6882 @var{b}. Omitting the `@code{&}' constraint means that the location of @var{b}
6883 will be undefined if @var{a} is modified before using @var{b}.
6884
6885 @code{asm} supports operand modifiers on operands (for example @code{%k2}
6886 instead of simply @code{%2}). Typically these qualifiers are hardware
6887 dependent. The list of supported modifiers for i386 is found at
6888 @ref{i386Operandmodifiers,i386 Operand modifiers}.
6889
6890 If the C code that follows the @code{asm} makes no use of any of the output
6891 operands, use @code{volatile} for the @code{asm} statement to prevent the
6892 optimizers from discarding the @code{asm} statement as unneeded
6893 (see @ref{Volatile}).
6894
6895 Examples:
6896
6897 This code makes no use of the optional asmSymbolicName. Therefore it
6898 references the first output operand as @code{%0} (were there a second, it
6899 would be @code{%1}, etc). The number of the first input operand is one greater
6900 than that of the last output operand. In this i386 example, that makes
6901 @var{Mask} @code{%1}:
6902
6903 @example
6904 uint32_t Mask = 1234;
6905 uint32_t Index;
6906
6907 asm ("bsfl %1, %0"
6908 : "=r" (Index)
6909 : "r" (Mask)
6910 : "cc");
6911 @end example
6912
6913 That code overwrites the variable Index ("="), placing the value in a register
6914 ("r"). The generic "r" constraint instead of a constraint for a specific
6915 register allows the compiler to pick the register to use, which can result
6916 in more efficient code. This may not be possible if an assembler instruction
6917 requires a specific register.
6918
6919 The following i386 example uses the asmSymbolicName operand. It produces the
6920 same result as the code above, but some may consider it more readable or more
6921 maintainable since reordering index numbers is not necessary when adding or
6922 removing operands. The names aIndex and aMask are only used to emphasize which
6923 names get used where. It is acceptable to reuse the names Index and Mask.
6924
6925 @example
6926 uint32_t Mask = 1234;
6927 uint32_t Index;
6928
6929 asm ("bsfl %[aMask], %[aIndex]"
6930 : [aIndex] "=r" (Index)
6931 : [aMask] "r" (Mask)
6932 : "cc");
6933 @end example
6934
6935 Here are some more examples of output operands.
6936
6937 @example
6938 uint32_t c = 1;
6939 uint32_t d;
6940 uint32_t *e = &c;
6941
6942 asm ("mov %[e], %[d]"
6943 : [d] "=rm" (d)
6944 : [e] "rm" (*e));
6945 @end example
6946
6947 Here, @var{d} may either be in a register or in memory. Since the compiler
6948 might already have the current value of the uint32_t pointed to by @var{e}
6949 in a register, you can enable it to choose the best location
6950 for @var{d} by specifying both constraints.
6951
6952 @anchor{InputOperands}
6953 @subsubsection Input Operands
6954 @cindex @code{asm} input operands
6955 @cindex @code{asm} expressions
6956
6957 Input operands make inputs from C variables and expressions available to the
6958 assembly code.
6959
6960 Specify input operands by using the format:
6961
6962 @example
6963 [ [asmSymbolicName] ] "constraint" (cexpression)
6964 @end example
6965
6966 @emph{asmSymbolicName}
6967 @*
6968 When not using asmSymbolicNames, use the (zero-based) position of the operand
6969 in the list of operands, including outputs, in the assembler template. For
6970 example, if there are two output parameters and three inputs, @code{%2} refers
6971 to the first input, @code{%3} to the second, and @code{%4} to the third.
6972 When using an asmSymbolicName, reference it by enclosing the name in square
6973 brackets (e.g. @code{%[Value]}). The scope of the name is the @code{asm}
6974 statement that contains the definition. Any valid C variable name is
6975 acceptable, including names already defined in the surrounding code. No two
6976 operands within the same @code{asm} statement can use the same symbolic name.
6977
6978 @emph{constraint}
6979 @*
6980 Input constraints must be a string containing one or more constraints
6981 (@pxref{Constraints}). When you give more than one possible constraint
6982 (for example, @code{"irm"}), the compiler will choose the most efficient
6983 method based on the current context. Input constraints may not begin with
6984 either "=" or "+". If you must use a specific register, but your Machine
6985 Constraints do not provide sufficient control to select the specific
6986 register you want, Local Reg Vars may provide a solution
6987 (@pxref{Local Reg Vars}).
6988
6989 Input constraints can also be digits (for example, @code{"0"}). This indicates
6990 that the specified input will be in the same place as the output constraint
6991 at the (zero-based) index in the output constraint list. When using
6992 asmSymbolicNames for the output operands, you may use these names (enclosed
6993 in brackets []) instead of digits.
6994
6995 @emph{cexpression}
6996 @*
6997 This is the C variable or expression being passed to the @code{asm} statement
6998 as input.
6999
7000 When the compiler selects the registers to use to represent the input
7001 operands, it will not use any of the clobbered registers (@pxref{Clobbers}).
7002
7003 If there are no output operands but there are input operands, place two
7004 consecutive colons where the output operands would go:
7005
7006 @example
7007 __asm__ ("some instructions"
7008 : /* No outputs. */
7009 : "r" (Offset / 8);
7010 @end example
7011
7012 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
7013 (except for inputs tied to outputs). The compiler assumes that on exit from
7014 the @code{asm} statement these operands will contain the same values as they
7015 had before executing the assembler. It is @emph{not} possible to use Clobbers
7016 to inform the compiler that the values in these inputs are changing. One
7017 common work-around is to tie the changing input variable to an output variable
7018 that never gets used. Note, however, that if the code that follows the
7019 @code{asm} statement makes no use of any of the output operands, the GCC
7020 optimizers may discard the @code{asm} statement as unneeded
7021 (see @ref{Volatile}).
7022
7023 Remarks:
7024
7025 The total number of input + output + goto operands has a limit of 30.
7026
7027 @code{asm} supports operand modifiers on operands (for example @code{%k2}
7028 instead of simply @code{%2}). Typically these qualifiers are hardware
7029 dependent. The list of supported modifiers for i386 is found at
7030 @ref{i386Operandmodifiers,i386 Operand modifiers}.
7031
7032 Examples:
7033
7034 In this example using the fictitious @code{combine} instruction, the
7035 constraint @code{"0"} for input operand 1 says that it must occupy the same
7036 location as output operand 0. Only input operands may use numbers in
7037 constraints, and they must each refer to an output operand. Only a number (or
7038 the symbolic assembler name) in the constraint can guarantee that one operand
7039 is in the same place as another. The mere fact that @var{foo} is the value of
7040 both operands is not enough to guarantee that they are in the same place in
7041 the generated assembler code.
7042
7043 @example
7044 asm ("combine %2, %0"
7045 : "=r" (foo)
7046 : "0" (foo), "g" (bar));
7047 @end example
7048
7049 Here is an example using symbolic names.
7050
7051 @example
7052 asm ("cmoveq %1, %2, %[result]"
7053 : [result] "=r"(result)
7054 : "r" (test), "r" (new), "[result]" (old));
7055 @end example
7056
7057 @anchor{Clobbers}
7058 @subsubsection Clobbers
7059 @cindex @code{asm} clobbers
7060
7061 While the compiler is aware of changes to entries listed in the output
7062 operands, the assembler code may modify more than just the outputs. For
7063 example, calculations may require additional registers, or the processor may
7064 overwrite a register as a side effect of a particular assembler instruction.
7065 In order to inform the compiler of these changes, list them in the clobber
7066 list. Clobber list items are either register names or the special clobbers
7067 (listed below). Each clobber list item is enclosed in double quotes and
7068 separated by commas.
7069
7070 Clobber descriptions may not in any way overlap with an input or output
7071 operand. For example, you may not have an operand describing a register class
7072 with one member when listing that register in the clobber list. Variables
7073 declared to live in specific registers (@pxref{Explicit Reg Vars}), and used
7074 as @code{asm} input or output operands, must have no part mentioned in the
7075 clobber description. In particular, there is no way to specify that input
7076 operands get modified without also specifying them as output operands.
7077
7078 When the compiler selects which registers to use to represent input and output
7079 operands, it will not use any of the clobbered registers. As a result,
7080 clobbered registers are available for any use in the assembler code.
7081
7082 Here is a realistic example for the VAX showing the use of clobbered
7083 registers:
7084
7085 @example
7086 asm volatile ("movc3 %0, %1, %2"
7087 : /* No outputs. */
7088 : "g" (from), "g" (to), "g" (count)
7089 : "r0", "r1", "r2", "r3", "r4", "r5");
7090 @end example
7091
7092 Also, there are two special clobber arguments:
7093
7094 @enumerate
7095 @item
7096 The @code{"cc"} clobber indicates that the assembler code modifies the flags
7097 register. On some machines, GCC represents the condition codes as a specific
7098 hardware register; "cc" serves to name this register. On other machines,
7099 condition code handling is different, and specifying "cc" has no effect. But
7100 it is valid no matter what the machine.
7101
7102 @item
7103 The "memory" clobber tells the compiler that the assembly code performs memory
7104 reads or writes to items other than those listed in the input and output
7105 operands (for example accessing the memory pointed to by one of the input
7106 parameters). To ensure memory contains correct values, GCC may need to flush
7107 specific register values to memory before executing the @code{asm}. Further,
7108 the compiler will not assume that any values read from memory before an
7109 @code{asm} will remain unchanged after that @code{asm}; it will reload them as
7110 needed. This effectively forms a read/write memory barrier for the compiler.
7111
7112 Note that this clobber does not prevent the @emph{processor} from doing
7113 speculative reads past the @code{asm} statement. To prevent that, you need
7114 processor-specific fence instructions.
7115
7116 Flushing registers to memory has performance implications and may be an issue
7117 for time-sensitive code. One trick to avoid this is available if the size of
7118 the memory being accessed is known at compile time. For example, if accessing
7119 ten bytes of a string, use a memory input like:
7120
7121 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
7122
7123 @end enumerate
7124
7125 @anchor{GotoLabels}
7126 @subsubsection Goto Labels
7127 @cindex @code{asm} goto labels
7128
7129 @code{asm goto} allows assembly code to jump to one or more C labels. The
7130 GotoLabels section in an @code{asm goto} statement contains a comma-separated
7131 list of all C labels to which the assembler code may jump. GCC assumes that
7132 @code{asm} execution falls through to the next statement (if this is not the
7133 case, consider using the @code{__builtin_unreachable} intrinsic after the
7134 @code{asm} statement). Optimization of @code{asm goto} may be improved by
7135 using the @code{hot} and @code{cold} label attributes (@pxref{Label
7136 Attributes}). The total number of input + output + goto operands has
7137 a limit of 30.
7138
7139 An @code{asm goto} statement can not have outputs (which means that the
7140 statement is implicitly volatile). This is due to an internal restriction of
7141 the compiler: control transfer instructions cannot have outputs. If the
7142 assembler code does modify anything, use the "memory" clobber to force the
7143 optimizers to flush all register values to memory, and reload them if
7144 necessary, after the @code{asm} statement.
7145
7146 To reference a label, prefix it with @code{%l} (that's a lowercase L) followed
7147 by its (zero-based) position in GotoLabels plus the number of input
7148 arguments. For example, if the @code{asm} has three inputs and references two
7149 labels, refer to the first label as @code{%l3} and the second as @code{%l4}).
7150
7151 @code{asm} statements may not perform jumps into other @code{asm} statements.
7152 GCC's optimizers do not know about these jumps; therefore they cannot take
7153 account of them when deciding how to optimize.
7154
7155 Example code for i386 might look like:
7156
7157 @example
7158 asm goto (
7159 "btl %1, %0\n\t"
7160 "jc %l2"
7161 : /* No outputs. */
7162 : "r" (p1), "r" (p2)
7163 : "cc"
7164 : carry);
7165
7166 return 0;
7167
7168 carry:
7169 return 1;
7170 @end example
7171
7172 The following example shows an @code{asm goto} that uses the memory clobber.
7173
7174 @example
7175 int frob(int x)
7176 @{
7177 int y;
7178 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
7179 : /* No outputs. */
7180 : "r"(x), "r"(&y)
7181 : "r5", "memory"
7182 : error);
7183 return y;
7184 error:
7185 return -1;
7186 @}
7187 @end example
7188
7189 @anchor{i386Operandmodifiers}
7190 @subsubsection i386 Operand modifiers
7191
7192 Input, output, and goto operands for extended @code{asm} statements can use
7193 modifiers to affect the code output to the assembler. For example, the
7194 following code uses the "h" and "b" modifiers for i386:
7195
7196 @example
7197 uint16_t num;
7198 asm volatile ("xchg %h0, %b0" : "+a" (num) );
7199 @end example
7200
7201 These modifiers generate this assembler code:
7202
7203 @example
7204 xchg %ah, %al
7205 @end example
7206
7207 The rest of this discussion uses the following code for illustrative purposes.
7208
7209 @example
7210 int main()
7211 @{
7212 int iInt = 1;
7213
7214 top:
7215
7216 asm volatile goto ("some assembler instructions here"
7217 : /* No outputs. */
7218 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
7219 : /* No clobbers. */
7220 : top);
7221 @}
7222 @end example
7223
7224 With no modifiers, this is what the output from the operands would be for the
7225 att and intel dialects of assembler:
7226
7227 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
7228 @headitem Operand @tab masm=att @tab masm=intel
7229 @item @code{%0}
7230 @tab @code{%eax}
7231 @tab @code{eax}
7232 @item @code{%1}
7233 @tab @code{$2}
7234 @tab @code{2}
7235 @item @code{%2}
7236 @tab @code{$.L2}
7237 @tab @code{OFFSET FLAT:.L2}
7238 @end multitable
7239
7240 The table below shows the list of supported modifiers and their effects.
7241
7242 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
7243 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
7244 @item @code{z}
7245 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
7246 @tab @code{%z0}
7247 @tab @code{l}
7248 @tab
7249 @item @code{b}
7250 @tab Print the QImode name of the register.
7251 @tab @code{%b0}
7252 @tab @code{%al}
7253 @tab @code{al}
7254 @item @code{h}
7255 @tab Print the QImode name for a ``high'' register.
7256 @tab @code{%h0}
7257 @tab @code{%ah}
7258 @tab @code{ah}
7259 @item @code{w}
7260 @tab Print the HImode name of the register.
7261 @tab @code{%w0}
7262 @tab @code{%ax}
7263 @tab @code{ax}
7264 @item @code{k}
7265 @tab Print the SImode name of the register.
7266 @tab @code{%k0}
7267 @tab @code{%eax}
7268 @tab @code{eax}
7269 @item @code{q}
7270 @tab Print the DImode name of the register.
7271 @tab @code{%q0}
7272 @tab @code{%rax}
7273 @tab @code{rax}
7274 @item @code{l}
7275 @tab Print the label name with no punctuation.
7276 @tab @code{%l2}
7277 @tab @code{.L2}
7278 @tab @code{.L2}
7279 @item @code{c}
7280 @tab Require a constant operand and print the constant expression with no punctuation.
7281 @tab @code{%c1}
7282 @tab @code{2}
7283 @tab @code{2}
7284 @end multitable
7285
7286 @anchor{i386floatingpointasmoperands}
7287 @subsubsection i386 floating-point asm operands
7288
7289 On i386 targets, there are several rules on the usage of stack-like registers
7290 in the operands of an @code{asm}. These rules apply only to the operands
7291 that are stack-like registers:
7292
7293 @enumerate
7294 @item
7295 Given a set of input registers that die in an @code{asm}, it is
7296 necessary to know which are implicitly popped by the @code{asm}, and
7297 which must be explicitly popped by GCC@.
7298
7299 An input register that is implicitly popped by the @code{asm} must be
7300 explicitly clobbered, unless it is constrained to match an
7301 output operand.
7302
7303 @item
7304 For any input register that is implicitly popped by an @code{asm}, it is
7305 necessary to know how to adjust the stack to compensate for the pop.
7306 If any non-popped input is closer to the top of the reg-stack than
7307 the implicitly popped register, it would not be possible to know what the
7308 stack looked like---it's not clear how the rest of the stack ``slides
7309 up''.
7310
7311 All implicitly popped input registers must be closer to the top of
7312 the reg-stack than any input that is not implicitly popped.
7313
7314 It is possible that if an input dies in an @code{asm}, the compiler might
7315 use the input register for an output reload. Consider this example:
7316
7317 @smallexample
7318 asm ("foo" : "=t" (a) : "f" (b));
7319 @end smallexample
7320
7321 @noindent
7322 This code says that input @code{b} is not popped by the @code{asm}, and that
7323 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
7324 deeper after the @code{asm} than it was before. But, it is possible that
7325 reload may think that it can use the same register for both the input and
7326 the output.
7327
7328 To prevent this from happening,
7329 if any input operand uses the @code{f} constraint, all output register
7330 constraints must use the @code{&} early-clobber modifier.
7331
7332 The example above would be correctly written as:
7333
7334 @smallexample
7335 asm ("foo" : "=&t" (a) : "f" (b));
7336 @end smallexample
7337
7338 @item
7339 Some operands need to be in particular places on the stack. All
7340 output operands fall in this category---GCC has no other way to
7341 know which registers the outputs appear in unless you indicate
7342 this in the constraints.
7343
7344 Output operands must specifically indicate which register an output
7345 appears in after an @code{asm}. @code{=f} is not allowed: the operand
7346 constraints must select a class with a single register.
7347
7348 @item
7349 Output operands may not be ``inserted'' between existing stack registers.
7350 Since no 387 opcode uses a read/write operand, all output operands
7351 are dead before the @code{asm}, and are pushed by the @code{asm}.
7352 It makes no sense to push anywhere but the top of the reg-stack.
7353
7354 Output operands must start at the top of the reg-stack: output
7355 operands may not ``skip'' a register.
7356
7357 @item
7358 Some @code{asm} statements may need extra stack space for internal
7359 calculations. This can be guaranteed by clobbering stack registers
7360 unrelated to the inputs and outputs.
7361
7362 @end enumerate
7363
7364 Here are a couple of reasonable @code{asm}s to want to write. This
7365 @code{asm}
7366 takes one input, which is internally popped, and produces two outputs.
7367
7368 @smallexample
7369 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
7370 @end smallexample
7371
7372 @noindent
7373 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
7374 and replaces them with one output. The @code{st(1)} clobber is necessary
7375 for the compiler to know that @code{fyl2xp1} pops both inputs.
7376
7377 @smallexample
7378 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
7379 @end smallexample
7380
7381 @lowersections
7382 @include md.texi
7383 @raisesections
7384
7385 @node Asm Labels
7386 @subsection Controlling Names Used in Assembler Code
7387 @cindex assembler names for identifiers
7388 @cindex names used in assembler code
7389 @cindex identifiers, names in assembler code
7390
7391 You can specify the name to be used in the assembler code for a C
7392 function or variable by writing the @code{asm} (or @code{__asm__})
7393 keyword after the declarator as follows:
7394
7395 @smallexample
7396 int foo asm ("myfoo") = 2;
7397 @end smallexample
7398
7399 @noindent
7400 This specifies that the name to be used for the variable @code{foo} in
7401 the assembler code should be @samp{myfoo} rather than the usual
7402 @samp{_foo}.
7403
7404 On systems where an underscore is normally prepended to the name of a C
7405 function or variable, this feature allows you to define names for the
7406 linker that do not start with an underscore.
7407
7408 It does not make sense to use this feature with a non-static local
7409 variable since such variables do not have assembler names. If you are
7410 trying to put the variable in a particular register, see @ref{Explicit
7411 Reg Vars}. GCC presently accepts such code with a warning, but will
7412 probably be changed to issue an error, rather than a warning, in the
7413 future.
7414
7415 You cannot use @code{asm} in this way in a function @emph{definition}; but
7416 you can get the same effect by writing a declaration for the function
7417 before its definition and putting @code{asm} there, like this:
7418
7419 @smallexample
7420 extern func () asm ("FUNC");
7421
7422 func (x, y)
7423 int x, y;
7424 /* @r{@dots{}} */
7425 @end smallexample
7426
7427 It is up to you to make sure that the assembler names you choose do not
7428 conflict with any other assembler symbols. Also, you must not use a
7429 register name; that would produce completely invalid assembler code. GCC
7430 does not as yet have the ability to store static variables in registers.
7431 Perhaps that will be added.
7432
7433 @node Explicit Reg Vars
7434 @subsection Variables in Specified Registers
7435 @cindex explicit register variables
7436 @cindex variables in specified registers
7437 @cindex specified registers
7438 @cindex registers, global allocation
7439
7440 GNU C allows you to put a few global variables into specified hardware
7441 registers. You can also specify the register in which an ordinary
7442 register variable should be allocated.
7443
7444 @itemize @bullet
7445 @item
7446 Global register variables reserve registers throughout the program.
7447 This may be useful in programs such as programming language
7448 interpreters that have a couple of global variables that are accessed
7449 very often.
7450
7451 @item
7452 Local register variables in specific registers do not reserve the
7453 registers, except at the point where they are used as input or output
7454 operands in an @code{asm} statement and the @code{asm} statement itself is
7455 not deleted. The compiler's data flow analysis is capable of determining
7456 where the specified registers contain live values, and where they are
7457 available for other uses. Stores into local register variables may be deleted
7458 when they appear to be dead according to dataflow analysis. References
7459 to local register variables may be deleted or moved or simplified.
7460
7461 These local variables are sometimes convenient for use with the extended
7462 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
7463 output of the assembler instruction directly into a particular register.
7464 (This works provided the register you specify fits the constraints
7465 specified for that operand in the @code{asm}.)
7466 @end itemize
7467
7468 @menu
7469 * Global Reg Vars::
7470 * Local Reg Vars::
7471 @end menu
7472
7473 @node Global Reg Vars
7474 @subsubsection Defining Global Register Variables
7475 @cindex global register variables
7476 @cindex registers, global variables in
7477
7478 You can define a global register variable in GNU C like this:
7479
7480 @smallexample
7481 register int *foo asm ("a5");
7482 @end smallexample
7483
7484 @noindent
7485 Here @code{a5} is the name of the register that should be used. Choose a
7486 register that is normally saved and restored by function calls on your
7487 machine, so that library routines will not clobber it.
7488
7489 Naturally the register name is cpu-dependent, so you need to
7490 conditionalize your program according to cpu type. The register
7491 @code{a5} is a good choice on a 68000 for a variable of pointer
7492 type. On machines with register windows, be sure to choose a ``global''
7493 register that is not affected magically by the function call mechanism.
7494
7495 In addition, different operating systems on the same CPU may differ in how they
7496 name the registers; then you need additional conditionals. For
7497 example, some 68000 operating systems call this register @code{%a5}.
7498
7499 Eventually there may be a way of asking the compiler to choose a register
7500 automatically, but first we need to figure out how it should choose and
7501 how to enable you to guide the choice. No solution is evident.
7502
7503 Defining a global register variable in a certain register reserves that
7504 register entirely for this use, at least within the current compilation.
7505 The register is not allocated for any other purpose in the functions
7506 in the current compilation, and is not saved and restored by
7507 these functions. Stores into this register are never deleted even if they
7508 appear to be dead, but references may be deleted or moved or
7509 simplified.
7510
7511 It is not safe to access the global register variables from signal
7512 handlers, or from more than one thread of control, because the system
7513 library routines may temporarily use the register for other things (unless
7514 you recompile them specially for the task at hand).
7515
7516 @cindex @code{qsort}, and global register variables
7517 It is not safe for one function that uses a global register variable to
7518 call another such function @code{foo} by way of a third function
7519 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
7520 different source file in which the variable isn't declared). This is
7521 because @code{lose} might save the register and put some other value there.
7522 For example, you can't expect a global register variable to be available in
7523 the comparison-function that you pass to @code{qsort}, since @code{qsort}
7524 might have put something else in that register. (If you are prepared to
7525 recompile @code{qsort} with the same global register variable, you can
7526 solve this problem.)
7527
7528 If you want to recompile @code{qsort} or other source files that do not
7529 actually use your global register variable, so that they do not use that
7530 register for any other purpose, then it suffices to specify the compiler
7531 option @option{-ffixed-@var{reg}}. You need not actually add a global
7532 register declaration to their source code.
7533
7534 A function that can alter the value of a global register variable cannot
7535 safely be called from a function compiled without this variable, because it
7536 could clobber the value the caller expects to find there on return.
7537 Therefore, the function that is the entry point into the part of the
7538 program that uses the global register variable must explicitly save and
7539 restore the value that belongs to its caller.
7540
7541 @cindex register variable after @code{longjmp}
7542 @cindex global register after @code{longjmp}
7543 @cindex value after @code{longjmp}
7544 @findex longjmp
7545 @findex setjmp
7546 On most machines, @code{longjmp} restores to each global register
7547 variable the value it had at the time of the @code{setjmp}. On some
7548 machines, however, @code{longjmp} does not change the value of global
7549 register variables. To be portable, the function that called @code{setjmp}
7550 should make other arrangements to save the values of the global register
7551 variables, and to restore them in a @code{longjmp}. This way, the same
7552 thing happens regardless of what @code{longjmp} does.
7553
7554 All global register variable declarations must precede all function
7555 definitions. If such a declaration could appear after function
7556 definitions, the declaration would be too late to prevent the register from
7557 being used for other purposes in the preceding functions.
7558
7559 Global register variables may not have initial values, because an
7560 executable file has no means to supply initial contents for a register.
7561
7562 On the SPARC, there are reports that g3 @dots{} g7 are suitable
7563 registers, but certain library functions, such as @code{getwd}, as well
7564 as the subroutines for division and remainder, modify g3 and g4. g1 and
7565 g2 are local temporaries.
7566
7567 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
7568 Of course, it does not do to use more than a few of those.
7569
7570 @node Local Reg Vars
7571 @subsubsection Specifying Registers for Local Variables
7572 @cindex local variables, specifying registers
7573 @cindex specifying registers for local variables
7574 @cindex registers for local variables
7575
7576 You can define a local register variable with a specified register
7577 like this:
7578
7579 @smallexample
7580 register int *foo asm ("a5");
7581 @end smallexample
7582
7583 @noindent
7584 Here @code{a5} is the name of the register that should be used. Note
7585 that this is the same syntax used for defining global register
7586 variables, but for a local variable it appears within a function.
7587
7588 Naturally the register name is cpu-dependent, but this is not a
7589 problem, since specific registers are most often useful with explicit
7590 assembler instructions (@pxref{Extended Asm}). Both of these things
7591 generally require that you conditionalize your program according to
7592 cpu type.
7593
7594 In addition, operating systems on one type of cpu may differ in how they
7595 name the registers; then you need additional conditionals. For
7596 example, some 68000 operating systems call this register @code{%a5}.
7597
7598 Defining such a register variable does not reserve the register; it
7599 remains available for other uses in places where flow control determines
7600 the variable's value is not live.
7601
7602 This option does not guarantee that GCC generates code that has
7603 this variable in the register you specify at all times. You may not
7604 code an explicit reference to this register in the @emph{assembler
7605 instruction template} part of an @code{asm} statement and assume it
7606 always refers to this variable. However, using the variable as an
7607 @code{asm} @emph{operand} guarantees that the specified register is used
7608 for the operand.
7609
7610 Stores into local register variables may be deleted when they appear to be dead
7611 according to dataflow analysis. References to local register variables may
7612 be deleted or moved or simplified.
7613
7614 As with global register variables, it is recommended that you choose a
7615 register that is normally saved and restored by function calls on
7616 your machine, so that library routines will not clobber it.
7617
7618 Sometimes when writing inline @code{asm} code, you need to make an operand be a
7619 specific register, but there's no matching constraint letter for that
7620 register. To force the operand into that register, create a local variable
7621 and specify the register in the variable's declaration. Then use the local
7622 variable for the asm operand and specify any constraint letter that matches
7623 the register:
7624
7625 @smallexample
7626 register int *p1 asm ("r0") = @dots{};
7627 register int *p2 asm ("r1") = @dots{};
7628 register int *result asm ("r0");
7629 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7630 @end smallexample
7631
7632 @emph{Warning:} In the above example, be aware that a register (for example r0) can be
7633 call-clobbered by subsequent code, including function calls and library calls
7634 for arithmetic operators on other variables (for example the initialization
7635 of p2). In this case, use temporary variables for expressions between the
7636 register assignments:
7637
7638 @smallexample
7639 int t1 = @dots{};
7640 register int *p1 asm ("r0") = @dots{};
7641 register int *p2 asm ("r1") = t1;
7642 register int *result asm ("r0");
7643 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7644 @end smallexample
7645
7646 @node Size of an asm
7647 @subsection Size of an @code{asm}
7648
7649 Some targets require that GCC track the size of each instruction used
7650 in order to generate correct code. Because the final length of the
7651 code produced by an @code{asm} statement is only known by the
7652 assembler, GCC must make an estimate as to how big it will be. It
7653 does this by counting the number of instructions in the pattern of the
7654 @code{asm} and multiplying that by the length of the longest
7655 instruction supported by that processor. (When working out the number
7656 of instructions, it assumes that any occurrence of a newline or of
7657 whatever statement separator character is supported by the assembler --
7658 typically @samp{;} --- indicates the end of an instruction.)
7659
7660 Normally, GCC's estimate is adequate to ensure that correct
7661 code is generated, but it is possible to confuse the compiler if you use
7662 pseudo instructions or assembler macros that expand into multiple real
7663 instructions, or if you use assembler directives that expand to more
7664 space in the object file than is needed for a single instruction.
7665 If this happens then the assembler may produce a diagnostic saying that
7666 a label is unreachable.
7667
7668 @node Alternate Keywords
7669 @section Alternate Keywords
7670 @cindex alternate keywords
7671 @cindex keywords, alternate
7672
7673 @option{-ansi} and the various @option{-std} options disable certain
7674 keywords. This causes trouble when you want to use GNU C extensions, or
7675 a general-purpose header file that should be usable by all programs,
7676 including ISO C programs. The keywords @code{asm}, @code{typeof} and
7677 @code{inline} are not available in programs compiled with
7678 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
7679 program compiled with @option{-std=c99} or @option{-std=c11}). The
7680 ISO C99 keyword
7681 @code{restrict} is only available when @option{-std=gnu99} (which will
7682 eventually be the default) or @option{-std=c99} (or the equivalent
7683 @option{-std=iso9899:1999}), or an option for a later standard
7684 version, is used.
7685
7686 The way to solve these problems is to put @samp{__} at the beginning and
7687 end of each problematical keyword. For example, use @code{__asm__}
7688 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
7689
7690 Other C compilers won't accept these alternative keywords; if you want to
7691 compile with another compiler, you can define the alternate keywords as
7692 macros to replace them with the customary keywords. It looks like this:
7693
7694 @smallexample
7695 #ifndef __GNUC__
7696 #define __asm__ asm
7697 #endif
7698 @end smallexample
7699
7700 @findex __extension__
7701 @opindex pedantic
7702 @option{-pedantic} and other options cause warnings for many GNU C extensions.
7703 You can
7704 prevent such warnings within one expression by writing
7705 @code{__extension__} before the expression. @code{__extension__} has no
7706 effect aside from this.
7707
7708 @node Incomplete Enums
7709 @section Incomplete @code{enum} Types
7710
7711 You can define an @code{enum} tag without specifying its possible values.
7712 This results in an incomplete type, much like what you get if you write
7713 @code{struct foo} without describing the elements. A later declaration
7714 that does specify the possible values completes the type.
7715
7716 You can't allocate variables or storage using the type while it is
7717 incomplete. However, you can work with pointers to that type.
7718
7719 This extension may not be very useful, but it makes the handling of
7720 @code{enum} more consistent with the way @code{struct} and @code{union}
7721 are handled.
7722
7723 This extension is not supported by GNU C++.
7724
7725 @node Function Names
7726 @section Function Names as Strings
7727 @cindex @code{__func__} identifier
7728 @cindex @code{__FUNCTION__} identifier
7729 @cindex @code{__PRETTY_FUNCTION__} identifier
7730
7731 GCC provides three magic variables that hold the name of the current
7732 function, as a string. The first of these is @code{__func__}, which
7733 is part of the C99 standard:
7734
7735 The identifier @code{__func__} is implicitly declared by the translator
7736 as if, immediately following the opening brace of each function
7737 definition, the declaration
7738
7739 @smallexample
7740 static const char __func__[] = "function-name";
7741 @end smallexample
7742
7743 @noindent
7744 appeared, where function-name is the name of the lexically-enclosing
7745 function. This name is the unadorned name of the function.
7746
7747 @code{__FUNCTION__} is another name for @code{__func__}. Older
7748 versions of GCC recognize only this name. However, it is not
7749 standardized. For maximum portability, we recommend you use
7750 @code{__func__}, but provide a fallback definition with the
7751 preprocessor:
7752
7753 @smallexample
7754 #if __STDC_VERSION__ < 199901L
7755 # if __GNUC__ >= 2
7756 # define __func__ __FUNCTION__
7757 # else
7758 # define __func__ "<unknown>"
7759 # endif
7760 #endif
7761 @end smallexample
7762
7763 In C, @code{__PRETTY_FUNCTION__} is yet another name for
7764 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
7765 the type signature of the function as well as its bare name. For
7766 example, this program:
7767
7768 @smallexample
7769 extern "C" @{
7770 extern int printf (char *, ...);
7771 @}
7772
7773 class a @{
7774 public:
7775 void sub (int i)
7776 @{
7777 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
7778 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
7779 @}
7780 @};
7781
7782 int
7783 main (void)
7784 @{
7785 a ax;
7786 ax.sub (0);
7787 return 0;
7788 @}
7789 @end smallexample
7790
7791 @noindent
7792 gives this output:
7793
7794 @smallexample
7795 __FUNCTION__ = sub
7796 __PRETTY_FUNCTION__ = void a::sub(int)
7797 @end smallexample
7798
7799 These identifiers are not preprocessor macros. In GCC 3.3 and
7800 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
7801 were treated as string literals; they could be used to initialize
7802 @code{char} arrays, and they could be concatenated with other string
7803 literals. GCC 3.4 and later treat them as variables, like
7804 @code{__func__}. In C++, @code{__FUNCTION__} and
7805 @code{__PRETTY_FUNCTION__} have always been variables.
7806
7807 @node Return Address
7808 @section Getting the Return or Frame Address of a Function
7809
7810 These functions may be used to get information about the callers of a
7811 function.
7812
7813 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
7814 This function returns the return address of the current function, or of
7815 one of its callers. The @var{level} argument is number of frames to
7816 scan up the call stack. A value of @code{0} yields the return address
7817 of the current function, a value of @code{1} yields the return address
7818 of the caller of the current function, and so forth. When inlining
7819 the expected behavior is that the function returns the address of
7820 the function that is returned to. To work around this behavior use
7821 the @code{noinline} function attribute.
7822
7823 The @var{level} argument must be a constant integer.
7824
7825 On some machines it may be impossible to determine the return address of
7826 any function other than the current one; in such cases, or when the top
7827 of the stack has been reached, this function returns @code{0} or a
7828 random value. In addition, @code{__builtin_frame_address} may be used
7829 to determine if the top of the stack has been reached.
7830
7831 Additional post-processing of the returned value may be needed, see
7832 @code{__builtin_extract_return_addr}.
7833
7834 This function should only be used with a nonzero argument for debugging
7835 purposes.
7836 @end deftypefn
7837
7838 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
7839 The address as returned by @code{__builtin_return_address} may have to be fed
7840 through this function to get the actual encoded address. For example, on the
7841 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
7842 platforms an offset has to be added for the true next instruction to be
7843 executed.
7844
7845 If no fixup is needed, this function simply passes through @var{addr}.
7846 @end deftypefn
7847
7848 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
7849 This function does the reverse of @code{__builtin_extract_return_addr}.
7850 @end deftypefn
7851
7852 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
7853 This function is similar to @code{__builtin_return_address}, but it
7854 returns the address of the function frame rather than the return address
7855 of the function. Calling @code{__builtin_frame_address} with a value of
7856 @code{0} yields the frame address of the current function, a value of
7857 @code{1} yields the frame address of the caller of the current function,
7858 and so forth.
7859
7860 The frame is the area on the stack that holds local variables and saved
7861 registers. The frame address is normally the address of the first word
7862 pushed on to the stack by the function. However, the exact definition
7863 depends upon the processor and the calling convention. If the processor
7864 has a dedicated frame pointer register, and the function has a frame,
7865 then @code{__builtin_frame_address} returns the value of the frame
7866 pointer register.
7867
7868 On some machines it may be impossible to determine the frame address of
7869 any function other than the current one; in such cases, or when the top
7870 of the stack has been reached, this function returns @code{0} if
7871 the first frame pointer is properly initialized by the startup code.
7872
7873 This function should only be used with a nonzero argument for debugging
7874 purposes.
7875 @end deftypefn
7876
7877 @node Vector Extensions
7878 @section Using Vector Instructions through Built-in Functions
7879
7880 On some targets, the instruction set contains SIMD vector instructions which
7881 operate on multiple values contained in one large register at the same time.
7882 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
7883 this way.
7884
7885 The first step in using these extensions is to provide the necessary data
7886 types. This should be done using an appropriate @code{typedef}:
7887
7888 @smallexample
7889 typedef int v4si __attribute__ ((vector_size (16)));
7890 @end smallexample
7891
7892 @noindent
7893 The @code{int} type specifies the base type, while the attribute specifies
7894 the vector size for the variable, measured in bytes. For example, the
7895 declaration above causes the compiler to set the mode for the @code{v4si}
7896 type to be 16 bytes wide and divided into @code{int} sized units. For
7897 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
7898 corresponding mode of @code{foo} is @acronym{V4SI}.
7899
7900 The @code{vector_size} attribute is only applicable to integral and
7901 float scalars, although arrays, pointers, and function return values
7902 are allowed in conjunction with this construct. Only sizes that are
7903 a power of two are currently allowed.
7904
7905 All the basic integer types can be used as base types, both as signed
7906 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
7907 @code{long long}. In addition, @code{float} and @code{double} can be
7908 used to build floating-point vector types.
7909
7910 Specifying a combination that is not valid for the current architecture
7911 causes GCC to synthesize the instructions using a narrower mode.
7912 For example, if you specify a variable of type @code{V4SI} and your
7913 architecture does not allow for this specific SIMD type, GCC
7914 produces code that uses 4 @code{SIs}.
7915
7916 The types defined in this manner can be used with a subset of normal C
7917 operations. Currently, GCC allows using the following operators
7918 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
7919
7920 The operations behave like C++ @code{valarrays}. Addition is defined as
7921 the addition of the corresponding elements of the operands. For
7922 example, in the code below, each of the 4 elements in @var{a} is
7923 added to the corresponding 4 elements in @var{b} and the resulting
7924 vector is stored in @var{c}.
7925
7926 @smallexample
7927 typedef int v4si __attribute__ ((vector_size (16)));
7928
7929 v4si a, b, c;
7930
7931 c = a + b;
7932 @end smallexample
7933
7934 Subtraction, multiplication, division, and the logical operations
7935 operate in a similar manner. Likewise, the result of using the unary
7936 minus or complement operators on a vector type is a vector whose
7937 elements are the negative or complemented values of the corresponding
7938 elements in the operand.
7939
7940 It is possible to use shifting operators @code{<<}, @code{>>} on
7941 integer-type vectors. The operation is defined as following: @code{@{a0,
7942 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
7943 @dots{}, an >> bn@}}@. Vector operands must have the same number of
7944 elements.
7945
7946 For convenience, it is allowed to use a binary vector operation
7947 where one operand is a scalar. In that case the compiler transforms
7948 the scalar operand into a vector where each element is the scalar from
7949 the operation. The transformation happens only if the scalar could be
7950 safely converted to the vector-element type.
7951 Consider the following code.
7952
7953 @smallexample
7954 typedef int v4si __attribute__ ((vector_size (16)));
7955
7956 v4si a, b, c;
7957 long l;
7958
7959 a = b + 1; /* a = b + @{1,1,1,1@}; */
7960 a = 2 * b; /* a = @{2,2,2,2@} * b; */
7961
7962 a = l + a; /* Error, cannot convert long to int. */
7963 @end smallexample
7964
7965 Vectors can be subscripted as if the vector were an array with
7966 the same number of elements and base type. Out of bound accesses
7967 invoke undefined behavior at run time. Warnings for out of bound
7968 accesses for vector subscription can be enabled with
7969 @option{-Warray-bounds}.
7970
7971 Vector comparison is supported with standard comparison
7972 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
7973 vector expressions of integer-type or real-type. Comparison between
7974 integer-type vectors and real-type vectors are not supported. The
7975 result of the comparison is a vector of the same width and number of
7976 elements as the comparison operands with a signed integral element
7977 type.
7978
7979 Vectors are compared element-wise producing 0 when comparison is false
7980 and -1 (constant of the appropriate type where all bits are set)
7981 otherwise. Consider the following example.
7982
7983 @smallexample
7984 typedef int v4si __attribute__ ((vector_size (16)));
7985
7986 v4si a = @{1,2,3,4@};
7987 v4si b = @{3,2,1,4@};
7988 v4si c;
7989
7990 c = a > b; /* The result would be @{0, 0,-1, 0@} */
7991 c = a == b; /* The result would be @{0,-1, 0,-1@} */
7992 @end smallexample
7993
7994 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
7995 @code{b} and @code{c} are vectors of the same type and @code{a} is an
7996 integer vector with the same number of elements of the same size as @code{b}
7997 and @code{c}, computes all three arguments and creates a vector
7998 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
7999 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
8000 As in the case of binary operations, this syntax is also accepted when
8001 one of @code{b} or @code{c} is a scalar that is then transformed into a
8002 vector. If both @code{b} and @code{c} are scalars and the type of
8003 @code{true?b:c} has the same size as the element type of @code{a}, then
8004 @code{b} and @code{c} are converted to a vector type whose elements have
8005 this type and with the same number of elements as @code{a}.
8006
8007 In C++, the logic operators @code{!, &&, ||} are available for vectors.
8008 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
8009 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
8010 For mixed operations between a scalar @code{s} and a vector @code{v},
8011 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
8012 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
8013
8014 Vector shuffling is available using functions
8015 @code{__builtin_shuffle (vec, mask)} and
8016 @code{__builtin_shuffle (vec0, vec1, mask)}.
8017 Both functions construct a permutation of elements from one or two
8018 vectors and return a vector of the same type as the input vector(s).
8019 The @var{mask} is an integral vector with the same width (@var{W})
8020 and element count (@var{N}) as the output vector.
8021
8022 The elements of the input vectors are numbered in memory ordering of
8023 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
8024 elements of @var{mask} are considered modulo @var{N} in the single-operand
8025 case and modulo @math{2*@var{N}} in the two-operand case.
8026
8027 Consider the following example,
8028
8029 @smallexample
8030 typedef int v4si __attribute__ ((vector_size (16)));
8031
8032 v4si a = @{1,2,3,4@};
8033 v4si b = @{5,6,7,8@};
8034 v4si mask1 = @{0,1,1,3@};
8035 v4si mask2 = @{0,4,2,5@};
8036 v4si res;
8037
8038 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
8039 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
8040 @end smallexample
8041
8042 Note that @code{__builtin_shuffle} is intentionally semantically
8043 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
8044
8045 You can declare variables and use them in function calls and returns, as
8046 well as in assignments and some casts. You can specify a vector type as
8047 a return type for a function. Vector types can also be used as function
8048 arguments. It is possible to cast from one vector type to another,
8049 provided they are of the same size (in fact, you can also cast vectors
8050 to and from other datatypes of the same size).
8051
8052 You cannot operate between vectors of different lengths or different
8053 signedness without a cast.
8054
8055 @node Offsetof
8056 @section Offsetof
8057 @findex __builtin_offsetof
8058
8059 GCC implements for both C and C++ a syntactic extension to implement
8060 the @code{offsetof} macro.
8061
8062 @smallexample
8063 primary:
8064 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
8065
8066 offsetof_member_designator:
8067 @code{identifier}
8068 | offsetof_member_designator "." @code{identifier}
8069 | offsetof_member_designator "[" @code{expr} "]"
8070 @end smallexample
8071
8072 This extension is sufficient such that
8073
8074 @smallexample
8075 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
8076 @end smallexample
8077
8078 @noindent
8079 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
8080 may be dependent. In either case, @var{member} may consist of a single
8081 identifier, or a sequence of member accesses and array references.
8082
8083 @node __sync Builtins
8084 @section Legacy __sync Built-in Functions for Atomic Memory Access
8085
8086 The following built-in functions
8087 are intended to be compatible with those described
8088 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
8089 section 7.4. As such, they depart from the normal GCC practice of using
8090 the @samp{__builtin_} prefix, and further that they are overloaded such that
8091 they work on multiple types.
8092
8093 The definition given in the Intel documentation allows only for the use of
8094 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
8095 counterparts. GCC allows any integral scalar or pointer type that is
8096 1, 2, 4 or 8 bytes in length.
8097
8098 Not all operations are supported by all target processors. If a particular
8099 operation cannot be implemented on the target processor, a warning is
8100 generated and a call an external function is generated. The external
8101 function carries the same name as the built-in version,
8102 with an additional suffix
8103 @samp{_@var{n}} where @var{n} is the size of the data type.
8104
8105 @c ??? Should we have a mechanism to suppress this warning? This is almost
8106 @c useful for implementing the operation under the control of an external
8107 @c mutex.
8108
8109 In most cases, these built-in functions are considered a @dfn{full barrier}.
8110 That is,
8111 no memory operand is moved across the operation, either forward or
8112 backward. Further, instructions are issued as necessary to prevent the
8113 processor from speculating loads across the operation and from queuing stores
8114 after the operation.
8115
8116 All of the routines are described in the Intel documentation to take
8117 ``an optional list of variables protected by the memory barrier''. It's
8118 not clear what is meant by that; it could mean that @emph{only} the
8119 following variables are protected, or it could mean that these variables
8120 should in addition be protected. At present GCC ignores this list and
8121 protects all variables that are globally accessible. If in the future
8122 we make some use of this list, an empty list will continue to mean all
8123 globally accessible variables.
8124
8125 @table @code
8126 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
8127 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
8128 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
8129 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
8130 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
8131 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
8132 @findex __sync_fetch_and_add
8133 @findex __sync_fetch_and_sub
8134 @findex __sync_fetch_and_or
8135 @findex __sync_fetch_and_and
8136 @findex __sync_fetch_and_xor
8137 @findex __sync_fetch_and_nand
8138 These built-in functions perform the operation suggested by the name, and
8139 returns the value that had previously been in memory. That is,
8140
8141 @smallexample
8142 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
8143 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
8144 @end smallexample
8145
8146 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
8147 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
8148
8149 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
8150 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
8151 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
8152 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
8153 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
8154 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
8155 @findex __sync_add_and_fetch
8156 @findex __sync_sub_and_fetch
8157 @findex __sync_or_and_fetch
8158 @findex __sync_and_and_fetch
8159 @findex __sync_xor_and_fetch
8160 @findex __sync_nand_and_fetch
8161 These built-in functions perform the operation suggested by the name, and
8162 return the new value. That is,
8163
8164 @smallexample
8165 @{ *ptr @var{op}= value; return *ptr; @}
8166 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
8167 @end smallexample
8168
8169 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
8170 as @code{*ptr = ~(*ptr & value)} instead of
8171 @code{*ptr = ~*ptr & value}.
8172
8173 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8174 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8175 @findex __sync_bool_compare_and_swap
8176 @findex __sync_val_compare_and_swap
8177 These built-in functions perform an atomic compare and swap.
8178 That is, if the current
8179 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
8180 @code{*@var{ptr}}.
8181
8182 The ``bool'' version returns true if the comparison is successful and
8183 @var{newval} is written. The ``val'' version returns the contents
8184 of @code{*@var{ptr}} before the operation.
8185
8186 @item __sync_synchronize (...)
8187 @findex __sync_synchronize
8188 This built-in function issues a full memory barrier.
8189
8190 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
8191 @findex __sync_lock_test_and_set
8192 This built-in function, as described by Intel, is not a traditional test-and-set
8193 operation, but rather an atomic exchange operation. It writes @var{value}
8194 into @code{*@var{ptr}}, and returns the previous contents of
8195 @code{*@var{ptr}}.
8196
8197 Many targets have only minimal support for such locks, and do not support
8198 a full exchange operation. In this case, a target may support reduced
8199 functionality here by which the @emph{only} valid value to store is the
8200 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
8201 is implementation defined.
8202
8203 This built-in function is not a full barrier,
8204 but rather an @dfn{acquire barrier}.
8205 This means that references after the operation cannot move to (or be
8206 speculated to) before the operation, but previous memory stores may not
8207 be globally visible yet, and previous memory loads may not yet be
8208 satisfied.
8209
8210 @item void __sync_lock_release (@var{type} *ptr, ...)
8211 @findex __sync_lock_release
8212 This built-in function releases the lock acquired by
8213 @code{__sync_lock_test_and_set}.
8214 Normally this means writing the constant 0 to @code{*@var{ptr}}.
8215
8216 This built-in function is not a full barrier,
8217 but rather a @dfn{release barrier}.
8218 This means that all previous memory stores are globally visible, and all
8219 previous memory loads have been satisfied, but following memory reads
8220 are not prevented from being speculated to before the barrier.
8221 @end table
8222
8223 @node __atomic Builtins
8224 @section Built-in functions for memory model aware atomic operations
8225
8226 The following built-in functions approximately match the requirements for
8227 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
8228 functions, but all also have a memory model parameter. These are all
8229 identified by being prefixed with @samp{__atomic}, and most are overloaded
8230 such that they work with multiple types.
8231
8232 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
8233 bytes in length. 16-byte integral types are also allowed if
8234 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
8235
8236 Target architectures are encouraged to provide their own patterns for
8237 each of these built-in functions. If no target is provided, the original
8238 non-memory model set of @samp{__sync} atomic built-in functions are
8239 utilized, along with any required synchronization fences surrounding it in
8240 order to achieve the proper behavior. Execution in this case is subject
8241 to the same restrictions as those built-in functions.
8242
8243 If there is no pattern or mechanism to provide a lock free instruction
8244 sequence, a call is made to an external routine with the same parameters
8245 to be resolved at run time.
8246
8247 The four non-arithmetic functions (load, store, exchange, and
8248 compare_exchange) all have a generic version as well. This generic
8249 version works on any data type. If the data type size maps to one
8250 of the integral sizes that may have lock free support, the generic
8251 version utilizes the lock free built-in function. Otherwise an
8252 external call is left to be resolved at run time. This external call is
8253 the same format with the addition of a @samp{size_t} parameter inserted
8254 as the first parameter indicating the size of the object being pointed to.
8255 All objects must be the same size.
8256
8257 There are 6 different memory models that can be specified. These map
8258 to the same names in the C++11 standard. Refer there or to the
8259 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
8260 atomic synchronization} for more detailed definitions. These memory
8261 models integrate both barriers to code motion as well as synchronization
8262 requirements with other threads. These are listed in approximately
8263 ascending order of strength. It is also possible to use target specific
8264 flags for memory model flags, like Hardware Lock Elision.
8265
8266 @table @code
8267 @item __ATOMIC_RELAXED
8268 No barriers or synchronization.
8269 @item __ATOMIC_CONSUME
8270 Data dependency only for both barrier and synchronization with another
8271 thread.
8272 @item __ATOMIC_ACQUIRE
8273 Barrier to hoisting of code and synchronizes with release (or stronger)
8274 semantic stores from another thread.
8275 @item __ATOMIC_RELEASE
8276 Barrier to sinking of code and synchronizes with acquire (or stronger)
8277 semantic loads from another thread.
8278 @item __ATOMIC_ACQ_REL
8279 Full barrier in both directions and synchronizes with acquire loads and
8280 release stores in another thread.
8281 @item __ATOMIC_SEQ_CST
8282 Full barrier in both directions and synchronizes with acquire loads and
8283 release stores in all threads.
8284 @end table
8285
8286 When implementing patterns for these built-in functions, the memory model
8287 parameter can be ignored as long as the pattern implements the most
8288 restrictive @code{__ATOMIC_SEQ_CST} model. Any of the other memory models
8289 execute correctly with this memory model but they may not execute as
8290 efficiently as they could with a more appropriate implementation of the
8291 relaxed requirements.
8292
8293 Note that the C++11 standard allows for the memory model parameter to be
8294 determined at run time rather than at compile time. These built-in
8295 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
8296 than invoke a runtime library call or inline a switch statement. This is
8297 standard compliant, safe, and the simplest approach for now.
8298
8299 The memory model parameter is a signed int, but only the lower 8 bits are
8300 reserved for the memory model. The remainder of the signed int is reserved
8301 for future use and should be 0. Use of the predefined atomic values
8302 ensures proper usage.
8303
8304 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
8305 This built-in function implements an atomic load operation. It returns the
8306 contents of @code{*@var{ptr}}.
8307
8308 The valid memory model variants are
8309 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8310 and @code{__ATOMIC_CONSUME}.
8311
8312 @end deftypefn
8313
8314 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
8315 This is the generic version of an atomic load. It returns the
8316 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
8317
8318 @end deftypefn
8319
8320 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
8321 This built-in function implements an atomic store operation. It writes
8322 @code{@var{val}} into @code{*@var{ptr}}.
8323
8324 The valid memory model variants are
8325 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
8326
8327 @end deftypefn
8328
8329 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
8330 This is the generic version of an atomic store. It stores the value
8331 of @code{*@var{val}} into @code{*@var{ptr}}.
8332
8333 @end deftypefn
8334
8335 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
8336 This built-in function implements an atomic exchange operation. It writes
8337 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
8338 @code{*@var{ptr}}.
8339
8340 The valid memory model variants are
8341 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8342 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
8343
8344 @end deftypefn
8345
8346 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
8347 This is the generic version of an atomic exchange. It stores the
8348 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
8349 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
8350
8351 @end deftypefn
8352
8353 @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)
8354 This built-in function implements an atomic compare and exchange operation.
8355 This compares the contents of @code{*@var{ptr}} with the contents of
8356 @code{*@var{expected}} and if equal, writes @var{desired} into
8357 @code{*@var{ptr}}. If they are not equal, the current contents of
8358 @code{*@var{ptr}} is written into @code{*@var{expected}}. @var{weak} is true
8359 for weak compare_exchange, and false for the strong variation. Many targets
8360 only offer the strong variation and ignore the parameter. When in doubt, use
8361 the strong variation.
8362
8363 True is returned if @var{desired} is written into
8364 @code{*@var{ptr}} and the execution is considered to conform to the
8365 memory model specified by @var{success_memmodel}. There are no
8366 restrictions on what memory model can be used here.
8367
8368 False is returned otherwise, and the execution is considered to conform
8369 to @var{failure_memmodel}. This memory model cannot be
8370 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
8371 stronger model than that specified by @var{success_memmodel}.
8372
8373 @end deftypefn
8374
8375 @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)
8376 This built-in function implements the generic version of
8377 @code{__atomic_compare_exchange}. The function is virtually identical to
8378 @code{__atomic_compare_exchange_n}, except the desired value is also a
8379 pointer.
8380
8381 @end deftypefn
8382
8383 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8384 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8385 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8386 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8387 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8388 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8389 These built-in functions perform the operation suggested by the name, and
8390 return the result of the operation. That is,
8391
8392 @smallexample
8393 @{ *ptr @var{op}= val; return *ptr; @}
8394 @end smallexample
8395
8396 All memory models are valid.
8397
8398 @end deftypefn
8399
8400 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
8401 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
8402 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
8403 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
8404 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
8405 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
8406 These built-in functions perform the operation suggested by the name, and
8407 return the value that had previously been in @code{*@var{ptr}}. That is,
8408
8409 @smallexample
8410 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
8411 @end smallexample
8412
8413 All memory models are valid.
8414
8415 @end deftypefn
8416
8417 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
8418
8419 This built-in function performs an atomic test-and-set operation on
8420 the byte at @code{*@var{ptr}}. The byte is set to some implementation
8421 defined nonzero ``set'' value and the return value is @code{true} if and only
8422 if the previous contents were ``set''.
8423 It should be only used for operands of type @code{bool} or @code{char}. For
8424 other types only part of the value may be set.
8425
8426 All memory models are valid.
8427
8428 @end deftypefn
8429
8430 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
8431
8432 This built-in function performs an atomic clear operation on
8433 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
8434 It should be only used for operands of type @code{bool} or @code{char} and
8435 in conjunction with @code{__atomic_test_and_set}.
8436 For other types it may only clear partially. If the type is not @code{bool}
8437 prefer using @code{__atomic_store}.
8438
8439 The valid memory model variants are
8440 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
8441 @code{__ATOMIC_RELEASE}.
8442
8443 @end deftypefn
8444
8445 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
8446
8447 This built-in function acts as a synchronization fence between threads
8448 based on the specified memory model.
8449
8450 All memory orders are valid.
8451
8452 @end deftypefn
8453
8454 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
8455
8456 This built-in function acts as a synchronization fence between a thread
8457 and signal handlers based in the same thread.
8458
8459 All memory orders are valid.
8460
8461 @end deftypefn
8462
8463 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
8464
8465 This built-in function returns true if objects of @var{size} bytes always
8466 generate lock free atomic instructions for the target architecture.
8467 @var{size} must resolve to a compile-time constant and the result also
8468 resolves to a compile-time constant.
8469
8470 @var{ptr} is an optional pointer to the object that may be used to determine
8471 alignment. A value of 0 indicates typical alignment should be used. The
8472 compiler may also ignore this parameter.
8473
8474 @smallexample
8475 if (_atomic_always_lock_free (sizeof (long long), 0))
8476 @end smallexample
8477
8478 @end deftypefn
8479
8480 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
8481
8482 This built-in function returns true if objects of @var{size} bytes always
8483 generate lock free atomic instructions for the target architecture. If
8484 it is not known to be lock free a call is made to a runtime routine named
8485 @code{__atomic_is_lock_free}.
8486
8487 @var{ptr} is an optional pointer to the object that may be used to determine
8488 alignment. A value of 0 indicates typical alignment should be used. The
8489 compiler may also ignore this parameter.
8490 @end deftypefn
8491
8492 @node Integer Overflow Builtins
8493 @section Built-in functions to perform arithmetics and arithmetic overflow checking.
8494
8495 The following built-in functions allow performing simple arithmetic operations
8496 together with checking whether the operations overflowed.
8497
8498 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8499 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
8500 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
8501 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
8502 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
8503 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8504 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8505
8506 These built-in functions promote the first two operands into infinite precision signed
8507 type and perform addition on those promoted operands. The result is then
8508 cast to the type the third pointer argument points to and stored there.
8509 If the stored result is equal to the infinite precision result, the built-in
8510 functions return false, otherwise they return true. As the addition is
8511 performed in infinite signed precision, these built-in functions have fully defined
8512 behavior for all argument values.
8513
8514 The first built-in function allows arbitrary integral types for operands and
8515 the result type must be pointer to some integer type, the rest of the built-in
8516 functions have explicit integer types.
8517
8518 The compiler will attempt to use hardware instructions to implement
8519 these built-in functions where possible, like conditional jump on overflow
8520 after addition, conditional jump on carry etc.
8521
8522 @end deftypefn
8523
8524 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8525 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
8526 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
8527 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
8528 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
8529 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8530 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8531
8532 These built-in functions are similar to the add overflow checking built-in
8533 functions above, except they perform subtraction, subtract the second argument
8534 from the first one, instead of addition.
8535
8536 @end deftypefn
8537
8538 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8539 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
8540 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
8541 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
8542 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
8543 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8544 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8545
8546 These built-in functions are similar to the add overflow checking built-in
8547 functions above, except they perform multiplication, instead of addition.
8548
8549 @end deftypefn
8550
8551 @node x86 specific memory model extensions for transactional memory
8552 @section x86 specific memory model extensions for transactional memory
8553
8554 The i386 architecture supports additional memory ordering flags
8555 to mark lock critical sections for hardware lock elision.
8556 These must be specified in addition to an existing memory model to
8557 atomic intrinsics.
8558
8559 @table @code
8560 @item __ATOMIC_HLE_ACQUIRE
8561 Start lock elision on a lock variable.
8562 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
8563 @item __ATOMIC_HLE_RELEASE
8564 End lock elision on a lock variable.
8565 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
8566 @end table
8567
8568 When a lock acquire fails it is required for good performance to abort
8569 the transaction quickly. This can be done with a @code{_mm_pause}
8570
8571 @smallexample
8572 #include <immintrin.h> // For _mm_pause
8573
8574 int lockvar;
8575
8576 /* Acquire lock with lock elision */
8577 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
8578 _mm_pause(); /* Abort failed transaction */
8579 ...
8580 /* Free lock with lock elision */
8581 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
8582 @end smallexample
8583
8584 @node Object Size Checking
8585 @section Object Size Checking Built-in Functions
8586 @findex __builtin_object_size
8587 @findex __builtin___memcpy_chk
8588 @findex __builtin___mempcpy_chk
8589 @findex __builtin___memmove_chk
8590 @findex __builtin___memset_chk
8591 @findex __builtin___strcpy_chk
8592 @findex __builtin___stpcpy_chk
8593 @findex __builtin___strncpy_chk
8594 @findex __builtin___strcat_chk
8595 @findex __builtin___strncat_chk
8596 @findex __builtin___sprintf_chk
8597 @findex __builtin___snprintf_chk
8598 @findex __builtin___vsprintf_chk
8599 @findex __builtin___vsnprintf_chk
8600 @findex __builtin___printf_chk
8601 @findex __builtin___vprintf_chk
8602 @findex __builtin___fprintf_chk
8603 @findex __builtin___vfprintf_chk
8604
8605 GCC implements a limited buffer overflow protection mechanism
8606 that can prevent some buffer overflow attacks.
8607
8608 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
8609 is a built-in construct that returns a constant number of bytes from
8610 @var{ptr} to the end of the object @var{ptr} pointer points to
8611 (if known at compile time). @code{__builtin_object_size} never evaluates
8612 its arguments for side-effects. If there are any side-effects in them, it
8613 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8614 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
8615 point to and all of them are known at compile time, the returned number
8616 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
8617 0 and minimum if nonzero. If it is not possible to determine which objects
8618 @var{ptr} points to at compile time, @code{__builtin_object_size} should
8619 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8620 for @var{type} 2 or 3.
8621
8622 @var{type} is an integer constant from 0 to 3. If the least significant
8623 bit is clear, objects are whole variables, if it is set, a closest
8624 surrounding subobject is considered the object a pointer points to.
8625 The second bit determines if maximum or minimum of remaining bytes
8626 is computed.
8627
8628 @smallexample
8629 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
8630 char *p = &var.buf1[1], *q = &var.b;
8631
8632 /* Here the object p points to is var. */
8633 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
8634 /* The subobject p points to is var.buf1. */
8635 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
8636 /* The object q points to is var. */
8637 assert (__builtin_object_size (q, 0)
8638 == (char *) (&var + 1) - (char *) &var.b);
8639 /* The subobject q points to is var.b. */
8640 assert (__builtin_object_size (q, 1) == sizeof (var.b));
8641 @end smallexample
8642 @end deftypefn
8643
8644 There are built-in functions added for many common string operation
8645 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
8646 built-in is provided. This built-in has an additional last argument,
8647 which is the number of bytes remaining in object the @var{dest}
8648 argument points to or @code{(size_t) -1} if the size is not known.
8649
8650 The built-in functions are optimized into the normal string functions
8651 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
8652 it is known at compile time that the destination object will not
8653 be overflown. If the compiler can determine at compile time the
8654 object will be always overflown, it issues a warning.
8655
8656 The intended use can be e.g.@:
8657
8658 @smallexample
8659 #undef memcpy
8660 #define bos0(dest) __builtin_object_size (dest, 0)
8661 #define memcpy(dest, src, n) \
8662 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
8663
8664 char *volatile p;
8665 char buf[10];
8666 /* It is unknown what object p points to, so this is optimized
8667 into plain memcpy - no checking is possible. */
8668 memcpy (p, "abcde", n);
8669 /* Destination is known and length too. It is known at compile
8670 time there will be no overflow. */
8671 memcpy (&buf[5], "abcde", 5);
8672 /* Destination is known, but the length is not known at compile time.
8673 This will result in __memcpy_chk call that can check for overflow
8674 at run time. */
8675 memcpy (&buf[5], "abcde", n);
8676 /* Destination is known and it is known at compile time there will
8677 be overflow. There will be a warning and __memcpy_chk call that
8678 will abort the program at run time. */
8679 memcpy (&buf[6], "abcde", 5);
8680 @end smallexample
8681
8682 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
8683 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
8684 @code{strcat} and @code{strncat}.
8685
8686 There are also checking built-in functions for formatted output functions.
8687 @smallexample
8688 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
8689 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8690 const char *fmt, ...);
8691 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
8692 va_list ap);
8693 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8694 const char *fmt, va_list ap);
8695 @end smallexample
8696
8697 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
8698 etc.@: functions and can contain implementation specific flags on what
8699 additional security measures the checking function might take, such as
8700 handling @code{%n} differently.
8701
8702 The @var{os} argument is the object size @var{s} points to, like in the
8703 other built-in functions. There is a small difference in the behavior
8704 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
8705 optimized into the non-checking functions only if @var{flag} is 0, otherwise
8706 the checking function is called with @var{os} argument set to
8707 @code{(size_t) -1}.
8708
8709 In addition to this, there are checking built-in functions
8710 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
8711 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
8712 These have just one additional argument, @var{flag}, right before
8713 format string @var{fmt}. If the compiler is able to optimize them to
8714 @code{fputc} etc.@: functions, it does, otherwise the checking function
8715 is called and the @var{flag} argument passed to it.
8716
8717 @node Pointer Bounds Checker builtins
8718 @section Pointer Bounds Checker Built-in Functions
8719 @findex __builtin___bnd_set_ptr_bounds
8720 @findex __builtin___bnd_narrow_ptr_bounds
8721 @findex __builtin___bnd_copy_ptr_bounds
8722 @findex __builtin___bnd_init_ptr_bounds
8723 @findex __builtin___bnd_null_ptr_bounds
8724 @findex __builtin___bnd_store_ptr_bounds
8725 @findex __builtin___bnd_chk_ptr_lbounds
8726 @findex __builtin___bnd_chk_ptr_ubounds
8727 @findex __builtin___bnd_chk_ptr_bounds
8728 @findex __builtin___bnd_get_ptr_lbound
8729 @findex __builtin___bnd_get_ptr_ubound
8730
8731 GCC provides a set of built-in functions to control Pointer Bounds Checker
8732 instrumentation. Note that all Pointer Bounds Checker builtins are allowed
8733 to use even if you compile with Pointer Bounds Checker off. The builtins
8734 behavior may differ in such case as documented below.
8735
8736 @deftypefn {Built-in Function} void * __builtin___bnd_set_ptr_bounds (const void * @var{q}, size_t @var{size})
8737
8738 This built-in function returns a new pointer with the value of @var{q}, and
8739 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
8740 Bounds Checker off built-in function just returns the first argument.
8741
8742 @smallexample
8743 extern void *__wrap_malloc (size_t n)
8744 @{
8745 void *p = (void *)__real_malloc (n);
8746 if (!p) return __builtin___bnd_null_ptr_bounds (p);
8747 return __builtin___bnd_set_ptr_bounds (p, n);
8748 @}
8749 @end smallexample
8750
8751 @end deftypefn
8752
8753 @deftypefn {Built-in Function} void * __builtin___bnd_narrow_ptr_bounds (const void * @var{p}, const void * @var{q}, size_t @var{size})
8754
8755 This built-in function returns a new pointer with the value of @var{p}
8756 and associate it with the narrowed bounds formed by the intersection
8757 of bounds associated with @var{q} and the [@var{p}, @var{p} + @var{size} - 1].
8758 With Pointer Bounds Checker off built-in function just returns the first
8759 argument.
8760
8761 @smallexample
8762 void init_objects (object *objs, size_t size)
8763 @{
8764 size_t i;
8765 /* Initialize objects one-by-one passing pointers with bounds of an object,
8766 not the full array of objects. */
8767 for (i = 0; i < size; i++)
8768 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs, sizeof(object)));
8769 @}
8770 @end smallexample
8771
8772 @end deftypefn
8773
8774 @deftypefn {Built-in Function} void * __builtin___bnd_copy_ptr_bounds (const void * @var{q}, const void * @var{r})
8775
8776 This built-in function returns a new pointer with the value of @var{q},
8777 and associate it with the bounds already associated with pointer @var{r}.
8778 With Pointer Bounds Checker off built-in function just returns the first
8779 argument.
8780
8781 @smallexample
8782 /* Here is a way to get pointer to object's field but
8783 still with the full object's bounds. */
8784 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_filed, objptr);
8785 @end smallexample
8786
8787 @end deftypefn
8788
8789 @deftypefn {Built-in Function} void * __builtin___bnd_init_ptr_bounds (const void * @var{q})
8790
8791 This built-in function returns a new pointer with the value of @var{q}, and
8792 associate it with INIT (allowing full memory access) bounds. With Pointer
8793 Bounds Checker off built-in function just returns the first argument.
8794
8795 @end deftypefn
8796
8797 @deftypefn {Built-in Function} void * __builtin___bnd_null_ptr_bounds (const void * @var{q})
8798
8799 This built-in function returns a new pointer with the value of @var{q}, and
8800 associate it with NULL (allowing no memory access) bounds. With Pointer
8801 Bounds Checker off built-in function just returns the first argument.
8802
8803 @end deftypefn
8804
8805 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void ** @var{ptr_addr}, const void * @var{ptr_val})
8806
8807 This built-in function stores the bounds associated with pointer @var{ptr_val}
8808 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
8809 bounds from legacy code without touching the associated pointer's memory when
8810 pointers were copied as integers. With Pointer Bounds Checker off built-in
8811 function call is ignored.
8812
8813 @end deftypefn
8814
8815 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void * @var{q})
8816
8817 This built-in function checks if the pointer @var{q} is within the lower
8818 bound of its associated bounds. With Pointer Bounds Checker off built-in
8819 function call is ignored.
8820
8821 @smallexample
8822 extern void *__wrap_memset (void *dst, int c, size_t len)
8823 @{
8824 if (len > 0)
8825 @{
8826 __builtin___bnd_chk_ptr_lbounds (dst);
8827 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
8828 __real_memset (dst, c, len);
8829 @}
8830 return dst;
8831 @}
8832 @end smallexample
8833
8834 @end deftypefn
8835
8836 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void * @var{q})
8837
8838 This built-in function checks if the pointer @var{q} is within the upper
8839 bound of its associated bounds. With Pointer Bounds Checker off built-in
8840 function call is ignored.
8841
8842 @end deftypefn
8843
8844 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void * @var{q}, size_t @var{size})
8845
8846 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
8847 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
8848 off built-in function call is ignored.
8849
8850 @smallexample
8851 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
8852 @{
8853 if (n > 0)
8854 @{
8855 __bnd_chk_ptr_bounds (dst, n);
8856 __bnd_chk_ptr_bounds (src, n);
8857 __real_memcpy (dst, src, n);
8858 @}
8859 return dst;
8860 @}
8861 @end smallexample
8862
8863 @end deftypefn
8864
8865 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_lbound (const void * @var{q})
8866
8867 This built-in function returns the lower bound (which is a pointer) associated
8868 with the pointer @var{q}. This is at least useful for debugging using printf.
8869 With Pointer Bounds Checker off built-in function returns 0.
8870
8871 @smallexample
8872 void *lb = __builtin___bnd_get_ptr_lbound (q);
8873 void *ub = __builtin___bnd_get_ptr_ubound (q);
8874 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
8875 @end smallexample
8876
8877 @end deftypefn
8878
8879 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_ubound (const void * @var{q})
8880
8881 This built-in function returns the upper bound (which is a pointer) associated
8882 with the pointer @var{q}. With Pointer Bounds Checker off built-in function
8883 returns -1.
8884
8885 @end deftypefn
8886
8887 @node Cilk Plus Builtins
8888 @section Cilk Plus C/C++ language extension Built-in Functions.
8889
8890 GCC provides support for the following built-in reduction funtions if Cilk Plus
8891 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
8892
8893 @itemize @bullet
8894 @item __sec_implicit_index
8895 @item __sec_reduce
8896 @item __sec_reduce_add
8897 @item __sec_reduce_all_nonzero
8898 @item __sec_reduce_all_zero
8899 @item __sec_reduce_any_nonzero
8900 @item __sec_reduce_any_zero
8901 @item __sec_reduce_max
8902 @item __sec_reduce_min
8903 @item __sec_reduce_max_ind
8904 @item __sec_reduce_min_ind
8905 @item __sec_reduce_mul
8906 @item __sec_reduce_mutating
8907 @end itemize
8908
8909 Further details and examples about these built-in functions are described
8910 in the Cilk Plus language manual which can be found at
8911 @uref{http://www.cilkplus.org}.
8912
8913 @node Other Builtins
8914 @section Other Built-in Functions Provided by GCC
8915 @cindex built-in functions
8916 @findex __builtin_fpclassify
8917 @findex __builtin_isfinite
8918 @findex __builtin_isnormal
8919 @findex __builtin_isgreater
8920 @findex __builtin_isgreaterequal
8921 @findex __builtin_isinf_sign
8922 @findex __builtin_isless
8923 @findex __builtin_islessequal
8924 @findex __builtin_islessgreater
8925 @findex __builtin_isunordered
8926 @findex __builtin_powi
8927 @findex __builtin_powif
8928 @findex __builtin_powil
8929 @findex _Exit
8930 @findex _exit
8931 @findex abort
8932 @findex abs
8933 @findex acos
8934 @findex acosf
8935 @findex acosh
8936 @findex acoshf
8937 @findex acoshl
8938 @findex acosl
8939 @findex alloca
8940 @findex asin
8941 @findex asinf
8942 @findex asinh
8943 @findex asinhf
8944 @findex asinhl
8945 @findex asinl
8946 @findex atan
8947 @findex atan2
8948 @findex atan2f
8949 @findex atan2l
8950 @findex atanf
8951 @findex atanh
8952 @findex atanhf
8953 @findex atanhl
8954 @findex atanl
8955 @findex bcmp
8956 @findex bzero
8957 @findex cabs
8958 @findex cabsf
8959 @findex cabsl
8960 @findex cacos
8961 @findex cacosf
8962 @findex cacosh
8963 @findex cacoshf
8964 @findex cacoshl
8965 @findex cacosl
8966 @findex calloc
8967 @findex carg
8968 @findex cargf
8969 @findex cargl
8970 @findex casin
8971 @findex casinf
8972 @findex casinh
8973 @findex casinhf
8974 @findex casinhl
8975 @findex casinl
8976 @findex catan
8977 @findex catanf
8978 @findex catanh
8979 @findex catanhf
8980 @findex catanhl
8981 @findex catanl
8982 @findex cbrt
8983 @findex cbrtf
8984 @findex cbrtl
8985 @findex ccos
8986 @findex ccosf
8987 @findex ccosh
8988 @findex ccoshf
8989 @findex ccoshl
8990 @findex ccosl
8991 @findex ceil
8992 @findex ceilf
8993 @findex ceill
8994 @findex cexp
8995 @findex cexpf
8996 @findex cexpl
8997 @findex cimag
8998 @findex cimagf
8999 @findex cimagl
9000 @findex clog
9001 @findex clogf
9002 @findex clogl
9003 @findex conj
9004 @findex conjf
9005 @findex conjl
9006 @findex copysign
9007 @findex copysignf
9008 @findex copysignl
9009 @findex cos
9010 @findex cosf
9011 @findex cosh
9012 @findex coshf
9013 @findex coshl
9014 @findex cosl
9015 @findex cpow
9016 @findex cpowf
9017 @findex cpowl
9018 @findex cproj
9019 @findex cprojf
9020 @findex cprojl
9021 @findex creal
9022 @findex crealf
9023 @findex creall
9024 @findex csin
9025 @findex csinf
9026 @findex csinh
9027 @findex csinhf
9028 @findex csinhl
9029 @findex csinl
9030 @findex csqrt
9031 @findex csqrtf
9032 @findex csqrtl
9033 @findex ctan
9034 @findex ctanf
9035 @findex ctanh
9036 @findex ctanhf
9037 @findex ctanhl
9038 @findex ctanl
9039 @findex dcgettext
9040 @findex dgettext
9041 @findex drem
9042 @findex dremf
9043 @findex dreml
9044 @findex erf
9045 @findex erfc
9046 @findex erfcf
9047 @findex erfcl
9048 @findex erff
9049 @findex erfl
9050 @findex exit
9051 @findex exp
9052 @findex exp10
9053 @findex exp10f
9054 @findex exp10l
9055 @findex exp2
9056 @findex exp2f
9057 @findex exp2l
9058 @findex expf
9059 @findex expl
9060 @findex expm1
9061 @findex expm1f
9062 @findex expm1l
9063 @findex fabs
9064 @findex fabsf
9065 @findex fabsl
9066 @findex fdim
9067 @findex fdimf
9068 @findex fdiml
9069 @findex ffs
9070 @findex floor
9071 @findex floorf
9072 @findex floorl
9073 @findex fma
9074 @findex fmaf
9075 @findex fmal
9076 @findex fmax
9077 @findex fmaxf
9078 @findex fmaxl
9079 @findex fmin
9080 @findex fminf
9081 @findex fminl
9082 @findex fmod
9083 @findex fmodf
9084 @findex fmodl
9085 @findex fprintf
9086 @findex fprintf_unlocked
9087 @findex fputs
9088 @findex fputs_unlocked
9089 @findex frexp
9090 @findex frexpf
9091 @findex frexpl
9092 @findex fscanf
9093 @findex gamma
9094 @findex gammaf
9095 @findex gammal
9096 @findex gamma_r
9097 @findex gammaf_r
9098 @findex gammal_r
9099 @findex gettext
9100 @findex hypot
9101 @findex hypotf
9102 @findex hypotl
9103 @findex ilogb
9104 @findex ilogbf
9105 @findex ilogbl
9106 @findex imaxabs
9107 @findex index
9108 @findex isalnum
9109 @findex isalpha
9110 @findex isascii
9111 @findex isblank
9112 @findex iscntrl
9113 @findex isdigit
9114 @findex isgraph
9115 @findex islower
9116 @findex isprint
9117 @findex ispunct
9118 @findex isspace
9119 @findex isupper
9120 @findex iswalnum
9121 @findex iswalpha
9122 @findex iswblank
9123 @findex iswcntrl
9124 @findex iswdigit
9125 @findex iswgraph
9126 @findex iswlower
9127 @findex iswprint
9128 @findex iswpunct
9129 @findex iswspace
9130 @findex iswupper
9131 @findex iswxdigit
9132 @findex isxdigit
9133 @findex j0
9134 @findex j0f
9135 @findex j0l
9136 @findex j1
9137 @findex j1f
9138 @findex j1l
9139 @findex jn
9140 @findex jnf
9141 @findex jnl
9142 @findex labs
9143 @findex ldexp
9144 @findex ldexpf
9145 @findex ldexpl
9146 @findex lgamma
9147 @findex lgammaf
9148 @findex lgammal
9149 @findex lgamma_r
9150 @findex lgammaf_r
9151 @findex lgammal_r
9152 @findex llabs
9153 @findex llrint
9154 @findex llrintf
9155 @findex llrintl
9156 @findex llround
9157 @findex llroundf
9158 @findex llroundl
9159 @findex log
9160 @findex log10
9161 @findex log10f
9162 @findex log10l
9163 @findex log1p
9164 @findex log1pf
9165 @findex log1pl
9166 @findex log2
9167 @findex log2f
9168 @findex log2l
9169 @findex logb
9170 @findex logbf
9171 @findex logbl
9172 @findex logf
9173 @findex logl
9174 @findex lrint
9175 @findex lrintf
9176 @findex lrintl
9177 @findex lround
9178 @findex lroundf
9179 @findex lroundl
9180 @findex malloc
9181 @findex memchr
9182 @findex memcmp
9183 @findex memcpy
9184 @findex mempcpy
9185 @findex memset
9186 @findex modf
9187 @findex modff
9188 @findex modfl
9189 @findex nearbyint
9190 @findex nearbyintf
9191 @findex nearbyintl
9192 @findex nextafter
9193 @findex nextafterf
9194 @findex nextafterl
9195 @findex nexttoward
9196 @findex nexttowardf
9197 @findex nexttowardl
9198 @findex pow
9199 @findex pow10
9200 @findex pow10f
9201 @findex pow10l
9202 @findex powf
9203 @findex powl
9204 @findex printf
9205 @findex printf_unlocked
9206 @findex putchar
9207 @findex puts
9208 @findex remainder
9209 @findex remainderf
9210 @findex remainderl
9211 @findex remquo
9212 @findex remquof
9213 @findex remquol
9214 @findex rindex
9215 @findex rint
9216 @findex rintf
9217 @findex rintl
9218 @findex round
9219 @findex roundf
9220 @findex roundl
9221 @findex scalb
9222 @findex scalbf
9223 @findex scalbl
9224 @findex scalbln
9225 @findex scalblnf
9226 @findex scalblnf
9227 @findex scalbn
9228 @findex scalbnf
9229 @findex scanfnl
9230 @findex signbit
9231 @findex signbitf
9232 @findex signbitl
9233 @findex signbitd32
9234 @findex signbitd64
9235 @findex signbitd128
9236 @findex significand
9237 @findex significandf
9238 @findex significandl
9239 @findex sin
9240 @findex sincos
9241 @findex sincosf
9242 @findex sincosl
9243 @findex sinf
9244 @findex sinh
9245 @findex sinhf
9246 @findex sinhl
9247 @findex sinl
9248 @findex snprintf
9249 @findex sprintf
9250 @findex sqrt
9251 @findex sqrtf
9252 @findex sqrtl
9253 @findex sscanf
9254 @findex stpcpy
9255 @findex stpncpy
9256 @findex strcasecmp
9257 @findex strcat
9258 @findex strchr
9259 @findex strcmp
9260 @findex strcpy
9261 @findex strcspn
9262 @findex strdup
9263 @findex strfmon
9264 @findex strftime
9265 @findex strlen
9266 @findex strncasecmp
9267 @findex strncat
9268 @findex strncmp
9269 @findex strncpy
9270 @findex strndup
9271 @findex strpbrk
9272 @findex strrchr
9273 @findex strspn
9274 @findex strstr
9275 @findex tan
9276 @findex tanf
9277 @findex tanh
9278 @findex tanhf
9279 @findex tanhl
9280 @findex tanl
9281 @findex tgamma
9282 @findex tgammaf
9283 @findex tgammal
9284 @findex toascii
9285 @findex tolower
9286 @findex toupper
9287 @findex towlower
9288 @findex towupper
9289 @findex trunc
9290 @findex truncf
9291 @findex truncl
9292 @findex vfprintf
9293 @findex vfscanf
9294 @findex vprintf
9295 @findex vscanf
9296 @findex vsnprintf
9297 @findex vsprintf
9298 @findex vsscanf
9299 @findex y0
9300 @findex y0f
9301 @findex y0l
9302 @findex y1
9303 @findex y1f
9304 @findex y1l
9305 @findex yn
9306 @findex ynf
9307 @findex ynl
9308
9309 GCC provides a large number of built-in functions other than the ones
9310 mentioned above. Some of these are for internal use in the processing
9311 of exceptions or variable-length argument lists and are not
9312 documented here because they may change from time to time; we do not
9313 recommend general use of these functions.
9314
9315 The remaining functions are provided for optimization purposes.
9316
9317 @opindex fno-builtin
9318 GCC includes built-in versions of many of the functions in the standard
9319 C library. The versions prefixed with @code{__builtin_} are always
9320 treated as having the same meaning as the C library function even if you
9321 specify the @option{-fno-builtin} option. (@pxref{C Dialect Options})
9322 Many of these functions are only optimized in certain cases; if they are
9323 not optimized in a particular case, a call to the library function is
9324 emitted.
9325
9326 @opindex ansi
9327 @opindex std
9328 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
9329 @option{-std=c99} or @option{-std=c11}), the functions
9330 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
9331 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
9332 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
9333 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
9334 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
9335 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
9336 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
9337 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
9338 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
9339 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
9340 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
9341 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
9342 @code{signbitd64}, @code{signbitd128}, @code{significandf},
9343 @code{significandl}, @code{significand}, @code{sincosf},
9344 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
9345 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
9346 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
9347 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
9348 @code{yn}
9349 may be handled as built-in functions.
9350 All these functions have corresponding versions
9351 prefixed with @code{__builtin_}, which may be used even in strict C90
9352 mode.
9353
9354 The ISO C99 functions
9355 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
9356 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
9357 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
9358 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
9359 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
9360 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
9361 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
9362 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
9363 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
9364 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
9365 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
9366 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
9367 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
9368 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
9369 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
9370 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
9371 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
9372 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
9373 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
9374 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
9375 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
9376 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
9377 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
9378 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
9379 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
9380 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
9381 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
9382 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
9383 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
9384 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
9385 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
9386 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
9387 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
9388 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
9389 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
9390 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
9391 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
9392 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
9393 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
9394 are handled as built-in functions
9395 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9396
9397 There are also built-in versions of the ISO C99 functions
9398 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
9399 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
9400 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
9401 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
9402 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
9403 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
9404 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
9405 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
9406 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
9407 that are recognized in any mode since ISO C90 reserves these names for
9408 the purpose to which ISO C99 puts them. All these functions have
9409 corresponding versions prefixed with @code{__builtin_}.
9410
9411 The ISO C94 functions
9412 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
9413 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
9414 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
9415 @code{towupper}
9416 are handled as built-in functions
9417 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9418
9419 The ISO C90 functions
9420 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
9421 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
9422 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
9423 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
9424 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
9425 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
9426 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
9427 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
9428 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
9429 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
9430 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
9431 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
9432 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
9433 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
9434 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
9435 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
9436 are all recognized as built-in functions unless
9437 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
9438 is specified for an individual function). All of these functions have
9439 corresponding versions prefixed with @code{__builtin_}.
9440
9441 GCC provides built-in versions of the ISO C99 floating-point comparison
9442 macros that avoid raising exceptions for unordered operands. They have
9443 the same names as the standard macros ( @code{isgreater},
9444 @code{isgreaterequal}, @code{isless}, @code{islessequal},
9445 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
9446 prefixed. We intend for a library implementor to be able to simply
9447 @code{#define} each standard macro to its built-in equivalent.
9448 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
9449 @code{isinf_sign} and @code{isnormal} built-ins used with
9450 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
9451 built-in functions appear both with and without the @code{__builtin_} prefix.
9452
9453 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
9454
9455 You can use the built-in function @code{__builtin_types_compatible_p} to
9456 determine whether two types are the same.
9457
9458 This built-in function returns 1 if the unqualified versions of the
9459 types @var{type1} and @var{type2} (which are types, not expressions) are
9460 compatible, 0 otherwise. The result of this built-in function can be
9461 used in integer constant expressions.
9462
9463 This built-in function ignores top level qualifiers (e.g., @code{const},
9464 @code{volatile}). For example, @code{int} is equivalent to @code{const
9465 int}.
9466
9467 The type @code{int[]} and @code{int[5]} are compatible. On the other
9468 hand, @code{int} and @code{char *} are not compatible, even if the size
9469 of their types, on the particular architecture are the same. Also, the
9470 amount of pointer indirection is taken into account when determining
9471 similarity. Consequently, @code{short *} is not similar to
9472 @code{short **}. Furthermore, two types that are typedefed are
9473 considered compatible if their underlying types are compatible.
9474
9475 An @code{enum} type is not considered to be compatible with another
9476 @code{enum} type even if both are compatible with the same integer
9477 type; this is what the C standard specifies.
9478 For example, @code{enum @{foo, bar@}} is not similar to
9479 @code{enum @{hot, dog@}}.
9480
9481 You typically use this function in code whose execution varies
9482 depending on the arguments' types. For example:
9483
9484 @smallexample
9485 #define foo(x) \
9486 (@{ \
9487 typeof (x) tmp = (x); \
9488 if (__builtin_types_compatible_p (typeof (x), long double)) \
9489 tmp = foo_long_double (tmp); \
9490 else if (__builtin_types_compatible_p (typeof (x), double)) \
9491 tmp = foo_double (tmp); \
9492 else if (__builtin_types_compatible_p (typeof (x), float)) \
9493 tmp = foo_float (tmp); \
9494 else \
9495 abort (); \
9496 tmp; \
9497 @})
9498 @end smallexample
9499
9500 @emph{Note:} This construct is only available for C@.
9501
9502 @end deftypefn
9503
9504 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
9505
9506 You can use the built-in function @code{__builtin_choose_expr} to
9507 evaluate code depending on the value of a constant expression. This
9508 built-in function returns @var{exp1} if @var{const_exp}, which is an
9509 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
9510
9511 This built-in function is analogous to the @samp{? :} operator in C,
9512 except that the expression returned has its type unaltered by promotion
9513 rules. Also, the built-in function does not evaluate the expression
9514 that is not chosen. For example, if @var{const_exp} evaluates to true,
9515 @var{exp2} is not evaluated even if it has side-effects.
9516
9517 This built-in function can return an lvalue if the chosen argument is an
9518 lvalue.
9519
9520 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
9521 type. Similarly, if @var{exp2} is returned, its return type is the same
9522 as @var{exp2}.
9523
9524 Example:
9525
9526 @smallexample
9527 #define foo(x) \
9528 __builtin_choose_expr ( \
9529 __builtin_types_compatible_p (typeof (x), double), \
9530 foo_double (x), \
9531 __builtin_choose_expr ( \
9532 __builtin_types_compatible_p (typeof (x), float), \
9533 foo_float (x), \
9534 /* @r{The void expression results in a compile-time error} \
9535 @r{when assigning the result to something.} */ \
9536 (void)0))
9537 @end smallexample
9538
9539 @emph{Note:} This construct is only available for C@. Furthermore, the
9540 unused expression (@var{exp1} or @var{exp2} depending on the value of
9541 @var{const_exp}) may still generate syntax errors. This may change in
9542 future revisions.
9543
9544 @end deftypefn
9545
9546 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
9547
9548 The built-in function @code{__builtin_complex} is provided for use in
9549 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
9550 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
9551 real binary floating-point type, and the result has the corresponding
9552 complex type with real and imaginary parts @var{real} and @var{imag}.
9553 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
9554 infinities, NaNs and negative zeros are involved.
9555
9556 @end deftypefn
9557
9558 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
9559 You can use the built-in function @code{__builtin_constant_p} to
9560 determine if a value is known to be constant at compile time and hence
9561 that GCC can perform constant-folding on expressions involving that
9562 value. The argument of the function is the value to test. The function
9563 returns the integer 1 if the argument is known to be a compile-time
9564 constant and 0 if it is not known to be a compile-time constant. A
9565 return of 0 does not indicate that the value is @emph{not} a constant,
9566 but merely that GCC cannot prove it is a constant with the specified
9567 value of the @option{-O} option.
9568
9569 You typically use this function in an embedded application where
9570 memory is a critical resource. If you have some complex calculation,
9571 you may want it to be folded if it involves constants, but need to call
9572 a function if it does not. For example:
9573
9574 @smallexample
9575 #define Scale_Value(X) \
9576 (__builtin_constant_p (X) \
9577 ? ((X) * SCALE + OFFSET) : Scale (X))
9578 @end smallexample
9579
9580 You may use this built-in function in either a macro or an inline
9581 function. However, if you use it in an inlined function and pass an
9582 argument of the function as the argument to the built-in, GCC
9583 never returns 1 when you call the inline function with a string constant
9584 or compound literal (@pxref{Compound Literals}) and does not return 1
9585 when you pass a constant numeric value to the inline function unless you
9586 specify the @option{-O} option.
9587
9588 You may also use @code{__builtin_constant_p} in initializers for static
9589 data. For instance, you can write
9590
9591 @smallexample
9592 static const int table[] = @{
9593 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
9594 /* @r{@dots{}} */
9595 @};
9596 @end smallexample
9597
9598 @noindent
9599 This is an acceptable initializer even if @var{EXPRESSION} is not a
9600 constant expression, including the case where
9601 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
9602 folded to a constant but @var{EXPRESSION} contains operands that are
9603 not otherwise permitted in a static initializer (for example,
9604 @code{0 && foo ()}). GCC must be more conservative about evaluating the
9605 built-in in this case, because it has no opportunity to perform
9606 optimization.
9607
9608 Previous versions of GCC did not accept this built-in in data
9609 initializers. The earliest version where it is completely safe is
9610 3.0.1.
9611 @end deftypefn
9612
9613 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
9614 @opindex fprofile-arcs
9615 You may use @code{__builtin_expect} to provide the compiler with
9616 branch prediction information. In general, you should prefer to
9617 use actual profile feedback for this (@option{-fprofile-arcs}), as
9618 programmers are notoriously bad at predicting how their programs
9619 actually perform. However, there are applications in which this
9620 data is hard to collect.
9621
9622 The return value is the value of @var{exp}, which should be an integral
9623 expression. The semantics of the built-in are that it is expected that
9624 @var{exp} == @var{c}. For example:
9625
9626 @smallexample
9627 if (__builtin_expect (x, 0))
9628 foo ();
9629 @end smallexample
9630
9631 @noindent
9632 indicates that we do not expect to call @code{foo}, since
9633 we expect @code{x} to be zero. Since you are limited to integral
9634 expressions for @var{exp}, you should use constructions such as
9635
9636 @smallexample
9637 if (__builtin_expect (ptr != NULL, 1))
9638 foo (*ptr);
9639 @end smallexample
9640
9641 @noindent
9642 when testing pointer or floating-point values.
9643 @end deftypefn
9644
9645 @deftypefn {Built-in Function} void __builtin_trap (void)
9646 This function causes the program to exit abnormally. GCC implements
9647 this function by using a target-dependent mechanism (such as
9648 intentionally executing an illegal instruction) or by calling
9649 @code{abort}. The mechanism used may vary from release to release so
9650 you should not rely on any particular implementation.
9651 @end deftypefn
9652
9653 @deftypefn {Built-in Function} void __builtin_unreachable (void)
9654 If control flow reaches the point of the @code{__builtin_unreachable},
9655 the program is undefined. It is useful in situations where the
9656 compiler cannot deduce the unreachability of the code.
9657
9658 One such case is immediately following an @code{asm} statement that
9659 either never terminates, or one that transfers control elsewhere
9660 and never returns. In this example, without the
9661 @code{__builtin_unreachable}, GCC issues a warning that control
9662 reaches the end of a non-void function. It also generates code
9663 to return after the @code{asm}.
9664
9665 @smallexample
9666 int f (int c, int v)
9667 @{
9668 if (c)
9669 @{
9670 return v;
9671 @}
9672 else
9673 @{
9674 asm("jmp error_handler");
9675 __builtin_unreachable ();
9676 @}
9677 @}
9678 @end smallexample
9679
9680 @noindent
9681 Because the @code{asm} statement unconditionally transfers control out
9682 of the function, control never reaches the end of the function
9683 body. The @code{__builtin_unreachable} is in fact unreachable and
9684 communicates this fact to the compiler.
9685
9686 Another use for @code{__builtin_unreachable} is following a call a
9687 function that never returns but that is not declared
9688 @code{__attribute__((noreturn))}, as in this example:
9689
9690 @smallexample
9691 void function_that_never_returns (void);
9692
9693 int g (int c)
9694 @{
9695 if (c)
9696 @{
9697 return 1;
9698 @}
9699 else
9700 @{
9701 function_that_never_returns ();
9702 __builtin_unreachable ();
9703 @}
9704 @}
9705 @end smallexample
9706
9707 @end deftypefn
9708
9709 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
9710 This function returns its first argument, and allows the compiler
9711 to assume that the returned pointer is at least @var{align} bytes
9712 aligned. This built-in can have either two or three arguments,
9713 if it has three, the third argument should have integer type, and
9714 if it is nonzero means misalignment offset. For example:
9715
9716 @smallexample
9717 void *x = __builtin_assume_aligned (arg, 16);
9718 @end smallexample
9719
9720 @noindent
9721 means that the compiler can assume @code{x}, set to @code{arg}, is at least
9722 16-byte aligned, while:
9723
9724 @smallexample
9725 void *x = __builtin_assume_aligned (arg, 32, 8);
9726 @end smallexample
9727
9728 @noindent
9729 means that the compiler can assume for @code{x}, set to @code{arg}, that
9730 @code{(char *) x - 8} is 32-byte aligned.
9731 @end deftypefn
9732
9733 @deftypefn {Built-in Function} int __builtin_LINE ()
9734 This function is the equivalent to the preprocessor @code{__LINE__}
9735 macro and returns the line number of the invocation of the built-in.
9736 In a C++ default argument for a function @var{F}, it gets the line number of
9737 the call to @var{F}.
9738 @end deftypefn
9739
9740 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
9741 This function is the equivalent to the preprocessor @code{__FUNCTION__}
9742 macro and returns the function name the invocation of the built-in is in.
9743 @end deftypefn
9744
9745 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
9746 This function is the equivalent to the preprocessor @code{__FILE__}
9747 macro and returns the file name the invocation of the built-in is in.
9748 In a C++ default argument for a function @var{F}, it gets the file name of
9749 the call to @var{F}.
9750 @end deftypefn
9751
9752 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
9753 This function is used to flush the processor's instruction cache for
9754 the region of memory between @var{begin} inclusive and @var{end}
9755 exclusive. Some targets require that the instruction cache be
9756 flushed, after modifying memory containing code, in order to obtain
9757 deterministic behavior.
9758
9759 If the target does not require instruction cache flushes,
9760 @code{__builtin___clear_cache} has no effect. Otherwise either
9761 instructions are emitted in-line to clear the instruction cache or a
9762 call to the @code{__clear_cache} function in libgcc is made.
9763 @end deftypefn
9764
9765 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
9766 This function is used to minimize cache-miss latency by moving data into
9767 a cache before it is accessed.
9768 You can insert calls to @code{__builtin_prefetch} into code for which
9769 you know addresses of data in memory that is likely to be accessed soon.
9770 If the target supports them, data prefetch instructions are generated.
9771 If the prefetch is done early enough before the access then the data will
9772 be in the cache by the time it is accessed.
9773
9774 The value of @var{addr} is the address of the memory to prefetch.
9775 There are two optional arguments, @var{rw} and @var{locality}.
9776 The value of @var{rw} is a compile-time constant one or zero; one
9777 means that the prefetch is preparing for a write to the memory address
9778 and zero, the default, means that the prefetch is preparing for a read.
9779 The value @var{locality} must be a compile-time constant integer between
9780 zero and three. A value of zero means that the data has no temporal
9781 locality, so it need not be left in the cache after the access. A value
9782 of three means that the data has a high degree of temporal locality and
9783 should be left in all levels of cache possible. Values of one and two
9784 mean, respectively, a low or moderate degree of temporal locality. The
9785 default is three.
9786
9787 @smallexample
9788 for (i = 0; i < n; i++)
9789 @{
9790 a[i] = a[i] + b[i];
9791 __builtin_prefetch (&a[i+j], 1, 1);
9792 __builtin_prefetch (&b[i+j], 0, 1);
9793 /* @r{@dots{}} */
9794 @}
9795 @end smallexample
9796
9797 Data prefetch does not generate faults if @var{addr} is invalid, but
9798 the address expression itself must be valid. For example, a prefetch
9799 of @code{p->next} does not fault if @code{p->next} is not a valid
9800 address, but evaluation faults if @code{p} is not a valid address.
9801
9802 If the target does not support data prefetch, the address expression
9803 is evaluated if it includes side effects but no other code is generated
9804 and GCC does not issue a warning.
9805 @end deftypefn
9806
9807 @deftypefn {Built-in Function} double __builtin_huge_val (void)
9808 Returns a positive infinity, if supported by the floating-point format,
9809 else @code{DBL_MAX}. This function is suitable for implementing the
9810 ISO C macro @code{HUGE_VAL}.
9811 @end deftypefn
9812
9813 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
9814 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
9815 @end deftypefn
9816
9817 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
9818 Similar to @code{__builtin_huge_val}, except the return
9819 type is @code{long double}.
9820 @end deftypefn
9821
9822 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
9823 This built-in implements the C99 fpclassify functionality. The first
9824 five int arguments should be the target library's notion of the
9825 possible FP classes and are used for return values. They must be
9826 constant values and they must appear in this order: @code{FP_NAN},
9827 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
9828 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
9829 to classify. GCC treats the last argument as type-generic, which
9830 means it does not do default promotion from float to double.
9831 @end deftypefn
9832
9833 @deftypefn {Built-in Function} double __builtin_inf (void)
9834 Similar to @code{__builtin_huge_val}, except a warning is generated
9835 if the target floating-point format does not support infinities.
9836 @end deftypefn
9837
9838 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
9839 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
9840 @end deftypefn
9841
9842 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
9843 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
9844 @end deftypefn
9845
9846 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
9847 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
9848 @end deftypefn
9849
9850 @deftypefn {Built-in Function} float __builtin_inff (void)
9851 Similar to @code{__builtin_inf}, except the return type is @code{float}.
9852 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
9853 @end deftypefn
9854
9855 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
9856 Similar to @code{__builtin_inf}, except the return
9857 type is @code{long double}.
9858 @end deftypefn
9859
9860 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
9861 Similar to @code{isinf}, except the return value is -1 for
9862 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
9863 Note while the parameter list is an
9864 ellipsis, this function only accepts exactly one floating-point
9865 argument. GCC treats this parameter as type-generic, which means it
9866 does not do default promotion from float to double.
9867 @end deftypefn
9868
9869 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
9870 This is an implementation of the ISO C99 function @code{nan}.
9871
9872 Since ISO C99 defines this function in terms of @code{strtod}, which we
9873 do not implement, a description of the parsing is in order. The string
9874 is parsed as by @code{strtol}; that is, the base is recognized by
9875 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
9876 in the significand such that the least significant bit of the number
9877 is at the least significant bit of the significand. The number is
9878 truncated to fit the significand field provided. The significand is
9879 forced to be a quiet NaN@.
9880
9881 This function, if given a string literal all of which would have been
9882 consumed by @code{strtol}, is evaluated early enough that it is considered a
9883 compile-time constant.
9884 @end deftypefn
9885
9886 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
9887 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
9888 @end deftypefn
9889
9890 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
9891 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
9892 @end deftypefn
9893
9894 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
9895 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
9896 @end deftypefn
9897
9898 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
9899 Similar to @code{__builtin_nan}, except the return type is @code{float}.
9900 @end deftypefn
9901
9902 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
9903 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
9904 @end deftypefn
9905
9906 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
9907 Similar to @code{__builtin_nan}, except the significand is forced
9908 to be a signaling NaN@. The @code{nans} function is proposed by
9909 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
9910 @end deftypefn
9911
9912 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
9913 Similar to @code{__builtin_nans}, except the return type is @code{float}.
9914 @end deftypefn
9915
9916 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
9917 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
9918 @end deftypefn
9919
9920 @deftypefn {Built-in Function} int __builtin_ffs (int x)
9921 Returns one plus the index of the least significant 1-bit of @var{x}, or
9922 if @var{x} is zero, returns zero.
9923 @end deftypefn
9924
9925 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
9926 Returns the number of leading 0-bits in @var{x}, starting at the most
9927 significant bit position. If @var{x} is 0, the result is undefined.
9928 @end deftypefn
9929
9930 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
9931 Returns the number of trailing 0-bits in @var{x}, starting at the least
9932 significant bit position. If @var{x} is 0, the result is undefined.
9933 @end deftypefn
9934
9935 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
9936 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
9937 number of bits following the most significant bit that are identical
9938 to it. There are no special cases for 0 or other values.
9939 @end deftypefn
9940
9941 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
9942 Returns the number of 1-bits in @var{x}.
9943 @end deftypefn
9944
9945 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
9946 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
9947 modulo 2.
9948 @end deftypefn
9949
9950 @deftypefn {Built-in Function} int __builtin_ffsl (long)
9951 Similar to @code{__builtin_ffs}, except the argument type is
9952 @code{long}.
9953 @end deftypefn
9954
9955 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
9956 Similar to @code{__builtin_clz}, except the argument type is
9957 @code{unsigned long}.
9958 @end deftypefn
9959
9960 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
9961 Similar to @code{__builtin_ctz}, except the argument type is
9962 @code{unsigned long}.
9963 @end deftypefn
9964
9965 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
9966 Similar to @code{__builtin_clrsb}, except the argument type is
9967 @code{long}.
9968 @end deftypefn
9969
9970 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
9971 Similar to @code{__builtin_popcount}, except the argument type is
9972 @code{unsigned long}.
9973 @end deftypefn
9974
9975 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
9976 Similar to @code{__builtin_parity}, except the argument type is
9977 @code{unsigned long}.
9978 @end deftypefn
9979
9980 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
9981 Similar to @code{__builtin_ffs}, except the argument type is
9982 @code{long long}.
9983 @end deftypefn
9984
9985 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
9986 Similar to @code{__builtin_clz}, except the argument type is
9987 @code{unsigned long long}.
9988 @end deftypefn
9989
9990 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
9991 Similar to @code{__builtin_ctz}, except the argument type is
9992 @code{unsigned long long}.
9993 @end deftypefn
9994
9995 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
9996 Similar to @code{__builtin_clrsb}, except the argument type is
9997 @code{long long}.
9998 @end deftypefn
9999
10000 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
10001 Similar to @code{__builtin_popcount}, except the argument type is
10002 @code{unsigned long long}.
10003 @end deftypefn
10004
10005 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
10006 Similar to @code{__builtin_parity}, except the argument type is
10007 @code{unsigned long long}.
10008 @end deftypefn
10009
10010 @deftypefn {Built-in Function} double __builtin_powi (double, int)
10011 Returns the first argument raised to the power of the second. Unlike the
10012 @code{pow} function no guarantees about precision and rounding are made.
10013 @end deftypefn
10014
10015 @deftypefn {Built-in Function} float __builtin_powif (float, int)
10016 Similar to @code{__builtin_powi}, except the argument and return types
10017 are @code{float}.
10018 @end deftypefn
10019
10020 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
10021 Similar to @code{__builtin_powi}, except the argument and return types
10022 are @code{long double}.
10023 @end deftypefn
10024
10025 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
10026 Returns @var{x} with the order of the bytes reversed; for example,
10027 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
10028 exactly 8 bits.
10029 @end deftypefn
10030
10031 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
10032 Similar to @code{__builtin_bswap16}, except the argument and return types
10033 are 32 bit.
10034 @end deftypefn
10035
10036 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
10037 Similar to @code{__builtin_bswap32}, except the argument and return types
10038 are 64 bit.
10039 @end deftypefn
10040
10041 @node Target Builtins
10042 @section Built-in Functions Specific to Particular Target Machines
10043
10044 On some target machines, GCC supports many built-in functions specific
10045 to those machines. Generally these generate calls to specific machine
10046 instructions, but allow the compiler to schedule those calls.
10047
10048 @menu
10049 * AArch64 Built-in Functions::
10050 * Alpha Built-in Functions::
10051 * Altera Nios II Built-in Functions::
10052 * ARC Built-in Functions::
10053 * ARC SIMD Built-in Functions::
10054 * ARM iWMMXt Built-in Functions::
10055 * ARM C Language Extensions (ACLE)::
10056 * ARM Floating Point Status and Control Intrinsics::
10057 * AVR Built-in Functions::
10058 * Blackfin Built-in Functions::
10059 * FR-V Built-in Functions::
10060 * X86 Built-in Functions::
10061 * X86 transactional memory intrinsics::
10062 * MIPS DSP Built-in Functions::
10063 * MIPS Paired-Single Support::
10064 * MIPS Loongson Built-in Functions::
10065 * Other MIPS Built-in Functions::
10066 * MSP430 Built-in Functions::
10067 * NDS32 Built-in Functions::
10068 * picoChip Built-in Functions::
10069 * PowerPC Built-in Functions::
10070 * PowerPC AltiVec/VSX Built-in Functions::
10071 * PowerPC Hardware Transactional Memory Built-in Functions::
10072 * RX Built-in Functions::
10073 * S/390 System z Built-in Functions::
10074 * SH Built-in Functions::
10075 * SPARC VIS Built-in Functions::
10076 * SPU Built-in Functions::
10077 * TI C6X Built-in Functions::
10078 * TILE-Gx Built-in Functions::
10079 * TILEPro Built-in Functions::
10080 @end menu
10081
10082 @node AArch64 Built-in Functions
10083 @subsection AArch64 Built-in Functions
10084
10085 These built-in functions are available for the AArch64 family of
10086 processors.
10087 @smallexample
10088 unsigned int __builtin_aarch64_get_fpcr ()
10089 void __builtin_aarch64_set_fpcr (unsigned int)
10090 unsigned int __builtin_aarch64_get_fpsr ()
10091 void __builtin_aarch64_set_fpsr (unsigned int)
10092 @end smallexample
10093
10094 @node Alpha Built-in Functions
10095 @subsection Alpha Built-in Functions
10096
10097 These built-in functions are available for the Alpha family of
10098 processors, depending on the command-line switches used.
10099
10100 The following built-in functions are always available. They
10101 all generate the machine instruction that is part of the name.
10102
10103 @smallexample
10104 long __builtin_alpha_implver (void)
10105 long __builtin_alpha_rpcc (void)
10106 long __builtin_alpha_amask (long)
10107 long __builtin_alpha_cmpbge (long, long)
10108 long __builtin_alpha_extbl (long, long)
10109 long __builtin_alpha_extwl (long, long)
10110 long __builtin_alpha_extll (long, long)
10111 long __builtin_alpha_extql (long, long)
10112 long __builtin_alpha_extwh (long, long)
10113 long __builtin_alpha_extlh (long, long)
10114 long __builtin_alpha_extqh (long, long)
10115 long __builtin_alpha_insbl (long, long)
10116 long __builtin_alpha_inswl (long, long)
10117 long __builtin_alpha_insll (long, long)
10118 long __builtin_alpha_insql (long, long)
10119 long __builtin_alpha_inswh (long, long)
10120 long __builtin_alpha_inslh (long, long)
10121 long __builtin_alpha_insqh (long, long)
10122 long __builtin_alpha_mskbl (long, long)
10123 long __builtin_alpha_mskwl (long, long)
10124 long __builtin_alpha_mskll (long, long)
10125 long __builtin_alpha_mskql (long, long)
10126 long __builtin_alpha_mskwh (long, long)
10127 long __builtin_alpha_msklh (long, long)
10128 long __builtin_alpha_mskqh (long, long)
10129 long __builtin_alpha_umulh (long, long)
10130 long __builtin_alpha_zap (long, long)
10131 long __builtin_alpha_zapnot (long, long)
10132 @end smallexample
10133
10134 The following built-in functions are always with @option{-mmax}
10135 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
10136 later. They all generate the machine instruction that is part
10137 of the name.
10138
10139 @smallexample
10140 long __builtin_alpha_pklb (long)
10141 long __builtin_alpha_pkwb (long)
10142 long __builtin_alpha_unpkbl (long)
10143 long __builtin_alpha_unpkbw (long)
10144 long __builtin_alpha_minub8 (long, long)
10145 long __builtin_alpha_minsb8 (long, long)
10146 long __builtin_alpha_minuw4 (long, long)
10147 long __builtin_alpha_minsw4 (long, long)
10148 long __builtin_alpha_maxub8 (long, long)
10149 long __builtin_alpha_maxsb8 (long, long)
10150 long __builtin_alpha_maxuw4 (long, long)
10151 long __builtin_alpha_maxsw4 (long, long)
10152 long __builtin_alpha_perr (long, long)
10153 @end smallexample
10154
10155 The following built-in functions are always with @option{-mcix}
10156 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
10157 later. They all generate the machine instruction that is part
10158 of the name.
10159
10160 @smallexample
10161 long __builtin_alpha_cttz (long)
10162 long __builtin_alpha_ctlz (long)
10163 long __builtin_alpha_ctpop (long)
10164 @end smallexample
10165
10166 The following built-in functions are available on systems that use the OSF/1
10167 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
10168 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
10169 @code{rdval} and @code{wrval}.
10170
10171 @smallexample
10172 void *__builtin_thread_pointer (void)
10173 void __builtin_set_thread_pointer (void *)
10174 @end smallexample
10175
10176 @node Altera Nios II Built-in Functions
10177 @subsection Altera Nios II Built-in Functions
10178
10179 These built-in functions are available for the Altera Nios II
10180 family of processors.
10181
10182 The following built-in functions are always available. They
10183 all generate the machine instruction that is part of the name.
10184
10185 @example
10186 int __builtin_ldbio (volatile const void *)
10187 int __builtin_ldbuio (volatile const void *)
10188 int __builtin_ldhio (volatile const void *)
10189 int __builtin_ldhuio (volatile const void *)
10190 int __builtin_ldwio (volatile const void *)
10191 void __builtin_stbio (volatile void *, int)
10192 void __builtin_sthio (volatile void *, int)
10193 void __builtin_stwio (volatile void *, int)
10194 void __builtin_sync (void)
10195 int __builtin_rdctl (int)
10196 void __builtin_wrctl (int, int)
10197 @end example
10198
10199 The following built-in functions are always available. They
10200 all generate a Nios II Custom Instruction. The name of the
10201 function represents the types that the function takes and
10202 returns. The letter before the @code{n} is the return type
10203 or void if absent. The @code{n} represents the first parameter
10204 to all the custom instructions, the custom instruction number.
10205 The two letters after the @code{n} represent the up to two
10206 parameters to the function.
10207
10208 The letters represent the following data types:
10209 @table @code
10210 @item <no letter>
10211 @code{void} for return type and no parameter for parameter types.
10212
10213 @item i
10214 @code{int} for return type and parameter type
10215
10216 @item f
10217 @code{float} for return type and parameter type
10218
10219 @item p
10220 @code{void *} for return type and parameter type
10221
10222 @end table
10223
10224 And the function names are:
10225 @example
10226 void __builtin_custom_n (void)
10227 void __builtin_custom_ni (int)
10228 void __builtin_custom_nf (float)
10229 void __builtin_custom_np (void *)
10230 void __builtin_custom_nii (int, int)
10231 void __builtin_custom_nif (int, float)
10232 void __builtin_custom_nip (int, void *)
10233 void __builtin_custom_nfi (float, int)
10234 void __builtin_custom_nff (float, float)
10235 void __builtin_custom_nfp (float, void *)
10236 void __builtin_custom_npi (void *, int)
10237 void __builtin_custom_npf (void *, float)
10238 void __builtin_custom_npp (void *, void *)
10239 int __builtin_custom_in (void)
10240 int __builtin_custom_ini (int)
10241 int __builtin_custom_inf (float)
10242 int __builtin_custom_inp (void *)
10243 int __builtin_custom_inii (int, int)
10244 int __builtin_custom_inif (int, float)
10245 int __builtin_custom_inip (int, void *)
10246 int __builtin_custom_infi (float, int)
10247 int __builtin_custom_inff (float, float)
10248 int __builtin_custom_infp (float, void *)
10249 int __builtin_custom_inpi (void *, int)
10250 int __builtin_custom_inpf (void *, float)
10251 int __builtin_custom_inpp (void *, void *)
10252 float __builtin_custom_fn (void)
10253 float __builtin_custom_fni (int)
10254 float __builtin_custom_fnf (float)
10255 float __builtin_custom_fnp (void *)
10256 float __builtin_custom_fnii (int, int)
10257 float __builtin_custom_fnif (int, float)
10258 float __builtin_custom_fnip (int, void *)
10259 float __builtin_custom_fnfi (float, int)
10260 float __builtin_custom_fnff (float, float)
10261 float __builtin_custom_fnfp (float, void *)
10262 float __builtin_custom_fnpi (void *, int)
10263 float __builtin_custom_fnpf (void *, float)
10264 float __builtin_custom_fnpp (void *, void *)
10265 void * __builtin_custom_pn (void)
10266 void * __builtin_custom_pni (int)
10267 void * __builtin_custom_pnf (float)
10268 void * __builtin_custom_pnp (void *)
10269 void * __builtin_custom_pnii (int, int)
10270 void * __builtin_custom_pnif (int, float)
10271 void * __builtin_custom_pnip (int, void *)
10272 void * __builtin_custom_pnfi (float, int)
10273 void * __builtin_custom_pnff (float, float)
10274 void * __builtin_custom_pnfp (float, void *)
10275 void * __builtin_custom_pnpi (void *, int)
10276 void * __builtin_custom_pnpf (void *, float)
10277 void * __builtin_custom_pnpp (void *, void *)
10278 @end example
10279
10280 @node ARC Built-in Functions
10281 @subsection ARC Built-in Functions
10282
10283 The following built-in functions are provided for ARC targets. The
10284 built-ins generate the corresponding assembly instructions. In the
10285 examples given below, the generated code often requires an operand or
10286 result to be in a register. Where necessary further code will be
10287 generated to ensure this is true, but for brevity this is not
10288 described in each case.
10289
10290 @emph{Note:} Using a built-in to generate an instruction not supported
10291 by a target may cause problems. At present the compiler is not
10292 guaranteed to detect such misuse, and as a result an internal compiler
10293 error may be generated.
10294
10295 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
10296 Return 1 if @var{val} is known to have the byte alignment given
10297 by @var{alignval}, otherwise return 0.
10298 Note that this is different from
10299 @smallexample
10300 __alignof__(*(char *)@var{val}) >= alignval
10301 @end smallexample
10302 because __alignof__ sees only the type of the dereference, whereas
10303 __builtin_arc_align uses alignment information from the pointer
10304 as well as from the pointed-to type.
10305 The information available will depend on optimization level.
10306 @end deftypefn
10307
10308 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
10309 Generates
10310 @example
10311 brk
10312 @end example
10313 @end deftypefn
10314
10315 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
10316 The operand is the number of a register to be read. Generates:
10317 @example
10318 mov @var{dest}, r@var{regno}
10319 @end example
10320 where the value in @var{dest} will be the result returned from the
10321 built-in.
10322 @end deftypefn
10323
10324 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
10325 The first operand is the number of a register to be written, the
10326 second operand is a compile time constant to write into that
10327 register. Generates:
10328 @example
10329 mov r@var{regno}, @var{val}
10330 @end example
10331 @end deftypefn
10332
10333 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
10334 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
10335 Generates:
10336 @example
10337 divaw @var{dest}, @var{a}, @var{b}
10338 @end example
10339 where the value in @var{dest} will be the result returned from the
10340 built-in.
10341 @end deftypefn
10342
10343 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
10344 Generates
10345 @example
10346 flag @var{a}
10347 @end example
10348 @end deftypefn
10349
10350 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
10351 The operand, @var{auxv}, is the address of an auxiliary register and
10352 must be a compile time constant. Generates:
10353 @example
10354 lr @var{dest}, [@var{auxr}]
10355 @end example
10356 Where the value in @var{dest} will be the result returned from the
10357 built-in.
10358 @end deftypefn
10359
10360 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
10361 Only available with @option{-mmul64}. Generates:
10362 @example
10363 mul64 @var{a}, @var{b}
10364 @end example
10365 @end deftypefn
10366
10367 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
10368 Only available with @option{-mmul64}. Generates:
10369 @example
10370 mulu64 @var{a}, @var{b}
10371 @end example
10372 @end deftypefn
10373
10374 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
10375 Generates:
10376 @example
10377 nop
10378 @end example
10379 @end deftypefn
10380
10381 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
10382 Only valid if the @samp{norm} instruction is available through the
10383 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10384 Generates:
10385 @example
10386 norm @var{dest}, @var{src}
10387 @end example
10388 Where the value in @var{dest} will be the result returned from the
10389 built-in.
10390 @end deftypefn
10391
10392 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
10393 Only valid if the @samp{normw} instruction is available through the
10394 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10395 Generates:
10396 @example
10397 normw @var{dest}, @var{src}
10398 @end example
10399 Where the value in @var{dest} will be the result returned from the
10400 built-in.
10401 @end deftypefn
10402
10403 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
10404 Generates:
10405 @example
10406 rtie
10407 @end example
10408 @end deftypefn
10409
10410 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
10411 Generates:
10412 @example
10413 sleep @var{a}
10414 @end example
10415 @end deftypefn
10416
10417 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
10418 The first argument, @var{auxv}, is the address of an auxiliary
10419 register, the second argument, @var{val}, is a compile time constant
10420 to be written to the register. Generates:
10421 @example
10422 sr @var{auxr}, [@var{val}]
10423 @end example
10424 @end deftypefn
10425
10426 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
10427 Only valid with @option{-mswap}. Generates:
10428 @example
10429 swap @var{dest}, @var{src}
10430 @end example
10431 Where the value in @var{dest} will be the result returned from the
10432 built-in.
10433 @end deftypefn
10434
10435 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
10436 Generates:
10437 @example
10438 swi
10439 @end example
10440 @end deftypefn
10441
10442 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
10443 Only available with @option{-mcpu=ARC700}. Generates:
10444 @example
10445 sync
10446 @end example
10447 @end deftypefn
10448
10449 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
10450 Only available with @option{-mcpu=ARC700}. Generates:
10451 @example
10452 trap_s @var{c}
10453 @end example
10454 @end deftypefn
10455
10456 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
10457 Only available with @option{-mcpu=ARC700}. Generates:
10458 @example
10459 unimp_s
10460 @end example
10461 @end deftypefn
10462
10463 The instructions generated by the following builtins are not
10464 considered as candidates for scheduling. They are not moved around by
10465 the compiler during scheduling, and thus can be expected to appear
10466 where they are put in the C code:
10467 @example
10468 __builtin_arc_brk()
10469 __builtin_arc_core_read()
10470 __builtin_arc_core_write()
10471 __builtin_arc_flag()
10472 __builtin_arc_lr()
10473 __builtin_arc_sleep()
10474 __builtin_arc_sr()
10475 __builtin_arc_swi()
10476 @end example
10477
10478 @node ARC SIMD Built-in Functions
10479 @subsection ARC SIMD Built-in Functions
10480
10481 SIMD builtins provided by the compiler can be used to generate the
10482 vector instructions. This section describes the available builtins
10483 and their usage in programs. With the @option{-msimd} option, the
10484 compiler provides 128-bit vector types, which can be specified using
10485 the @code{vector_size} attribute. The header file @file{arc-simd.h}
10486 can be included to use the following predefined types:
10487 @example
10488 typedef int __v4si __attribute__((vector_size(16)));
10489 typedef short __v8hi __attribute__((vector_size(16)));
10490 @end example
10491
10492 These types can be used to define 128-bit variables. The built-in
10493 functions listed in the following section can be used on these
10494 variables to generate the vector operations.
10495
10496 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
10497 @file{arc-simd.h} also provides equivalent macros called
10498 @code{_@var{someinsn}} that can be used for programming ease and
10499 improved readability. The following macros for DMA control are also
10500 provided:
10501 @example
10502 #define _setup_dma_in_channel_reg _vdiwr
10503 #define _setup_dma_out_channel_reg _vdowr
10504 @end example
10505
10506 The following is a complete list of all the SIMD built-ins provided
10507 for ARC, grouped by calling signature.
10508
10509 The following take two @code{__v8hi} arguments and return a
10510 @code{__v8hi} result:
10511 @example
10512 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
10513 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
10514 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
10515 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
10516 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
10517 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
10518 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
10519 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
10520 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
10521 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
10522 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
10523 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
10524 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
10525 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
10526 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
10527 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
10528 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
10529 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
10530 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
10531 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
10532 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
10533 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
10534 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
10535 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
10536 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
10537 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
10538 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
10539 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
10540 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
10541 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
10542 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
10543 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
10544 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
10545 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
10546 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
10547 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
10548 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
10549 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
10550 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
10551 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
10552 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
10553 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
10554 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
10555 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
10556 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
10557 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
10558 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
10559 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
10560 @end example
10561
10562 The following take one @code{__v8hi} and one @code{int} argument and return a
10563 @code{__v8hi} result:
10564
10565 @example
10566 __v8hi __builtin_arc_vbaddw (__v8hi, int)
10567 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
10568 __v8hi __builtin_arc_vbminw (__v8hi, int)
10569 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
10570 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
10571 __v8hi __builtin_arc_vbmulw (__v8hi, int)
10572 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
10573 __v8hi __builtin_arc_vbsubw (__v8hi, int)
10574 @end example
10575
10576 The following take one @code{__v8hi} argument and one @code{int} argument which
10577 must be a 3-bit compile time constant indicating a register number
10578 I0-I7. They return a @code{__v8hi} result.
10579 @example
10580 __v8hi __builtin_arc_vasrw (__v8hi, const int)
10581 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
10582 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
10583 @end example
10584
10585 The following take one @code{__v8hi} argument and one @code{int}
10586 argument which must be a 6-bit compile time constant. They return a
10587 @code{__v8hi} result.
10588 @example
10589 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
10590 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
10591 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
10592 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
10593 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
10594 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
10595 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
10596 @end example
10597
10598 The following take one @code{__v8hi} argument and one @code{int} argument which
10599 must be a 8-bit compile time constant. They return a @code{__v8hi}
10600 result.
10601 @example
10602 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
10603 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
10604 __v8hi __builtin_arc_vmvw (__v8hi, const int)
10605 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
10606 @end example
10607
10608 The following take two @code{int} arguments, the second of which which
10609 must be a 8-bit compile time constant. They return a @code{__v8hi}
10610 result:
10611 @example
10612 __v8hi __builtin_arc_vmovaw (int, const int)
10613 __v8hi __builtin_arc_vmovw (int, const int)
10614 __v8hi __builtin_arc_vmovzw (int, const int)
10615 @end example
10616
10617 The following take a single @code{__v8hi} argument and return a
10618 @code{__v8hi} result:
10619 @example
10620 __v8hi __builtin_arc_vabsaw (__v8hi)
10621 __v8hi __builtin_arc_vabsw (__v8hi)
10622 __v8hi __builtin_arc_vaddsuw (__v8hi)
10623 __v8hi __builtin_arc_vexch1 (__v8hi)
10624 __v8hi __builtin_arc_vexch2 (__v8hi)
10625 __v8hi __builtin_arc_vexch4 (__v8hi)
10626 __v8hi __builtin_arc_vsignw (__v8hi)
10627 __v8hi __builtin_arc_vupbaw (__v8hi)
10628 __v8hi __builtin_arc_vupbw (__v8hi)
10629 __v8hi __builtin_arc_vupsbaw (__v8hi)
10630 __v8hi __builtin_arc_vupsbw (__v8hi)
10631 @end example
10632
10633 The followign take two @code{int} arguments and return no result:
10634 @example
10635 void __builtin_arc_vdirun (int, int)
10636 void __builtin_arc_vdorun (int, int)
10637 @end example
10638
10639 The following take two @code{int} arguments and return no result. The
10640 first argument must a 3-bit compile time constant indicating one of
10641 the DR0-DR7 DMA setup channels:
10642 @example
10643 void __builtin_arc_vdiwr (const int, int)
10644 void __builtin_arc_vdowr (const int, int)
10645 @end example
10646
10647 The following take an @code{int} argument and return no result:
10648 @example
10649 void __builtin_arc_vendrec (int)
10650 void __builtin_arc_vrec (int)
10651 void __builtin_arc_vrecrun (int)
10652 void __builtin_arc_vrun (int)
10653 @end example
10654
10655 The following take a @code{__v8hi} argument and two @code{int}
10656 arguments and return a @code{__v8hi} result. The second argument must
10657 be a 3-bit compile time constants, indicating one the registers I0-I7,
10658 and the third argument must be an 8-bit compile time constant.
10659
10660 @emph{Note:} Although the equivalent hardware instructions do not take
10661 an SIMD register as an operand, these builtins overwrite the relevant
10662 bits of the @code{__v8hi} register provided as the first argument with
10663 the value loaded from the @code{[Ib, u8]} location in the SDM.
10664
10665 @example
10666 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
10667 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
10668 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
10669 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
10670 @end example
10671
10672 The following take two @code{int} arguments and return a @code{__v8hi}
10673 result. The first argument must be a 3-bit compile time constants,
10674 indicating one the registers I0-I7, and the second argument must be an
10675 8-bit compile time constant.
10676
10677 @example
10678 __v8hi __builtin_arc_vld128 (const int, const int)
10679 __v8hi __builtin_arc_vld64w (const int, const int)
10680 @end example
10681
10682 The following take a @code{__v8hi} argument and two @code{int}
10683 arguments and return no result. The second argument must be a 3-bit
10684 compile time constants, indicating one the registers I0-I7, and the
10685 third argument must be an 8-bit compile time constant.
10686
10687 @example
10688 void __builtin_arc_vst128 (__v8hi, const int, const int)
10689 void __builtin_arc_vst64 (__v8hi, const int, const int)
10690 @end example
10691
10692 The following take a @code{__v8hi} argument and three @code{int}
10693 arguments and return no result. The second argument must be a 3-bit
10694 compile-time constant, identifying the 16-bit sub-register to be
10695 stored, the third argument must be a 3-bit compile time constants,
10696 indicating one the registers I0-I7, and the fourth argument must be an
10697 8-bit compile time constant.
10698
10699 @example
10700 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
10701 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
10702 @end example
10703
10704 @node ARM iWMMXt Built-in Functions
10705 @subsection ARM iWMMXt Built-in Functions
10706
10707 These built-in functions are available for the ARM family of
10708 processors when the @option{-mcpu=iwmmxt} switch is used:
10709
10710 @smallexample
10711 typedef int v2si __attribute__ ((vector_size (8)));
10712 typedef short v4hi __attribute__ ((vector_size (8)));
10713 typedef char v8qi __attribute__ ((vector_size (8)));
10714
10715 int __builtin_arm_getwcgr0 (void)
10716 void __builtin_arm_setwcgr0 (int)
10717 int __builtin_arm_getwcgr1 (void)
10718 void __builtin_arm_setwcgr1 (int)
10719 int __builtin_arm_getwcgr2 (void)
10720 void __builtin_arm_setwcgr2 (int)
10721 int __builtin_arm_getwcgr3 (void)
10722 void __builtin_arm_setwcgr3 (int)
10723 int __builtin_arm_textrmsb (v8qi, int)
10724 int __builtin_arm_textrmsh (v4hi, int)
10725 int __builtin_arm_textrmsw (v2si, int)
10726 int __builtin_arm_textrmub (v8qi, int)
10727 int __builtin_arm_textrmuh (v4hi, int)
10728 int __builtin_arm_textrmuw (v2si, int)
10729 v8qi __builtin_arm_tinsrb (v8qi, int, int)
10730 v4hi __builtin_arm_tinsrh (v4hi, int, int)
10731 v2si __builtin_arm_tinsrw (v2si, int, int)
10732 long long __builtin_arm_tmia (long long, int, int)
10733 long long __builtin_arm_tmiabb (long long, int, int)
10734 long long __builtin_arm_tmiabt (long long, int, int)
10735 long long __builtin_arm_tmiaph (long long, int, int)
10736 long long __builtin_arm_tmiatb (long long, int, int)
10737 long long __builtin_arm_tmiatt (long long, int, int)
10738 int __builtin_arm_tmovmskb (v8qi)
10739 int __builtin_arm_tmovmskh (v4hi)
10740 int __builtin_arm_tmovmskw (v2si)
10741 long long __builtin_arm_waccb (v8qi)
10742 long long __builtin_arm_wacch (v4hi)
10743 long long __builtin_arm_waccw (v2si)
10744 v8qi __builtin_arm_waddb (v8qi, v8qi)
10745 v8qi __builtin_arm_waddbss (v8qi, v8qi)
10746 v8qi __builtin_arm_waddbus (v8qi, v8qi)
10747 v4hi __builtin_arm_waddh (v4hi, v4hi)
10748 v4hi __builtin_arm_waddhss (v4hi, v4hi)
10749 v4hi __builtin_arm_waddhus (v4hi, v4hi)
10750 v2si __builtin_arm_waddw (v2si, v2si)
10751 v2si __builtin_arm_waddwss (v2si, v2si)
10752 v2si __builtin_arm_waddwus (v2si, v2si)
10753 v8qi __builtin_arm_walign (v8qi, v8qi, int)
10754 long long __builtin_arm_wand(long long, long long)
10755 long long __builtin_arm_wandn (long long, long long)
10756 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
10757 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
10758 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
10759 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
10760 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
10761 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
10762 v2si __builtin_arm_wcmpeqw (v2si, v2si)
10763 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
10764 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
10765 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
10766 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
10767 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
10768 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
10769 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
10770 long long __builtin_arm_wmacsz (v4hi, v4hi)
10771 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
10772 long long __builtin_arm_wmacuz (v4hi, v4hi)
10773 v4hi __builtin_arm_wmadds (v4hi, v4hi)
10774 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
10775 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
10776 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
10777 v2si __builtin_arm_wmaxsw (v2si, v2si)
10778 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
10779 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
10780 v2si __builtin_arm_wmaxuw (v2si, v2si)
10781 v8qi __builtin_arm_wminsb (v8qi, v8qi)
10782 v4hi __builtin_arm_wminsh (v4hi, v4hi)
10783 v2si __builtin_arm_wminsw (v2si, v2si)
10784 v8qi __builtin_arm_wminub (v8qi, v8qi)
10785 v4hi __builtin_arm_wminuh (v4hi, v4hi)
10786 v2si __builtin_arm_wminuw (v2si, v2si)
10787 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
10788 v4hi __builtin_arm_wmulul (v4hi, v4hi)
10789 v4hi __builtin_arm_wmulum (v4hi, v4hi)
10790 long long __builtin_arm_wor (long long, long long)
10791 v2si __builtin_arm_wpackdss (long long, long long)
10792 v2si __builtin_arm_wpackdus (long long, long long)
10793 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
10794 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
10795 v4hi __builtin_arm_wpackwss (v2si, v2si)
10796 v4hi __builtin_arm_wpackwus (v2si, v2si)
10797 long long __builtin_arm_wrord (long long, long long)
10798 long long __builtin_arm_wrordi (long long, int)
10799 v4hi __builtin_arm_wrorh (v4hi, long long)
10800 v4hi __builtin_arm_wrorhi (v4hi, int)
10801 v2si __builtin_arm_wrorw (v2si, long long)
10802 v2si __builtin_arm_wrorwi (v2si, int)
10803 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
10804 v2si __builtin_arm_wsadbz (v8qi, v8qi)
10805 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
10806 v2si __builtin_arm_wsadhz (v4hi, v4hi)
10807 v4hi __builtin_arm_wshufh (v4hi, int)
10808 long long __builtin_arm_wslld (long long, long long)
10809 long long __builtin_arm_wslldi (long long, int)
10810 v4hi __builtin_arm_wsllh (v4hi, long long)
10811 v4hi __builtin_arm_wsllhi (v4hi, int)
10812 v2si __builtin_arm_wsllw (v2si, long long)
10813 v2si __builtin_arm_wsllwi (v2si, int)
10814 long long __builtin_arm_wsrad (long long, long long)
10815 long long __builtin_arm_wsradi (long long, int)
10816 v4hi __builtin_arm_wsrah (v4hi, long long)
10817 v4hi __builtin_arm_wsrahi (v4hi, int)
10818 v2si __builtin_arm_wsraw (v2si, long long)
10819 v2si __builtin_arm_wsrawi (v2si, int)
10820 long long __builtin_arm_wsrld (long long, long long)
10821 long long __builtin_arm_wsrldi (long long, int)
10822 v4hi __builtin_arm_wsrlh (v4hi, long long)
10823 v4hi __builtin_arm_wsrlhi (v4hi, int)
10824 v2si __builtin_arm_wsrlw (v2si, long long)
10825 v2si __builtin_arm_wsrlwi (v2si, int)
10826 v8qi __builtin_arm_wsubb (v8qi, v8qi)
10827 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
10828 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
10829 v4hi __builtin_arm_wsubh (v4hi, v4hi)
10830 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
10831 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
10832 v2si __builtin_arm_wsubw (v2si, v2si)
10833 v2si __builtin_arm_wsubwss (v2si, v2si)
10834 v2si __builtin_arm_wsubwus (v2si, v2si)
10835 v4hi __builtin_arm_wunpckehsb (v8qi)
10836 v2si __builtin_arm_wunpckehsh (v4hi)
10837 long long __builtin_arm_wunpckehsw (v2si)
10838 v4hi __builtin_arm_wunpckehub (v8qi)
10839 v2si __builtin_arm_wunpckehuh (v4hi)
10840 long long __builtin_arm_wunpckehuw (v2si)
10841 v4hi __builtin_arm_wunpckelsb (v8qi)
10842 v2si __builtin_arm_wunpckelsh (v4hi)
10843 long long __builtin_arm_wunpckelsw (v2si)
10844 v4hi __builtin_arm_wunpckelub (v8qi)
10845 v2si __builtin_arm_wunpckeluh (v4hi)
10846 long long __builtin_arm_wunpckeluw (v2si)
10847 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
10848 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
10849 v2si __builtin_arm_wunpckihw (v2si, v2si)
10850 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
10851 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
10852 v2si __builtin_arm_wunpckilw (v2si, v2si)
10853 long long __builtin_arm_wxor (long long, long long)
10854 long long __builtin_arm_wzero ()
10855 @end smallexample
10856
10857
10858 @node ARM C Language Extensions (ACLE)
10859 @subsection ARM C Language Extensions (ACLE)
10860
10861 GCC implements extensions for C as described in the ARM C Language
10862 Extensions (ACLE) specification, which can be found at
10863 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
10864
10865 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
10866 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
10867 intrinsics can be found at
10868 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
10869 The built-in intrinsics for the Advanced SIMD extension are available when
10870 NEON is enabled.
10871
10872 Currently, ARM and AArch64 back-ends do not support ACLE 2.0 fully. Both
10873 back-ends support CRC32 intrinsics from @file{arm_acle.h}. The ARM backend's
10874 16-bit floating-point Advanded SIMD Intrinsics currently comply to ACLE v1.1.
10875 AArch64's backend does not have support for 16-bit floating point Advanced SIMD
10876 Intrinsics yet.
10877
10878 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
10879 availability of extensions.
10880
10881 @node ARM Floating Point Status and Control Intrinsics
10882 @subsection ARM Floating Point Status and Control Intrinsics
10883
10884 These built-in functions are available for the ARM family of
10885 processors with floating-point unit.
10886
10887 @smallexample
10888 unsigned int __builtin_arm_get_fpscr ()
10889 void __builtin_arm_set_fpscr (unsigned int)
10890 @end smallexample
10891
10892 @node AVR Built-in Functions
10893 @subsection AVR Built-in Functions
10894
10895 For each built-in function for AVR, there is an equally named,
10896 uppercase built-in macro defined. That way users can easily query if
10897 or if not a specific built-in is implemented or not. For example, if
10898 @code{__builtin_avr_nop} is available the macro
10899 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
10900
10901 The following built-in functions map to the respective machine
10902 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
10903 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
10904 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
10905 as library call if no hardware multiplier is available.
10906
10907 @smallexample
10908 void __builtin_avr_nop (void)
10909 void __builtin_avr_sei (void)
10910 void __builtin_avr_cli (void)
10911 void __builtin_avr_sleep (void)
10912 void __builtin_avr_wdr (void)
10913 unsigned char __builtin_avr_swap (unsigned char)
10914 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
10915 int __builtin_avr_fmuls (char, char)
10916 int __builtin_avr_fmulsu (char, unsigned char)
10917 @end smallexample
10918
10919 In order to delay execution for a specific number of cycles, GCC
10920 implements
10921 @smallexample
10922 void __builtin_avr_delay_cycles (unsigned long ticks)
10923 @end smallexample
10924
10925 @noindent
10926 @code{ticks} is the number of ticks to delay execution. Note that this
10927 built-in does not take into account the effect of interrupts that
10928 might increase delay time. @code{ticks} must be a compile-time
10929 integer constant; delays with a variable number of cycles are not supported.
10930
10931 @smallexample
10932 char __builtin_avr_flash_segment (const __memx void*)
10933 @end smallexample
10934
10935 @noindent
10936 This built-in takes a byte address to the 24-bit
10937 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
10938 the number of the flash segment (the 64 KiB chunk) where the address
10939 points to. Counting starts at @code{0}.
10940 If the address does not point to flash memory, return @code{-1}.
10941
10942 @smallexample
10943 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
10944 @end smallexample
10945
10946 @noindent
10947 Insert bits from @var{bits} into @var{val} and return the resulting
10948 value. The nibbles of @var{map} determine how the insertion is
10949 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
10950 @enumerate
10951 @item If @var{X} is @code{0xf},
10952 then the @var{n}-th bit of @var{val} is returned unaltered.
10953
10954 @item If X is in the range 0@dots{}7,
10955 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
10956
10957 @item If X is in the range 8@dots{}@code{0xe},
10958 then the @var{n}-th result bit is undefined.
10959 @end enumerate
10960
10961 @noindent
10962 One typical use case for this built-in is adjusting input and
10963 output values to non-contiguous port layouts. Some examples:
10964
10965 @smallexample
10966 // same as val, bits is unused
10967 __builtin_avr_insert_bits (0xffffffff, bits, val)
10968 @end smallexample
10969
10970 @smallexample
10971 // same as bits, val is unused
10972 __builtin_avr_insert_bits (0x76543210, bits, val)
10973 @end smallexample
10974
10975 @smallexample
10976 // same as rotating bits by 4
10977 __builtin_avr_insert_bits (0x32107654, bits, 0)
10978 @end smallexample
10979
10980 @smallexample
10981 // high nibble of result is the high nibble of val
10982 // low nibble of result is the low nibble of bits
10983 __builtin_avr_insert_bits (0xffff3210, bits, val)
10984 @end smallexample
10985
10986 @smallexample
10987 // reverse the bit order of bits
10988 __builtin_avr_insert_bits (0x01234567, bits, 0)
10989 @end smallexample
10990
10991 @node Blackfin Built-in Functions
10992 @subsection Blackfin Built-in Functions
10993
10994 Currently, there are two Blackfin-specific built-in functions. These are
10995 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
10996 using inline assembly; by using these built-in functions the compiler can
10997 automatically add workarounds for hardware errata involving these
10998 instructions. These functions are named as follows:
10999
11000 @smallexample
11001 void __builtin_bfin_csync (void)
11002 void __builtin_bfin_ssync (void)
11003 @end smallexample
11004
11005 @node FR-V Built-in Functions
11006 @subsection FR-V Built-in Functions
11007
11008 GCC provides many FR-V-specific built-in functions. In general,
11009 these functions are intended to be compatible with those described
11010 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
11011 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
11012 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
11013 pointer rather than by value.
11014
11015 Most of the functions are named after specific FR-V instructions.
11016 Such functions are said to be ``directly mapped'' and are summarized
11017 here in tabular form.
11018
11019 @menu
11020 * Argument Types::
11021 * Directly-mapped Integer Functions::
11022 * Directly-mapped Media Functions::
11023 * Raw read/write Functions::
11024 * Other Built-in Functions::
11025 @end menu
11026
11027 @node Argument Types
11028 @subsubsection Argument Types
11029
11030 The arguments to the built-in functions can be divided into three groups:
11031 register numbers, compile-time constants and run-time values. In order
11032 to make this classification clear at a glance, the arguments and return
11033 values are given the following pseudo types:
11034
11035 @multitable @columnfractions .20 .30 .15 .35
11036 @item Pseudo type @tab Real C type @tab Constant? @tab Description
11037 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
11038 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
11039 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
11040 @item @code{uw2} @tab @code{unsigned long long} @tab No
11041 @tab an unsigned doubleword
11042 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
11043 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
11044 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
11045 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
11046 @end multitable
11047
11048 These pseudo types are not defined by GCC, they are simply a notational
11049 convenience used in this manual.
11050
11051 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
11052 and @code{sw2} are evaluated at run time. They correspond to
11053 register operands in the underlying FR-V instructions.
11054
11055 @code{const} arguments represent immediate operands in the underlying
11056 FR-V instructions. They must be compile-time constants.
11057
11058 @code{acc} arguments are evaluated at compile time and specify the number
11059 of an accumulator register. For example, an @code{acc} argument of 2
11060 selects the ACC2 register.
11061
11062 @code{iacc} arguments are similar to @code{acc} arguments but specify the
11063 number of an IACC register. See @pxref{Other Built-in Functions}
11064 for more details.
11065
11066 @node Directly-mapped Integer Functions
11067 @subsubsection Directly-mapped Integer Functions
11068
11069 The functions listed below map directly to FR-V I-type instructions.
11070
11071 @multitable @columnfractions .45 .32 .23
11072 @item Function prototype @tab Example usage @tab Assembly output
11073 @item @code{sw1 __ADDSS (sw1, sw1)}
11074 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
11075 @tab @code{ADDSS @var{a},@var{b},@var{c}}
11076 @item @code{sw1 __SCAN (sw1, sw1)}
11077 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
11078 @tab @code{SCAN @var{a},@var{b},@var{c}}
11079 @item @code{sw1 __SCUTSS (sw1)}
11080 @tab @code{@var{b} = __SCUTSS (@var{a})}
11081 @tab @code{SCUTSS @var{a},@var{b}}
11082 @item @code{sw1 __SLASS (sw1, sw1)}
11083 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
11084 @tab @code{SLASS @var{a},@var{b},@var{c}}
11085 @item @code{void __SMASS (sw1, sw1)}
11086 @tab @code{__SMASS (@var{a}, @var{b})}
11087 @tab @code{SMASS @var{a},@var{b}}
11088 @item @code{void __SMSSS (sw1, sw1)}
11089 @tab @code{__SMSSS (@var{a}, @var{b})}
11090 @tab @code{SMSSS @var{a},@var{b}}
11091 @item @code{void __SMU (sw1, sw1)}
11092 @tab @code{__SMU (@var{a}, @var{b})}
11093 @tab @code{SMU @var{a},@var{b}}
11094 @item @code{sw2 __SMUL (sw1, sw1)}
11095 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
11096 @tab @code{SMUL @var{a},@var{b},@var{c}}
11097 @item @code{sw1 __SUBSS (sw1, sw1)}
11098 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
11099 @tab @code{SUBSS @var{a},@var{b},@var{c}}
11100 @item @code{uw2 __UMUL (uw1, uw1)}
11101 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
11102 @tab @code{UMUL @var{a},@var{b},@var{c}}
11103 @end multitable
11104
11105 @node Directly-mapped Media Functions
11106 @subsubsection Directly-mapped Media Functions
11107
11108 The functions listed below map directly to FR-V M-type instructions.
11109
11110 @multitable @columnfractions .45 .32 .23
11111 @item Function prototype @tab Example usage @tab Assembly output
11112 @item @code{uw1 __MABSHS (sw1)}
11113 @tab @code{@var{b} = __MABSHS (@var{a})}
11114 @tab @code{MABSHS @var{a},@var{b}}
11115 @item @code{void __MADDACCS (acc, acc)}
11116 @tab @code{__MADDACCS (@var{b}, @var{a})}
11117 @tab @code{MADDACCS @var{a},@var{b}}
11118 @item @code{sw1 __MADDHSS (sw1, sw1)}
11119 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
11120 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
11121 @item @code{uw1 __MADDHUS (uw1, uw1)}
11122 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
11123 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
11124 @item @code{uw1 __MAND (uw1, uw1)}
11125 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
11126 @tab @code{MAND @var{a},@var{b},@var{c}}
11127 @item @code{void __MASACCS (acc, acc)}
11128 @tab @code{__MASACCS (@var{b}, @var{a})}
11129 @tab @code{MASACCS @var{a},@var{b}}
11130 @item @code{uw1 __MAVEH (uw1, uw1)}
11131 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
11132 @tab @code{MAVEH @var{a},@var{b},@var{c}}
11133 @item @code{uw2 __MBTOH (uw1)}
11134 @tab @code{@var{b} = __MBTOH (@var{a})}
11135 @tab @code{MBTOH @var{a},@var{b}}
11136 @item @code{void __MBTOHE (uw1 *, uw1)}
11137 @tab @code{__MBTOHE (&@var{b}, @var{a})}
11138 @tab @code{MBTOHE @var{a},@var{b}}
11139 @item @code{void __MCLRACC (acc)}
11140 @tab @code{__MCLRACC (@var{a})}
11141 @tab @code{MCLRACC @var{a}}
11142 @item @code{void __MCLRACCA (void)}
11143 @tab @code{__MCLRACCA ()}
11144 @tab @code{MCLRACCA}
11145 @item @code{uw1 __Mcop1 (uw1, uw1)}
11146 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
11147 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
11148 @item @code{uw1 __Mcop2 (uw1, uw1)}
11149 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
11150 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
11151 @item @code{uw1 __MCPLHI (uw2, const)}
11152 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
11153 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
11154 @item @code{uw1 __MCPLI (uw2, const)}
11155 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
11156 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
11157 @item @code{void __MCPXIS (acc, sw1, sw1)}
11158 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
11159 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
11160 @item @code{void __MCPXIU (acc, uw1, uw1)}
11161 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
11162 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
11163 @item @code{void __MCPXRS (acc, sw1, sw1)}
11164 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
11165 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
11166 @item @code{void __MCPXRU (acc, uw1, uw1)}
11167 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
11168 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
11169 @item @code{uw1 __MCUT (acc, uw1)}
11170 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
11171 @tab @code{MCUT @var{a},@var{b},@var{c}}
11172 @item @code{uw1 __MCUTSS (acc, sw1)}
11173 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
11174 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
11175 @item @code{void __MDADDACCS (acc, acc)}
11176 @tab @code{__MDADDACCS (@var{b}, @var{a})}
11177 @tab @code{MDADDACCS @var{a},@var{b}}
11178 @item @code{void __MDASACCS (acc, acc)}
11179 @tab @code{__MDASACCS (@var{b}, @var{a})}
11180 @tab @code{MDASACCS @var{a},@var{b}}
11181 @item @code{uw2 __MDCUTSSI (acc, const)}
11182 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
11183 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
11184 @item @code{uw2 __MDPACKH (uw2, uw2)}
11185 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
11186 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
11187 @item @code{uw2 __MDROTLI (uw2, const)}
11188 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
11189 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
11190 @item @code{void __MDSUBACCS (acc, acc)}
11191 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
11192 @tab @code{MDSUBACCS @var{a},@var{b}}
11193 @item @code{void __MDUNPACKH (uw1 *, uw2)}
11194 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
11195 @tab @code{MDUNPACKH @var{a},@var{b}}
11196 @item @code{uw2 __MEXPDHD (uw1, const)}
11197 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
11198 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
11199 @item @code{uw1 __MEXPDHW (uw1, const)}
11200 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
11201 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
11202 @item @code{uw1 __MHDSETH (uw1, const)}
11203 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
11204 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
11205 @item @code{sw1 __MHDSETS (const)}
11206 @tab @code{@var{b} = __MHDSETS (@var{a})}
11207 @tab @code{MHDSETS #@var{a},@var{b}}
11208 @item @code{uw1 __MHSETHIH (uw1, const)}
11209 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
11210 @tab @code{MHSETHIH #@var{a},@var{b}}
11211 @item @code{sw1 __MHSETHIS (sw1, const)}
11212 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
11213 @tab @code{MHSETHIS #@var{a},@var{b}}
11214 @item @code{uw1 __MHSETLOH (uw1, const)}
11215 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
11216 @tab @code{MHSETLOH #@var{a},@var{b}}
11217 @item @code{sw1 __MHSETLOS (sw1, const)}
11218 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
11219 @tab @code{MHSETLOS #@var{a},@var{b}}
11220 @item @code{uw1 __MHTOB (uw2)}
11221 @tab @code{@var{b} = __MHTOB (@var{a})}
11222 @tab @code{MHTOB @var{a},@var{b}}
11223 @item @code{void __MMACHS (acc, sw1, sw1)}
11224 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
11225 @tab @code{MMACHS @var{a},@var{b},@var{c}}
11226 @item @code{void __MMACHU (acc, uw1, uw1)}
11227 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
11228 @tab @code{MMACHU @var{a},@var{b},@var{c}}
11229 @item @code{void __MMRDHS (acc, sw1, sw1)}
11230 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
11231 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
11232 @item @code{void __MMRDHU (acc, uw1, uw1)}
11233 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
11234 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
11235 @item @code{void __MMULHS (acc, sw1, sw1)}
11236 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
11237 @tab @code{MMULHS @var{a},@var{b},@var{c}}
11238 @item @code{void __MMULHU (acc, uw1, uw1)}
11239 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
11240 @tab @code{MMULHU @var{a},@var{b},@var{c}}
11241 @item @code{void __MMULXHS (acc, sw1, sw1)}
11242 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
11243 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
11244 @item @code{void __MMULXHU (acc, uw1, uw1)}
11245 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
11246 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
11247 @item @code{uw1 __MNOT (uw1)}
11248 @tab @code{@var{b} = __MNOT (@var{a})}
11249 @tab @code{MNOT @var{a},@var{b}}
11250 @item @code{uw1 __MOR (uw1, uw1)}
11251 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
11252 @tab @code{MOR @var{a},@var{b},@var{c}}
11253 @item @code{uw1 __MPACKH (uh, uh)}
11254 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
11255 @tab @code{MPACKH @var{a},@var{b},@var{c}}
11256 @item @code{sw2 __MQADDHSS (sw2, sw2)}
11257 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
11258 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
11259 @item @code{uw2 __MQADDHUS (uw2, uw2)}
11260 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
11261 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
11262 @item @code{void __MQCPXIS (acc, sw2, sw2)}
11263 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
11264 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
11265 @item @code{void __MQCPXIU (acc, uw2, uw2)}
11266 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
11267 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
11268 @item @code{void __MQCPXRS (acc, sw2, sw2)}
11269 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
11270 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
11271 @item @code{void __MQCPXRU (acc, uw2, uw2)}
11272 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
11273 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
11274 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
11275 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
11276 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
11277 @item @code{sw2 __MQLMTHS (sw2, sw2)}
11278 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
11279 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
11280 @item @code{void __MQMACHS (acc, sw2, sw2)}
11281 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
11282 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
11283 @item @code{void __MQMACHU (acc, uw2, uw2)}
11284 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
11285 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
11286 @item @code{void __MQMACXHS (acc, sw2, sw2)}
11287 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
11288 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
11289 @item @code{void __MQMULHS (acc, sw2, sw2)}
11290 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
11291 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
11292 @item @code{void __MQMULHU (acc, uw2, uw2)}
11293 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
11294 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
11295 @item @code{void __MQMULXHS (acc, sw2, sw2)}
11296 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
11297 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
11298 @item @code{void __MQMULXHU (acc, uw2, uw2)}
11299 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
11300 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
11301 @item @code{sw2 __MQSATHS (sw2, sw2)}
11302 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
11303 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
11304 @item @code{uw2 __MQSLLHI (uw2, int)}
11305 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
11306 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
11307 @item @code{sw2 __MQSRAHI (sw2, int)}
11308 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
11309 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
11310 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
11311 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
11312 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
11313 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
11314 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
11315 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
11316 @item @code{void __MQXMACHS (acc, sw2, sw2)}
11317 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
11318 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
11319 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
11320 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
11321 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
11322 @item @code{uw1 __MRDACC (acc)}
11323 @tab @code{@var{b} = __MRDACC (@var{a})}
11324 @tab @code{MRDACC @var{a},@var{b}}
11325 @item @code{uw1 __MRDACCG (acc)}
11326 @tab @code{@var{b} = __MRDACCG (@var{a})}
11327 @tab @code{MRDACCG @var{a},@var{b}}
11328 @item @code{uw1 __MROTLI (uw1, const)}
11329 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
11330 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
11331 @item @code{uw1 __MROTRI (uw1, const)}
11332 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
11333 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
11334 @item @code{sw1 __MSATHS (sw1, sw1)}
11335 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
11336 @tab @code{MSATHS @var{a},@var{b},@var{c}}
11337 @item @code{uw1 __MSATHU (uw1, uw1)}
11338 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
11339 @tab @code{MSATHU @var{a},@var{b},@var{c}}
11340 @item @code{uw1 __MSLLHI (uw1, const)}
11341 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
11342 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
11343 @item @code{sw1 __MSRAHI (sw1, const)}
11344 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
11345 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
11346 @item @code{uw1 __MSRLHI (uw1, const)}
11347 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
11348 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
11349 @item @code{void __MSUBACCS (acc, acc)}
11350 @tab @code{__MSUBACCS (@var{b}, @var{a})}
11351 @tab @code{MSUBACCS @var{a},@var{b}}
11352 @item @code{sw1 __MSUBHSS (sw1, sw1)}
11353 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
11354 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
11355 @item @code{uw1 __MSUBHUS (uw1, uw1)}
11356 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
11357 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
11358 @item @code{void __MTRAP (void)}
11359 @tab @code{__MTRAP ()}
11360 @tab @code{MTRAP}
11361 @item @code{uw2 __MUNPACKH (uw1)}
11362 @tab @code{@var{b} = __MUNPACKH (@var{a})}
11363 @tab @code{MUNPACKH @var{a},@var{b}}
11364 @item @code{uw1 __MWCUT (uw2, uw1)}
11365 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
11366 @tab @code{MWCUT @var{a},@var{b},@var{c}}
11367 @item @code{void __MWTACC (acc, uw1)}
11368 @tab @code{__MWTACC (@var{b}, @var{a})}
11369 @tab @code{MWTACC @var{a},@var{b}}
11370 @item @code{void __MWTACCG (acc, uw1)}
11371 @tab @code{__MWTACCG (@var{b}, @var{a})}
11372 @tab @code{MWTACCG @var{a},@var{b}}
11373 @item @code{uw1 __MXOR (uw1, uw1)}
11374 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
11375 @tab @code{MXOR @var{a},@var{b},@var{c}}
11376 @end multitable
11377
11378 @node Raw read/write Functions
11379 @subsubsection Raw read/write Functions
11380
11381 This sections describes built-in functions related to read and write
11382 instructions to access memory. These functions generate
11383 @code{membar} instructions to flush the I/O load and stores where
11384 appropriate, as described in Fujitsu's manual described above.
11385
11386 @table @code
11387
11388 @item unsigned char __builtin_read8 (void *@var{data})
11389 @item unsigned short __builtin_read16 (void *@var{data})
11390 @item unsigned long __builtin_read32 (void *@var{data})
11391 @item unsigned long long __builtin_read64 (void *@var{data})
11392
11393 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
11394 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
11395 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
11396 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
11397 @end table
11398
11399 @node Other Built-in Functions
11400 @subsubsection Other Built-in Functions
11401
11402 This section describes built-in functions that are not named after
11403 a specific FR-V instruction.
11404
11405 @table @code
11406 @item sw2 __IACCreadll (iacc @var{reg})
11407 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
11408 for future expansion and must be 0.
11409
11410 @item sw1 __IACCreadl (iacc @var{reg})
11411 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
11412 Other values of @var{reg} are rejected as invalid.
11413
11414 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
11415 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
11416 is reserved for future expansion and must be 0.
11417
11418 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
11419 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
11420 is 1. Other values of @var{reg} are rejected as invalid.
11421
11422 @item void __data_prefetch0 (const void *@var{x})
11423 Use the @code{dcpl} instruction to load the contents of address @var{x}
11424 into the data cache.
11425
11426 @item void __data_prefetch (const void *@var{x})
11427 Use the @code{nldub} instruction to load the contents of address @var{x}
11428 into the data cache. The instruction is issued in slot I1@.
11429 @end table
11430
11431 @node X86 Built-in Functions
11432 @subsection X86 Built-in Functions
11433
11434 These built-in functions are available for the i386 and x86-64 family
11435 of computers, depending on the command-line switches used.
11436
11437 If you specify command-line switches such as @option{-msse},
11438 the compiler could use the extended instruction sets even if the built-ins
11439 are not used explicitly in the program. For this reason, applications
11440 that perform run-time CPU detection must compile separate files for each
11441 supported architecture, using the appropriate flags. In particular,
11442 the file containing the CPU detection code should be compiled without
11443 these options.
11444
11445 The following machine modes are available for use with MMX built-in functions
11446 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
11447 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
11448 vector of eight 8-bit integers. Some of the built-in functions operate on
11449 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
11450
11451 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
11452 of two 32-bit floating-point values.
11453
11454 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
11455 floating-point values. Some instructions use a vector of four 32-bit
11456 integers, these use @code{V4SI}. Finally, some instructions operate on an
11457 entire vector register, interpreting it as a 128-bit integer, these use mode
11458 @code{TI}.
11459
11460 In 64-bit mode, the x86-64 family of processors uses additional built-in
11461 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
11462 floating point and @code{TC} 128-bit complex floating-point values.
11463
11464 The following floating-point built-in functions are available in 64-bit
11465 mode. All of them implement the function that is part of the name.
11466
11467 @smallexample
11468 __float128 __builtin_fabsq (__float128)
11469 __float128 __builtin_copysignq (__float128, __float128)
11470 @end smallexample
11471
11472 The following built-in function is always available.
11473
11474 @table @code
11475 @item void __builtin_ia32_pause (void)
11476 Generates the @code{pause} machine instruction with a compiler memory
11477 barrier.
11478 @end table
11479
11480 The following floating-point built-in functions are made available in the
11481 64-bit mode.
11482
11483 @table @code
11484 @item __float128 __builtin_infq (void)
11485 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
11486 @findex __builtin_infq
11487
11488 @item __float128 __builtin_huge_valq (void)
11489 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
11490 @findex __builtin_huge_valq
11491 @end table
11492
11493 The following built-in functions are always available and can be used to
11494 check the target platform type.
11495
11496 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
11497 This function runs the CPU detection code to check the type of CPU and the
11498 features supported. This built-in function needs to be invoked along with the built-in functions
11499 to check CPU type and features, @code{__builtin_cpu_is} and
11500 @code{__builtin_cpu_supports}, only when used in a function that is
11501 executed before any constructors are called. The CPU detection code is
11502 automatically executed in a very high priority constructor.
11503
11504 For example, this function has to be used in @code{ifunc} resolvers that
11505 check for CPU type using the built-in functions @code{__builtin_cpu_is}
11506 and @code{__builtin_cpu_supports}, or in constructors on targets that
11507 don't support constructor priority.
11508 @smallexample
11509
11510 static void (*resolve_memcpy (void)) (void)
11511 @{
11512 // ifunc resolvers fire before constructors, explicitly call the init
11513 // function.
11514 __builtin_cpu_init ();
11515 if (__builtin_cpu_supports ("ssse3"))
11516 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
11517 else
11518 return default_memcpy;
11519 @}
11520
11521 void *memcpy (void *, const void *, size_t)
11522 __attribute__ ((ifunc ("resolve_memcpy")));
11523 @end smallexample
11524
11525 @end deftypefn
11526
11527 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
11528 This function returns a positive integer if the run-time CPU
11529 is of type @var{cpuname}
11530 and returns @code{0} otherwise. The following CPU names can be detected:
11531
11532 @table @samp
11533 @item intel
11534 Intel CPU.
11535
11536 @item atom
11537 Intel Atom CPU.
11538
11539 @item core2
11540 Intel Core 2 CPU.
11541
11542 @item corei7
11543 Intel Core i7 CPU.
11544
11545 @item nehalem
11546 Intel Core i7 Nehalem CPU.
11547
11548 @item westmere
11549 Intel Core i7 Westmere CPU.
11550
11551 @item sandybridge
11552 Intel Core i7 Sandy Bridge CPU.
11553
11554 @item amd
11555 AMD CPU.
11556
11557 @item amdfam10h
11558 AMD Family 10h CPU.
11559
11560 @item barcelona
11561 AMD Family 10h Barcelona CPU.
11562
11563 @item shanghai
11564 AMD Family 10h Shanghai CPU.
11565
11566 @item istanbul
11567 AMD Family 10h Istanbul CPU.
11568
11569 @item btver1
11570 AMD Family 14h CPU.
11571
11572 @item amdfam15h
11573 AMD Family 15h CPU.
11574
11575 @item bdver1
11576 AMD Family 15h Bulldozer version 1.
11577
11578 @item bdver2
11579 AMD Family 15h Bulldozer version 2.
11580
11581 @item bdver3
11582 AMD Family 15h Bulldozer version 3.
11583
11584 @item bdver4
11585 AMD Family 15h Bulldozer version 4.
11586
11587 @item btver2
11588 AMD Family 16h CPU.
11589 @end table
11590
11591 Here is an example:
11592 @smallexample
11593 if (__builtin_cpu_is ("corei7"))
11594 @{
11595 do_corei7 (); // Core i7 specific implementation.
11596 @}
11597 else
11598 @{
11599 do_generic (); // Generic implementation.
11600 @}
11601 @end smallexample
11602 @end deftypefn
11603
11604 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
11605 This function returns a positive integer if the run-time CPU
11606 supports @var{feature}
11607 and returns @code{0} otherwise. The following features can be detected:
11608
11609 @table @samp
11610 @item cmov
11611 CMOV instruction.
11612 @item mmx
11613 MMX instructions.
11614 @item popcnt
11615 POPCNT instruction.
11616 @item sse
11617 SSE instructions.
11618 @item sse2
11619 SSE2 instructions.
11620 @item sse3
11621 SSE3 instructions.
11622 @item ssse3
11623 SSSE3 instructions.
11624 @item sse4.1
11625 SSE4.1 instructions.
11626 @item sse4.2
11627 SSE4.2 instructions.
11628 @item avx
11629 AVX instructions.
11630 @item avx2
11631 AVX2 instructions.
11632 @end table
11633
11634 Here is an example:
11635 @smallexample
11636 if (__builtin_cpu_supports ("popcnt"))
11637 @{
11638 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
11639 @}
11640 else
11641 @{
11642 count = generic_countbits (n); //generic implementation.
11643 @}
11644 @end smallexample
11645 @end deftypefn
11646
11647
11648 The following built-in functions are made available by @option{-mmmx}.
11649 All of them generate the machine instruction that is part of the name.
11650
11651 @smallexample
11652 v8qi __builtin_ia32_paddb (v8qi, v8qi)
11653 v4hi __builtin_ia32_paddw (v4hi, v4hi)
11654 v2si __builtin_ia32_paddd (v2si, v2si)
11655 v8qi __builtin_ia32_psubb (v8qi, v8qi)
11656 v4hi __builtin_ia32_psubw (v4hi, v4hi)
11657 v2si __builtin_ia32_psubd (v2si, v2si)
11658 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
11659 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
11660 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
11661 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
11662 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
11663 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
11664 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
11665 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
11666 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
11667 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
11668 di __builtin_ia32_pand (di, di)
11669 di __builtin_ia32_pandn (di,di)
11670 di __builtin_ia32_por (di, di)
11671 di __builtin_ia32_pxor (di, di)
11672 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
11673 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
11674 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
11675 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
11676 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
11677 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
11678 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
11679 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
11680 v2si __builtin_ia32_punpckhdq (v2si, v2si)
11681 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
11682 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
11683 v2si __builtin_ia32_punpckldq (v2si, v2si)
11684 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
11685 v4hi __builtin_ia32_packssdw (v2si, v2si)
11686 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
11687
11688 v4hi __builtin_ia32_psllw (v4hi, v4hi)
11689 v2si __builtin_ia32_pslld (v2si, v2si)
11690 v1di __builtin_ia32_psllq (v1di, v1di)
11691 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
11692 v2si __builtin_ia32_psrld (v2si, v2si)
11693 v1di __builtin_ia32_psrlq (v1di, v1di)
11694 v4hi __builtin_ia32_psraw (v4hi, v4hi)
11695 v2si __builtin_ia32_psrad (v2si, v2si)
11696 v4hi __builtin_ia32_psllwi (v4hi, int)
11697 v2si __builtin_ia32_pslldi (v2si, int)
11698 v1di __builtin_ia32_psllqi (v1di, int)
11699 v4hi __builtin_ia32_psrlwi (v4hi, int)
11700 v2si __builtin_ia32_psrldi (v2si, int)
11701 v1di __builtin_ia32_psrlqi (v1di, int)
11702 v4hi __builtin_ia32_psrawi (v4hi, int)
11703 v2si __builtin_ia32_psradi (v2si, int)
11704
11705 @end smallexample
11706
11707 The following built-in functions are made available either with
11708 @option{-msse}, or with a combination of @option{-m3dnow} and
11709 @option{-march=athlon}. All of them generate the machine
11710 instruction that is part of the name.
11711
11712 @smallexample
11713 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
11714 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
11715 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
11716 v1di __builtin_ia32_psadbw (v8qi, v8qi)
11717 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
11718 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
11719 v8qi __builtin_ia32_pminub (v8qi, v8qi)
11720 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
11721 int __builtin_ia32_pmovmskb (v8qi)
11722 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
11723 void __builtin_ia32_movntq (di *, di)
11724 void __builtin_ia32_sfence (void)
11725 @end smallexample
11726
11727 The following built-in functions are available when @option{-msse} is used.
11728 All of them generate the machine instruction that is part of the name.
11729
11730 @smallexample
11731 int __builtin_ia32_comieq (v4sf, v4sf)
11732 int __builtin_ia32_comineq (v4sf, v4sf)
11733 int __builtin_ia32_comilt (v4sf, v4sf)
11734 int __builtin_ia32_comile (v4sf, v4sf)
11735 int __builtin_ia32_comigt (v4sf, v4sf)
11736 int __builtin_ia32_comige (v4sf, v4sf)
11737 int __builtin_ia32_ucomieq (v4sf, v4sf)
11738 int __builtin_ia32_ucomineq (v4sf, v4sf)
11739 int __builtin_ia32_ucomilt (v4sf, v4sf)
11740 int __builtin_ia32_ucomile (v4sf, v4sf)
11741 int __builtin_ia32_ucomigt (v4sf, v4sf)
11742 int __builtin_ia32_ucomige (v4sf, v4sf)
11743 v4sf __builtin_ia32_addps (v4sf, v4sf)
11744 v4sf __builtin_ia32_subps (v4sf, v4sf)
11745 v4sf __builtin_ia32_mulps (v4sf, v4sf)
11746 v4sf __builtin_ia32_divps (v4sf, v4sf)
11747 v4sf __builtin_ia32_addss (v4sf, v4sf)
11748 v4sf __builtin_ia32_subss (v4sf, v4sf)
11749 v4sf __builtin_ia32_mulss (v4sf, v4sf)
11750 v4sf __builtin_ia32_divss (v4sf, v4sf)
11751 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
11752 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
11753 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
11754 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
11755 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
11756 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
11757 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
11758 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
11759 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
11760 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
11761 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
11762 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
11763 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
11764 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
11765 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
11766 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
11767 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
11768 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
11769 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
11770 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
11771 v4sf __builtin_ia32_maxps (v4sf, v4sf)
11772 v4sf __builtin_ia32_maxss (v4sf, v4sf)
11773 v4sf __builtin_ia32_minps (v4sf, v4sf)
11774 v4sf __builtin_ia32_minss (v4sf, v4sf)
11775 v4sf __builtin_ia32_andps (v4sf, v4sf)
11776 v4sf __builtin_ia32_andnps (v4sf, v4sf)
11777 v4sf __builtin_ia32_orps (v4sf, v4sf)
11778 v4sf __builtin_ia32_xorps (v4sf, v4sf)
11779 v4sf __builtin_ia32_movss (v4sf, v4sf)
11780 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
11781 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
11782 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
11783 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
11784 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
11785 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
11786 v2si __builtin_ia32_cvtps2pi (v4sf)
11787 int __builtin_ia32_cvtss2si (v4sf)
11788 v2si __builtin_ia32_cvttps2pi (v4sf)
11789 int __builtin_ia32_cvttss2si (v4sf)
11790 v4sf __builtin_ia32_rcpps (v4sf)
11791 v4sf __builtin_ia32_rsqrtps (v4sf)
11792 v4sf __builtin_ia32_sqrtps (v4sf)
11793 v4sf __builtin_ia32_rcpss (v4sf)
11794 v4sf __builtin_ia32_rsqrtss (v4sf)
11795 v4sf __builtin_ia32_sqrtss (v4sf)
11796 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
11797 void __builtin_ia32_movntps (float *, v4sf)
11798 int __builtin_ia32_movmskps (v4sf)
11799 @end smallexample
11800
11801 The following built-in functions are available when @option{-msse} is used.
11802
11803 @table @code
11804 @item v4sf __builtin_ia32_loadups (float *)
11805 Generates the @code{movups} machine instruction as a load from memory.
11806 @item void __builtin_ia32_storeups (float *, v4sf)
11807 Generates the @code{movups} machine instruction as a store to memory.
11808 @item v4sf __builtin_ia32_loadss (float *)
11809 Generates the @code{movss} machine instruction as a load from memory.
11810 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
11811 Generates the @code{movhps} machine instruction as a load from memory.
11812 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
11813 Generates the @code{movlps} machine instruction as a load from memory
11814 @item void __builtin_ia32_storehps (v2sf *, v4sf)
11815 Generates the @code{movhps} machine instruction as a store to memory.
11816 @item void __builtin_ia32_storelps (v2sf *, v4sf)
11817 Generates the @code{movlps} machine instruction as a store to memory.
11818 @end table
11819
11820 The following built-in functions are available when @option{-msse2} is used.
11821 All of them generate the machine instruction that is part of the name.
11822
11823 @smallexample
11824 int __builtin_ia32_comisdeq (v2df, v2df)
11825 int __builtin_ia32_comisdlt (v2df, v2df)
11826 int __builtin_ia32_comisdle (v2df, v2df)
11827 int __builtin_ia32_comisdgt (v2df, v2df)
11828 int __builtin_ia32_comisdge (v2df, v2df)
11829 int __builtin_ia32_comisdneq (v2df, v2df)
11830 int __builtin_ia32_ucomisdeq (v2df, v2df)
11831 int __builtin_ia32_ucomisdlt (v2df, v2df)
11832 int __builtin_ia32_ucomisdle (v2df, v2df)
11833 int __builtin_ia32_ucomisdgt (v2df, v2df)
11834 int __builtin_ia32_ucomisdge (v2df, v2df)
11835 int __builtin_ia32_ucomisdneq (v2df, v2df)
11836 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
11837 v2df __builtin_ia32_cmpltpd (v2df, v2df)
11838 v2df __builtin_ia32_cmplepd (v2df, v2df)
11839 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
11840 v2df __builtin_ia32_cmpgepd (v2df, v2df)
11841 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
11842 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
11843 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
11844 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
11845 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
11846 v2df __builtin_ia32_cmpngepd (v2df, v2df)
11847 v2df __builtin_ia32_cmpordpd (v2df, v2df)
11848 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
11849 v2df __builtin_ia32_cmpltsd (v2df, v2df)
11850 v2df __builtin_ia32_cmplesd (v2df, v2df)
11851 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
11852 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
11853 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
11854 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
11855 v2df __builtin_ia32_cmpordsd (v2df, v2df)
11856 v2di __builtin_ia32_paddq (v2di, v2di)
11857 v2di __builtin_ia32_psubq (v2di, v2di)
11858 v2df __builtin_ia32_addpd (v2df, v2df)
11859 v2df __builtin_ia32_subpd (v2df, v2df)
11860 v2df __builtin_ia32_mulpd (v2df, v2df)
11861 v2df __builtin_ia32_divpd (v2df, v2df)
11862 v2df __builtin_ia32_addsd (v2df, v2df)
11863 v2df __builtin_ia32_subsd (v2df, v2df)
11864 v2df __builtin_ia32_mulsd (v2df, v2df)
11865 v2df __builtin_ia32_divsd (v2df, v2df)
11866 v2df __builtin_ia32_minpd (v2df, v2df)
11867 v2df __builtin_ia32_maxpd (v2df, v2df)
11868 v2df __builtin_ia32_minsd (v2df, v2df)
11869 v2df __builtin_ia32_maxsd (v2df, v2df)
11870 v2df __builtin_ia32_andpd (v2df, v2df)
11871 v2df __builtin_ia32_andnpd (v2df, v2df)
11872 v2df __builtin_ia32_orpd (v2df, v2df)
11873 v2df __builtin_ia32_xorpd (v2df, v2df)
11874 v2df __builtin_ia32_movsd (v2df, v2df)
11875 v2df __builtin_ia32_unpckhpd (v2df, v2df)
11876 v2df __builtin_ia32_unpcklpd (v2df, v2df)
11877 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
11878 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
11879 v4si __builtin_ia32_paddd128 (v4si, v4si)
11880 v2di __builtin_ia32_paddq128 (v2di, v2di)
11881 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
11882 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
11883 v4si __builtin_ia32_psubd128 (v4si, v4si)
11884 v2di __builtin_ia32_psubq128 (v2di, v2di)
11885 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
11886 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
11887 v2di __builtin_ia32_pand128 (v2di, v2di)
11888 v2di __builtin_ia32_pandn128 (v2di, v2di)
11889 v2di __builtin_ia32_por128 (v2di, v2di)
11890 v2di __builtin_ia32_pxor128 (v2di, v2di)
11891 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
11892 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
11893 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
11894 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
11895 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
11896 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
11897 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
11898 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
11899 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
11900 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
11901 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
11902 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
11903 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
11904 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
11905 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
11906 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
11907 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
11908 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
11909 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
11910 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
11911 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
11912 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
11913 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
11914 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
11915 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
11916 v2df __builtin_ia32_loadupd (double *)
11917 void __builtin_ia32_storeupd (double *, v2df)
11918 v2df __builtin_ia32_loadhpd (v2df, double const *)
11919 v2df __builtin_ia32_loadlpd (v2df, double const *)
11920 int __builtin_ia32_movmskpd (v2df)
11921 int __builtin_ia32_pmovmskb128 (v16qi)
11922 void __builtin_ia32_movnti (int *, int)
11923 void __builtin_ia32_movnti64 (long long int *, long long int)
11924 void __builtin_ia32_movntpd (double *, v2df)
11925 void __builtin_ia32_movntdq (v2df *, v2df)
11926 v4si __builtin_ia32_pshufd (v4si, int)
11927 v8hi __builtin_ia32_pshuflw (v8hi, int)
11928 v8hi __builtin_ia32_pshufhw (v8hi, int)
11929 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
11930 v2df __builtin_ia32_sqrtpd (v2df)
11931 v2df __builtin_ia32_sqrtsd (v2df)
11932 v2df __builtin_ia32_shufpd (v2df, v2df, int)
11933 v2df __builtin_ia32_cvtdq2pd (v4si)
11934 v4sf __builtin_ia32_cvtdq2ps (v4si)
11935 v4si __builtin_ia32_cvtpd2dq (v2df)
11936 v2si __builtin_ia32_cvtpd2pi (v2df)
11937 v4sf __builtin_ia32_cvtpd2ps (v2df)
11938 v4si __builtin_ia32_cvttpd2dq (v2df)
11939 v2si __builtin_ia32_cvttpd2pi (v2df)
11940 v2df __builtin_ia32_cvtpi2pd (v2si)
11941 int __builtin_ia32_cvtsd2si (v2df)
11942 int __builtin_ia32_cvttsd2si (v2df)
11943 long long __builtin_ia32_cvtsd2si64 (v2df)
11944 long long __builtin_ia32_cvttsd2si64 (v2df)
11945 v4si __builtin_ia32_cvtps2dq (v4sf)
11946 v2df __builtin_ia32_cvtps2pd (v4sf)
11947 v4si __builtin_ia32_cvttps2dq (v4sf)
11948 v2df __builtin_ia32_cvtsi2sd (v2df, int)
11949 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
11950 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
11951 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
11952 void __builtin_ia32_clflush (const void *)
11953 void __builtin_ia32_lfence (void)
11954 void __builtin_ia32_mfence (void)
11955 v16qi __builtin_ia32_loaddqu (const char *)
11956 void __builtin_ia32_storedqu (char *, v16qi)
11957 v1di __builtin_ia32_pmuludq (v2si, v2si)
11958 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
11959 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
11960 v4si __builtin_ia32_pslld128 (v4si, v4si)
11961 v2di __builtin_ia32_psllq128 (v2di, v2di)
11962 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
11963 v4si __builtin_ia32_psrld128 (v4si, v4si)
11964 v2di __builtin_ia32_psrlq128 (v2di, v2di)
11965 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
11966 v4si __builtin_ia32_psrad128 (v4si, v4si)
11967 v2di __builtin_ia32_pslldqi128 (v2di, int)
11968 v8hi __builtin_ia32_psllwi128 (v8hi, int)
11969 v4si __builtin_ia32_pslldi128 (v4si, int)
11970 v2di __builtin_ia32_psllqi128 (v2di, int)
11971 v2di __builtin_ia32_psrldqi128 (v2di, int)
11972 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
11973 v4si __builtin_ia32_psrldi128 (v4si, int)
11974 v2di __builtin_ia32_psrlqi128 (v2di, int)
11975 v8hi __builtin_ia32_psrawi128 (v8hi, int)
11976 v4si __builtin_ia32_psradi128 (v4si, int)
11977 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
11978 v2di __builtin_ia32_movq128 (v2di)
11979 @end smallexample
11980
11981 The following built-in functions are available when @option{-msse3} is used.
11982 All of them generate the machine instruction that is part of the name.
11983
11984 @smallexample
11985 v2df __builtin_ia32_addsubpd (v2df, v2df)
11986 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
11987 v2df __builtin_ia32_haddpd (v2df, v2df)
11988 v4sf __builtin_ia32_haddps (v4sf, v4sf)
11989 v2df __builtin_ia32_hsubpd (v2df, v2df)
11990 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
11991 v16qi __builtin_ia32_lddqu (char const *)
11992 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
11993 v4sf __builtin_ia32_movshdup (v4sf)
11994 v4sf __builtin_ia32_movsldup (v4sf)
11995 void __builtin_ia32_mwait (unsigned int, unsigned int)
11996 @end smallexample
11997
11998 The following built-in functions are available when @option{-mssse3} is used.
11999 All of them generate the machine instruction that is part of the name.
12000
12001 @smallexample
12002 v2si __builtin_ia32_phaddd (v2si, v2si)
12003 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
12004 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
12005 v2si __builtin_ia32_phsubd (v2si, v2si)
12006 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
12007 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
12008 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
12009 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
12010 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
12011 v8qi __builtin_ia32_psignb (v8qi, v8qi)
12012 v2si __builtin_ia32_psignd (v2si, v2si)
12013 v4hi __builtin_ia32_psignw (v4hi, v4hi)
12014 v1di __builtin_ia32_palignr (v1di, v1di, int)
12015 v8qi __builtin_ia32_pabsb (v8qi)
12016 v2si __builtin_ia32_pabsd (v2si)
12017 v4hi __builtin_ia32_pabsw (v4hi)
12018 @end smallexample
12019
12020 The following built-in functions are available when @option{-mssse3} is used.
12021 All of them generate the machine instruction that is part of the name.
12022
12023 @smallexample
12024 v4si __builtin_ia32_phaddd128 (v4si, v4si)
12025 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
12026 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
12027 v4si __builtin_ia32_phsubd128 (v4si, v4si)
12028 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
12029 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
12030 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
12031 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
12032 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
12033 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
12034 v4si __builtin_ia32_psignd128 (v4si, v4si)
12035 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
12036 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
12037 v16qi __builtin_ia32_pabsb128 (v16qi)
12038 v4si __builtin_ia32_pabsd128 (v4si)
12039 v8hi __builtin_ia32_pabsw128 (v8hi)
12040 @end smallexample
12041
12042 The following built-in functions are available when @option{-msse4.1} is
12043 used. All of them generate the machine instruction that is part of the
12044 name.
12045
12046 @smallexample
12047 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
12048 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
12049 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
12050 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
12051 v2df __builtin_ia32_dppd (v2df, v2df, const int)
12052 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
12053 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
12054 v2di __builtin_ia32_movntdqa (v2di *);
12055 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
12056 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
12057 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
12058 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
12059 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
12060 v8hi __builtin_ia32_phminposuw128 (v8hi)
12061 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
12062 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
12063 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
12064 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
12065 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
12066 v4si __builtin_ia32_pminsd128 (v4si, v4si)
12067 v4si __builtin_ia32_pminud128 (v4si, v4si)
12068 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
12069 v4si __builtin_ia32_pmovsxbd128 (v16qi)
12070 v2di __builtin_ia32_pmovsxbq128 (v16qi)
12071 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
12072 v2di __builtin_ia32_pmovsxdq128 (v4si)
12073 v4si __builtin_ia32_pmovsxwd128 (v8hi)
12074 v2di __builtin_ia32_pmovsxwq128 (v8hi)
12075 v4si __builtin_ia32_pmovzxbd128 (v16qi)
12076 v2di __builtin_ia32_pmovzxbq128 (v16qi)
12077 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
12078 v2di __builtin_ia32_pmovzxdq128 (v4si)
12079 v4si __builtin_ia32_pmovzxwd128 (v8hi)
12080 v2di __builtin_ia32_pmovzxwq128 (v8hi)
12081 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
12082 v4si __builtin_ia32_pmulld128 (v4si, v4si)
12083 int __builtin_ia32_ptestc128 (v2di, v2di)
12084 int __builtin_ia32_ptestnzc128 (v2di, v2di)
12085 int __builtin_ia32_ptestz128 (v2di, v2di)
12086 v2df __builtin_ia32_roundpd (v2df, const int)
12087 v4sf __builtin_ia32_roundps (v4sf, const int)
12088 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
12089 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
12090 @end smallexample
12091
12092 The following built-in functions are available when @option{-msse4.1} is
12093 used.
12094
12095 @table @code
12096 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
12097 Generates the @code{insertps} machine instruction.
12098 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
12099 Generates the @code{pextrb} machine instruction.
12100 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
12101 Generates the @code{pinsrb} machine instruction.
12102 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
12103 Generates the @code{pinsrd} machine instruction.
12104 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
12105 Generates the @code{pinsrq} machine instruction in 64bit mode.
12106 @end table
12107
12108 The following built-in functions are changed to generate new SSE4.1
12109 instructions when @option{-msse4.1} is used.
12110
12111 @table @code
12112 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
12113 Generates the @code{extractps} machine instruction.
12114 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
12115 Generates the @code{pextrd} machine instruction.
12116 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
12117 Generates the @code{pextrq} machine instruction in 64bit mode.
12118 @end table
12119
12120 The following built-in functions are available when @option{-msse4.2} is
12121 used. All of them generate the machine instruction that is part of the
12122 name.
12123
12124 @smallexample
12125 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
12126 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
12127 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
12128 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
12129 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
12130 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
12131 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
12132 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
12133 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
12134 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
12135 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
12136 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
12137 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
12138 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
12139 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
12140 @end smallexample
12141
12142 The following built-in functions are available when @option{-msse4.2} is
12143 used.
12144
12145 @table @code
12146 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
12147 Generates the @code{crc32b} machine instruction.
12148 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
12149 Generates the @code{crc32w} machine instruction.
12150 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
12151 Generates the @code{crc32l} machine instruction.
12152 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
12153 Generates the @code{crc32q} machine instruction.
12154 @end table
12155
12156 The following built-in functions are changed to generate new SSE4.2
12157 instructions when @option{-msse4.2} is used.
12158
12159 @table @code
12160 @item int __builtin_popcount (unsigned int)
12161 Generates the @code{popcntl} machine instruction.
12162 @item int __builtin_popcountl (unsigned long)
12163 Generates the @code{popcntl} or @code{popcntq} machine instruction,
12164 depending on the size of @code{unsigned long}.
12165 @item int __builtin_popcountll (unsigned long long)
12166 Generates the @code{popcntq} machine instruction.
12167 @end table
12168
12169 The following built-in functions are available when @option{-mavx} is
12170 used. All of them generate the machine instruction that is part of the
12171 name.
12172
12173 @smallexample
12174 v4df __builtin_ia32_addpd256 (v4df,v4df)
12175 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
12176 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
12177 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
12178 v4df __builtin_ia32_andnpd256 (v4df,v4df)
12179 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
12180 v4df __builtin_ia32_andpd256 (v4df,v4df)
12181 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
12182 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
12183 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
12184 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
12185 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
12186 v2df __builtin_ia32_cmppd (v2df,v2df,int)
12187 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
12188 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
12189 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
12190 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
12191 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
12192 v4df __builtin_ia32_cvtdq2pd256 (v4si)
12193 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
12194 v4si __builtin_ia32_cvtpd2dq256 (v4df)
12195 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
12196 v8si __builtin_ia32_cvtps2dq256 (v8sf)
12197 v4df __builtin_ia32_cvtps2pd256 (v4sf)
12198 v4si __builtin_ia32_cvttpd2dq256 (v4df)
12199 v8si __builtin_ia32_cvttps2dq256 (v8sf)
12200 v4df __builtin_ia32_divpd256 (v4df,v4df)
12201 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
12202 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
12203 v4df __builtin_ia32_haddpd256 (v4df,v4df)
12204 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
12205 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
12206 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
12207 v32qi __builtin_ia32_lddqu256 (pcchar)
12208 v32qi __builtin_ia32_loaddqu256 (pcchar)
12209 v4df __builtin_ia32_loadupd256 (pcdouble)
12210 v8sf __builtin_ia32_loadups256 (pcfloat)
12211 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
12212 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
12213 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
12214 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
12215 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
12216 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
12217 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
12218 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
12219 v4df __builtin_ia32_maxpd256 (v4df,v4df)
12220 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
12221 v4df __builtin_ia32_minpd256 (v4df,v4df)
12222 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
12223 v4df __builtin_ia32_movddup256 (v4df)
12224 int __builtin_ia32_movmskpd256 (v4df)
12225 int __builtin_ia32_movmskps256 (v8sf)
12226 v8sf __builtin_ia32_movshdup256 (v8sf)
12227 v8sf __builtin_ia32_movsldup256 (v8sf)
12228 v4df __builtin_ia32_mulpd256 (v4df,v4df)
12229 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
12230 v4df __builtin_ia32_orpd256 (v4df,v4df)
12231 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
12232 v2df __builtin_ia32_pd_pd256 (v4df)
12233 v4df __builtin_ia32_pd256_pd (v2df)
12234 v4sf __builtin_ia32_ps_ps256 (v8sf)
12235 v8sf __builtin_ia32_ps256_ps (v4sf)
12236 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
12237 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
12238 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
12239 v8sf __builtin_ia32_rcpps256 (v8sf)
12240 v4df __builtin_ia32_roundpd256 (v4df,int)
12241 v8sf __builtin_ia32_roundps256 (v8sf,int)
12242 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
12243 v8sf __builtin_ia32_rsqrtps256 (v8sf)
12244 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
12245 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
12246 v4si __builtin_ia32_si_si256 (v8si)
12247 v8si __builtin_ia32_si256_si (v4si)
12248 v4df __builtin_ia32_sqrtpd256 (v4df)
12249 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
12250 v8sf __builtin_ia32_sqrtps256 (v8sf)
12251 void __builtin_ia32_storedqu256 (pchar,v32qi)
12252 void __builtin_ia32_storeupd256 (pdouble,v4df)
12253 void __builtin_ia32_storeups256 (pfloat,v8sf)
12254 v4df __builtin_ia32_subpd256 (v4df,v4df)
12255 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
12256 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
12257 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
12258 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
12259 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
12260 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
12261 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
12262 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
12263 v4sf __builtin_ia32_vbroadcastss (pcfloat)
12264 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
12265 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
12266 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
12267 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
12268 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
12269 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
12270 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
12271 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
12272 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
12273 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
12274 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
12275 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
12276 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
12277 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
12278 v2df __builtin_ia32_vpermilpd (v2df,int)
12279 v4df __builtin_ia32_vpermilpd256 (v4df,int)
12280 v4sf __builtin_ia32_vpermilps (v4sf,int)
12281 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
12282 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
12283 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
12284 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
12285 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
12286 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
12287 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
12288 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
12289 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
12290 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
12291 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
12292 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
12293 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
12294 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
12295 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
12296 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
12297 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
12298 void __builtin_ia32_vzeroall (void)
12299 void __builtin_ia32_vzeroupper (void)
12300 v4df __builtin_ia32_xorpd256 (v4df,v4df)
12301 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
12302 @end smallexample
12303
12304 The following built-in functions are available when @option{-mavx2} is
12305 used. All of them generate the machine instruction that is part of the
12306 name.
12307
12308 @smallexample
12309 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
12310 v32qi __builtin_ia32_pabsb256 (v32qi)
12311 v16hi __builtin_ia32_pabsw256 (v16hi)
12312 v8si __builtin_ia32_pabsd256 (v8si)
12313 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
12314 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
12315 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
12316 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
12317 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
12318 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
12319 v8si __builtin_ia32_paddd256 (v8si,v8si)
12320 v4di __builtin_ia32_paddq256 (v4di,v4di)
12321 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
12322 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
12323 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
12324 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
12325 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
12326 v4di __builtin_ia32_andsi256 (v4di,v4di)
12327 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
12328 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
12329 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
12330 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
12331 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
12332 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
12333 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
12334 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
12335 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
12336 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
12337 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
12338 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
12339 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
12340 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
12341 v8si __builtin_ia32_phaddd256 (v8si,v8si)
12342 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
12343 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
12344 v8si __builtin_ia32_phsubd256 (v8si,v8si)
12345 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
12346 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
12347 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
12348 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
12349 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
12350 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
12351 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
12352 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
12353 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
12354 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
12355 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
12356 v8si __builtin_ia32_pminsd256 (v8si,v8si)
12357 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
12358 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
12359 v8si __builtin_ia32_pminud256 (v8si,v8si)
12360 int __builtin_ia32_pmovmskb256 (v32qi)
12361 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
12362 v8si __builtin_ia32_pmovsxbd256 (v16qi)
12363 v4di __builtin_ia32_pmovsxbq256 (v16qi)
12364 v8si __builtin_ia32_pmovsxwd256 (v8hi)
12365 v4di __builtin_ia32_pmovsxwq256 (v8hi)
12366 v4di __builtin_ia32_pmovsxdq256 (v4si)
12367 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
12368 v8si __builtin_ia32_pmovzxbd256 (v16qi)
12369 v4di __builtin_ia32_pmovzxbq256 (v16qi)
12370 v8si __builtin_ia32_pmovzxwd256 (v8hi)
12371 v4di __builtin_ia32_pmovzxwq256 (v8hi)
12372 v4di __builtin_ia32_pmovzxdq256 (v4si)
12373 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
12374 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
12375 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
12376 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
12377 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
12378 v8si __builtin_ia32_pmulld256 (v8si,v8si)
12379 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
12380 v4di __builtin_ia32_por256 (v4di,v4di)
12381 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
12382 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
12383 v8si __builtin_ia32_pshufd256 (v8si,int)
12384 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
12385 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
12386 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
12387 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
12388 v8si __builtin_ia32_psignd256 (v8si,v8si)
12389 v4di __builtin_ia32_pslldqi256 (v4di,int)
12390 v16hi __builtin_ia32_psllwi256 (16hi,int)
12391 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
12392 v8si __builtin_ia32_pslldi256 (v8si,int)
12393 v8si __builtin_ia32_pslld256(v8si,v4si)
12394 v4di __builtin_ia32_psllqi256 (v4di,int)
12395 v4di __builtin_ia32_psllq256(v4di,v2di)
12396 v16hi __builtin_ia32_psrawi256 (v16hi,int)
12397 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
12398 v8si __builtin_ia32_psradi256 (v8si,int)
12399 v8si __builtin_ia32_psrad256 (v8si,v4si)
12400 v4di __builtin_ia32_psrldqi256 (v4di, int)
12401 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
12402 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
12403 v8si __builtin_ia32_psrldi256 (v8si,int)
12404 v8si __builtin_ia32_psrld256 (v8si,v4si)
12405 v4di __builtin_ia32_psrlqi256 (v4di,int)
12406 v4di __builtin_ia32_psrlq256(v4di,v2di)
12407 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
12408 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
12409 v8si __builtin_ia32_psubd256 (v8si,v8si)
12410 v4di __builtin_ia32_psubq256 (v4di,v4di)
12411 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
12412 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
12413 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
12414 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
12415 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
12416 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
12417 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
12418 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
12419 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
12420 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
12421 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
12422 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
12423 v4di __builtin_ia32_pxor256 (v4di,v4di)
12424 v4di __builtin_ia32_movntdqa256 (pv4di)
12425 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
12426 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
12427 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
12428 v4di __builtin_ia32_vbroadcastsi256 (v2di)
12429 v4si __builtin_ia32_pblendd128 (v4si,v4si)
12430 v8si __builtin_ia32_pblendd256 (v8si,v8si)
12431 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
12432 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
12433 v8si __builtin_ia32_pbroadcastd256 (v4si)
12434 v4di __builtin_ia32_pbroadcastq256 (v2di)
12435 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
12436 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
12437 v4si __builtin_ia32_pbroadcastd128 (v4si)
12438 v2di __builtin_ia32_pbroadcastq128 (v2di)
12439 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
12440 v4df __builtin_ia32_permdf256 (v4df,int)
12441 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
12442 v4di __builtin_ia32_permdi256 (v4di,int)
12443 v4di __builtin_ia32_permti256 (v4di,v4di,int)
12444 v4di __builtin_ia32_extract128i256 (v4di,int)
12445 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
12446 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
12447 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
12448 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
12449 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
12450 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
12451 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
12452 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
12453 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
12454 v8si __builtin_ia32_psllv8si (v8si,v8si)
12455 v4si __builtin_ia32_psllv4si (v4si,v4si)
12456 v4di __builtin_ia32_psllv4di (v4di,v4di)
12457 v2di __builtin_ia32_psllv2di (v2di,v2di)
12458 v8si __builtin_ia32_psrav8si (v8si,v8si)
12459 v4si __builtin_ia32_psrav4si (v4si,v4si)
12460 v8si __builtin_ia32_psrlv8si (v8si,v8si)
12461 v4si __builtin_ia32_psrlv4si (v4si,v4si)
12462 v4di __builtin_ia32_psrlv4di (v4di,v4di)
12463 v2di __builtin_ia32_psrlv2di (v2di,v2di)
12464 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
12465 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
12466 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
12467 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
12468 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
12469 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
12470 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
12471 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
12472 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
12473 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
12474 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
12475 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
12476 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
12477 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
12478 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
12479 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
12480 @end smallexample
12481
12482 The following built-in functions are available when @option{-maes} is
12483 used. All of them generate the machine instruction that is part of the
12484 name.
12485
12486 @smallexample
12487 v2di __builtin_ia32_aesenc128 (v2di, v2di)
12488 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
12489 v2di __builtin_ia32_aesdec128 (v2di, v2di)
12490 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
12491 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
12492 v2di __builtin_ia32_aesimc128 (v2di)
12493 @end smallexample
12494
12495 The following built-in function is available when @option{-mpclmul} is
12496 used.
12497
12498 @table @code
12499 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
12500 Generates the @code{pclmulqdq} machine instruction.
12501 @end table
12502
12503 The following built-in function is available when @option{-mfsgsbase} is
12504 used. All of them generate the machine instruction that is part of the
12505 name.
12506
12507 @smallexample
12508 unsigned int __builtin_ia32_rdfsbase32 (void)
12509 unsigned long long __builtin_ia32_rdfsbase64 (void)
12510 unsigned int __builtin_ia32_rdgsbase32 (void)
12511 unsigned long long __builtin_ia32_rdgsbase64 (void)
12512 void _writefsbase_u32 (unsigned int)
12513 void _writefsbase_u64 (unsigned long long)
12514 void _writegsbase_u32 (unsigned int)
12515 void _writegsbase_u64 (unsigned long long)
12516 @end smallexample
12517
12518 The following built-in function is available when @option{-mrdrnd} is
12519 used. All of them generate the machine instruction that is part of the
12520 name.
12521
12522 @smallexample
12523 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
12524 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
12525 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
12526 @end smallexample
12527
12528 The following built-in functions are available when @option{-msse4a} is used.
12529 All of them generate the machine instruction that is part of the name.
12530
12531 @smallexample
12532 void __builtin_ia32_movntsd (double *, v2df)
12533 void __builtin_ia32_movntss (float *, v4sf)
12534 v2di __builtin_ia32_extrq (v2di, v16qi)
12535 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
12536 v2di __builtin_ia32_insertq (v2di, v2di)
12537 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
12538 @end smallexample
12539
12540 The following built-in functions are available when @option{-mxop} is used.
12541 @smallexample
12542 v2df __builtin_ia32_vfrczpd (v2df)
12543 v4sf __builtin_ia32_vfrczps (v4sf)
12544 v2df __builtin_ia32_vfrczsd (v2df)
12545 v4sf __builtin_ia32_vfrczss (v4sf)
12546 v4df __builtin_ia32_vfrczpd256 (v4df)
12547 v8sf __builtin_ia32_vfrczps256 (v8sf)
12548 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
12549 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
12550 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
12551 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
12552 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
12553 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
12554 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
12555 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
12556 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
12557 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
12558 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
12559 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
12560 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
12561 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
12562 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12563 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
12564 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
12565 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
12566 v4si __builtin_ia32_vpcomequd (v4si, v4si)
12567 v2di __builtin_ia32_vpcomequq (v2di, v2di)
12568 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
12569 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12570 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
12571 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
12572 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
12573 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
12574 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
12575 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
12576 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
12577 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
12578 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
12579 v4si __builtin_ia32_vpcomged (v4si, v4si)
12580 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
12581 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
12582 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
12583 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
12584 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
12585 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
12586 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
12587 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
12588 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
12589 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
12590 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
12591 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
12592 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
12593 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
12594 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
12595 v4si __builtin_ia32_vpcomled (v4si, v4si)
12596 v2di __builtin_ia32_vpcomleq (v2di, v2di)
12597 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
12598 v4si __builtin_ia32_vpcomleud (v4si, v4si)
12599 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
12600 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
12601 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
12602 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
12603 v4si __builtin_ia32_vpcomltd (v4si, v4si)
12604 v2di __builtin_ia32_vpcomltq (v2di, v2di)
12605 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
12606 v4si __builtin_ia32_vpcomltud (v4si, v4si)
12607 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
12608 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
12609 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
12610 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
12611 v4si __builtin_ia32_vpcomned (v4si, v4si)
12612 v2di __builtin_ia32_vpcomneq (v2di, v2di)
12613 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
12614 v4si __builtin_ia32_vpcomneud (v4si, v4si)
12615 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
12616 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
12617 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
12618 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
12619 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
12620 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
12621 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
12622 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
12623 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
12624 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
12625 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
12626 v4si __builtin_ia32_vphaddbd (v16qi)
12627 v2di __builtin_ia32_vphaddbq (v16qi)
12628 v8hi __builtin_ia32_vphaddbw (v16qi)
12629 v2di __builtin_ia32_vphadddq (v4si)
12630 v4si __builtin_ia32_vphaddubd (v16qi)
12631 v2di __builtin_ia32_vphaddubq (v16qi)
12632 v8hi __builtin_ia32_vphaddubw (v16qi)
12633 v2di __builtin_ia32_vphaddudq (v4si)
12634 v4si __builtin_ia32_vphadduwd (v8hi)
12635 v2di __builtin_ia32_vphadduwq (v8hi)
12636 v4si __builtin_ia32_vphaddwd (v8hi)
12637 v2di __builtin_ia32_vphaddwq (v8hi)
12638 v8hi __builtin_ia32_vphsubbw (v16qi)
12639 v2di __builtin_ia32_vphsubdq (v4si)
12640 v4si __builtin_ia32_vphsubwd (v8hi)
12641 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
12642 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
12643 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
12644 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
12645 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
12646 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
12647 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
12648 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
12649 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
12650 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
12651 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
12652 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
12653 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
12654 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
12655 v4si __builtin_ia32_vprotd (v4si, v4si)
12656 v2di __builtin_ia32_vprotq (v2di, v2di)
12657 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
12658 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
12659 v4si __builtin_ia32_vpshad (v4si, v4si)
12660 v2di __builtin_ia32_vpshaq (v2di, v2di)
12661 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
12662 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
12663 v4si __builtin_ia32_vpshld (v4si, v4si)
12664 v2di __builtin_ia32_vpshlq (v2di, v2di)
12665 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
12666 @end smallexample
12667
12668 The following built-in functions are available when @option{-mfma4} is used.
12669 All of them generate the machine instruction that is part of the name.
12670
12671 @smallexample
12672 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
12673 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
12674 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
12675 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
12676 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
12677 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
12678 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
12679 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
12680 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
12681 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
12682 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
12683 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
12684 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
12685 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
12686 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
12687 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
12688 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
12689 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
12690 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
12691 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
12692 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
12693 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
12694 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
12695 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
12696 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
12697 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
12698 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
12699 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
12700 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
12701 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
12702 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
12703 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
12704
12705 @end smallexample
12706
12707 The following built-in functions are available when @option{-mlwp} is used.
12708
12709 @smallexample
12710 void __builtin_ia32_llwpcb16 (void *);
12711 void __builtin_ia32_llwpcb32 (void *);
12712 void __builtin_ia32_llwpcb64 (void *);
12713 void * __builtin_ia32_llwpcb16 (void);
12714 void * __builtin_ia32_llwpcb32 (void);
12715 void * __builtin_ia32_llwpcb64 (void);
12716 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
12717 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
12718 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
12719 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
12720 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
12721 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
12722 @end smallexample
12723
12724 The following built-in functions are available when @option{-mbmi} is used.
12725 All of them generate the machine instruction that is part of the name.
12726 @smallexample
12727 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
12728 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
12729 @end smallexample
12730
12731 The following built-in functions are available when @option{-mbmi2} is used.
12732 All of them generate the machine instruction that is part of the name.
12733 @smallexample
12734 unsigned int _bzhi_u32 (unsigned int, unsigned int)
12735 unsigned int _pdep_u32 (unsigned int, unsigned int)
12736 unsigned int _pext_u32 (unsigned int, unsigned int)
12737 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
12738 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
12739 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
12740 @end smallexample
12741
12742 The following built-in functions are available when @option{-mlzcnt} is used.
12743 All of them generate the machine instruction that is part of the name.
12744 @smallexample
12745 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
12746 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
12747 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
12748 @end smallexample
12749
12750 The following built-in functions are available when @option{-mfxsr} is used.
12751 All of them generate the machine instruction that is part of the name.
12752 @smallexample
12753 void __builtin_ia32_fxsave (void *)
12754 void __builtin_ia32_fxrstor (void *)
12755 void __builtin_ia32_fxsave64 (void *)
12756 void __builtin_ia32_fxrstor64 (void *)
12757 @end smallexample
12758
12759 The following built-in functions are available when @option{-mxsave} is used.
12760 All of them generate the machine instruction that is part of the name.
12761 @smallexample
12762 void __builtin_ia32_xsave (void *, long long)
12763 void __builtin_ia32_xrstor (void *, long long)
12764 void __builtin_ia32_xsave64 (void *, long long)
12765 void __builtin_ia32_xrstor64 (void *, long long)
12766 @end smallexample
12767
12768 The following built-in functions are available when @option{-mxsaveopt} is used.
12769 All of them generate the machine instruction that is part of the name.
12770 @smallexample
12771 void __builtin_ia32_xsaveopt (void *, long long)
12772 void __builtin_ia32_xsaveopt64 (void *, long long)
12773 @end smallexample
12774
12775 The following built-in functions are available when @option{-mtbm} is used.
12776 Both of them generate the immediate form of the bextr machine instruction.
12777 @smallexample
12778 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
12779 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
12780 @end smallexample
12781
12782
12783 The following built-in functions are available when @option{-m3dnow} is used.
12784 All of them generate the machine instruction that is part of the name.
12785
12786 @smallexample
12787 void __builtin_ia32_femms (void)
12788 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
12789 v2si __builtin_ia32_pf2id (v2sf)
12790 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
12791 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
12792 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
12793 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
12794 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
12795 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
12796 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
12797 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
12798 v2sf __builtin_ia32_pfrcp (v2sf)
12799 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
12800 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
12801 v2sf __builtin_ia32_pfrsqrt (v2sf)
12802 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
12803 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
12804 v2sf __builtin_ia32_pi2fd (v2si)
12805 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
12806 @end smallexample
12807
12808 The following built-in functions are available when both @option{-m3dnow}
12809 and @option{-march=athlon} are used. All of them generate the machine
12810 instruction that is part of the name.
12811
12812 @smallexample
12813 v2si __builtin_ia32_pf2iw (v2sf)
12814 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
12815 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
12816 v2sf __builtin_ia32_pi2fw (v2si)
12817 v2sf __builtin_ia32_pswapdsf (v2sf)
12818 v2si __builtin_ia32_pswapdsi (v2si)
12819 @end smallexample
12820
12821 The following built-in functions are available when @option{-mrtm} is used
12822 They are used for restricted transactional memory. These are the internal
12823 low level functions. Normally the functions in
12824 @ref{X86 transactional memory intrinsics} should be used instead.
12825
12826 @smallexample
12827 int __builtin_ia32_xbegin ()
12828 void __builtin_ia32_xend ()
12829 void __builtin_ia32_xabort (status)
12830 int __builtin_ia32_xtest ()
12831 @end smallexample
12832
12833 @node X86 transactional memory intrinsics
12834 @subsection X86 transaction memory intrinsics
12835
12836 Hardware transactional memory intrinsics for i386. These allow to use
12837 memory transactions with RTM (Restricted Transactional Memory).
12838 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
12839 This support is enabled with the @option{-mrtm} option.
12840
12841 A memory transaction commits all changes to memory in an atomic way,
12842 as visible to other threads. If the transaction fails it is rolled back
12843 and all side effects discarded.
12844
12845 Generally there is no guarantee that a memory transaction ever succeeds
12846 and suitable fallback code always needs to be supplied.
12847
12848 @deftypefn {RTM Function} {unsigned} _xbegin ()
12849 Start a RTM (Restricted Transactional Memory) transaction.
12850 Returns _XBEGIN_STARTED when the transaction
12851 started successfully (note this is not 0, so the constant has to be
12852 explicitely tested). When the transaction aborts all side effects
12853 are undone and an abort code is returned. There is no guarantee
12854 any transaction ever succeeds, so there always needs to be a valid
12855 tested fallback path.
12856 @end deftypefn
12857
12858 @smallexample
12859 #include <immintrin.h>
12860
12861 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
12862 ... transaction code...
12863 _xend ();
12864 @} else @{
12865 ... non transactional fallback path...
12866 @}
12867 @end smallexample
12868
12869 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
12870
12871 @table @code
12872 @item _XABORT_EXPLICIT
12873 Transaction explicitely aborted with @code{_xabort}. The parameter passed
12874 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
12875 @item _XABORT_RETRY
12876 Transaction retry is possible.
12877 @item _XABORT_CONFLICT
12878 Transaction abort due to a memory conflict with another thread
12879 @item _XABORT_CAPACITY
12880 Transaction abort due to the transaction using too much memory
12881 @item _XABORT_DEBUG
12882 Transaction abort due to a debug trap
12883 @item _XABORT_NESTED
12884 Transaction abort in a inner nested transaction
12885 @end table
12886
12887 @deftypefn {RTM Function} {void} _xend ()
12888 Commit the current transaction. When no transaction is active this will
12889 fault. All memory side effects of the transactions will become visible
12890 to other threads in an atomic matter.
12891 @end deftypefn
12892
12893 @deftypefn {RTM Function} {int} _xtest ()
12894 Return a value not zero when a transaction is currently active, otherwise 0.
12895 @end deftypefn
12896
12897 @deftypefn {RTM Function} {void} _xabort (status)
12898 Abort the current transaction. When no transaction is active this is a no-op.
12899 status must be a 8bit constant, that is included in the status code returned
12900 by @code{_xbegin}
12901 @end deftypefn
12902
12903 @node MIPS DSP Built-in Functions
12904 @subsection MIPS DSP Built-in Functions
12905
12906 The MIPS DSP Application-Specific Extension (ASE) includes new
12907 instructions that are designed to improve the performance of DSP and
12908 media applications. It provides instructions that operate on packed
12909 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12910
12911 GCC supports MIPS DSP operations using both the generic
12912 vector extensions (@pxref{Vector Extensions}) and a collection of
12913 MIPS-specific built-in functions. Both kinds of support are
12914 enabled by the @option{-mdsp} command-line option.
12915
12916 Revision 2 of the ASE was introduced in the second half of 2006.
12917 This revision adds extra instructions to the original ASE, but is
12918 otherwise backwards-compatible with it. You can select revision 2
12919 using the command-line option @option{-mdspr2}; this option implies
12920 @option{-mdsp}.
12921
12922 The SCOUNT and POS bits of the DSP control register are global. The
12923 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12924 POS bits. During optimization, the compiler does not delete these
12925 instructions and it does not delete calls to functions containing
12926 these instructions.
12927
12928 At present, GCC only provides support for operations on 32-bit
12929 vectors. The vector type associated with 8-bit integer data is
12930 usually called @code{v4i8}, the vector type associated with Q7
12931 is usually called @code{v4q7}, the vector type associated with 16-bit
12932 integer data is usually called @code{v2i16}, and the vector type
12933 associated with Q15 is usually called @code{v2q15}. They can be
12934 defined in C as follows:
12935
12936 @smallexample
12937 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12938 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12939 typedef short v2i16 __attribute__ ((vector_size(4)));
12940 typedef short v2q15 __attribute__ ((vector_size(4)));
12941 @end smallexample
12942
12943 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12944 initialized in the same way as aggregates. For example:
12945
12946 @smallexample
12947 v4i8 a = @{1, 2, 3, 4@};
12948 v4i8 b;
12949 b = (v4i8) @{5, 6, 7, 8@};
12950
12951 v2q15 c = @{0x0fcb, 0x3a75@};
12952 v2q15 d;
12953 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12954 @end smallexample
12955
12956 @emph{Note:} The CPU's endianness determines the order in which values
12957 are packed. On little-endian targets, the first value is the least
12958 significant and the last value is the most significant. The opposite
12959 order applies to big-endian targets. For example, the code above
12960 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12961 and @code{4} on big-endian targets.
12962
12963 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12964 representation. As shown in this example, the integer representation
12965 of a Q7 value can be obtained by multiplying the fractional value by
12966 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
12967 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
12968 @code{0x1.0p31}.
12969
12970 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12971 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
12972 and @code{c} and @code{d} are @code{v2q15} values.
12973
12974 @multitable @columnfractions .50 .50
12975 @item C code @tab MIPS instruction
12976 @item @code{a + b} @tab @code{addu.qb}
12977 @item @code{c + d} @tab @code{addq.ph}
12978 @item @code{a - b} @tab @code{subu.qb}
12979 @item @code{c - d} @tab @code{subq.ph}
12980 @end multitable
12981
12982 The table below lists the @code{v2i16} operation for which
12983 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
12984 @code{v2i16} values.
12985
12986 @multitable @columnfractions .50 .50
12987 @item C code @tab MIPS instruction
12988 @item @code{e * f} @tab @code{mul.ph}
12989 @end multitable
12990
12991 It is easier to describe the DSP built-in functions if we first define
12992 the following types:
12993
12994 @smallexample
12995 typedef int q31;
12996 typedef int i32;
12997 typedef unsigned int ui32;
12998 typedef long long a64;
12999 @end smallexample
13000
13001 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13002 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13003 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
13004 @code{long long}, but we use @code{a64} to indicate values that are
13005 placed in one of the four DSP accumulators (@code{$ac0},
13006 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13007
13008 Also, some built-in functions prefer or require immediate numbers as
13009 parameters, because the corresponding DSP instructions accept both immediate
13010 numbers and register operands, or accept immediate numbers only. The
13011 immediate parameters are listed as follows.
13012
13013 @smallexample
13014 imm0_3: 0 to 3.
13015 imm0_7: 0 to 7.
13016 imm0_15: 0 to 15.
13017 imm0_31: 0 to 31.
13018 imm0_63: 0 to 63.
13019 imm0_255: 0 to 255.
13020 imm_n32_31: -32 to 31.
13021 imm_n512_511: -512 to 511.
13022 @end smallexample
13023
13024 The following built-in functions map directly to a particular MIPS DSP
13025 instruction. Please refer to the architecture specification
13026 for details on what each instruction does.
13027
13028 @smallexample
13029 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13030 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13031 q31 __builtin_mips_addq_s_w (q31, q31)
13032 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13033 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13034 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13035 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13036 q31 __builtin_mips_subq_s_w (q31, q31)
13037 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13038 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13039 i32 __builtin_mips_addsc (i32, i32)
13040 i32 __builtin_mips_addwc (i32, i32)
13041 i32 __builtin_mips_modsub (i32, i32)
13042 i32 __builtin_mips_raddu_w_qb (v4i8)
13043 v2q15 __builtin_mips_absq_s_ph (v2q15)
13044 q31 __builtin_mips_absq_s_w (q31)
13045 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13046 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13047 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13048 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13049 q31 __builtin_mips_preceq_w_phl (v2q15)
13050 q31 __builtin_mips_preceq_w_phr (v2q15)
13051 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13052 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13053 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13054 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13055 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13056 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13057 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13058 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13059 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13060 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13061 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13062 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13063 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13064 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13065 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13066 q31 __builtin_mips_shll_s_w (q31, i32)
13067 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13068 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13069 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13070 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13071 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13072 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13073 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13074 q31 __builtin_mips_shra_r_w (q31, i32)
13075 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13076 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13077 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13078 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13079 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13080 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13081 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13082 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13083 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13084 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13085 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13086 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13087 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13088 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13089 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13090 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13091 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13092 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13093 i32 __builtin_mips_bitrev (i32)
13094 i32 __builtin_mips_insv (i32, i32)
13095 v4i8 __builtin_mips_repl_qb (imm0_255)
13096 v4i8 __builtin_mips_repl_qb (i32)
13097 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13098 v2q15 __builtin_mips_repl_ph (i32)
13099 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13100 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13101 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13102 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13103 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13104 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13105 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13106 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13107 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13108 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13109 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13110 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13111 i32 __builtin_mips_extr_w (a64, imm0_31)
13112 i32 __builtin_mips_extr_w (a64, i32)
13113 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13114 i32 __builtin_mips_extr_s_h (a64, i32)
13115 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13116 i32 __builtin_mips_extr_rs_w (a64, i32)
13117 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13118 i32 __builtin_mips_extr_r_w (a64, i32)
13119 i32 __builtin_mips_extp (a64, imm0_31)
13120 i32 __builtin_mips_extp (a64, i32)
13121 i32 __builtin_mips_extpdp (a64, imm0_31)
13122 i32 __builtin_mips_extpdp (a64, i32)
13123 a64 __builtin_mips_shilo (a64, imm_n32_31)
13124 a64 __builtin_mips_shilo (a64, i32)
13125 a64 __builtin_mips_mthlip (a64, i32)
13126 void __builtin_mips_wrdsp (i32, imm0_63)
13127 i32 __builtin_mips_rddsp (imm0_63)
13128 i32 __builtin_mips_lbux (void *, i32)
13129 i32 __builtin_mips_lhx (void *, i32)
13130 i32 __builtin_mips_lwx (void *, i32)
13131 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13132 i32 __builtin_mips_bposge32 (void)
13133 a64 __builtin_mips_madd (a64, i32, i32);
13134 a64 __builtin_mips_maddu (a64, ui32, ui32);
13135 a64 __builtin_mips_msub (a64, i32, i32);
13136 a64 __builtin_mips_msubu (a64, ui32, ui32);
13137 a64 __builtin_mips_mult (i32, i32);
13138 a64 __builtin_mips_multu (ui32, ui32);
13139 @end smallexample
13140
13141 The following built-in functions map directly to a particular MIPS DSP REV 2
13142 instruction. Please refer to the architecture specification
13143 for details on what each instruction does.
13144
13145 @smallexample
13146 v4q7 __builtin_mips_absq_s_qb (v4q7);
13147 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13148 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13149 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13150 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13151 i32 __builtin_mips_append (i32, i32, imm0_31);
13152 i32 __builtin_mips_balign (i32, i32, imm0_3);
13153 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13154 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13155 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13156 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13157 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13158 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13159 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13160 q31 __builtin_mips_mulq_rs_w (q31, q31);
13161 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13162 q31 __builtin_mips_mulq_s_w (q31, q31);
13163 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13164 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13165 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13166 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13167 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13168 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13169 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13170 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13171 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13172 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13173 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13174 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13175 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13176 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13177 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13178 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13179 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13180 q31 __builtin_mips_addqh_w (q31, q31);
13181 q31 __builtin_mips_addqh_r_w (q31, q31);
13182 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13183 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13184 q31 __builtin_mips_subqh_w (q31, q31);
13185 q31 __builtin_mips_subqh_r_w (q31, q31);
13186 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13187 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13188 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13189 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13190 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13191 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13192 @end smallexample
13193
13194
13195 @node MIPS Paired-Single Support
13196 @subsection MIPS Paired-Single Support
13197
13198 The MIPS64 architecture includes a number of instructions that
13199 operate on pairs of single-precision floating-point values.
13200 Each pair is packed into a 64-bit floating-point register,
13201 with one element being designated the ``upper half'' and
13202 the other being designated the ``lower half''.
13203
13204 GCC supports paired-single operations using both the generic
13205 vector extensions (@pxref{Vector Extensions}) and a collection of
13206 MIPS-specific built-in functions. Both kinds of support are
13207 enabled by the @option{-mpaired-single} command-line option.
13208
13209 The vector type associated with paired-single values is usually
13210 called @code{v2sf}. It can be defined in C as follows:
13211
13212 @smallexample
13213 typedef float v2sf __attribute__ ((vector_size (8)));
13214 @end smallexample
13215
13216 @code{v2sf} values are initialized in the same way as aggregates.
13217 For example:
13218
13219 @smallexample
13220 v2sf a = @{1.5, 9.1@};
13221 v2sf b;
13222 float e, f;
13223 b = (v2sf) @{e, f@};
13224 @end smallexample
13225
13226 @emph{Note:} The CPU's endianness determines which value is stored in
13227 the upper half of a register and which value is stored in the lower half.
13228 On little-endian targets, the first value is the lower one and the second
13229 value is the upper one. The opposite order applies to big-endian targets.
13230 For example, the code above sets the lower half of @code{a} to
13231 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13232
13233 @node MIPS Loongson Built-in Functions
13234 @subsection MIPS Loongson Built-in Functions
13235
13236 GCC provides intrinsics to access the SIMD instructions provided by the
13237 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
13238 available after inclusion of the @code{loongson.h} header file,
13239 operate on the following 64-bit vector types:
13240
13241 @itemize
13242 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13243 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13244 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13245 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13246 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13247 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13248 @end itemize
13249
13250 The intrinsics provided are listed below; each is named after the
13251 machine instruction to which it corresponds, with suffixes added as
13252 appropriate to distinguish intrinsics that expand to the same machine
13253 instruction yet have different argument types. Refer to the architecture
13254 documentation for a description of the functionality of each
13255 instruction.
13256
13257 @smallexample
13258 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13259 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13260 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13261 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13262 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13263 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13264 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13265 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13266 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13267 uint64_t paddd_u (uint64_t s, uint64_t t);
13268 int64_t paddd_s (int64_t s, int64_t t);
13269 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13270 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13271 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13272 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13273 uint64_t pandn_ud (uint64_t s, uint64_t t);
13274 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13275 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13276 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13277 int64_t pandn_sd (int64_t s, int64_t t);
13278 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13279 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13280 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13281 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13282 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13283 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13284 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13285 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13286 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13287 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13288 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13289 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13290 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13291 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13292 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13293 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13294 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13295 uint16x4_t pextrh_u (uint16x4_t s, int field);
13296 int16x4_t pextrh_s (int16x4_t s, int field);
13297 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13298 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13299 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13300 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13301 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13302 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13303 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13304 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13305 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13306 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13307 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13308 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13309 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13310 uint8x8_t pmovmskb_u (uint8x8_t s);
13311 int8x8_t pmovmskb_s (int8x8_t s);
13312 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13313 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13314 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13315 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13316 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13317 uint16x4_t biadd (uint8x8_t s);
13318 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13319 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13320 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13321 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13322 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13323 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13324 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13325 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13326 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13327 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13328 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13329 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13330 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13331 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13332 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13333 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13334 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13335 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13336 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13337 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13338 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13339 uint64_t psubd_u (uint64_t s, uint64_t t);
13340 int64_t psubd_s (int64_t s, int64_t t);
13341 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13342 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13343 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13344 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13345 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13346 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13347 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13348 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13349 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13350 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13351 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13352 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13353 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13354 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13355 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13356 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13357 @end smallexample
13358
13359 @menu
13360 * Paired-Single Arithmetic::
13361 * Paired-Single Built-in Functions::
13362 * MIPS-3D Built-in Functions::
13363 @end menu
13364
13365 @node Paired-Single Arithmetic
13366 @subsubsection Paired-Single Arithmetic
13367
13368 The table below lists the @code{v2sf} operations for which hardware
13369 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
13370 values and @code{x} is an integral value.
13371
13372 @multitable @columnfractions .50 .50
13373 @item C code @tab MIPS instruction
13374 @item @code{a + b} @tab @code{add.ps}
13375 @item @code{a - b} @tab @code{sub.ps}
13376 @item @code{-a} @tab @code{neg.ps}
13377 @item @code{a * b} @tab @code{mul.ps}
13378 @item @code{a * b + c} @tab @code{madd.ps}
13379 @item @code{a * b - c} @tab @code{msub.ps}
13380 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13381 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13382 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13383 @end multitable
13384
13385 Note that the multiply-accumulate instructions can be disabled
13386 using the command-line option @code{-mno-fused-madd}.
13387
13388 @node Paired-Single Built-in Functions
13389 @subsubsection Paired-Single Built-in Functions
13390
13391 The following paired-single functions map directly to a particular
13392 MIPS instruction. Please refer to the architecture specification
13393 for details on what each instruction does.
13394
13395 @table @code
13396 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13397 Pair lower lower (@code{pll.ps}).
13398
13399 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13400 Pair upper lower (@code{pul.ps}).
13401
13402 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13403 Pair lower upper (@code{plu.ps}).
13404
13405 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13406 Pair upper upper (@code{puu.ps}).
13407
13408 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13409 Convert pair to paired single (@code{cvt.ps.s}).
13410
13411 @item float __builtin_mips_cvt_s_pl (v2sf)
13412 Convert pair lower to single (@code{cvt.s.pl}).
13413
13414 @item float __builtin_mips_cvt_s_pu (v2sf)
13415 Convert pair upper to single (@code{cvt.s.pu}).
13416
13417 @item v2sf __builtin_mips_abs_ps (v2sf)
13418 Absolute value (@code{abs.ps}).
13419
13420 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13421 Align variable (@code{alnv.ps}).
13422
13423 @emph{Note:} The value of the third parameter must be 0 or 4
13424 modulo 8, otherwise the result is unpredictable. Please read the
13425 instruction description for details.
13426 @end table
13427
13428 The following multi-instruction functions are also available.
13429 In each case, @var{cond} can be any of the 16 floating-point conditions:
13430 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13431 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13432 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13433
13434 @table @code
13435 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13436 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13437 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13438 @code{movt.ps}/@code{movf.ps}).
13439
13440 The @code{movt} functions return the value @var{x} computed by:
13441
13442 @smallexample
13443 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13444 mov.ps @var{x},@var{c}
13445 movt.ps @var{x},@var{d},@var{cc}
13446 @end smallexample
13447
13448 The @code{movf} functions are similar but use @code{movf.ps} instead
13449 of @code{movt.ps}.
13450
13451 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13452 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13453 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13454 @code{bc1t}/@code{bc1f}).
13455
13456 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13457 and return either the upper or lower half of the result. For example:
13458
13459 @smallexample
13460 v2sf a, b;
13461 if (__builtin_mips_upper_c_eq_ps (a, b))
13462 upper_halves_are_equal ();
13463 else
13464 upper_halves_are_unequal ();
13465
13466 if (__builtin_mips_lower_c_eq_ps (a, b))
13467 lower_halves_are_equal ();
13468 else
13469 lower_halves_are_unequal ();
13470 @end smallexample
13471 @end table
13472
13473 @node MIPS-3D Built-in Functions
13474 @subsubsection MIPS-3D Built-in Functions
13475
13476 The MIPS-3D Application-Specific Extension (ASE) includes additional
13477 paired-single instructions that are designed to improve the performance
13478 of 3D graphics operations. Support for these instructions is controlled
13479 by the @option{-mips3d} command-line option.
13480
13481 The functions listed below map directly to a particular MIPS-3D
13482 instruction. Please refer to the architecture specification for
13483 more details on what each instruction does.
13484
13485 @table @code
13486 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13487 Reduction add (@code{addr.ps}).
13488
13489 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13490 Reduction multiply (@code{mulr.ps}).
13491
13492 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13493 Convert paired single to paired word (@code{cvt.pw.ps}).
13494
13495 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13496 Convert paired word to paired single (@code{cvt.ps.pw}).
13497
13498 @item float __builtin_mips_recip1_s (float)
13499 @itemx double __builtin_mips_recip1_d (double)
13500 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13501 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13502
13503 @item float __builtin_mips_recip2_s (float, float)
13504 @itemx double __builtin_mips_recip2_d (double, double)
13505 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13506 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13507
13508 @item float __builtin_mips_rsqrt1_s (float)
13509 @itemx double __builtin_mips_rsqrt1_d (double)
13510 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13511 Reduced-precision reciprocal square root (sequence step 1)
13512 (@code{rsqrt1.@var{fmt}}).
13513
13514 @item float __builtin_mips_rsqrt2_s (float, float)
13515 @itemx double __builtin_mips_rsqrt2_d (double, double)
13516 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13517 Reduced-precision reciprocal square root (sequence step 2)
13518 (@code{rsqrt2.@var{fmt}}).
13519 @end table
13520
13521 The following multi-instruction functions are also available.
13522 In each case, @var{cond} can be any of the 16 floating-point conditions:
13523 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13524 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13525 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13526
13527 @table @code
13528 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13529 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13530 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13531 @code{bc1t}/@code{bc1f}).
13532
13533 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13534 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13535 For example:
13536
13537 @smallexample
13538 float a, b;
13539 if (__builtin_mips_cabs_eq_s (a, b))
13540 true ();
13541 else
13542 false ();
13543 @end smallexample
13544
13545 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13546 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13547 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13548 @code{bc1t}/@code{bc1f}).
13549
13550 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13551 and return either the upper or lower half of the result. For example:
13552
13553 @smallexample
13554 v2sf a, b;
13555 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13556 upper_halves_are_equal ();
13557 else
13558 upper_halves_are_unequal ();
13559
13560 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13561 lower_halves_are_equal ();
13562 else
13563 lower_halves_are_unequal ();
13564 @end smallexample
13565
13566 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13567 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13568 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13569 @code{movt.ps}/@code{movf.ps}).
13570
13571 The @code{movt} functions return the value @var{x} computed by:
13572
13573 @smallexample
13574 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13575 mov.ps @var{x},@var{c}
13576 movt.ps @var{x},@var{d},@var{cc}
13577 @end smallexample
13578
13579 The @code{movf} functions are similar but use @code{movf.ps} instead
13580 of @code{movt.ps}.
13581
13582 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13583 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13584 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13585 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13586 Comparison of two paired-single values
13587 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13588 @code{bc1any2t}/@code{bc1any2f}).
13589
13590 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13591 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13592 result is true and the @code{all} forms return true if both results are true.
13593 For example:
13594
13595 @smallexample
13596 v2sf a, b;
13597 if (__builtin_mips_any_c_eq_ps (a, b))
13598 one_is_true ();
13599 else
13600 both_are_false ();
13601
13602 if (__builtin_mips_all_c_eq_ps (a, b))
13603 both_are_true ();
13604 else
13605 one_is_false ();
13606 @end smallexample
13607
13608 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13609 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13610 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13611 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13612 Comparison of four paired-single values
13613 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13614 @code{bc1any4t}/@code{bc1any4f}).
13615
13616 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13617 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13618 The @code{any} forms return true if any of the four results are true
13619 and the @code{all} forms return true if all four results are true.
13620 For example:
13621
13622 @smallexample
13623 v2sf a, b, c, d;
13624 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13625 some_are_true ();
13626 else
13627 all_are_false ();
13628
13629 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13630 all_are_true ();
13631 else
13632 some_are_false ();
13633 @end smallexample
13634 @end table
13635
13636 @node Other MIPS Built-in Functions
13637 @subsection Other MIPS Built-in Functions
13638
13639 GCC provides other MIPS-specific built-in functions:
13640
13641 @table @code
13642 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13643 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13644 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13645 when this function is available.
13646
13647 @item unsigned int __builtin_mips_get_fcsr (void)
13648 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13649 Get and set the contents of the floating-point control and status register
13650 (FPU control register 31). These functions are only available in hard-float
13651 code but can be called in both MIPS16 and non-MIPS16 contexts.
13652
13653 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13654 register except the condition codes, which GCC assumes are preserved.
13655 @end table
13656
13657 @node MSP430 Built-in Functions
13658 @subsection MSP430 Built-in Functions
13659
13660 GCC provides a couple of special builtin functions to aid in the
13661 writing of interrupt handlers in C.
13662
13663 @table @code
13664 @item __bic_SR_register_on_exit (int @var{mask})
13665 This clears the indicated bits in the saved copy of the status register
13666 currently residing on the stack. This only works inside interrupt
13667 handlers and the changes to the status register will only take affect
13668 once the handler returns.
13669
13670 @item __bis_SR_register_on_exit (int @var{mask})
13671 This sets the indicated bits in the saved copy of the status register
13672 currently residing on the stack. This only works inside interrupt
13673 handlers and the changes to the status register will only take affect
13674 once the handler returns.
13675
13676 @item __delay_cycles (long long @var{cycles})
13677 This inserts an instruction sequence that takes exactly @var{cycles}
13678 cycles (between 0 and about 17E9) to complete. The inserted sequence
13679 may use jumps, loops, or no-ops, and does not interfere with any other
13680 instructions. Note that @var{cycles} must be a compile-time constant
13681 integer - that is, you must pass a number, not a variable that may be
13682 optimized to a constant later. The number of cycles delayed by this
13683 builtin is exact.
13684 @end table
13685
13686 @node NDS32 Built-in Functions
13687 @subsection NDS32 Built-in Functions
13688
13689 These built-in functions are available for the NDS32 target:
13690
13691 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13692 Insert an ISYNC instruction into the instruction stream where
13693 @var{addr} is an instruction address for serialization.
13694 @end deftypefn
13695
13696 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13697 Insert an ISB instruction into the instruction stream.
13698 @end deftypefn
13699
13700 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13701 Return the content of a system register which is mapped by @var{sr}.
13702 @end deftypefn
13703
13704 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13705 Return the content of a user space register which is mapped by @var{usr}.
13706 @end deftypefn
13707
13708 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13709 Move the @var{value} to a system register which is mapped by @var{sr}.
13710 @end deftypefn
13711
13712 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13713 Move the @var{value} to a user space register which is mapped by @var{usr}.
13714 @end deftypefn
13715
13716 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13717 Enable global interrupt.
13718 @end deftypefn
13719
13720 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13721 Disable global interrupt.
13722 @end deftypefn
13723
13724 @node picoChip Built-in Functions
13725 @subsection picoChip Built-in Functions
13726
13727 GCC provides an interface to selected machine instructions from the
13728 picoChip instruction set.
13729
13730 @table @code
13731 @item int __builtin_sbc (int @var{value})
13732 Sign bit count. Return the number of consecutive bits in @var{value}
13733 that have the same value as the sign bit. The result is the number of
13734 leading sign bits minus one, giving the number of redundant sign bits in
13735 @var{value}.
13736
13737 @item int __builtin_byteswap (int @var{value})
13738 Byte swap. Return the result of swapping the upper and lower bytes of
13739 @var{value}.
13740
13741 @item int __builtin_brev (int @var{value})
13742 Bit reversal. Return the result of reversing the bits in
13743 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13744 and so on.
13745
13746 @item int __builtin_adds (int @var{x}, int @var{y})
13747 Saturating addition. Return the result of adding @var{x} and @var{y},
13748 storing the value 32767 if the result overflows.
13749
13750 @item int __builtin_subs (int @var{x}, int @var{y})
13751 Saturating subtraction. Return the result of subtracting @var{y} from
13752 @var{x}, storing the value @minus{}32768 if the result overflows.
13753
13754 @item void __builtin_halt (void)
13755 Halt. The processor stops execution. This built-in is useful for
13756 implementing assertions.
13757
13758 @end table
13759
13760 @node PowerPC Built-in Functions
13761 @subsection PowerPC Built-in Functions
13762
13763 These built-in functions are available for the PowerPC family of
13764 processors:
13765 @smallexample
13766 float __builtin_recipdivf (float, float);
13767 float __builtin_rsqrtf (float);
13768 double __builtin_recipdiv (double, double);
13769 double __builtin_rsqrt (double);
13770 uint64_t __builtin_ppc_get_timebase ();
13771 unsigned long __builtin_ppc_mftb ();
13772 double __builtin_unpack_longdouble (long double, int);
13773 long double __builtin_pack_longdouble (double, double);
13774 @end smallexample
13775
13776 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13777 @code{__builtin_rsqrtf} functions generate multiple instructions to
13778 implement the reciprocal sqrt functionality using reciprocal sqrt
13779 estimate instructions.
13780
13781 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13782 functions generate multiple instructions to implement division using
13783 the reciprocal estimate instructions.
13784
13785 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13786 functions generate instructions to read the Time Base Register. The
13787 @code{__builtin_ppc_get_timebase} function may generate multiple
13788 instructions and always returns the 64 bits of the Time Base Register.
13789 The @code{__builtin_ppc_mftb} function always generates one instruction and
13790 returns the Time Base Register value as an unsigned long, throwing away
13791 the most significant word on 32-bit environments.
13792
13793 The following built-in functions are available for the PowerPC family
13794 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13795 or @option{-mpopcntd}):
13796 @smallexample
13797 long __builtin_bpermd (long, long);
13798 int __builtin_divwe (int, int);
13799 int __builtin_divweo (int, int);
13800 unsigned int __builtin_divweu (unsigned int, unsigned int);
13801 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13802 long __builtin_divde (long, long);
13803 long __builtin_divdeo (long, long);
13804 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13805 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13806 unsigned int cdtbcd (unsigned int);
13807 unsigned int cbcdtd (unsigned int);
13808 unsigned int addg6s (unsigned int, unsigned int);
13809 @end smallexample
13810
13811 The @code{__builtin_divde}, @code{__builtin_divdeo},
13812 @code{__builitin_divdeu}, @code{__builtin_divdeou} functions require a
13813 64-bit environment support ISA 2.06 or later.
13814
13815 The following built-in functions are available for the PowerPC family
13816 of processors when hardware decimal floating point
13817 (@option{-mhard-dfp}) is available:
13818 @smallexample
13819 _Decimal64 __builtin_dxex (_Decimal64);
13820 _Decimal128 __builtin_dxexq (_Decimal128);
13821 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13822 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13823 _Decimal64 __builtin_denbcd (int, _Decimal64);
13824 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13825 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13826 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13827 _Decimal64 __builtin_dscli (_Decimal64, int);
13828 _Decimal128 __builitn_dscliq (_Decimal128, int);
13829 _Decimal64 __builtin_dscri (_Decimal64, int);
13830 _Decimal128 __builitn_dscriq (_Decimal128, int);
13831 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13832 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13833 @end smallexample
13834
13835 The following built-in functions are available for the PowerPC family
13836 of processors when the Vector Scalar (vsx) instruction set is
13837 available:
13838 @smallexample
13839 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13840 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13841 unsigned long long);
13842 @end smallexample
13843
13844 @node PowerPC AltiVec/VSX Built-in Functions
13845 @subsection PowerPC AltiVec Built-in Functions
13846
13847 GCC provides an interface for the PowerPC family of processors to access
13848 the AltiVec operations described in Motorola's AltiVec Programming
13849 Interface Manual. The interface is made available by including
13850 @code{<altivec.h>} and using @option{-maltivec} and
13851 @option{-mabi=altivec}. The interface supports the following vector
13852 types.
13853
13854 @smallexample
13855 vector unsigned char
13856 vector signed char
13857 vector bool char
13858
13859 vector unsigned short
13860 vector signed short
13861 vector bool short
13862 vector pixel
13863
13864 vector unsigned int
13865 vector signed int
13866 vector bool int
13867 vector float
13868 @end smallexample
13869
13870 If @option{-mvsx} is used the following additional vector types are
13871 implemented.
13872
13873 @smallexample
13874 vector unsigned long
13875 vector signed long
13876 vector double
13877 @end smallexample
13878
13879 The long types are only implemented for 64-bit code generation, and
13880 the long type is only used in the floating point/integer conversion
13881 instructions.
13882
13883 GCC's implementation of the high-level language interface available from
13884 C and C++ code differs from Motorola's documentation in several ways.
13885
13886 @itemize @bullet
13887
13888 @item
13889 A vector constant is a list of constant expressions within curly braces.
13890
13891 @item
13892 A vector initializer requires no cast if the vector constant is of the
13893 same type as the variable it is initializing.
13894
13895 @item
13896 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13897 vector type is the default signedness of the base type. The default
13898 varies depending on the operating system, so a portable program should
13899 always specify the signedness.
13900
13901 @item
13902 Compiling with @option{-maltivec} adds keywords @code{__vector},
13903 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13904 @code{bool}. When compiling ISO C, the context-sensitive substitution
13905 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13906 disabled. To use them, you must include @code{<altivec.h>} instead.
13907
13908 @item
13909 GCC allows using a @code{typedef} name as the type specifier for a
13910 vector type.
13911
13912 @item
13913 For C, overloaded functions are implemented with macros so the following
13914 does not work:
13915
13916 @smallexample
13917 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13918 @end smallexample
13919
13920 @noindent
13921 Since @code{vec_add} is a macro, the vector constant in the example
13922 is treated as four separate arguments. Wrap the entire argument in
13923 parentheses for this to work.
13924 @end itemize
13925
13926 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13927 Internally, GCC uses built-in functions to achieve the functionality in
13928 the aforementioned header file, but they are not supported and are
13929 subject to change without notice.
13930
13931 The following interfaces are supported for the generic and specific
13932 AltiVec operations and the AltiVec predicates. In cases where there
13933 is a direct mapping between generic and specific operations, only the
13934 generic names are shown here, although the specific operations can also
13935 be used.
13936
13937 Arguments that are documented as @code{const int} require literal
13938 integral values within the range required for that operation.
13939
13940 @smallexample
13941 vector signed char vec_abs (vector signed char);
13942 vector signed short vec_abs (vector signed short);
13943 vector signed int vec_abs (vector signed int);
13944 vector float vec_abs (vector float);
13945
13946 vector signed char vec_abss (vector signed char);
13947 vector signed short vec_abss (vector signed short);
13948 vector signed int vec_abss (vector signed int);
13949
13950 vector signed char vec_add (vector bool char, vector signed char);
13951 vector signed char vec_add (vector signed char, vector bool char);
13952 vector signed char vec_add (vector signed char, vector signed char);
13953 vector unsigned char vec_add (vector bool char, vector unsigned char);
13954 vector unsigned char vec_add (vector unsigned char, vector bool char);
13955 vector unsigned char vec_add (vector unsigned char,
13956 vector unsigned char);
13957 vector signed short vec_add (vector bool short, vector signed short);
13958 vector signed short vec_add (vector signed short, vector bool short);
13959 vector signed short vec_add (vector signed short, vector signed short);
13960 vector unsigned short vec_add (vector bool short,
13961 vector unsigned short);
13962 vector unsigned short vec_add (vector unsigned short,
13963 vector bool short);
13964 vector unsigned short vec_add (vector unsigned short,
13965 vector unsigned short);
13966 vector signed int vec_add (vector bool int, vector signed int);
13967 vector signed int vec_add (vector signed int, vector bool int);
13968 vector signed int vec_add (vector signed int, vector signed int);
13969 vector unsigned int vec_add (vector bool int, vector unsigned int);
13970 vector unsigned int vec_add (vector unsigned int, vector bool int);
13971 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13972 vector float vec_add (vector float, vector float);
13973
13974 vector float vec_vaddfp (vector float, vector float);
13975
13976 vector signed int vec_vadduwm (vector bool int, vector signed int);
13977 vector signed int vec_vadduwm (vector signed int, vector bool int);
13978 vector signed int vec_vadduwm (vector signed int, vector signed int);
13979 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13980 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
13981 vector unsigned int vec_vadduwm (vector unsigned int,
13982 vector unsigned int);
13983
13984 vector signed short vec_vadduhm (vector bool short,
13985 vector signed short);
13986 vector signed short vec_vadduhm (vector signed short,
13987 vector bool short);
13988 vector signed short vec_vadduhm (vector signed short,
13989 vector signed short);
13990 vector unsigned short vec_vadduhm (vector bool short,
13991 vector unsigned short);
13992 vector unsigned short vec_vadduhm (vector unsigned short,
13993 vector bool short);
13994 vector unsigned short vec_vadduhm (vector unsigned short,
13995 vector unsigned short);
13996
13997 vector signed char vec_vaddubm (vector bool char, vector signed char);
13998 vector signed char vec_vaddubm (vector signed char, vector bool char);
13999 vector signed char vec_vaddubm (vector signed char, vector signed char);
14000 vector unsigned char vec_vaddubm (vector bool char,
14001 vector unsigned char);
14002 vector unsigned char vec_vaddubm (vector unsigned char,
14003 vector bool char);
14004 vector unsigned char vec_vaddubm (vector unsigned char,
14005 vector unsigned char);
14006
14007 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
14008
14009 vector unsigned char vec_adds (vector bool char, vector unsigned char);
14010 vector unsigned char vec_adds (vector unsigned char, vector bool char);
14011 vector unsigned char vec_adds (vector unsigned char,
14012 vector unsigned char);
14013 vector signed char vec_adds (vector bool char, vector signed char);
14014 vector signed char vec_adds (vector signed char, vector bool char);
14015 vector signed char vec_adds (vector signed char, vector signed char);
14016 vector unsigned short vec_adds (vector bool short,
14017 vector unsigned short);
14018 vector unsigned short vec_adds (vector unsigned short,
14019 vector bool short);
14020 vector unsigned short vec_adds (vector unsigned short,
14021 vector unsigned short);
14022 vector signed short vec_adds (vector bool short, vector signed short);
14023 vector signed short vec_adds (vector signed short, vector bool short);
14024 vector signed short vec_adds (vector signed short, vector signed short);
14025 vector unsigned int vec_adds (vector bool int, vector unsigned int);
14026 vector unsigned int vec_adds (vector unsigned int, vector bool int);
14027 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
14028 vector signed int vec_adds (vector bool int, vector signed int);
14029 vector signed int vec_adds (vector signed int, vector bool int);
14030 vector signed int vec_adds (vector signed int, vector signed int);
14031
14032 vector signed int vec_vaddsws (vector bool int, vector signed int);
14033 vector signed int vec_vaddsws (vector signed int, vector bool int);
14034 vector signed int vec_vaddsws (vector signed int, vector signed int);
14035
14036 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
14037 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
14038 vector unsigned int vec_vadduws (vector unsigned int,
14039 vector unsigned int);
14040
14041 vector signed short vec_vaddshs (vector bool short,
14042 vector signed short);
14043 vector signed short vec_vaddshs (vector signed short,
14044 vector bool short);
14045 vector signed short vec_vaddshs (vector signed short,
14046 vector signed short);
14047
14048 vector unsigned short vec_vadduhs (vector bool short,
14049 vector unsigned short);
14050 vector unsigned short vec_vadduhs (vector unsigned short,
14051 vector bool short);
14052 vector unsigned short vec_vadduhs (vector unsigned short,
14053 vector unsigned short);
14054
14055 vector signed char vec_vaddsbs (vector bool char, vector signed char);
14056 vector signed char vec_vaddsbs (vector signed char, vector bool char);
14057 vector signed char vec_vaddsbs (vector signed char, vector signed char);
14058
14059 vector unsigned char vec_vaddubs (vector bool char,
14060 vector unsigned char);
14061 vector unsigned char vec_vaddubs (vector unsigned char,
14062 vector bool char);
14063 vector unsigned char vec_vaddubs (vector unsigned char,
14064 vector unsigned char);
14065
14066 vector float vec_and (vector float, vector float);
14067 vector float vec_and (vector float, vector bool int);
14068 vector float vec_and (vector bool int, vector float);
14069 vector bool int vec_and (vector bool int, vector bool int);
14070 vector signed int vec_and (vector bool int, vector signed int);
14071 vector signed int vec_and (vector signed int, vector bool int);
14072 vector signed int vec_and (vector signed int, vector signed int);
14073 vector unsigned int vec_and (vector bool int, vector unsigned int);
14074 vector unsigned int vec_and (vector unsigned int, vector bool int);
14075 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
14076 vector bool short vec_and (vector bool short, vector bool short);
14077 vector signed short vec_and (vector bool short, vector signed short);
14078 vector signed short vec_and (vector signed short, vector bool short);
14079 vector signed short vec_and (vector signed short, vector signed short);
14080 vector unsigned short vec_and (vector bool short,
14081 vector unsigned short);
14082 vector unsigned short vec_and (vector unsigned short,
14083 vector bool short);
14084 vector unsigned short vec_and (vector unsigned short,
14085 vector unsigned short);
14086 vector signed char vec_and (vector bool char, vector signed char);
14087 vector bool char vec_and (vector bool char, vector bool char);
14088 vector signed char vec_and (vector signed char, vector bool char);
14089 vector signed char vec_and (vector signed char, vector signed char);
14090 vector unsigned char vec_and (vector bool char, vector unsigned char);
14091 vector unsigned char vec_and (vector unsigned char, vector bool char);
14092 vector unsigned char vec_and (vector unsigned char,
14093 vector unsigned char);
14094
14095 vector float vec_andc (vector float, vector float);
14096 vector float vec_andc (vector float, vector bool int);
14097 vector float vec_andc (vector bool int, vector float);
14098 vector bool int vec_andc (vector bool int, vector bool int);
14099 vector signed int vec_andc (vector bool int, vector signed int);
14100 vector signed int vec_andc (vector signed int, vector bool int);
14101 vector signed int vec_andc (vector signed int, vector signed int);
14102 vector unsigned int vec_andc (vector bool int, vector unsigned int);
14103 vector unsigned int vec_andc (vector unsigned int, vector bool int);
14104 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
14105 vector bool short vec_andc (vector bool short, vector bool short);
14106 vector signed short vec_andc (vector bool short, vector signed short);
14107 vector signed short vec_andc (vector signed short, vector bool short);
14108 vector signed short vec_andc (vector signed short, vector signed short);
14109 vector unsigned short vec_andc (vector bool short,
14110 vector unsigned short);
14111 vector unsigned short vec_andc (vector unsigned short,
14112 vector bool short);
14113 vector unsigned short vec_andc (vector unsigned short,
14114 vector unsigned short);
14115 vector signed char vec_andc (vector bool char, vector signed char);
14116 vector bool char vec_andc (vector bool char, vector bool char);
14117 vector signed char vec_andc (vector signed char, vector bool char);
14118 vector signed char vec_andc (vector signed char, vector signed char);
14119 vector unsigned char vec_andc (vector bool char, vector unsigned char);
14120 vector unsigned char vec_andc (vector unsigned char, vector bool char);
14121 vector unsigned char vec_andc (vector unsigned char,
14122 vector unsigned char);
14123
14124 vector unsigned char vec_avg (vector unsigned char,
14125 vector unsigned char);
14126 vector signed char vec_avg (vector signed char, vector signed char);
14127 vector unsigned short vec_avg (vector unsigned short,
14128 vector unsigned short);
14129 vector signed short vec_avg (vector signed short, vector signed short);
14130 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
14131 vector signed int vec_avg (vector signed int, vector signed int);
14132
14133 vector signed int vec_vavgsw (vector signed int, vector signed int);
14134
14135 vector unsigned int vec_vavguw (vector unsigned int,
14136 vector unsigned int);
14137
14138 vector signed short vec_vavgsh (vector signed short,
14139 vector signed short);
14140
14141 vector unsigned short vec_vavguh (vector unsigned short,
14142 vector unsigned short);
14143
14144 vector signed char vec_vavgsb (vector signed char, vector signed char);
14145
14146 vector unsigned char vec_vavgub (vector unsigned char,
14147 vector unsigned char);
14148
14149 vector float vec_copysign (vector float);
14150
14151 vector float vec_ceil (vector float);
14152
14153 vector signed int vec_cmpb (vector float, vector float);
14154
14155 vector bool char vec_cmpeq (vector signed char, vector signed char);
14156 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
14157 vector bool short vec_cmpeq (vector signed short, vector signed short);
14158 vector bool short vec_cmpeq (vector unsigned short,
14159 vector unsigned short);
14160 vector bool int vec_cmpeq (vector signed int, vector signed int);
14161 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
14162 vector bool int vec_cmpeq (vector float, vector float);
14163
14164 vector bool int vec_vcmpeqfp (vector float, vector float);
14165
14166 vector bool int vec_vcmpequw (vector signed int, vector signed int);
14167 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
14168
14169 vector bool short vec_vcmpequh (vector signed short,
14170 vector signed short);
14171 vector bool short vec_vcmpequh (vector unsigned short,
14172 vector unsigned short);
14173
14174 vector bool char vec_vcmpequb (vector signed char, vector signed char);
14175 vector bool char vec_vcmpequb (vector unsigned char,
14176 vector unsigned char);
14177
14178 vector bool int vec_cmpge (vector float, vector float);
14179
14180 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
14181 vector bool char vec_cmpgt (vector signed char, vector signed char);
14182 vector bool short vec_cmpgt (vector unsigned short,
14183 vector unsigned short);
14184 vector bool short vec_cmpgt (vector signed short, vector signed short);
14185 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
14186 vector bool int vec_cmpgt (vector signed int, vector signed int);
14187 vector bool int vec_cmpgt (vector float, vector float);
14188
14189 vector bool int vec_vcmpgtfp (vector float, vector float);
14190
14191 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
14192
14193 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
14194
14195 vector bool short vec_vcmpgtsh (vector signed short,
14196 vector signed short);
14197
14198 vector bool short vec_vcmpgtuh (vector unsigned short,
14199 vector unsigned short);
14200
14201 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
14202
14203 vector bool char vec_vcmpgtub (vector unsigned char,
14204 vector unsigned char);
14205
14206 vector bool int vec_cmple (vector float, vector float);
14207
14208 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
14209 vector bool char vec_cmplt (vector signed char, vector signed char);
14210 vector bool short vec_cmplt (vector unsigned short,
14211 vector unsigned short);
14212 vector bool short vec_cmplt (vector signed short, vector signed short);
14213 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
14214 vector bool int vec_cmplt (vector signed int, vector signed int);
14215 vector bool int vec_cmplt (vector float, vector float);
14216
14217 vector float vec_cpsgn (vector float, vector float);
14218
14219 vector float vec_ctf (vector unsigned int, const int);
14220 vector float vec_ctf (vector signed int, const int);
14221 vector double vec_ctf (vector unsigned long, const int);
14222 vector double vec_ctf (vector signed long, const int);
14223
14224 vector float vec_vcfsx (vector signed int, const int);
14225
14226 vector float vec_vcfux (vector unsigned int, const int);
14227
14228 vector signed int vec_cts (vector float, const int);
14229 vector signed long vec_cts (vector double, const int);
14230
14231 vector unsigned int vec_ctu (vector float, const int);
14232 vector unsigned long vec_ctu (vector double, const int);
14233
14234 void vec_dss (const int);
14235
14236 void vec_dssall (void);
14237
14238 void vec_dst (const vector unsigned char *, int, const int);
14239 void vec_dst (const vector signed char *, int, const int);
14240 void vec_dst (const vector bool char *, int, const int);
14241 void vec_dst (const vector unsigned short *, int, const int);
14242 void vec_dst (const vector signed short *, int, const int);
14243 void vec_dst (const vector bool short *, int, const int);
14244 void vec_dst (const vector pixel *, int, const int);
14245 void vec_dst (const vector unsigned int *, int, const int);
14246 void vec_dst (const vector signed int *, int, const int);
14247 void vec_dst (const vector bool int *, int, const int);
14248 void vec_dst (const vector float *, int, const int);
14249 void vec_dst (const unsigned char *, int, const int);
14250 void vec_dst (const signed char *, int, const int);
14251 void vec_dst (const unsigned short *, int, const int);
14252 void vec_dst (const short *, int, const int);
14253 void vec_dst (const unsigned int *, int, const int);
14254 void vec_dst (const int *, int, const int);
14255 void vec_dst (const unsigned long *, int, const int);
14256 void vec_dst (const long *, int, const int);
14257 void vec_dst (const float *, int, const int);
14258
14259 void vec_dstst (const vector unsigned char *, int, const int);
14260 void vec_dstst (const vector signed char *, int, const int);
14261 void vec_dstst (const vector bool char *, int, const int);
14262 void vec_dstst (const vector unsigned short *, int, const int);
14263 void vec_dstst (const vector signed short *, int, const int);
14264 void vec_dstst (const vector bool short *, int, const int);
14265 void vec_dstst (const vector pixel *, int, const int);
14266 void vec_dstst (const vector unsigned int *, int, const int);
14267 void vec_dstst (const vector signed int *, int, const int);
14268 void vec_dstst (const vector bool int *, int, const int);
14269 void vec_dstst (const vector float *, int, const int);
14270 void vec_dstst (const unsigned char *, int, const int);
14271 void vec_dstst (const signed char *, int, const int);
14272 void vec_dstst (const unsigned short *, int, const int);
14273 void vec_dstst (const short *, int, const int);
14274 void vec_dstst (const unsigned int *, int, const int);
14275 void vec_dstst (const int *, int, const int);
14276 void vec_dstst (const unsigned long *, int, const int);
14277 void vec_dstst (const long *, int, const int);
14278 void vec_dstst (const float *, int, const int);
14279
14280 void vec_dststt (const vector unsigned char *, int, const int);
14281 void vec_dststt (const vector signed char *, int, const int);
14282 void vec_dststt (const vector bool char *, int, const int);
14283 void vec_dststt (const vector unsigned short *, int, const int);
14284 void vec_dststt (const vector signed short *, int, const int);
14285 void vec_dststt (const vector bool short *, int, const int);
14286 void vec_dststt (const vector pixel *, int, const int);
14287 void vec_dststt (const vector unsigned int *, int, const int);
14288 void vec_dststt (const vector signed int *, int, const int);
14289 void vec_dststt (const vector bool int *, int, const int);
14290 void vec_dststt (const vector float *, int, const int);
14291 void vec_dststt (const unsigned char *, int, const int);
14292 void vec_dststt (const signed char *, int, const int);
14293 void vec_dststt (const unsigned short *, int, const int);
14294 void vec_dststt (const short *, int, const int);
14295 void vec_dststt (const unsigned int *, int, const int);
14296 void vec_dststt (const int *, int, const int);
14297 void vec_dststt (const unsigned long *, int, const int);
14298 void vec_dststt (const long *, int, const int);
14299 void vec_dststt (const float *, int, const int);
14300
14301 void vec_dstt (const vector unsigned char *, int, const int);
14302 void vec_dstt (const vector signed char *, int, const int);
14303 void vec_dstt (const vector bool char *, int, const int);
14304 void vec_dstt (const vector unsigned short *, int, const int);
14305 void vec_dstt (const vector signed short *, int, const int);
14306 void vec_dstt (const vector bool short *, int, const int);
14307 void vec_dstt (const vector pixel *, int, const int);
14308 void vec_dstt (const vector unsigned int *, int, const int);
14309 void vec_dstt (const vector signed int *, int, const int);
14310 void vec_dstt (const vector bool int *, int, const int);
14311 void vec_dstt (const vector float *, int, const int);
14312 void vec_dstt (const unsigned char *, int, const int);
14313 void vec_dstt (const signed char *, int, const int);
14314 void vec_dstt (const unsigned short *, int, const int);
14315 void vec_dstt (const short *, int, const int);
14316 void vec_dstt (const unsigned int *, int, const int);
14317 void vec_dstt (const int *, int, const int);
14318 void vec_dstt (const unsigned long *, int, const int);
14319 void vec_dstt (const long *, int, const int);
14320 void vec_dstt (const float *, int, const int);
14321
14322 vector float vec_expte (vector float);
14323
14324 vector float vec_floor (vector float);
14325
14326 vector float vec_ld (int, const vector float *);
14327 vector float vec_ld (int, const float *);
14328 vector bool int vec_ld (int, const vector bool int *);
14329 vector signed int vec_ld (int, const vector signed int *);
14330 vector signed int vec_ld (int, const int *);
14331 vector signed int vec_ld (int, const long *);
14332 vector unsigned int vec_ld (int, const vector unsigned int *);
14333 vector unsigned int vec_ld (int, const unsigned int *);
14334 vector unsigned int vec_ld (int, const unsigned long *);
14335 vector bool short vec_ld (int, const vector bool short *);
14336 vector pixel vec_ld (int, const vector pixel *);
14337 vector signed short vec_ld (int, const vector signed short *);
14338 vector signed short vec_ld (int, const short *);
14339 vector unsigned short vec_ld (int, const vector unsigned short *);
14340 vector unsigned short vec_ld (int, const unsigned short *);
14341 vector bool char vec_ld (int, const vector bool char *);
14342 vector signed char vec_ld (int, const vector signed char *);
14343 vector signed char vec_ld (int, const signed char *);
14344 vector unsigned char vec_ld (int, const vector unsigned char *);
14345 vector unsigned char vec_ld (int, const unsigned char *);
14346
14347 vector signed char vec_lde (int, const signed char *);
14348 vector unsigned char vec_lde (int, const unsigned char *);
14349 vector signed short vec_lde (int, const short *);
14350 vector unsigned short vec_lde (int, const unsigned short *);
14351 vector float vec_lde (int, const float *);
14352 vector signed int vec_lde (int, const int *);
14353 vector unsigned int vec_lde (int, const unsigned int *);
14354 vector signed int vec_lde (int, const long *);
14355 vector unsigned int vec_lde (int, const unsigned long *);
14356
14357 vector float vec_lvewx (int, float *);
14358 vector signed int vec_lvewx (int, int *);
14359 vector unsigned int vec_lvewx (int, unsigned int *);
14360 vector signed int vec_lvewx (int, long *);
14361 vector unsigned int vec_lvewx (int, unsigned long *);
14362
14363 vector signed short vec_lvehx (int, short *);
14364 vector unsigned short vec_lvehx (int, unsigned short *);
14365
14366 vector signed char vec_lvebx (int, char *);
14367 vector unsigned char vec_lvebx (int, unsigned char *);
14368
14369 vector float vec_ldl (int, const vector float *);
14370 vector float vec_ldl (int, const float *);
14371 vector bool int vec_ldl (int, const vector bool int *);
14372 vector signed int vec_ldl (int, const vector signed int *);
14373 vector signed int vec_ldl (int, const int *);
14374 vector signed int vec_ldl (int, const long *);
14375 vector unsigned int vec_ldl (int, const vector unsigned int *);
14376 vector unsigned int vec_ldl (int, const unsigned int *);
14377 vector unsigned int vec_ldl (int, const unsigned long *);
14378 vector bool short vec_ldl (int, const vector bool short *);
14379 vector pixel vec_ldl (int, const vector pixel *);
14380 vector signed short vec_ldl (int, const vector signed short *);
14381 vector signed short vec_ldl (int, const short *);
14382 vector unsigned short vec_ldl (int, const vector unsigned short *);
14383 vector unsigned short vec_ldl (int, const unsigned short *);
14384 vector bool char vec_ldl (int, const vector bool char *);
14385 vector signed char vec_ldl (int, const vector signed char *);
14386 vector signed char vec_ldl (int, const signed char *);
14387 vector unsigned char vec_ldl (int, const vector unsigned char *);
14388 vector unsigned char vec_ldl (int, const unsigned char *);
14389
14390 vector float vec_loge (vector float);
14391
14392 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14393 vector unsigned char vec_lvsl (int, const volatile signed char *);
14394 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14395 vector unsigned char vec_lvsl (int, const volatile short *);
14396 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14397 vector unsigned char vec_lvsl (int, const volatile int *);
14398 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14399 vector unsigned char vec_lvsl (int, const volatile long *);
14400 vector unsigned char vec_lvsl (int, const volatile float *);
14401
14402 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14403 vector unsigned char vec_lvsr (int, const volatile signed char *);
14404 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14405 vector unsigned char vec_lvsr (int, const volatile short *);
14406 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14407 vector unsigned char vec_lvsr (int, const volatile int *);
14408 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14409 vector unsigned char vec_lvsr (int, const volatile long *);
14410 vector unsigned char vec_lvsr (int, const volatile float *);
14411
14412 vector float vec_madd (vector float, vector float, vector float);
14413
14414 vector signed short vec_madds (vector signed short,
14415 vector signed short,
14416 vector signed short);
14417
14418 vector unsigned char vec_max (vector bool char, vector unsigned char);
14419 vector unsigned char vec_max (vector unsigned char, vector bool char);
14420 vector unsigned char vec_max (vector unsigned char,
14421 vector unsigned char);
14422 vector signed char vec_max (vector bool char, vector signed char);
14423 vector signed char vec_max (vector signed char, vector bool char);
14424 vector signed char vec_max (vector signed char, vector signed char);
14425 vector unsigned short vec_max (vector bool short,
14426 vector unsigned short);
14427 vector unsigned short vec_max (vector unsigned short,
14428 vector bool short);
14429 vector unsigned short vec_max (vector unsigned short,
14430 vector unsigned short);
14431 vector signed short vec_max (vector bool short, vector signed short);
14432 vector signed short vec_max (vector signed short, vector bool short);
14433 vector signed short vec_max (vector signed short, vector signed short);
14434 vector unsigned int vec_max (vector bool int, vector unsigned int);
14435 vector unsigned int vec_max (vector unsigned int, vector bool int);
14436 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14437 vector signed int vec_max (vector bool int, vector signed int);
14438 vector signed int vec_max (vector signed int, vector bool int);
14439 vector signed int vec_max (vector signed int, vector signed int);
14440 vector float vec_max (vector float, vector float);
14441
14442 vector float vec_vmaxfp (vector float, vector float);
14443
14444 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14445 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14446 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14447
14448 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14449 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14450 vector unsigned int vec_vmaxuw (vector unsigned int,
14451 vector unsigned int);
14452
14453 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14454 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14455 vector signed short vec_vmaxsh (vector signed short,
14456 vector signed short);
14457
14458 vector unsigned short vec_vmaxuh (vector bool short,
14459 vector unsigned short);
14460 vector unsigned short vec_vmaxuh (vector unsigned short,
14461 vector bool short);
14462 vector unsigned short vec_vmaxuh (vector unsigned short,
14463 vector unsigned short);
14464
14465 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14466 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14467 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14468
14469 vector unsigned char vec_vmaxub (vector bool char,
14470 vector unsigned char);
14471 vector unsigned char vec_vmaxub (vector unsigned char,
14472 vector bool char);
14473 vector unsigned char vec_vmaxub (vector unsigned char,
14474 vector unsigned char);
14475
14476 vector bool char vec_mergeh (vector bool char, vector bool char);
14477 vector signed char vec_mergeh (vector signed char, vector signed char);
14478 vector unsigned char vec_mergeh (vector unsigned char,
14479 vector unsigned char);
14480 vector bool short vec_mergeh (vector bool short, vector bool short);
14481 vector pixel vec_mergeh (vector pixel, vector pixel);
14482 vector signed short vec_mergeh (vector signed short,
14483 vector signed short);
14484 vector unsigned short vec_mergeh (vector unsigned short,
14485 vector unsigned short);
14486 vector float vec_mergeh (vector float, vector float);
14487 vector bool int vec_mergeh (vector bool int, vector bool int);
14488 vector signed int vec_mergeh (vector signed int, vector signed int);
14489 vector unsigned int vec_mergeh (vector unsigned int,
14490 vector unsigned int);
14491
14492 vector float vec_vmrghw (vector float, vector float);
14493 vector bool int vec_vmrghw (vector bool int, vector bool int);
14494 vector signed int vec_vmrghw (vector signed int, vector signed int);
14495 vector unsigned int vec_vmrghw (vector unsigned int,
14496 vector unsigned int);
14497
14498 vector bool short vec_vmrghh (vector bool short, vector bool short);
14499 vector signed short vec_vmrghh (vector signed short,
14500 vector signed short);
14501 vector unsigned short vec_vmrghh (vector unsigned short,
14502 vector unsigned short);
14503 vector pixel vec_vmrghh (vector pixel, vector pixel);
14504
14505 vector bool char vec_vmrghb (vector bool char, vector bool char);
14506 vector signed char vec_vmrghb (vector signed char, vector signed char);
14507 vector unsigned char vec_vmrghb (vector unsigned char,
14508 vector unsigned char);
14509
14510 vector bool char vec_mergel (vector bool char, vector bool char);
14511 vector signed char vec_mergel (vector signed char, vector signed char);
14512 vector unsigned char vec_mergel (vector unsigned char,
14513 vector unsigned char);
14514 vector bool short vec_mergel (vector bool short, vector bool short);
14515 vector pixel vec_mergel (vector pixel, vector pixel);
14516 vector signed short vec_mergel (vector signed short,
14517 vector signed short);
14518 vector unsigned short vec_mergel (vector unsigned short,
14519 vector unsigned short);
14520 vector float vec_mergel (vector float, vector float);
14521 vector bool int vec_mergel (vector bool int, vector bool int);
14522 vector signed int vec_mergel (vector signed int, vector signed int);
14523 vector unsigned int vec_mergel (vector unsigned int,
14524 vector unsigned int);
14525
14526 vector float vec_vmrglw (vector float, vector float);
14527 vector signed int vec_vmrglw (vector signed int, vector signed int);
14528 vector unsigned int vec_vmrglw (vector unsigned int,
14529 vector unsigned int);
14530 vector bool int vec_vmrglw (vector bool int, vector bool int);
14531
14532 vector bool short vec_vmrglh (vector bool short, vector bool short);
14533 vector signed short vec_vmrglh (vector signed short,
14534 vector signed short);
14535 vector unsigned short vec_vmrglh (vector unsigned short,
14536 vector unsigned short);
14537 vector pixel vec_vmrglh (vector pixel, vector pixel);
14538
14539 vector bool char vec_vmrglb (vector bool char, vector bool char);
14540 vector signed char vec_vmrglb (vector signed char, vector signed char);
14541 vector unsigned char vec_vmrglb (vector unsigned char,
14542 vector unsigned char);
14543
14544 vector unsigned short vec_mfvscr (void);
14545
14546 vector unsigned char vec_min (vector bool char, vector unsigned char);
14547 vector unsigned char vec_min (vector unsigned char, vector bool char);
14548 vector unsigned char vec_min (vector unsigned char,
14549 vector unsigned char);
14550 vector signed char vec_min (vector bool char, vector signed char);
14551 vector signed char vec_min (vector signed char, vector bool char);
14552 vector signed char vec_min (vector signed char, vector signed char);
14553 vector unsigned short vec_min (vector bool short,
14554 vector unsigned short);
14555 vector unsigned short vec_min (vector unsigned short,
14556 vector bool short);
14557 vector unsigned short vec_min (vector unsigned short,
14558 vector unsigned short);
14559 vector signed short vec_min (vector bool short, vector signed short);
14560 vector signed short vec_min (vector signed short, vector bool short);
14561 vector signed short vec_min (vector signed short, vector signed short);
14562 vector unsigned int vec_min (vector bool int, vector unsigned int);
14563 vector unsigned int vec_min (vector unsigned int, vector bool int);
14564 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14565 vector signed int vec_min (vector bool int, vector signed int);
14566 vector signed int vec_min (vector signed int, vector bool int);
14567 vector signed int vec_min (vector signed int, vector signed int);
14568 vector float vec_min (vector float, vector float);
14569
14570 vector float vec_vminfp (vector float, vector float);
14571
14572 vector signed int vec_vminsw (vector bool int, vector signed int);
14573 vector signed int vec_vminsw (vector signed int, vector bool int);
14574 vector signed int vec_vminsw (vector signed int, vector signed int);
14575
14576 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14577 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14578 vector unsigned int vec_vminuw (vector unsigned int,
14579 vector unsigned int);
14580
14581 vector signed short vec_vminsh (vector bool short, vector signed short);
14582 vector signed short vec_vminsh (vector signed short, vector bool short);
14583 vector signed short vec_vminsh (vector signed short,
14584 vector signed short);
14585
14586 vector unsigned short vec_vminuh (vector bool short,
14587 vector unsigned short);
14588 vector unsigned short vec_vminuh (vector unsigned short,
14589 vector bool short);
14590 vector unsigned short vec_vminuh (vector unsigned short,
14591 vector unsigned short);
14592
14593 vector signed char vec_vminsb (vector bool char, vector signed char);
14594 vector signed char vec_vminsb (vector signed char, vector bool char);
14595 vector signed char vec_vminsb (vector signed char, vector signed char);
14596
14597 vector unsigned char vec_vminub (vector bool char,
14598 vector unsigned char);
14599 vector unsigned char vec_vminub (vector unsigned char,
14600 vector bool char);
14601 vector unsigned char vec_vminub (vector unsigned char,
14602 vector unsigned char);
14603
14604 vector signed short vec_mladd (vector signed short,
14605 vector signed short,
14606 vector signed short);
14607 vector signed short vec_mladd (vector signed short,
14608 vector unsigned short,
14609 vector unsigned short);
14610 vector signed short vec_mladd (vector unsigned short,
14611 vector signed short,
14612 vector signed short);
14613 vector unsigned short vec_mladd (vector unsigned short,
14614 vector unsigned short,
14615 vector unsigned short);
14616
14617 vector signed short vec_mradds (vector signed short,
14618 vector signed short,
14619 vector signed short);
14620
14621 vector unsigned int vec_msum (vector unsigned char,
14622 vector unsigned char,
14623 vector unsigned int);
14624 vector signed int vec_msum (vector signed char,
14625 vector unsigned char,
14626 vector signed int);
14627 vector unsigned int vec_msum (vector unsigned short,
14628 vector unsigned short,
14629 vector unsigned int);
14630 vector signed int vec_msum (vector signed short,
14631 vector signed short,
14632 vector signed int);
14633
14634 vector signed int vec_vmsumshm (vector signed short,
14635 vector signed short,
14636 vector signed int);
14637
14638 vector unsigned int vec_vmsumuhm (vector unsigned short,
14639 vector unsigned short,
14640 vector unsigned int);
14641
14642 vector signed int vec_vmsummbm (vector signed char,
14643 vector unsigned char,
14644 vector signed int);
14645
14646 vector unsigned int vec_vmsumubm (vector unsigned char,
14647 vector unsigned char,
14648 vector unsigned int);
14649
14650 vector unsigned int vec_msums (vector unsigned short,
14651 vector unsigned short,
14652 vector unsigned int);
14653 vector signed int vec_msums (vector signed short,
14654 vector signed short,
14655 vector signed int);
14656
14657 vector signed int vec_vmsumshs (vector signed short,
14658 vector signed short,
14659 vector signed int);
14660
14661 vector unsigned int vec_vmsumuhs (vector unsigned short,
14662 vector unsigned short,
14663 vector unsigned int);
14664
14665 void vec_mtvscr (vector signed int);
14666 void vec_mtvscr (vector unsigned int);
14667 void vec_mtvscr (vector bool int);
14668 void vec_mtvscr (vector signed short);
14669 void vec_mtvscr (vector unsigned short);
14670 void vec_mtvscr (vector bool short);
14671 void vec_mtvscr (vector pixel);
14672 void vec_mtvscr (vector signed char);
14673 void vec_mtvscr (vector unsigned char);
14674 void vec_mtvscr (vector bool char);
14675
14676 vector unsigned short vec_mule (vector unsigned char,
14677 vector unsigned char);
14678 vector signed short vec_mule (vector signed char,
14679 vector signed char);
14680 vector unsigned int vec_mule (vector unsigned short,
14681 vector unsigned short);
14682 vector signed int vec_mule (vector signed short, vector signed short);
14683
14684 vector signed int vec_vmulesh (vector signed short,
14685 vector signed short);
14686
14687 vector unsigned int vec_vmuleuh (vector unsigned short,
14688 vector unsigned short);
14689
14690 vector signed short vec_vmulesb (vector signed char,
14691 vector signed char);
14692
14693 vector unsigned short vec_vmuleub (vector unsigned char,
14694 vector unsigned char);
14695
14696 vector unsigned short vec_mulo (vector unsigned char,
14697 vector unsigned char);
14698 vector signed short vec_mulo (vector signed char, vector signed char);
14699 vector unsigned int vec_mulo (vector unsigned short,
14700 vector unsigned short);
14701 vector signed int vec_mulo (vector signed short, vector signed short);
14702
14703 vector signed int vec_vmulosh (vector signed short,
14704 vector signed short);
14705
14706 vector unsigned int vec_vmulouh (vector unsigned short,
14707 vector unsigned short);
14708
14709 vector signed short vec_vmulosb (vector signed char,
14710 vector signed char);
14711
14712 vector unsigned short vec_vmuloub (vector unsigned char,
14713 vector unsigned char);
14714
14715 vector float vec_nmsub (vector float, vector float, vector float);
14716
14717 vector float vec_nor (vector float, vector float);
14718 vector signed int vec_nor (vector signed int, vector signed int);
14719 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14720 vector bool int vec_nor (vector bool int, vector bool int);
14721 vector signed short vec_nor (vector signed short, vector signed short);
14722 vector unsigned short vec_nor (vector unsigned short,
14723 vector unsigned short);
14724 vector bool short vec_nor (vector bool short, vector bool short);
14725 vector signed char vec_nor (vector signed char, vector signed char);
14726 vector unsigned char vec_nor (vector unsigned char,
14727 vector unsigned char);
14728 vector bool char vec_nor (vector bool char, vector bool char);
14729
14730 vector float vec_or (vector float, vector float);
14731 vector float vec_or (vector float, vector bool int);
14732 vector float vec_or (vector bool int, vector float);
14733 vector bool int vec_or (vector bool int, vector bool int);
14734 vector signed int vec_or (vector bool int, vector signed int);
14735 vector signed int vec_or (vector signed int, vector bool int);
14736 vector signed int vec_or (vector signed int, vector signed int);
14737 vector unsigned int vec_or (vector bool int, vector unsigned int);
14738 vector unsigned int vec_or (vector unsigned int, vector bool int);
14739 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14740 vector bool short vec_or (vector bool short, vector bool short);
14741 vector signed short vec_or (vector bool short, vector signed short);
14742 vector signed short vec_or (vector signed short, vector bool short);
14743 vector signed short vec_or (vector signed short, vector signed short);
14744 vector unsigned short vec_or (vector bool short, vector unsigned short);
14745 vector unsigned short vec_or (vector unsigned short, vector bool short);
14746 vector unsigned short vec_or (vector unsigned short,
14747 vector unsigned short);
14748 vector signed char vec_or (vector bool char, vector signed char);
14749 vector bool char vec_or (vector bool char, vector bool char);
14750 vector signed char vec_or (vector signed char, vector bool char);
14751 vector signed char vec_or (vector signed char, vector signed char);
14752 vector unsigned char vec_or (vector bool char, vector unsigned char);
14753 vector unsigned char vec_or (vector unsigned char, vector bool char);
14754 vector unsigned char vec_or (vector unsigned char,
14755 vector unsigned char);
14756
14757 vector signed char vec_pack (vector signed short, vector signed short);
14758 vector unsigned char vec_pack (vector unsigned short,
14759 vector unsigned short);
14760 vector bool char vec_pack (vector bool short, vector bool short);
14761 vector signed short vec_pack (vector signed int, vector signed int);
14762 vector unsigned short vec_pack (vector unsigned int,
14763 vector unsigned int);
14764 vector bool short vec_pack (vector bool int, vector bool int);
14765
14766 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14767 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14768 vector unsigned short vec_vpkuwum (vector unsigned int,
14769 vector unsigned int);
14770
14771 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14772 vector signed char vec_vpkuhum (vector signed short,
14773 vector signed short);
14774 vector unsigned char vec_vpkuhum (vector unsigned short,
14775 vector unsigned short);
14776
14777 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14778
14779 vector unsigned char vec_packs (vector unsigned short,
14780 vector unsigned short);
14781 vector signed char vec_packs (vector signed short, vector signed short);
14782 vector unsigned short vec_packs (vector unsigned int,
14783 vector unsigned int);
14784 vector signed short vec_packs (vector signed int, vector signed int);
14785
14786 vector signed short vec_vpkswss (vector signed int, vector signed int);
14787
14788 vector unsigned short vec_vpkuwus (vector unsigned int,
14789 vector unsigned int);
14790
14791 vector signed char vec_vpkshss (vector signed short,
14792 vector signed short);
14793
14794 vector unsigned char vec_vpkuhus (vector unsigned short,
14795 vector unsigned short);
14796
14797 vector unsigned char vec_packsu (vector unsigned short,
14798 vector unsigned short);
14799 vector unsigned char vec_packsu (vector signed short,
14800 vector signed short);
14801 vector unsigned short vec_packsu (vector unsigned int,
14802 vector unsigned int);
14803 vector unsigned short vec_packsu (vector signed int, vector signed int);
14804
14805 vector unsigned short vec_vpkswus (vector signed int,
14806 vector signed int);
14807
14808 vector unsigned char vec_vpkshus (vector signed short,
14809 vector signed short);
14810
14811 vector float vec_perm (vector float,
14812 vector float,
14813 vector unsigned char);
14814 vector signed int vec_perm (vector signed int,
14815 vector signed int,
14816 vector unsigned char);
14817 vector unsigned int vec_perm (vector unsigned int,
14818 vector unsigned int,
14819 vector unsigned char);
14820 vector bool int vec_perm (vector bool int,
14821 vector bool int,
14822 vector unsigned char);
14823 vector signed short vec_perm (vector signed short,
14824 vector signed short,
14825 vector unsigned char);
14826 vector unsigned short vec_perm (vector unsigned short,
14827 vector unsigned short,
14828 vector unsigned char);
14829 vector bool short vec_perm (vector bool short,
14830 vector bool short,
14831 vector unsigned char);
14832 vector pixel vec_perm (vector pixel,
14833 vector pixel,
14834 vector unsigned char);
14835 vector signed char vec_perm (vector signed char,
14836 vector signed char,
14837 vector unsigned char);
14838 vector unsigned char vec_perm (vector unsigned char,
14839 vector unsigned char,
14840 vector unsigned char);
14841 vector bool char vec_perm (vector bool char,
14842 vector bool char,
14843 vector unsigned char);
14844
14845 vector float vec_re (vector float);
14846
14847 vector signed char vec_rl (vector signed char,
14848 vector unsigned char);
14849 vector unsigned char vec_rl (vector unsigned char,
14850 vector unsigned char);
14851 vector signed short vec_rl (vector signed short, vector unsigned short);
14852 vector unsigned short vec_rl (vector unsigned short,
14853 vector unsigned short);
14854 vector signed int vec_rl (vector signed int, vector unsigned int);
14855 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14856
14857 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14858 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14859
14860 vector signed short vec_vrlh (vector signed short,
14861 vector unsigned short);
14862 vector unsigned short vec_vrlh (vector unsigned short,
14863 vector unsigned short);
14864
14865 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14866 vector unsigned char vec_vrlb (vector unsigned char,
14867 vector unsigned char);
14868
14869 vector float vec_round (vector float);
14870
14871 vector float vec_recip (vector float, vector float);
14872
14873 vector float vec_rsqrt (vector float);
14874
14875 vector float vec_rsqrte (vector float);
14876
14877 vector float vec_sel (vector float, vector float, vector bool int);
14878 vector float vec_sel (vector float, vector float, vector unsigned int);
14879 vector signed int vec_sel (vector signed int,
14880 vector signed int,
14881 vector bool int);
14882 vector signed int vec_sel (vector signed int,
14883 vector signed int,
14884 vector unsigned int);
14885 vector unsigned int vec_sel (vector unsigned int,
14886 vector unsigned int,
14887 vector bool int);
14888 vector unsigned int vec_sel (vector unsigned int,
14889 vector unsigned int,
14890 vector unsigned int);
14891 vector bool int vec_sel (vector bool int,
14892 vector bool int,
14893 vector bool int);
14894 vector bool int vec_sel (vector bool int,
14895 vector bool int,
14896 vector unsigned int);
14897 vector signed short vec_sel (vector signed short,
14898 vector signed short,
14899 vector bool short);
14900 vector signed short vec_sel (vector signed short,
14901 vector signed short,
14902 vector unsigned short);
14903 vector unsigned short vec_sel (vector unsigned short,
14904 vector unsigned short,
14905 vector bool short);
14906 vector unsigned short vec_sel (vector unsigned short,
14907 vector unsigned short,
14908 vector unsigned short);
14909 vector bool short vec_sel (vector bool short,
14910 vector bool short,
14911 vector bool short);
14912 vector bool short vec_sel (vector bool short,
14913 vector bool short,
14914 vector unsigned short);
14915 vector signed char vec_sel (vector signed char,
14916 vector signed char,
14917 vector bool char);
14918 vector signed char vec_sel (vector signed char,
14919 vector signed char,
14920 vector unsigned char);
14921 vector unsigned char vec_sel (vector unsigned char,
14922 vector unsigned char,
14923 vector bool char);
14924 vector unsigned char vec_sel (vector unsigned char,
14925 vector unsigned char,
14926 vector unsigned char);
14927 vector bool char vec_sel (vector bool char,
14928 vector bool char,
14929 vector bool char);
14930 vector bool char vec_sel (vector bool char,
14931 vector bool char,
14932 vector unsigned char);
14933
14934 vector signed char vec_sl (vector signed char,
14935 vector unsigned char);
14936 vector unsigned char vec_sl (vector unsigned char,
14937 vector unsigned char);
14938 vector signed short vec_sl (vector signed short, vector unsigned short);
14939 vector unsigned short vec_sl (vector unsigned short,
14940 vector unsigned short);
14941 vector signed int vec_sl (vector signed int, vector unsigned int);
14942 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14943
14944 vector signed int vec_vslw (vector signed int, vector unsigned int);
14945 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14946
14947 vector signed short vec_vslh (vector signed short,
14948 vector unsigned short);
14949 vector unsigned short vec_vslh (vector unsigned short,
14950 vector unsigned short);
14951
14952 vector signed char vec_vslb (vector signed char, vector unsigned char);
14953 vector unsigned char vec_vslb (vector unsigned char,
14954 vector unsigned char);
14955
14956 vector float vec_sld (vector float, vector float, const int);
14957 vector signed int vec_sld (vector signed int,
14958 vector signed int,
14959 const int);
14960 vector unsigned int vec_sld (vector unsigned int,
14961 vector unsigned int,
14962 const int);
14963 vector bool int vec_sld (vector bool int,
14964 vector bool int,
14965 const int);
14966 vector signed short vec_sld (vector signed short,
14967 vector signed short,
14968 const int);
14969 vector unsigned short vec_sld (vector unsigned short,
14970 vector unsigned short,
14971 const int);
14972 vector bool short vec_sld (vector bool short,
14973 vector bool short,
14974 const int);
14975 vector pixel vec_sld (vector pixel,
14976 vector pixel,
14977 const int);
14978 vector signed char vec_sld (vector signed char,
14979 vector signed char,
14980 const int);
14981 vector unsigned char vec_sld (vector unsigned char,
14982 vector unsigned char,
14983 const int);
14984 vector bool char vec_sld (vector bool char,
14985 vector bool char,
14986 const int);
14987
14988 vector signed int vec_sll (vector signed int,
14989 vector unsigned int);
14990 vector signed int vec_sll (vector signed int,
14991 vector unsigned short);
14992 vector signed int vec_sll (vector signed int,
14993 vector unsigned char);
14994 vector unsigned int vec_sll (vector unsigned int,
14995 vector unsigned int);
14996 vector unsigned int vec_sll (vector unsigned int,
14997 vector unsigned short);
14998 vector unsigned int vec_sll (vector unsigned int,
14999 vector unsigned char);
15000 vector bool int vec_sll (vector bool int,
15001 vector unsigned int);
15002 vector bool int vec_sll (vector bool int,
15003 vector unsigned short);
15004 vector bool int vec_sll (vector bool int,
15005 vector unsigned char);
15006 vector signed short vec_sll (vector signed short,
15007 vector unsigned int);
15008 vector signed short vec_sll (vector signed short,
15009 vector unsigned short);
15010 vector signed short vec_sll (vector signed short,
15011 vector unsigned char);
15012 vector unsigned short vec_sll (vector unsigned short,
15013 vector unsigned int);
15014 vector unsigned short vec_sll (vector unsigned short,
15015 vector unsigned short);
15016 vector unsigned short vec_sll (vector unsigned short,
15017 vector unsigned char);
15018 vector bool short vec_sll (vector bool short, vector unsigned int);
15019 vector bool short vec_sll (vector bool short, vector unsigned short);
15020 vector bool short vec_sll (vector bool short, vector unsigned char);
15021 vector pixel vec_sll (vector pixel, vector unsigned int);
15022 vector pixel vec_sll (vector pixel, vector unsigned short);
15023 vector pixel vec_sll (vector pixel, vector unsigned char);
15024 vector signed char vec_sll (vector signed char, vector unsigned int);
15025 vector signed char vec_sll (vector signed char, vector unsigned short);
15026 vector signed char vec_sll (vector signed char, vector unsigned char);
15027 vector unsigned char vec_sll (vector unsigned char,
15028 vector unsigned int);
15029 vector unsigned char vec_sll (vector unsigned char,
15030 vector unsigned short);
15031 vector unsigned char vec_sll (vector unsigned char,
15032 vector unsigned char);
15033 vector bool char vec_sll (vector bool char, vector unsigned int);
15034 vector bool char vec_sll (vector bool char, vector unsigned short);
15035 vector bool char vec_sll (vector bool char, vector unsigned char);
15036
15037 vector float vec_slo (vector float, vector signed char);
15038 vector float vec_slo (vector float, vector unsigned char);
15039 vector signed int vec_slo (vector signed int, vector signed char);
15040 vector signed int vec_slo (vector signed int, vector unsigned char);
15041 vector unsigned int vec_slo (vector unsigned int, vector signed char);
15042 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
15043 vector signed short vec_slo (vector signed short, vector signed char);
15044 vector signed short vec_slo (vector signed short, vector unsigned char);
15045 vector unsigned short vec_slo (vector unsigned short,
15046 vector signed char);
15047 vector unsigned short vec_slo (vector unsigned short,
15048 vector unsigned char);
15049 vector pixel vec_slo (vector pixel, vector signed char);
15050 vector pixel vec_slo (vector pixel, vector unsigned char);
15051 vector signed char vec_slo (vector signed char, vector signed char);
15052 vector signed char vec_slo (vector signed char, vector unsigned char);
15053 vector unsigned char vec_slo (vector unsigned char, vector signed char);
15054 vector unsigned char vec_slo (vector unsigned char,
15055 vector unsigned char);
15056
15057 vector signed char vec_splat (vector signed char, const int);
15058 vector unsigned char vec_splat (vector unsigned char, const int);
15059 vector bool char vec_splat (vector bool char, const int);
15060 vector signed short vec_splat (vector signed short, const int);
15061 vector unsigned short vec_splat (vector unsigned short, const int);
15062 vector bool short vec_splat (vector bool short, const int);
15063 vector pixel vec_splat (vector pixel, const int);
15064 vector float vec_splat (vector float, const int);
15065 vector signed int vec_splat (vector signed int, const int);
15066 vector unsigned int vec_splat (vector unsigned int, const int);
15067 vector bool int vec_splat (vector bool int, const int);
15068 vector signed long vec_splat (vector signed long, const int);
15069 vector unsigned long vec_splat (vector unsigned long, const int);
15070
15071 vector signed char vec_splats (signed char);
15072 vector unsigned char vec_splats (unsigned char);
15073 vector signed short vec_splats (signed short);
15074 vector unsigned short vec_splats (unsigned short);
15075 vector signed int vec_splats (signed int);
15076 vector unsigned int vec_splats (unsigned int);
15077 vector float vec_splats (float);
15078
15079 vector float vec_vspltw (vector float, const int);
15080 vector signed int vec_vspltw (vector signed int, const int);
15081 vector unsigned int vec_vspltw (vector unsigned int, const int);
15082 vector bool int vec_vspltw (vector bool int, const int);
15083
15084 vector bool short vec_vsplth (vector bool short, const int);
15085 vector signed short vec_vsplth (vector signed short, const int);
15086 vector unsigned short vec_vsplth (vector unsigned short, const int);
15087 vector pixel vec_vsplth (vector pixel, const int);
15088
15089 vector signed char vec_vspltb (vector signed char, const int);
15090 vector unsigned char vec_vspltb (vector unsigned char, const int);
15091 vector bool char vec_vspltb (vector bool char, const int);
15092
15093 vector signed char vec_splat_s8 (const int);
15094
15095 vector signed short vec_splat_s16 (const int);
15096
15097 vector signed int vec_splat_s32 (const int);
15098
15099 vector unsigned char vec_splat_u8 (const int);
15100
15101 vector unsigned short vec_splat_u16 (const int);
15102
15103 vector unsigned int vec_splat_u32 (const int);
15104
15105 vector signed char vec_sr (vector signed char, vector unsigned char);
15106 vector unsigned char vec_sr (vector unsigned char,
15107 vector unsigned char);
15108 vector signed short vec_sr (vector signed short,
15109 vector unsigned short);
15110 vector unsigned short vec_sr (vector unsigned short,
15111 vector unsigned short);
15112 vector signed int vec_sr (vector signed int, vector unsigned int);
15113 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
15114
15115 vector signed int vec_vsrw (vector signed int, vector unsigned int);
15116 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
15117
15118 vector signed short vec_vsrh (vector signed short,
15119 vector unsigned short);
15120 vector unsigned short vec_vsrh (vector unsigned short,
15121 vector unsigned short);
15122
15123 vector signed char vec_vsrb (vector signed char, vector unsigned char);
15124 vector unsigned char vec_vsrb (vector unsigned char,
15125 vector unsigned char);
15126
15127 vector signed char vec_sra (vector signed char, vector unsigned char);
15128 vector unsigned char vec_sra (vector unsigned char,
15129 vector unsigned char);
15130 vector signed short vec_sra (vector signed short,
15131 vector unsigned short);
15132 vector unsigned short vec_sra (vector unsigned short,
15133 vector unsigned short);
15134 vector signed int vec_sra (vector signed int, vector unsigned int);
15135 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
15136
15137 vector signed int vec_vsraw (vector signed int, vector unsigned int);
15138 vector unsigned int vec_vsraw (vector unsigned int,
15139 vector unsigned int);
15140
15141 vector signed short vec_vsrah (vector signed short,
15142 vector unsigned short);
15143 vector unsigned short vec_vsrah (vector unsigned short,
15144 vector unsigned short);
15145
15146 vector signed char vec_vsrab (vector signed char, vector unsigned char);
15147 vector unsigned char vec_vsrab (vector unsigned char,
15148 vector unsigned char);
15149
15150 vector signed int vec_srl (vector signed int, vector unsigned int);
15151 vector signed int vec_srl (vector signed int, vector unsigned short);
15152 vector signed int vec_srl (vector signed int, vector unsigned char);
15153 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
15154 vector unsigned int vec_srl (vector unsigned int,
15155 vector unsigned short);
15156 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
15157 vector bool int vec_srl (vector bool int, vector unsigned int);
15158 vector bool int vec_srl (vector bool int, vector unsigned short);
15159 vector bool int vec_srl (vector bool int, vector unsigned char);
15160 vector signed short vec_srl (vector signed short, vector unsigned int);
15161 vector signed short vec_srl (vector signed short,
15162 vector unsigned short);
15163 vector signed short vec_srl (vector signed short, vector unsigned char);
15164 vector unsigned short vec_srl (vector unsigned short,
15165 vector unsigned int);
15166 vector unsigned short vec_srl (vector unsigned short,
15167 vector unsigned short);
15168 vector unsigned short vec_srl (vector unsigned short,
15169 vector unsigned char);
15170 vector bool short vec_srl (vector bool short, vector unsigned int);
15171 vector bool short vec_srl (vector bool short, vector unsigned short);
15172 vector bool short vec_srl (vector bool short, vector unsigned char);
15173 vector pixel vec_srl (vector pixel, vector unsigned int);
15174 vector pixel vec_srl (vector pixel, vector unsigned short);
15175 vector pixel vec_srl (vector pixel, vector unsigned char);
15176 vector signed char vec_srl (vector signed char, vector unsigned int);
15177 vector signed char vec_srl (vector signed char, vector unsigned short);
15178 vector signed char vec_srl (vector signed char, vector unsigned char);
15179 vector unsigned char vec_srl (vector unsigned char,
15180 vector unsigned int);
15181 vector unsigned char vec_srl (vector unsigned char,
15182 vector unsigned short);
15183 vector unsigned char vec_srl (vector unsigned char,
15184 vector unsigned char);
15185 vector bool char vec_srl (vector bool char, vector unsigned int);
15186 vector bool char vec_srl (vector bool char, vector unsigned short);
15187 vector bool char vec_srl (vector bool char, vector unsigned char);
15188
15189 vector float vec_sro (vector float, vector signed char);
15190 vector float vec_sro (vector float, vector unsigned char);
15191 vector signed int vec_sro (vector signed int, vector signed char);
15192 vector signed int vec_sro (vector signed int, vector unsigned char);
15193 vector unsigned int vec_sro (vector unsigned int, vector signed char);
15194 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
15195 vector signed short vec_sro (vector signed short, vector signed char);
15196 vector signed short vec_sro (vector signed short, vector unsigned char);
15197 vector unsigned short vec_sro (vector unsigned short,
15198 vector signed char);
15199 vector unsigned short vec_sro (vector unsigned short,
15200 vector unsigned char);
15201 vector pixel vec_sro (vector pixel, vector signed char);
15202 vector pixel vec_sro (vector pixel, vector unsigned char);
15203 vector signed char vec_sro (vector signed char, vector signed char);
15204 vector signed char vec_sro (vector signed char, vector unsigned char);
15205 vector unsigned char vec_sro (vector unsigned char, vector signed char);
15206 vector unsigned char vec_sro (vector unsigned char,
15207 vector unsigned char);
15208
15209 void vec_st (vector float, int, vector float *);
15210 void vec_st (vector float, int, float *);
15211 void vec_st (vector signed int, int, vector signed int *);
15212 void vec_st (vector signed int, int, int *);
15213 void vec_st (vector unsigned int, int, vector unsigned int *);
15214 void vec_st (vector unsigned int, int, unsigned int *);
15215 void vec_st (vector bool int, int, vector bool int *);
15216 void vec_st (vector bool int, int, unsigned int *);
15217 void vec_st (vector bool int, int, int *);
15218 void vec_st (vector signed short, int, vector signed short *);
15219 void vec_st (vector signed short, int, short *);
15220 void vec_st (vector unsigned short, int, vector unsigned short *);
15221 void vec_st (vector unsigned short, int, unsigned short *);
15222 void vec_st (vector bool short, int, vector bool short *);
15223 void vec_st (vector bool short, int, unsigned short *);
15224 void vec_st (vector pixel, int, vector pixel *);
15225 void vec_st (vector pixel, int, unsigned short *);
15226 void vec_st (vector pixel, int, short *);
15227 void vec_st (vector bool short, int, short *);
15228 void vec_st (vector signed char, int, vector signed char *);
15229 void vec_st (vector signed char, int, signed char *);
15230 void vec_st (vector unsigned char, int, vector unsigned char *);
15231 void vec_st (vector unsigned char, int, unsigned char *);
15232 void vec_st (vector bool char, int, vector bool char *);
15233 void vec_st (vector bool char, int, unsigned char *);
15234 void vec_st (vector bool char, int, signed char *);
15235
15236 void vec_ste (vector signed char, int, signed char *);
15237 void vec_ste (vector unsigned char, int, unsigned char *);
15238 void vec_ste (vector bool char, int, signed char *);
15239 void vec_ste (vector bool char, int, unsigned char *);
15240 void vec_ste (vector signed short, int, short *);
15241 void vec_ste (vector unsigned short, int, unsigned short *);
15242 void vec_ste (vector bool short, int, short *);
15243 void vec_ste (vector bool short, int, unsigned short *);
15244 void vec_ste (vector pixel, int, short *);
15245 void vec_ste (vector pixel, int, unsigned short *);
15246 void vec_ste (vector float, int, float *);
15247 void vec_ste (vector signed int, int, int *);
15248 void vec_ste (vector unsigned int, int, unsigned int *);
15249 void vec_ste (vector bool int, int, int *);
15250 void vec_ste (vector bool int, int, unsigned int *);
15251
15252 void vec_stvewx (vector float, int, float *);
15253 void vec_stvewx (vector signed int, int, int *);
15254 void vec_stvewx (vector unsigned int, int, unsigned int *);
15255 void vec_stvewx (vector bool int, int, int *);
15256 void vec_stvewx (vector bool int, int, unsigned int *);
15257
15258 void vec_stvehx (vector signed short, int, short *);
15259 void vec_stvehx (vector unsigned short, int, unsigned short *);
15260 void vec_stvehx (vector bool short, int, short *);
15261 void vec_stvehx (vector bool short, int, unsigned short *);
15262 void vec_stvehx (vector pixel, int, short *);
15263 void vec_stvehx (vector pixel, int, unsigned short *);
15264
15265 void vec_stvebx (vector signed char, int, signed char *);
15266 void vec_stvebx (vector unsigned char, int, unsigned char *);
15267 void vec_stvebx (vector bool char, int, signed char *);
15268 void vec_stvebx (vector bool char, int, unsigned char *);
15269
15270 void vec_stl (vector float, int, vector float *);
15271 void vec_stl (vector float, int, float *);
15272 void vec_stl (vector signed int, int, vector signed int *);
15273 void vec_stl (vector signed int, int, int *);
15274 void vec_stl (vector unsigned int, int, vector unsigned int *);
15275 void vec_stl (vector unsigned int, int, unsigned int *);
15276 void vec_stl (vector bool int, int, vector bool int *);
15277 void vec_stl (vector bool int, int, unsigned int *);
15278 void vec_stl (vector bool int, int, int *);
15279 void vec_stl (vector signed short, int, vector signed short *);
15280 void vec_stl (vector signed short, int, short *);
15281 void vec_stl (vector unsigned short, int, vector unsigned short *);
15282 void vec_stl (vector unsigned short, int, unsigned short *);
15283 void vec_stl (vector bool short, int, vector bool short *);
15284 void vec_stl (vector bool short, int, unsigned short *);
15285 void vec_stl (vector bool short, int, short *);
15286 void vec_stl (vector pixel, int, vector pixel *);
15287 void vec_stl (vector pixel, int, unsigned short *);
15288 void vec_stl (vector pixel, int, short *);
15289 void vec_stl (vector signed char, int, vector signed char *);
15290 void vec_stl (vector signed char, int, signed char *);
15291 void vec_stl (vector unsigned char, int, vector unsigned char *);
15292 void vec_stl (vector unsigned char, int, unsigned char *);
15293 void vec_stl (vector bool char, int, vector bool char *);
15294 void vec_stl (vector bool char, int, unsigned char *);
15295 void vec_stl (vector bool char, int, signed char *);
15296
15297 vector signed char vec_sub (vector bool char, vector signed char);
15298 vector signed char vec_sub (vector signed char, vector bool char);
15299 vector signed char vec_sub (vector signed char, vector signed char);
15300 vector unsigned char vec_sub (vector bool char, vector unsigned char);
15301 vector unsigned char vec_sub (vector unsigned char, vector bool char);
15302 vector unsigned char vec_sub (vector unsigned char,
15303 vector unsigned char);
15304 vector signed short vec_sub (vector bool short, vector signed short);
15305 vector signed short vec_sub (vector signed short, vector bool short);
15306 vector signed short vec_sub (vector signed short, vector signed short);
15307 vector unsigned short vec_sub (vector bool short,
15308 vector unsigned short);
15309 vector unsigned short vec_sub (vector unsigned short,
15310 vector bool short);
15311 vector unsigned short vec_sub (vector unsigned short,
15312 vector unsigned short);
15313 vector signed int vec_sub (vector bool int, vector signed int);
15314 vector signed int vec_sub (vector signed int, vector bool int);
15315 vector signed int vec_sub (vector signed int, vector signed int);
15316 vector unsigned int vec_sub (vector bool int, vector unsigned int);
15317 vector unsigned int vec_sub (vector unsigned int, vector bool int);
15318 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
15319 vector float vec_sub (vector float, vector float);
15320
15321 vector float vec_vsubfp (vector float, vector float);
15322
15323 vector signed int vec_vsubuwm (vector bool int, vector signed int);
15324 vector signed int vec_vsubuwm (vector signed int, vector bool int);
15325 vector signed int vec_vsubuwm (vector signed int, vector signed int);
15326 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
15327 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
15328 vector unsigned int vec_vsubuwm (vector unsigned int,
15329 vector unsigned int);
15330
15331 vector signed short vec_vsubuhm (vector bool short,
15332 vector signed short);
15333 vector signed short vec_vsubuhm (vector signed short,
15334 vector bool short);
15335 vector signed short vec_vsubuhm (vector signed short,
15336 vector signed short);
15337 vector unsigned short vec_vsubuhm (vector bool short,
15338 vector unsigned short);
15339 vector unsigned short vec_vsubuhm (vector unsigned short,
15340 vector bool short);
15341 vector unsigned short vec_vsubuhm (vector unsigned short,
15342 vector unsigned short);
15343
15344 vector signed char vec_vsububm (vector bool char, vector signed char);
15345 vector signed char vec_vsububm (vector signed char, vector bool char);
15346 vector signed char vec_vsububm (vector signed char, vector signed char);
15347 vector unsigned char vec_vsububm (vector bool char,
15348 vector unsigned char);
15349 vector unsigned char vec_vsububm (vector unsigned char,
15350 vector bool char);
15351 vector unsigned char vec_vsububm (vector unsigned char,
15352 vector unsigned char);
15353
15354 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
15355
15356 vector unsigned char vec_subs (vector bool char, vector unsigned char);
15357 vector unsigned char vec_subs (vector unsigned char, vector bool char);
15358 vector unsigned char vec_subs (vector unsigned char,
15359 vector unsigned char);
15360 vector signed char vec_subs (vector bool char, vector signed char);
15361 vector signed char vec_subs (vector signed char, vector bool char);
15362 vector signed char vec_subs (vector signed char, vector signed char);
15363 vector unsigned short vec_subs (vector bool short,
15364 vector unsigned short);
15365 vector unsigned short vec_subs (vector unsigned short,
15366 vector bool short);
15367 vector unsigned short vec_subs (vector unsigned short,
15368 vector unsigned short);
15369 vector signed short vec_subs (vector bool short, vector signed short);
15370 vector signed short vec_subs (vector signed short, vector bool short);
15371 vector signed short vec_subs (vector signed short, vector signed short);
15372 vector unsigned int vec_subs (vector bool int, vector unsigned int);
15373 vector unsigned int vec_subs (vector unsigned int, vector bool int);
15374 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
15375 vector signed int vec_subs (vector bool int, vector signed int);
15376 vector signed int vec_subs (vector signed int, vector bool int);
15377 vector signed int vec_subs (vector signed int, vector signed int);
15378
15379 vector signed int vec_vsubsws (vector bool int, vector signed int);
15380 vector signed int vec_vsubsws (vector signed int, vector bool int);
15381 vector signed int vec_vsubsws (vector signed int, vector signed int);
15382
15383 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
15384 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15385 vector unsigned int vec_vsubuws (vector unsigned int,
15386 vector unsigned int);
15387
15388 vector signed short vec_vsubshs (vector bool short,
15389 vector signed short);
15390 vector signed short vec_vsubshs (vector signed short,
15391 vector bool short);
15392 vector signed short vec_vsubshs (vector signed short,
15393 vector signed short);
15394
15395 vector unsigned short vec_vsubuhs (vector bool short,
15396 vector unsigned short);
15397 vector unsigned short vec_vsubuhs (vector unsigned short,
15398 vector bool short);
15399 vector unsigned short vec_vsubuhs (vector unsigned short,
15400 vector unsigned short);
15401
15402 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15403 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15404 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15405
15406 vector unsigned char vec_vsububs (vector bool char,
15407 vector unsigned char);
15408 vector unsigned char vec_vsububs (vector unsigned char,
15409 vector bool char);
15410 vector unsigned char vec_vsububs (vector unsigned char,
15411 vector unsigned char);
15412
15413 vector unsigned int vec_sum4s (vector unsigned char,
15414 vector unsigned int);
15415 vector signed int vec_sum4s (vector signed char, vector signed int);
15416 vector signed int vec_sum4s (vector signed short, vector signed int);
15417
15418 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15419
15420 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15421
15422 vector unsigned int vec_vsum4ubs (vector unsigned char,
15423 vector unsigned int);
15424
15425 vector signed int vec_sum2s (vector signed int, vector signed int);
15426
15427 vector signed int vec_sums (vector signed int, vector signed int);
15428
15429 vector float vec_trunc (vector float);
15430
15431 vector signed short vec_unpackh (vector signed char);
15432 vector bool short vec_unpackh (vector bool char);
15433 vector signed int vec_unpackh (vector signed short);
15434 vector bool int vec_unpackh (vector bool short);
15435 vector unsigned int vec_unpackh (vector pixel);
15436
15437 vector bool int vec_vupkhsh (vector bool short);
15438 vector signed int vec_vupkhsh (vector signed short);
15439
15440 vector unsigned int vec_vupkhpx (vector pixel);
15441
15442 vector bool short vec_vupkhsb (vector bool char);
15443 vector signed short vec_vupkhsb (vector signed char);
15444
15445 vector signed short vec_unpackl (vector signed char);
15446 vector bool short vec_unpackl (vector bool char);
15447 vector unsigned int vec_unpackl (vector pixel);
15448 vector signed int vec_unpackl (vector signed short);
15449 vector bool int vec_unpackl (vector bool short);
15450
15451 vector unsigned int vec_vupklpx (vector pixel);
15452
15453 vector bool int vec_vupklsh (vector bool short);
15454 vector signed int vec_vupklsh (vector signed short);
15455
15456 vector bool short vec_vupklsb (vector bool char);
15457 vector signed short vec_vupklsb (vector signed char);
15458
15459 vector float vec_xor (vector float, vector float);
15460 vector float vec_xor (vector float, vector bool int);
15461 vector float vec_xor (vector bool int, vector float);
15462 vector bool int vec_xor (vector bool int, vector bool int);
15463 vector signed int vec_xor (vector bool int, vector signed int);
15464 vector signed int vec_xor (vector signed int, vector bool int);
15465 vector signed int vec_xor (vector signed int, vector signed int);
15466 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15467 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15468 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15469 vector bool short vec_xor (vector bool short, vector bool short);
15470 vector signed short vec_xor (vector bool short, vector signed short);
15471 vector signed short vec_xor (vector signed short, vector bool short);
15472 vector signed short vec_xor (vector signed short, vector signed short);
15473 vector unsigned short vec_xor (vector bool short,
15474 vector unsigned short);
15475 vector unsigned short vec_xor (vector unsigned short,
15476 vector bool short);
15477 vector unsigned short vec_xor (vector unsigned short,
15478 vector unsigned short);
15479 vector signed char vec_xor (vector bool char, vector signed char);
15480 vector bool char vec_xor (vector bool char, vector bool char);
15481 vector signed char vec_xor (vector signed char, vector bool char);
15482 vector signed char vec_xor (vector signed char, vector signed char);
15483 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15484 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15485 vector unsigned char vec_xor (vector unsigned char,
15486 vector unsigned char);
15487
15488 int vec_all_eq (vector signed char, vector bool char);
15489 int vec_all_eq (vector signed char, vector signed char);
15490 int vec_all_eq (vector unsigned char, vector bool char);
15491 int vec_all_eq (vector unsigned char, vector unsigned char);
15492 int vec_all_eq (vector bool char, vector bool char);
15493 int vec_all_eq (vector bool char, vector unsigned char);
15494 int vec_all_eq (vector bool char, vector signed char);
15495 int vec_all_eq (vector signed short, vector bool short);
15496 int vec_all_eq (vector signed short, vector signed short);
15497 int vec_all_eq (vector unsigned short, vector bool short);
15498 int vec_all_eq (vector unsigned short, vector unsigned short);
15499 int vec_all_eq (vector bool short, vector bool short);
15500 int vec_all_eq (vector bool short, vector unsigned short);
15501 int vec_all_eq (vector bool short, vector signed short);
15502 int vec_all_eq (vector pixel, vector pixel);
15503 int vec_all_eq (vector signed int, vector bool int);
15504 int vec_all_eq (vector signed int, vector signed int);
15505 int vec_all_eq (vector unsigned int, vector bool int);
15506 int vec_all_eq (vector unsigned int, vector unsigned int);
15507 int vec_all_eq (vector bool int, vector bool int);
15508 int vec_all_eq (vector bool int, vector unsigned int);
15509 int vec_all_eq (vector bool int, vector signed int);
15510 int vec_all_eq (vector float, vector float);
15511
15512 int vec_all_ge (vector bool char, vector unsigned char);
15513 int vec_all_ge (vector unsigned char, vector bool char);
15514 int vec_all_ge (vector unsigned char, vector unsigned char);
15515 int vec_all_ge (vector bool char, vector signed char);
15516 int vec_all_ge (vector signed char, vector bool char);
15517 int vec_all_ge (vector signed char, vector signed char);
15518 int vec_all_ge (vector bool short, vector unsigned short);
15519 int vec_all_ge (vector unsigned short, vector bool short);
15520 int vec_all_ge (vector unsigned short, vector unsigned short);
15521 int vec_all_ge (vector signed short, vector signed short);
15522 int vec_all_ge (vector bool short, vector signed short);
15523 int vec_all_ge (vector signed short, vector bool short);
15524 int vec_all_ge (vector bool int, vector unsigned int);
15525 int vec_all_ge (vector unsigned int, vector bool int);
15526 int vec_all_ge (vector unsigned int, vector unsigned int);
15527 int vec_all_ge (vector bool int, vector signed int);
15528 int vec_all_ge (vector signed int, vector bool int);
15529 int vec_all_ge (vector signed int, vector signed int);
15530 int vec_all_ge (vector float, vector float);
15531
15532 int vec_all_gt (vector bool char, vector unsigned char);
15533 int vec_all_gt (vector unsigned char, vector bool char);
15534 int vec_all_gt (vector unsigned char, vector unsigned char);
15535 int vec_all_gt (vector bool char, vector signed char);
15536 int vec_all_gt (vector signed char, vector bool char);
15537 int vec_all_gt (vector signed char, vector signed char);
15538 int vec_all_gt (vector bool short, vector unsigned short);
15539 int vec_all_gt (vector unsigned short, vector bool short);
15540 int vec_all_gt (vector unsigned short, vector unsigned short);
15541 int vec_all_gt (vector bool short, vector signed short);
15542 int vec_all_gt (vector signed short, vector bool short);
15543 int vec_all_gt (vector signed short, vector signed short);
15544 int vec_all_gt (vector bool int, vector unsigned int);
15545 int vec_all_gt (vector unsigned int, vector bool int);
15546 int vec_all_gt (vector unsigned int, vector unsigned int);
15547 int vec_all_gt (vector bool int, vector signed int);
15548 int vec_all_gt (vector signed int, vector bool int);
15549 int vec_all_gt (vector signed int, vector signed int);
15550 int vec_all_gt (vector float, vector float);
15551
15552 int vec_all_in (vector float, vector float);
15553
15554 int vec_all_le (vector bool char, vector unsigned char);
15555 int vec_all_le (vector unsigned char, vector bool char);
15556 int vec_all_le (vector unsigned char, vector unsigned char);
15557 int vec_all_le (vector bool char, vector signed char);
15558 int vec_all_le (vector signed char, vector bool char);
15559 int vec_all_le (vector signed char, vector signed char);
15560 int vec_all_le (vector bool short, vector unsigned short);
15561 int vec_all_le (vector unsigned short, vector bool short);
15562 int vec_all_le (vector unsigned short, vector unsigned short);
15563 int vec_all_le (vector bool short, vector signed short);
15564 int vec_all_le (vector signed short, vector bool short);
15565 int vec_all_le (vector signed short, vector signed short);
15566 int vec_all_le (vector bool int, vector unsigned int);
15567 int vec_all_le (vector unsigned int, vector bool int);
15568 int vec_all_le (vector unsigned int, vector unsigned int);
15569 int vec_all_le (vector bool int, vector signed int);
15570 int vec_all_le (vector signed int, vector bool int);
15571 int vec_all_le (vector signed int, vector signed int);
15572 int vec_all_le (vector float, vector float);
15573
15574 int vec_all_lt (vector bool char, vector unsigned char);
15575 int vec_all_lt (vector unsigned char, vector bool char);
15576 int vec_all_lt (vector unsigned char, vector unsigned char);
15577 int vec_all_lt (vector bool char, vector signed char);
15578 int vec_all_lt (vector signed char, vector bool char);
15579 int vec_all_lt (vector signed char, vector signed char);
15580 int vec_all_lt (vector bool short, vector unsigned short);
15581 int vec_all_lt (vector unsigned short, vector bool short);
15582 int vec_all_lt (vector unsigned short, vector unsigned short);
15583 int vec_all_lt (vector bool short, vector signed short);
15584 int vec_all_lt (vector signed short, vector bool short);
15585 int vec_all_lt (vector signed short, vector signed short);
15586 int vec_all_lt (vector bool int, vector unsigned int);
15587 int vec_all_lt (vector unsigned int, vector bool int);
15588 int vec_all_lt (vector unsigned int, vector unsigned int);
15589 int vec_all_lt (vector bool int, vector signed int);
15590 int vec_all_lt (vector signed int, vector bool int);
15591 int vec_all_lt (vector signed int, vector signed int);
15592 int vec_all_lt (vector float, vector float);
15593
15594 int vec_all_nan (vector float);
15595
15596 int vec_all_ne (vector signed char, vector bool char);
15597 int vec_all_ne (vector signed char, vector signed char);
15598 int vec_all_ne (vector unsigned char, vector bool char);
15599 int vec_all_ne (vector unsigned char, vector unsigned char);
15600 int vec_all_ne (vector bool char, vector bool char);
15601 int vec_all_ne (vector bool char, vector unsigned char);
15602 int vec_all_ne (vector bool char, vector signed char);
15603 int vec_all_ne (vector signed short, vector bool short);
15604 int vec_all_ne (vector signed short, vector signed short);
15605 int vec_all_ne (vector unsigned short, vector bool short);
15606 int vec_all_ne (vector unsigned short, vector unsigned short);
15607 int vec_all_ne (vector bool short, vector bool short);
15608 int vec_all_ne (vector bool short, vector unsigned short);
15609 int vec_all_ne (vector bool short, vector signed short);
15610 int vec_all_ne (vector pixel, vector pixel);
15611 int vec_all_ne (vector signed int, vector bool int);
15612 int vec_all_ne (vector signed int, vector signed int);
15613 int vec_all_ne (vector unsigned int, vector bool int);
15614 int vec_all_ne (vector unsigned int, vector unsigned int);
15615 int vec_all_ne (vector bool int, vector bool int);
15616 int vec_all_ne (vector bool int, vector unsigned int);
15617 int vec_all_ne (vector bool int, vector signed int);
15618 int vec_all_ne (vector float, vector float);
15619
15620 int vec_all_nge (vector float, vector float);
15621
15622 int vec_all_ngt (vector float, vector float);
15623
15624 int vec_all_nle (vector float, vector float);
15625
15626 int vec_all_nlt (vector float, vector float);
15627
15628 int vec_all_numeric (vector float);
15629
15630 int vec_any_eq (vector signed char, vector bool char);
15631 int vec_any_eq (vector signed char, vector signed char);
15632 int vec_any_eq (vector unsigned char, vector bool char);
15633 int vec_any_eq (vector unsigned char, vector unsigned char);
15634 int vec_any_eq (vector bool char, vector bool char);
15635 int vec_any_eq (vector bool char, vector unsigned char);
15636 int vec_any_eq (vector bool char, vector signed char);
15637 int vec_any_eq (vector signed short, vector bool short);
15638 int vec_any_eq (vector signed short, vector signed short);
15639 int vec_any_eq (vector unsigned short, vector bool short);
15640 int vec_any_eq (vector unsigned short, vector unsigned short);
15641 int vec_any_eq (vector bool short, vector bool short);
15642 int vec_any_eq (vector bool short, vector unsigned short);
15643 int vec_any_eq (vector bool short, vector signed short);
15644 int vec_any_eq (vector pixel, vector pixel);
15645 int vec_any_eq (vector signed int, vector bool int);
15646 int vec_any_eq (vector signed int, vector signed int);
15647 int vec_any_eq (vector unsigned int, vector bool int);
15648 int vec_any_eq (vector unsigned int, vector unsigned int);
15649 int vec_any_eq (vector bool int, vector bool int);
15650 int vec_any_eq (vector bool int, vector unsigned int);
15651 int vec_any_eq (vector bool int, vector signed int);
15652 int vec_any_eq (vector float, vector float);
15653
15654 int vec_any_ge (vector signed char, vector bool char);
15655 int vec_any_ge (vector unsigned char, vector bool char);
15656 int vec_any_ge (vector unsigned char, vector unsigned char);
15657 int vec_any_ge (vector signed char, vector signed char);
15658 int vec_any_ge (vector bool char, vector unsigned char);
15659 int vec_any_ge (vector bool char, vector signed char);
15660 int vec_any_ge (vector unsigned short, vector bool short);
15661 int vec_any_ge (vector unsigned short, vector unsigned short);
15662 int vec_any_ge (vector signed short, vector signed short);
15663 int vec_any_ge (vector signed short, vector bool short);
15664 int vec_any_ge (vector bool short, vector unsigned short);
15665 int vec_any_ge (vector bool short, vector signed short);
15666 int vec_any_ge (vector signed int, vector bool int);
15667 int vec_any_ge (vector unsigned int, vector bool int);
15668 int vec_any_ge (vector unsigned int, vector unsigned int);
15669 int vec_any_ge (vector signed int, vector signed int);
15670 int vec_any_ge (vector bool int, vector unsigned int);
15671 int vec_any_ge (vector bool int, vector signed int);
15672 int vec_any_ge (vector float, vector float);
15673
15674 int vec_any_gt (vector bool char, vector unsigned char);
15675 int vec_any_gt (vector unsigned char, vector bool char);
15676 int vec_any_gt (vector unsigned char, vector unsigned char);
15677 int vec_any_gt (vector bool char, vector signed char);
15678 int vec_any_gt (vector signed char, vector bool char);
15679 int vec_any_gt (vector signed char, vector signed char);
15680 int vec_any_gt (vector bool short, vector unsigned short);
15681 int vec_any_gt (vector unsigned short, vector bool short);
15682 int vec_any_gt (vector unsigned short, vector unsigned short);
15683 int vec_any_gt (vector bool short, vector signed short);
15684 int vec_any_gt (vector signed short, vector bool short);
15685 int vec_any_gt (vector signed short, vector signed short);
15686 int vec_any_gt (vector bool int, vector unsigned int);
15687 int vec_any_gt (vector unsigned int, vector bool int);
15688 int vec_any_gt (vector unsigned int, vector unsigned int);
15689 int vec_any_gt (vector bool int, vector signed int);
15690 int vec_any_gt (vector signed int, vector bool int);
15691 int vec_any_gt (vector signed int, vector signed int);
15692 int vec_any_gt (vector float, vector float);
15693
15694 int vec_any_le (vector bool char, vector unsigned char);
15695 int vec_any_le (vector unsigned char, vector bool char);
15696 int vec_any_le (vector unsigned char, vector unsigned char);
15697 int vec_any_le (vector bool char, vector signed char);
15698 int vec_any_le (vector signed char, vector bool char);
15699 int vec_any_le (vector signed char, vector signed char);
15700 int vec_any_le (vector bool short, vector unsigned short);
15701 int vec_any_le (vector unsigned short, vector bool short);
15702 int vec_any_le (vector unsigned short, vector unsigned short);
15703 int vec_any_le (vector bool short, vector signed short);
15704 int vec_any_le (vector signed short, vector bool short);
15705 int vec_any_le (vector signed short, vector signed short);
15706 int vec_any_le (vector bool int, vector unsigned int);
15707 int vec_any_le (vector unsigned int, vector bool int);
15708 int vec_any_le (vector unsigned int, vector unsigned int);
15709 int vec_any_le (vector bool int, vector signed int);
15710 int vec_any_le (vector signed int, vector bool int);
15711 int vec_any_le (vector signed int, vector signed int);
15712 int vec_any_le (vector float, vector float);
15713
15714 int vec_any_lt (vector bool char, vector unsigned char);
15715 int vec_any_lt (vector unsigned char, vector bool char);
15716 int vec_any_lt (vector unsigned char, vector unsigned char);
15717 int vec_any_lt (vector bool char, vector signed char);
15718 int vec_any_lt (vector signed char, vector bool char);
15719 int vec_any_lt (vector signed char, vector signed char);
15720 int vec_any_lt (vector bool short, vector unsigned short);
15721 int vec_any_lt (vector unsigned short, vector bool short);
15722 int vec_any_lt (vector unsigned short, vector unsigned short);
15723 int vec_any_lt (vector bool short, vector signed short);
15724 int vec_any_lt (vector signed short, vector bool short);
15725 int vec_any_lt (vector signed short, vector signed short);
15726 int vec_any_lt (vector bool int, vector unsigned int);
15727 int vec_any_lt (vector unsigned int, vector bool int);
15728 int vec_any_lt (vector unsigned int, vector unsigned int);
15729 int vec_any_lt (vector bool int, vector signed int);
15730 int vec_any_lt (vector signed int, vector bool int);
15731 int vec_any_lt (vector signed int, vector signed int);
15732 int vec_any_lt (vector float, vector float);
15733
15734 int vec_any_nan (vector float);
15735
15736 int vec_any_ne (vector signed char, vector bool char);
15737 int vec_any_ne (vector signed char, vector signed char);
15738 int vec_any_ne (vector unsigned char, vector bool char);
15739 int vec_any_ne (vector unsigned char, vector unsigned char);
15740 int vec_any_ne (vector bool char, vector bool char);
15741 int vec_any_ne (vector bool char, vector unsigned char);
15742 int vec_any_ne (vector bool char, vector signed char);
15743 int vec_any_ne (vector signed short, vector bool short);
15744 int vec_any_ne (vector signed short, vector signed short);
15745 int vec_any_ne (vector unsigned short, vector bool short);
15746 int vec_any_ne (vector unsigned short, vector unsigned short);
15747 int vec_any_ne (vector bool short, vector bool short);
15748 int vec_any_ne (vector bool short, vector unsigned short);
15749 int vec_any_ne (vector bool short, vector signed short);
15750 int vec_any_ne (vector pixel, vector pixel);
15751 int vec_any_ne (vector signed int, vector bool int);
15752 int vec_any_ne (vector signed int, vector signed int);
15753 int vec_any_ne (vector unsigned int, vector bool int);
15754 int vec_any_ne (vector unsigned int, vector unsigned int);
15755 int vec_any_ne (vector bool int, vector bool int);
15756 int vec_any_ne (vector bool int, vector unsigned int);
15757 int vec_any_ne (vector bool int, vector signed int);
15758 int vec_any_ne (vector float, vector float);
15759
15760 int vec_any_nge (vector float, vector float);
15761
15762 int vec_any_ngt (vector float, vector float);
15763
15764 int vec_any_nle (vector float, vector float);
15765
15766 int vec_any_nlt (vector float, vector float);
15767
15768 int vec_any_numeric (vector float);
15769
15770 int vec_any_out (vector float, vector float);
15771 @end smallexample
15772
15773 If the vector/scalar (VSX) instruction set is available, the following
15774 additional functions are available:
15775
15776 @smallexample
15777 vector double vec_abs (vector double);
15778 vector double vec_add (vector double, vector double);
15779 vector double vec_and (vector double, vector double);
15780 vector double vec_and (vector double, vector bool long);
15781 vector double vec_and (vector bool long, vector double);
15782 vector long vec_and (vector long, vector long);
15783 vector long vec_and (vector long, vector bool long);
15784 vector long vec_and (vector bool long, vector long);
15785 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15786 vector unsigned long vec_and (vector unsigned long, vector bool long);
15787 vector unsigned long vec_and (vector bool long, vector unsigned long);
15788 vector double vec_andc (vector double, vector double);
15789 vector double vec_andc (vector double, vector bool long);
15790 vector double vec_andc (vector bool long, vector double);
15791 vector long vec_andc (vector long, vector long);
15792 vector long vec_andc (vector long, vector bool long);
15793 vector long vec_andc (vector bool long, vector long);
15794 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15795 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15796 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15797 vector double vec_ceil (vector double);
15798 vector bool long vec_cmpeq (vector double, vector double);
15799 vector bool long vec_cmpge (vector double, vector double);
15800 vector bool long vec_cmpgt (vector double, vector double);
15801 vector bool long vec_cmple (vector double, vector double);
15802 vector bool long vec_cmplt (vector double, vector double);
15803 vector double vec_cpsgn (vector double, vector double);
15804 vector float vec_div (vector float, vector float);
15805 vector double vec_div (vector double, vector double);
15806 vector long vec_div (vector long, vector long);
15807 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15808 vector double vec_floor (vector double);
15809 vector double vec_ld (int, const vector double *);
15810 vector double vec_ld (int, const double *);
15811 vector double vec_ldl (int, const vector double *);
15812 vector double vec_ldl (int, const double *);
15813 vector unsigned char vec_lvsl (int, const volatile double *);
15814 vector unsigned char vec_lvsr (int, const volatile double *);
15815 vector double vec_madd (vector double, vector double, vector double);
15816 vector double vec_max (vector double, vector double);
15817 vector signed long vec_mergeh (vector signed long, vector signed long);
15818 vector signed long vec_mergeh (vector signed long, vector bool long);
15819 vector signed long vec_mergeh (vector bool long, vector signed long);
15820 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15821 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15822 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15823 vector signed long vec_mergel (vector signed long, vector signed long);
15824 vector signed long vec_mergel (vector signed long, vector bool long);
15825 vector signed long vec_mergel (vector bool long, vector signed long);
15826 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15827 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15828 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15829 vector double vec_min (vector double, vector double);
15830 vector float vec_msub (vector float, vector float, vector float);
15831 vector double vec_msub (vector double, vector double, vector double);
15832 vector float vec_mul (vector float, vector float);
15833 vector double vec_mul (vector double, vector double);
15834 vector long vec_mul (vector long, vector long);
15835 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15836 vector float vec_nearbyint (vector float);
15837 vector double vec_nearbyint (vector double);
15838 vector float vec_nmadd (vector float, vector float, vector float);
15839 vector double vec_nmadd (vector double, vector double, vector double);
15840 vector double vec_nmsub (vector double, vector double, vector double);
15841 vector double vec_nor (vector double, vector double);
15842 vector long vec_nor (vector long, vector long);
15843 vector long vec_nor (vector long, vector bool long);
15844 vector long vec_nor (vector bool long, vector long);
15845 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15846 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15847 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15848 vector double vec_or (vector double, vector double);
15849 vector double vec_or (vector double, vector bool long);
15850 vector double vec_or (vector bool long, vector double);
15851 vector long vec_or (vector long, vector long);
15852 vector long vec_or (vector long, vector bool long);
15853 vector long vec_or (vector bool long, vector long);
15854 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15855 vector unsigned long vec_or (vector unsigned long, vector bool long);
15856 vector unsigned long vec_or (vector bool long, vector unsigned long);
15857 vector double vec_perm (vector double, vector double, vector unsigned char);
15858 vector long vec_perm (vector long, vector long, vector unsigned char);
15859 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15860 vector unsigned char);
15861 vector double vec_rint (vector double);
15862 vector double vec_recip (vector double, vector double);
15863 vector double vec_rsqrt (vector double);
15864 vector double vec_rsqrte (vector double);
15865 vector double vec_sel (vector double, vector double, vector bool long);
15866 vector double vec_sel (vector double, vector double, vector unsigned long);
15867 vector long vec_sel (vector long, vector long, vector long);
15868 vector long vec_sel (vector long, vector long, vector unsigned long);
15869 vector long vec_sel (vector long, vector long, vector bool long);
15870 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15871 vector long);
15872 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15873 vector unsigned long);
15874 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15875 vector bool long);
15876 vector double vec_splats (double);
15877 vector signed long vec_splats (signed long);
15878 vector unsigned long vec_splats (unsigned long);
15879 vector float vec_sqrt (vector float);
15880 vector double vec_sqrt (vector double);
15881 void vec_st (vector double, int, vector double *);
15882 void vec_st (vector double, int, double *);
15883 vector double vec_sub (vector double, vector double);
15884 vector double vec_trunc (vector double);
15885 vector double vec_xor (vector double, vector double);
15886 vector double vec_xor (vector double, vector bool long);
15887 vector double vec_xor (vector bool long, vector double);
15888 vector long vec_xor (vector long, vector long);
15889 vector long vec_xor (vector long, vector bool long);
15890 vector long vec_xor (vector bool long, vector long);
15891 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15892 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15893 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15894 int vec_all_eq (vector double, vector double);
15895 int vec_all_ge (vector double, vector double);
15896 int vec_all_gt (vector double, vector double);
15897 int vec_all_le (vector double, vector double);
15898 int vec_all_lt (vector double, vector double);
15899 int vec_all_nan (vector double);
15900 int vec_all_ne (vector double, vector double);
15901 int vec_all_nge (vector double, vector double);
15902 int vec_all_ngt (vector double, vector double);
15903 int vec_all_nle (vector double, vector double);
15904 int vec_all_nlt (vector double, vector double);
15905 int vec_all_numeric (vector double);
15906 int vec_any_eq (vector double, vector double);
15907 int vec_any_ge (vector double, vector double);
15908 int vec_any_gt (vector double, vector double);
15909 int vec_any_le (vector double, vector double);
15910 int vec_any_lt (vector double, vector double);
15911 int vec_any_nan (vector double);
15912 int vec_any_ne (vector double, vector double);
15913 int vec_any_nge (vector double, vector double);
15914 int vec_any_ngt (vector double, vector double);
15915 int vec_any_nle (vector double, vector double);
15916 int vec_any_nlt (vector double, vector double);
15917 int vec_any_numeric (vector double);
15918
15919 vector double vec_vsx_ld (int, const vector double *);
15920 vector double vec_vsx_ld (int, const double *);
15921 vector float vec_vsx_ld (int, const vector float *);
15922 vector float vec_vsx_ld (int, const float *);
15923 vector bool int vec_vsx_ld (int, const vector bool int *);
15924 vector signed int vec_vsx_ld (int, const vector signed int *);
15925 vector signed int vec_vsx_ld (int, const int *);
15926 vector signed int vec_vsx_ld (int, const long *);
15927 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15928 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15929 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15930 vector bool short vec_vsx_ld (int, const vector bool short *);
15931 vector pixel vec_vsx_ld (int, const vector pixel *);
15932 vector signed short vec_vsx_ld (int, const vector signed short *);
15933 vector signed short vec_vsx_ld (int, const short *);
15934 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15935 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15936 vector bool char vec_vsx_ld (int, const vector bool char *);
15937 vector signed char vec_vsx_ld (int, const vector signed char *);
15938 vector signed char vec_vsx_ld (int, const signed char *);
15939 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15940 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15941
15942 void vec_vsx_st (vector double, int, vector double *);
15943 void vec_vsx_st (vector double, int, double *);
15944 void vec_vsx_st (vector float, int, vector float *);
15945 void vec_vsx_st (vector float, int, float *);
15946 void vec_vsx_st (vector signed int, int, vector signed int *);
15947 void vec_vsx_st (vector signed int, int, int *);
15948 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15949 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15950 void vec_vsx_st (vector bool int, int, vector bool int *);
15951 void vec_vsx_st (vector bool int, int, unsigned int *);
15952 void vec_vsx_st (vector bool int, int, int *);
15953 void vec_vsx_st (vector signed short, int, vector signed short *);
15954 void vec_vsx_st (vector signed short, int, short *);
15955 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15956 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15957 void vec_vsx_st (vector bool short, int, vector bool short *);
15958 void vec_vsx_st (vector bool short, int, unsigned short *);
15959 void vec_vsx_st (vector pixel, int, vector pixel *);
15960 void vec_vsx_st (vector pixel, int, unsigned short *);
15961 void vec_vsx_st (vector pixel, int, short *);
15962 void vec_vsx_st (vector bool short, int, short *);
15963 void vec_vsx_st (vector signed char, int, vector signed char *);
15964 void vec_vsx_st (vector signed char, int, signed char *);
15965 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15966 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15967 void vec_vsx_st (vector bool char, int, vector bool char *);
15968 void vec_vsx_st (vector bool char, int, unsigned char *);
15969 void vec_vsx_st (vector bool char, int, signed char *);
15970
15971 vector double vec_xxpermdi (vector double, vector double, int);
15972 vector float vec_xxpermdi (vector float, vector float, int);
15973 vector long long vec_xxpermdi (vector long long, vector long long, int);
15974 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15975 vector unsigned long long, int);
15976 vector int vec_xxpermdi (vector int, vector int, int);
15977 vector unsigned int vec_xxpermdi (vector unsigned int,
15978 vector unsigned int, int);
15979 vector short vec_xxpermdi (vector short, vector short, int);
15980 vector unsigned short vec_xxpermdi (vector unsigned short,
15981 vector unsigned short, int);
15982 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
15983 vector unsigned char vec_xxpermdi (vector unsigned char,
15984 vector unsigned char, int);
15985
15986 vector double vec_xxsldi (vector double, vector double, int);
15987 vector float vec_xxsldi (vector float, vector float, int);
15988 vector long long vec_xxsldi (vector long long, vector long long, int);
15989 vector unsigned long long vec_xxsldi (vector unsigned long long,
15990 vector unsigned long long, int);
15991 vector int vec_xxsldi (vector int, vector int, int);
15992 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
15993 vector short vec_xxsldi (vector short, vector short, int);
15994 vector unsigned short vec_xxsldi (vector unsigned short,
15995 vector unsigned short, int);
15996 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
15997 vector unsigned char vec_xxsldi (vector unsigned char,
15998 vector unsigned char, int);
15999 @end smallexample
16000
16001 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
16002 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
16003 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
16004 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
16005 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
16006
16007 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16008 instruction set is available, the following additional functions are
16009 available for both 32-bit and 64-bit targets. For 64-bit targets, you
16010 can use @var{vector long} instead of @var{vector long long},
16011 @var{vector bool long} instead of @var{vector bool long long}, and
16012 @var{vector unsigned long} instead of @var{vector unsigned long long}.
16013
16014 @smallexample
16015 vector long long vec_abs (vector long long);
16016
16017 vector long long vec_add (vector long long, vector long long);
16018 vector unsigned long long vec_add (vector unsigned long long,
16019 vector unsigned long long);
16020
16021 int vec_all_eq (vector long long, vector long long);
16022 int vec_all_eq (vector unsigned long long, vector unsigned long long);
16023 int vec_all_ge (vector long long, vector long long);
16024 int vec_all_ge (vector unsigned long long, vector unsigned long long);
16025 int vec_all_gt (vector long long, vector long long);
16026 int vec_all_gt (vector unsigned long long, vector unsigned long long);
16027 int vec_all_le (vector long long, vector long long);
16028 int vec_all_le (vector unsigned long long, vector unsigned long long);
16029 int vec_all_lt (vector long long, vector long long);
16030 int vec_all_lt (vector unsigned long long, vector unsigned long long);
16031 int vec_all_ne (vector long long, vector long long);
16032 int vec_all_ne (vector unsigned long long, vector unsigned long long);
16033
16034 int vec_any_eq (vector long long, vector long long);
16035 int vec_any_eq (vector unsigned long long, vector unsigned long long);
16036 int vec_any_ge (vector long long, vector long long);
16037 int vec_any_ge (vector unsigned long long, vector unsigned long long);
16038 int vec_any_gt (vector long long, vector long long);
16039 int vec_any_gt (vector unsigned long long, vector unsigned long long);
16040 int vec_any_le (vector long long, vector long long);
16041 int vec_any_le (vector unsigned long long, vector unsigned long long);
16042 int vec_any_lt (vector long long, vector long long);
16043 int vec_any_lt (vector unsigned long long, vector unsigned long long);
16044 int vec_any_ne (vector long long, vector long long);
16045 int vec_any_ne (vector unsigned long long, vector unsigned long long);
16046
16047 vector long long vec_eqv (vector long long, vector long long);
16048 vector long long vec_eqv (vector bool long long, vector long long);
16049 vector long long vec_eqv (vector long long, vector bool long long);
16050 vector unsigned long long vec_eqv (vector unsigned long long,
16051 vector unsigned long long);
16052 vector unsigned long long vec_eqv (vector bool long long,
16053 vector unsigned long long);
16054 vector unsigned long long vec_eqv (vector unsigned long long,
16055 vector bool long long);
16056 vector int vec_eqv (vector int, vector int);
16057 vector int vec_eqv (vector bool int, vector int);
16058 vector int vec_eqv (vector int, vector bool int);
16059 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
16060 vector unsigned int vec_eqv (vector bool unsigned int,
16061 vector unsigned int);
16062 vector unsigned int vec_eqv (vector unsigned int,
16063 vector bool unsigned int);
16064 vector short vec_eqv (vector short, vector short);
16065 vector short vec_eqv (vector bool short, vector short);
16066 vector short vec_eqv (vector short, vector bool short);
16067 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
16068 vector unsigned short vec_eqv (vector bool unsigned short,
16069 vector unsigned short);
16070 vector unsigned short vec_eqv (vector unsigned short,
16071 vector bool unsigned short);
16072 vector signed char vec_eqv (vector signed char, vector signed char);
16073 vector signed char vec_eqv (vector bool signed char, vector signed char);
16074 vector signed char vec_eqv (vector signed char, vector bool signed char);
16075 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
16076 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
16077 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
16078
16079 vector long long vec_max (vector long long, vector long long);
16080 vector unsigned long long vec_max (vector unsigned long long,
16081 vector unsigned long long);
16082
16083 vector signed int vec_mergee (vector signed int, vector signed int);
16084 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
16085 vector bool int vec_mergee (vector bool int, vector bool int);
16086
16087 vector signed int vec_mergeo (vector signed int, vector signed int);
16088 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
16089 vector bool int vec_mergeo (vector bool int, vector bool int);
16090
16091 vector long long vec_min (vector long long, vector long long);
16092 vector unsigned long long vec_min (vector unsigned long long,
16093 vector unsigned long long);
16094
16095 vector long long vec_nand (vector long long, vector long long);
16096 vector long long vec_nand (vector bool long long, vector long long);
16097 vector long long vec_nand (vector long long, vector bool long long);
16098 vector unsigned long long vec_nand (vector unsigned long long,
16099 vector unsigned long long);
16100 vector unsigned long long vec_nand (vector bool long long,
16101 vector unsigned long long);
16102 vector unsigned long long vec_nand (vector unsigned long long,
16103 vector bool long long);
16104 vector int vec_nand (vector int, vector int);
16105 vector int vec_nand (vector bool int, vector int);
16106 vector int vec_nand (vector int, vector bool int);
16107 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
16108 vector unsigned int vec_nand (vector bool unsigned int,
16109 vector unsigned int);
16110 vector unsigned int vec_nand (vector unsigned int,
16111 vector bool unsigned int);
16112 vector short vec_nand (vector short, vector short);
16113 vector short vec_nand (vector bool short, vector short);
16114 vector short vec_nand (vector short, vector bool short);
16115 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
16116 vector unsigned short vec_nand (vector bool unsigned short,
16117 vector unsigned short);
16118 vector unsigned short vec_nand (vector unsigned short,
16119 vector bool unsigned short);
16120 vector signed char vec_nand (vector signed char, vector signed char);
16121 vector signed char vec_nand (vector bool signed char, vector signed char);
16122 vector signed char vec_nand (vector signed char, vector bool signed char);
16123 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
16124 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
16125 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
16126
16127 vector long long vec_orc (vector long long, vector long long);
16128 vector long long vec_orc (vector bool long long, vector long long);
16129 vector long long vec_orc (vector long long, vector bool long long);
16130 vector unsigned long long vec_orc (vector unsigned long long,
16131 vector unsigned long long);
16132 vector unsigned long long vec_orc (vector bool long long,
16133 vector unsigned long long);
16134 vector unsigned long long vec_orc (vector unsigned long long,
16135 vector bool long long);
16136 vector int vec_orc (vector int, vector int);
16137 vector int vec_orc (vector bool int, vector int);
16138 vector int vec_orc (vector int, vector bool int);
16139 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
16140 vector unsigned int vec_orc (vector bool unsigned int,
16141 vector unsigned int);
16142 vector unsigned int vec_orc (vector unsigned int,
16143 vector bool unsigned int);
16144 vector short vec_orc (vector short, vector short);
16145 vector short vec_orc (vector bool short, vector short);
16146 vector short vec_orc (vector short, vector bool short);
16147 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
16148 vector unsigned short vec_orc (vector bool unsigned short,
16149 vector unsigned short);
16150 vector unsigned short vec_orc (vector unsigned short,
16151 vector bool unsigned short);
16152 vector signed char vec_orc (vector signed char, vector signed char);
16153 vector signed char vec_orc (vector bool signed char, vector signed char);
16154 vector signed char vec_orc (vector signed char, vector bool signed char);
16155 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
16156 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
16157 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
16158
16159 vector int vec_pack (vector long long, vector long long);
16160 vector unsigned int vec_pack (vector unsigned long long,
16161 vector unsigned long long);
16162 vector bool int vec_pack (vector bool long long, vector bool long long);
16163
16164 vector int vec_packs (vector long long, vector long long);
16165 vector unsigned int vec_packs (vector unsigned long long,
16166 vector unsigned long long);
16167
16168 vector unsigned int vec_packsu (vector long long, vector long long);
16169 vector unsigned int vec_packsu (vector unsigned long long,
16170 vector unsigned long long);
16171
16172 vector long long vec_rl (vector long long,
16173 vector unsigned long long);
16174 vector long long vec_rl (vector unsigned long long,
16175 vector unsigned long long);
16176
16177 vector long long vec_sl (vector long long, vector unsigned long long);
16178 vector long long vec_sl (vector unsigned long long,
16179 vector unsigned long long);
16180
16181 vector long long vec_sr (vector long long, vector unsigned long long);
16182 vector unsigned long long char vec_sr (vector unsigned long long,
16183 vector unsigned long long);
16184
16185 vector long long vec_sra (vector long long, vector unsigned long long);
16186 vector unsigned long long vec_sra (vector unsigned long long,
16187 vector unsigned long long);
16188
16189 vector long long vec_sub (vector long long, vector long long);
16190 vector unsigned long long vec_sub (vector unsigned long long,
16191 vector unsigned long long);
16192
16193 vector long long vec_unpackh (vector int);
16194 vector unsigned long long vec_unpackh (vector unsigned int);
16195
16196 vector long long vec_unpackl (vector int);
16197 vector unsigned long long vec_unpackl (vector unsigned int);
16198
16199 vector long long vec_vaddudm (vector long long, vector long long);
16200 vector long long vec_vaddudm (vector bool long long, vector long long);
16201 vector long long vec_vaddudm (vector long long, vector bool long long);
16202 vector unsigned long long vec_vaddudm (vector unsigned long long,
16203 vector unsigned long long);
16204 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
16205 vector unsigned long long);
16206 vector unsigned long long vec_vaddudm (vector unsigned long long,
16207 vector bool unsigned long long);
16208
16209 vector long long vec_vbpermq (vector signed char, vector signed char);
16210 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
16211
16212 vector long long vec_cntlz (vector long long);
16213 vector unsigned long long vec_cntlz (vector unsigned long long);
16214 vector int vec_cntlz (vector int);
16215 vector unsigned int vec_cntlz (vector int);
16216 vector short vec_cntlz (vector short);
16217 vector unsigned short vec_cntlz (vector unsigned short);
16218 vector signed char vec_cntlz (vector signed char);
16219 vector unsigned char vec_cntlz (vector unsigned char);
16220
16221 vector long long vec_vclz (vector long long);
16222 vector unsigned long long vec_vclz (vector unsigned long long);
16223 vector int vec_vclz (vector int);
16224 vector unsigned int vec_vclz (vector int);
16225 vector short vec_vclz (vector short);
16226 vector unsigned short vec_vclz (vector unsigned short);
16227 vector signed char vec_vclz (vector signed char);
16228 vector unsigned char vec_vclz (vector unsigned char);
16229
16230 vector signed char vec_vclzb (vector signed char);
16231 vector unsigned char vec_vclzb (vector unsigned char);
16232
16233 vector long long vec_vclzd (vector long long);
16234 vector unsigned long long vec_vclzd (vector unsigned long long);
16235
16236 vector short vec_vclzh (vector short);
16237 vector unsigned short vec_vclzh (vector unsigned short);
16238
16239 vector int vec_vclzw (vector int);
16240 vector unsigned int vec_vclzw (vector int);
16241
16242 vector signed char vec_vgbbd (vector signed char);
16243 vector unsigned char vec_vgbbd (vector unsigned char);
16244
16245 vector long long vec_vmaxsd (vector long long, vector long long);
16246
16247 vector unsigned long long vec_vmaxud (vector unsigned long long,
16248 unsigned vector long long);
16249
16250 vector long long vec_vminsd (vector long long, vector long long);
16251
16252 vector unsigned long long vec_vminud (vector long long,
16253 vector long long);
16254
16255 vector int vec_vpksdss (vector long long, vector long long);
16256 vector unsigned int vec_vpksdss (vector long long, vector long long);
16257
16258 vector unsigned int vec_vpkudus (vector unsigned long long,
16259 vector unsigned long long);
16260
16261 vector int vec_vpkudum (vector long long, vector long long);
16262 vector unsigned int vec_vpkudum (vector unsigned long long,
16263 vector unsigned long long);
16264 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
16265
16266 vector long long vec_vpopcnt (vector long long);
16267 vector unsigned long long vec_vpopcnt (vector unsigned long long);
16268 vector int vec_vpopcnt (vector int);
16269 vector unsigned int vec_vpopcnt (vector int);
16270 vector short vec_vpopcnt (vector short);
16271 vector unsigned short vec_vpopcnt (vector unsigned short);
16272 vector signed char vec_vpopcnt (vector signed char);
16273 vector unsigned char vec_vpopcnt (vector unsigned char);
16274
16275 vector signed char vec_vpopcntb (vector signed char);
16276 vector unsigned char vec_vpopcntb (vector unsigned char);
16277
16278 vector long long vec_vpopcntd (vector long long);
16279 vector unsigned long long vec_vpopcntd (vector unsigned long long);
16280
16281 vector short vec_vpopcnth (vector short);
16282 vector unsigned short vec_vpopcnth (vector unsigned short);
16283
16284 vector int vec_vpopcntw (vector int);
16285 vector unsigned int vec_vpopcntw (vector int);
16286
16287 vector long long vec_vrld (vector long long, vector unsigned long long);
16288 vector unsigned long long vec_vrld (vector unsigned long long,
16289 vector unsigned long long);
16290
16291 vector long long vec_vsld (vector long long, vector unsigned long long);
16292 vector long long vec_vsld (vector unsigned long long,
16293 vector unsigned long long);
16294
16295 vector long long vec_vsrad (vector long long, vector unsigned long long);
16296 vector unsigned long long vec_vsrad (vector unsigned long long,
16297 vector unsigned long long);
16298
16299 vector long long vec_vsrd (vector long long, vector unsigned long long);
16300 vector unsigned long long char vec_vsrd (vector unsigned long long,
16301 vector unsigned long long);
16302
16303 vector long long vec_vsubudm (vector long long, vector long long);
16304 vector long long vec_vsubudm (vector bool long long, vector long long);
16305 vector long long vec_vsubudm (vector long long, vector bool long long);
16306 vector unsigned long long vec_vsubudm (vector unsigned long long,
16307 vector unsigned long long);
16308 vector unsigned long long vec_vsubudm (vector bool long long,
16309 vector unsigned long long);
16310 vector unsigned long long vec_vsubudm (vector unsigned long long,
16311 vector bool long long);
16312
16313 vector long long vec_vupkhsw (vector int);
16314 vector unsigned long long vec_vupkhsw (vector unsigned int);
16315
16316 vector long long vec_vupklsw (vector int);
16317 vector unsigned long long vec_vupklsw (vector int);
16318 @end smallexample
16319
16320 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16321 instruction set is available, the following additional functions are
16322 available for 64-bit targets. New vector types
16323 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
16324 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
16325 builtins.
16326
16327 The normal vector extract, and set operations work on
16328 @var{vector __int128_t} and @var{vector __uint128_t} types,
16329 but the index value must be 0.
16330
16331 @smallexample
16332 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
16333 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
16334
16335 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
16336 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
16337
16338 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
16339 vector __int128_t);
16340 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
16341 vector __uint128_t);
16342
16343 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
16344 vector __int128_t);
16345 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
16346 vector __uint128_t);
16347
16348 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
16349 vector __int128_t);
16350 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
16351 vector __uint128_t);
16352
16353 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
16354 vector __int128_t);
16355 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
16356 vector __uint128_t);
16357
16358 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
16359 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
16360
16361 __int128_t vec_vsubuqm (__int128_t, __int128_t);
16362 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
16363
16364 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
16365 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
16366 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
16367 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
16368 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
16369 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
16370 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
16371 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
16372 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
16373 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
16374 @end smallexample
16375
16376 If the cryptographic instructions are enabled (@option{-mcrypto} or
16377 @option{-mcpu=power8}), the following builtins are enabled.
16378
16379 @smallexample
16380 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
16381
16382 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
16383 vector unsigned long long);
16384
16385 vector unsigned long long __builtin_crypto_vcipherlast
16386 (vector unsigned long long,
16387 vector unsigned long long);
16388
16389 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
16390 vector unsigned long long);
16391
16392 vector unsigned long long __builtin_crypto_vncipherlast
16393 (vector unsigned long long,
16394 vector unsigned long long);
16395
16396 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
16397 vector unsigned char,
16398 vector unsigned char);
16399
16400 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
16401 vector unsigned short,
16402 vector unsigned short);
16403
16404 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
16405 vector unsigned int,
16406 vector unsigned int);
16407
16408 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
16409 vector unsigned long long,
16410 vector unsigned long long);
16411
16412 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
16413 vector unsigned char);
16414
16415 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
16416 vector unsigned short);
16417
16418 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
16419 vector unsigned int);
16420
16421 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
16422 vector unsigned long long);
16423
16424 vector unsigned long long __builtin_crypto_vshasigmad
16425 (vector unsigned long long, int, int);
16426
16427 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
16428 int, int);
16429 @end smallexample
16430
16431 The second argument to the @var{__builtin_crypto_vshasigmad} and
16432 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
16433 integer that is 0 or 1. The third argument to these builtin functions
16434 must be a constant integer in the range of 0 to 15.
16435
16436 @node PowerPC Hardware Transactional Memory Built-in Functions
16437 @subsection PowerPC Hardware Transactional Memory Built-in Functions
16438 GCC provides two interfaces for accessing the Hardware Transactional
16439 Memory (HTM) instructions available on some of the PowerPC family
16440 of prcoessors (eg, POWER8). The two interfaces come in a low level
16441 interface, consisting of built-in functions specific to PowerPC and a
16442 higher level interface consisting of inline functions that are common
16443 between PowerPC and S/390.
16444
16445 @subsubsection PowerPC HTM Low Level Built-in Functions
16446
16447 The following low level built-in functions are available with
16448 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
16449 They all generate the machine instruction that is part of the name.
16450
16451 The HTM built-ins return true or false depending on their success and
16452 their arguments match exactly the type and order of the associated
16453 hardware instruction's operands. Refer to the ISA manual for a
16454 description of each instruction's operands.
16455
16456 @smallexample
16457 unsigned int __builtin_tbegin (unsigned int)
16458 unsigned int __builtin_tend (unsigned int)
16459
16460 unsigned int __builtin_tabort (unsigned int)
16461 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16462 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16463 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16464 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16465
16466 unsigned int __builtin_tcheck (unsigned int)
16467 unsigned int __builtin_treclaim (unsigned int)
16468 unsigned int __builtin_trechkpt (void)
16469 unsigned int __builtin_tsr (unsigned int)
16470 @end smallexample
16471
16472 In addition to the above HTM built-ins, we have added built-ins for
16473 some common extended mnemonics of the HTM instructions:
16474
16475 @smallexample
16476 unsigned int __builtin_tendall (void)
16477 unsigned int __builtin_tresume (void)
16478 unsigned int __builtin_tsuspend (void)
16479 @end smallexample
16480
16481 The following set of built-in functions are available to gain access
16482 to the HTM specific special purpose registers.
16483
16484 @smallexample
16485 unsigned long __builtin_get_texasr (void)
16486 unsigned long __builtin_get_texasru (void)
16487 unsigned long __builtin_get_tfhar (void)
16488 unsigned long __builtin_get_tfiar (void)
16489
16490 void __builtin_set_texasr (unsigned long);
16491 void __builtin_set_texasru (unsigned long);
16492 void __builtin_set_tfhar (unsigned long);
16493 void __builtin_set_tfiar (unsigned long);
16494 @end smallexample
16495
16496 Example usage of these low level built-in functions may look like:
16497
16498 @smallexample
16499 #include <htmintrin.h>
16500
16501 int num_retries = 10;
16502
16503 while (1)
16504 @{
16505 if (__builtin_tbegin (0))
16506 @{
16507 /* Transaction State Initiated. */
16508 if (is_locked (lock))
16509 __builtin_tabort (0);
16510 ... transaction code...
16511 __builtin_tend (0);
16512 break;
16513 @}
16514 else
16515 @{
16516 /* Transaction State Failed. Use locks if the transaction
16517 failure is "persistent" or we've tried too many times. */
16518 if (num_retries-- <= 0
16519 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16520 @{
16521 acquire_lock (lock);
16522 ... non transactional fallback path...
16523 release_lock (lock);
16524 break;
16525 @}
16526 @}
16527 @}
16528 @end smallexample
16529
16530 One final built-in function has been added that returns the value of
16531 the 2-bit Transaction State field of the Machine Status Register (MSR)
16532 as stored in @code{CR0}.
16533
16534 @smallexample
16535 unsigned long __builtin_ttest (void)
16536 @end smallexample
16537
16538 This built-in can be used to determine the current transaction state
16539 using the following code example:
16540
16541 @smallexample
16542 #include <htmintrin.h>
16543
16544 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16545
16546 if (tx_state == _HTM_TRANSACTIONAL)
16547 @{
16548 /* Code to use in transactional state. */
16549 @}
16550 else if (tx_state == _HTM_NONTRANSACTIONAL)
16551 @{
16552 /* Code to use in non-transactional state. */
16553 @}
16554 else if (tx_state == _HTM_SUSPENDED)
16555 @{
16556 /* Code to use in transaction suspended state. */
16557 @}
16558 @end smallexample
16559
16560 @subsubsection PowerPC HTM High Level Inline Functions
16561
16562 The following high level HTM interface is made available by including
16563 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16564 where CPU is `power8' or later. This interface is common between PowerPC
16565 and S/390, allowing users to write one HTM source implementation that
16566 can be compiled and executed on either system.
16567
16568 @smallexample
16569 long __TM_simple_begin (void)
16570 long __TM_begin (void* const TM_buff)
16571 long __TM_end (void)
16572 void __TM_abort (void)
16573 void __TM_named_abort (unsigned char const code)
16574 void __TM_resume (void)
16575 void __TM_suspend (void)
16576
16577 long __TM_is_user_abort (void* const TM_buff)
16578 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16579 long __TM_is_illegal (void* const TM_buff)
16580 long __TM_is_footprint_exceeded (void* const TM_buff)
16581 long __TM_nesting_depth (void* const TM_buff)
16582 long __TM_is_nested_too_deep(void* const TM_buff)
16583 long __TM_is_conflict(void* const TM_buff)
16584 long __TM_is_failure_persistent(void* const TM_buff)
16585 long __TM_failure_address(void* const TM_buff)
16586 long long __TM_failure_code(void* const TM_buff)
16587 @end smallexample
16588
16589 Using these common set of HTM inline functions, we can create
16590 a more portable version of the HTM example in the previous
16591 section that will work on either PowerPC or S/390:
16592
16593 @smallexample
16594 #include <htmxlintrin.h>
16595
16596 int num_retries = 10;
16597 TM_buff_type TM_buff;
16598
16599 while (1)
16600 @{
16601 if (__TM_begin (TM_buff))
16602 @{
16603 /* Transaction State Initiated. */
16604 if (is_locked (lock))
16605 __TM_abort ();
16606 ... transaction code...
16607 __TM_end ();
16608 break;
16609 @}
16610 else
16611 @{
16612 /* Transaction State Failed. Use locks if the transaction
16613 failure is "persistent" or we've tried too many times. */
16614 if (num_retries-- <= 0
16615 || __TM_is_failure_persistent (TM_buff))
16616 @{
16617 acquire_lock (lock);
16618 ... non transactional fallback path...
16619 release_lock (lock);
16620 break;
16621 @}
16622 @}
16623 @}
16624 @end smallexample
16625
16626 @node RX Built-in Functions
16627 @subsection RX Built-in Functions
16628 GCC supports some of the RX instructions which cannot be expressed in
16629 the C programming language via the use of built-in functions. The
16630 following functions are supported:
16631
16632 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
16633 Generates the @code{brk} machine instruction.
16634 @end deftypefn
16635
16636 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
16637 Generates the @code{clrpsw} machine instruction to clear the specified
16638 bit in the processor status word.
16639 @end deftypefn
16640
16641 @deftypefn {Built-in Function} void __builtin_rx_int (int)
16642 Generates the @code{int} machine instruction to generate an interrupt
16643 with the specified value.
16644 @end deftypefn
16645
16646 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
16647 Generates the @code{machi} machine instruction to add the result of
16648 multiplying the top 16 bits of the two arguments into the
16649 accumulator.
16650 @end deftypefn
16651
16652 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
16653 Generates the @code{maclo} machine instruction to add the result of
16654 multiplying the bottom 16 bits of the two arguments into the
16655 accumulator.
16656 @end deftypefn
16657
16658 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
16659 Generates the @code{mulhi} machine instruction to place the result of
16660 multiplying the top 16 bits of the two arguments into the
16661 accumulator.
16662 @end deftypefn
16663
16664 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
16665 Generates the @code{mullo} machine instruction to place the result of
16666 multiplying the bottom 16 bits of the two arguments into the
16667 accumulator.
16668 @end deftypefn
16669
16670 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
16671 Generates the @code{mvfachi} machine instruction to read the top
16672 32 bits of the accumulator.
16673 @end deftypefn
16674
16675 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
16676 Generates the @code{mvfacmi} machine instruction to read the middle
16677 32 bits of the accumulator.
16678 @end deftypefn
16679
16680 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
16681 Generates the @code{mvfc} machine instruction which reads the control
16682 register specified in its argument and returns its value.
16683 @end deftypefn
16684
16685 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
16686 Generates the @code{mvtachi} machine instruction to set the top
16687 32 bits of the accumulator.
16688 @end deftypefn
16689
16690 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
16691 Generates the @code{mvtaclo} machine instruction to set the bottom
16692 32 bits of the accumulator.
16693 @end deftypefn
16694
16695 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
16696 Generates the @code{mvtc} machine instruction which sets control
16697 register number @code{reg} to @code{val}.
16698 @end deftypefn
16699
16700 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
16701 Generates the @code{mvtipl} machine instruction set the interrupt
16702 priority level.
16703 @end deftypefn
16704
16705 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
16706 Generates the @code{racw} machine instruction to round the accumulator
16707 according to the specified mode.
16708 @end deftypefn
16709
16710 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
16711 Generates the @code{revw} machine instruction which swaps the bytes in
16712 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16713 and also bits 16--23 occupy bits 24--31 and vice versa.
16714 @end deftypefn
16715
16716 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
16717 Generates the @code{rmpa} machine instruction which initiates a
16718 repeated multiply and accumulate sequence.
16719 @end deftypefn
16720
16721 @deftypefn {Built-in Function} void __builtin_rx_round (float)
16722 Generates the @code{round} machine instruction which returns the
16723 floating-point argument rounded according to the current rounding mode
16724 set in the floating-point status word register.
16725 @end deftypefn
16726
16727 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
16728 Generates the @code{sat} machine instruction which returns the
16729 saturated value of the argument.
16730 @end deftypefn
16731
16732 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
16733 Generates the @code{setpsw} machine instruction to set the specified
16734 bit in the processor status word.
16735 @end deftypefn
16736
16737 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
16738 Generates the @code{wait} machine instruction.
16739 @end deftypefn
16740
16741 @node S/390 System z Built-in Functions
16742 @subsection S/390 System z Built-in Functions
16743 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16744 Generates the @code{tbegin} machine instruction starting a
16745 non-constraint hardware transaction. If the parameter is non-NULL the
16746 memory area is used to store the transaction diagnostic buffer and
16747 will be passed as first operand to @code{tbegin}. This buffer can be
16748 defined using the @code{struct __htm_tdb} C struct defined in
16749 @code{htmintrin.h} and must reside on a double-word boundary. The
16750 second tbegin operand is set to @code{0xff0c}. This enables
16751 save/restore of all GPRs and disables aborts for FPR and AR
16752 manipulations inside the transaction body. The condition code set by
16753 the tbegin instruction is returned as integer value. The tbegin
16754 instruction by definition overwrites the content of all FPRs. The
16755 compiler will generate code which saves and restores the FPRs. For
16756 soft-float code it is recommended to used the @code{*_nofloat}
16757 variant. In order to prevent a TDB from being written it is required
16758 to pass an constant zero value as parameter. Passing the zero value
16759 through a variable is not sufficient. Although modifications of
16760 access registers inside the transaction will not trigger an
16761 transaction abort it is not supported to actually modify them. Access
16762 registers do not get saved when entering a transaction. They will have
16763 undefined state when reaching the abort code.
16764 @end deftypefn
16765
16766 Macros for the possible return codes of tbegin are defined in the
16767 @code{htmintrin.h} header file:
16768
16769 @table @code
16770 @item _HTM_TBEGIN_STARTED
16771 @code{tbegin} has been executed as part of normal processing. The
16772 transaction body is supposed to be executed.
16773 @item _HTM_TBEGIN_INDETERMINATE
16774 The transaction was aborted due to an indeterminate condition which
16775 might be persistent.
16776 @item _HTM_TBEGIN_TRANSIENT
16777 The transaction aborted due to a transient failure. The transaction
16778 should be re-executed in that case.
16779 @item _HTM_TBEGIN_PERSISTENT
16780 The transaction aborted due to a persistent failure. Re-execution
16781 under same circumstances will not be productive.
16782 @end table
16783
16784 @defmac _HTM_FIRST_USER_ABORT_CODE
16785 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16786 specifies the first abort code which can be used for
16787 @code{__builtin_tabort}. Values below this threshold are reserved for
16788 machine use.
16789 @end defmac
16790
16791 @deftp {Data type} {struct __htm_tdb}
16792 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16793 the structure of the transaction diagnostic block as specified in the
16794 Principles of Operation manual chapter 5-91.
16795 @end deftp
16796
16797 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16798 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16799 Using this variant in code making use of FPRs will leave the FPRs in
16800 undefined state when entering the transaction abort handler code.
16801 @end deftypefn
16802
16803 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16804 In addition to @code{__builtin_tbegin} a loop for transient failures
16805 is generated. If tbegin returns a condition code of 2 the transaction
16806 will be retried as often as specified in the second argument. The
16807 perform processor assist instruction is used to tell the CPU about the
16808 number of fails so far.
16809 @end deftypefn
16810
16811 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16812 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16813 restores. Using this variant in code making use of FPRs will leave
16814 the FPRs in undefined state when entering the transaction abort
16815 handler code.
16816 @end deftypefn
16817
16818 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16819 Generates the @code{tbeginc} machine instruction starting a constraint
16820 hardware transaction. The second operand is set to @code{0xff08}.
16821 @end deftypefn
16822
16823 @deftypefn {Built-in Function} int __builtin_tend (void)
16824 Generates the @code{tend} machine instruction finishing a transaction
16825 and making the changes visible to other threads. The condition code
16826 generated by tend is returned as integer value.
16827 @end deftypefn
16828
16829 @deftypefn {Built-in Function} void __builtin_tabort (int)
16830 Generates the @code{tabort} machine instruction with the specified
16831 abort code. Abort codes from 0 through 255 are reserved and will
16832 result in an error message.
16833 @end deftypefn
16834
16835 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16836 Generates the @code{ppa rX,rY,1} machine instruction. Where the
16837 integer parameter is loaded into rX and a value of zero is loaded into
16838 rY. The integer parameter specifies the number of times the
16839 transaction repeatedly aborted.
16840 @end deftypefn
16841
16842 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16843 Generates the @code{etnd} machine instruction. The current nesting
16844 depth is returned as integer value. For a nesting depth of 0 the code
16845 is not executed as part of an transaction.
16846 @end deftypefn
16847
16848 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16849
16850 Generates the @code{ntstg} machine instruction. The second argument
16851 is written to the first arguments location. The store operation will
16852 not be rolled-back in case of an transaction abort.
16853 @end deftypefn
16854
16855 @node SH Built-in Functions
16856 @subsection SH Built-in Functions
16857 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16858 families of processors:
16859
16860 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16861 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
16862 used by system code that manages threads and execution contexts. The compiler
16863 normally does not generate code that modifies the contents of @samp{GBR} and
16864 thus the value is preserved across function calls. Changing the @samp{GBR}
16865 value in user code must be done with caution, since the compiler might use
16866 @samp{GBR} in order to access thread local variables.
16867
16868 @end deftypefn
16869
16870 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16871 Returns the value that is currently set in the @samp{GBR} register.
16872 Memory loads and stores that use the thread pointer as a base address are
16873 turned into @samp{GBR} based displacement loads and stores, if possible.
16874 For example:
16875 @smallexample
16876 struct my_tcb
16877 @{
16878 int a, b, c, d, e;
16879 @};
16880
16881 int get_tcb_value (void)
16882 @{
16883 // Generate @samp{mov.l @@(8,gbr),r0} instruction
16884 return ((my_tcb*)__builtin_thread_pointer ())->c;
16885 @}
16886
16887 @end smallexample
16888 @end deftypefn
16889
16890 @node SPARC VIS Built-in Functions
16891 @subsection SPARC VIS Built-in Functions
16892
16893 GCC supports SIMD operations on the SPARC using both the generic vector
16894 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16895 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
16896 switch, the VIS extension is exposed as the following built-in functions:
16897
16898 @smallexample
16899 typedef int v1si __attribute__ ((vector_size (4)));
16900 typedef int v2si __attribute__ ((vector_size (8)));
16901 typedef short v4hi __attribute__ ((vector_size (8)));
16902 typedef short v2hi __attribute__ ((vector_size (4)));
16903 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16904 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16905
16906 void __builtin_vis_write_gsr (int64_t);
16907 int64_t __builtin_vis_read_gsr (void);
16908
16909 void * __builtin_vis_alignaddr (void *, long);
16910 void * __builtin_vis_alignaddrl (void *, long);
16911 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16912 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16913 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16914 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16915
16916 v4hi __builtin_vis_fexpand (v4qi);
16917
16918 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16919 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16920 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16921 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16922 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16923 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16924 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16925
16926 v4qi __builtin_vis_fpack16 (v4hi);
16927 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16928 v2hi __builtin_vis_fpackfix (v2si);
16929 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16930
16931 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16932
16933 long __builtin_vis_edge8 (void *, void *);
16934 long __builtin_vis_edge8l (void *, void *);
16935 long __builtin_vis_edge16 (void *, void *);
16936 long __builtin_vis_edge16l (void *, void *);
16937 long __builtin_vis_edge32 (void *, void *);
16938 long __builtin_vis_edge32l (void *, void *);
16939
16940 long __builtin_vis_fcmple16 (v4hi, v4hi);
16941 long __builtin_vis_fcmple32 (v2si, v2si);
16942 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16943 long __builtin_vis_fcmpne32 (v2si, v2si);
16944 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16945 long __builtin_vis_fcmpgt32 (v2si, v2si);
16946 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16947 long __builtin_vis_fcmpeq32 (v2si, v2si);
16948
16949 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16950 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16951 v2si __builtin_vis_fpadd32 (v2si, v2si);
16952 v1si __builtin_vis_fpadd32s (v1si, v1si);
16953 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
16954 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
16955 v2si __builtin_vis_fpsub32 (v2si, v2si);
16956 v1si __builtin_vis_fpsub32s (v1si, v1si);
16957
16958 long __builtin_vis_array8 (long, long);
16959 long __builtin_vis_array16 (long, long);
16960 long __builtin_vis_array32 (long, long);
16961 @end smallexample
16962
16963 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
16964 functions also become available:
16965
16966 @smallexample
16967 long __builtin_vis_bmask (long, long);
16968 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
16969 v2si __builtin_vis_bshufflev2si (v2si, v2si);
16970 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
16971 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
16972
16973 long __builtin_vis_edge8n (void *, void *);
16974 long __builtin_vis_edge8ln (void *, void *);
16975 long __builtin_vis_edge16n (void *, void *);
16976 long __builtin_vis_edge16ln (void *, void *);
16977 long __builtin_vis_edge32n (void *, void *);
16978 long __builtin_vis_edge32ln (void *, void *);
16979 @end smallexample
16980
16981 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
16982 functions also become available:
16983
16984 @smallexample
16985 void __builtin_vis_cmask8 (long);
16986 void __builtin_vis_cmask16 (long);
16987 void __builtin_vis_cmask32 (long);
16988
16989 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
16990
16991 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
16992 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
16993 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
16994 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
16995 v2si __builtin_vis_fsll16 (v2si, v2si);
16996 v2si __builtin_vis_fslas16 (v2si, v2si);
16997 v2si __builtin_vis_fsrl16 (v2si, v2si);
16998 v2si __builtin_vis_fsra16 (v2si, v2si);
16999
17000 long __builtin_vis_pdistn (v8qi, v8qi);
17001
17002 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
17003
17004 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
17005 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
17006
17007 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
17008 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
17009 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
17010 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
17011 v2si __builtin_vis_fpadds32 (v2si, v2si);
17012 v1si __builtin_vis_fpadds32s (v1si, v1si);
17013 v2si __builtin_vis_fpsubs32 (v2si, v2si);
17014 v1si __builtin_vis_fpsubs32s (v1si, v1si);
17015
17016 long __builtin_vis_fucmple8 (v8qi, v8qi);
17017 long __builtin_vis_fucmpne8 (v8qi, v8qi);
17018 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
17019 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
17020
17021 float __builtin_vis_fhadds (float, float);
17022 double __builtin_vis_fhaddd (double, double);
17023 float __builtin_vis_fhsubs (float, float);
17024 double __builtin_vis_fhsubd (double, double);
17025 float __builtin_vis_fnhadds (float, float);
17026 double __builtin_vis_fnhaddd (double, double);
17027
17028 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
17029 int64_t __builtin_vis_xmulx (int64_t, int64_t);
17030 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
17031 @end smallexample
17032
17033 @node SPU Built-in Functions
17034 @subsection SPU Built-in Functions
17035
17036 GCC provides extensions for the SPU processor as described in the
17037 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
17038 found at @uref{http://cell.scei.co.jp/} or
17039 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
17040 implementation differs in several ways.
17041
17042 @itemize @bullet
17043
17044 @item
17045 The optional extension of specifying vector constants in parentheses is
17046 not supported.
17047
17048 @item
17049 A vector initializer requires no cast if the vector constant is of the
17050 same type as the variable it is initializing.
17051
17052 @item
17053 If @code{signed} or @code{unsigned} is omitted, the signedness of the
17054 vector type is the default signedness of the base type. The default
17055 varies depending on the operating system, so a portable program should
17056 always specify the signedness.
17057
17058 @item
17059 By default, the keyword @code{__vector} is added. The macro
17060 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
17061 undefined.
17062
17063 @item
17064 GCC allows using a @code{typedef} name as the type specifier for a
17065 vector type.
17066
17067 @item
17068 For C, overloaded functions are implemented with macros so the following
17069 does not work:
17070
17071 @smallexample
17072 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
17073 @end smallexample
17074
17075 @noindent
17076 Since @code{spu_add} is a macro, the vector constant in the example
17077 is treated as four separate arguments. Wrap the entire argument in
17078 parentheses for this to work.
17079
17080 @item
17081 The extended version of @code{__builtin_expect} is not supported.
17082
17083 @end itemize
17084
17085 @emph{Note:} Only the interface described in the aforementioned
17086 specification is supported. Internally, GCC uses built-in functions to
17087 implement the required functionality, but these are not supported and
17088 are subject to change without notice.
17089
17090 @node TI C6X Built-in Functions
17091 @subsection TI C6X Built-in Functions
17092
17093 GCC provides intrinsics to access certain instructions of the TI C6X
17094 processors. These intrinsics, listed below, are available after
17095 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
17096 to C6X instructions.
17097
17098 @smallexample
17099
17100 int _sadd (int, int)
17101 int _ssub (int, int)
17102 int _sadd2 (int, int)
17103 int _ssub2 (int, int)
17104 long long _mpy2 (int, int)
17105 long long _smpy2 (int, int)
17106 int _add4 (int, int)
17107 int _sub4 (int, int)
17108 int _saddu4 (int, int)
17109
17110 int _smpy (int, int)
17111 int _smpyh (int, int)
17112 int _smpyhl (int, int)
17113 int _smpylh (int, int)
17114
17115 int _sshl (int, int)
17116 int _subc (int, int)
17117
17118 int _avg2 (int, int)
17119 int _avgu4 (int, int)
17120
17121 int _clrr (int, int)
17122 int _extr (int, int)
17123 int _extru (int, int)
17124 int _abs (int)
17125 int _abs2 (int)
17126
17127 @end smallexample
17128
17129 @node TILE-Gx Built-in Functions
17130 @subsection TILE-Gx Built-in Functions
17131
17132 GCC provides intrinsics to access every instruction of the TILE-Gx
17133 processor. The intrinsics are of the form:
17134
17135 @smallexample
17136
17137 unsigned long long __insn_@var{op} (...)
17138
17139 @end smallexample
17140
17141 Where @var{op} is the name of the instruction. Refer to the ISA manual
17142 for the complete list of instructions.
17143
17144 GCC also provides intrinsics to directly access the network registers.
17145 The intrinsics are:
17146
17147 @smallexample
17148
17149 unsigned long long __tile_idn0_receive (void)
17150 unsigned long long __tile_idn1_receive (void)
17151 unsigned long long __tile_udn0_receive (void)
17152 unsigned long long __tile_udn1_receive (void)
17153 unsigned long long __tile_udn2_receive (void)
17154 unsigned long long __tile_udn3_receive (void)
17155 void __tile_idn_send (unsigned long long)
17156 void __tile_udn_send (unsigned long long)
17157
17158 @end smallexample
17159
17160 The intrinsic @code{void __tile_network_barrier (void)} is used to
17161 guarantee that no network operations before it are reordered with
17162 those after it.
17163
17164 @node TILEPro Built-in Functions
17165 @subsection TILEPro Built-in Functions
17166
17167 GCC provides intrinsics to access every instruction of the TILEPro
17168 processor. The intrinsics are of the form:
17169
17170 @smallexample
17171
17172 unsigned __insn_@var{op} (...)
17173
17174 @end smallexample
17175
17176 @noindent
17177 where @var{op} is the name of the instruction. Refer to the ISA manual
17178 for the complete list of instructions.
17179
17180 GCC also provides intrinsics to directly access the network registers.
17181 The intrinsics are:
17182
17183 @smallexample
17184
17185 unsigned __tile_idn0_receive (void)
17186 unsigned __tile_idn1_receive (void)
17187 unsigned __tile_sn_receive (void)
17188 unsigned __tile_udn0_receive (void)
17189 unsigned __tile_udn1_receive (void)
17190 unsigned __tile_udn2_receive (void)
17191 unsigned __tile_udn3_receive (void)
17192 void __tile_idn_send (unsigned)
17193 void __tile_sn_send (unsigned)
17194 void __tile_udn_send (unsigned)
17195
17196 @end smallexample
17197
17198 The intrinsic @code{void __tile_network_barrier (void)} is used to
17199 guarantee that no network operations before it are reordered with
17200 those after it.
17201
17202 @node Target Format Checks
17203 @section Format Checks Specific to Particular Target Machines
17204
17205 For some target machines, GCC supports additional options to the
17206 format attribute
17207 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
17208
17209 @menu
17210 * Solaris Format Checks::
17211 * Darwin Format Checks::
17212 @end menu
17213
17214 @node Solaris Format Checks
17215 @subsection Solaris Format Checks
17216
17217 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
17218 check. @code{cmn_err} accepts a subset of the standard @code{printf}
17219 conversions, and the two-argument @code{%b} conversion for displaying
17220 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
17221
17222 @node Darwin Format Checks
17223 @subsection Darwin Format Checks
17224
17225 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
17226 attribute context. Declarations made with such attribution are parsed for correct syntax
17227 and format argument types. However, parsing of the format string itself is currently undefined
17228 and is not carried out by this version of the compiler.
17229
17230 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
17231 also be used as format arguments. Note that the relevant headers are only likely to be
17232 available on Darwin (OSX) installations. On such installations, the XCode and system
17233 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
17234 associated functions.
17235
17236 @node Pragmas
17237 @section Pragmas Accepted by GCC
17238 @cindex pragmas
17239 @cindex @code{#pragma}
17240
17241 GCC supports several types of pragmas, primarily in order to compile
17242 code originally written for other compilers. Note that in general
17243 we do not recommend the use of pragmas; @xref{Function Attributes},
17244 for further explanation.
17245
17246 @menu
17247 * ARM Pragmas::
17248 * M32C Pragmas::
17249 * MeP Pragmas::
17250 * RS/6000 and PowerPC Pragmas::
17251 * Darwin Pragmas::
17252 * Solaris Pragmas::
17253 * Symbol-Renaming Pragmas::
17254 * Structure-Packing Pragmas::
17255 * Weak Pragmas::
17256 * Diagnostic Pragmas::
17257 * Visibility Pragmas::
17258 * Push/Pop Macro Pragmas::
17259 * Function Specific Option Pragmas::
17260 * Loop-Specific Pragmas::
17261 @end menu
17262
17263 @node ARM Pragmas
17264 @subsection ARM Pragmas
17265
17266 The ARM target defines pragmas for controlling the default addition of
17267 @code{long_call} and @code{short_call} attributes to functions.
17268 @xref{Function Attributes}, for information about the effects of these
17269 attributes.
17270
17271 @table @code
17272 @item long_calls
17273 @cindex pragma, long_calls
17274 Set all subsequent functions to have the @code{long_call} attribute.
17275
17276 @item no_long_calls
17277 @cindex pragma, no_long_calls
17278 Set all subsequent functions to have the @code{short_call} attribute.
17279
17280 @item long_calls_off
17281 @cindex pragma, long_calls_off
17282 Do not affect the @code{long_call} or @code{short_call} attributes of
17283 subsequent functions.
17284 @end table
17285
17286 @node M32C Pragmas
17287 @subsection M32C Pragmas
17288
17289 @table @code
17290 @item GCC memregs @var{number}
17291 @cindex pragma, memregs
17292 Overrides the command-line option @code{-memregs=} for the current
17293 file. Use with care! This pragma must be before any function in the
17294 file, and mixing different memregs values in different objects may
17295 make them incompatible. This pragma is useful when a
17296 performance-critical function uses a memreg for temporary values,
17297 as it may allow you to reduce the number of memregs used.
17298
17299 @item ADDRESS @var{name} @var{address}
17300 @cindex pragma, address
17301 For any declared symbols matching @var{name}, this does three things
17302 to that symbol: it forces the symbol to be located at the given
17303 address (a number), it forces the symbol to be volatile, and it
17304 changes the symbol's scope to be static. This pragma exists for
17305 compatibility with other compilers, but note that the common
17306 @code{1234H} numeric syntax is not supported (use @code{0x1234}
17307 instead). Example:
17308
17309 @smallexample
17310 #pragma ADDRESS port3 0x103
17311 char port3;
17312 @end smallexample
17313
17314 @end table
17315
17316 @node MeP Pragmas
17317 @subsection MeP Pragmas
17318
17319 @table @code
17320
17321 @item custom io_volatile (on|off)
17322 @cindex pragma, custom io_volatile
17323 Overrides the command-line option @code{-mio-volatile} for the current
17324 file. Note that for compatibility with future GCC releases, this
17325 option should only be used once before any @code{io} variables in each
17326 file.
17327
17328 @item GCC coprocessor available @var{registers}
17329 @cindex pragma, coprocessor available
17330 Specifies which coprocessor registers are available to the register
17331 allocator. @var{registers} may be a single register, register range
17332 separated by ellipses, or comma-separated list of those. Example:
17333
17334 @smallexample
17335 #pragma GCC coprocessor available $c0...$c10, $c28
17336 @end smallexample
17337
17338 @item GCC coprocessor call_saved @var{registers}
17339 @cindex pragma, coprocessor call_saved
17340 Specifies which coprocessor registers are to be saved and restored by
17341 any function using them. @var{registers} may be a single register,
17342 register range separated by ellipses, or comma-separated list of
17343 those. Example:
17344
17345 @smallexample
17346 #pragma GCC coprocessor call_saved $c4...$c6, $c31
17347 @end smallexample
17348
17349 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
17350 @cindex pragma, coprocessor subclass
17351 Creates and defines a register class. These register classes can be
17352 used by inline @code{asm} constructs. @var{registers} may be a single
17353 register, register range separated by ellipses, or comma-separated
17354 list of those. Example:
17355
17356 @smallexample
17357 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
17358
17359 asm ("cpfoo %0" : "=B" (x));
17360 @end smallexample
17361
17362 @item GCC disinterrupt @var{name} , @var{name} @dots{}
17363 @cindex pragma, disinterrupt
17364 For the named functions, the compiler adds code to disable interrupts
17365 for the duration of those functions. If any functions so named
17366 are not encountered in the source, a warning is emitted that the pragma is
17367 not used. Examples:
17368
17369 @smallexample
17370 #pragma disinterrupt foo
17371 #pragma disinterrupt bar, grill
17372 int foo () @{ @dots{} @}
17373 @end smallexample
17374
17375 @item GCC call @var{name} , @var{name} @dots{}
17376 @cindex pragma, call
17377 For the named functions, the compiler always uses a register-indirect
17378 call model when calling the named functions. Examples:
17379
17380 @smallexample
17381 extern int foo ();
17382 #pragma call foo
17383 @end smallexample
17384
17385 @end table
17386
17387 @node RS/6000 and PowerPC Pragmas
17388 @subsection RS/6000 and PowerPC Pragmas
17389
17390 The RS/6000 and PowerPC targets define one pragma for controlling
17391 whether or not the @code{longcall} attribute is added to function
17392 declarations by default. This pragma overrides the @option{-mlongcall}
17393 option, but not the @code{longcall} and @code{shortcall} attributes.
17394 @xref{RS/6000 and PowerPC Options}, for more information about when long
17395 calls are and are not necessary.
17396
17397 @table @code
17398 @item longcall (1)
17399 @cindex pragma, longcall
17400 Apply the @code{longcall} attribute to all subsequent function
17401 declarations.
17402
17403 @item longcall (0)
17404 Do not apply the @code{longcall} attribute to subsequent function
17405 declarations.
17406 @end table
17407
17408 @c Describe h8300 pragmas here.
17409 @c Describe sh pragmas here.
17410 @c Describe v850 pragmas here.
17411
17412 @node Darwin Pragmas
17413 @subsection Darwin Pragmas
17414
17415 The following pragmas are available for all architectures running the
17416 Darwin operating system. These are useful for compatibility with other
17417 Mac OS compilers.
17418
17419 @table @code
17420 @item mark @var{tokens}@dots{}
17421 @cindex pragma, mark
17422 This pragma is accepted, but has no effect.
17423
17424 @item options align=@var{alignment}
17425 @cindex pragma, options align
17426 This pragma sets the alignment of fields in structures. The values of
17427 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
17428 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
17429 properly; to restore the previous setting, use @code{reset} for the
17430 @var{alignment}.
17431
17432 @item segment @var{tokens}@dots{}
17433 @cindex pragma, segment
17434 This pragma is accepted, but has no effect.
17435
17436 @item unused (@var{var} [, @var{var}]@dots{})
17437 @cindex pragma, unused
17438 This pragma declares variables to be possibly unused. GCC does not
17439 produce warnings for the listed variables. The effect is similar to
17440 that of the @code{unused} attribute, except that this pragma may appear
17441 anywhere within the variables' scopes.
17442 @end table
17443
17444 @node Solaris Pragmas
17445 @subsection Solaris Pragmas
17446
17447 The Solaris target supports @code{#pragma redefine_extname}
17448 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
17449 @code{#pragma} directives for compatibility with the system compiler.
17450
17451 @table @code
17452 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
17453 @cindex pragma, align
17454
17455 Increase the minimum alignment of each @var{variable} to @var{alignment}.
17456 This is the same as GCC's @code{aligned} attribute @pxref{Variable
17457 Attributes}). Macro expansion occurs on the arguments to this pragma
17458 when compiling C and Objective-C@. It does not currently occur when
17459 compiling C++, but this is a bug which may be fixed in a future
17460 release.
17461
17462 @item fini (@var{function} [, @var{function}]...)
17463 @cindex pragma, fini
17464
17465 This pragma causes each listed @var{function} to be called after
17466 main, or during shared module unloading, by adding a call to the
17467 @code{.fini} section.
17468
17469 @item init (@var{function} [, @var{function}]...)
17470 @cindex pragma, init
17471
17472 This pragma causes each listed @var{function} to be called during
17473 initialization (before @code{main}) or during shared module loading, by
17474 adding a call to the @code{.init} section.
17475
17476 @end table
17477
17478 @node Symbol-Renaming Pragmas
17479 @subsection Symbol-Renaming Pragmas
17480
17481 GCC supports a @code{#pragma} directive that changes the name used in
17482 assembly for a given declaration. This effect can also be achieved
17483 using the asm labels extension (@pxref{Asm Labels}).
17484
17485 @table @code
17486 @item redefine_extname @var{oldname} @var{newname}
17487 @cindex pragma, redefine_extname
17488
17489 This pragma gives the C function @var{oldname} the assembly symbol
17490 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
17491 is defined if this pragma is available (currently on all platforms).
17492 @end table
17493
17494 This pragma and the asm labels extension interact in a complicated
17495 manner. Here are some corner cases you may want to be aware of:
17496
17497 @enumerate
17498 @item This pragma silently applies only to declarations with external
17499 linkage. Asm labels do not have this restriction.
17500
17501 @item In C++, this pragma silently applies only to declarations with
17502 ``C'' linkage. Again, asm labels do not have this restriction.
17503
17504 @item If either of the ways of changing the assembly name of a
17505 declaration are applied to a declaration whose assembly name has
17506 already been determined (either by a previous use of one of these
17507 features, or because the compiler needed the assembly name in order to
17508 generate code), and the new name is different, a warning issues and
17509 the name does not change.
17510
17511 @item The @var{oldname} used by @code{#pragma redefine_extname} is
17512 always the C-language name.
17513 @end enumerate
17514
17515 @node Structure-Packing Pragmas
17516 @subsection Structure-Packing Pragmas
17517
17518 For compatibility with Microsoft Windows compilers, GCC supports a
17519 set of @code{#pragma} directives that change the maximum alignment of
17520 members of structures (other than zero-width bit-fields), unions, and
17521 classes subsequently defined. The @var{n} value below always is required
17522 to be a small power of two and specifies the new alignment in bytes.
17523
17524 @enumerate
17525 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
17526 @item @code{#pragma pack()} sets the alignment to the one that was in
17527 effect when compilation started (see also command-line option
17528 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
17529 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
17530 setting on an internal stack and then optionally sets the new alignment.
17531 @item @code{#pragma pack(pop)} restores the alignment setting to the one
17532 saved at the top of the internal stack (and removes that stack entry).
17533 Note that @code{#pragma pack([@var{n}])} does not influence this internal
17534 stack; thus it is possible to have @code{#pragma pack(push)} followed by
17535 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
17536 @code{#pragma pack(pop)}.
17537 @end enumerate
17538
17539 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
17540 @code{#pragma} which lays out a structure as the documented
17541 @code{__attribute__ ((ms_struct))}.
17542 @enumerate
17543 @item @code{#pragma ms_struct on} turns on the layout for structures
17544 declared.
17545 @item @code{#pragma ms_struct off} turns off the layout for structures
17546 declared.
17547 @item @code{#pragma ms_struct reset} goes back to the default layout.
17548 @end enumerate
17549
17550 @node Weak Pragmas
17551 @subsection Weak Pragmas
17552
17553 For compatibility with SVR4, GCC supports a set of @code{#pragma}
17554 directives for declaring symbols to be weak, and defining weak
17555 aliases.
17556
17557 @table @code
17558 @item #pragma weak @var{symbol}
17559 @cindex pragma, weak
17560 This pragma declares @var{symbol} to be weak, as if the declaration
17561 had the attribute of the same name. The pragma may appear before
17562 or after the declaration of @var{symbol}. It is not an error for
17563 @var{symbol} to never be defined at all.
17564
17565 @item #pragma weak @var{symbol1} = @var{symbol2}
17566 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
17567 It is an error if @var{symbol2} is not defined in the current
17568 translation unit.
17569 @end table
17570
17571 @node Diagnostic Pragmas
17572 @subsection Diagnostic Pragmas
17573
17574 GCC allows the user to selectively enable or disable certain types of
17575 diagnostics, and change the kind of the diagnostic. For example, a
17576 project's policy might require that all sources compile with
17577 @option{-Werror} but certain files might have exceptions allowing
17578 specific types of warnings. Or, a project might selectively enable
17579 diagnostics and treat them as errors depending on which preprocessor
17580 macros are defined.
17581
17582 @table @code
17583 @item #pragma GCC diagnostic @var{kind} @var{option}
17584 @cindex pragma, diagnostic
17585
17586 Modifies the disposition of a diagnostic. Note that not all
17587 diagnostics are modifiable; at the moment only warnings (normally
17588 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
17589 Use @option{-fdiagnostics-show-option} to determine which diagnostics
17590 are controllable and which option controls them.
17591
17592 @var{kind} is @samp{error} to treat this diagnostic as an error,
17593 @samp{warning} to treat it like a warning (even if @option{-Werror} is
17594 in effect), or @samp{ignored} if the diagnostic is to be ignored.
17595 @var{option} is a double quoted string that matches the command-line
17596 option.
17597
17598 @smallexample
17599 #pragma GCC diagnostic warning "-Wformat"
17600 #pragma GCC diagnostic error "-Wformat"
17601 #pragma GCC diagnostic ignored "-Wformat"
17602 @end smallexample
17603
17604 Note that these pragmas override any command-line options. GCC keeps
17605 track of the location of each pragma, and issues diagnostics according
17606 to the state as of that point in the source file. Thus, pragmas occurring
17607 after a line do not affect diagnostics caused by that line.
17608
17609 @item #pragma GCC diagnostic push
17610 @itemx #pragma GCC diagnostic pop
17611
17612 Causes GCC to remember the state of the diagnostics as of each
17613 @code{push}, and restore to that point at each @code{pop}. If a
17614 @code{pop} has no matching @code{push}, the command-line options are
17615 restored.
17616
17617 @smallexample
17618 #pragma GCC diagnostic error "-Wuninitialized"
17619 foo(a); /* error is given for this one */
17620 #pragma GCC diagnostic push
17621 #pragma GCC diagnostic ignored "-Wuninitialized"
17622 foo(b); /* no diagnostic for this one */
17623 #pragma GCC diagnostic pop
17624 foo(c); /* error is given for this one */
17625 #pragma GCC diagnostic pop
17626 foo(d); /* depends on command-line options */
17627 @end smallexample
17628
17629 @end table
17630
17631 GCC also offers a simple mechanism for printing messages during
17632 compilation.
17633
17634 @table @code
17635 @item #pragma message @var{string}
17636 @cindex pragma, diagnostic
17637
17638 Prints @var{string} as a compiler message on compilation. The message
17639 is informational only, and is neither a compilation warning nor an error.
17640
17641 @smallexample
17642 #pragma message "Compiling " __FILE__ "..."
17643 @end smallexample
17644
17645 @var{string} may be parenthesized, and is printed with location
17646 information. For example,
17647
17648 @smallexample
17649 #define DO_PRAGMA(x) _Pragma (#x)
17650 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
17651
17652 TODO(Remember to fix this)
17653 @end smallexample
17654
17655 @noindent
17656 prints @samp{/tmp/file.c:4: note: #pragma message:
17657 TODO - Remember to fix this}.
17658
17659 @end table
17660
17661 @node Visibility Pragmas
17662 @subsection Visibility Pragmas
17663
17664 @table @code
17665 @item #pragma GCC visibility push(@var{visibility})
17666 @itemx #pragma GCC visibility pop
17667 @cindex pragma, visibility
17668
17669 This pragma allows the user to set the visibility for multiple
17670 declarations without having to give each a visibility attribute
17671 (@pxref{Function Attributes}).
17672
17673 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
17674 declarations. Class members and template specializations are not
17675 affected; if you want to override the visibility for a particular
17676 member or instantiation, you must use an attribute.
17677
17678 @end table
17679
17680
17681 @node Push/Pop Macro Pragmas
17682 @subsection Push/Pop Macro Pragmas
17683
17684 For compatibility with Microsoft Windows compilers, GCC supports
17685 @samp{#pragma push_macro(@var{"macro_name"})}
17686 and @samp{#pragma pop_macro(@var{"macro_name"})}.
17687
17688 @table @code
17689 @item #pragma push_macro(@var{"macro_name"})
17690 @cindex pragma, push_macro
17691 This pragma saves the value of the macro named as @var{macro_name} to
17692 the top of the stack for this macro.
17693
17694 @item #pragma pop_macro(@var{"macro_name"})
17695 @cindex pragma, pop_macro
17696 This pragma sets the value of the macro named as @var{macro_name} to
17697 the value on top of the stack for this macro. If the stack for
17698 @var{macro_name} is empty, the value of the macro remains unchanged.
17699 @end table
17700
17701 For example:
17702
17703 @smallexample
17704 #define X 1
17705 #pragma push_macro("X")
17706 #undef X
17707 #define X -1
17708 #pragma pop_macro("X")
17709 int x [X];
17710 @end smallexample
17711
17712 @noindent
17713 In this example, the definition of X as 1 is saved by @code{#pragma
17714 push_macro} and restored by @code{#pragma pop_macro}.
17715
17716 @node Function Specific Option Pragmas
17717 @subsection Function Specific Option Pragmas
17718
17719 @table @code
17720 @item #pragma GCC target (@var{"string"}...)
17721 @cindex pragma GCC target
17722
17723 This pragma allows you to set target specific options for functions
17724 defined later in the source file. One or more strings can be
17725 specified. Each function that is defined after this point is as
17726 if @code{attribute((target("STRING")))} was specified for that
17727 function. The parenthesis around the options is optional.
17728 @xref{Function Attributes}, for more information about the
17729 @code{target} attribute and the attribute syntax.
17730
17731 The @code{#pragma GCC target} pragma is presently implemented for
17732 i386/x86_64, PowerPC, and Nios II targets only.
17733 @end table
17734
17735 @table @code
17736 @item #pragma GCC optimize (@var{"string"}...)
17737 @cindex pragma GCC optimize
17738
17739 This pragma allows you to set global optimization options for functions
17740 defined later in the source file. One or more strings can be
17741 specified. Each function that is defined after this point is as
17742 if @code{attribute((optimize("STRING")))} was specified for that
17743 function. The parenthesis around the options is optional.
17744 @xref{Function Attributes}, for more information about the
17745 @code{optimize} attribute and the attribute syntax.
17746
17747 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
17748 versions earlier than 4.4.
17749 @end table
17750
17751 @table @code
17752 @item #pragma GCC push_options
17753 @itemx #pragma GCC pop_options
17754 @cindex pragma GCC push_options
17755 @cindex pragma GCC pop_options
17756
17757 These pragmas maintain a stack of the current target and optimization
17758 options. It is intended for include files where you temporarily want
17759 to switch to using a different @samp{#pragma GCC target} or
17760 @samp{#pragma GCC optimize} and then to pop back to the previous
17761 options.
17762
17763 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
17764 pragmas are not implemented in GCC versions earlier than 4.4.
17765 @end table
17766
17767 @table @code
17768 @item #pragma GCC reset_options
17769 @cindex pragma GCC reset_options
17770
17771 This pragma clears the current @code{#pragma GCC target} and
17772 @code{#pragma GCC optimize} to use the default switches as specified
17773 on the command line.
17774
17775 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
17776 versions earlier than 4.4.
17777 @end table
17778
17779 @node Loop-Specific Pragmas
17780 @subsection Loop-Specific Pragmas
17781
17782 @table @code
17783 @item #pragma GCC ivdep
17784 @cindex pragma GCC ivdep
17785 @end table
17786
17787 With this pragma, the programmer asserts that there are no loop-carried
17788 dependencies which would prevent that consecutive iterations of
17789 the following loop can be executed concurrently with SIMD
17790 (single instruction multiple data) instructions.
17791
17792 For example, the compiler can only unconditionally vectorize the following
17793 loop with the pragma:
17794
17795 @smallexample
17796 void foo (int n, int *a, int *b, int *c)
17797 @{
17798 int i, j;
17799 #pragma GCC ivdep
17800 for (i = 0; i < n; ++i)
17801 a[i] = b[i] + c[i];
17802 @}
17803 @end smallexample
17804
17805 @noindent
17806 In this example, using the @code{restrict} qualifier had the same
17807 effect. In the following example, that would not be possible. Assume
17808 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
17809 that it can unconditionally vectorize the following loop:
17810
17811 @smallexample
17812 void ignore_vec_dep (int *a, int k, int c, int m)
17813 @{
17814 #pragma GCC ivdep
17815 for (int i = 0; i < m; i++)
17816 a[i] = a[i + k] * c;
17817 @}
17818 @end smallexample
17819
17820
17821 @node Unnamed Fields
17822 @section Unnamed struct/union fields within structs/unions
17823 @cindex @code{struct}
17824 @cindex @code{union}
17825
17826 As permitted by ISO C11 and for compatibility with other compilers,
17827 GCC allows you to define
17828 a structure or union that contains, as fields, structures and unions
17829 without names. For example:
17830
17831 @smallexample
17832 struct @{
17833 int a;
17834 union @{
17835 int b;
17836 float c;
17837 @};
17838 int d;
17839 @} foo;
17840 @end smallexample
17841
17842 @noindent
17843 In this example, you are able to access members of the unnamed
17844 union with code like @samp{foo.b}. Note that only unnamed structs and
17845 unions are allowed, you may not have, for example, an unnamed
17846 @code{int}.
17847
17848 You must never create such structures that cause ambiguous field definitions.
17849 For example, in this structure:
17850
17851 @smallexample
17852 struct @{
17853 int a;
17854 struct @{
17855 int a;
17856 @};
17857 @} foo;
17858 @end smallexample
17859
17860 @noindent
17861 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
17862 The compiler gives errors for such constructs.
17863
17864 @opindex fms-extensions
17865 Unless @option{-fms-extensions} is used, the unnamed field must be a
17866 structure or union definition without a tag (for example, @samp{struct
17867 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
17868 also be a definition with a tag such as @samp{struct foo @{ int a;
17869 @};}, a reference to a previously defined structure or union such as
17870 @samp{struct foo;}, or a reference to a @code{typedef} name for a
17871 previously defined structure or union type.
17872
17873 @opindex fplan9-extensions
17874 The option @option{-fplan9-extensions} enables
17875 @option{-fms-extensions} as well as two other extensions. First, a
17876 pointer to a structure is automatically converted to a pointer to an
17877 anonymous field for assignments and function calls. For example:
17878
17879 @smallexample
17880 struct s1 @{ int a; @};
17881 struct s2 @{ struct s1; @};
17882 extern void f1 (struct s1 *);
17883 void f2 (struct s2 *p) @{ f1 (p); @}
17884 @end smallexample
17885
17886 @noindent
17887 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
17888 converted into a pointer to the anonymous field.
17889
17890 Second, when the type of an anonymous field is a @code{typedef} for a
17891 @code{struct} or @code{union}, code may refer to the field using the
17892 name of the @code{typedef}.
17893
17894 @smallexample
17895 typedef struct @{ int a; @} s1;
17896 struct s2 @{ s1; @};
17897 s1 f1 (struct s2 *p) @{ return p->s1; @}
17898 @end smallexample
17899
17900 These usages are only permitted when they are not ambiguous.
17901
17902 @node Thread-Local
17903 @section Thread-Local Storage
17904 @cindex Thread-Local Storage
17905 @cindex @acronym{TLS}
17906 @cindex @code{__thread}
17907
17908 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
17909 are allocated such that there is one instance of the variable per extant
17910 thread. The runtime model GCC uses to implement this originates
17911 in the IA-64 processor-specific ABI, but has since been migrated
17912 to other processors as well. It requires significant support from
17913 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
17914 system libraries (@file{libc.so} and @file{libpthread.so}), so it
17915 is not available everywhere.
17916
17917 At the user level, the extension is visible with a new storage
17918 class keyword: @code{__thread}. For example:
17919
17920 @smallexample
17921 __thread int i;
17922 extern __thread struct state s;
17923 static __thread char *p;
17924 @end smallexample
17925
17926 The @code{__thread} specifier may be used alone, with the @code{extern}
17927 or @code{static} specifiers, but with no other storage class specifier.
17928 When used with @code{extern} or @code{static}, @code{__thread} must appear
17929 immediately after the other storage class specifier.
17930
17931 The @code{__thread} specifier may be applied to any global, file-scoped
17932 static, function-scoped static, or static data member of a class. It may
17933 not be applied to block-scoped automatic or non-static data member.
17934
17935 When the address-of operator is applied to a thread-local variable, it is
17936 evaluated at run time and returns the address of the current thread's
17937 instance of that variable. An address so obtained may be used by any
17938 thread. When a thread terminates, any pointers to thread-local variables
17939 in that thread become invalid.
17940
17941 No static initialization may refer to the address of a thread-local variable.
17942
17943 In C++, if an initializer is present for a thread-local variable, it must
17944 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
17945 standard.
17946
17947 See @uref{http://www.akkadia.org/drepper/tls.pdf,
17948 ELF Handling For Thread-Local Storage} for a detailed explanation of
17949 the four thread-local storage addressing models, and how the runtime
17950 is expected to function.
17951
17952 @menu
17953 * C99 Thread-Local Edits::
17954 * C++98 Thread-Local Edits::
17955 @end menu
17956
17957 @node C99 Thread-Local Edits
17958 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
17959
17960 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
17961 that document the exact semantics of the language extension.
17962
17963 @itemize @bullet
17964 @item
17965 @cite{5.1.2 Execution environments}
17966
17967 Add new text after paragraph 1
17968
17969 @quotation
17970 Within either execution environment, a @dfn{thread} is a flow of
17971 control within a program. It is implementation defined whether
17972 or not there may be more than one thread associated with a program.
17973 It is implementation defined how threads beyond the first are
17974 created, the name and type of the function called at thread
17975 startup, and how threads may be terminated. However, objects
17976 with thread storage duration shall be initialized before thread
17977 startup.
17978 @end quotation
17979
17980 @item
17981 @cite{6.2.4 Storage durations of objects}
17982
17983 Add new text before paragraph 3
17984
17985 @quotation
17986 An object whose identifier is declared with the storage-class
17987 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
17988 Its lifetime is the entire execution of the thread, and its
17989 stored value is initialized only once, prior to thread startup.
17990 @end quotation
17991
17992 @item
17993 @cite{6.4.1 Keywords}
17994
17995 Add @code{__thread}.
17996
17997 @item
17998 @cite{6.7.1 Storage-class specifiers}
17999
18000 Add @code{__thread} to the list of storage class specifiers in
18001 paragraph 1.
18002
18003 Change paragraph 2 to
18004
18005 @quotation
18006 With the exception of @code{__thread}, at most one storage-class
18007 specifier may be given [@dots{}]. The @code{__thread} specifier may
18008 be used alone, or immediately following @code{extern} or
18009 @code{static}.
18010 @end quotation
18011
18012 Add new text after paragraph 6
18013
18014 @quotation
18015 The declaration of an identifier for a variable that has
18016 block scope that specifies @code{__thread} shall also
18017 specify either @code{extern} or @code{static}.
18018
18019 The @code{__thread} specifier shall be used only with
18020 variables.
18021 @end quotation
18022 @end itemize
18023
18024 @node C++98 Thread-Local Edits
18025 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
18026
18027 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
18028 that document the exact semantics of the language extension.
18029
18030 @itemize @bullet
18031 @item
18032 @b{[intro.execution]}
18033
18034 New text after paragraph 4
18035
18036 @quotation
18037 A @dfn{thread} is a flow of control within the abstract machine.
18038 It is implementation defined whether or not there may be more than
18039 one thread.
18040 @end quotation
18041
18042 New text after paragraph 7
18043
18044 @quotation
18045 It is unspecified whether additional action must be taken to
18046 ensure when and whether side effects are visible to other threads.
18047 @end quotation
18048
18049 @item
18050 @b{[lex.key]}
18051
18052 Add @code{__thread}.
18053
18054 @item
18055 @b{[basic.start.main]}
18056
18057 Add after paragraph 5
18058
18059 @quotation
18060 The thread that begins execution at the @code{main} function is called
18061 the @dfn{main thread}. It is implementation defined how functions
18062 beginning threads other than the main thread are designated or typed.
18063 A function so designated, as well as the @code{main} function, is called
18064 a @dfn{thread startup function}. It is implementation defined what
18065 happens if a thread startup function returns. It is implementation
18066 defined what happens to other threads when any thread calls @code{exit}.
18067 @end quotation
18068
18069 @item
18070 @b{[basic.start.init]}
18071
18072 Add after paragraph 4
18073
18074 @quotation
18075 The storage for an object of thread storage duration shall be
18076 statically initialized before the first statement of the thread startup
18077 function. An object of thread storage duration shall not require
18078 dynamic initialization.
18079 @end quotation
18080
18081 @item
18082 @b{[basic.start.term]}
18083
18084 Add after paragraph 3
18085
18086 @quotation
18087 The type of an object with thread storage duration shall not have a
18088 non-trivial destructor, nor shall it be an array type whose elements
18089 (directly or indirectly) have non-trivial destructors.
18090 @end quotation
18091
18092 @item
18093 @b{[basic.stc]}
18094
18095 Add ``thread storage duration'' to the list in paragraph 1.
18096
18097 Change paragraph 2
18098
18099 @quotation
18100 Thread, static, and automatic storage durations are associated with
18101 objects introduced by declarations [@dots{}].
18102 @end quotation
18103
18104 Add @code{__thread} to the list of specifiers in paragraph 3.
18105
18106 @item
18107 @b{[basic.stc.thread]}
18108
18109 New section before @b{[basic.stc.static]}
18110
18111 @quotation
18112 The keyword @code{__thread} applied to a non-local object gives the
18113 object thread storage duration.
18114
18115 A local variable or class data member declared both @code{static}
18116 and @code{__thread} gives the variable or member thread storage
18117 duration.
18118 @end quotation
18119
18120 @item
18121 @b{[basic.stc.static]}
18122
18123 Change paragraph 1
18124
18125 @quotation
18126 All objects that have neither thread storage duration, dynamic
18127 storage duration nor are local [@dots{}].
18128 @end quotation
18129
18130 @item
18131 @b{[dcl.stc]}
18132
18133 Add @code{__thread} to the list in paragraph 1.
18134
18135 Change paragraph 1
18136
18137 @quotation
18138 With the exception of @code{__thread}, at most one
18139 @var{storage-class-specifier} shall appear in a given
18140 @var{decl-specifier-seq}. The @code{__thread} specifier may
18141 be used alone, or immediately following the @code{extern} or
18142 @code{static} specifiers. [@dots{}]
18143 @end quotation
18144
18145 Add after paragraph 5
18146
18147 @quotation
18148 The @code{__thread} specifier can be applied only to the names of objects
18149 and to anonymous unions.
18150 @end quotation
18151
18152 @item
18153 @b{[class.mem]}
18154
18155 Add after paragraph 6
18156
18157 @quotation
18158 Non-@code{static} members shall not be @code{__thread}.
18159 @end quotation
18160 @end itemize
18161
18162 @node Binary constants
18163 @section Binary constants using the @samp{0b} prefix
18164 @cindex Binary constants using the @samp{0b} prefix
18165
18166 Integer constants can be written as binary constants, consisting of a
18167 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
18168 @samp{0B}. This is particularly useful in environments that operate a
18169 lot on the bit level (like microcontrollers).
18170
18171 The following statements are identical:
18172
18173 @smallexample
18174 i = 42;
18175 i = 0x2a;
18176 i = 052;
18177 i = 0b101010;
18178 @end smallexample
18179
18180 The type of these constants follows the same rules as for octal or
18181 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
18182 can be applied.
18183
18184 @node C++ Extensions
18185 @chapter Extensions to the C++ Language
18186 @cindex extensions, C++ language
18187 @cindex C++ language extensions
18188
18189 The GNU compiler provides these extensions to the C++ language (and you
18190 can also use most of the C language extensions in your C++ programs). If you
18191 want to write code that checks whether these features are available, you can
18192 test for the GNU compiler the same way as for C programs: check for a
18193 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
18194 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
18195 Predefined Macros,cpp,The GNU C Preprocessor}).
18196
18197 @menu
18198 * C++ Volatiles:: What constitutes an access to a volatile object.
18199 * Restricted Pointers:: C99 restricted pointers and references.
18200 * Vague Linkage:: Where G++ puts inlines, vtables and such.
18201 * C++ Interface:: You can use a single C++ header file for both
18202 declarations and definitions.
18203 * Template Instantiation:: Methods for ensuring that exactly one copy of
18204 each needed template instantiation is emitted.
18205 * Bound member functions:: You can extract a function pointer to the
18206 method denoted by a @samp{->*} or @samp{.*} expression.
18207 * C++ Attributes:: Variable, function, and type attributes for C++ only.
18208 * Function Multiversioning:: Declaring multiple function versions.
18209 * Namespace Association:: Strong using-directives for namespace association.
18210 * Type Traits:: Compiler support for type traits
18211 * Java Exceptions:: Tweaking exception handling to work with Java.
18212 * Deprecated Features:: Things will disappear from G++.
18213 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
18214 @end menu
18215
18216 @node C++ Volatiles
18217 @section When is a Volatile C++ Object Accessed?
18218 @cindex accessing volatiles
18219 @cindex volatile read
18220 @cindex volatile write
18221 @cindex volatile access
18222
18223 The C++ standard differs from the C standard in its treatment of
18224 volatile objects. It fails to specify what constitutes a volatile
18225 access, except to say that C++ should behave in a similar manner to C
18226 with respect to volatiles, where possible. However, the different
18227 lvalueness of expressions between C and C++ complicate the behavior.
18228 G++ behaves the same as GCC for volatile access, @xref{C
18229 Extensions,,Volatiles}, for a description of GCC's behavior.
18230
18231 The C and C++ language specifications differ when an object is
18232 accessed in a void context:
18233
18234 @smallexample
18235 volatile int *src = @var{somevalue};
18236 *src;
18237 @end smallexample
18238
18239 The C++ standard specifies that such expressions do not undergo lvalue
18240 to rvalue conversion, and that the type of the dereferenced object may
18241 be incomplete. The C++ standard does not specify explicitly that it
18242 is lvalue to rvalue conversion that is responsible for causing an
18243 access. There is reason to believe that it is, because otherwise
18244 certain simple expressions become undefined. However, because it
18245 would surprise most programmers, G++ treats dereferencing a pointer to
18246 volatile object of complete type as GCC would do for an equivalent
18247 type in C@. When the object has incomplete type, G++ issues a
18248 warning; if you wish to force an error, you must force a conversion to
18249 rvalue with, for instance, a static cast.
18250
18251 When using a reference to volatile, G++ does not treat equivalent
18252 expressions as accesses to volatiles, but instead issues a warning that
18253 no volatile is accessed. The rationale for this is that otherwise it
18254 becomes difficult to determine where volatile access occur, and not
18255 possible to ignore the return value from functions returning volatile
18256 references. Again, if you wish to force a read, cast the reference to
18257 an rvalue.
18258
18259 G++ implements the same behavior as GCC does when assigning to a
18260 volatile object---there is no reread of the assigned-to object, the
18261 assigned rvalue is reused. Note that in C++ assignment expressions
18262 are lvalues, and if used as an lvalue, the volatile object is
18263 referred to. For instance, @var{vref} refers to @var{vobj}, as
18264 expected, in the following example:
18265
18266 @smallexample
18267 volatile int vobj;
18268 volatile int &vref = vobj = @var{something};
18269 @end smallexample
18270
18271 @node Restricted Pointers
18272 @section Restricting Pointer Aliasing
18273 @cindex restricted pointers
18274 @cindex restricted references
18275 @cindex restricted this pointer
18276
18277 As with the C front end, G++ understands the C99 feature of restricted pointers,
18278 specified with the @code{__restrict__}, or @code{__restrict} type
18279 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
18280 language flag, @code{restrict} is not a keyword in C++.
18281
18282 In addition to allowing restricted pointers, you can specify restricted
18283 references, which indicate that the reference is not aliased in the local
18284 context.
18285
18286 @smallexample
18287 void fn (int *__restrict__ rptr, int &__restrict__ rref)
18288 @{
18289 /* @r{@dots{}} */
18290 @}
18291 @end smallexample
18292
18293 @noindent
18294 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
18295 @var{rref} refers to a (different) unaliased integer.
18296
18297 You may also specify whether a member function's @var{this} pointer is
18298 unaliased by using @code{__restrict__} as a member function qualifier.
18299
18300 @smallexample
18301 void T::fn () __restrict__
18302 @{
18303 /* @r{@dots{}} */
18304 @}
18305 @end smallexample
18306
18307 @noindent
18308 Within the body of @code{T::fn}, @var{this} has the effective
18309 definition @code{T *__restrict__ const this}. Notice that the
18310 interpretation of a @code{__restrict__} member function qualifier is
18311 different to that of @code{const} or @code{volatile} qualifier, in that it
18312 is applied to the pointer rather than the object. This is consistent with
18313 other compilers that implement restricted pointers.
18314
18315 As with all outermost parameter qualifiers, @code{__restrict__} is
18316 ignored in function definition matching. This means you only need to
18317 specify @code{__restrict__} in a function definition, rather than
18318 in a function prototype as well.
18319
18320 @node Vague Linkage
18321 @section Vague Linkage
18322 @cindex vague linkage
18323
18324 There are several constructs in C++ that require space in the object
18325 file but are not clearly tied to a single translation unit. We say that
18326 these constructs have ``vague linkage''. Typically such constructs are
18327 emitted wherever they are needed, though sometimes we can be more
18328 clever.
18329
18330 @table @asis
18331 @item Inline Functions
18332 Inline functions are typically defined in a header file which can be
18333 included in many different compilations. Hopefully they can usually be
18334 inlined, but sometimes an out-of-line copy is necessary, if the address
18335 of the function is taken or if inlining fails. In general, we emit an
18336 out-of-line copy in all translation units where one is needed. As an
18337 exception, we only emit inline virtual functions with the vtable, since
18338 it always requires a copy.
18339
18340 Local static variables and string constants used in an inline function
18341 are also considered to have vague linkage, since they must be shared
18342 between all inlined and out-of-line instances of the function.
18343
18344 @item VTables
18345 @cindex vtable
18346 C++ virtual functions are implemented in most compilers using a lookup
18347 table, known as a vtable. The vtable contains pointers to the virtual
18348 functions provided by a class, and each object of the class contains a
18349 pointer to its vtable (or vtables, in some multiple-inheritance
18350 situations). If the class declares any non-inline, non-pure virtual
18351 functions, the first one is chosen as the ``key method'' for the class,
18352 and the vtable is only emitted in the translation unit where the key
18353 method is defined.
18354
18355 @emph{Note:} If the chosen key method is later defined as inline, the
18356 vtable is still emitted in every translation unit that defines it.
18357 Make sure that any inline virtuals are declared inline in the class
18358 body, even if they are not defined there.
18359
18360 @item @code{type_info} objects
18361 @cindex @code{type_info}
18362 @cindex RTTI
18363 C++ requires information about types to be written out in order to
18364 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
18365 For polymorphic classes (classes with virtual functions), the @samp{type_info}
18366 object is written out along with the vtable so that @samp{dynamic_cast}
18367 can determine the dynamic type of a class object at run time. For all
18368 other types, we write out the @samp{type_info} object when it is used: when
18369 applying @samp{typeid} to an expression, throwing an object, or
18370 referring to a type in a catch clause or exception specification.
18371
18372 @item Template Instantiations
18373 Most everything in this section also applies to template instantiations,
18374 but there are other options as well.
18375 @xref{Template Instantiation,,Where's the Template?}.
18376
18377 @end table
18378
18379 When used with GNU ld version 2.8 or later on an ELF system such as
18380 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
18381 these constructs will be discarded at link time. This is known as
18382 COMDAT support.
18383
18384 On targets that don't support COMDAT, but do support weak symbols, GCC
18385 uses them. This way one copy overrides all the others, but
18386 the unused copies still take up space in the executable.
18387
18388 For targets that do not support either COMDAT or weak symbols,
18389 most entities with vague linkage are emitted as local symbols to
18390 avoid duplicate definition errors from the linker. This does not happen
18391 for local statics in inlines, however, as having multiple copies
18392 almost certainly breaks things.
18393
18394 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
18395 another way to control placement of these constructs.
18396
18397 @node C++ Interface
18398 @section #pragma interface and implementation
18399
18400 @cindex interface and implementation headers, C++
18401 @cindex C++ interface and implementation headers
18402 @cindex pragmas, interface and implementation
18403
18404 @code{#pragma interface} and @code{#pragma implementation} provide the
18405 user with a way of explicitly directing the compiler to emit entities
18406 with vague linkage (and debugging information) in a particular
18407 translation unit.
18408
18409 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
18410 most cases, because of COMDAT support and the ``key method'' heuristic
18411 mentioned in @ref{Vague Linkage}. Using them can actually cause your
18412 program to grow due to unnecessary out-of-line copies of inline
18413 functions. Currently (3.4) the only benefit of these
18414 @code{#pragma}s is reduced duplication of debugging information, and
18415 that should be addressed soon on DWARF 2 targets with the use of
18416 COMDAT groups.
18417
18418 @table @code
18419 @item #pragma interface
18420 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
18421 @kindex #pragma interface
18422 Use this directive in @emph{header files} that define object classes, to save
18423 space in most of the object files that use those classes. Normally,
18424 local copies of certain information (backup copies of inline member
18425 functions, debugging information, and the internal tables that implement
18426 virtual functions) must be kept in each object file that includes class
18427 definitions. You can use this pragma to avoid such duplication. When a
18428 header file containing @samp{#pragma interface} is included in a
18429 compilation, this auxiliary information is not generated (unless
18430 the main input source file itself uses @samp{#pragma implementation}).
18431 Instead, the object files contain references to be resolved at link
18432 time.
18433
18434 The second form of this directive is useful for the case where you have
18435 multiple headers with the same name in different directories. If you
18436 use this form, you must specify the same string to @samp{#pragma
18437 implementation}.
18438
18439 @item #pragma implementation
18440 @itemx #pragma implementation "@var{objects}.h"
18441 @kindex #pragma implementation
18442 Use this pragma in a @emph{main input file}, when you want full output from
18443 included header files to be generated (and made globally visible). The
18444 included header file, in turn, should use @samp{#pragma interface}.
18445 Backup copies of inline member functions, debugging information, and the
18446 internal tables used to implement virtual functions are all generated in
18447 implementation files.
18448
18449 @cindex implied @code{#pragma implementation}
18450 @cindex @code{#pragma implementation}, implied
18451 @cindex naming convention, implementation headers
18452 If you use @samp{#pragma implementation} with no argument, it applies to
18453 an include file with the same basename@footnote{A file's @dfn{basename}
18454 is the name stripped of all leading path information and of trailing
18455 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
18456 file. For example, in @file{allclass.cc}, giving just
18457 @samp{#pragma implementation}
18458 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
18459
18460 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
18461 an implementation file whenever you would include it from
18462 @file{allclass.cc} even if you never specified @samp{#pragma
18463 implementation}. This was deemed to be more trouble than it was worth,
18464 however, and disabled.
18465
18466 Use the string argument if you want a single implementation file to
18467 include code from multiple header files. (You must also use
18468 @samp{#include} to include the header file; @samp{#pragma
18469 implementation} only specifies how to use the file---it doesn't actually
18470 include it.)
18471
18472 There is no way to split up the contents of a single header file into
18473 multiple implementation files.
18474 @end table
18475
18476 @cindex inlining and C++ pragmas
18477 @cindex C++ pragmas, effect on inlining
18478 @cindex pragmas in C++, effect on inlining
18479 @samp{#pragma implementation} and @samp{#pragma interface} also have an
18480 effect on function inlining.
18481
18482 If you define a class in a header file marked with @samp{#pragma
18483 interface}, the effect on an inline function defined in that class is
18484 similar to an explicit @code{extern} declaration---the compiler emits
18485 no code at all to define an independent version of the function. Its
18486 definition is used only for inlining with its callers.
18487
18488 @opindex fno-implement-inlines
18489 Conversely, when you include the same header file in a main source file
18490 that declares it as @samp{#pragma implementation}, the compiler emits
18491 code for the function itself; this defines a version of the function
18492 that can be found via pointers (or by callers compiled without
18493 inlining). If all calls to the function can be inlined, you can avoid
18494 emitting the function by compiling with @option{-fno-implement-inlines}.
18495 If any calls are not inlined, you will get linker errors.
18496
18497 @node Template Instantiation
18498 @section Where's the Template?
18499 @cindex template instantiation
18500
18501 C++ templates are the first language feature to require more
18502 intelligence from the environment than one usually finds on a UNIX
18503 system. Somehow the compiler and linker have to make sure that each
18504 template instance occurs exactly once in the executable if it is needed,
18505 and not at all otherwise. There are two basic approaches to this
18506 problem, which are referred to as the Borland model and the Cfront model.
18507
18508 @table @asis
18509 @item Borland model
18510 Borland C++ solved the template instantiation problem by adding the code
18511 equivalent of common blocks to their linker; the compiler emits template
18512 instances in each translation unit that uses them, and the linker
18513 collapses them together. The advantage of this model is that the linker
18514 only has to consider the object files themselves; there is no external
18515 complexity to worry about. This disadvantage is that compilation time
18516 is increased because the template code is being compiled repeatedly.
18517 Code written for this model tends to include definitions of all
18518 templates in the header file, since they must be seen to be
18519 instantiated.
18520
18521 @item Cfront model
18522 The AT&T C++ translator, Cfront, solved the template instantiation
18523 problem by creating the notion of a template repository, an
18524 automatically maintained place where template instances are stored. A
18525 more modern version of the repository works as follows: As individual
18526 object files are built, the compiler places any template definitions and
18527 instantiations encountered in the repository. At link time, the link
18528 wrapper adds in the objects in the repository and compiles any needed
18529 instances that were not previously emitted. The advantages of this
18530 model are more optimal compilation speed and the ability to use the
18531 system linker; to implement the Borland model a compiler vendor also
18532 needs to replace the linker. The disadvantages are vastly increased
18533 complexity, and thus potential for error; for some code this can be
18534 just as transparent, but in practice it can been very difficult to build
18535 multiple programs in one directory and one program in multiple
18536 directories. Code written for this model tends to separate definitions
18537 of non-inline member templates into a separate file, which should be
18538 compiled separately.
18539 @end table
18540
18541 When used with GNU ld version 2.8 or later on an ELF system such as
18542 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
18543 Borland model. On other systems, G++ implements neither automatic
18544 model.
18545
18546 You have the following options for dealing with template instantiations:
18547
18548 @enumerate
18549 @item
18550 @opindex frepo
18551 Compile your template-using code with @option{-frepo}. The compiler
18552 generates files with the extension @samp{.rpo} listing all of the
18553 template instantiations used in the corresponding object files that
18554 could be instantiated there; the link wrapper, @samp{collect2},
18555 then updates the @samp{.rpo} files to tell the compiler where to place
18556 those instantiations and rebuild any affected object files. The
18557 link-time overhead is negligible after the first pass, as the compiler
18558 continues to place the instantiations in the same files.
18559
18560 This is your best option for application code written for the Borland
18561 model, as it just works. Code written for the Cfront model
18562 needs to be modified so that the template definitions are available at
18563 one or more points of instantiation; usually this is as simple as adding
18564 @code{#include <tmethods.cc>} to the end of each template header.
18565
18566 For library code, if you want the library to provide all of the template
18567 instantiations it needs, just try to link all of its object files
18568 together; the link will fail, but cause the instantiations to be
18569 generated as a side effect. Be warned, however, that this may cause
18570 conflicts if multiple libraries try to provide the same instantiations.
18571 For greater control, use explicit instantiation as described in the next
18572 option.
18573
18574 @item
18575 @opindex fno-implicit-templates
18576 Compile your code with @option{-fno-implicit-templates} to disable the
18577 implicit generation of template instances, and explicitly instantiate
18578 all the ones you use. This approach requires more knowledge of exactly
18579 which instances you need than do the others, but it's less
18580 mysterious and allows greater control. You can scatter the explicit
18581 instantiations throughout your program, perhaps putting them in the
18582 translation units where the instances are used or the translation units
18583 that define the templates themselves; you can put all of the explicit
18584 instantiations you need into one big file; or you can create small files
18585 like
18586
18587 @smallexample
18588 #include "Foo.h"
18589 #include "Foo.cc"
18590
18591 template class Foo<int>;
18592 template ostream& operator <<
18593 (ostream&, const Foo<int>&);
18594 @end smallexample
18595
18596 @noindent
18597 for each of the instances you need, and create a template instantiation
18598 library from those.
18599
18600 If you are using Cfront-model code, you can probably get away with not
18601 using @option{-fno-implicit-templates} when compiling files that don't
18602 @samp{#include} the member template definitions.
18603
18604 If you use one big file to do the instantiations, you may want to
18605 compile it without @option{-fno-implicit-templates} so you get all of the
18606 instances required by your explicit instantiations (but not by any
18607 other files) without having to specify them as well.
18608
18609 The ISO C++ 2011 standard allows forward declaration of explicit
18610 instantiations (with @code{extern}). G++ supports explicit instantiation
18611 declarations in C++98 mode and has extended the template instantiation
18612 syntax to support instantiation of the compiler support data for a
18613 template class (i.e.@: the vtable) without instantiating any of its
18614 members (with @code{inline}), and instantiation of only the static data
18615 members of a template class, without the support data or member
18616 functions (with @code{static}):
18617
18618 @smallexample
18619 extern template int max (int, int);
18620 inline template class Foo<int>;
18621 static template class Foo<int>;
18622 @end smallexample
18623
18624 @item
18625 Do nothing. Pretend G++ does implement automatic instantiation
18626 management. Code written for the Borland model works fine, but
18627 each translation unit contains instances of each of the templates it
18628 uses. In a large program, this can lead to an unacceptable amount of code
18629 duplication.
18630 @end enumerate
18631
18632 @node Bound member functions
18633 @section Extracting the function pointer from a bound pointer to member function
18634 @cindex pmf
18635 @cindex pointer to member function
18636 @cindex bound pointer to member function
18637
18638 In C++, pointer to member functions (PMFs) are implemented using a wide
18639 pointer of sorts to handle all the possible call mechanisms; the PMF
18640 needs to store information about how to adjust the @samp{this} pointer,
18641 and if the function pointed to is virtual, where to find the vtable, and
18642 where in the vtable to look for the member function. If you are using
18643 PMFs in an inner loop, you should really reconsider that decision. If
18644 that is not an option, you can extract the pointer to the function that
18645 would be called for a given object/PMF pair and call it directly inside
18646 the inner loop, to save a bit of time.
18647
18648 Note that you still pay the penalty for the call through a
18649 function pointer; on most modern architectures, such a call defeats the
18650 branch prediction features of the CPU@. This is also true of normal
18651 virtual function calls.
18652
18653 The syntax for this extension is
18654
18655 @smallexample
18656 extern A a;
18657 extern int (A::*fp)();
18658 typedef int (*fptr)(A *);
18659
18660 fptr p = (fptr)(a.*fp);
18661 @end smallexample
18662
18663 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
18664 no object is needed to obtain the address of the function. They can be
18665 converted to function pointers directly:
18666
18667 @smallexample
18668 fptr p1 = (fptr)(&A::foo);
18669 @end smallexample
18670
18671 @opindex Wno-pmf-conversions
18672 You must specify @option{-Wno-pmf-conversions} to use this extension.
18673
18674 @node C++ Attributes
18675 @section C++-Specific Variable, Function, and Type Attributes
18676
18677 Some attributes only make sense for C++ programs.
18678
18679 @table @code
18680 @item abi_tag ("@var{tag}", ...)
18681 @cindex @code{abi_tag} attribute
18682 The @code{abi_tag} attribute can be applied to a function or class
18683 declaration. It modifies the mangled name of the function or class to
18684 incorporate the tag name, in order to distinguish the function or
18685 class from an earlier version with a different ABI; perhaps the class
18686 has changed size, or the function has a different return type that is
18687 not encoded in the mangled name.
18688
18689 The argument can be a list of strings of arbitrary length. The
18690 strings are sorted on output, so the order of the list is
18691 unimportant.
18692
18693 A redeclaration of a function or class must not add new ABI tags,
18694 since doing so would change the mangled name.
18695
18696 The ABI tags apply to a name, so all instantiations and
18697 specializations of a template have the same tags. The attribute will
18698 be ignored if applied to an explicit specialization or instantiation.
18699
18700 The @option{-Wabi-tag} flag enables a warning about a class which does
18701 not have all the ABI tags used by its subobjects and virtual functions; for users with code
18702 that needs to coexist with an earlier ABI, using this option can help
18703 to find all affected types that need to be tagged.
18704
18705 @item init_priority (@var{priority})
18706 @cindex @code{init_priority} attribute
18707
18708
18709 In Standard C++, objects defined at namespace scope are guaranteed to be
18710 initialized in an order in strict accordance with that of their definitions
18711 @emph{in a given translation unit}. No guarantee is made for initializations
18712 across translation units. However, GNU C++ allows users to control the
18713 order of initialization of objects defined at namespace scope with the
18714 @code{init_priority} attribute by specifying a relative @var{priority},
18715 a constant integral expression currently bounded between 101 and 65535
18716 inclusive. Lower numbers indicate a higher priority.
18717
18718 In the following example, @code{A} would normally be created before
18719 @code{B}, but the @code{init_priority} attribute reverses that order:
18720
18721 @smallexample
18722 Some_Class A __attribute__ ((init_priority (2000)));
18723 Some_Class B __attribute__ ((init_priority (543)));
18724 @end smallexample
18725
18726 @noindent
18727 Note that the particular values of @var{priority} do not matter; only their
18728 relative ordering.
18729
18730 @item java_interface
18731 @cindex @code{java_interface} attribute
18732
18733 This type attribute informs C++ that the class is a Java interface. It may
18734 only be applied to classes declared within an @code{extern "Java"} block.
18735 Calls to methods declared in this interface are dispatched using GCJ's
18736 interface table mechanism, instead of regular virtual table dispatch.
18737
18738 @item warn_unused
18739 @cindex @code{warn_unused} attribute
18740
18741 For C++ types with non-trivial constructors and/or destructors it is
18742 impossible for the compiler to determine whether a variable of this
18743 type is truly unused if it is not referenced. This type attribute
18744 informs the compiler that variables of this type should be warned
18745 about if they appear to be unused, just like variables of fundamental
18746 types.
18747
18748 This attribute is appropriate for types which just represent a value,
18749 such as @code{std::string}; it is not appropriate for types which
18750 control a resource, such as @code{std::mutex}.
18751
18752 This attribute is also accepted in C, but it is unnecessary because C
18753 does not have constructors or destructors.
18754
18755 @end table
18756
18757 See also @ref{Namespace Association}.
18758
18759 @node Function Multiversioning
18760 @section Function Multiversioning
18761 @cindex function versions
18762
18763 With the GNU C++ front end, for target i386, you may specify multiple
18764 versions of a function, where each function is specialized for a
18765 specific target feature. At runtime, the appropriate version of the
18766 function is automatically executed depending on the characteristics of
18767 the execution platform. Here is an example.
18768
18769 @smallexample
18770 __attribute__ ((target ("default")))
18771 int foo ()
18772 @{
18773 // The default version of foo.
18774 return 0;
18775 @}
18776
18777 __attribute__ ((target ("sse4.2")))
18778 int foo ()
18779 @{
18780 // foo version for SSE4.2
18781 return 1;
18782 @}
18783
18784 __attribute__ ((target ("arch=atom")))
18785 int foo ()
18786 @{
18787 // foo version for the Intel ATOM processor
18788 return 2;
18789 @}
18790
18791 __attribute__ ((target ("arch=amdfam10")))
18792 int foo ()
18793 @{
18794 // foo version for the AMD Family 0x10 processors.
18795 return 3;
18796 @}
18797
18798 int main ()
18799 @{
18800 int (*p)() = &foo;
18801 assert ((*p) () == foo ());
18802 return 0;
18803 @}
18804 @end smallexample
18805
18806 In the above example, four versions of function foo are created. The
18807 first version of foo with the target attribute "default" is the default
18808 version. This version gets executed when no other target specific
18809 version qualifies for execution on a particular platform. A new version
18810 of foo is created by using the same function signature but with a
18811 different target string. Function foo is called or a pointer to it is
18812 taken just like a regular function. GCC takes care of doing the
18813 dispatching to call the right version at runtime. Refer to the
18814 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
18815 Function Multiversioning} for more details.
18816
18817 @node Namespace Association
18818 @section Namespace Association
18819
18820 @strong{Caution:} The semantics of this extension are equivalent
18821 to C++ 2011 inline namespaces. Users should use inline namespaces
18822 instead as this extension will be removed in future versions of G++.
18823
18824 A using-directive with @code{__attribute ((strong))} is stronger
18825 than a normal using-directive in two ways:
18826
18827 @itemize @bullet
18828 @item
18829 Templates from the used namespace can be specialized and explicitly
18830 instantiated as though they were members of the using namespace.
18831
18832 @item
18833 The using namespace is considered an associated namespace of all
18834 templates in the used namespace for purposes of argument-dependent
18835 name lookup.
18836 @end itemize
18837
18838 The used namespace must be nested within the using namespace so that
18839 normal unqualified lookup works properly.
18840
18841 This is useful for composing a namespace transparently from
18842 implementation namespaces. For example:
18843
18844 @smallexample
18845 namespace std @{
18846 namespace debug @{
18847 template <class T> struct A @{ @};
18848 @}
18849 using namespace debug __attribute ((__strong__));
18850 template <> struct A<int> @{ @}; // @r{OK to specialize}
18851
18852 template <class T> void f (A<T>);
18853 @}
18854
18855 int main()
18856 @{
18857 f (std::A<float>()); // @r{lookup finds} std::f
18858 f (std::A<int>());
18859 @}
18860 @end smallexample
18861
18862 @node Type Traits
18863 @section Type Traits
18864
18865 The C++ front end implements syntactic extensions that allow
18866 compile-time determination of
18867 various characteristics of a type (or of a
18868 pair of types).
18869
18870 @table @code
18871 @item __has_nothrow_assign (type)
18872 If @code{type} is const qualified or is a reference type then the trait is
18873 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
18874 is true, else if @code{type} is a cv class or union type with copy assignment
18875 operators that are known not to throw an exception then the trait is true,
18876 else it is false. Requires: @code{type} shall be a complete type,
18877 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18878
18879 @item __has_nothrow_copy (type)
18880 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
18881 @code{type} is a cv class or union type with copy constructors that
18882 are known not to throw an exception then the trait is true, else it is false.
18883 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
18884 @code{void}, or an array of unknown bound.
18885
18886 @item __has_nothrow_constructor (type)
18887 If @code{__has_trivial_constructor (type)} is true then the trait is
18888 true, else if @code{type} is a cv class or union type (or array
18889 thereof) with a default constructor that is known not to throw an
18890 exception then the trait is true, else it is false. Requires:
18891 @code{type} shall be a complete type, (possibly cv-qualified)
18892 @code{void}, or an array of unknown bound.
18893
18894 @item __has_trivial_assign (type)
18895 If @code{type} is const qualified or is a reference type then the trait is
18896 false. Otherwise if @code{__is_pod (type)} is true then the trait is
18897 true, else if @code{type} is a cv class or union type with a trivial
18898 copy assignment ([class.copy]) then the trait is true, else it is
18899 false. Requires: @code{type} shall be a complete type, (possibly
18900 cv-qualified) @code{void}, or an array of unknown bound.
18901
18902 @item __has_trivial_copy (type)
18903 If @code{__is_pod (type)} is true or @code{type} is a reference type
18904 then the trait is true, else if @code{type} is a cv class or union type
18905 with a trivial copy constructor ([class.copy]) then the trait
18906 is true, else it is false. Requires: @code{type} shall be a complete
18907 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18908
18909 @item __has_trivial_constructor (type)
18910 If @code{__is_pod (type)} is true then the trait is true, else if
18911 @code{type} is a cv class or union type (or array thereof) with a
18912 trivial default constructor ([class.ctor]) then the trait is true,
18913 else it is false. Requires: @code{type} shall be a complete
18914 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18915
18916 @item __has_trivial_destructor (type)
18917 If @code{__is_pod (type)} is true or @code{type} is a reference type then
18918 the trait is true, else if @code{type} is a cv class or union type (or
18919 array thereof) with a trivial destructor ([class.dtor]) then the trait
18920 is true, else it is false. Requires: @code{type} shall be a complete
18921 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18922
18923 @item __has_virtual_destructor (type)
18924 If @code{type} is a class type with a virtual destructor
18925 ([class.dtor]) then the trait is true, else it is false. Requires:
18926 @code{type} shall be a complete type, (possibly cv-qualified)
18927 @code{void}, or an array of unknown bound.
18928
18929 @item __is_abstract (type)
18930 If @code{type} is an abstract class ([class.abstract]) then the trait
18931 is true, else it is false. Requires: @code{type} shall be a complete
18932 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18933
18934 @item __is_base_of (base_type, derived_type)
18935 If @code{base_type} is a base class of @code{derived_type}
18936 ([class.derived]) then the trait is true, otherwise it is false.
18937 Top-level cv qualifications of @code{base_type} and
18938 @code{derived_type} are ignored. For the purposes of this trait, a
18939 class type is considered is own base. Requires: if @code{__is_class
18940 (base_type)} and @code{__is_class (derived_type)} are true and
18941 @code{base_type} and @code{derived_type} are not the same type
18942 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
18943 type. Diagnostic is produced if this requirement is not met.
18944
18945 @item __is_class (type)
18946 If @code{type} is a cv class type, and not a union type
18947 ([basic.compound]) the trait is true, else it is false.
18948
18949 @item __is_empty (type)
18950 If @code{__is_class (type)} is false then the trait is false.
18951 Otherwise @code{type} is considered empty if and only if: @code{type}
18952 has no non-static data members, or all non-static data members, if
18953 any, are bit-fields of length 0, and @code{type} has no virtual
18954 members, and @code{type} has no virtual base classes, and @code{type}
18955 has no base classes @code{base_type} for which
18956 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
18957 be a complete type, (possibly cv-qualified) @code{void}, or an array
18958 of unknown bound.
18959
18960 @item __is_enum (type)
18961 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
18962 true, else it is false.
18963
18964 @item __is_literal_type (type)
18965 If @code{type} is a literal type ([basic.types]) the trait is
18966 true, else it is false. Requires: @code{type} shall be a complete type,
18967 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18968
18969 @item __is_pod (type)
18970 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
18971 else it is false. Requires: @code{type} shall be a complete type,
18972 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18973
18974 @item __is_polymorphic (type)
18975 If @code{type} is a polymorphic class ([class.virtual]) then the trait
18976 is true, else it is false. Requires: @code{type} shall be a complete
18977 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18978
18979 @item __is_standard_layout (type)
18980 If @code{type} is a standard-layout type ([basic.types]) the trait is
18981 true, else it is false. Requires: @code{type} shall be a complete
18982 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18983
18984 @item __is_trivial (type)
18985 If @code{type} is a trivial type ([basic.types]) the trait is
18986 true, else it is false. Requires: @code{type} shall be a complete
18987 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18988
18989 @item __is_union (type)
18990 If @code{type} is a cv union type ([basic.compound]) the trait is
18991 true, else it is false.
18992
18993 @item __underlying_type (type)
18994 The underlying type of @code{type}. Requires: @code{type} shall be
18995 an enumeration type ([dcl.enum]).
18996
18997 @end table
18998
18999 @node Java Exceptions
19000 @section Java Exceptions
19001
19002 The Java language uses a slightly different exception handling model
19003 from C++. Normally, GNU C++ automatically detects when you are
19004 writing C++ code that uses Java exceptions, and handle them
19005 appropriately. However, if C++ code only needs to execute destructors
19006 when Java exceptions are thrown through it, GCC guesses incorrectly.
19007 Sample problematic code is:
19008
19009 @smallexample
19010 struct S @{ ~S(); @};
19011 extern void bar(); // @r{is written in Java, and may throw exceptions}
19012 void foo()
19013 @{
19014 S s;
19015 bar();
19016 @}
19017 @end smallexample
19018
19019 @noindent
19020 The usual effect of an incorrect guess is a link failure, complaining of
19021 a missing routine called @samp{__gxx_personality_v0}.
19022
19023 You can inform the compiler that Java exceptions are to be used in a
19024 translation unit, irrespective of what it might think, by writing
19025 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
19026 @samp{#pragma} must appear before any functions that throw or catch
19027 exceptions, or run destructors when exceptions are thrown through them.
19028
19029 You cannot mix Java and C++ exceptions in the same translation unit. It
19030 is believed to be safe to throw a C++ exception from one file through
19031 another file compiled for the Java exception model, or vice versa, but
19032 there may be bugs in this area.
19033
19034 @node Deprecated Features
19035 @section Deprecated Features
19036
19037 In the past, the GNU C++ compiler was extended to experiment with new
19038 features, at a time when the C++ language was still evolving. Now that
19039 the C++ standard is complete, some of those features are superseded by
19040 superior alternatives. Using the old features might cause a warning in
19041 some cases that the feature will be dropped in the future. In other
19042 cases, the feature might be gone already.
19043
19044 While the list below is not exhaustive, it documents some of the options
19045 that are now deprecated:
19046
19047 @table @code
19048 @item -fexternal-templates
19049 @itemx -falt-external-templates
19050 These are two of the many ways for G++ to implement template
19051 instantiation. @xref{Template Instantiation}. The C++ standard clearly
19052 defines how template definitions have to be organized across
19053 implementation units. G++ has an implicit instantiation mechanism that
19054 should work just fine for standard-conforming code.
19055
19056 @item -fstrict-prototype
19057 @itemx -fno-strict-prototype
19058 Previously it was possible to use an empty prototype parameter list to
19059 indicate an unspecified number of parameters (like C), rather than no
19060 parameters, as C++ demands. This feature has been removed, except where
19061 it is required for backwards compatibility. @xref{Backwards Compatibility}.
19062 @end table
19063
19064 G++ allows a virtual function returning @samp{void *} to be overridden
19065 by one returning a different pointer type. This extension to the
19066 covariant return type rules is now deprecated and will be removed from a
19067 future version.
19068
19069 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
19070 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
19071 and are now removed from G++. Code using these operators should be
19072 modified to use @code{std::min} and @code{std::max} instead.
19073
19074 The named return value extension has been deprecated, and is now
19075 removed from G++.
19076
19077 The use of initializer lists with new expressions has been deprecated,
19078 and is now removed from G++.
19079
19080 Floating and complex non-type template parameters have been deprecated,
19081 and are now removed from G++.
19082
19083 The implicit typename extension has been deprecated and is now
19084 removed from G++.
19085
19086 The use of default arguments in function pointers, function typedefs
19087 and other places where they are not permitted by the standard is
19088 deprecated and will be removed from a future version of G++.
19089
19090 G++ allows floating-point literals to appear in integral constant expressions,
19091 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
19092 This extension is deprecated and will be removed from a future version.
19093
19094 G++ allows static data members of const floating-point type to be declared
19095 with an initializer in a class definition. The standard only allows
19096 initializers for static members of const integral types and const
19097 enumeration types so this extension has been deprecated and will be removed
19098 from a future version.
19099
19100 @node Backwards Compatibility
19101 @section Backwards Compatibility
19102 @cindex Backwards Compatibility
19103 @cindex ARM [Annotated C++ Reference Manual]
19104
19105 Now that there is a definitive ISO standard C++, G++ has a specification
19106 to adhere to. The C++ language evolved over time, and features that
19107 used to be acceptable in previous drafts of the standard, such as the ARM
19108 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
19109 compilation of C++ written to such drafts, G++ contains some backwards
19110 compatibilities. @emph{All such backwards compatibility features are
19111 liable to disappear in future versions of G++.} They should be considered
19112 deprecated. @xref{Deprecated Features}.
19113
19114 @table @code
19115 @item For scope
19116 If a variable is declared at for scope, it used to remain in scope until
19117 the end of the scope that contained the for statement (rather than just
19118 within the for scope). G++ retains this, but issues a warning, if such a
19119 variable is accessed outside the for scope.
19120
19121 @item Implicit C language
19122 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
19123 scope to set the language. On such systems, all header files are
19124 implicitly scoped inside a C language scope. Also, an empty prototype
19125 @code{()} is treated as an unspecified number of arguments, rather
19126 than no arguments, as C++ demands.
19127 @end table
19128
19129 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
19130 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr followign