]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/extend.texi
re PR target/61044 (Computed goto on AVR fails to use word-addressing)
[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 * x86 specific memory model extensions for transactional memory:: x86 memory models.
80 * Object Size Checking:: Built-in functions for limited buffer overflow
81 checking.
82 * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
83 * Other Builtins:: Other built-in functions.
84 * Target Builtins:: Built-in functions specific to particular targets.
85 * Target Format Checks:: Format checks specific to particular targets.
86 * Pragmas:: Pragmas accepted by GCC.
87 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
88 * Thread-Local:: Per-thread variables.
89 * Binary constants:: Binary constants using the @samp{0b} prefix.
90 @end menu
91
92 @node Statement Exprs
93 @section Statements and Declarations in Expressions
94 @cindex statements inside expressions
95 @cindex declarations inside expressions
96 @cindex expressions containing statements
97 @cindex macros, statements in expressions
98
99 @c the above section title wrapped and causes an underfull hbox.. i
100 @c changed it from "within" to "in". --mew 4feb93
101 A compound statement enclosed in parentheses may appear as an expression
102 in GNU C@. This allows you to use loops, switches, and local variables
103 within an expression.
104
105 Recall that a compound statement is a sequence of statements surrounded
106 by braces; in this construct, parentheses go around the braces. For
107 example:
108
109 @smallexample
110 (@{ int y = foo (); int z;
111 if (y > 0) z = y;
112 else z = - y;
113 z; @})
114 @end smallexample
115
116 @noindent
117 is a valid (though slightly more complex than necessary) expression
118 for the absolute value of @code{foo ()}.
119
120 The last thing in the compound statement should be an expression
121 followed by a semicolon; the value of this subexpression serves as the
122 value of the entire construct. (If you use some other kind of statement
123 last within the braces, the construct has type @code{void}, and thus
124 effectively no value.)
125
126 This feature is especially useful in making macro definitions ``safe'' (so
127 that they evaluate each operand exactly once). For example, the
128 ``maximum'' function is commonly defined as a macro in standard C as
129 follows:
130
131 @smallexample
132 #define max(a,b) ((a) > (b) ? (a) : (b))
133 @end smallexample
134
135 @noindent
136 @cindex side effects, macro argument
137 But this definition computes either @var{a} or @var{b} twice, with bad
138 results if the operand has side effects. In GNU C, if you know the
139 type of the operands (here taken as @code{int}), you can define
140 the macro safely as follows:
141
142 @smallexample
143 #define maxint(a,b) \
144 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
145 @end smallexample
146
147 Embedded statements are not allowed in constant expressions, such as
148 the value of an enumeration constant, the width of a bit-field, or
149 the initial value of a static variable.
150
151 If you don't know the type of the operand, you can still do this, but you
152 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
153
154 In G++, the result value of a statement expression undergoes array and
155 function pointer decay, and is returned by value to the enclosing
156 expression. For instance, if @code{A} is a class, then
157
158 @smallexample
159 A a;
160
161 (@{a;@}).Foo ()
162 @end smallexample
163
164 @noindent
165 constructs a temporary @code{A} object to hold the result of the
166 statement expression, and that is used to invoke @code{Foo}.
167 Therefore the @code{this} pointer observed by @code{Foo} is not the
168 address of @code{a}.
169
170 In a statement expression, any temporaries created within a statement
171 are destroyed at that statement's end. This makes statement
172 expressions inside macros slightly different from function calls. In
173 the latter case temporaries introduced during argument evaluation are
174 destroyed at the end of the statement that includes the function
175 call. In the statement expression case they are destroyed during
176 the statement expression. For instance,
177
178 @smallexample
179 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
180 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
181
182 void foo ()
183 @{
184 macro (X ());
185 function (X ());
186 @}
187 @end smallexample
188
189 @noindent
190 has different places where temporaries are destroyed. For the
191 @code{macro} case, the temporary @code{X} is destroyed just after
192 the initialization of @code{b}. In the @code{function} case that
193 temporary is destroyed when the function returns.
194
195 These considerations mean that it is probably a bad idea to use
196 statement expressions of this form in header files that are designed to
197 work with C++. (Note that some versions of the GNU C Library contained
198 header files using statement expressions that lead to precisely this
199 bug.)
200
201 Jumping into a statement expression with @code{goto} or using a
202 @code{switch} statement outside the statement expression with a
203 @code{case} or @code{default} label inside the statement expression is
204 not permitted. Jumping into a statement expression with a computed
205 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
206 Jumping out of a statement expression is permitted, but if the
207 statement expression is part of a larger expression then it is
208 unspecified which other subexpressions of that expression have been
209 evaluated except where the language definition requires certain
210 subexpressions to be evaluated before or after the statement
211 expression. In any case, as with a function call, the evaluation of a
212 statement expression is not interleaved with the evaluation of other
213 parts of the containing expression. For example,
214
215 @smallexample
216 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
217 @end smallexample
218
219 @noindent
220 calls @code{foo} and @code{bar1} and does not call @code{baz} but
221 may or may not call @code{bar2}. If @code{bar2} is called, it is
222 called after @code{foo} and before @code{bar1}.
223
224 @node Local Labels
225 @section Locally Declared Labels
226 @cindex local labels
227 @cindex macros, local labels
228
229 GCC allows you to declare @dfn{local labels} in any nested block
230 scope. A local label is just like an ordinary label, but you can
231 only reference it (with a @code{goto} statement, or by taking its
232 address) within the block in which it is declared.
233
234 A local label declaration looks like this:
235
236 @smallexample
237 __label__ @var{label};
238 @end smallexample
239
240 @noindent
241 or
242
243 @smallexample
244 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
245 @end smallexample
246
247 Local label declarations must come at the beginning of the block,
248 before any ordinary declarations or statements.
249
250 The label declaration defines the label @emph{name}, but does not define
251 the label itself. You must do this in the usual way, with
252 @code{@var{label}:}, within the statements of the statement expression.
253
254 The local label feature is useful for complex macros. If a macro
255 contains nested loops, a @code{goto} can be useful for breaking out of
256 them. However, an ordinary label whose scope is the whole function
257 cannot be used: if the macro can be expanded several times in one
258 function, the label is multiply defined in that function. A
259 local label avoids this problem. For example:
260
261 @smallexample
262 #define SEARCH(value, array, target) \
263 do @{ \
264 __label__ found; \
265 typeof (target) _SEARCH_target = (target); \
266 typeof (*(array)) *_SEARCH_array = (array); \
267 int i, j; \
268 int value; \
269 for (i = 0; i < max; i++) \
270 for (j = 0; j < max; j++) \
271 if (_SEARCH_array[i][j] == _SEARCH_target) \
272 @{ (value) = i; goto found; @} \
273 (value) = -1; \
274 found:; \
275 @} while (0)
276 @end smallexample
277
278 This could also be written using a statement expression:
279
280 @smallexample
281 #define SEARCH(array, target) \
282 (@{ \
283 __label__ found; \
284 typeof (target) _SEARCH_target = (target); \
285 typeof (*(array)) *_SEARCH_array = (array); \
286 int i, j; \
287 int value; \
288 for (i = 0; i < max; i++) \
289 for (j = 0; j < max; j++) \
290 if (_SEARCH_array[i][j] == _SEARCH_target) \
291 @{ value = i; goto found; @} \
292 value = -1; \
293 found: \
294 value; \
295 @})
296 @end smallexample
297
298 Local label declarations also make the labels they declare visible to
299 nested functions, if there are any. @xref{Nested Functions}, for details.
300
301 @node Labels as Values
302 @section Labels as Values
303 @cindex labels as values
304 @cindex computed gotos
305 @cindex goto with computed label
306 @cindex address of a label
307
308 You can get the address of a label defined in the current function
309 (or a containing function) with the unary operator @samp{&&}. The
310 value has type @code{void *}. This value is a constant and can be used
311 wherever a constant of that type is valid. For example:
312
313 @smallexample
314 void *ptr;
315 /* @r{@dots{}} */
316 ptr = &&foo;
317 @end smallexample
318
319 To use these values, you need to be able to jump to one. This is done
320 with the computed goto statement@footnote{The analogous feature in
321 Fortran is called an assigned goto, but that name seems inappropriate in
322 C, where one can do more than simply store label addresses in label
323 variables.}, @code{goto *@var{exp};}. For example,
324
325 @smallexample
326 goto *ptr;
327 @end smallexample
328
329 @noindent
330 Any expression of type @code{void *} is allowed.
331
332 One way of using these constants is in initializing a static array that
333 serves as a jump table:
334
335 @smallexample
336 static void *array[] = @{ &&foo, &&bar, &&hack @};
337 @end smallexample
338
339 @noindent
340 Then you can select a label with indexing, like this:
341
342 @smallexample
343 goto *array[i];
344 @end smallexample
345
346 @noindent
347 Note that this does not check whether the subscript is in bounds---array
348 indexing in C never does that.
349
350 Such an array of label values serves a purpose much like that of the
351 @code{switch} statement. The @code{switch} statement is cleaner, so
352 use that rather than an array unless the problem does not fit a
353 @code{switch} statement very well.
354
355 Another use of label values is in an interpreter for threaded code.
356 The labels within the interpreter function can be stored in the
357 threaded code for super-fast dispatching.
358
359 You may not use this mechanism to jump to code in a different function.
360 If you do that, totally unpredictable things happen. The best way to
361 avoid this is to store the label address only in automatic variables and
362 never pass it as an argument.
363
364 An alternate way to write the above example is
365
366 @smallexample
367 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
368 &&hack - &&foo @};
369 goto *(&&foo + array[i]);
370 @end smallexample
371
372 @noindent
373 This is more friendly to code living in shared libraries, as it reduces
374 the number of dynamic relocations that are needed, and by consequence,
375 allows the data to be read-only.
376 This alternative with label differences is not supported for the AVR target,
377 please use the first approach for AVR programs.
378
379 The @code{&&foo} expressions for the same label might have different
380 values if the containing function is inlined or cloned. If a program
381 relies on them being always the same,
382 @code{__attribute__((__noinline__,__noclone__))} should be used to
383 prevent inlining and cloning. If @code{&&foo} is used in a static
384 variable initializer, inlining and cloning is forbidden.
385
386 @node Nested Functions
387 @section Nested Functions
388 @cindex nested functions
389 @cindex downward funargs
390 @cindex thunks
391
392 A @dfn{nested function} is a function defined inside another function.
393 Nested functions are supported as an extension in GNU C, but are not
394 supported by GNU C++.
395
396 The nested function's name is local to the block where it is defined.
397 For example, here we define a nested function named @code{square}, and
398 call it twice:
399
400 @smallexample
401 @group
402 foo (double a, double b)
403 @{
404 double square (double z) @{ return z * z; @}
405
406 return square (a) + square (b);
407 @}
408 @end group
409 @end smallexample
410
411 The nested function can access all the variables of the containing
412 function that are visible at the point of its definition. This is
413 called @dfn{lexical scoping}. For example, here we show a nested
414 function which uses an inherited variable named @code{offset}:
415
416 @smallexample
417 @group
418 bar (int *array, int offset, int size)
419 @{
420 int access (int *array, int index)
421 @{ return array[index + offset]; @}
422 int i;
423 /* @r{@dots{}} */
424 for (i = 0; i < size; i++)
425 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
426 @}
427 @end group
428 @end smallexample
429
430 Nested function definitions are permitted within functions in the places
431 where variable definitions are allowed; that is, in any block, mixed
432 with the other declarations and statements in the block.
433
434 It is possible to call the nested function from outside the scope of its
435 name by storing its address or passing the address to another function:
436
437 @smallexample
438 hack (int *array, int size)
439 @{
440 void store (int index, int value)
441 @{ array[index] = value; @}
442
443 intermediate (store, size);
444 @}
445 @end smallexample
446
447 Here, the function @code{intermediate} receives the address of
448 @code{store} as an argument. If @code{intermediate} calls @code{store},
449 the arguments given to @code{store} are used to store into @code{array}.
450 But this technique works only so long as the containing function
451 (@code{hack}, in this example) does not exit.
452
453 If you try to call the nested function through its address after the
454 containing function exits, all hell breaks loose. If you try
455 to call it after a containing scope level exits, and if it refers
456 to some of the variables that are no longer in scope, you may be lucky,
457 but it's not wise to take the risk. If, however, the nested function
458 does not refer to anything that has gone out of scope, you should be
459 safe.
460
461 GCC implements taking the address of a nested function using a technique
462 called @dfn{trampolines}. This technique was described in
463 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
464 C++ Conference Proceedings, October 17-21, 1988).
465
466 A nested function can jump to a label inherited from a containing
467 function, provided the label is explicitly declared in the containing
468 function (@pxref{Local Labels}). Such a jump returns instantly to the
469 containing function, exiting the nested function that did the
470 @code{goto} and any intermediate functions as well. Here is an example:
471
472 @smallexample
473 @group
474 bar (int *array, int offset, int size)
475 @{
476 __label__ failure;
477 int access (int *array, int index)
478 @{
479 if (index > size)
480 goto failure;
481 return array[index + offset];
482 @}
483 int i;
484 /* @r{@dots{}} */
485 for (i = 0; i < size; i++)
486 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
487 /* @r{@dots{}} */
488 return 0;
489
490 /* @r{Control comes here from @code{access}
491 if it detects an error.} */
492 failure:
493 return -1;
494 @}
495 @end group
496 @end smallexample
497
498 A nested function always has no linkage. Declaring one with
499 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
500 before its definition, use @code{auto} (which is otherwise meaningless
501 for function declarations).
502
503 @smallexample
504 bar (int *array, int offset, int size)
505 @{
506 __label__ failure;
507 auto int access (int *, int);
508 /* @r{@dots{}} */
509 int access (int *array, int index)
510 @{
511 if (index > size)
512 goto failure;
513 return array[index + offset];
514 @}
515 /* @r{@dots{}} */
516 @}
517 @end smallexample
518
519 @node Constructing Calls
520 @section Constructing Function Calls
521 @cindex constructing calls
522 @cindex forwarding calls
523
524 Using the built-in functions described below, you can record
525 the arguments a function received, and call another function
526 with the same arguments, without knowing the number or types
527 of the arguments.
528
529 You can also record the return value of that function call,
530 and later return that value, without knowing what data type
531 the function tried to return (as long as your caller expects
532 that data type).
533
534 However, these built-in functions may interact badly with some
535 sophisticated features or other extensions of the language. It
536 is, therefore, not recommended to use them outside very simple
537 functions acting as mere forwarders for their arguments.
538
539 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
540 This built-in function returns a pointer to data
541 describing how to perform a call with the same arguments as are passed
542 to the current function.
543
544 The function saves the arg pointer register, structure value address,
545 and all registers that might be used to pass arguments to a function
546 into a block of memory allocated on the stack. Then it returns the
547 address of that block.
548 @end deftypefn
549
550 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
551 This built-in function invokes @var{function}
552 with a copy of the parameters described by @var{arguments}
553 and @var{size}.
554
555 The value of @var{arguments} should be the value returned by
556 @code{__builtin_apply_args}. The argument @var{size} specifies the size
557 of the stack argument data, in bytes.
558
559 This function returns a pointer to data describing
560 how to return whatever value is returned by @var{function}. The data
561 is saved in a block of memory allocated on the stack.
562
563 It is not always simple to compute the proper value for @var{size}. The
564 value is used by @code{__builtin_apply} to compute the amount of data
565 that should be pushed on the stack and copied from the incoming argument
566 area.
567 @end deftypefn
568
569 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
570 This built-in function returns the value described by @var{result} from
571 the containing function. You should specify, for @var{result}, a value
572 returned by @code{__builtin_apply}.
573 @end deftypefn
574
575 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
576 This built-in function represents all anonymous arguments of an inline
577 function. It can be used only in inline functions that are always
578 inlined, never compiled as a separate function, such as those using
579 @code{__attribute__ ((__always_inline__))} or
580 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
581 It must be only passed as last argument to some other function
582 with variable arguments. This is useful for writing small wrapper
583 inlines for variable argument functions, when using preprocessor
584 macros is undesirable. For example:
585 @smallexample
586 extern int myprintf (FILE *f, const char *format, ...);
587 extern inline __attribute__ ((__gnu_inline__)) int
588 myprintf (FILE *f, const char *format, ...)
589 @{
590 int r = fprintf (f, "myprintf: ");
591 if (r < 0)
592 return r;
593 int s = fprintf (f, format, __builtin_va_arg_pack ());
594 if (s < 0)
595 return s;
596 return r + s;
597 @}
598 @end smallexample
599 @end deftypefn
600
601 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
602 This built-in function returns the number of anonymous arguments of
603 an inline function. It can be used only in inline functions that
604 are always inlined, never compiled as a separate function, such
605 as those using @code{__attribute__ ((__always_inline__))} or
606 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
607 For example following does link- or run-time checking of open
608 arguments for optimized code:
609 @smallexample
610 #ifdef __OPTIMIZE__
611 extern inline __attribute__((__gnu_inline__)) int
612 myopen (const char *path, int oflag, ...)
613 @{
614 if (__builtin_va_arg_pack_len () > 1)
615 warn_open_too_many_arguments ();
616
617 if (__builtin_constant_p (oflag))
618 @{
619 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
620 @{
621 warn_open_missing_mode ();
622 return __open_2 (path, oflag);
623 @}
624 return open (path, oflag, __builtin_va_arg_pack ());
625 @}
626
627 if (__builtin_va_arg_pack_len () < 1)
628 return __open_2 (path, oflag);
629
630 return open (path, oflag, __builtin_va_arg_pack ());
631 @}
632 #endif
633 @end smallexample
634 @end deftypefn
635
636 @node Typeof
637 @section Referring to a Type with @code{typeof}
638 @findex typeof
639 @findex sizeof
640 @cindex macros, types of arguments
641
642 Another way to refer to the type of an expression is with @code{typeof}.
643 The syntax of using of this keyword looks like @code{sizeof}, but the
644 construct acts semantically like a type name defined with @code{typedef}.
645
646 There are two ways of writing the argument to @code{typeof}: with an
647 expression or with a type. Here is an example with an expression:
648
649 @smallexample
650 typeof (x[0](1))
651 @end smallexample
652
653 @noindent
654 This assumes that @code{x} is an array of pointers to functions;
655 the type described is that of the values of the functions.
656
657 Here is an example with a typename as the argument:
658
659 @smallexample
660 typeof (int *)
661 @end smallexample
662
663 @noindent
664 Here the type described is that of pointers to @code{int}.
665
666 If you are writing a header file that must work when included in ISO C
667 programs, write @code{__typeof__} instead of @code{typeof}.
668 @xref{Alternate Keywords}.
669
670 A @code{typeof} construct can be used anywhere a typedef name can be
671 used. For example, you can use it in a declaration, in a cast, or inside
672 of @code{sizeof} or @code{typeof}.
673
674 The operand of @code{typeof} is evaluated for its side effects if and
675 only if it is an expression of variably modified type or the name of
676 such a type.
677
678 @code{typeof} is often useful in conjunction with
679 statement expressions (@pxref{Statement Exprs}).
680 Here is how the two together can
681 be used to define a safe ``maximum'' macro which operates on any
682 arithmetic type and evaluates each of its arguments exactly once:
683
684 @smallexample
685 #define max(a,b) \
686 (@{ typeof (a) _a = (a); \
687 typeof (b) _b = (b); \
688 _a > _b ? _a : _b; @})
689 @end smallexample
690
691 @cindex underscores in variables in macros
692 @cindex @samp{_} in variables in macros
693 @cindex local variables in macros
694 @cindex variables, local, in macros
695 @cindex macros, local variables in
696
697 The reason for using names that start with underscores for the local
698 variables is to avoid conflicts with variable names that occur within the
699 expressions that are substituted for @code{a} and @code{b}. Eventually we
700 hope to design a new form of declaration syntax that allows you to declare
701 variables whose scopes start only after their initializers; this will be a
702 more reliable way to prevent such conflicts.
703
704 @noindent
705 Some more examples of the use of @code{typeof}:
706
707 @itemize @bullet
708 @item
709 This declares @code{y} with the type of what @code{x} points to.
710
711 @smallexample
712 typeof (*x) y;
713 @end smallexample
714
715 @item
716 This declares @code{y} as an array of such values.
717
718 @smallexample
719 typeof (*x) y[4];
720 @end smallexample
721
722 @item
723 This declares @code{y} as an array of pointers to characters:
724
725 @smallexample
726 typeof (typeof (char *)[4]) y;
727 @end smallexample
728
729 @noindent
730 It is equivalent to the following traditional C declaration:
731
732 @smallexample
733 char *y[4];
734 @end smallexample
735
736 To see the meaning of the declaration using @code{typeof}, and why it
737 might be a useful way to write, rewrite it with these macros:
738
739 @smallexample
740 #define pointer(T) typeof(T *)
741 #define array(T, N) typeof(T [N])
742 @end smallexample
743
744 @noindent
745 Now the declaration can be rewritten this way:
746
747 @smallexample
748 array (pointer (char), 4) y;
749 @end smallexample
750
751 @noindent
752 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
753 pointers to @code{char}.
754 @end itemize
755
756 In GNU C, but not GNU C++, you may also declare the type of a variable
757 as @code{__auto_type}. In that case, the declaration must declare
758 only one variable, whose declarator must just be an identifier, the
759 declaration must be initialized, and the type of the variable is
760 determined by the initializer; the name of the variable is not in
761 scope until after the initializer. (In C++, you should use C++11
762 @code{auto} for this purpose.) Using @code{__auto_type}, the
763 ``maximum'' macro above could be written as:
764
765 @smallexample
766 #define max(a,b) \
767 (@{ __auto_type _a = (a); \
768 __auto_type _b = (b); \
769 _a > _b ? _a : _b; @})
770 @end smallexample
771
772 Using @code{__auto_type} instead of @code{typeof} has two advantages:
773
774 @itemize @bullet
775 @item Each argument to the macro appears only once in the expansion of
776 the macro. This prevents the size of the macro expansion growing
777 exponentially when calls to such macros are nested inside arguments of
778 such macros.
779
780 @item If the argument to the macro has variably modified type, it is
781 evaluated only once when using @code{__auto_type}, but twice if
782 @code{typeof} is used.
783 @end itemize
784
785 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
786 a more limited extension that permitted one to write
787
788 @smallexample
789 typedef @var{T} = @var{expr};
790 @end smallexample
791
792 @noindent
793 with the effect of declaring @var{T} to have the type of the expression
794 @var{expr}. This extension does not work with GCC 3 (versions between
795 3.0 and 3.2 crash; 3.2.1 and later give an error). Code that
796 relies on it should be rewritten to use @code{typeof}:
797
798 @smallexample
799 typedef typeof(@var{expr}) @var{T};
800 @end smallexample
801
802 @noindent
803 This works with all versions of GCC@.
804
805 @node Conditionals
806 @section Conditionals with Omitted Operands
807 @cindex conditional expressions, extensions
808 @cindex omitted middle-operands
809 @cindex middle-operands, omitted
810 @cindex extensions, @code{?:}
811 @cindex @code{?:} extensions
812
813 The middle operand in a conditional expression may be omitted. Then
814 if the first operand is nonzero, its value is the value of the conditional
815 expression.
816
817 Therefore, the expression
818
819 @smallexample
820 x ? : y
821 @end smallexample
822
823 @noindent
824 has the value of @code{x} if that is nonzero; otherwise, the value of
825 @code{y}.
826
827 This example is perfectly equivalent to
828
829 @smallexample
830 x ? x : y
831 @end smallexample
832
833 @cindex side effect in @code{?:}
834 @cindex @code{?:} side effect
835 @noindent
836 In this simple case, the ability to omit the middle operand is not
837 especially useful. When it becomes useful is when the first operand does,
838 or may (if it is a macro argument), contain a side effect. Then repeating
839 the operand in the middle would perform the side effect twice. Omitting
840 the middle operand uses the value already computed without the undesirable
841 effects of recomputing it.
842
843 @node __int128
844 @section 128-bit integers
845 @cindex @code{__int128} data types
846
847 As an extension the integer scalar type @code{__int128} is supported for
848 targets which have an integer mode wide enough to hold 128 bits.
849 Simply write @code{__int128} for a signed 128-bit integer, or
850 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
851 support in GCC for expressing an integer constant of type @code{__int128}
852 for targets with @code{long long} integer less than 128 bits wide.
853
854 @node Long Long
855 @section Double-Word Integers
856 @cindex @code{long long} data types
857 @cindex double-word arithmetic
858 @cindex multiprecision arithmetic
859 @cindex @code{LL} integer suffix
860 @cindex @code{ULL} integer suffix
861
862 ISO C99 supports data types for integers that are at least 64 bits wide,
863 and as an extension GCC supports them in C90 mode and in C++.
864 Simply write @code{long long int} for a signed integer, or
865 @code{unsigned long long int} for an unsigned integer. To make an
866 integer constant of type @code{long long int}, add the suffix @samp{LL}
867 to the integer. To make an integer constant of type @code{unsigned long
868 long int}, add the suffix @samp{ULL} to the integer.
869
870 You can use these types in arithmetic like any other integer types.
871 Addition, subtraction, and bitwise boolean operations on these types
872 are open-coded on all types of machines. Multiplication is open-coded
873 if the machine supports a fullword-to-doubleword widening multiply
874 instruction. Division and shifts are open-coded only on machines that
875 provide special support. The operations that are not open-coded use
876 special library routines that come with GCC@.
877
878 There may be pitfalls when you use @code{long long} types for function
879 arguments without function prototypes. If a function
880 expects type @code{int} for its argument, and you pass a value of type
881 @code{long long int}, confusion results because the caller and the
882 subroutine disagree about the number of bytes for the argument.
883 Likewise, if the function expects @code{long long int} and you pass
884 @code{int}. The best way to avoid such problems is to use prototypes.
885
886 @node Complex
887 @section Complex Numbers
888 @cindex complex numbers
889 @cindex @code{_Complex} keyword
890 @cindex @code{__complex__} keyword
891
892 ISO C99 supports complex floating data types, and as an extension GCC
893 supports them in C90 mode and in C++. GCC also supports complex integer data
894 types which are not part of ISO C99. You can declare complex types
895 using the keyword @code{_Complex}. As an extension, the older GNU
896 keyword @code{__complex__} is also supported.
897
898 For example, @samp{_Complex double x;} declares @code{x} as a
899 variable whose real part and imaginary part are both of type
900 @code{double}. @samp{_Complex short int y;} declares @code{y} to
901 have real and imaginary parts of type @code{short int}; this is not
902 likely to be useful, but it shows that the set of complex types is
903 complete.
904
905 To write a constant with a complex data type, use the suffix @samp{i} or
906 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
907 has type @code{_Complex float} and @code{3i} has type
908 @code{_Complex int}. Such a constant always has a pure imaginary
909 value, but you can form any complex value you like by adding one to a
910 real constant. This is a GNU extension; if you have an ISO C99
911 conforming C library (such as the GNU C Library), and want to construct complex
912 constants of floating type, you should include @code{<complex.h>} and
913 use the macros @code{I} or @code{_Complex_I} instead.
914
915 @cindex @code{__real__} keyword
916 @cindex @code{__imag__} keyword
917 To extract the real part of a complex-valued expression @var{exp}, write
918 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
919 extract the imaginary part. This is a GNU extension; for values of
920 floating type, you should use the ISO C99 functions @code{crealf},
921 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
922 @code{cimagl}, declared in @code{<complex.h>} and also provided as
923 built-in functions by GCC@.
924
925 @cindex complex conjugation
926 The operator @samp{~} performs complex conjugation when used on a value
927 with a complex type. This is a GNU extension; for values of
928 floating type, you should use the ISO C99 functions @code{conjf},
929 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
930 provided as built-in functions by GCC@.
931
932 GCC can allocate complex automatic variables in a noncontiguous
933 fashion; it's even possible for the real part to be in a register while
934 the imaginary part is on the stack (or vice versa). Only the DWARF 2
935 debug info format can represent this, so use of DWARF 2 is recommended.
936 If you are using the stabs debug info format, GCC describes a noncontiguous
937 complex variable as if it were two separate variables of noncomplex type.
938 If the variable's actual name is @code{foo}, the two fictitious
939 variables are named @code{foo$real} and @code{foo$imag}. You can
940 examine and set these two fictitious variables with your debugger.
941
942 @node Floating Types
943 @section Additional Floating Types
944 @cindex additional floating types
945 @cindex @code{__float80} data type
946 @cindex @code{__float128} data type
947 @cindex @code{w} floating point suffix
948 @cindex @code{q} floating point suffix
949 @cindex @code{W} floating point suffix
950 @cindex @code{Q} floating point suffix
951
952 As an extension, GNU C supports additional floating
953 types, @code{__float80} and @code{__float128} to support 80-bit
954 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
955 Support for additional types includes the arithmetic operators:
956 add, subtract, multiply, divide; unary arithmetic operators;
957 relational operators; equality operators; and conversions to and from
958 integer and other floating types. Use a suffix @samp{w} or @samp{W}
959 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
960 for @code{_float128}. You can declare complex types using the
961 corresponding internal complex type, @code{XCmode} for @code{__float80}
962 type and @code{TCmode} for @code{__float128} type:
963
964 @smallexample
965 typedef _Complex float __attribute__((mode(TC))) _Complex128;
966 typedef _Complex float __attribute__((mode(XC))) _Complex80;
967 @end smallexample
968
969 Not all targets support additional floating-point types. @code{__float80}
970 and @code{__float128} types are supported on i386, x86_64 and IA-64 targets.
971 The @code{__float128} type is supported on hppa HP-UX targets.
972
973 @node Half-Precision
974 @section Half-Precision Floating Point
975 @cindex half-precision floating point
976 @cindex @code{__fp16} data type
977
978 On ARM targets, GCC supports half-precision (16-bit) floating point via
979 the @code{__fp16} type. You must enable this type explicitly
980 with the @option{-mfp16-format} command-line option in order to use it.
981
982 ARM supports two incompatible representations for half-precision
983 floating-point values. You must choose one of the representations and
984 use it consistently in your program.
985
986 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
987 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
988 There are 11 bits of significand precision, approximately 3
989 decimal digits.
990
991 Specifying @option{-mfp16-format=alternative} selects the ARM
992 alternative format. This representation is similar to the IEEE
993 format, but does not support infinities or NaNs. Instead, the range
994 of exponents is extended, so that this format can represent normalized
995 values in the range of @math{2^{-14}} to 131008.
996
997 The @code{__fp16} type is a storage format only. For purposes
998 of arithmetic and other operations, @code{__fp16} values in C or C++
999 expressions are automatically promoted to @code{float}. In addition,
1000 you cannot declare a function with a return value or parameters
1001 of type @code{__fp16}.
1002
1003 Note that conversions from @code{double} to @code{__fp16}
1004 involve an intermediate conversion to @code{float}. Because
1005 of rounding, this can sometimes produce a different result than a
1006 direct conversion.
1007
1008 ARM provides hardware support for conversions between
1009 @code{__fp16} and @code{float} values
1010 as an extension to VFP and NEON (Advanced SIMD). GCC generates
1011 code using these hardware instructions if you compile with
1012 options to select an FPU that provides them;
1013 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1014 in addition to the @option{-mfp16-format} option to select
1015 a half-precision format.
1016
1017 Language-level support for the @code{__fp16} data type is
1018 independent of whether GCC generates code using hardware floating-point
1019 instructions. In cases where hardware support is not specified, GCC
1020 implements conversions between @code{__fp16} and @code{float} values
1021 as library calls.
1022
1023 @node Decimal Float
1024 @section Decimal Floating Types
1025 @cindex decimal floating types
1026 @cindex @code{_Decimal32} data type
1027 @cindex @code{_Decimal64} data type
1028 @cindex @code{_Decimal128} data type
1029 @cindex @code{df} integer suffix
1030 @cindex @code{dd} integer suffix
1031 @cindex @code{dl} integer suffix
1032 @cindex @code{DF} integer suffix
1033 @cindex @code{DD} integer suffix
1034 @cindex @code{DL} integer suffix
1035
1036 As an extension, GNU C supports decimal floating types as
1037 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1038 floating types in GCC will evolve as the draft technical report changes.
1039 Calling conventions for any target might also change. Not all targets
1040 support decimal floating types.
1041
1042 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1043 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1044 @code{float}, @code{double}, and @code{long double} whose radix is not
1045 specified by the C standard but is usually two.
1046
1047 Support for decimal floating types includes the arithmetic operators
1048 add, subtract, multiply, divide; unary arithmetic operators;
1049 relational operators; equality operators; and conversions to and from
1050 integer and other floating types. Use a suffix @samp{df} or
1051 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1052 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1053 @code{_Decimal128}.
1054
1055 GCC support of decimal float as specified by the draft technical report
1056 is incomplete:
1057
1058 @itemize @bullet
1059 @item
1060 When the value of a decimal floating type cannot be represented in the
1061 integer type to which it is being converted, the result is undefined
1062 rather than the result value specified by the draft technical report.
1063
1064 @item
1065 GCC does not provide the C library functionality associated with
1066 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1067 @file{wchar.h}, which must come from a separate C library implementation.
1068 Because of this the GNU C compiler does not define macro
1069 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1070 the technical report.
1071 @end itemize
1072
1073 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1074 are supported by the DWARF 2 debug information format.
1075
1076 @node Hex Floats
1077 @section Hex Floats
1078 @cindex hex floats
1079
1080 ISO C99 supports floating-point numbers written not only in the usual
1081 decimal notation, such as @code{1.55e1}, but also numbers such as
1082 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1083 supports this in C90 mode (except in some cases when strictly
1084 conforming) and in C++. In that format the
1085 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1086 mandatory. The exponent is a decimal number that indicates the power of
1087 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1088 @tex
1089 $1 {15\over16}$,
1090 @end tex
1091 @ifnottex
1092 1 15/16,
1093 @end ifnottex
1094 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1095 is the same as @code{1.55e1}.
1096
1097 Unlike for floating-point numbers in the decimal notation the exponent
1098 is always required in the hexadecimal notation. Otherwise the compiler
1099 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1100 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1101 extension for floating-point constants of type @code{float}.
1102
1103 @node Fixed-Point
1104 @section Fixed-Point Types
1105 @cindex fixed-point types
1106 @cindex @code{_Fract} data type
1107 @cindex @code{_Accum} data type
1108 @cindex @code{_Sat} data type
1109 @cindex @code{hr} fixed-suffix
1110 @cindex @code{r} fixed-suffix
1111 @cindex @code{lr} fixed-suffix
1112 @cindex @code{llr} fixed-suffix
1113 @cindex @code{uhr} fixed-suffix
1114 @cindex @code{ur} fixed-suffix
1115 @cindex @code{ulr} fixed-suffix
1116 @cindex @code{ullr} fixed-suffix
1117 @cindex @code{hk} fixed-suffix
1118 @cindex @code{k} fixed-suffix
1119 @cindex @code{lk} fixed-suffix
1120 @cindex @code{llk} fixed-suffix
1121 @cindex @code{uhk} fixed-suffix
1122 @cindex @code{uk} fixed-suffix
1123 @cindex @code{ulk} fixed-suffix
1124 @cindex @code{ullk} fixed-suffix
1125 @cindex @code{HR} fixed-suffix
1126 @cindex @code{R} fixed-suffix
1127 @cindex @code{LR} fixed-suffix
1128 @cindex @code{LLR} fixed-suffix
1129 @cindex @code{UHR} fixed-suffix
1130 @cindex @code{UR} fixed-suffix
1131 @cindex @code{ULR} fixed-suffix
1132 @cindex @code{ULLR} fixed-suffix
1133 @cindex @code{HK} fixed-suffix
1134 @cindex @code{K} fixed-suffix
1135 @cindex @code{LK} fixed-suffix
1136 @cindex @code{LLK} fixed-suffix
1137 @cindex @code{UHK} fixed-suffix
1138 @cindex @code{UK} fixed-suffix
1139 @cindex @code{ULK} fixed-suffix
1140 @cindex @code{ULLK} fixed-suffix
1141
1142 As an extension, GNU C supports fixed-point types as
1143 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1144 types in GCC will evolve as the draft technical report changes.
1145 Calling conventions for any target might also change. Not all targets
1146 support fixed-point types.
1147
1148 The fixed-point types are
1149 @code{short _Fract},
1150 @code{_Fract},
1151 @code{long _Fract},
1152 @code{long long _Fract},
1153 @code{unsigned short _Fract},
1154 @code{unsigned _Fract},
1155 @code{unsigned long _Fract},
1156 @code{unsigned long long _Fract},
1157 @code{_Sat short _Fract},
1158 @code{_Sat _Fract},
1159 @code{_Sat long _Fract},
1160 @code{_Sat long long _Fract},
1161 @code{_Sat unsigned short _Fract},
1162 @code{_Sat unsigned _Fract},
1163 @code{_Sat unsigned long _Fract},
1164 @code{_Sat unsigned long long _Fract},
1165 @code{short _Accum},
1166 @code{_Accum},
1167 @code{long _Accum},
1168 @code{long long _Accum},
1169 @code{unsigned short _Accum},
1170 @code{unsigned _Accum},
1171 @code{unsigned long _Accum},
1172 @code{unsigned long long _Accum},
1173 @code{_Sat short _Accum},
1174 @code{_Sat _Accum},
1175 @code{_Sat long _Accum},
1176 @code{_Sat long long _Accum},
1177 @code{_Sat unsigned short _Accum},
1178 @code{_Sat unsigned _Accum},
1179 @code{_Sat unsigned long _Accum},
1180 @code{_Sat unsigned long long _Accum}.
1181
1182 Fixed-point data values contain fractional and optional integral parts.
1183 The format of fixed-point data varies and depends on the target machine.
1184
1185 Support for fixed-point types includes:
1186 @itemize @bullet
1187 @item
1188 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1189 @item
1190 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1191 @item
1192 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1193 @item
1194 binary shift operators (@code{<<}, @code{>>})
1195 @item
1196 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1197 @item
1198 equality operators (@code{==}, @code{!=})
1199 @item
1200 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1201 @code{<<=}, @code{>>=})
1202 @item
1203 conversions to and from integer, floating-point, or fixed-point types
1204 @end itemize
1205
1206 Use a suffix in a fixed-point literal constant:
1207 @itemize
1208 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1209 @code{_Sat short _Fract}
1210 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1211 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1212 @code{_Sat long _Fract}
1213 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1214 @code{_Sat long long _Fract}
1215 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1216 @code{_Sat unsigned short _Fract}
1217 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1218 @code{_Sat unsigned _Fract}
1219 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1220 @code{_Sat unsigned long _Fract}
1221 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1222 and @code{_Sat unsigned long long _Fract}
1223 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1224 @code{_Sat short _Accum}
1225 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1226 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1227 @code{_Sat long _Accum}
1228 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1229 @code{_Sat long long _Accum}
1230 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1231 @code{_Sat unsigned short _Accum}
1232 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1233 @code{_Sat unsigned _Accum}
1234 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1235 @code{_Sat unsigned long _Accum}
1236 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1237 and @code{_Sat unsigned long long _Accum}
1238 @end itemize
1239
1240 GCC support of fixed-point types as specified by the draft technical report
1241 is incomplete:
1242
1243 @itemize @bullet
1244 @item
1245 Pragmas to control overflow and rounding behaviors are not implemented.
1246 @end itemize
1247
1248 Fixed-point types are supported by the DWARF 2 debug information format.
1249
1250 @node Named Address Spaces
1251 @section Named Address Spaces
1252 @cindex Named Address Spaces
1253
1254 As an extension, GNU C supports named address spaces as
1255 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1256 address spaces in GCC will evolve as the draft technical report
1257 changes. Calling conventions for any target might also change. At
1258 present, only the AVR, SPU, M32C, and RL78 targets support address
1259 spaces other than the generic address space.
1260
1261 Address space identifiers may be used exactly like any other C type
1262 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1263 document for more details.
1264
1265 @anchor{AVR Named Address Spaces}
1266 @subsection AVR Named Address Spaces
1267
1268 On the AVR target, there are several address spaces that can be used
1269 in order to put read-only data into the flash memory and access that
1270 data by means of the special instructions @code{LPM} or @code{ELPM}
1271 needed to read from flash.
1272
1273 Per default, any data including read-only data is located in RAM
1274 (the generic address space) so that non-generic address spaces are
1275 needed to locate read-only data in flash memory
1276 @emph{and} to generate the right instructions to access this data
1277 without using (inline) assembler code.
1278
1279 @table @code
1280 @item __flash
1281 @cindex @code{__flash} AVR Named Address Spaces
1282 The @code{__flash} qualifier locates data in the
1283 @code{.progmem.data} section. Data is read using the @code{LPM}
1284 instruction. Pointers to this address space are 16 bits wide.
1285
1286 @item __flash1
1287 @itemx __flash2
1288 @itemx __flash3
1289 @itemx __flash4
1290 @itemx __flash5
1291 @cindex @code{__flash1} AVR Named Address Spaces
1292 @cindex @code{__flash2} AVR Named Address Spaces
1293 @cindex @code{__flash3} AVR Named Address Spaces
1294 @cindex @code{__flash4} AVR Named Address Spaces
1295 @cindex @code{__flash5} AVR Named Address Spaces
1296 These are 16-bit address spaces locating data in section
1297 @code{.progmem@var{N}.data} where @var{N} refers to
1298 address space @code{__flash@var{N}}.
1299 The compiler sets the @code{RAMPZ} segment register appropriately
1300 before reading data by means of the @code{ELPM} instruction.
1301
1302 @item __memx
1303 @cindex @code{__memx} AVR Named Address Spaces
1304 This is a 24-bit address space that linearizes flash and RAM:
1305 If the high bit of the address is set, data is read from
1306 RAM using the lower two bytes as RAM address.
1307 If the high bit of the address is clear, data is read from flash
1308 with @code{RAMPZ} set according to the high byte of the address.
1309 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1310
1311 Objects in this address space are located in @code{.progmemx.data}.
1312 @end table
1313
1314 @b{Example}
1315
1316 @smallexample
1317 char my_read (const __flash char ** p)
1318 @{
1319 /* p is a pointer to RAM that points to a pointer to flash.
1320 The first indirection of p reads that flash pointer
1321 from RAM and the second indirection reads a char from this
1322 flash address. */
1323
1324 return **p;
1325 @}
1326
1327 /* Locate array[] in flash memory */
1328 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1329
1330 int i = 1;
1331
1332 int main (void)
1333 @{
1334 /* Return 17 by reading from flash memory */
1335 return array[array[i]];
1336 @}
1337 @end smallexample
1338
1339 @noindent
1340 For each named address space supported by avr-gcc there is an equally
1341 named but uppercase built-in macro defined.
1342 The purpose is to facilitate testing if respective address space
1343 support is available or not:
1344
1345 @smallexample
1346 #ifdef __FLASH
1347 const __flash int var = 1;
1348
1349 int read_var (void)
1350 @{
1351 return var;
1352 @}
1353 #else
1354 #include <avr/pgmspace.h> /* From AVR-LibC */
1355
1356 const int var PROGMEM = 1;
1357
1358 int read_var (void)
1359 @{
1360 return (int) pgm_read_word (&var);
1361 @}
1362 #endif /* __FLASH */
1363 @end smallexample
1364
1365 @noindent
1366 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1367 locates data in flash but
1368 accesses to these data read from generic address space, i.e.@:
1369 from RAM,
1370 so that you need special accessors like @code{pgm_read_byte}
1371 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1372 together with attribute @code{progmem}.
1373
1374 @noindent
1375 @b{Limitations and caveats}
1376
1377 @itemize
1378 @item
1379 Reading across the 64@tie{}KiB section boundary of
1380 the @code{__flash} or @code{__flash@var{N}} address spaces
1381 shows undefined behavior. The only address space that
1382 supports reading across the 64@tie{}KiB flash segment boundaries is
1383 @code{__memx}.
1384
1385 @item
1386 If you use one of the @code{__flash@var{N}} address spaces
1387 you must arrange your linker script to locate the
1388 @code{.progmem@var{N}.data} sections according to your needs.
1389
1390 @item
1391 Any data or pointers to the non-generic address spaces must
1392 be qualified as @code{const}, i.e.@: as read-only data.
1393 This still applies if the data in one of these address
1394 spaces like software version number or calibration lookup table are intended to
1395 be changed after load time by, say, a boot loader. In this case
1396 the right qualification is @code{const} @code{volatile} so that the compiler
1397 must not optimize away known values or insert them
1398 as immediates into operands of instructions.
1399
1400 @item
1401 The following code initializes a variable @code{pfoo}
1402 located in static storage with a 24-bit address:
1403 @smallexample
1404 extern const __memx char foo;
1405 const __memx void *pfoo = &foo;
1406 @end smallexample
1407
1408 @noindent
1409 Such code requires at least binutils 2.23, see
1410 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1411
1412 @end itemize
1413
1414 @subsection M32C Named Address Spaces
1415 @cindex @code{__far} M32C Named Address Spaces
1416
1417 On the M32C target, with the R8C and M16C CPU variants, variables
1418 qualified with @code{__far} are accessed using 32-bit addresses in
1419 order to access memory beyond the first 64@tie{}Ki bytes. If
1420 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1421 effect.
1422
1423 @subsection RL78 Named Address Spaces
1424 @cindex @code{__far} RL78 Named Address Spaces
1425
1426 On the RL78 target, variables qualified with @code{__far} are accessed
1427 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1428 addresses. Non-far variables are assumed to appear in the topmost
1429 64@tie{}KiB of the address space.
1430
1431 @subsection SPU Named Address Spaces
1432 @cindex @code{__ea} SPU Named Address Spaces
1433
1434 On the SPU target variables may be declared as
1435 belonging to another address space by qualifying the type with the
1436 @code{__ea} address space identifier:
1437
1438 @smallexample
1439 extern int __ea i;
1440 @end smallexample
1441
1442 @noindent
1443 The compiler generates special code to access the variable @code{i}.
1444 It may use runtime library
1445 support, or generate special machine instructions to access that address
1446 space.
1447
1448 @node Zero Length
1449 @section Arrays of Length Zero
1450 @cindex arrays of length zero
1451 @cindex zero-length arrays
1452 @cindex length-zero arrays
1453 @cindex flexible array members
1454
1455 Zero-length arrays are allowed in GNU C@. They are very useful as the
1456 last element of a structure that is really a header for a variable-length
1457 object:
1458
1459 @smallexample
1460 struct line @{
1461 int length;
1462 char contents[0];
1463 @};
1464
1465 struct line *thisline = (struct line *)
1466 malloc (sizeof (struct line) + this_length);
1467 thisline->length = this_length;
1468 @end smallexample
1469
1470 In ISO C90, you would have to give @code{contents} a length of 1, which
1471 means either you waste space or complicate the argument to @code{malloc}.
1472
1473 In ISO C99, you would use a @dfn{flexible array member}, which is
1474 slightly different in syntax and semantics:
1475
1476 @itemize @bullet
1477 @item
1478 Flexible array members are written as @code{contents[]} without
1479 the @code{0}.
1480
1481 @item
1482 Flexible array members have incomplete type, and so the @code{sizeof}
1483 operator may not be applied. As a quirk of the original implementation
1484 of zero-length arrays, @code{sizeof} evaluates to zero.
1485
1486 @item
1487 Flexible array members may only appear as the last member of a
1488 @code{struct} that is otherwise non-empty.
1489
1490 @item
1491 A structure containing a flexible array member, or a union containing
1492 such a structure (possibly recursively), may not be a member of a
1493 structure or an element of an array. (However, these uses are
1494 permitted by GCC as extensions.)
1495 @end itemize
1496
1497 GCC versions before 3.0 allowed zero-length arrays to be statically
1498 initialized, as if they were flexible arrays. In addition to those
1499 cases that were useful, it also allowed initializations in situations
1500 that would corrupt later data. Non-empty initialization of zero-length
1501 arrays is now treated like any case where there are more initializer
1502 elements than the array holds, in that a suitable warning about ``excess
1503 elements in array'' is given, and the excess elements (all of them, in
1504 this case) are ignored.
1505
1506 Instead GCC allows static initialization of flexible array members.
1507 This is equivalent to defining a new structure containing the original
1508 structure followed by an array of sufficient size to contain the data.
1509 E.g.@: in the following, @code{f1} is constructed as if it were declared
1510 like @code{f2}.
1511
1512 @smallexample
1513 struct f1 @{
1514 int x; int y[];
1515 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1516
1517 struct f2 @{
1518 struct f1 f1; int data[3];
1519 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1520 @end smallexample
1521
1522 @noindent
1523 The convenience of this extension is that @code{f1} has the desired
1524 type, eliminating the need to consistently refer to @code{f2.f1}.
1525
1526 This has symmetry with normal static arrays, in that an array of
1527 unknown size is also written with @code{[]}.
1528
1529 Of course, this extension only makes sense if the extra data comes at
1530 the end of a top-level object, as otherwise we would be overwriting
1531 data at subsequent offsets. To avoid undue complication and confusion
1532 with initialization of deeply nested arrays, we simply disallow any
1533 non-empty initialization except when the structure is the top-level
1534 object. For example:
1535
1536 @smallexample
1537 struct foo @{ int x; int y[]; @};
1538 struct bar @{ struct foo z; @};
1539
1540 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1541 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1542 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1543 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1544 @end smallexample
1545
1546 @node Empty Structures
1547 @section Structures With No Members
1548 @cindex empty structures
1549 @cindex zero-size structures
1550
1551 GCC permits a C structure to have no members:
1552
1553 @smallexample
1554 struct empty @{
1555 @};
1556 @end smallexample
1557
1558 The structure has size zero. In C++, empty structures are part
1559 of the language. G++ treats empty structures as if they had a single
1560 member of type @code{char}.
1561
1562 @node Variable Length
1563 @section Arrays of Variable Length
1564 @cindex variable-length arrays
1565 @cindex arrays of variable length
1566 @cindex VLAs
1567
1568 Variable-length automatic arrays are allowed in ISO C99, and as an
1569 extension GCC accepts them in C90 mode and in C++. These arrays are
1570 declared like any other automatic arrays, but with a length that is not
1571 a constant expression. The storage is allocated at the point of
1572 declaration and deallocated when the block scope containing the declaration
1573 exits. For
1574 example:
1575
1576 @smallexample
1577 FILE *
1578 concat_fopen (char *s1, char *s2, char *mode)
1579 @{
1580 char str[strlen (s1) + strlen (s2) + 1];
1581 strcpy (str, s1);
1582 strcat (str, s2);
1583 return fopen (str, mode);
1584 @}
1585 @end smallexample
1586
1587 @cindex scope of a variable length array
1588 @cindex variable-length array scope
1589 @cindex deallocating variable length arrays
1590 Jumping or breaking out of the scope of the array name deallocates the
1591 storage. Jumping into the scope is not allowed; you get an error
1592 message for it.
1593
1594 @cindex variable-length array in a structure
1595 As an extension, GCC accepts variable-length arrays as a member of
1596 a structure or a union. For example:
1597
1598 @smallexample
1599 void
1600 foo (int n)
1601 @{
1602 struct S @{ int x[n]; @};
1603 @}
1604 @end smallexample
1605
1606 @cindex @code{alloca} vs variable-length arrays
1607 You can use the function @code{alloca} to get an effect much like
1608 variable-length arrays. The function @code{alloca} is available in
1609 many other C implementations (but not in all). On the other hand,
1610 variable-length arrays are more elegant.
1611
1612 There are other differences between these two methods. Space allocated
1613 with @code{alloca} exists until the containing @emph{function} returns.
1614 The space for a variable-length array is deallocated as soon as the array
1615 name's scope ends. (If you use both variable-length arrays and
1616 @code{alloca} in the same function, deallocation of a variable-length array
1617 also deallocates anything more recently allocated with @code{alloca}.)
1618
1619 You can also use variable-length arrays as arguments to functions:
1620
1621 @smallexample
1622 struct entry
1623 tester (int len, char data[len][len])
1624 @{
1625 /* @r{@dots{}} */
1626 @}
1627 @end smallexample
1628
1629 The length of an array is computed once when the storage is allocated
1630 and is remembered for the scope of the array in case you access it with
1631 @code{sizeof}.
1632
1633 If you want to pass the array first and the length afterward, you can
1634 use a forward declaration in the parameter list---another GNU extension.
1635
1636 @smallexample
1637 struct entry
1638 tester (int len; char data[len][len], int len)
1639 @{
1640 /* @r{@dots{}} */
1641 @}
1642 @end smallexample
1643
1644 @cindex parameter forward declaration
1645 The @samp{int len} before the semicolon is a @dfn{parameter forward
1646 declaration}, and it serves the purpose of making the name @code{len}
1647 known when the declaration of @code{data} is parsed.
1648
1649 You can write any number of such parameter forward declarations in the
1650 parameter list. They can be separated by commas or semicolons, but the
1651 last one must end with a semicolon, which is followed by the ``real''
1652 parameter declarations. Each forward declaration must match a ``real''
1653 declaration in parameter name and data type. ISO C99 does not support
1654 parameter forward declarations.
1655
1656 @node Variadic Macros
1657 @section Macros with a Variable Number of Arguments.
1658 @cindex variable number of arguments
1659 @cindex macro with variable arguments
1660 @cindex rest argument (in macro)
1661 @cindex variadic macros
1662
1663 In the ISO C standard of 1999, a macro can be declared to accept a
1664 variable number of arguments much as a function can. The syntax for
1665 defining the macro is similar to that of a function. Here is an
1666 example:
1667
1668 @smallexample
1669 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1670 @end smallexample
1671
1672 @noindent
1673 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1674 such a macro, it represents the zero or more tokens until the closing
1675 parenthesis that ends the invocation, including any commas. This set of
1676 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1677 wherever it appears. See the CPP manual for more information.
1678
1679 GCC has long supported variadic macros, and used a different syntax that
1680 allowed you to give a name to the variable arguments just like any other
1681 argument. Here is an example:
1682
1683 @smallexample
1684 #define debug(format, args...) fprintf (stderr, format, args)
1685 @end smallexample
1686
1687 @noindent
1688 This is in all ways equivalent to the ISO C example above, but arguably
1689 more readable and descriptive.
1690
1691 GNU CPP has two further variadic macro extensions, and permits them to
1692 be used with either of the above forms of macro definition.
1693
1694 In standard C, you are not allowed to leave the variable argument out
1695 entirely; but you are allowed to pass an empty argument. For example,
1696 this invocation is invalid in ISO C, because there is no comma after
1697 the string:
1698
1699 @smallexample
1700 debug ("A message")
1701 @end smallexample
1702
1703 GNU CPP permits you to completely omit the variable arguments in this
1704 way. In the above examples, the compiler would complain, though since
1705 the expansion of the macro still has the extra comma after the format
1706 string.
1707
1708 To help solve this problem, CPP behaves specially for variable arguments
1709 used with the token paste operator, @samp{##}. If instead you write
1710
1711 @smallexample
1712 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1713 @end smallexample
1714
1715 @noindent
1716 and if the variable arguments are omitted or empty, the @samp{##}
1717 operator causes the preprocessor to remove the comma before it. If you
1718 do provide some variable arguments in your macro invocation, GNU CPP
1719 does not complain about the paste operation and instead places the
1720 variable arguments after the comma. Just like any other pasted macro
1721 argument, these arguments are not macro expanded.
1722
1723 @node Escaped Newlines
1724 @section Slightly Looser Rules for Escaped Newlines
1725 @cindex escaped newlines
1726 @cindex newlines (escaped)
1727
1728 Recently, the preprocessor has relaxed its treatment of escaped
1729 newlines. Previously, the newline had to immediately follow a
1730 backslash. The current implementation allows whitespace in the form
1731 of spaces, horizontal and vertical tabs, and form feeds between the
1732 backslash and the subsequent newline. The preprocessor issues a
1733 warning, but treats it as a valid escaped newline and combines the two
1734 lines to form a single logical line. This works within comments and
1735 tokens, as well as between tokens. Comments are @emph{not} treated as
1736 whitespace for the purposes of this relaxation, since they have not
1737 yet been replaced with spaces.
1738
1739 @node Subscripting
1740 @section Non-Lvalue Arrays May Have Subscripts
1741 @cindex subscripting
1742 @cindex arrays, non-lvalue
1743
1744 @cindex subscripting and function values
1745 In ISO C99, arrays that are not lvalues still decay to pointers, and
1746 may be subscripted, although they may not be modified or used after
1747 the next sequence point and the unary @samp{&} operator may not be
1748 applied to them. As an extension, GNU C allows such arrays to be
1749 subscripted in C90 mode, though otherwise they do not decay to
1750 pointers outside C99 mode. For example,
1751 this is valid in GNU C though not valid in C90:
1752
1753 @smallexample
1754 @group
1755 struct foo @{int a[4];@};
1756
1757 struct foo f();
1758
1759 bar (int index)
1760 @{
1761 return f().a[index];
1762 @}
1763 @end group
1764 @end smallexample
1765
1766 @node Pointer Arith
1767 @section Arithmetic on @code{void}- and Function-Pointers
1768 @cindex void pointers, arithmetic
1769 @cindex void, size of pointer to
1770 @cindex function pointers, arithmetic
1771 @cindex function, size of pointer to
1772
1773 In GNU C, addition and subtraction operations are supported on pointers to
1774 @code{void} and on pointers to functions. This is done by treating the
1775 size of a @code{void} or of a function as 1.
1776
1777 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1778 and on function types, and returns 1.
1779
1780 @opindex Wpointer-arith
1781 The option @option{-Wpointer-arith} requests a warning if these extensions
1782 are used.
1783
1784 @node Initializers
1785 @section Non-Constant Initializers
1786 @cindex initializers, non-constant
1787 @cindex non-constant initializers
1788
1789 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1790 automatic variable are not required to be constant expressions in GNU C@.
1791 Here is an example of an initializer with run-time varying elements:
1792
1793 @smallexample
1794 foo (float f, float g)
1795 @{
1796 float beat_freqs[2] = @{ f-g, f+g @};
1797 /* @r{@dots{}} */
1798 @}
1799 @end smallexample
1800
1801 @node Compound Literals
1802 @section Compound Literals
1803 @cindex constructor expressions
1804 @cindex initializations in expressions
1805 @cindex structures, constructor expression
1806 @cindex expressions, constructor
1807 @cindex compound literals
1808 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1809
1810 ISO C99 supports compound literals. A compound literal looks like
1811 a cast containing an initializer. Its value is an object of the
1812 type specified in the cast, containing the elements specified in
1813 the initializer; it is an lvalue. As an extension, GCC supports
1814 compound literals in C90 mode and in C++, though the semantics are
1815 somewhat different in C++.
1816
1817 Usually, the specified type is a structure. Assume that
1818 @code{struct foo} and @code{structure} are declared as shown:
1819
1820 @smallexample
1821 struct foo @{int a; char b[2];@} structure;
1822 @end smallexample
1823
1824 @noindent
1825 Here is an example of constructing a @code{struct foo} with a compound literal:
1826
1827 @smallexample
1828 structure = ((struct foo) @{x + y, 'a', 0@});
1829 @end smallexample
1830
1831 @noindent
1832 This is equivalent to writing the following:
1833
1834 @smallexample
1835 @{
1836 struct foo temp = @{x + y, 'a', 0@};
1837 structure = temp;
1838 @}
1839 @end smallexample
1840
1841 You can also construct an array, though this is dangerous in C++, as
1842 explained below. If all the elements of the compound literal are
1843 (made up of) simple constant expressions, suitable for use in
1844 initializers of objects of static storage duration, then the compound
1845 literal can be coerced to a pointer to its first element and used in
1846 such an initializer, as shown here:
1847
1848 @smallexample
1849 char **foo = (char *[]) @{ "x", "y", "z" @};
1850 @end smallexample
1851
1852 Compound literals for scalar types and union types are
1853 also allowed, but then the compound literal is equivalent
1854 to a cast.
1855
1856 As a GNU extension, GCC allows initialization of objects with static storage
1857 duration by compound literals (which is not possible in ISO C99, because
1858 the initializer is not a constant).
1859 It is handled as if the object is initialized only with the bracket
1860 enclosed list if the types of the compound literal and the object match.
1861 The initializer list of the compound literal must be constant.
1862 If the object being initialized has array type of unknown size, the size is
1863 determined by compound literal size.
1864
1865 @smallexample
1866 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1867 static int y[] = (int []) @{1, 2, 3@};
1868 static int z[] = (int [3]) @{1@};
1869 @end smallexample
1870
1871 @noindent
1872 The above lines are equivalent to the following:
1873 @smallexample
1874 static struct foo x = @{1, 'a', 'b'@};
1875 static int y[] = @{1, 2, 3@};
1876 static int z[] = @{1, 0, 0@};
1877 @end smallexample
1878
1879 In C, a compound literal designates an unnamed object with static or
1880 automatic storage duration. In C++, a compound literal designates a
1881 temporary object, which only lives until the end of its
1882 full-expression. As a result, well-defined C code that takes the
1883 address of a subobject of a compound literal can be undefined in C++.
1884 For instance, if the array compound literal example above appeared
1885 inside a function, any subsequent use of @samp{foo} in C++ has
1886 undefined behavior because the lifetime of the array ends after the
1887 declaration of @samp{foo}. As a result, the C++ compiler now rejects
1888 the conversion of a temporary array to a pointer.
1889
1890 As an optimization, the C++ compiler sometimes gives array compound
1891 literals longer lifetimes: when the array either appears outside a
1892 function or has const-qualified type. If @samp{foo} and its
1893 initializer had elements of @samp{char *const} type rather than
1894 @samp{char *}, or if @samp{foo} were a global variable, the array
1895 would have static storage duration. But it is probably safest just to
1896 avoid the use of array compound literals in code compiled as C++.
1897
1898 @node Designated Inits
1899 @section Designated Initializers
1900 @cindex initializers with labeled elements
1901 @cindex labeled elements in initializers
1902 @cindex case labels in initializers
1903 @cindex designated initializers
1904
1905 Standard C90 requires the elements of an initializer to appear in a fixed
1906 order, the same as the order of the elements in the array or structure
1907 being initialized.
1908
1909 In ISO C99 you can give the elements in any order, specifying the array
1910 indices or structure field names they apply to, and GNU C allows this as
1911 an extension in C90 mode as well. This extension is not
1912 implemented in GNU C++.
1913
1914 To specify an array index, write
1915 @samp{[@var{index}] =} before the element value. For example,
1916
1917 @smallexample
1918 int a[6] = @{ [4] = 29, [2] = 15 @};
1919 @end smallexample
1920
1921 @noindent
1922 is equivalent to
1923
1924 @smallexample
1925 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1926 @end smallexample
1927
1928 @noindent
1929 The index values must be constant expressions, even if the array being
1930 initialized is automatic.
1931
1932 An alternative syntax for this that has been obsolete since GCC 2.5 but
1933 GCC still accepts is to write @samp{[@var{index}]} before the element
1934 value, with no @samp{=}.
1935
1936 To initialize a range of elements to the same value, write
1937 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
1938 extension. For example,
1939
1940 @smallexample
1941 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1942 @end smallexample
1943
1944 @noindent
1945 If the value in it has side-effects, the side-effects happen only once,
1946 not for each initialized field by the range initializer.
1947
1948 @noindent
1949 Note that the length of the array is the highest value specified
1950 plus one.
1951
1952 In a structure initializer, specify the name of a field to initialize
1953 with @samp{.@var{fieldname} =} before the element value. For example,
1954 given the following structure,
1955
1956 @smallexample
1957 struct point @{ int x, y; @};
1958 @end smallexample
1959
1960 @noindent
1961 the following initialization
1962
1963 @smallexample
1964 struct point p = @{ .y = yvalue, .x = xvalue @};
1965 @end smallexample
1966
1967 @noindent
1968 is equivalent to
1969
1970 @smallexample
1971 struct point p = @{ xvalue, yvalue @};
1972 @end smallexample
1973
1974 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1975 @samp{@var{fieldname}:}, as shown here:
1976
1977 @smallexample
1978 struct point p = @{ y: yvalue, x: xvalue @};
1979 @end smallexample
1980
1981 Omitted field members are implicitly initialized the same as objects
1982 that have static storage duration.
1983
1984 @cindex designators
1985 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1986 @dfn{designator}. You can also use a designator (or the obsolete colon
1987 syntax) when initializing a union, to specify which element of the union
1988 should be used. For example,
1989
1990 @smallexample
1991 union foo @{ int i; double d; @};
1992
1993 union foo f = @{ .d = 4 @};
1994 @end smallexample
1995
1996 @noindent
1997 converts 4 to a @code{double} to store it in the union using
1998 the second element. By contrast, casting 4 to type @code{union foo}
1999 stores it into the union as the integer @code{i}, since it is
2000 an integer. (@xref{Cast to Union}.)
2001
2002 You can combine this technique of naming elements with ordinary C
2003 initialization of successive elements. Each initializer element that
2004 does not have a designator applies to the next consecutive element of the
2005 array or structure. For example,
2006
2007 @smallexample
2008 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2009 @end smallexample
2010
2011 @noindent
2012 is equivalent to
2013
2014 @smallexample
2015 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2016 @end smallexample
2017
2018 Labeling the elements of an array initializer is especially useful
2019 when the indices are characters or belong to an @code{enum} type.
2020 For example:
2021
2022 @smallexample
2023 int whitespace[256]
2024 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2025 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2026 @end smallexample
2027
2028 @cindex designator lists
2029 You can also write a series of @samp{.@var{fieldname}} and
2030 @samp{[@var{index}]} designators before an @samp{=} to specify a
2031 nested subobject to initialize; the list is taken relative to the
2032 subobject corresponding to the closest surrounding brace pair. For
2033 example, with the @samp{struct point} declaration above:
2034
2035 @smallexample
2036 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2037 @end smallexample
2038
2039 @noindent
2040 If the same field is initialized multiple times, it has the value from
2041 the last initialization. If any such overridden initialization has
2042 side-effect, it is unspecified whether the side-effect happens or not.
2043 Currently, GCC discards them and issues a warning.
2044
2045 @node Case Ranges
2046 @section Case Ranges
2047 @cindex case ranges
2048 @cindex ranges in case statements
2049
2050 You can specify a range of consecutive values in a single @code{case} label,
2051 like this:
2052
2053 @smallexample
2054 case @var{low} ... @var{high}:
2055 @end smallexample
2056
2057 @noindent
2058 This has the same effect as the proper number of individual @code{case}
2059 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2060
2061 This feature is especially useful for ranges of ASCII character codes:
2062
2063 @smallexample
2064 case 'A' ... 'Z':
2065 @end smallexample
2066
2067 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2068 it may be parsed wrong when you use it with integer values. For example,
2069 write this:
2070
2071 @smallexample
2072 case 1 ... 5:
2073 @end smallexample
2074
2075 @noindent
2076 rather than this:
2077
2078 @smallexample
2079 case 1...5:
2080 @end smallexample
2081
2082 @node Cast to Union
2083 @section Cast to a Union Type
2084 @cindex cast to a union
2085 @cindex union, casting to a
2086
2087 A cast to union type is similar to other casts, except that the type
2088 specified is a union type. You can specify the type either with
2089 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2090 a constructor, not a cast, and hence does not yield an lvalue like
2091 normal casts. (@xref{Compound Literals}.)
2092
2093 The types that may be cast to the union type are those of the members
2094 of the union. Thus, given the following union and variables:
2095
2096 @smallexample
2097 union foo @{ int i; double d; @};
2098 int x;
2099 double y;
2100 @end smallexample
2101
2102 @noindent
2103 both @code{x} and @code{y} can be cast to type @code{union foo}.
2104
2105 Using the cast as the right-hand side of an assignment to a variable of
2106 union type is equivalent to storing in a member of the union:
2107
2108 @smallexample
2109 union foo u;
2110 /* @r{@dots{}} */
2111 u = (union foo) x @equiv{} u.i = x
2112 u = (union foo) y @equiv{} u.d = y
2113 @end smallexample
2114
2115 You can also use the union cast as a function argument:
2116
2117 @smallexample
2118 void hack (union foo);
2119 /* @r{@dots{}} */
2120 hack ((union foo) x);
2121 @end smallexample
2122
2123 @node Mixed Declarations
2124 @section Mixed Declarations and Code
2125 @cindex mixed declarations and code
2126 @cindex declarations, mixed with code
2127 @cindex code, mixed with declarations
2128
2129 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2130 within compound statements. As an extension, GNU C also allows this in
2131 C90 mode. For example, you could do:
2132
2133 @smallexample
2134 int i;
2135 /* @r{@dots{}} */
2136 i++;
2137 int j = i + 2;
2138 @end smallexample
2139
2140 Each identifier is visible from where it is declared until the end of
2141 the enclosing block.
2142
2143 @node Function Attributes
2144 @section Declaring Attributes of Functions
2145 @cindex function attributes
2146 @cindex declaring attributes of functions
2147 @cindex functions that never return
2148 @cindex functions that return more than once
2149 @cindex functions that have no side effects
2150 @cindex functions in arbitrary sections
2151 @cindex functions that behave like malloc
2152 @cindex @code{volatile} applied to function
2153 @cindex @code{const} applied to function
2154 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2155 @cindex functions with non-null pointer arguments
2156 @cindex functions that are passed arguments in registers on the 386
2157 @cindex functions that pop the argument stack on the 386
2158 @cindex functions that do not pop the argument stack on the 386
2159 @cindex functions that have different compilation options on the 386
2160 @cindex functions that have different optimization options
2161 @cindex functions that are dynamically resolved
2162
2163 In GNU C, you declare certain things about functions called in your program
2164 which help the compiler optimize function calls and check your code more
2165 carefully.
2166
2167 The keyword @code{__attribute__} allows you to specify special
2168 attributes when making a declaration. This keyword is followed by an
2169 attribute specification inside double parentheses. The following
2170 attributes are currently defined for functions on all targets:
2171 @code{aligned}, @code{alloc_size}, @code{alloc_align}, @code{assume_aligned},
2172 @code{noreturn}, @code{returns_twice}, @code{noinline}, @code{noclone},
2173 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2174 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2175 @code{no_instrument_function}, @code{no_split_stack},
2176 @code{section}, @code{constructor},
2177 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2178 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2179 @code{warn_unused_result}, @code{nonnull},
2180 @code{returns_nonnull}, @code{gnu_inline},
2181 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2182 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2183 @code{no_sanitize_undefined},
2184 @code{error} and @code{warning}.
2185 Several other attributes are defined for functions on particular
2186 target systems. Other attributes, including @code{section} are
2187 supported for variables declarations (@pxref{Variable Attributes}),
2188 labels (@pxref{Label Attributes})
2189 and for types (@pxref{Type Attributes}).
2190
2191 GCC plugins may provide their own attributes.
2192
2193 You may also specify attributes with @samp{__} preceding and following
2194 each keyword. This allows you to use them in header files without
2195 being concerned about a possible macro of the same name. For example,
2196 you may use @code{__noreturn__} instead of @code{noreturn}.
2197
2198 @xref{Attribute Syntax}, for details of the exact syntax for using
2199 attributes.
2200
2201 @table @code
2202 @c Keep this table alphabetized by attribute name. Treat _ as space.
2203
2204 @item alias ("@var{target}")
2205 @cindex @code{alias} attribute
2206 The @code{alias} attribute causes the declaration to be emitted as an
2207 alias for another symbol, which must be specified. For instance,
2208
2209 @smallexample
2210 void __f () @{ /* @r{Do something.} */; @}
2211 void f () __attribute__ ((weak, alias ("__f")));
2212 @end smallexample
2213
2214 @noindent
2215 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2216 mangled name for the target must be used. It is an error if @samp{__f}
2217 is not defined in the same translation unit.
2218
2219 Not all target machines support this attribute.
2220
2221 @item aligned (@var{alignment})
2222 @cindex @code{aligned} attribute
2223 This attribute specifies a minimum alignment for the function,
2224 measured in bytes.
2225
2226 You cannot use this attribute to decrease the alignment of a function,
2227 only to increase it. However, when you explicitly specify a function
2228 alignment this overrides the effect of the
2229 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2230 function.
2231
2232 Note that the effectiveness of @code{aligned} attributes may be
2233 limited by inherent limitations in your linker. On many systems, the
2234 linker is only able to arrange for functions to be aligned up to a
2235 certain maximum alignment. (For some linkers, the maximum supported
2236 alignment may be very very small.) See your linker documentation for
2237 further information.
2238
2239 The @code{aligned} attribute can also be used for variables and fields
2240 (@pxref{Variable Attributes}.)
2241
2242 @item alloc_size
2243 @cindex @code{alloc_size} attribute
2244 The @code{alloc_size} attribute is used to tell the compiler that the
2245 function return value points to memory, where the size is given by
2246 one or two of the functions parameters. GCC uses this
2247 information to improve the correctness of @code{__builtin_object_size}.
2248
2249 The function parameter(s) denoting the allocated size are specified by
2250 one or two integer arguments supplied to the attribute. The allocated size
2251 is either the value of the single function argument specified or the product
2252 of the two function arguments specified. Argument numbering starts at
2253 one.
2254
2255 For instance,
2256
2257 @smallexample
2258 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2259 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2260 @end smallexample
2261
2262 @noindent
2263 declares that @code{my_calloc} returns memory of the size given by
2264 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2265 of the size given by parameter 2.
2266
2267 @item alloc_align
2268 @cindex @code{alloc_align} attribute
2269 The @code{alloc_align} attribute is used to tell the compiler that the
2270 function return value points to memory, where the returned pointer minimum
2271 alignment is given by one of the functions parameters. GCC uses this
2272 information to improve pointer alignment analysis.
2273
2274 The function parameter denoting the allocated alignment is specified by
2275 one integer argument, whose number is the argument of the attribute.
2276 Argument numbering starts at one.
2277
2278 For instance,
2279
2280 @smallexample
2281 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2282 @end smallexample
2283
2284 @noindent
2285 declares that @code{my_memalign} returns memory with minimum alignment
2286 given by parameter 1.
2287
2288 @item assume_aligned
2289 @cindex @code{assume_aligned} attribute
2290 The @code{assume_aligned} attribute is used to tell the compiler that the
2291 function return value points to memory, where the returned pointer minimum
2292 alignment is given by the first argument.
2293 If the attribute has two arguments, the second argument is misalignment offset.
2294
2295 For instance
2296
2297 @smallexample
2298 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2299 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2300 @end smallexample
2301
2302 @noindent
2303 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2304 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2305 to 8.
2306
2307 @item always_inline
2308 @cindex @code{always_inline} function attribute
2309 Generally, functions are not inlined unless optimization is specified.
2310 For functions declared inline, this attribute inlines the function even
2311 if no optimization level is specified.
2312
2313 @item gnu_inline
2314 @cindex @code{gnu_inline} function attribute
2315 This attribute should be used with a function that is also declared
2316 with the @code{inline} keyword. It directs GCC to treat the function
2317 as if it were defined in gnu90 mode even when compiling in C99 or
2318 gnu99 mode.
2319
2320 If the function is declared @code{extern}, then this definition of the
2321 function is used only for inlining. In no case is the function
2322 compiled as a standalone function, not even if you take its address
2323 explicitly. Such an address becomes an external reference, as if you
2324 had only declared the function, and had not defined it. This has
2325 almost the effect of a macro. The way to use this is to put a
2326 function definition in a header file with this attribute, and put
2327 another copy of the function, without @code{extern}, in a library
2328 file. The definition in the header file causes most calls to the
2329 function to be inlined. If any uses of the function remain, they
2330 refer to the single copy in the library. Note that the two
2331 definitions of the functions need not be precisely the same, although
2332 if they do not have the same effect your program may behave oddly.
2333
2334 In C, if the function is neither @code{extern} nor @code{static}, then
2335 the function is compiled as a standalone function, as well as being
2336 inlined where possible.
2337
2338 This is how GCC traditionally handled functions declared
2339 @code{inline}. Since ISO C99 specifies a different semantics for
2340 @code{inline}, this function attribute is provided as a transition
2341 measure and as a useful feature in its own right. This attribute is
2342 available in GCC 4.1.3 and later. It is available if either of the
2343 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2344 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2345 Function is As Fast As a Macro}.
2346
2347 In C++, this attribute does not depend on @code{extern} in any way,
2348 but it still requires the @code{inline} keyword to enable its special
2349 behavior.
2350
2351 @item artificial
2352 @cindex @code{artificial} function attribute
2353 This attribute is useful for small inline wrappers that if possible
2354 should appear during debugging as a unit. Depending on the debug
2355 info format it either means marking the function as artificial
2356 or using the caller location for all instructions within the inlined
2357 body.
2358
2359 @item bank_switch
2360 @cindex interrupt handler functions
2361 When added to an interrupt handler with the M32C port, causes the
2362 prologue and epilogue to use bank switching to preserve the registers
2363 rather than saving them on the stack.
2364
2365 @item flatten
2366 @cindex @code{flatten} function attribute
2367 Generally, inlining into a function is limited. For a function marked with
2368 this attribute, every call inside this function is inlined, if possible.
2369 Whether the function itself is considered for inlining depends on its size and
2370 the current inlining parameters.
2371
2372 @item error ("@var{message}")
2373 @cindex @code{error} function attribute
2374 If this attribute is used on a function declaration and a call to such a function
2375 is not eliminated through dead code elimination or other optimizations, an error
2376 that includes @var{message} is diagnosed. This is useful
2377 for compile-time checking, especially together with @code{__builtin_constant_p}
2378 and inline functions where checking the inline function arguments is not
2379 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2380 While it is possible to leave the function undefined and thus invoke
2381 a link failure, when using this attribute the problem is diagnosed
2382 earlier and with exact location of the call even in presence of inline
2383 functions or when not emitting debugging information.
2384
2385 @item warning ("@var{message}")
2386 @cindex @code{warning} function attribute
2387 If this attribute is used on a function declaration and a call to such a function
2388 is not eliminated through dead code elimination or other optimizations, a warning
2389 that includes @var{message} is diagnosed. This is useful
2390 for compile-time checking, especially together with @code{__builtin_constant_p}
2391 and inline functions. While it is possible to define the function with
2392 a message in @code{.gnu.warning*} section, when using this attribute the problem
2393 is diagnosed earlier and with exact location of the call even in presence
2394 of inline functions or when not emitting debugging information.
2395
2396 @item cdecl
2397 @cindex functions that do pop the argument stack on the 386
2398 @opindex mrtd
2399 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2400 assume that the calling function pops off the stack space used to
2401 pass arguments. This is
2402 useful to override the effects of the @option{-mrtd} switch.
2403
2404 @item const
2405 @cindex @code{const} function attribute
2406 Many functions do not examine any values except their arguments, and
2407 have no effects except the return value. Basically this is just slightly
2408 more strict class than the @code{pure} attribute below, since function is not
2409 allowed to read global memory.
2410
2411 @cindex pointer arguments
2412 Note that a function that has pointer arguments and examines the data
2413 pointed to must @emph{not} be declared @code{const}. Likewise, a
2414 function that calls a non-@code{const} function usually must not be
2415 @code{const}. It does not make sense for a @code{const} function to
2416 return @code{void}.
2417
2418 The attribute @code{const} is not implemented in GCC versions earlier
2419 than 2.5. An alternative way to declare that a function has no side
2420 effects, which works in the current version and in some older versions,
2421 is as follows:
2422
2423 @smallexample
2424 typedef int intfn ();
2425
2426 extern const intfn square;
2427 @end smallexample
2428
2429 @noindent
2430 This approach does not work in GNU C++ from 2.6.0 on, since the language
2431 specifies that the @samp{const} must be attached to the return value.
2432
2433 @item constructor
2434 @itemx destructor
2435 @itemx constructor (@var{priority})
2436 @itemx destructor (@var{priority})
2437 @cindex @code{constructor} function attribute
2438 @cindex @code{destructor} function attribute
2439 The @code{constructor} attribute causes the function to be called
2440 automatically before execution enters @code{main ()}. Similarly, the
2441 @code{destructor} attribute causes the function to be called
2442 automatically after @code{main ()} completes or @code{exit ()} is
2443 called. Functions with these attributes are useful for
2444 initializing data that is used implicitly during the execution of
2445 the program.
2446
2447 You may provide an optional integer priority to control the order in
2448 which constructor and destructor functions are run. A constructor
2449 with a smaller priority number runs before a constructor with a larger
2450 priority number; the opposite relationship holds for destructors. So,
2451 if you have a constructor that allocates a resource and a destructor
2452 that deallocates the same resource, both functions typically have the
2453 same priority. The priorities for constructor and destructor
2454 functions are the same as those specified for namespace-scope C++
2455 objects (@pxref{C++ Attributes}).
2456
2457 These attributes are not currently implemented for Objective-C@.
2458
2459 @item deprecated
2460 @itemx deprecated (@var{msg})
2461 @cindex @code{deprecated} attribute.
2462 The @code{deprecated} attribute results in a warning if the function
2463 is used anywhere in the source file. This is useful when identifying
2464 functions that are expected to be removed in a future version of a
2465 program. The warning also includes the location of the declaration
2466 of the deprecated function, to enable users to easily find further
2467 information about why the function is deprecated, or what they should
2468 do instead. Note that the warnings only occurs for uses:
2469
2470 @smallexample
2471 int old_fn () __attribute__ ((deprecated));
2472 int old_fn ();
2473 int (*fn_ptr)() = old_fn;
2474 @end smallexample
2475
2476 @noindent
2477 results in a warning on line 3 but not line 2. The optional @var{msg}
2478 argument, which must be a string, is printed in the warning if
2479 present.
2480
2481 The @code{deprecated} attribute can also be used for variables and
2482 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2483
2484 @item disinterrupt
2485 @cindex @code{disinterrupt} attribute
2486 On Epiphany and MeP targets, this attribute causes the compiler to emit
2487 instructions to disable interrupts for the duration of the given
2488 function.
2489
2490 @item dllexport
2491 @cindex @code{__declspec(dllexport)}
2492 On Microsoft Windows targets and Symbian OS targets the
2493 @code{dllexport} attribute causes the compiler to provide a global
2494 pointer to a pointer in a DLL, so that it can be referenced with the
2495 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
2496 name is formed by combining @code{_imp__} and the function or variable
2497 name.
2498
2499 You can use @code{__declspec(dllexport)} as a synonym for
2500 @code{__attribute__ ((dllexport))} for compatibility with other
2501 compilers.
2502
2503 On systems that support the @code{visibility} attribute, this
2504 attribute also implies ``default'' visibility. It is an error to
2505 explicitly specify any other visibility.
2506
2507 In previous versions of GCC, the @code{dllexport} attribute was ignored
2508 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2509 had been used. The default behavior now is to emit all dllexported
2510 inline functions; however, this can cause object file-size bloat, in
2511 which case the old behavior can be restored by using
2512 @option{-fno-keep-inline-dllexport}.
2513
2514 The attribute is also ignored for undefined symbols.
2515
2516 When applied to C++ classes, the attribute marks defined non-inlined
2517 member functions and static data members as exports. Static consts
2518 initialized in-class are not marked unless they are also defined
2519 out-of-class.
2520
2521 For Microsoft Windows targets there are alternative methods for
2522 including the symbol in the DLL's export table such as using a
2523 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2524 the @option{--export-all} linker flag.
2525
2526 @item dllimport
2527 @cindex @code{__declspec(dllimport)}
2528 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2529 attribute causes the compiler to reference a function or variable via
2530 a global pointer to a pointer that is set up by the DLL exporting the
2531 symbol. The attribute implies @code{extern}. On Microsoft Windows
2532 targets, the pointer name is formed by combining @code{_imp__} and the
2533 function or variable name.
2534
2535 You can use @code{__declspec(dllimport)} as a synonym for
2536 @code{__attribute__ ((dllimport))} for compatibility with other
2537 compilers.
2538
2539 On systems that support the @code{visibility} attribute, this
2540 attribute also implies ``default'' visibility. It is an error to
2541 explicitly specify any other visibility.
2542
2543 Currently, the attribute is ignored for inlined functions. If the
2544 attribute is applied to a symbol @emph{definition}, an error is reported.
2545 If a symbol previously declared @code{dllimport} is later defined, the
2546 attribute is ignored in subsequent references, and a warning is emitted.
2547 The attribute is also overridden by a subsequent declaration as
2548 @code{dllexport}.
2549
2550 When applied to C++ classes, the attribute marks non-inlined
2551 member functions and static data members as imports. However, the
2552 attribute is ignored for virtual methods to allow creation of vtables
2553 using thunks.
2554
2555 On the SH Symbian OS target the @code{dllimport} attribute also has
2556 another affect---it can cause the vtable and run-time type information
2557 for a class to be exported. This happens when the class has a
2558 dllimported constructor or a non-inline, non-pure virtual function
2559 and, for either of those two conditions, the class also has an inline
2560 constructor or destructor and has a key function that is defined in
2561 the current translation unit.
2562
2563 For Microsoft Windows targets the use of the @code{dllimport}
2564 attribute on functions is not necessary, but provides a small
2565 performance benefit by eliminating a thunk in the DLL@. The use of the
2566 @code{dllimport} attribute on imported variables was required on older
2567 versions of the GNU linker, but can now be avoided by passing the
2568 @option{--enable-auto-import} switch to the GNU linker. As with
2569 functions, using the attribute for a variable eliminates a thunk in
2570 the DLL@.
2571
2572 One drawback to using this attribute is that a pointer to a
2573 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2574 address. However, a pointer to a @emph{function} with the
2575 @code{dllimport} attribute can be used as a constant initializer; in
2576 this case, the address of a stub function in the import lib is
2577 referenced. On Microsoft Windows targets, the attribute can be disabled
2578 for functions by setting the @option{-mnop-fun-dllimport} flag.
2579
2580 @item eightbit_data
2581 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2582 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2583 variable should be placed into the eight-bit data section.
2584 The compiler generates more efficient code for certain operations
2585 on data in the eight-bit data area. Note the eight-bit data area is limited to
2586 256 bytes of data.
2587
2588 You must use GAS and GLD from GNU binutils version 2.7 or later for
2589 this attribute to work correctly.
2590
2591 @item exception
2592 @cindex exception handler functions
2593 Use this attribute on the NDS32 target to indicate that the specified function
2594 is an exception handler. The compiler will generate corresponding sections
2595 for use in an exception handler.
2596
2597 @item exception_handler
2598 @cindex exception handler functions on the Blackfin processor
2599 Use this attribute on the Blackfin to indicate that the specified function
2600 is an exception handler. The compiler generates function entry and
2601 exit sequences suitable for use in an exception handler when this
2602 attribute is present.
2603
2604 @item externally_visible
2605 @cindex @code{externally_visible} attribute.
2606 This attribute, attached to a global variable or function, nullifies
2607 the effect of the @option{-fwhole-program} command-line option, so the
2608 object remains visible outside the current compilation unit.
2609
2610 If @option{-fwhole-program} is used together with @option{-flto} and
2611 @command{gold} is used as the linker plugin,
2612 @code{externally_visible} attributes are automatically added to functions
2613 (not variable yet due to a current @command{gold} issue)
2614 that are accessed outside of LTO objects according to resolution file
2615 produced by @command{gold}.
2616 For other linkers that cannot generate resolution file,
2617 explicit @code{externally_visible} attributes are still necessary.
2618
2619 @item far
2620 @cindex functions that handle memory bank switching
2621 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2622 use a calling convention that takes care of switching memory banks when
2623 entering and leaving a function. This calling convention is also the
2624 default when using the @option{-mlong-calls} option.
2625
2626 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2627 to call and return from a function.
2628
2629 On 68HC11 the compiler generates a sequence of instructions
2630 to invoke a board-specific routine to switch the memory bank and call the
2631 real function. The board-specific routine simulates a @code{call}.
2632 At the end of a function, it jumps to a board-specific routine
2633 instead of using @code{rts}. The board-specific return routine simulates
2634 the @code{rtc}.
2635
2636 On MeP targets this causes the compiler to use a calling convention
2637 that assumes the called function is too far away for the built-in
2638 addressing modes.
2639
2640 @item fast_interrupt
2641 @cindex interrupt handler functions
2642 Use this attribute on the M32C and RX ports to indicate that the specified
2643 function is a fast interrupt handler. This is just like the
2644 @code{interrupt} attribute, except that @code{freit} is used to return
2645 instead of @code{reit}.
2646
2647 @item fastcall
2648 @cindex functions that pop the argument stack on the 386
2649 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2650 pass the first argument (if of integral type) in the register ECX and
2651 the second argument (if of integral type) in the register EDX@. Subsequent
2652 and other typed arguments are passed on the stack. The called function
2653 pops the arguments off the stack. If the number of arguments is variable all
2654 arguments are pushed on the stack.
2655
2656 @item thiscall
2657 @cindex functions that pop the argument stack on the 386
2658 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2659 pass the first argument (if of integral type) in the register ECX.
2660 Subsequent and other typed arguments are passed on the stack. The called
2661 function pops the arguments off the stack.
2662 If the number of arguments is variable all arguments are pushed on the
2663 stack.
2664 The @code{thiscall} attribute is intended for C++ non-static member functions.
2665 As a GCC extension, this calling convention can be used for C functions
2666 and for static member methods.
2667
2668 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2669 @cindex @code{format} function attribute
2670 @opindex Wformat
2671 The @code{format} attribute specifies that a function takes @code{printf},
2672 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2673 should be type-checked against a format string. For example, the
2674 declaration:
2675
2676 @smallexample
2677 extern int
2678 my_printf (void *my_object, const char *my_format, ...)
2679 __attribute__ ((format (printf, 2, 3)));
2680 @end smallexample
2681
2682 @noindent
2683 causes the compiler to check the arguments in calls to @code{my_printf}
2684 for consistency with the @code{printf} style format string argument
2685 @code{my_format}.
2686
2687 The parameter @var{archetype} determines how the format string is
2688 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2689 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2690 @code{strfmon}. (You can also use @code{__printf__},
2691 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2692 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2693 @code{ms_strftime} are also present.
2694 @var{archetype} values such as @code{printf} refer to the formats accepted
2695 by the system's C runtime library,
2696 while values prefixed with @samp{gnu_} always refer
2697 to the formats accepted by the GNU C Library. On Microsoft Windows
2698 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2699 @file{msvcrt.dll} library.
2700 The parameter @var{string-index}
2701 specifies which argument is the format string argument (starting
2702 from 1), while @var{first-to-check} is the number of the first
2703 argument to check against the format string. For functions
2704 where the arguments are not available to be checked (such as
2705 @code{vprintf}), specify the third parameter as zero. In this case the
2706 compiler only checks the format string for consistency. For
2707 @code{strftime} formats, the third parameter is required to be zero.
2708 Since non-static C++ methods have an implicit @code{this} argument, the
2709 arguments of such methods should be counted from two, not one, when
2710 giving values for @var{string-index} and @var{first-to-check}.
2711
2712 In the example above, the format string (@code{my_format}) is the second
2713 argument of the function @code{my_print}, and the arguments to check
2714 start with the third argument, so the correct parameters for the format
2715 attribute are 2 and 3.
2716
2717 @opindex ffreestanding
2718 @opindex fno-builtin
2719 The @code{format} attribute allows you to identify your own functions
2720 that take format strings as arguments, so that GCC can check the
2721 calls to these functions for errors. The compiler always (unless
2722 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2723 for the standard library functions @code{printf}, @code{fprintf},
2724 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2725 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2726 warnings are requested (using @option{-Wformat}), so there is no need to
2727 modify the header file @file{stdio.h}. In C99 mode, the functions
2728 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2729 @code{vsscanf} are also checked. Except in strictly conforming C
2730 standard modes, the X/Open function @code{strfmon} is also checked as
2731 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2732 @xref{C Dialect Options,,Options Controlling C Dialect}.
2733
2734 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2735 recognized in the same context. Declarations including these format attributes
2736 are parsed for correct syntax, however the result of checking of such format
2737 strings is not yet defined, and is not carried out by this version of the
2738 compiler.
2739
2740 The target may also provide additional types of format checks.
2741 @xref{Target Format Checks,,Format Checks Specific to Particular
2742 Target Machines}.
2743
2744 @item format_arg (@var{string-index})
2745 @cindex @code{format_arg} function attribute
2746 @opindex Wformat-nonliteral
2747 The @code{format_arg} attribute specifies that a function takes a format
2748 string for a @code{printf}, @code{scanf}, @code{strftime} or
2749 @code{strfmon} style function and modifies it (for example, to translate
2750 it into another language), so the result can be passed to a
2751 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2752 function (with the remaining arguments to the format function the same
2753 as they would have been for the unmodified string). For example, the
2754 declaration:
2755
2756 @smallexample
2757 extern char *
2758 my_dgettext (char *my_domain, const char *my_format)
2759 __attribute__ ((format_arg (2)));
2760 @end smallexample
2761
2762 @noindent
2763 causes the compiler to check the arguments in calls to a @code{printf},
2764 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2765 format string argument is a call to the @code{my_dgettext} function, for
2766 consistency with the format string argument @code{my_format}. If the
2767 @code{format_arg} attribute had not been specified, all the compiler
2768 could tell in such calls to format functions would be that the format
2769 string argument is not constant; this would generate a warning when
2770 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2771 without the attribute.
2772
2773 The parameter @var{string-index} specifies which argument is the format
2774 string argument (starting from one). Since non-static C++ methods have
2775 an implicit @code{this} argument, the arguments of such methods should
2776 be counted from two.
2777
2778 The @code{format_arg} attribute allows you to identify your own
2779 functions that modify format strings, so that GCC can check the
2780 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2781 type function whose operands are a call to one of your own function.
2782 The compiler always treats @code{gettext}, @code{dgettext}, and
2783 @code{dcgettext} in this manner except when strict ISO C support is
2784 requested by @option{-ansi} or an appropriate @option{-std} option, or
2785 @option{-ffreestanding} or @option{-fno-builtin}
2786 is used. @xref{C Dialect Options,,Options
2787 Controlling C Dialect}.
2788
2789 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2790 @code{NSString} reference for compatibility with the @code{format} attribute
2791 above.
2792
2793 The target may also allow additional types in @code{format-arg} attributes.
2794 @xref{Target Format Checks,,Format Checks Specific to Particular
2795 Target Machines}.
2796
2797 @item function_vector
2798 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2799 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2800 function should be called through the function vector. Calling a
2801 function through the function vector reduces code size, however;
2802 the function vector has a limited size (maximum 128 entries on the H8/300
2803 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2804
2805 On SH2A targets, this attribute declares a function to be called using the
2806 TBR relative addressing mode. The argument to this attribute is the entry
2807 number of the same function in a vector table containing all the TBR
2808 relative addressable functions. For correct operation the TBR must be setup
2809 accordingly to point to the start of the vector table before any functions with
2810 this attribute are invoked. Usually a good place to do the initialization is
2811 the startup routine. The TBR relative vector table can have at max 256 function
2812 entries. The jumps to these functions are generated using a SH2A specific,
2813 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
2814 from GNU binutils version 2.7 or later for this attribute to work correctly.
2815
2816 Please refer the example of M16C target, to see the use of this
2817 attribute while declaring a function,
2818
2819 In an application, for a function being called once, this attribute
2820 saves at least 8 bytes of code; and if other successive calls are being
2821 made to the same function, it saves 2 bytes of code per each of these
2822 calls.
2823
2824 On M16C/M32C targets, the @code{function_vector} attribute declares a
2825 special page subroutine call function. Use of this attribute reduces
2826 the code size by 2 bytes for each call generated to the
2827 subroutine. The argument to the attribute is the vector number entry
2828 from the special page vector table which contains the 16 low-order
2829 bits of the subroutine's entry address. Each vector table has special
2830 page number (18 to 255) that is used in @code{jsrs} instructions.
2831 Jump addresses of the routines are generated by adding 0x0F0000 (in
2832 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2833 2-byte addresses set in the vector table. Therefore you need to ensure
2834 that all the special page vector routines should get mapped within the
2835 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2836 (for M32C).
2837
2838 In the following example 2 bytes are saved for each call to
2839 function @code{foo}.
2840
2841 @smallexample
2842 void foo (void) __attribute__((function_vector(0x18)));
2843 void foo (void)
2844 @{
2845 @}
2846
2847 void bar (void)
2848 @{
2849 foo();
2850 @}
2851 @end smallexample
2852
2853 If functions are defined in one file and are called in another file,
2854 then be sure to write this declaration in both files.
2855
2856 This attribute is ignored for R8C target.
2857
2858 @item ifunc ("@var{resolver}")
2859 @cindex @code{ifunc} attribute
2860 The @code{ifunc} attribute is used to mark a function as an indirect
2861 function using the STT_GNU_IFUNC symbol type extension to the ELF
2862 standard. This allows the resolution of the symbol value to be
2863 determined dynamically at load time, and an optimized version of the
2864 routine can be selected for the particular processor or other system
2865 characteristics determined then. To use this attribute, first define
2866 the implementation functions available, and a resolver function that
2867 returns a pointer to the selected implementation function. The
2868 implementation functions' declarations must match the API of the
2869 function being implemented, the resolver's declaration is be a
2870 function returning pointer to void function returning void:
2871
2872 @smallexample
2873 void *my_memcpy (void *dst, const void *src, size_t len)
2874 @{
2875 @dots{}
2876 @}
2877
2878 static void (*resolve_memcpy (void)) (void)
2879 @{
2880 return my_memcpy; // we'll just always select this routine
2881 @}
2882 @end smallexample
2883
2884 @noindent
2885 The exported header file declaring the function the user calls would
2886 contain:
2887
2888 @smallexample
2889 extern void *memcpy (void *, const void *, size_t);
2890 @end smallexample
2891
2892 @noindent
2893 allowing the user to call this as a regular function, unaware of the
2894 implementation. Finally, the indirect function needs to be defined in
2895 the same translation unit as the resolver function:
2896
2897 @smallexample
2898 void *memcpy (void *, const void *, size_t)
2899 __attribute__ ((ifunc ("resolve_memcpy")));
2900 @end smallexample
2901
2902 Indirect functions cannot be weak, and require a recent binutils (at
2903 least version 2.20.1), and GNU C library (at least version 2.11.1).
2904
2905 @item interrupt
2906 @cindex interrupt handler functions
2907 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2908 m68k, MeP, MIPS, MSP430, RL78, RX and Xstormy16 ports to indicate that
2909 the specified function is an
2910 interrupt handler. The compiler generates function entry and exit
2911 sequences suitable for use in an interrupt handler when this attribute
2912 is present. With Epiphany targets it may also generate a special section with
2913 code to initialize the interrupt vector table.
2914
2915 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2916 and SH processors can be specified via the @code{interrupt_handler} attribute.
2917
2918 Note, on the ARC, you must specify the kind of interrupt to be handled
2919 in a parameter to the interrupt attribute like this:
2920
2921 @smallexample
2922 void f () __attribute__ ((interrupt ("ilink1")));
2923 @end smallexample
2924
2925 Permissible values for this parameter are: @w{@code{ilink1}} and
2926 @w{@code{ilink2}}.
2927
2928 Note, on the AVR, the hardware globally disables interrupts when an
2929 interrupt is executed. The first instruction of an interrupt handler
2930 declared with this attribute is a @code{SEI} instruction to
2931 re-enable interrupts. See also the @code{signal} function attribute
2932 that does not insert a @code{SEI} instruction. If both @code{signal} and
2933 @code{interrupt} are specified for the same function, @code{signal}
2934 is silently ignored.
2935
2936 Note, for the ARM, you can specify the kind of interrupt to be handled by
2937 adding an optional parameter to the interrupt attribute like this:
2938
2939 @smallexample
2940 void f () __attribute__ ((interrupt ("IRQ")));
2941 @end smallexample
2942
2943 @noindent
2944 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2945 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2946
2947 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2948 may be called with a word-aligned stack pointer.
2949
2950 Note, for the MSP430 you can provide an argument to the interrupt
2951 attribute which specifies a name or number. If the argument is a
2952 number it indicates the slot in the interrupt vector table (0 - 31) to
2953 which this handler should be assigned. If the argument is a name it
2954 is treated as a symbolic name for the vector slot. These names should
2955 match up with appropriate entries in the linker script. By default
2956 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2957 @code{reset} for vector 31 are recognised.
2958
2959 You can also use the following function attributes to modify how
2960 normal functions interact with interrupt functions:
2961
2962 @table @code
2963 @item critical
2964 @cindex @code{critical} attribute
2965 Critical functions disable interrupts upon entry and restore the
2966 previous interrupt state upon exit. Critical functions cannot also
2967 have the @code{naked} or @code{reentrant} attributes. They can have
2968 the @code{interrupt} attribute.
2969
2970 @item reentrant
2971 @cindex @code{reentrant} attribute
2972 Reentrant functions disable interrupts upon entry and enable them
2973 upon exit. Reentrant functions cannot also have the @code{naked}
2974 or @code{critical} attributes. They can have the @code{interrupt}
2975 attribute.
2976
2977 @item wakeup
2978 @cindex @code{wakeup} attribute
2979 This attribute only applies to interrupt functions. It is silently
2980 ignored if applied to a non-interrupt function. A wakeup interrupt
2981 function will rouse the processor from any low-power state that it
2982 might be in when the function exits.
2983
2984 @end table
2985
2986 On Epiphany targets one or more optional parameters can be added like this:
2987
2988 @smallexample
2989 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2990 @end smallexample
2991
2992 Permissible values for these parameters are: @w{@code{reset}},
2993 @w{@code{software_exception}}, @w{@code{page_miss}},
2994 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
2995 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
2996 Multiple parameters indicate that multiple entries in the interrupt
2997 vector table should be initialized for this function, i.e.@: for each
2998 parameter @w{@var{name}}, a jump to the function is emitted in
2999 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
3000 entirely, in which case no interrupt vector table entry is provided.
3001
3002 Note, on Epiphany targets, interrupts are enabled inside the function
3003 unless the @code{disinterrupt} attribute is also specified.
3004
3005 On Epiphany targets, you can also use the following attribute to
3006 modify the behavior of an interrupt handler:
3007 @table @code
3008 @item forwarder_section
3009 @cindex @code{forwarder_section} attribute
3010 The interrupt handler may be in external memory which cannot be
3011 reached by a branch instruction, so generate a local memory trampoline
3012 to transfer control. The single parameter identifies the section where
3013 the trampoline is placed.
3014 @end table
3015
3016 The following examples are all valid uses of these attributes on
3017 Epiphany targets:
3018 @smallexample
3019 void __attribute__ ((interrupt)) universal_handler ();
3020 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3021 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3022 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3023 fast_timer_handler ();
3024 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
3025 external_dma_handler ();
3026 @end smallexample
3027
3028 On MIPS targets, you can use the following attributes to modify the behavior
3029 of an interrupt handler:
3030 @table @code
3031 @item use_shadow_register_set
3032 @cindex @code{use_shadow_register_set} attribute
3033 Assume that the handler uses a shadow register set, instead of
3034 the main general-purpose registers.
3035
3036 @item keep_interrupts_masked
3037 @cindex @code{keep_interrupts_masked} attribute
3038 Keep interrupts masked for the whole function. Without this attribute,
3039 GCC tries to reenable interrupts for as much of the function as it can.
3040
3041 @item use_debug_exception_return
3042 @cindex @code{use_debug_exception_return} attribute
3043 Return using the @code{deret} instruction. Interrupt handlers that don't
3044 have this attribute return using @code{eret} instead.
3045 @end table
3046
3047 You can use any combination of these attributes, as shown below:
3048 @smallexample
3049 void __attribute__ ((interrupt)) v0 ();
3050 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
3051 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
3052 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
3053 void __attribute__ ((interrupt, use_shadow_register_set,
3054 keep_interrupts_masked)) v4 ();
3055 void __attribute__ ((interrupt, use_shadow_register_set,
3056 use_debug_exception_return)) v5 ();
3057 void __attribute__ ((interrupt, keep_interrupts_masked,
3058 use_debug_exception_return)) v6 ();
3059 void __attribute__ ((interrupt, use_shadow_register_set,
3060 keep_interrupts_masked,
3061 use_debug_exception_return)) v7 ();
3062 @end smallexample
3063
3064 On NDS32 target, this attribute is to indicate that the specified function
3065 is an interrupt handler. The compiler will generate corresponding sections
3066 for use in an interrupt handler. You can use the following attributes
3067 to modify the behavior:
3068 @table @code
3069 @item nested
3070 @cindex @code{nested} attribute
3071 This interrupt service routine is interruptible.
3072 @item not_nested
3073 @cindex @code{not_nested} attribute
3074 This interrupt service routine is not interruptible.
3075 @item nested_ready
3076 @cindex @code{nested_ready} attribute
3077 This interrupt service routine is interruptible after @code{PSW.GIE}
3078 (global interrupt enable) is set. This allows interrupt service routine to
3079 finish some short critical code before enabling interrupts.
3080 @item save_all
3081 @cindex @code{save_all} attribute
3082 The system will help save all registers into stack before entering
3083 interrupt handler.
3084 @item partial_save
3085 @cindex @code{partial_save} attribute
3086 The system will help save caller registers into stack before entering
3087 interrupt handler.
3088 @end table
3089
3090 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
3091 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
3092 that must end with @code{RETB} instead of @code{RETI}).
3093
3094 On RX targets, you may specify one or more vector numbers as arguments
3095 to the attribute, as well as naming an alternate table name.
3096 Parameters are handled sequentially, so one handler can be assigned to
3097 multiple entries in multiple tables. One may also pass the magic
3098 string @code{"$default"} which causes the function to be used for any
3099 unfilled slots in the current table.
3100
3101 This example shows a simple assignment of a function to one vector in
3102 the default table (note that preprocessor macros may be used for
3103 chip-specific symbolic vector names):
3104 @smallexample
3105 void __attribute__ ((interrupt (5))) txd1_handler ();
3106 @end smallexample
3107
3108 This example assigns a function to two slots in the default table
3109 (using preprocessor macros defined elsewhere) and makes it the default
3110 for the @code{dct} table:
3111 @smallexample
3112 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
3113 txd1_handler ();
3114 @end smallexample
3115
3116 @item interrupt_handler
3117 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
3118 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
3119 indicate that the specified function is an interrupt handler. The compiler
3120 generates function entry and exit sequences suitable for use in an
3121 interrupt handler when this attribute is present.
3122
3123 @item interrupt_thread
3124 @cindex interrupt thread functions on fido
3125 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3126 that the specified function is an interrupt handler that is designed
3127 to run as a thread. The compiler omits generate prologue/epilogue
3128 sequences and replaces the return instruction with a @code{sleep}
3129 instruction. This attribute is available only on fido.
3130
3131 @item isr
3132 @cindex interrupt service routines on ARM
3133 Use this attribute on ARM to write Interrupt Service Routines. This is an
3134 alias to the @code{interrupt} attribute above.
3135
3136 @item kspisusp
3137 @cindex User stack pointer in interrupts on the Blackfin
3138 When used together with @code{interrupt_handler}, @code{exception_handler}
3139 or @code{nmi_handler}, code is generated to load the stack pointer
3140 from the USP register in the function prologue.
3141
3142 @item l1_text
3143 @cindex @code{l1_text} function attribute
3144 This attribute specifies a function to be placed into L1 Instruction
3145 SRAM@. The function is put into a specific section named @code{.l1.text}.
3146 With @option{-mfdpic}, function calls with a such function as the callee
3147 or caller uses inlined PLT.
3148
3149 @item l2
3150 @cindex @code{l2} function attribute
3151 On the Blackfin, this attribute specifies a function to be placed into L2
3152 SRAM. The function is put into a specific section named
3153 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3154 an inlined PLT.
3155
3156 @item leaf
3157 @cindex @code{leaf} function attribute
3158 Calls to external functions with this attribute must return to the current
3159 compilation unit only by return or by exception handling. In particular, leaf
3160 functions are not allowed to call callback function passed to it from the current
3161 compilation unit or directly call functions exported by the unit or longjmp
3162 into the unit. Leaf function might still call functions from other compilation
3163 units and thus they are not necessarily leaf in the sense that they contain no
3164 function calls at all.
3165
3166 The attribute is intended for library functions to improve dataflow analysis.
3167 The compiler takes the hint that any data not escaping the current compilation unit can
3168 not be used or modified by the leaf function. For example, the @code{sin} function
3169 is a leaf function, but @code{qsort} is not.
3170
3171 Note that leaf functions might invoke signals and signal handlers might be
3172 defined in the current compilation unit and use static variables. The only
3173 compliant way to write such a signal handler is to declare such variables
3174 @code{volatile}.
3175
3176 The attribute has no effect on functions defined within the current compilation
3177 unit. This is to allow easy merging of multiple compilation units into one,
3178 for example, by using the link-time optimization. For this reason the
3179 attribute is not allowed on types to annotate indirect calls.
3180
3181 @item long_call/medium_call/short_call
3182 @cindex indirect calls on ARC
3183 @cindex indirect calls on ARM
3184 @cindex indirect calls on Epiphany
3185 These attributes specify how a particular function is called on
3186 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3187 These attributes override the
3188 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3189 and @option{-mmedium-calls} (@pxref{ARC Options})
3190 command-line switches and @code{#pragma long_calls} settings. For ARM, the
3191 @code{long_call} attribute indicates that the function might be far
3192 away from the call site and require a different (more expensive)
3193 calling sequence. The @code{short_call} attribute always places
3194 the offset to the function from the call site into the @samp{BL}
3195 instruction directly.
3196
3197 For ARC, a function marked with the @code{long_call} attribute is
3198 always called using register-indirect jump-and-link instructions,
3199 thereby enabling the called function to be placed anywhere within the
3200 32-bit address space. A function marked with the @code{medium_call}
3201 attribute will always be close enough to be called with an unconditional
3202 branch-and-link instruction, which has a 25-bit offset from
3203 the call site. A function marked with the @code{short_call}
3204 attribute will always be close enough to be called with a conditional
3205 branch-and-link instruction, which has a 21-bit offset from
3206 the call site.
3207
3208 @item longcall/shortcall
3209 @cindex functions called via pointer on the RS/6000 and PowerPC
3210 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3211 indicates that the function might be far away from the call site and
3212 require a different (more expensive) calling sequence. The
3213 @code{shortcall} attribute indicates that the function is always close
3214 enough for the shorter calling sequence to be used. These attributes
3215 override both the @option{-mlongcall} switch and, on the RS/6000 and
3216 PowerPC, the @code{#pragma longcall} setting.
3217
3218 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3219 calls are necessary.
3220
3221 @item long_call/near/far
3222 @cindex indirect calls on MIPS
3223 These attributes specify how a particular function is called on MIPS@.
3224 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3225 command-line switch. The @code{long_call} and @code{far} attributes are
3226 synonyms, and cause the compiler to always call
3227 the function by first loading its address into a register, and then using
3228 the contents of that register. The @code{near} attribute has the opposite
3229 effect; it specifies that non-PIC calls should be made using the more
3230 efficient @code{jal} instruction.
3231
3232 @item malloc
3233 @cindex @code{malloc} attribute
3234 This tells the compiler that a function is @code{malloc}-like, i.e.,
3235 that the pointer @var{P} returned by the function cannot alias any
3236 other pointer valid when the function returns, and moreover no
3237 pointers to valid objects occur in any storage addressed by @var{P}.
3238
3239 Using this attribute can improve optimization. Functions like
3240 @code{malloc} and @code{calloc} have this property because they return
3241 a pointer to uninitialized or zeroed-out storage. However, functions
3242 like @code{realloc} do not have this property, as they can return a
3243 pointer to storage containing pointers.
3244
3245 @item mips16/nomips16
3246 @cindex @code{mips16} attribute
3247 @cindex @code{nomips16} attribute
3248
3249 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3250 function attributes to locally select or turn off MIPS16 code generation.
3251 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3252 while MIPS16 code generation is disabled for functions with the
3253 @code{nomips16} attribute. These attributes override the
3254 @option{-mips16} and @option{-mno-mips16} options on the command line
3255 (@pxref{MIPS Options}).
3256
3257 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3258 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3259 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
3260 may interact badly with some GCC extensions such as @code{__builtin_apply}
3261 (@pxref{Constructing Calls}).
3262
3263 @item micromips/nomicromips
3264 @cindex @code{micromips} attribute
3265 @cindex @code{nomicromips} attribute
3266
3267 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3268 function attributes to locally select or turn off microMIPS code generation.
3269 A function with the @code{micromips} attribute is emitted as microMIPS code,
3270 while microMIPS code generation is disabled for functions with the
3271 @code{nomicromips} attribute. These attributes override the
3272 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3273 (@pxref{MIPS Options}).
3274
3275 When compiling files containing mixed microMIPS and non-microMIPS code, the
3276 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3277 command line,
3278 not that within individual functions. Mixed microMIPS and non-microMIPS code
3279 may interact badly with some GCC extensions such as @code{__builtin_apply}
3280 (@pxref{Constructing Calls}).
3281
3282 @item model (@var{model-name})
3283 @cindex function addressability on the M32R/D
3284 @cindex variable addressability on the IA-64
3285
3286 On the M32R/D, use this attribute to set the addressability of an
3287 object, and of the code generated for a function. The identifier
3288 @var{model-name} is one of @code{small}, @code{medium}, or
3289 @code{large}, representing each of the code models.
3290
3291 Small model objects live in the lower 16MB of memory (so that their
3292 addresses can be loaded with the @code{ld24} instruction), and are
3293 callable with the @code{bl} instruction.
3294
3295 Medium model objects may live anywhere in the 32-bit address space (the
3296 compiler generates @code{seth/add3} instructions to load their addresses),
3297 and are callable with the @code{bl} instruction.
3298
3299 Large model objects may live anywhere in the 32-bit address space (the
3300 compiler generates @code{seth/add3} instructions to load their addresses),
3301 and may not be reachable with the @code{bl} instruction (the compiler
3302 generates the much slower @code{seth/add3/jl} instruction sequence).
3303
3304 On IA-64, use this attribute to set the addressability of an object.
3305 At present, the only supported identifier for @var{model-name} is
3306 @code{small}, indicating addressability via ``small'' (22-bit)
3307 addresses (so that their addresses can be loaded with the @code{addl}
3308 instruction). Caveat: such addressing is by definition not position
3309 independent and hence this attribute must not be used for objects
3310 defined by shared libraries.
3311
3312 @item ms_abi/sysv_abi
3313 @cindex @code{ms_abi} attribute
3314 @cindex @code{sysv_abi} attribute
3315
3316 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3317 to indicate which calling convention should be used for a function. The
3318 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3319 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3320 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
3321 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
3322
3323 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3324 requires the @option{-maccumulate-outgoing-args} option.
3325
3326 @item callee_pop_aggregate_return (@var{number})
3327 @cindex @code{callee_pop_aggregate_return} attribute
3328
3329 On 32-bit i?86-*-* targets, you can use this attribute to control how
3330 aggregates are returned in memory. If the caller is responsible for
3331 popping the hidden pointer together with the rest of the arguments, specify
3332 @var{number} equal to zero. If callee is responsible for popping the
3333 hidden pointer, specify @var{number} equal to one.
3334
3335 The default i386 ABI assumes that the callee pops the
3336 stack for hidden pointer. However, on 32-bit i386 Microsoft Windows targets,
3337 the compiler assumes that the
3338 caller pops the stack for hidden pointer.
3339
3340 @item ms_hook_prologue
3341 @cindex @code{ms_hook_prologue} attribute
3342
3343 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3344 this function attribute to make GCC generate the ``hot-patching'' function
3345 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3346 and newer.
3347
3348 @item hotpatch [(@var{prologue-halfwords})]
3349 @cindex @code{hotpatch} attribute
3350
3351 On S/390 System z targets, you can use this function attribute to
3352 make GCC generate a ``hot-patching'' function prologue. The
3353 @code{hotpatch} has no effect on funtions that are explicitly
3354 inline. If the @option{-mhotpatch} or @option{-mno-hotpatch}
3355 command-line option is used at the same time, the @code{hotpatch}
3356 attribute takes precedence. If an argument is given, the maximum
3357 allowed value is 1000000.
3358
3359 @item naked
3360 @cindex function without a prologue/epilogue code
3361 Use this attribute on the ARM, AVR, MCORE, MSP430, NDS32, RL78, RX and SPU
3362 ports to indicate that the specified function does not need prologue/epilogue
3363 sequences generated by the compiler.
3364 It is up to the programmer to provide these sequences. The
3365 only statements that can be safely included in naked functions are
3366 @code{asm} statements that do not have operands. All other statements,
3367 including declarations of local variables, @code{if} statements, and so
3368 forth, should be avoided. Naked functions should be used to implement the
3369 body of an assembly function, while allowing the compiler to construct
3370 the requisite function declaration for the assembler.
3371
3372 @item near
3373 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3374 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3375 use the normal calling convention based on @code{jsr} and @code{rts}.
3376 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3377 option.
3378
3379 On MeP targets this attribute causes the compiler to assume the called
3380 function is close enough to use the normal calling convention,
3381 overriding the @option{-mtf} command-line option.
3382
3383 @item nesting
3384 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3385 Use this attribute together with @code{interrupt_handler},
3386 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3387 entry code should enable nested interrupts or exceptions.
3388
3389 @item nmi_handler
3390 @cindex NMI handler functions on the Blackfin processor
3391 Use this attribute on the Blackfin to indicate that the specified function
3392 is an NMI handler. The compiler generates function entry and
3393 exit sequences suitable for use in an NMI handler when this
3394 attribute is present.
3395
3396 @item nocompression
3397 @cindex @code{nocompression} attribute
3398 On MIPS targets, you can use the @code{nocompression} function attribute
3399 to locally turn off MIPS16 and microMIPS code generation. This attribute
3400 overrides the @option{-mips16} and @option{-mmicromips} options on the
3401 command line (@pxref{MIPS Options}).
3402
3403 @item no_instrument_function
3404 @cindex @code{no_instrument_function} function attribute
3405 @opindex finstrument-functions
3406 If @option{-finstrument-functions} is given, profiling function calls are
3407 generated at entry and exit of most user-compiled functions.
3408 Functions with this attribute are not so instrumented.
3409
3410 @item no_split_stack
3411 @cindex @code{no_split_stack} function attribute
3412 @opindex fsplit-stack
3413 If @option{-fsplit-stack} is given, functions have a small
3414 prologue which decides whether to split the stack. Functions with the
3415 @code{no_split_stack} attribute do not have that prologue, and thus
3416 may run with only a small amount of stack space available.
3417
3418 @item noinline
3419 @cindex @code{noinline} function attribute
3420 This function attribute prevents a function from being considered for
3421 inlining.
3422 @c Don't enumerate the optimizations by name here; we try to be
3423 @c future-compatible with this mechanism.
3424 If the function does not have side-effects, there are optimizations
3425 other than inlining that cause function calls to be optimized away,
3426 although the function call is live. To keep such calls from being
3427 optimized away, put
3428 @smallexample
3429 asm ("");
3430 @end smallexample
3431
3432 @noindent
3433 (@pxref{Extended Asm}) in the called function, to serve as a special
3434 side-effect.
3435
3436 @item noclone
3437 @cindex @code{noclone} function attribute
3438 This function attribute prevents a function from being considered for
3439 cloning---a mechanism that produces specialized copies of functions
3440 and which is (currently) performed by interprocedural constant
3441 propagation.
3442
3443 @item nonnull (@var{arg-index}, @dots{})
3444 @cindex @code{nonnull} function attribute
3445 The @code{nonnull} attribute specifies that some function parameters should
3446 be non-null pointers. For instance, the declaration:
3447
3448 @smallexample
3449 extern void *
3450 my_memcpy (void *dest, const void *src, size_t len)
3451 __attribute__((nonnull (1, 2)));
3452 @end smallexample
3453
3454 @noindent
3455 causes the compiler to check that, in calls to @code{my_memcpy},
3456 arguments @var{dest} and @var{src} are non-null. If the compiler
3457 determines that a null pointer is passed in an argument slot marked
3458 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3459 is issued. The compiler may also choose to make optimizations based
3460 on the knowledge that certain function arguments will never be null.
3461
3462 If no argument index list is given to the @code{nonnull} attribute,
3463 all pointer arguments are marked as non-null. To illustrate, the
3464 following declaration is equivalent to the previous example:
3465
3466 @smallexample
3467 extern void *
3468 my_memcpy (void *dest, const void *src, size_t len)
3469 __attribute__((nonnull));
3470 @end smallexample
3471
3472 @item returns_nonnull
3473 @cindex @code{returns_nonnull} function attribute
3474 The @code{returns_nonnull} attribute specifies that the function
3475 return value should be a non-null pointer. For instance, the declaration:
3476
3477 @smallexample
3478 extern void *
3479 mymalloc (size_t len) __attribute__((returns_nonnull));
3480 @end smallexample
3481
3482 @noindent
3483 lets the compiler optimize callers based on the knowledge
3484 that the return value will never be null.
3485
3486 @item noreturn
3487 @cindex @code{noreturn} function attribute
3488 A few standard library functions, such as @code{abort} and @code{exit},
3489 cannot return. GCC knows this automatically. Some programs define
3490 their own functions that never return. You can declare them
3491 @code{noreturn} to tell the compiler this fact. For example,
3492
3493 @smallexample
3494 @group
3495 void fatal () __attribute__ ((noreturn));
3496
3497 void
3498 fatal (/* @r{@dots{}} */)
3499 @{
3500 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3501 exit (1);
3502 @}
3503 @end group
3504 @end smallexample
3505
3506 The @code{noreturn} keyword tells the compiler to assume that
3507 @code{fatal} cannot return. It can then optimize without regard to what
3508 would happen if @code{fatal} ever did return. This makes slightly
3509 better code. More importantly, it helps avoid spurious warnings of
3510 uninitialized variables.
3511
3512 The @code{noreturn} keyword does not affect the exceptional path when that
3513 applies: a @code{noreturn}-marked function may still return to the caller
3514 by throwing an exception or calling @code{longjmp}.
3515
3516 Do not assume that registers saved by the calling function are
3517 restored before calling the @code{noreturn} function.
3518
3519 It does not make sense for a @code{noreturn} function to have a return
3520 type other than @code{void}.
3521
3522 The attribute @code{noreturn} is not implemented in GCC versions
3523 earlier than 2.5. An alternative way to declare that a function does
3524 not return, which works in the current version and in some older
3525 versions, is as follows:
3526
3527 @smallexample
3528 typedef void voidfn ();
3529
3530 volatile voidfn fatal;
3531 @end smallexample
3532
3533 @noindent
3534 This approach does not work in GNU C++.
3535
3536 @item nothrow
3537 @cindex @code{nothrow} function attribute
3538 The @code{nothrow} attribute is used to inform the compiler that a
3539 function cannot throw an exception. For example, most functions in
3540 the standard C library can be guaranteed not to throw an exception
3541 with the notable exceptions of @code{qsort} and @code{bsearch} that
3542 take function pointer arguments. The @code{nothrow} attribute is not
3543 implemented in GCC versions earlier than 3.3.
3544
3545 @item nosave_low_regs
3546 @cindex @code{nosave_low_regs} attribute
3547 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3548 function should not save and restore registers R0..R7. This can be used on SH3*
3549 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3550 interrupt handlers.
3551
3552 @item optimize
3553 @cindex @code{optimize} function attribute
3554 The @code{optimize} attribute is used to specify that a function is to
3555 be compiled with different optimization options than specified on the
3556 command line. Arguments can either be numbers or strings. Numbers
3557 are assumed to be an optimization level. Strings that begin with
3558 @code{O} are assumed to be an optimization option, while other options
3559 are assumed to be used with a @code{-f} prefix. You can also use the
3560 @samp{#pragma GCC optimize} pragma to set the optimization options
3561 that affect more than one function.
3562 @xref{Function Specific Option Pragmas}, for details about the
3563 @samp{#pragma GCC optimize} pragma.
3564
3565 This can be used for instance to have frequently-executed functions
3566 compiled with more aggressive optimization options that produce faster
3567 and larger code, while other functions can be compiled with less
3568 aggressive options.
3569
3570 @item OS_main/OS_task
3571 @cindex @code{OS_main} AVR function attribute
3572 @cindex @code{OS_task} AVR function attribute
3573 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3574 do not save/restore any call-saved register in their prologue/epilogue.
3575
3576 The @code{OS_main} attribute can be used when there @emph{is
3577 guarantee} that interrupts are disabled at the time when the function
3578 is entered. This saves resources when the stack pointer has to be
3579 changed to set up a frame for local variables.
3580
3581 The @code{OS_task} attribute can be used when there is @emph{no
3582 guarantee} that interrupts are disabled at that time when the function
3583 is entered like for, e@.g@. task functions in a multi-threading operating
3584 system. In that case, changing the stack pointer register is
3585 guarded by save/clear/restore of the global interrupt enable flag.
3586
3587 The differences to the @code{naked} function attribute are:
3588 @itemize @bullet
3589 @item @code{naked} functions do not have a return instruction whereas
3590 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3591 @code{RETI} return instruction.
3592 @item @code{naked} functions do not set up a frame for local variables
3593 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3594 as needed.
3595 @end itemize
3596
3597 @item pcs
3598 @cindex @code{pcs} function attribute
3599
3600 The @code{pcs} attribute can be used to control the calling convention
3601 used for a function on ARM. The attribute takes an argument that specifies
3602 the calling convention to use.
3603
3604 When compiling using the AAPCS ABI (or a variant of it) then valid
3605 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3606 order to use a variant other than @code{"aapcs"} then the compiler must
3607 be permitted to use the appropriate co-processor registers (i.e., the
3608 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3609 For example,
3610
3611 @smallexample
3612 /* Argument passed in r0, and result returned in r0+r1. */
3613 double f2d (float) __attribute__((pcs("aapcs")));
3614 @end smallexample
3615
3616 Variadic functions always use the @code{"aapcs"} calling convention and
3617 the compiler rejects attempts to specify an alternative.
3618
3619 @item pure
3620 @cindex @code{pure} function attribute
3621 Many functions have no effects except the return value and their
3622 return value depends only on the parameters and/or global variables.
3623 Such a function can be subject
3624 to common subexpression elimination and loop optimization just as an
3625 arithmetic operator would be. These functions should be declared
3626 with the attribute @code{pure}. For example,
3627
3628 @smallexample
3629 int square (int) __attribute__ ((pure));
3630 @end smallexample
3631
3632 @noindent
3633 says that the hypothetical function @code{square} is safe to call
3634 fewer times than the program says.
3635
3636 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3637 Interesting non-pure functions are functions with infinite loops or those
3638 depending on volatile memory or other system resource, that may change between
3639 two consecutive calls (such as @code{feof} in a multithreading environment).
3640
3641 The attribute @code{pure} is not implemented in GCC versions earlier
3642 than 2.96.
3643
3644 @item hot
3645 @cindex @code{hot} function attribute
3646 The @code{hot} attribute on a function is used to inform the compiler that
3647 the function is a hot spot of the compiled program. The function is
3648 optimized more aggressively and on many targets it is placed into a special
3649 subsection of the text section so all hot functions appear close together,
3650 improving locality.
3651
3652 When profile feedback is available, via @option{-fprofile-use}, hot functions
3653 are automatically detected and this attribute is ignored.
3654
3655 The @code{hot} attribute on functions is not implemented in GCC versions
3656 earlier than 4.3.
3657
3658 @item cold
3659 @cindex @code{cold} function attribute
3660 The @code{cold} attribute on functions is used to inform the compiler that
3661 the function is unlikely to be executed. The function is optimized for
3662 size rather than speed and on many targets it is placed into a special
3663 subsection of the text section so all cold functions appear close together,
3664 improving code locality of non-cold parts of program. The paths leading
3665 to calls of cold functions within code are marked as unlikely by the branch
3666 prediction mechanism. It is thus useful to mark functions used to handle
3667 unlikely conditions, such as @code{perror}, as cold to improve optimization
3668 of hot functions that do call marked functions in rare occasions.
3669
3670 When profile feedback is available, via @option{-fprofile-use}, cold functions
3671 are automatically detected and this attribute is ignored.
3672
3673 The @code{cold} attribute on functions is not implemented in GCC versions
3674 earlier than 4.3.
3675
3676 @item no_sanitize_address
3677 @itemx no_address_safety_analysis
3678 @cindex @code{no_sanitize_address} function attribute
3679 The @code{no_sanitize_address} attribute on functions is used
3680 to inform the compiler that it should not instrument memory accesses
3681 in the function when compiling with the @option{-fsanitize=address} option.
3682 The @code{no_address_safety_analysis} is a deprecated alias of the
3683 @code{no_sanitize_address} attribute, new code should use
3684 @code{no_sanitize_address}.
3685
3686 @item no_sanitize_undefined
3687 @cindex @code{no_sanitize_undefined} function attribute
3688 The @code{no_sanitize_undefined} attribute on functions is used
3689 to inform the compiler that it should not check for undefined behavior
3690 in the function when compiling with the @option{-fsanitize=undefined} option.
3691
3692 @item regparm (@var{number})
3693 @cindex @code{regparm} attribute
3694 @cindex functions that are passed arguments in registers on the 386
3695 On the Intel 386, the @code{regparm} attribute causes the compiler to
3696 pass arguments number one to @var{number} if they are of integral type
3697 in registers EAX, EDX, and ECX instead of on the stack. Functions that
3698 take a variable number of arguments continue to be passed all of their
3699 arguments on the stack.
3700
3701 Beware that on some ELF systems this attribute is unsuitable for
3702 global functions in shared libraries with lazy binding (which is the
3703 default). Lazy binding sends the first call via resolving code in
3704 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3705 per the standard calling conventions. Solaris 8 is affected by this.
3706 Systems with the GNU C Library version 2.1 or higher
3707 and FreeBSD are believed to be
3708 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
3709 disabled with the linker or the loader if desired, to avoid the
3710 problem.)
3711
3712 @item reset
3713 @cindex reset handler functions
3714 Use this attribute on the NDS32 target to indicate that the specified function
3715 is a reset handler. The compiler will generate corresponding sections
3716 for use in a reset handler. You can use the following attributes
3717 to provide extra exception handling:
3718 @table @code
3719 @item nmi
3720 @cindex @code{nmi} attribute
3721 Provide a user-defined function to handle NMI exception.
3722 @item warm
3723 @cindex @code{warm} attribute
3724 Provide a user-defined function to handle warm reset exception.
3725 @end table
3726
3727 @item sseregparm
3728 @cindex @code{sseregparm} attribute
3729 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3730 causes the compiler to pass up to 3 floating-point arguments in
3731 SSE registers instead of on the stack. Functions that take a
3732 variable number of arguments continue to pass all of their
3733 floating-point arguments on the stack.
3734
3735 @item force_align_arg_pointer
3736 @cindex @code{force_align_arg_pointer} attribute
3737 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3738 applied to individual function definitions, generating an alternate
3739 prologue and epilogue that realigns the run-time stack if necessary.
3740 This supports mixing legacy codes that run with a 4-byte aligned stack
3741 with modern codes that keep a 16-byte stack for SSE compatibility.
3742
3743 @item renesas
3744 @cindex @code{renesas} attribute
3745 On SH targets this attribute specifies that the function or struct follows the
3746 Renesas ABI.
3747
3748 @item resbank
3749 @cindex @code{resbank} attribute
3750 On the SH2A target, this attribute enables the high-speed register
3751 saving and restoration using a register bank for @code{interrupt_handler}
3752 routines. Saving to the bank is performed automatically after the CPU
3753 accepts an interrupt that uses a register bank.
3754
3755 The nineteen 32-bit registers comprising general register R0 to R14,
3756 control register GBR, and system registers MACH, MACL, and PR and the
3757 vector table address offset are saved into a register bank. Register
3758 banks are stacked in first-in last-out (FILO) sequence. Restoration
3759 from the bank is executed by issuing a RESBANK instruction.
3760
3761 @item returns_twice
3762 @cindex @code{returns_twice} attribute
3763 The @code{returns_twice} attribute tells the compiler that a function may
3764 return more than one time. The compiler ensures that all registers
3765 are dead before calling such a function and emits a warning about
3766 the variables that may be clobbered after the second return from the
3767 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3768 The @code{longjmp}-like counterpart of such function, if any, might need
3769 to be marked with the @code{noreturn} attribute.
3770
3771 @item saveall
3772 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3773 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3774 all registers except the stack pointer should be saved in the prologue
3775 regardless of whether they are used or not.
3776
3777 @item save_volatiles
3778 @cindex save volatile registers on the MicroBlaze
3779 Use this attribute on the MicroBlaze to indicate that the function is
3780 an interrupt handler. All volatile registers (in addition to non-volatile
3781 registers) are saved in the function prologue. If the function is a leaf
3782 function, only volatiles used by the function are saved. A normal function
3783 return is generated instead of a return from interrupt.
3784
3785 @item break_handler
3786 @cindex break handler functions
3787 Use this attribute on the MicroBlaze ports to indicate that
3788 the specified function is an break handler. The compiler generates function
3789 entry and exit sequences suitable for use in an break handler when this
3790 attribute is present. The return from @code{break_handler} is done through
3791 the @code{rtbd} instead of @code{rtsd}.
3792
3793 @smallexample
3794 void f () __attribute__ ((break_handler));
3795 @end smallexample
3796
3797 @item section ("@var{section-name}")
3798 @cindex @code{section} function attribute
3799 Normally, the compiler places the code it generates in the @code{text} section.
3800 Sometimes, however, you need additional sections, or you need certain
3801 particular functions to appear in special sections. The @code{section}
3802 attribute specifies that a function lives in a particular section.
3803 For example, the declaration:
3804
3805 @smallexample
3806 extern void foobar (void) __attribute__ ((section ("bar")));
3807 @end smallexample
3808
3809 @noindent
3810 puts the function @code{foobar} in the @code{bar} section.
3811
3812 Some file formats do not support arbitrary sections so the @code{section}
3813 attribute is not available on all platforms.
3814 If you need to map the entire contents of a module to a particular
3815 section, consider using the facilities of the linker instead.
3816
3817 @item sentinel
3818 @cindex @code{sentinel} function attribute
3819 This function attribute ensures that a parameter in a function call is
3820 an explicit @code{NULL}. The attribute is only valid on variadic
3821 functions. By default, the sentinel is located at position zero, the
3822 last parameter of the function call. If an optional integer position
3823 argument P is supplied to the attribute, the sentinel must be located at
3824 position P counting backwards from the end of the argument list.
3825
3826 @smallexample
3827 __attribute__ ((sentinel))
3828 is equivalent to
3829 __attribute__ ((sentinel(0)))
3830 @end smallexample
3831
3832 The attribute is automatically set with a position of 0 for the built-in
3833 functions @code{execl} and @code{execlp}. The built-in function
3834 @code{execle} has the attribute set with a position of 1.
3835
3836 A valid @code{NULL} in this context is defined as zero with any pointer
3837 type. If your system defines the @code{NULL} macro with an integer type
3838 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3839 with a copy that redefines NULL appropriately.
3840
3841 The warnings for missing or incorrect sentinels are enabled with
3842 @option{-Wformat}.
3843
3844 @item short_call
3845 See @code{long_call/short_call}.
3846
3847 @item shortcall
3848 See @code{longcall/shortcall}.
3849
3850 @item signal
3851 @cindex interrupt handler functions on the AVR processors
3852 Use this attribute on the AVR to indicate that the specified
3853 function is an interrupt handler. The compiler generates function
3854 entry and exit sequences suitable for use in an interrupt handler when this
3855 attribute is present.
3856
3857 See also the @code{interrupt} function attribute.
3858
3859 The AVR hardware globally disables interrupts when an interrupt is executed.
3860 Interrupt handler functions defined with the @code{signal} attribute
3861 do not re-enable interrupts. It is save to enable interrupts in a
3862 @code{signal} handler. This ``save'' only applies to the code
3863 generated by the compiler and not to the IRQ layout of the
3864 application which is responsibility of the application.
3865
3866 If both @code{signal} and @code{interrupt} are specified for the same
3867 function, @code{signal} is silently ignored.
3868
3869 @item sp_switch
3870 @cindex @code{sp_switch} attribute
3871 Use this attribute on the SH to indicate an @code{interrupt_handler}
3872 function should switch to an alternate stack. It expects a string
3873 argument that names a global variable holding the address of the
3874 alternate stack.
3875
3876 @smallexample
3877 void *alt_stack;
3878 void f () __attribute__ ((interrupt_handler,
3879 sp_switch ("alt_stack")));
3880 @end smallexample
3881
3882 @item stdcall
3883 @cindex functions that pop the argument stack on the 386
3884 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3885 assume that the called function pops off the stack space used to
3886 pass arguments, unless it takes a variable number of arguments.
3887
3888 @item syscall_linkage
3889 @cindex @code{syscall_linkage} attribute
3890 This attribute is used to modify the IA-64 calling convention by marking
3891 all input registers as live at all function exits. This makes it possible
3892 to restart a system call after an interrupt without having to save/restore
3893 the input registers. This also prevents kernel data from leaking into
3894 application code.
3895
3896 @item target
3897 @cindex @code{target} function attribute
3898 The @code{target} attribute is used to specify that a function is to
3899 be compiled with different target options than specified on the
3900 command line. This can be used for instance to have functions
3901 compiled with a different ISA (instruction set architecture) than the
3902 default. You can also use the @samp{#pragma GCC target} pragma to set
3903 more than one function to be compiled with specific target options.
3904 @xref{Function Specific Option Pragmas}, for details about the
3905 @samp{#pragma GCC target} pragma.
3906
3907 For instance on a 386, you could compile one function with
3908 @code{target("sse4.1,arch=core2")} and another with
3909 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3910 compiling the first function with @option{-msse4.1} and
3911 @option{-march=core2} options, and the second function with
3912 @option{-msse4a} and @option{-march=amdfam10} options. It is up to the
3913 user to make sure that a function is only invoked on a machine that
3914 supports the particular ISA it is compiled for (for example by using
3915 @code{cpuid} on 386 to determine what feature bits and architecture
3916 family are used).
3917
3918 @smallexample
3919 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3920 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3921 @end smallexample
3922
3923 You can either use multiple
3924 strings to specify multiple options, or separate the options
3925 with a comma (@samp{,}).
3926
3927 The @code{target} attribute is presently implemented for
3928 i386/x86_64, PowerPC, and Nios II targets only.
3929 The options supported are specific to each target.
3930
3931 On the 386, the following options are allowed:
3932
3933 @table @samp
3934 @item abm
3935 @itemx no-abm
3936 @cindex @code{target("abm")} attribute
3937 Enable/disable the generation of the advanced bit instructions.
3938
3939 @item aes
3940 @itemx no-aes
3941 @cindex @code{target("aes")} attribute
3942 Enable/disable the generation of the AES instructions.
3943
3944 @item default
3945 @cindex @code{target("default")} attribute
3946 @xref{Function Multiversioning}, where it is used to specify the
3947 default function version.
3948
3949 @item mmx
3950 @itemx no-mmx
3951 @cindex @code{target("mmx")} attribute
3952 Enable/disable the generation of the MMX instructions.
3953
3954 @item pclmul
3955 @itemx no-pclmul
3956 @cindex @code{target("pclmul")} attribute
3957 Enable/disable the generation of the PCLMUL instructions.
3958
3959 @item popcnt
3960 @itemx no-popcnt
3961 @cindex @code{target("popcnt")} attribute
3962 Enable/disable the generation of the POPCNT instruction.
3963
3964 @item sse
3965 @itemx no-sse
3966 @cindex @code{target("sse")} attribute
3967 Enable/disable the generation of the SSE instructions.
3968
3969 @item sse2
3970 @itemx no-sse2
3971 @cindex @code{target("sse2")} attribute
3972 Enable/disable the generation of the SSE2 instructions.
3973
3974 @item sse3
3975 @itemx no-sse3
3976 @cindex @code{target("sse3")} attribute
3977 Enable/disable the generation of the SSE3 instructions.
3978
3979 @item sse4
3980 @itemx no-sse4
3981 @cindex @code{target("sse4")} attribute
3982 Enable/disable the generation of the SSE4 instructions (both SSE4.1
3983 and SSE4.2).
3984
3985 @item sse4.1
3986 @itemx no-sse4.1
3987 @cindex @code{target("sse4.1")} attribute
3988 Enable/disable the generation of the sse4.1 instructions.
3989
3990 @item sse4.2
3991 @itemx no-sse4.2
3992 @cindex @code{target("sse4.2")} attribute
3993 Enable/disable the generation of the sse4.2 instructions.
3994
3995 @item sse4a
3996 @itemx no-sse4a
3997 @cindex @code{target("sse4a")} attribute
3998 Enable/disable the generation of the SSE4A instructions.
3999
4000 @item fma4
4001 @itemx no-fma4
4002 @cindex @code{target("fma4")} attribute
4003 Enable/disable the generation of the FMA4 instructions.
4004
4005 @item xop
4006 @itemx no-xop
4007 @cindex @code{target("xop")} attribute
4008 Enable/disable the generation of the XOP instructions.
4009
4010 @item lwp
4011 @itemx no-lwp
4012 @cindex @code{target("lwp")} attribute
4013 Enable/disable the generation of the LWP instructions.
4014
4015 @item ssse3
4016 @itemx no-ssse3
4017 @cindex @code{target("ssse3")} attribute
4018 Enable/disable the generation of the SSSE3 instructions.
4019
4020 @item cld
4021 @itemx no-cld
4022 @cindex @code{target("cld")} attribute
4023 Enable/disable the generation of the CLD before string moves.
4024
4025 @item fancy-math-387
4026 @itemx no-fancy-math-387
4027 @cindex @code{target("fancy-math-387")} attribute
4028 Enable/disable the generation of the @code{sin}, @code{cos}, and
4029 @code{sqrt} instructions on the 387 floating-point unit.
4030
4031 @item fused-madd
4032 @itemx no-fused-madd
4033 @cindex @code{target("fused-madd")} attribute
4034 Enable/disable the generation of the fused multiply/add instructions.
4035
4036 @item ieee-fp
4037 @itemx no-ieee-fp
4038 @cindex @code{target("ieee-fp")} attribute
4039 Enable/disable the generation of floating point that depends on IEEE arithmetic.
4040
4041 @item inline-all-stringops
4042 @itemx no-inline-all-stringops
4043 @cindex @code{target("inline-all-stringops")} attribute
4044 Enable/disable inlining of string operations.
4045
4046 @item inline-stringops-dynamically
4047 @itemx no-inline-stringops-dynamically
4048 @cindex @code{target("inline-stringops-dynamically")} attribute
4049 Enable/disable the generation of the inline code to do small string
4050 operations and calling the library routines for large operations.
4051
4052 @item align-stringops
4053 @itemx no-align-stringops
4054 @cindex @code{target("align-stringops")} attribute
4055 Do/do not align destination of inlined string operations.
4056
4057 @item recip
4058 @itemx no-recip
4059 @cindex @code{target("recip")} attribute
4060 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
4061 instructions followed an additional Newton-Raphson step instead of
4062 doing a floating-point division.
4063
4064 @item arch=@var{ARCH}
4065 @cindex @code{target("arch=@var{ARCH}")} attribute
4066 Specify the architecture to generate code for in compiling the function.
4067
4068 @item tune=@var{TUNE}
4069 @cindex @code{target("tune=@var{TUNE}")} attribute
4070 Specify the architecture to tune for in compiling the function.
4071
4072 @item fpmath=@var{FPMATH}
4073 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
4074 Specify which floating-point unit to use. The
4075 @code{target("fpmath=sse,387")} option must be specified as
4076 @code{target("fpmath=sse+387")} because the comma would separate
4077 different options.
4078 @end table
4079
4080 On the PowerPC, the following options are allowed:
4081
4082 @table @samp
4083 @item altivec
4084 @itemx no-altivec
4085 @cindex @code{target("altivec")} attribute
4086 Generate code that uses (does not use) AltiVec instructions. In
4087 32-bit code, you cannot enable AltiVec instructions unless
4088 @option{-mabi=altivec} is used on the command line.
4089
4090 @item cmpb
4091 @itemx no-cmpb
4092 @cindex @code{target("cmpb")} attribute
4093 Generate code that uses (does not use) the compare bytes instruction
4094 implemented on the POWER6 processor and other processors that support
4095 the PowerPC V2.05 architecture.
4096
4097 @item dlmzb
4098 @itemx no-dlmzb
4099 @cindex @code{target("dlmzb")} attribute
4100 Generate code that uses (does not use) the string-search @samp{dlmzb}
4101 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4102 generated by default when targeting those processors.
4103
4104 @item fprnd
4105 @itemx no-fprnd
4106 @cindex @code{target("fprnd")} attribute
4107 Generate code that uses (does not use) the FP round to integer
4108 instructions implemented on the POWER5+ processor and other processors
4109 that support the PowerPC V2.03 architecture.
4110
4111 @item hard-dfp
4112 @itemx no-hard-dfp
4113 @cindex @code{target("hard-dfp")} attribute
4114 Generate code that uses (does not use) the decimal floating-point
4115 instructions implemented on some POWER processors.
4116
4117 @item isel
4118 @itemx no-isel
4119 @cindex @code{target("isel")} attribute
4120 Generate code that uses (does not use) ISEL instruction.
4121
4122 @item mfcrf
4123 @itemx no-mfcrf
4124 @cindex @code{target("mfcrf")} attribute
4125 Generate code that uses (does not use) the move from condition
4126 register field instruction implemented on the POWER4 processor and
4127 other processors that support the PowerPC V2.01 architecture.
4128
4129 @item mfpgpr
4130 @itemx no-mfpgpr
4131 @cindex @code{target("mfpgpr")} attribute
4132 Generate code that uses (does not use) the FP move to/from general
4133 purpose register instructions implemented on the POWER6X processor and
4134 other processors that support the extended PowerPC V2.05 architecture.
4135
4136 @item mulhw
4137 @itemx no-mulhw
4138 @cindex @code{target("mulhw")} attribute
4139 Generate code that uses (does not use) the half-word multiply and
4140 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4141 These instructions are generated by default when targeting those
4142 processors.
4143
4144 @item multiple
4145 @itemx no-multiple
4146 @cindex @code{target("multiple")} attribute
4147 Generate code that uses (does not use) the load multiple word
4148 instructions and the store multiple word instructions.
4149
4150 @item update
4151 @itemx no-update
4152 @cindex @code{target("update")} attribute
4153 Generate code that uses (does not use) the load or store instructions
4154 that update the base register to the address of the calculated memory
4155 location.
4156
4157 @item popcntb
4158 @itemx no-popcntb
4159 @cindex @code{target("popcntb")} attribute
4160 Generate code that uses (does not use) the popcount and double-precision
4161 FP reciprocal estimate instruction implemented on the POWER5
4162 processor and other processors that support the PowerPC V2.02
4163 architecture.
4164
4165 @item popcntd
4166 @itemx no-popcntd
4167 @cindex @code{target("popcntd")} attribute
4168 Generate code that uses (does not use) the popcount instruction
4169 implemented on the POWER7 processor and other processors that support
4170 the PowerPC V2.06 architecture.
4171
4172 @item powerpc-gfxopt
4173 @itemx no-powerpc-gfxopt
4174 @cindex @code{target("powerpc-gfxopt")} attribute
4175 Generate code that uses (does not use) the optional PowerPC
4176 architecture instructions in the Graphics group, including
4177 floating-point select.
4178
4179 @item powerpc-gpopt
4180 @itemx no-powerpc-gpopt
4181 @cindex @code{target("powerpc-gpopt")} attribute
4182 Generate code that uses (does not use) the optional PowerPC
4183 architecture instructions in the General Purpose group, including
4184 floating-point square root.
4185
4186 @item recip-precision
4187 @itemx no-recip-precision
4188 @cindex @code{target("recip-precision")} attribute
4189 Assume (do not assume) that the reciprocal estimate instructions
4190 provide higher-precision estimates than is mandated by the powerpc
4191 ABI.
4192
4193 @item string
4194 @itemx no-string
4195 @cindex @code{target("string")} attribute
4196 Generate code that uses (does not use) the load string instructions
4197 and the store string word instructions to save multiple registers and
4198 do small block moves.
4199
4200 @item vsx
4201 @itemx no-vsx
4202 @cindex @code{target("vsx")} attribute
4203 Generate code that uses (does not use) vector/scalar (VSX)
4204 instructions, and also enable the use of built-in functions that allow
4205 more direct access to the VSX instruction set. In 32-bit code, you
4206 cannot enable VSX or AltiVec instructions unless
4207 @option{-mabi=altivec} is used on the command line.
4208
4209 @item friz
4210 @itemx no-friz
4211 @cindex @code{target("friz")} attribute
4212 Generate (do not generate) the @code{friz} instruction when the
4213 @option{-funsafe-math-optimizations} option is used to optimize
4214 rounding a floating-point value to 64-bit integer and back to floating
4215 point. The @code{friz} instruction does not return the same value if
4216 the floating-point number is too large to fit in an integer.
4217
4218 @item avoid-indexed-addresses
4219 @itemx no-avoid-indexed-addresses
4220 @cindex @code{target("avoid-indexed-addresses")} attribute
4221 Generate code that tries to avoid (not avoid) the use of indexed load
4222 or store instructions.
4223
4224 @item paired
4225 @itemx no-paired
4226 @cindex @code{target("paired")} attribute
4227 Generate code that uses (does not use) the generation of PAIRED simd
4228 instructions.
4229
4230 @item longcall
4231 @itemx no-longcall
4232 @cindex @code{target("longcall")} attribute
4233 Generate code that assumes (does not assume) that all calls are far
4234 away so that a longer more expensive calling sequence is required.
4235
4236 @item cpu=@var{CPU}
4237 @cindex @code{target("cpu=@var{CPU}")} attribute
4238 Specify the architecture to generate code for when compiling the
4239 function. If you select the @code{target("cpu=power7")} attribute when
4240 generating 32-bit code, VSX and AltiVec instructions are not generated
4241 unless you use the @option{-mabi=altivec} option on the command line.
4242
4243 @item tune=@var{TUNE}
4244 @cindex @code{target("tune=@var{TUNE}")} attribute
4245 Specify the architecture to tune for when compiling the function. If
4246 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4247 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4248 compilation tunes for the @var{CPU} architecture, and not the
4249 default tuning specified on the command line.
4250 @end table
4251
4252 When compiling for Nios II, the following options are allowed:
4253
4254 @table @samp
4255 @item custom-@var{insn}=@var{N}
4256 @itemx no-custom-@var{insn}
4257 @cindex @code{target("custom-@var{insn}=@var{N}")} attribute
4258 @cindex @code{target("no-custom-@var{insn}")} attribute
4259 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4260 custom instruction with encoding @var{N} when generating code that uses
4261 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4262 the custom instruction @var{insn}.
4263 These target attributes correspond to the
4264 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4265 command-line options, and support the same set of @var{insn} keywords.
4266 @xref{Nios II Options}, for more information.
4267
4268 @item custom-fpu-cfg=@var{name}
4269 @cindex @code{target("custom-fpu-cfg=@var{name}")} attribute
4270 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4271 command-line option, to select a predefined set of custom instructions
4272 named @var{name}.
4273 @xref{Nios II Options}, for more information.
4274 @end table
4275
4276 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
4277 function that has different target options than the caller, unless the
4278 callee has a subset of the target options of the caller. For example
4279 a function declared with @code{target("sse3")} can inline a function
4280 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4281
4282 @item tiny_data
4283 @cindex tiny data section on the H8/300H and H8S
4284 Use this attribute on the H8/300H and H8S to indicate that the specified
4285 variable should be placed into the tiny data section.
4286 The compiler generates more efficient code for loads and stores
4287 on data in the tiny data section. Note the tiny data area is limited to
4288 slightly under 32KB of data.
4289
4290 @item trap_exit
4291 @cindex @code{trap_exit} attribute
4292 Use this attribute on the SH for an @code{interrupt_handler} to return using
4293 @code{trapa} instead of @code{rte}. This attribute expects an integer
4294 argument specifying the trap number to be used.
4295
4296 @item trapa_handler
4297 @cindex @code{trapa_handler} attribute
4298 On SH targets this function attribute is similar to @code{interrupt_handler}
4299 but it does not save and restore all registers.
4300
4301 @item unused
4302 @cindex @code{unused} attribute.
4303 This attribute, attached to a function, means that the function is meant
4304 to be possibly unused. GCC does not produce a warning for this
4305 function.
4306
4307 @item used
4308 @cindex @code{used} attribute.
4309 This attribute, attached to a function, means that code must be emitted
4310 for the function even if it appears that the function is not referenced.
4311 This is useful, for example, when the function is referenced only in
4312 inline assembly.
4313
4314 When applied to a member function of a C++ class template, the
4315 attribute also means that the function is instantiated if the
4316 class itself is instantiated.
4317
4318 @item vector
4319 @cindex @code{vector} attibute
4320 This RX attribute is similar to the @code{attribute}, including its
4321 parameters, but does not make the function an interrupt-handler type
4322 function (i.e. it retains the normal C function calling ABI). See the
4323 @code{interrupt} attribute for a description of its arguments.
4324
4325 @item version_id
4326 @cindex @code{version_id} attribute
4327 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4328 symbol to contain a version string, thus allowing for function level
4329 versioning. HP-UX system header files may use function level versioning
4330 for some system calls.
4331
4332 @smallexample
4333 extern int foo () __attribute__((version_id ("20040821")));
4334 @end smallexample
4335
4336 @noindent
4337 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4338
4339 @item visibility ("@var{visibility_type}")
4340 @cindex @code{visibility} attribute
4341 This attribute affects the linkage of the declaration to which it is attached.
4342 There are four supported @var{visibility_type} values: default,
4343 hidden, protected or internal visibility.
4344
4345 @smallexample
4346 void __attribute__ ((visibility ("protected")))
4347 f () @{ /* @r{Do something.} */; @}
4348 int i __attribute__ ((visibility ("hidden")));
4349 @end smallexample
4350
4351 The possible values of @var{visibility_type} correspond to the
4352 visibility settings in the ELF gABI.
4353
4354 @table @dfn
4355 @c keep this list of visibilities in alphabetical order.
4356
4357 @item default
4358 Default visibility is the normal case for the object file format.
4359 This value is available for the visibility attribute to override other
4360 options that may change the assumed visibility of entities.
4361
4362 On ELF, default visibility means that the declaration is visible to other
4363 modules and, in shared libraries, means that the declared entity may be
4364 overridden.
4365
4366 On Darwin, default visibility means that the declaration is visible to
4367 other modules.
4368
4369 Default visibility corresponds to ``external linkage'' in the language.
4370
4371 @item hidden
4372 Hidden visibility indicates that the entity declared has a new
4373 form of linkage, which we call ``hidden linkage''. Two
4374 declarations of an object with hidden linkage refer to the same object
4375 if they are in the same shared object.
4376
4377 @item internal
4378 Internal visibility is like hidden visibility, but with additional
4379 processor specific semantics. Unless otherwise specified by the
4380 psABI, GCC defines internal visibility to mean that a function is
4381 @emph{never} called from another module. Compare this with hidden
4382 functions which, while they cannot be referenced directly by other
4383 modules, can be referenced indirectly via function pointers. By
4384 indicating that a function cannot be called from outside the module,
4385 GCC may for instance omit the load of a PIC register since it is known
4386 that the calling function loaded the correct value.
4387
4388 @item protected
4389 Protected visibility is like default visibility except that it
4390 indicates that references within the defining module bind to the
4391 definition in that module. That is, the declared entity cannot be
4392 overridden by another module.
4393
4394 @end table
4395
4396 All visibilities are supported on many, but not all, ELF targets
4397 (supported when the assembler supports the @samp{.visibility}
4398 pseudo-op). Default visibility is supported everywhere. Hidden
4399 visibility is supported on Darwin targets.
4400
4401 The visibility attribute should be applied only to declarations that
4402 would otherwise have external linkage. The attribute should be applied
4403 consistently, so that the same entity should not be declared with
4404 different settings of the attribute.
4405
4406 In C++, the visibility attribute applies to types as well as functions
4407 and objects, because in C++ types have linkage. A class must not have
4408 greater visibility than its non-static data member types and bases,
4409 and class members default to the visibility of their class. Also, a
4410 declaration without explicit visibility is limited to the visibility
4411 of its type.
4412
4413 In C++, you can mark member functions and static member variables of a
4414 class with the visibility attribute. This is useful if you know a
4415 particular method or static member variable should only be used from
4416 one shared object; then you can mark it hidden while the rest of the
4417 class has default visibility. Care must be taken to avoid breaking
4418 the One Definition Rule; for example, it is usually not useful to mark
4419 an inline method as hidden without marking the whole class as hidden.
4420
4421 A C++ namespace declaration can also have the visibility attribute.
4422
4423 @smallexample
4424 namespace nspace1 __attribute__ ((visibility ("protected")))
4425 @{ /* @r{Do something.} */; @}
4426 @end smallexample
4427
4428 This attribute applies only to the particular namespace body, not to
4429 other definitions of the same namespace; it is equivalent to using
4430 @samp{#pragma GCC visibility} before and after the namespace
4431 definition (@pxref{Visibility Pragmas}).
4432
4433 In C++, if a template argument has limited visibility, this
4434 restriction is implicitly propagated to the template instantiation.
4435 Otherwise, template instantiations and specializations default to the
4436 visibility of their template.
4437
4438 If both the template and enclosing class have explicit visibility, the
4439 visibility from the template is used.
4440
4441 @item vliw
4442 @cindex @code{vliw} attribute
4443 On MeP, the @code{vliw} attribute tells the compiler to emit
4444 instructions in VLIW mode instead of core mode. Note that this
4445 attribute is not allowed unless a VLIW coprocessor has been configured
4446 and enabled through command-line options.
4447
4448 @item warn_unused_result
4449 @cindex @code{warn_unused_result} attribute
4450 The @code{warn_unused_result} attribute causes a warning to be emitted
4451 if a caller of the function with this attribute does not use its
4452 return value. This is useful for functions where not checking
4453 the result is either a security problem or always a bug, such as
4454 @code{realloc}.
4455
4456 @smallexample
4457 int fn () __attribute__ ((warn_unused_result));
4458 int foo ()
4459 @{
4460 if (fn () < 0) return -1;
4461 fn ();
4462 return 0;
4463 @}
4464 @end smallexample
4465
4466 @noindent
4467 results in warning on line 5.
4468
4469 @item weak
4470 @cindex @code{weak} attribute
4471 The @code{weak} attribute causes the declaration to be emitted as a weak
4472 symbol rather than a global. This is primarily useful in defining
4473 library functions that can be overridden in user code, though it can
4474 also be used with non-function declarations. Weak symbols are supported
4475 for ELF targets, and also for a.out targets when using the GNU assembler
4476 and linker.
4477
4478 @item weakref
4479 @itemx weakref ("@var{target}")
4480 @cindex @code{weakref} attribute
4481 The @code{weakref} attribute marks a declaration as a weak reference.
4482 Without arguments, it should be accompanied by an @code{alias} attribute
4483 naming the target symbol. Optionally, the @var{target} may be given as
4484 an argument to @code{weakref} itself. In either case, @code{weakref}
4485 implicitly marks the declaration as @code{weak}. Without a
4486 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4487 @code{weakref} is equivalent to @code{weak}.
4488
4489 @smallexample
4490 static int x() __attribute__ ((weakref ("y")));
4491 /* is equivalent to... */
4492 static int x() __attribute__ ((weak, weakref, alias ("y")));
4493 /* and to... */
4494 static int x() __attribute__ ((weakref));
4495 static int x() __attribute__ ((alias ("y")));
4496 @end smallexample
4497
4498 A weak reference is an alias that does not by itself require a
4499 definition to be given for the target symbol. If the target symbol is
4500 only referenced through weak references, then it becomes a @code{weak}
4501 undefined symbol. If it is directly referenced, however, then such
4502 strong references prevail, and a definition is required for the
4503 symbol, not necessarily in the same translation unit.
4504
4505 The effect is equivalent to moving all references to the alias to a
4506 separate translation unit, renaming the alias to the aliased symbol,
4507 declaring it as weak, compiling the two separate translation units and
4508 performing a reloadable link on them.
4509
4510 At present, a declaration to which @code{weakref} is attached can
4511 only be @code{static}.
4512
4513 @end table
4514
4515 You can specify multiple attributes in a declaration by separating them
4516 by commas within the double parentheses or by immediately following an
4517 attribute declaration with another attribute declaration.
4518
4519 @cindex @code{#pragma}, reason for not using
4520 @cindex pragma, reason for not using
4521 Some people object to the @code{__attribute__} feature, suggesting that
4522 ISO C's @code{#pragma} should be used instead. At the time
4523 @code{__attribute__} was designed, there were two reasons for not doing
4524 this.
4525
4526 @enumerate
4527 @item
4528 It is impossible to generate @code{#pragma} commands from a macro.
4529
4530 @item
4531 There is no telling what the same @code{#pragma} might mean in another
4532 compiler.
4533 @end enumerate
4534
4535 These two reasons applied to almost any application that might have been
4536 proposed for @code{#pragma}. It was basically a mistake to use
4537 @code{#pragma} for @emph{anything}.
4538
4539 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4540 to be generated from macros. In addition, a @code{#pragma GCC}
4541 namespace is now in use for GCC-specific pragmas. However, it has been
4542 found convenient to use @code{__attribute__} to achieve a natural
4543 attachment of attributes to their corresponding declarations, whereas
4544 @code{#pragma GCC} is of use for constructs that do not naturally form
4545 part of the grammar. @xref{Pragmas,,Pragmas Accepted by GCC}.
4546
4547 @node Label Attributes
4548 @section Label Attributes
4549 @cindex Label Attributes
4550
4551 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
4552 details of the exact syntax for using attributes. Other attributes are
4553 available for functions (@pxref{Function Attributes}), variables
4554 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
4555
4556 This example uses the @code{cold} label attribute to indicate the
4557 @code{ErrorHandling} branch is unlikely to be taken and that the
4558 @code{ErrorHandling} label is unused:
4559
4560 @smallexample
4561
4562 asm goto ("some asm" : : : : NoError);
4563
4564 /* This branch (the fallthru from the asm) is less commonly used */
4565 ErrorHandling:
4566 __attribute__((cold, unused)); /* Semi-colon is required here */
4567 printf("error\n");
4568 return 0;
4569
4570 NoError:
4571 printf("no error\n");
4572 return 1;
4573 @end smallexample
4574
4575 @table @code
4576 @item unused
4577 @cindex @code{unused} label attribute
4578 This feature is intended for program-generated code that may contain
4579 unused labels, but which is compiled with @option{-Wall}. It is
4580 not normally appropriate to use in it human-written code, though it
4581 could be useful in cases where the code that jumps to the label is
4582 contained within an @code{#ifdef} conditional.
4583
4584 @item hot
4585 @cindex @code{hot} label attribute
4586 The @code{hot} attribute on a label is used to inform the compiler that
4587 the path following the label is more likely than paths that are not so
4588 annotated. This attribute is used in cases where @code{__builtin_expect}
4589 cannot be used, for instance with computed goto or @code{asm goto}.
4590
4591 The @code{hot} attribute on labels is not implemented in GCC versions
4592 earlier than 4.8.
4593
4594 @item cold
4595 @cindex @code{cold} label attribute
4596 The @code{cold} attribute on labels is used to inform the compiler that
4597 the path following the label is unlikely to be executed. This attribute
4598 is used in cases where @code{__builtin_expect} cannot be used, for instance
4599 with computed goto or @code{asm goto}.
4600
4601 The @code{cold} attribute on labels is not implemented in GCC versions
4602 earlier than 4.8.
4603
4604 @end table
4605
4606 @node Attribute Syntax
4607 @section Attribute Syntax
4608 @cindex attribute syntax
4609
4610 This section describes the syntax with which @code{__attribute__} may be
4611 used, and the constructs to which attribute specifiers bind, for the C
4612 language. Some details may vary for C++ and Objective-C@. Because of
4613 infelicities in the grammar for attributes, some forms described here
4614 may not be successfully parsed in all cases.
4615
4616 There are some problems with the semantics of attributes in C++. For
4617 example, there are no manglings for attributes, although they may affect
4618 code generation, so problems may arise when attributed types are used in
4619 conjunction with templates or overloading. Similarly, @code{typeid}
4620 does not distinguish between types with different attributes. Support
4621 for attributes in C++ may be restricted in future to attributes on
4622 declarations only, but not on nested declarators.
4623
4624 @xref{Function Attributes}, for details of the semantics of attributes
4625 applying to functions. @xref{Variable Attributes}, for details of the
4626 semantics of attributes applying to variables. @xref{Type Attributes},
4627 for details of the semantics of attributes applying to structure, union
4628 and enumerated types.
4629 @xref{Label Attributes}, for details of the semantics of attributes
4630 applying to labels.
4631
4632 An @dfn{attribute specifier} is of the form
4633 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
4634 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4635 each attribute is one of the following:
4636
4637 @itemize @bullet
4638 @item
4639 Empty. Empty attributes are ignored.
4640
4641 @item
4642 A word (which may be an identifier such as @code{unused}, or a reserved
4643 word such as @code{const}).
4644
4645 @item
4646 A word, followed by, in parentheses, parameters for the attribute.
4647 These parameters take one of the following forms:
4648
4649 @itemize @bullet
4650 @item
4651 An identifier. For example, @code{mode} attributes use this form.
4652
4653 @item
4654 An identifier followed by a comma and a non-empty comma-separated list
4655 of expressions. For example, @code{format} attributes use this form.
4656
4657 @item
4658 A possibly empty comma-separated list of expressions. For example,
4659 @code{format_arg} attributes use this form with the list being a single
4660 integer constant expression, and @code{alias} attributes use this form
4661 with the list being a single string constant.
4662 @end itemize
4663 @end itemize
4664
4665 An @dfn{attribute specifier list} is a sequence of one or more attribute
4666 specifiers, not separated by any other tokens.
4667
4668 @subsubheading Label Attributes
4669
4670 In GNU C, an attribute specifier list may appear after the colon following a
4671 label, other than a @code{case} or @code{default} label. GNU C++ only permits
4672 attributes on labels if the attribute specifier is immediately
4673 followed by a semicolon (i.e., the label applies to an empty
4674 statement). If the semicolon is missing, C++ label attributes are
4675 ambiguous, as it is permissible for a declaration, which could begin
4676 with an attribute list, to be labelled in C++. Declarations cannot be
4677 labelled in C90 or C99, so the ambiguity does not arise there.
4678
4679 @subsubheading Type Attributes
4680
4681 An attribute specifier list may appear as part of a @code{struct},
4682 @code{union} or @code{enum} specifier. It may go either immediately
4683 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4684 the closing brace. The former syntax is preferred.
4685 Where attribute specifiers follow the closing brace, they are considered
4686 to relate to the structure, union or enumerated type defined, not to any
4687 enclosing declaration the type specifier appears in, and the type
4688 defined is not complete until after the attribute specifiers.
4689 @c Otherwise, there would be the following problems: a shift/reduce
4690 @c conflict between attributes binding the struct/union/enum and
4691 @c binding to the list of specifiers/qualifiers; and "aligned"
4692 @c attributes could use sizeof for the structure, but the size could be
4693 @c changed later by "packed" attributes.
4694
4695
4696 @subsubheading All other attributes
4697
4698 Otherwise, an attribute specifier appears as part of a declaration,
4699 counting declarations of unnamed parameters and type names, and relates
4700 to that declaration (which may be nested in another declaration, for
4701 example in the case of a parameter declaration), or to a particular declarator
4702 within a declaration. Where an
4703 attribute specifier is applied to a parameter declared as a function or
4704 an array, it should apply to the function or array rather than the
4705 pointer to which the parameter is implicitly converted, but this is not
4706 yet correctly implemented.
4707
4708 Any list of specifiers and qualifiers at the start of a declaration may
4709 contain attribute specifiers, whether or not such a list may in that
4710 context contain storage class specifiers. (Some attributes, however,
4711 are essentially in the nature of storage class specifiers, and only make
4712 sense where storage class specifiers may be used; for example,
4713 @code{section}.) There is one necessary limitation to this syntax: the
4714 first old-style parameter declaration in a function definition cannot
4715 begin with an attribute specifier, because such an attribute applies to
4716 the function instead by syntax described below (which, however, is not
4717 yet implemented in this case). In some other cases, attribute
4718 specifiers are permitted by this grammar but not yet supported by the
4719 compiler. All attribute specifiers in this place relate to the
4720 declaration as a whole. In the obsolescent usage where a type of
4721 @code{int} is implied by the absence of type specifiers, such a list of
4722 specifiers and qualifiers may be an attribute specifier list with no
4723 other specifiers or qualifiers.
4724
4725 At present, the first parameter in a function prototype must have some
4726 type specifier that is not an attribute specifier; this resolves an
4727 ambiguity in the interpretation of @code{void f(int
4728 (__attribute__((foo)) x))}, but is subject to change. At present, if
4729 the parentheses of a function declarator contain only attributes then
4730 those attributes are ignored, rather than yielding an error or warning
4731 or implying a single parameter of type int, but this is subject to
4732 change.
4733
4734 An attribute specifier list may appear immediately before a declarator
4735 (other than the first) in a comma-separated list of declarators in a
4736 declaration of more than one identifier using a single list of
4737 specifiers and qualifiers. Such attribute specifiers apply
4738 only to the identifier before whose declarator they appear. For
4739 example, in
4740
4741 @smallexample
4742 __attribute__((noreturn)) void d0 (void),
4743 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4744 d2 (void)
4745 @end smallexample
4746
4747 @noindent
4748 the @code{noreturn} attribute applies to all the functions
4749 declared; the @code{format} attribute only applies to @code{d1}.
4750
4751 An attribute specifier list may appear immediately before the comma,
4752 @code{=} or semicolon terminating the declaration of an identifier other
4753 than a function definition. Such attribute specifiers apply
4754 to the declared object or function. Where an
4755 assembler name for an object or function is specified (@pxref{Asm
4756 Labels}), the attribute must follow the @code{asm}
4757 specification.
4758
4759 An attribute specifier list may, in future, be permitted to appear after
4760 the declarator in a function definition (before any old-style parameter
4761 declarations or the function body).
4762
4763 Attribute specifiers may be mixed with type qualifiers appearing inside
4764 the @code{[]} of a parameter array declarator, in the C99 construct by
4765 which such qualifiers are applied to the pointer to which the array is
4766 implicitly converted. Such attribute specifiers apply to the pointer,
4767 not to the array, but at present this is not implemented and they are
4768 ignored.
4769
4770 An attribute specifier list may appear at the start of a nested
4771 declarator. At present, there are some limitations in this usage: the
4772 attributes correctly apply to the declarator, but for most individual
4773 attributes the semantics this implies are not implemented.
4774 When attribute specifiers follow the @code{*} of a pointer
4775 declarator, they may be mixed with any type qualifiers present.
4776 The following describes the formal semantics of this syntax. It makes the
4777 most sense if you are familiar with the formal specification of
4778 declarators in the ISO C standard.
4779
4780 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4781 D1}, where @code{T} contains declaration specifiers that specify a type
4782 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4783 contains an identifier @var{ident}. The type specified for @var{ident}
4784 for derived declarators whose type does not include an attribute
4785 specifier is as in the ISO C standard.
4786
4787 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4788 and the declaration @code{T D} specifies the type
4789 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4790 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4791 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4792
4793 If @code{D1} has the form @code{*
4794 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4795 declaration @code{T D} specifies the type
4796 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4797 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4798 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4799 @var{ident}.
4800
4801 For example,
4802
4803 @smallexample
4804 void (__attribute__((noreturn)) ****f) (void);
4805 @end smallexample
4806
4807 @noindent
4808 specifies the type ``pointer to pointer to pointer to pointer to
4809 non-returning function returning @code{void}''. As another example,
4810
4811 @smallexample
4812 char *__attribute__((aligned(8))) *f;
4813 @end smallexample
4814
4815 @noindent
4816 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4817 Note again that this does not work with most attributes; for example,
4818 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4819 is not yet supported.
4820
4821 For compatibility with existing code written for compiler versions that
4822 did not implement attributes on nested declarators, some laxity is
4823 allowed in the placing of attributes. If an attribute that only applies
4824 to types is applied to a declaration, it is treated as applying to
4825 the type of that declaration. If an attribute that only applies to
4826 declarations is applied to the type of a declaration, it is treated
4827 as applying to that declaration; and, for compatibility with code
4828 placing the attributes immediately before the identifier declared, such
4829 an attribute applied to a function return type is treated as
4830 applying to the function type, and such an attribute applied to an array
4831 element type is treated as applying to the array type. If an
4832 attribute that only applies to function types is applied to a
4833 pointer-to-function type, it is treated as applying to the pointer
4834 target type; if such an attribute is applied to a function return type
4835 that is not a pointer-to-function type, it is treated as applying
4836 to the function type.
4837
4838 @node Function Prototypes
4839 @section Prototypes and Old-Style Function Definitions
4840 @cindex function prototype declarations
4841 @cindex old-style function definitions
4842 @cindex promotion of formal parameters
4843
4844 GNU C extends ISO C to allow a function prototype to override a later
4845 old-style non-prototype definition. Consider the following example:
4846
4847 @smallexample
4848 /* @r{Use prototypes unless the compiler is old-fashioned.} */
4849 #ifdef __STDC__
4850 #define P(x) x
4851 #else
4852 #define P(x) ()
4853 #endif
4854
4855 /* @r{Prototype function declaration.} */
4856 int isroot P((uid_t));
4857
4858 /* @r{Old-style function definition.} */
4859 int
4860 isroot (x) /* @r{??? lossage here ???} */
4861 uid_t x;
4862 @{
4863 return x == 0;
4864 @}
4865 @end smallexample
4866
4867 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
4868 not allow this example, because subword arguments in old-style
4869 non-prototype definitions are promoted. Therefore in this example the
4870 function definition's argument is really an @code{int}, which does not
4871 match the prototype argument type of @code{short}.
4872
4873 This restriction of ISO C makes it hard to write code that is portable
4874 to traditional C compilers, because the programmer does not know
4875 whether the @code{uid_t} type is @code{short}, @code{int}, or
4876 @code{long}. Therefore, in cases like these GNU C allows a prototype
4877 to override a later old-style definition. More precisely, in GNU C, a
4878 function prototype argument type overrides the argument type specified
4879 by a later old-style definition if the former type is the same as the
4880 latter type before promotion. Thus in GNU C the above example is
4881 equivalent to the following:
4882
4883 @smallexample
4884 int isroot (uid_t);
4885
4886 int
4887 isroot (uid_t x)
4888 @{
4889 return x == 0;
4890 @}
4891 @end smallexample
4892
4893 @noindent
4894 GNU C++ does not support old-style function definitions, so this
4895 extension is irrelevant.
4896
4897 @node C++ Comments
4898 @section C++ Style Comments
4899 @cindex @code{//}
4900 @cindex C++ comments
4901 @cindex comments, C++ style
4902
4903 In GNU C, you may use C++ style comments, which start with @samp{//} and
4904 continue until the end of the line. Many other C implementations allow
4905 such comments, and they are included in the 1999 C standard. However,
4906 C++ style comments are not recognized if you specify an @option{-std}
4907 option specifying a version of ISO C before C99, or @option{-ansi}
4908 (equivalent to @option{-std=c90}).
4909
4910 @node Dollar Signs
4911 @section Dollar Signs in Identifier Names
4912 @cindex $
4913 @cindex dollar signs in identifier names
4914 @cindex identifier names, dollar signs in
4915
4916 In GNU C, you may normally use dollar signs in identifier names.
4917 This is because many traditional C implementations allow such identifiers.
4918 However, dollar signs in identifiers are not supported on a few target
4919 machines, typically because the target assembler does not allow them.
4920
4921 @node Character Escapes
4922 @section The Character @key{ESC} in Constants
4923
4924 You can use the sequence @samp{\e} in a string or character constant to
4925 stand for the ASCII character @key{ESC}.
4926
4927 @node Variable Attributes
4928 @section Specifying Attributes of Variables
4929 @cindex attribute of variables
4930 @cindex variable attributes
4931
4932 The keyword @code{__attribute__} allows you to specify special
4933 attributes of variables or structure fields. This keyword is followed
4934 by an attribute specification inside double parentheses. Some
4935 attributes are currently defined generically for variables.
4936 Other attributes are defined for variables on particular target
4937 systems. Other attributes are available for functions
4938 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for
4939 types (@pxref{Type Attributes}).
4940 Other front ends might define more attributes
4941 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4942
4943 You may also specify attributes with @samp{__} preceding and following
4944 each keyword. This allows you to use them in header files without
4945 being concerned about a possible macro of the same name. For example,
4946 you may use @code{__aligned__} instead of @code{aligned}.
4947
4948 @xref{Attribute Syntax}, for details of the exact syntax for using
4949 attributes.
4950
4951 @table @code
4952 @cindex @code{aligned} attribute
4953 @item aligned (@var{alignment})
4954 This attribute specifies a minimum alignment for the variable or
4955 structure field, measured in bytes. For example, the declaration:
4956
4957 @smallexample
4958 int x __attribute__ ((aligned (16))) = 0;
4959 @end smallexample
4960
4961 @noindent
4962 causes the compiler to allocate the global variable @code{x} on a
4963 16-byte boundary. On a 68040, this could be used in conjunction with
4964 an @code{asm} expression to access the @code{move16} instruction which
4965 requires 16-byte aligned operands.
4966
4967 You can also specify the alignment of structure fields. For example, to
4968 create a double-word aligned @code{int} pair, you could write:
4969
4970 @smallexample
4971 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
4972 @end smallexample
4973
4974 @noindent
4975 This is an alternative to creating a union with a @code{double} member,
4976 which forces the union to be double-word aligned.
4977
4978 As in the preceding examples, you can explicitly specify the alignment
4979 (in bytes) that you wish the compiler to use for a given variable or
4980 structure field. Alternatively, you can leave out the alignment factor
4981 and just ask the compiler to align a variable or field to the
4982 default alignment for the target architecture you are compiling for.
4983 The default alignment is sufficient for all scalar types, but may not be
4984 enough for all vector types on a target that supports vector operations.
4985 The default alignment is fixed for a particular target ABI.
4986
4987 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
4988 which is the largest alignment ever used for any data type on the
4989 target machine you are compiling for. For example, you could write:
4990
4991 @smallexample
4992 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
4993 @end smallexample
4994
4995 The compiler automatically sets the alignment for the declared
4996 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
4997 often make copy operations more efficient, because the compiler can
4998 use whatever instructions copy the biggest chunks of memory when
4999 performing copies to or from the variables or fields that you have
5000 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5001 may change depending on command-line options.
5002
5003 When used on a struct, or struct member, the @code{aligned} attribute can
5004 only increase the alignment; in order to decrease it, the @code{packed}
5005 attribute must be specified as well. When used as part of a typedef, the
5006 @code{aligned} attribute can both increase and decrease alignment, and
5007 specifying the @code{packed} attribute generates a warning.
5008
5009 Note that the effectiveness of @code{aligned} attributes may be limited
5010 by inherent limitations in your linker. On many systems, the linker is
5011 only able to arrange for variables to be aligned up to a certain maximum
5012 alignment. (For some linkers, the maximum supported alignment may
5013 be very very small.) If your linker is only able to align variables
5014 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5015 in an @code{__attribute__} still only provides you with 8-byte
5016 alignment. See your linker documentation for further information.
5017
5018 The @code{aligned} attribute can also be used for functions
5019 (@pxref{Function Attributes}.)
5020
5021 @item cleanup (@var{cleanup_function})
5022 @cindex @code{cleanup} attribute
5023 The @code{cleanup} attribute runs a function when the variable goes
5024 out of scope. This attribute can only be applied to auto function
5025 scope variables; it may not be applied to parameters or variables
5026 with static storage duration. The function must take one parameter,
5027 a pointer to a type compatible with the variable. The return value
5028 of the function (if any) is ignored.
5029
5030 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5031 is run during the stack unwinding that happens during the
5032 processing of the exception. Note that the @code{cleanup} attribute
5033 does not allow the exception to be caught, only to perform an action.
5034 It is undefined what happens if @var{cleanup_function} does not
5035 return normally.
5036
5037 @item common
5038 @itemx nocommon
5039 @cindex @code{common} attribute
5040 @cindex @code{nocommon} attribute
5041 @opindex fcommon
5042 @opindex fno-common
5043 The @code{common} attribute requests GCC to place a variable in
5044 ``common'' storage. The @code{nocommon} attribute requests the
5045 opposite---to allocate space for it directly.
5046
5047 These attributes override the default chosen by the
5048 @option{-fno-common} and @option{-fcommon} flags respectively.
5049
5050 @item deprecated
5051 @itemx deprecated (@var{msg})
5052 @cindex @code{deprecated} attribute
5053 The @code{deprecated} attribute results in a warning if the variable
5054 is used anywhere in the source file. This is useful when identifying
5055 variables that are expected to be removed in a future version of a
5056 program. The warning also includes the location of the declaration
5057 of the deprecated variable, to enable users to easily find further
5058 information about why the variable is deprecated, or what they should
5059 do instead. Note that the warning only occurs for uses:
5060
5061 @smallexample
5062 extern int old_var __attribute__ ((deprecated));
5063 extern int old_var;
5064 int new_fn () @{ return old_var; @}
5065 @end smallexample
5066
5067 @noindent
5068 results in a warning on line 3 but not line 2. The optional @var{msg}
5069 argument, which must be a string, is printed in the warning if
5070 present.
5071
5072 The @code{deprecated} attribute can also be used for functions and
5073 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
5074
5075 @item mode (@var{mode})
5076 @cindex @code{mode} attribute
5077 This attribute specifies the data type for the declaration---whichever
5078 type corresponds to the mode @var{mode}. This in effect lets you
5079 request an integer or floating-point type according to its width.
5080
5081 You may also specify a mode of @code{byte} or @code{__byte__} to
5082 indicate the mode corresponding to a one-byte integer, @code{word} or
5083 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5084 or @code{__pointer__} for the mode used to represent pointers.
5085
5086 @item packed
5087 @cindex @code{packed} attribute
5088 The @code{packed} attribute specifies that a variable or structure field
5089 should have the smallest possible alignment---one byte for a variable,
5090 and one bit for a field, unless you specify a larger value with the
5091 @code{aligned} attribute.
5092
5093 Here is a structure in which the field @code{x} is packed, so that it
5094 immediately follows @code{a}:
5095
5096 @smallexample
5097 struct foo
5098 @{
5099 char a;
5100 int x[2] __attribute__ ((packed));
5101 @};
5102 @end smallexample
5103
5104 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5105 @code{packed} attribute on bit-fields of type @code{char}. This has
5106 been fixed in GCC 4.4 but the change can lead to differences in the
5107 structure layout. See the documentation of
5108 @option{-Wpacked-bitfield-compat} for more information.
5109
5110 @item section ("@var{section-name}")
5111 @cindex @code{section} variable attribute
5112 Normally, the compiler places the objects it generates in sections like
5113 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5114 or you need certain particular variables to appear in special sections,
5115 for example to map to special hardware. The @code{section}
5116 attribute specifies that a variable (or function) lives in a particular
5117 section. For example, this small program uses several specific section names:
5118
5119 @smallexample
5120 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5121 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5122 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5123 int init_data __attribute__ ((section ("INITDATA")));
5124
5125 main()
5126 @{
5127 /* @r{Initialize stack pointer} */
5128 init_sp (stack + sizeof (stack));
5129
5130 /* @r{Initialize initialized data} */
5131 memcpy (&init_data, &data, &edata - &data);
5132
5133 /* @r{Turn on the serial ports} */
5134 init_duart (&a);
5135 init_duart (&b);
5136 @}
5137 @end smallexample
5138
5139 @noindent
5140 Use the @code{section} attribute with
5141 @emph{global} variables and not @emph{local} variables,
5142 as shown in the example.
5143
5144 You may use the @code{section} attribute with initialized or
5145 uninitialized global variables but the linker requires
5146 each object be defined once, with the exception that uninitialized
5147 variables tentatively go in the @code{common} (or @code{bss}) section
5148 and can be multiply ``defined''. Using the @code{section} attribute
5149 changes what section the variable goes into and may cause the
5150 linker to issue an error if an uninitialized variable has multiple
5151 definitions. You can force a variable to be initialized with the
5152 @option{-fno-common} flag or the @code{nocommon} attribute.
5153
5154 Some file formats do not support arbitrary sections so the @code{section}
5155 attribute is not available on all platforms.
5156 If you need to map the entire contents of a module to a particular
5157 section, consider using the facilities of the linker instead.
5158
5159 @item shared
5160 @cindex @code{shared} variable attribute
5161 On Microsoft Windows, in addition to putting variable definitions in a named
5162 section, the section can also be shared among all running copies of an
5163 executable or DLL@. For example, this small program defines shared data
5164 by putting it in a named section @code{shared} and marking the section
5165 shareable:
5166
5167 @smallexample
5168 int foo __attribute__((section ("shared"), shared)) = 0;
5169
5170 int
5171 main()
5172 @{
5173 /* @r{Read and write foo. All running
5174 copies see the same value.} */
5175 return 0;
5176 @}
5177 @end smallexample
5178
5179 @noindent
5180 You may only use the @code{shared} attribute along with @code{section}
5181 attribute with a fully-initialized global definition because of the way
5182 linkers work. See @code{section} attribute for more information.
5183
5184 The @code{shared} attribute is only available on Microsoft Windows@.
5185
5186 @item tls_model ("@var{tls_model}")
5187 @cindex @code{tls_model} attribute
5188 The @code{tls_model} attribute sets thread-local storage model
5189 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5190 overriding @option{-ftls-model=} command-line switch on a per-variable
5191 basis.
5192 The @var{tls_model} argument should be one of @code{global-dynamic},
5193 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5194
5195 Not all targets support this attribute.
5196
5197 @item unused
5198 This attribute, attached to a variable, means that the variable is meant
5199 to be possibly unused. GCC does not produce a warning for this
5200 variable.
5201
5202 @item used
5203 This attribute, attached to a variable with the static storage, means that
5204 the variable must be emitted even if it appears that the variable is not
5205 referenced.
5206
5207 When applied to a static data member of a C++ class template, the
5208 attribute also means that the member is instantiated if the
5209 class itself is instantiated.
5210
5211 @item vector_size (@var{bytes})
5212 This attribute specifies the vector size for the variable, measured in
5213 bytes. For example, the declaration:
5214
5215 @smallexample
5216 int foo __attribute__ ((vector_size (16)));
5217 @end smallexample
5218
5219 @noindent
5220 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5221 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5222 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5223
5224 This attribute is only applicable to integral and float scalars,
5225 although arrays, pointers, and function return values are allowed in
5226 conjunction with this construct.
5227
5228 Aggregates with this attribute are invalid, even if they are of the same
5229 size as a corresponding scalar. For example, the declaration:
5230
5231 @smallexample
5232 struct S @{ int a; @};
5233 struct S __attribute__ ((vector_size (16))) foo;
5234 @end smallexample
5235
5236 @noindent
5237 is invalid even if the size of the structure is the same as the size of
5238 the @code{int}.
5239
5240 @item selectany
5241 The @code{selectany} attribute causes an initialized global variable to
5242 have link-once semantics. When multiple definitions of the variable are
5243 encountered by the linker, the first is selected and the remainder are
5244 discarded. Following usage by the Microsoft compiler, the linker is told
5245 @emph{not} to warn about size or content differences of the multiple
5246 definitions.
5247
5248 Although the primary usage of this attribute is for POD types, the
5249 attribute can also be applied to global C++ objects that are initialized
5250 by a constructor. In this case, the static initialization and destruction
5251 code for the object is emitted in each translation defining the object,
5252 but the calls to the constructor and destructor are protected by a
5253 link-once guard variable.
5254
5255 The @code{selectany} attribute is only available on Microsoft Windows
5256 targets. You can use @code{__declspec (selectany)} as a synonym for
5257 @code{__attribute__ ((selectany))} for compatibility with other
5258 compilers.
5259
5260 @item weak
5261 The @code{weak} attribute is described in @ref{Function Attributes}.
5262
5263 @item dllimport
5264 The @code{dllimport} attribute is described in @ref{Function Attributes}.
5265
5266 @item dllexport
5267 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5268
5269 @end table
5270
5271 @anchor{AVR Variable Attributes}
5272 @subsection AVR Variable Attributes
5273
5274 @table @code
5275 @item progmem
5276 @cindex @code{progmem} AVR variable attribute
5277 The @code{progmem} attribute is used on the AVR to place read-only
5278 data in the non-volatile program memory (flash). The @code{progmem}
5279 attribute accomplishes this by putting respective variables into a
5280 section whose name starts with @code{.progmem}.
5281
5282 This attribute works similar to the @code{section} attribute
5283 but adds additional checking. Notice that just like the
5284 @code{section} attribute, @code{progmem} affects the location
5285 of the data but not how this data is accessed.
5286
5287 In order to read data located with the @code{progmem} attribute
5288 (inline) assembler must be used.
5289 @smallexample
5290 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5291 #include <avr/pgmspace.h>
5292
5293 /* Locate var in flash memory */
5294 const int var[2] PROGMEM = @{ 1, 2 @};
5295
5296 int read_var (int i)
5297 @{
5298 /* Access var[] by accessor macro from avr/pgmspace.h */
5299 return (int) pgm_read_word (& var[i]);
5300 @}
5301 @end smallexample
5302
5303 AVR is a Harvard architecture processor and data and read-only data
5304 normally resides in the data memory (RAM).
5305
5306 See also the @ref{AVR Named Address Spaces} section for
5307 an alternate way to locate and access data in flash memory.
5308 @end table
5309
5310 @subsection Blackfin Variable Attributes
5311
5312 Three attributes are currently defined for the Blackfin.
5313
5314 @table @code
5315 @item l1_data
5316 @itemx l1_data_A
5317 @itemx l1_data_B
5318 @cindex @code{l1_data} variable attribute
5319 @cindex @code{l1_data_A} variable attribute
5320 @cindex @code{l1_data_B} variable attribute
5321 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5322 Variables with @code{l1_data} attribute are put into the specific section
5323 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5324 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5325 attribute are put into the specific section named @code{.l1.data.B}.
5326
5327 @item l2
5328 @cindex @code{l2} variable attribute
5329 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5330 Variables with @code{l2} attribute are put into the specific section
5331 named @code{.l2.data}.
5332 @end table
5333
5334 @subsection M32R/D Variable Attributes
5335
5336 One attribute is currently defined for the M32R/D@.
5337
5338 @table @code
5339 @item model (@var{model-name})
5340 @cindex variable addressability on the M32R/D
5341 Use this attribute on the M32R/D to set the addressability of an object.
5342 The identifier @var{model-name} is one of @code{small}, @code{medium},
5343 or @code{large}, representing each of the code models.
5344
5345 Small model objects live in the lower 16MB of memory (so that their
5346 addresses can be loaded with the @code{ld24} instruction).
5347
5348 Medium and large model objects may live anywhere in the 32-bit address space
5349 (the compiler generates @code{seth/add3} instructions to load their
5350 addresses).
5351 @end table
5352
5353 @anchor{MeP Variable Attributes}
5354 @subsection MeP Variable Attributes
5355
5356 The MeP target has a number of addressing modes and busses. The
5357 @code{near} space spans the standard memory space's first 16 megabytes
5358 (24 bits). The @code{far} space spans the entire 32-bit memory space.
5359 The @code{based} space is a 128-byte region in the memory space that
5360 is addressed relative to the @code{$tp} register. The @code{tiny}
5361 space is a 65536-byte region relative to the @code{$gp} register. In
5362 addition to these memory regions, the MeP target has a separate 16-bit
5363 control bus which is specified with @code{cb} attributes.
5364
5365 @table @code
5366
5367 @item based
5368 Any variable with the @code{based} attribute is assigned to the
5369 @code{.based} section, and is accessed with relative to the
5370 @code{$tp} register.
5371
5372 @item tiny
5373 Likewise, the @code{tiny} attribute assigned variables to the
5374 @code{.tiny} section, relative to the @code{$gp} register.
5375
5376 @item near
5377 Variables with the @code{near} attribute are assumed to have addresses
5378 that fit in a 24-bit addressing mode. This is the default for large
5379 variables (@code{-mtiny=4} is the default) but this attribute can
5380 override @code{-mtiny=} for small variables, or override @code{-ml}.
5381
5382 @item far
5383 Variables with the @code{far} attribute are addressed using a full
5384 32-bit address. Since this covers the entire memory space, this
5385 allows modules to make no assumptions about where variables might be
5386 stored.
5387
5388 @item io
5389 @itemx io (@var{addr})
5390 Variables with the @code{io} attribute are used to address
5391 memory-mapped peripherals. If an address is specified, the variable
5392 is assigned that address, else it is not assigned an address (it is
5393 assumed some other module assigns an address). Example:
5394
5395 @smallexample
5396 int timer_count __attribute__((io(0x123)));
5397 @end smallexample
5398
5399 @item cb
5400 @itemx cb (@var{addr})
5401 Variables with the @code{cb} attribute are used to access the control
5402 bus, using special instructions. @code{addr} indicates the control bus
5403 address. Example:
5404
5405 @smallexample
5406 int cpu_clock __attribute__((cb(0x123)));
5407 @end smallexample
5408
5409 @end table
5410
5411 @anchor{i386 Variable Attributes}
5412 @subsection i386 Variable Attributes
5413
5414 Two attributes are currently defined for i386 configurations:
5415 @code{ms_struct} and @code{gcc_struct}
5416
5417 @table @code
5418 @item ms_struct
5419 @itemx gcc_struct
5420 @cindex @code{ms_struct} attribute
5421 @cindex @code{gcc_struct} attribute
5422
5423 If @code{packed} is used on a structure, or if bit-fields are used,
5424 it may be that the Microsoft ABI lays out the structure differently
5425 than the way GCC normally does. Particularly when moving packed
5426 data between functions compiled with GCC and the native Microsoft compiler
5427 (either via function call or as data in a file), it may be necessary to access
5428 either format.
5429
5430 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5431 compilers to match the native Microsoft compiler.
5432
5433 The Microsoft structure layout algorithm is fairly simple with the exception
5434 of the bit-field packing.
5435 The padding and alignment of members of structures and whether a bit-field
5436 can straddle a storage-unit boundary are determine by these rules:
5437
5438 @enumerate
5439 @item Structure members are stored sequentially in the order in which they are
5440 declared: the first member has the lowest memory address and the last member
5441 the highest.
5442
5443 @item Every data object has an alignment requirement. The alignment requirement
5444 for all data except structures, unions, and arrays is either the size of the
5445 object or the current packing size (specified with either the
5446 @code{aligned} attribute or the @code{pack} pragma),
5447 whichever is less. For structures, unions, and arrays,
5448 the alignment requirement is the largest alignment requirement of its members.
5449 Every object is allocated an offset so that:
5450
5451 @smallexample
5452 offset % alignment_requirement == 0
5453 @end smallexample
5454
5455 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5456 unit if the integral types are the same size and if the next bit-field fits
5457 into the current allocation unit without crossing the boundary imposed by the
5458 common alignment requirements of the bit-fields.
5459 @end enumerate
5460
5461 MSVC interprets zero-length bit-fields in the following ways:
5462
5463 @enumerate
5464 @item If a zero-length bit-field is inserted between two bit-fields that
5465 are normally coalesced, the bit-fields are not coalesced.
5466
5467 For example:
5468
5469 @smallexample
5470 struct
5471 @{
5472 unsigned long bf_1 : 12;
5473 unsigned long : 0;
5474 unsigned long bf_2 : 12;
5475 @} t1;
5476 @end smallexample
5477
5478 @noindent
5479 The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
5480 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5481
5482 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5483 alignment of the zero-length bit-field is greater than the member that follows it,
5484 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5485
5486 For example:
5487
5488 @smallexample
5489 struct
5490 @{
5491 char foo : 4;
5492 short : 0;
5493 char bar;
5494 @} t2;
5495
5496 struct
5497 @{
5498 char foo : 4;
5499 short : 0;
5500 double bar;
5501 @} t3;
5502 @end smallexample
5503
5504 @noindent
5505 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5506 Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
5507 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5508 of the structure.
5509
5510 Taking this into account, it is important to note the following:
5511
5512 @enumerate
5513 @item If a zero-length bit-field follows a normal bit-field, the type of the
5514 zero-length bit-field may affect the alignment of the structure as whole. For
5515 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5516 normal bit-field, and is of type short.
5517
5518 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5519 still affect the alignment of the structure:
5520
5521 @smallexample
5522 struct
5523 @{
5524 char foo : 6;
5525 long : 0;
5526 @} t4;
5527 @end smallexample
5528
5529 @noindent
5530 Here, @code{t4} takes up 4 bytes.
5531 @end enumerate
5532
5533 @item Zero-length bit-fields following non-bit-field members are ignored:
5534
5535 @smallexample
5536 struct
5537 @{
5538 char foo;
5539 long : 0;
5540 char bar;
5541 @} t5;
5542 @end smallexample
5543
5544 @noindent
5545 Here, @code{t5} takes up 2 bytes.
5546 @end enumerate
5547 @end table
5548
5549 @subsection PowerPC Variable Attributes
5550
5551 Three attributes currently are defined for PowerPC configurations:
5552 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5553
5554 For full documentation of the struct attributes please see the
5555 documentation in @ref{i386 Variable Attributes}.
5556
5557 For documentation of @code{altivec} attribute please see the
5558 documentation in @ref{PowerPC Type Attributes}.
5559
5560 @subsection SPU Variable Attributes
5561
5562 The SPU supports the @code{spu_vector} attribute for variables. For
5563 documentation of this attribute please see the documentation in
5564 @ref{SPU Type Attributes}.
5565
5566 @subsection Xstormy16 Variable Attributes
5567
5568 One attribute is currently defined for xstormy16 configurations:
5569 @code{below100}.
5570
5571 @table @code
5572 @item below100
5573 @cindex @code{below100} attribute
5574
5575 If a variable has the @code{below100} attribute (@code{BELOW100} is
5576 allowed also), GCC places the variable in the first 0x100 bytes of
5577 memory and use special opcodes to access it. Such variables are
5578 placed in either the @code{.bss_below100} section or the
5579 @code{.data_below100} section.
5580
5581 @end table
5582
5583 @node Type Attributes
5584 @section Specifying Attributes of Types
5585 @cindex attribute of types
5586 @cindex type attributes
5587
5588 The keyword @code{__attribute__} allows you to specify special
5589 attributes of @code{struct} and @code{union} types when you define
5590 such types. This keyword is followed by an attribute specification
5591 inside double parentheses. Seven attributes are currently defined for
5592 types: @code{aligned}, @code{packed}, @code{transparent_union},
5593 @code{unused}, @code{deprecated}, @code{visibility}, and
5594 @code{may_alias}. Other attributes are defined for functions
5595 (@pxref{Function Attributes}), labels (@pxref{Label
5596 Attributes}) and for variables (@pxref{Variable Attributes}).
5597
5598 You may also specify any one of these attributes with @samp{__}
5599 preceding and following its keyword. This allows you to use these
5600 attributes in header files without being concerned about a possible
5601 macro of the same name. For example, you may use @code{__aligned__}
5602 instead of @code{aligned}.
5603
5604 You may specify type attributes in an enum, struct or union type
5605 declaration or definition, or for other types in a @code{typedef}
5606 declaration.
5607
5608 For an enum, struct or union type, you may specify attributes either
5609 between the enum, struct or union tag and the name of the type, or
5610 just past the closing curly brace of the @emph{definition}. The
5611 former syntax is preferred.
5612
5613 @xref{Attribute Syntax}, for details of the exact syntax for using
5614 attributes.
5615
5616 @table @code
5617 @cindex @code{aligned} attribute
5618 @item aligned (@var{alignment})
5619 This attribute specifies a minimum alignment (in bytes) for variables
5620 of the specified type. For example, the declarations:
5621
5622 @smallexample
5623 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5624 typedef int more_aligned_int __attribute__ ((aligned (8)));
5625 @end smallexample
5626
5627 @noindent
5628 force the compiler to ensure (as far as it can) that each variable whose
5629 type is @code{struct S} or @code{more_aligned_int} is allocated and
5630 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
5631 variables of type @code{struct S} aligned to 8-byte boundaries allows
5632 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5633 store) instructions when copying one variable of type @code{struct S} to
5634 another, thus improving run-time efficiency.
5635
5636 Note that the alignment of any given @code{struct} or @code{union} type
5637 is required by the ISO C standard to be at least a perfect multiple of
5638 the lowest common multiple of the alignments of all of the members of
5639 the @code{struct} or @code{union} in question. This means that you @emph{can}
5640 effectively adjust the alignment of a @code{struct} or @code{union}
5641 type by attaching an @code{aligned} attribute to any one of the members
5642 of such a type, but the notation illustrated in the example above is a
5643 more obvious, intuitive, and readable way to request the compiler to
5644 adjust the alignment of an entire @code{struct} or @code{union} type.
5645
5646 As in the preceding example, you can explicitly specify the alignment
5647 (in bytes) that you wish the compiler to use for a given @code{struct}
5648 or @code{union} type. Alternatively, you can leave out the alignment factor
5649 and just ask the compiler to align a type to the maximum
5650 useful alignment for the target machine you are compiling for. For
5651 example, you could write:
5652
5653 @smallexample
5654 struct S @{ short f[3]; @} __attribute__ ((aligned));
5655 @end smallexample
5656
5657 Whenever you leave out the alignment factor in an @code{aligned}
5658 attribute specification, the compiler automatically sets the alignment
5659 for the type to the largest alignment that is ever used for any data
5660 type on the target machine you are compiling for. Doing this can often
5661 make copy operations more efficient, because the compiler can use
5662 whatever instructions copy the biggest chunks of memory when performing
5663 copies to or from the variables that have types that you have aligned
5664 this way.
5665
5666 In the example above, if the size of each @code{short} is 2 bytes, then
5667 the size of the entire @code{struct S} type is 6 bytes. The smallest
5668 power of two that is greater than or equal to that is 8, so the
5669 compiler sets the alignment for the entire @code{struct S} type to 8
5670 bytes.
5671
5672 Note that although you can ask the compiler to select a time-efficient
5673 alignment for a given type and then declare only individual stand-alone
5674 objects of that type, the compiler's ability to select a time-efficient
5675 alignment is primarily useful only when you plan to create arrays of
5676 variables having the relevant (efficiently aligned) type. If you
5677 declare or use arrays of variables of an efficiently-aligned type, then
5678 it is likely that your program also does pointer arithmetic (or
5679 subscripting, which amounts to the same thing) on pointers to the
5680 relevant type, and the code that the compiler generates for these
5681 pointer arithmetic operations is often more efficient for
5682 efficiently-aligned types than for other types.
5683
5684 The @code{aligned} attribute can only increase the alignment; but you
5685 can decrease it by specifying @code{packed} as well. See below.
5686
5687 Note that the effectiveness of @code{aligned} attributes may be limited
5688 by inherent limitations in your linker. On many systems, the linker is
5689 only able to arrange for variables to be aligned up to a certain maximum
5690 alignment. (For some linkers, the maximum supported alignment may
5691 be very very small.) If your linker is only able to align variables
5692 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5693 in an @code{__attribute__} still only provides you with 8-byte
5694 alignment. See your linker documentation for further information.
5695
5696 @item packed
5697 This attribute, attached to @code{struct} or @code{union} type
5698 definition, specifies that each member (other than zero-width bit-fields)
5699 of the structure or union is placed to minimize the memory required. When
5700 attached to an @code{enum} definition, it indicates that the smallest
5701 integral type should be used.
5702
5703 @opindex fshort-enums
5704 Specifying this attribute for @code{struct} and @code{union} types is
5705 equivalent to specifying the @code{packed} attribute on each of the
5706 structure or union members. Specifying the @option{-fshort-enums}
5707 flag on the line is equivalent to specifying the @code{packed}
5708 attribute on all @code{enum} definitions.
5709
5710 In the following example @code{struct my_packed_struct}'s members are
5711 packed closely together, but the internal layout of its @code{s} member
5712 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5713 be packed too.
5714
5715 @smallexample
5716 struct my_unpacked_struct
5717 @{
5718 char c;
5719 int i;
5720 @};
5721
5722 struct __attribute__ ((__packed__)) my_packed_struct
5723 @{
5724 char c;
5725 int i;
5726 struct my_unpacked_struct s;
5727 @};
5728 @end smallexample
5729
5730 You may only specify this attribute on the definition of an @code{enum},
5731 @code{struct} or @code{union}, not on a @code{typedef} that does not
5732 also define the enumerated type, structure or union.
5733
5734 @item transparent_union
5735 This attribute, attached to a @code{union} type definition, indicates
5736 that any function parameter having that union type causes calls to that
5737 function to be treated in a special way.
5738
5739 First, the argument corresponding to a transparent union type can be of
5740 any type in the union; no cast is required. Also, if the union contains
5741 a pointer type, the corresponding argument can be a null pointer
5742 constant or a void pointer expression; and if the union contains a void
5743 pointer type, the corresponding argument can be any pointer expression.
5744 If the union member type is a pointer, qualifiers like @code{const} on
5745 the referenced type must be respected, just as with normal pointer
5746 conversions.
5747
5748 Second, the argument is passed to the function using the calling
5749 conventions of the first member of the transparent union, not the calling
5750 conventions of the union itself. All members of the union must have the
5751 same machine representation; this is necessary for this argument passing
5752 to work properly.
5753
5754 Transparent unions are designed for library functions that have multiple
5755 interfaces for compatibility reasons. For example, suppose the
5756 @code{wait} function must accept either a value of type @code{int *} to
5757 comply with POSIX, or a value of type @code{union wait *} to comply with
5758 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
5759 @code{wait} would accept both kinds of arguments, but it would also
5760 accept any other pointer type and this would make argument type checking
5761 less useful. Instead, @code{<sys/wait.h>} might define the interface
5762 as follows:
5763
5764 @smallexample
5765 typedef union __attribute__ ((__transparent_union__))
5766 @{
5767 int *__ip;
5768 union wait *__up;
5769 @} wait_status_ptr_t;
5770
5771 pid_t wait (wait_status_ptr_t);
5772 @end smallexample
5773
5774 @noindent
5775 This interface allows either @code{int *} or @code{union wait *}
5776 arguments to be passed, using the @code{int *} calling convention.
5777 The program can call @code{wait} with arguments of either type:
5778
5779 @smallexample
5780 int w1 () @{ int w; return wait (&w); @}
5781 int w2 () @{ union wait w; return wait (&w); @}
5782 @end smallexample
5783
5784 @noindent
5785 With this interface, @code{wait}'s implementation might look like this:
5786
5787 @smallexample
5788 pid_t wait (wait_status_ptr_t p)
5789 @{
5790 return waitpid (-1, p.__ip, 0);
5791 @}
5792 @end smallexample
5793
5794 @item unused
5795 When attached to a type (including a @code{union} or a @code{struct}),
5796 this attribute means that variables of that type are meant to appear
5797 possibly unused. GCC does not produce a warning for any variables of
5798 that type, even if the variable appears to do nothing. This is often
5799 the case with lock or thread classes, which are usually defined and then
5800 not referenced, but contain constructors and destructors that have
5801 nontrivial bookkeeping functions.
5802
5803 @item deprecated
5804 @itemx deprecated (@var{msg})
5805 The @code{deprecated} attribute results in a warning if the type
5806 is used anywhere in the source file. This is useful when identifying
5807 types that are expected to be removed in a future version of a program.
5808 If possible, the warning also includes the location of the declaration
5809 of the deprecated type, to enable users to easily find further
5810 information about why the type is deprecated, or what they should do
5811 instead. Note that the warnings only occur for uses and then only
5812 if the type is being applied to an identifier that itself is not being
5813 declared as deprecated.
5814
5815 @smallexample
5816 typedef int T1 __attribute__ ((deprecated));
5817 T1 x;
5818 typedef T1 T2;
5819 T2 y;
5820 typedef T1 T3 __attribute__ ((deprecated));
5821 T3 z __attribute__ ((deprecated));
5822 @end smallexample
5823
5824 @noindent
5825 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
5826 warning is issued for line 4 because T2 is not explicitly
5827 deprecated. Line 5 has no warning because T3 is explicitly
5828 deprecated. Similarly for line 6. The optional @var{msg}
5829 argument, which must be a string, is printed in the warning if
5830 present.
5831
5832 The @code{deprecated} attribute can also be used for functions and
5833 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5834
5835 @item may_alias
5836 Accesses through pointers to types with this attribute are not subject
5837 to type-based alias analysis, but are instead assumed to be able to alias
5838 any other type of objects.
5839 In the context of section 6.5 paragraph 7 of the C99 standard,
5840 an lvalue expression
5841 dereferencing such a pointer is treated like having a character type.
5842 See @option{-fstrict-aliasing} for more information on aliasing issues.
5843 This extension exists to support some vector APIs, in which pointers to
5844 one vector type are permitted to alias pointers to a different vector type.
5845
5846 Note that an object of a type with this attribute does not have any
5847 special semantics.
5848
5849 Example of use:
5850
5851 @smallexample
5852 typedef short __attribute__((__may_alias__)) short_a;
5853
5854 int
5855 main (void)
5856 @{
5857 int a = 0x12345678;
5858 short_a *b = (short_a *) &a;
5859
5860 b[1] = 0;
5861
5862 if (a == 0x12345678)
5863 abort();
5864
5865 exit(0);
5866 @}
5867 @end smallexample
5868
5869 @noindent
5870 If you replaced @code{short_a} with @code{short} in the variable
5871 declaration, the above program would abort when compiled with
5872 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5873 above in recent GCC versions.
5874
5875 @item visibility
5876 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5877 applied to class, struct, union and enum types. Unlike other type
5878 attributes, the attribute must appear between the initial keyword and
5879 the name of the type; it cannot appear after the body of the type.
5880
5881 Note that the type visibility is applied to vague linkage entities
5882 associated with the class (vtable, typeinfo node, etc.). In
5883 particular, if a class is thrown as an exception in one shared object
5884 and caught in another, the class must have default visibility.
5885 Otherwise the two shared objects are unable to use the same
5886 typeinfo node and exception handling will break.
5887
5888 @end table
5889
5890 To specify multiple attributes, separate them by commas within the
5891 double parentheses: for example, @samp{__attribute__ ((aligned (16),
5892 packed))}.
5893
5894 @subsection ARM Type Attributes
5895
5896 On those ARM targets that support @code{dllimport} (such as Symbian
5897 OS), you can use the @code{notshared} attribute to indicate that the
5898 virtual table and other similar data for a class should not be
5899 exported from a DLL@. For example:
5900
5901 @smallexample
5902 class __declspec(notshared) C @{
5903 public:
5904 __declspec(dllimport) C();
5905 virtual void f();
5906 @}
5907
5908 __declspec(dllexport)
5909 C::C() @{@}
5910 @end smallexample
5911
5912 @noindent
5913 In this code, @code{C::C} is exported from the current DLL, but the
5914 virtual table for @code{C} is not exported. (You can use
5915 @code{__attribute__} instead of @code{__declspec} if you prefer, but
5916 most Symbian OS code uses @code{__declspec}.)
5917
5918 @anchor{MeP Type Attributes}
5919 @subsection MeP Type Attributes
5920
5921 Many of the MeP variable attributes may be applied to types as well.
5922 Specifically, the @code{based}, @code{tiny}, @code{near}, and
5923 @code{far} attributes may be applied to either. The @code{io} and
5924 @code{cb} attributes may not be applied to types.
5925
5926 @anchor{i386 Type Attributes}
5927 @subsection i386 Type Attributes
5928
5929 Two attributes are currently defined for i386 configurations:
5930 @code{ms_struct} and @code{gcc_struct}.
5931
5932 @table @code
5933
5934 @item ms_struct
5935 @itemx gcc_struct
5936 @cindex @code{ms_struct}
5937 @cindex @code{gcc_struct}
5938
5939 If @code{packed} is used on a structure, or if bit-fields are used
5940 it may be that the Microsoft ABI packs them differently
5941 than GCC normally packs them. Particularly when moving packed
5942 data between functions compiled with GCC and the native Microsoft compiler
5943 (either via function call or as data in a file), it may be necessary to access
5944 either format.
5945
5946 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5947 compilers to match the native Microsoft compiler.
5948 @end table
5949
5950 @anchor{PowerPC Type Attributes}
5951 @subsection PowerPC Type Attributes
5952
5953 Three attributes currently are defined for PowerPC configurations:
5954 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5955
5956 For full documentation of the @code{ms_struct} and @code{gcc_struct}
5957 attributes please see the documentation in @ref{i386 Type Attributes}.
5958
5959 The @code{altivec} attribute allows one to declare AltiVec vector data
5960 types supported by the AltiVec Programming Interface Manual. The
5961 attribute requires an argument to specify one of three vector types:
5962 @code{vector__}, @code{pixel__} (always followed by unsigned short),
5963 and @code{bool__} (always followed by unsigned).
5964
5965 @smallexample
5966 __attribute__((altivec(vector__)))
5967 __attribute__((altivec(pixel__))) unsigned short
5968 __attribute__((altivec(bool__))) unsigned
5969 @end smallexample
5970
5971 These attributes mainly are intended to support the @code{__vector},
5972 @code{__pixel}, and @code{__bool} AltiVec keywords.
5973
5974 @anchor{SPU Type Attributes}
5975 @subsection SPU Type Attributes
5976
5977 The SPU supports the @code{spu_vector} attribute for types. This attribute
5978 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
5979 Language Extensions Specification. It is intended to support the
5980 @code{__vector} keyword.
5981
5982 @node Alignment
5983 @section Inquiring on Alignment of Types or Variables
5984 @cindex alignment
5985 @cindex type alignment
5986 @cindex variable alignment
5987
5988 The keyword @code{__alignof__} allows you to inquire about how an object
5989 is aligned, or the minimum alignment usually required by a type. Its
5990 syntax is just like @code{sizeof}.
5991
5992 For example, if the target machine requires a @code{double} value to be
5993 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
5994 This is true on many RISC machines. On more traditional machine
5995 designs, @code{__alignof__ (double)} is 4 or even 2.
5996
5997 Some machines never actually require alignment; they allow reference to any
5998 data type even at an odd address. For these machines, @code{__alignof__}
5999 reports the smallest alignment that GCC gives the data type, usually as
6000 mandated by the target ABI.
6001
6002 If the operand of @code{__alignof__} is an lvalue rather than a type,
6003 its value is the required alignment for its type, taking into account
6004 any minimum alignment specified with GCC's @code{__attribute__}
6005 extension (@pxref{Variable Attributes}). For example, after this
6006 declaration:
6007
6008 @smallexample
6009 struct foo @{ int x; char y; @} foo1;
6010 @end smallexample
6011
6012 @noindent
6013 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6014 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6015
6016 It is an error to ask for the alignment of an incomplete type.
6017
6018
6019 @node Inline
6020 @section An Inline Function is As Fast As a Macro
6021 @cindex inline functions
6022 @cindex integrating function code
6023 @cindex open coding
6024 @cindex macros, inline alternative
6025
6026 By declaring a function inline, you can direct GCC to make
6027 calls to that function faster. One way GCC can achieve this is to
6028 integrate that function's code into the code for its callers. This
6029 makes execution faster by eliminating the function-call overhead; in
6030 addition, if any of the actual argument values are constant, their
6031 known values may permit simplifications at compile time so that not
6032 all of the inline function's code needs to be included. The effect on
6033 code size is less predictable; object code may be larger or smaller
6034 with function inlining, depending on the particular case. You can
6035 also direct GCC to try to integrate all ``simple enough'' functions
6036 into their callers with the option @option{-finline-functions}.
6037
6038 GCC implements three different semantics of declaring a function
6039 inline. One is available with @option{-std=gnu89} or
6040 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6041 on all inline declarations, another when
6042 @option{-std=c99}, @option{-std=c11},
6043 @option{-std=gnu99} or @option{-std=gnu11}
6044 (without @option{-fgnu89-inline}), and the third
6045 is used when compiling C++.
6046
6047 To declare a function inline, use the @code{inline} keyword in its
6048 declaration, like this:
6049
6050 @smallexample
6051 static inline int
6052 inc (int *a)
6053 @{
6054 return (*a)++;
6055 @}
6056 @end smallexample
6057
6058 If you are writing a header file to be included in ISO C90 programs, write
6059 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
6060
6061 The three types of inlining behave similarly in two important cases:
6062 when the @code{inline} keyword is used on a @code{static} function,
6063 like the example above, and when a function is first declared without
6064 using the @code{inline} keyword and then is defined with
6065 @code{inline}, like this:
6066
6067 @smallexample
6068 extern int inc (int *a);
6069 inline int
6070 inc (int *a)
6071 @{
6072 return (*a)++;
6073 @}
6074 @end smallexample
6075
6076 In both of these common cases, the program behaves the same as if you
6077 had not used the @code{inline} keyword, except for its speed.
6078
6079 @cindex inline functions, omission of
6080 @opindex fkeep-inline-functions
6081 When a function is both inline and @code{static}, if all calls to the
6082 function are integrated into the caller, and the function's address is
6083 never used, then the function's own assembler code is never referenced.
6084 In this case, GCC does not actually output assembler code for the
6085 function, unless you specify the option @option{-fkeep-inline-functions}.
6086 Some calls cannot be integrated for various reasons (in particular,
6087 calls that precede the function's definition cannot be integrated, and
6088 neither can recursive calls within the definition). If there is a
6089 nonintegrated call, then the function is compiled to assembler code as
6090 usual. The function must also be compiled as usual if the program
6091 refers to its address, because that can't be inlined.
6092
6093 @opindex Winline
6094 Note that certain usages in a function definition can make it unsuitable
6095 for inline substitution. Among these usages are: variadic functions, use of
6096 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6097 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6098 and nested functions (@pxref{Nested Functions}). Using @option{-Winline}
6099 warns when a function marked @code{inline} could not be substituted,
6100 and gives the reason for the failure.
6101
6102 @cindex automatic @code{inline} for C++ member fns
6103 @cindex @code{inline} automatic for C++ member fns
6104 @cindex member fns, automatically @code{inline}
6105 @cindex C++ member fns, automatically @code{inline}
6106 @opindex fno-default-inline
6107 As required by ISO C++, GCC considers member functions defined within
6108 the body of a class to be marked inline even if they are
6109 not explicitly declared with the @code{inline} keyword. You can
6110 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6111 Options,,Options Controlling C++ Dialect}.
6112
6113 GCC does not inline any functions when not optimizing unless you specify
6114 the @samp{always_inline} attribute for the function, like this:
6115
6116 @smallexample
6117 /* @r{Prototype.} */
6118 inline void foo (const char) __attribute__((always_inline));
6119 @end smallexample
6120
6121 The remainder of this section is specific to GNU C90 inlining.
6122
6123 @cindex non-static inline function
6124 When an inline function is not @code{static}, then the compiler must assume
6125 that there may be calls from other source files; since a global symbol can
6126 be defined only once in any program, the function must not be defined in
6127 the other source files, so the calls therein cannot be integrated.
6128 Therefore, a non-@code{static} inline function is always compiled on its
6129 own in the usual fashion.
6130
6131 If you specify both @code{inline} and @code{extern} in the function
6132 definition, then the definition is used only for inlining. In no case
6133 is the function compiled on its own, not even if you refer to its
6134 address explicitly. Such an address becomes an external reference, as
6135 if you had only declared the function, and had not defined it.
6136
6137 This combination of @code{inline} and @code{extern} has almost the
6138 effect of a macro. The way to use it is to put a function definition in
6139 a header file with these keywords, and put another copy of the
6140 definition (lacking @code{inline} and @code{extern}) in a library file.
6141 The definition in the header file causes most calls to the function
6142 to be inlined. If any uses of the function remain, they refer to
6143 the single copy in the library.
6144
6145 @node Volatiles
6146 @section When is a Volatile Object Accessed?
6147 @cindex accessing volatiles
6148 @cindex volatile read
6149 @cindex volatile write
6150 @cindex volatile access
6151
6152 C has the concept of volatile objects. These are normally accessed by
6153 pointers and used for accessing hardware or inter-thread
6154 communication. The standard encourages compilers to refrain from
6155 optimizations concerning accesses to volatile objects, but leaves it
6156 implementation defined as to what constitutes a volatile access. The
6157 minimum requirement is that at a sequence point all previous accesses
6158 to volatile objects have stabilized and no subsequent accesses have
6159 occurred. Thus an implementation is free to reorder and combine
6160 volatile accesses that occur between sequence points, but cannot do
6161 so for accesses across a sequence point. The use of volatile does
6162 not allow you to violate the restriction on updating objects multiple
6163 times between two sequence points.
6164
6165 Accesses to non-volatile objects are not ordered with respect to
6166 volatile accesses. You cannot use a volatile object as a memory
6167 barrier to order a sequence of writes to non-volatile memory. For
6168 instance:
6169
6170 @smallexample
6171 int *ptr = @var{something};
6172 volatile int vobj;
6173 *ptr = @var{something};
6174 vobj = 1;
6175 @end smallexample
6176
6177 @noindent
6178 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6179 that the write to @var{*ptr} occurs by the time the update
6180 of @var{vobj} happens. If you need this guarantee, you must use
6181 a stronger memory barrier such as:
6182
6183 @smallexample
6184 int *ptr = @var{something};
6185 volatile int vobj;
6186 *ptr = @var{something};
6187 asm volatile ("" : : : "memory");
6188 vobj = 1;
6189 @end smallexample
6190
6191 A scalar volatile object is read when it is accessed in a void context:
6192
6193 @smallexample
6194 volatile int *src = @var{somevalue};
6195 *src;
6196 @end smallexample
6197
6198 Such expressions are rvalues, and GCC implements this as a
6199 read of the volatile object being pointed to.
6200
6201 Assignments are also expressions and have an rvalue. However when
6202 assigning to a scalar volatile, the volatile object is not reread,
6203 regardless of whether the assignment expression's rvalue is used or
6204 not. If the assignment's rvalue is used, the value is that assigned
6205 to the volatile object. For instance, there is no read of @var{vobj}
6206 in all the following cases:
6207
6208 @smallexample
6209 int obj;
6210 volatile int vobj;
6211 vobj = @var{something};
6212 obj = vobj = @var{something};
6213 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6214 obj = (@var{something}, vobj = @var{anotherthing});
6215 @end smallexample
6216
6217 If you need to read the volatile object after an assignment has
6218 occurred, you must use a separate expression with an intervening
6219 sequence point.
6220
6221 As bit-fields are not individually addressable, volatile bit-fields may
6222 be implicitly read when written to, or when adjacent bit-fields are
6223 accessed. Bit-field operations may be optimized such that adjacent
6224 bit-fields are only partially accessed, if they straddle a storage unit
6225 boundary. For these reasons it is unwise to use volatile bit-fields to
6226 access hardware.
6227
6228 @node Using Assembly Language with C
6229 @section How to Use Inline Assembly Language in C Code
6230
6231 GCC provides various extensions that allow you to embed assembler within
6232 C code.
6233
6234 @menu
6235 * Basic Asm:: Inline assembler with no operands.
6236 * Extended Asm:: Inline assembler with operands.
6237 * Constraints:: Constraints for @code{asm} operands
6238 * Asm Labels:: Specifying the assembler name to use for a C symbol.
6239 * Explicit Reg Vars:: Defining variables residing in specified registers.
6240 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
6241 @end menu
6242
6243 @node Basic Asm
6244 @subsection Basic Asm --- Assembler Instructions with No Operands
6245 @cindex basic @code{asm}
6246
6247 The @code{asm} keyword allows you to embed assembler instructions within
6248 C code.
6249
6250 @example
6251 asm [ volatile ] ( AssemblerInstructions )
6252 @end example
6253
6254 To create headers compatible with ISO C, write @code{__asm__} instead of
6255 @code{asm} (@pxref{Alternate Keywords}).
6256
6257 By definition, a Basic @code{asm} statement is one with no operands.
6258 @code{asm} statements that contain one or more colons (used to delineate
6259 operands) are considered to be Extended (for example, @code{asm("int $3")}
6260 is Basic, and @code{asm("int $3" : )} is Extended). @xref{Extended Asm}.
6261
6262 @subsubheading Qualifiers
6263 @emph{volatile}
6264 @*
6265 This optional qualifier has no effect. All Basic @code{asm} blocks are
6266 implicitly volatile.
6267
6268 @subsubheading Parameters
6269 @emph{AssemblerInstructions}
6270 @*
6271 This is a literal string that specifies the assembler code. The string can
6272 contain any instructions recognized by the assembler, including directives.
6273 GCC does not parse the assembler instructions themselves and
6274 does not know what they mean or even whether they are valid assembler input.
6275 The compiler copies it verbatim to the assembly language output file, without
6276 processing dialects or any of the "%" operators that are available with
6277 Extended @code{asm}. This results in minor differences between Basic
6278 @code{asm} strings and Extended @code{asm} templates. For example, to refer to
6279 registers you might use %%eax in Extended @code{asm} and %eax in Basic
6280 @code{asm}.
6281
6282 You may place multiple assembler instructions together in a single @code{asm}
6283 string, separated by the characters normally used in assembly code for the
6284 system. A combination that works in most places is a newline to break the
6285 line, plus a tab character (written as "\n\t").
6286 Some assemblers allow semicolons as a line separator. However,
6287 note that some assembler dialects use semicolons to start a comment.
6288
6289 Do not expect a sequence of @code{asm} statements to remain perfectly
6290 consecutive after compilation. If certain instructions need to remain
6291 consecutive in the output, put them in a single multi-instruction asm
6292 statement. Note that GCC's optimizers can move @code{asm} statements
6293 relative to other code, including across jumps.
6294
6295 @code{asm} statements may not perform jumps into other @code{asm} statements.
6296 GCC does not know about these jumps, and therefore cannot take
6297 account of them when deciding how to optimize. Jumps from @code{asm} to C
6298 labels are only supported in Extended @code{asm}.
6299
6300 @subsubheading Remarks
6301 Using Extended @code{asm} will typically produce smaller, safer, and more
6302 efficient code, and in most cases it is a better solution. When writing
6303 inline assembly language outside of C functions, however, you must use Basic
6304 @code{asm}. Extended @code{asm} statements have to be inside a C function.
6305
6306 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
6307 assembly code when optimizing. This can lead to unexpected duplicate
6308 symbol errors during compilation if your assembly code defines symbols or
6309 labels.
6310
6311 Safely accessing C data and calling functions from Basic @code{asm} is more
6312 complex than it may appear. To access C data, it is better to use Extended
6313 @code{asm}.
6314
6315 Since GCC does not parse the AssemblerInstructions, it has no
6316 visibility of any symbols it references. This may result in GCC discarding
6317 those symbols as unreferenced.
6318
6319 Unlike Extended @code{asm}, all Basic @code{asm} blocks are implicitly
6320 volatile. @xref{Volatile}. Similarly, Basic @code{asm} blocks are not treated
6321 as though they used a "memory" clobber (@pxref{Clobbers}).
6322
6323 All Basic @code{asm} blocks use the assembler dialect specified by the
6324 @option{-masm} command-line option. Basic @code{asm} provides no
6325 mechanism to provide different assembler strings for different dialects.
6326
6327 Here is an example of Basic @code{asm} for i386:
6328
6329 @example
6330 /* Note that this code will not compile with -masm=intel */
6331 #define DebugBreak() asm("int $3")
6332 @end example
6333
6334 @node Extended Asm
6335 @subsection Extended Asm - Assembler Instructions with C Expression Operands
6336 @cindex @code{asm} keyword
6337 @cindex extended @code{asm}
6338 @cindex assembler instructions
6339
6340 The @code{asm} keyword allows you to embed assembler instructions within C
6341 code. With Extended @code{asm} you can read and write C variables from
6342 assembler and perform jumps from assembler code to C labels.
6343
6344 @example
6345 @ifhtml
6346 asm [volatile] ( AssemblerTemplate : [OutputOperands] [ : [InputOperands] [ : [Clobbers] ] ] )
6347
6348 asm [volatile] goto ( AssemblerTemplate : : [InputOperands] : [Clobbers] : GotoLabels )
6349 @end ifhtml
6350 @ifnothtml
6351 asm [volatile] ( AssemblerTemplate
6352 : [OutputOperands]
6353 [ : [InputOperands]
6354 [ : [Clobbers] ] ])
6355
6356 asm [volatile] goto ( AssemblerTemplate
6357 :
6358 : [InputOperands]
6359 : [Clobbers]
6360 : GotoLabels)
6361 @end ifnothtml
6362 @end example
6363
6364 To create headers compatible with ISO C, write @code{__asm__} instead of
6365 @code{asm} and @code{__volatile__} instead of @code{volatile}
6366 (@pxref{Alternate Keywords}). There is no alternate for @code{goto}.
6367
6368 By definition, Extended @code{asm} is an @code{asm} statement that contains
6369 operands. To separate the classes of operands, you use colons. Basic
6370 @code{asm} statements contain no colons. (So, for example,
6371 @code{asm("int $3")} is Basic @code{asm}, and @code{asm("int $3" : )} is
6372 Extended @code{asm}. @pxref{Basic Asm}.)
6373
6374 @subsubheading Qualifiers
6375 @emph{volatile}
6376 @*
6377 The typical use of Extended @code{asm} statements is to manipulate input
6378 values to produce output values. However, your @code{asm} statements may
6379 also produce side effects. If so, you may need to use the @code{volatile}
6380 qualifier to disable certain optimizations. @xref{Volatile}.
6381
6382 @emph{goto}
6383 @*
6384 This qualifier informs the compiler that the @code{asm} statement may
6385 perform a jump to one of the labels listed in the GotoLabels section.
6386 @xref{GotoLabels}.
6387
6388 @subsubheading Parameters
6389 @emph{AssemblerTemplate}
6390 @*
6391 This is a literal string that contains the assembler code. It is a
6392 combination of fixed text and tokens that refer to the input, output,
6393 and goto parameters. @xref{AssemblerTemplate}.
6394
6395 @emph{OutputOperands}
6396 @*
6397 A comma-separated list of the C variables modified by the instructions in the
6398 AssemblerTemplate. @xref{OutputOperands}.
6399
6400 @emph{InputOperands}
6401 @*
6402 A comma-separated list of C expressions read by the instructions in the
6403 AssemblerTemplate. @xref{InputOperands}.
6404
6405 @emph{Clobbers}
6406 @*
6407 A comma-separated list of registers or other values changed by the
6408 AssemblerTemplate, beyond those listed as outputs. @xref{Clobbers}.
6409
6410 @emph{GotoLabels}
6411 @*
6412 When you are using the @code{goto} form of @code{asm}, this section contains
6413 the list of all C labels to which the AssemblerTemplate may jump.
6414 @xref{GotoLabels}.
6415
6416 @subsubheading Remarks
6417 The @code{asm} statement allows you to include assembly instructions directly
6418 within C code. This may help you to maximize performance in time-sensitive
6419 code or to access assembly instructions that are not readily available to C
6420 programs.
6421
6422 Note that Extended @code{asm} statements must be inside a function. Only
6423 Basic @code{asm} may be outside functions (@pxref{Basic Asm}).
6424
6425 While the uses of @code{asm} are many and varied, it may help to think of an
6426 @code{asm} statement as a series of low-level instructions that convert input
6427 parameters to output parameters. So a simple (if not particularly useful)
6428 example for i386 using @code{asm} might look like this:
6429
6430 @example
6431 int src = 1;
6432 int dst;
6433
6434 asm ("mov %1, %0\n\t"
6435 "add $1, %0"
6436 : "=r" (dst)
6437 : "r" (src));
6438
6439 printf("%d\n", dst);
6440 @end example
6441
6442 This code will copy @var{src} to @var{dst} and add 1 to @var{dst}.
6443
6444 @anchor{Volatile}
6445 @subsubsection Volatile
6446 @cindex volatile @code{asm}
6447 @cindex @code{asm} volatile
6448
6449 GCC's optimizers sometimes discard @code{asm} statements if they determine
6450 there is no need for the output variables. Also, the optimizers may move
6451 code out of loops if they believe that the code will always return the same
6452 result (i.e. none of its input values change between calls). Using the
6453 @code{volatile} qualifier disables these optimizations. @code{asm} statements
6454 that have no output operands are implicitly volatile.
6455
6456 Examples:
6457
6458 This i386 code demonstrates a case that does not use (or require) the
6459 @code{volatile} qualifier. If it is performing assertion checking, this code
6460 uses @code{asm} to perform the validation. Otherwise, @var{dwRes} is
6461 unreferenced by any code. As a result, the optimizers can discard the
6462 @code{asm} statement, which in turn removes the need for the entire
6463 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
6464 isn't needed you allow the optimizers to produce the most efficient code
6465 possible.
6466
6467 @example
6468 void DoCheck(uint32_t dwSomeValue)
6469 @{
6470 uint32_t dwRes;
6471
6472 // Assumes dwSomeValue is not zero.
6473 asm ("bsfl %1,%0"
6474 : "=r" (dwRes)
6475 : "r" (dwSomeValue)
6476 : "cc");
6477
6478 assert(dwRes > 3);
6479 @}
6480 @end example
6481
6482 The next example shows a case where the optimizers can recognize that the input
6483 (@var{dwSomeValue}) never changes during the execution of the function and can
6484 therefore move the @code{asm} outside the loop to produce more efficient code.
6485 Again, using @code{volatile} disables this type of optimization.
6486
6487 @example
6488 void do_print(uint32_t dwSomeValue)
6489 @{
6490 uint32_t dwRes;
6491
6492 for (uint32_t x=0; x < 5; x++)
6493 @{
6494 // Assumes dwSomeValue is not zero.
6495 asm ("bsfl %1,%0"
6496 : "=r" (dwRes)
6497 : "r" (dwSomeValue)
6498 : "cc");
6499
6500 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
6501 @}
6502 @}
6503 @end example
6504
6505 The following example demonstrates a case where you need to use the
6506 @code{volatile} qualifier. It uses the i386 RDTSC instruction, which reads
6507 the computer's time-stamp counter. Without the @code{volatile} qualifier,
6508 the optimizers might assume that the @code{asm} block will always return the
6509 same value and therefore optimize away the second call.
6510
6511 @example
6512 uint64_t msr;
6513
6514 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
6515 "shl $32, %%rdx\n\t" // Shift the upper bits left.
6516 "or %%rdx, %0" // 'Or' in the lower bits.
6517 : "=a" (msr)
6518 :
6519 : "rdx");
6520
6521 printf("msr: %llx\n", msr);
6522
6523 // Do other work...
6524
6525 // Reprint the timestamp
6526 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
6527 "shl $32, %%rdx\n\t" // Shift the upper bits left.
6528 "or %%rdx, %0" // 'Or' in the lower bits.
6529 : "=a" (msr)
6530 :
6531 : "rdx");
6532
6533 printf("msr: %llx\n", msr);
6534 @end example
6535
6536 GCC's optimizers will not treat this code like the non-volatile code in the
6537 earlier examples. They do not move it out of loops or omit it on the
6538 assumption that the result from a previous call is still valid.
6539
6540 Note that the compiler can move even volatile @code{asm} instructions relative
6541 to other code, including across jump instructions. For example, on many
6542 targets there is a system register that controls the rounding mode of
6543 floating-point operations. Setting it with a volatile @code{asm}, as in the
6544 following PowerPC example, will not work reliably.
6545
6546 @example
6547 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
6548 sum = x + y;
6549 @end example
6550
6551 The compiler may move the addition back before the volatile @code{asm}. To
6552 make it work as expected, add an artificial dependency to the @code{asm} by
6553 referencing a variable in the subsequent code, for example:
6554
6555 @example
6556 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
6557 sum = x + y;
6558 @end example
6559
6560 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
6561 assembly code when optimizing. This can lead to unexpected duplicate symbol
6562 errors during compilation if your asm code defines symbols or labels. Using %=
6563 (@pxref{AssemblerTemplate}) may help resolve this problem.
6564
6565 @anchor{AssemblerTemplate}
6566 @subsubsection Assembler Template
6567 @cindex @code{asm} assembler template
6568
6569 An assembler template is a literal string containing assembler instructions.
6570 The compiler will replace any references to inputs, outputs, and goto labels
6571 in the template, and then output the resulting string to the assembler. The
6572 string can contain any instructions recognized by the assembler, including
6573 directives. GCC does not parse the assembler instructions
6574 themselves and does not know what they mean or even whether they are valid
6575 assembler input. However, it does count the statements
6576 (@pxref{Size of an asm}).
6577
6578 You may place multiple assembler instructions together in a single @code{asm}
6579 string, separated by the characters normally used in assembly code for the
6580 system. A combination that works in most places is a newline to break the
6581 line, plus a tab character to move to the instruction field (written as
6582 "\n\t"). Some assemblers allow semicolons as a line separator. However, note
6583 that some assembler dialects use semicolons to start a comment.
6584
6585 Do not expect a sequence of @code{asm} statements to remain perfectly
6586 consecutive after compilation, even when you are using the @code{volatile}
6587 qualifier. If certain instructions need to remain consecutive in the output,
6588 put them in a single multi-instruction asm statement.
6589
6590 Accessing data from C programs without using input/output operands (such as
6591 by using global symbols directly from the assembler template) may not work as
6592 expected. Similarly, calling functions directly from an assembler template
6593 requires a detailed understanding of the target assembler and ABI.
6594
6595 Since GCC does not parse the AssemblerTemplate, it has no visibility of any
6596 symbols it references. This may result in GCC discarding those symbols as
6597 unreferenced unless they are also listed as input, output, or goto operands.
6598
6599 GCC can support multiple assembler dialects (for example, GCC for i386
6600 supports "att" and "intel" dialects) for inline assembler. In builds that
6601 support this capability, the @option{-masm} option controls which dialect
6602 GCC uses as its default. The hardware-specific documentation for the
6603 @option{-masm} option contains the list of supported dialects, as well as the
6604 default dialect if the option is not specified. This information may be
6605 important to understand, since assembler code that works correctly when
6606 compiled using one dialect will likely fail if compiled using another.
6607
6608 @subsubheading Using braces in @code{asm} templates
6609
6610 If your code needs to support multiple assembler dialects (for example, if
6611 you are writing public headers that need to support a variety of compilation
6612 options), use constructs of this form:
6613
6614 @example
6615 @{ dialect0 | dialect1 | dialect2... @}
6616 @end example
6617
6618 This construct outputs 'dialect0' when using dialect #0 to compile the code,
6619 'dialect1' for dialect #1, etc. If there are fewer alternatives within the
6620 braces than the number of dialects the compiler supports, the construct
6621 outputs nothing.
6622
6623 For example, if an i386 compiler supports two dialects (att, intel), an
6624 assembler template such as this:
6625
6626 @example
6627 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
6628 @end example
6629
6630 would produce the output:
6631
6632 @example
6633 For att: "btl %[Offset],%[Base] ; jc %l2"
6634 For intel: "bt %[Base],%[Offset]; jc %l2"
6635 @end example
6636
6637 Using that same compiler, this code:
6638
6639 @example
6640 "xchg@{l@}\t@{%%@}ebx, %1"
6641 @end example
6642
6643 would produce
6644
6645 @example
6646 For att: "xchgl\t%%ebx, %1"
6647 For intel: "xchg\tebx, %1"
6648 @end example
6649
6650 There is no support for nesting dialect alternatives. Also, there is no
6651 ``escape'' for an open brace (@{), so do not use open braces in an Extended
6652 @code{asm} template other than as a dialect indicator.
6653
6654 @subsubheading Other format strings
6655
6656 In addition to the tokens described by the input, output, and goto operands,
6657 there are a few special cases:
6658
6659 @itemize
6660 @item
6661 "%%" outputs a single "%" into the assembler code.
6662
6663 @item
6664 "%=" outputs a number that is unique to each instance of the @code{asm}
6665 statement in the entire compilation. This option is useful when creating local
6666 labels and referring to them multiple times in a single template that
6667 generates multiple assembler instructions.
6668
6669 @end itemize
6670
6671 @anchor{OutputOperands}
6672 @subsubsection Output Operands
6673 @cindex @code{asm} output operands
6674
6675 An @code{asm} statement has zero or more output operands indicating the names
6676 of C variables modified by the assembler code.
6677
6678 In this i386 example, @var{old} (referred to in the template string as
6679 @code{%0}) and @var{*Base} (as @code{%1}) are outputs and @var{Offset}
6680 (@code{%2}) is an input:
6681
6682 @example
6683 bool old;
6684
6685 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
6686 "sbb %0,%0" // Use the CF to calculate old.
6687 : "=r" (old), "+rm" (*Base)
6688 : "Ir" (Offset)
6689 : "cc");
6690
6691 return old;
6692 @end example
6693
6694 Operands use this format:
6695
6696 @example
6697 [ [asmSymbolicName] ] "constraint" (cvariablename)
6698 @end example
6699
6700 @emph{asmSymbolicName}
6701 @*
6702
6703 When not using asmSymbolicNames, use the (zero-based) position of the operand
6704 in the list of operands in the assembler template. For example if there are
6705 three output operands, use @code{%0} in the template to refer to the first,
6706 @code{%1} for the second, and @code{%2} for the third. When using an
6707 asmSymbolicName, reference it by enclosing the name in square brackets
6708 (i.e. @code{%[Value]}). The scope of the name is the @code{asm} statement
6709 that contains the definition. Any valid C variable name is acceptable,
6710 including names already defined in the surrounding code. No two operands
6711 within the same @code{asm} statement can use the same symbolic name.
6712
6713 @emph{constraint}
6714 @*
6715 Output constraints must begin with either @code{"="} (a variable overwriting an
6716 existing value) or @code{"+"} (when reading and writing). When using
6717 @code{"="}, do not assume the location will contain the existing value (except
6718 when tying the variable to an input; @pxref{InputOperands,,Input Operands}).
6719
6720 After the prefix, there must be one or more additional constraints
6721 (@pxref{Constraints}) that describe where the value resides. Common
6722 constraints include @code{"r"} for register and @code{"m"} for memory.
6723 When you list more than one possible location (for example @code{"=rm"}), the
6724 compiler chooses the most efficient one based on the current context. If you
6725 list as many alternates as the @code{asm} statement allows, you will permit
6726 the optimizers to produce the best possible code. If you must use a specific
6727 register, but your Machine Constraints do not provide sufficient
6728 control to select the specific register you want, Local Reg Vars may provide
6729 a solution (@pxref{Local Reg Vars}).
6730
6731 @emph{cvariablename}
6732 @*
6733 Specifies the C variable name of the output (enclosed by parentheses). Accepts
6734 any (non-constant) variable within scope.
6735
6736 Remarks:
6737
6738 The total number of input + output + goto operands has a limit of 30. Commas
6739 separate the operands. When the compiler selects the registers to use to
6740 represent the output operands, it will not use any of the clobbered registers
6741 (@pxref{Clobbers}).
6742
6743 Output operand expressions must be lvalues. The compiler cannot check whether
6744 the operands have data types that are reasonable for the instruction being
6745 executed. For output expressions that are not directly addressable (for
6746 example a bit-field), the constraint must allow a register. In that case, GCC
6747 uses the register as the output of the @code{asm}, and then stores that
6748 register into the output.
6749
6750 Unless an output operand has the '@code{&}' constraint modifier
6751 (@pxref{Modifiers}), GCC may allocate it in the same register as an unrelated
6752 input operand, on the assumption that the assembler code will consume its
6753 inputs before producing outputs. This assumption may be false if the assembler
6754 code actually consists of more than one instruction. In this case, use
6755 '@code{&}' on each output operand that must not overlap an input.
6756
6757 The same problem can occur if one output parameter (@var{a}) allows a register
6758 constraint and another output parameter (@var{b}) allows a memory constraint.
6759 The code generated by GCC to access the memory address in @var{b} can contain
6760 registers which @emph{might} be shared by @var{a}, and GCC considers those
6761 registers to be inputs to the asm. As above, GCC assumes that such input
6762 registers are consumed before any outputs are written. This assumption may
6763 result in incorrect behavior if the asm writes to @var{a} before using
6764 @var{b}. Combining the `@code{&}' constraint with the register constraint
6765 ensures that modifying @var{a} will not affect what address is referenced by
6766 @var{b}. Omitting the `@code{&}' constraint means that the location of @var{b}
6767 will be undefined if @var{a} is modified before using @var{b}.
6768
6769 @code{asm} supports operand modifiers on operands (for example @code{%k2}
6770 instead of simply @code{%2}). Typically these qualifiers are hardware
6771 dependent. The list of supported modifiers for i386 is found at
6772 @ref{i386Operandmodifiers,i386 Operand modifiers}.
6773
6774 If the C code that follows the @code{asm} makes no use of any of the output
6775 operands, use @code{volatile} for the @code{asm} statement to prevent the
6776 optimizers from discarding the @code{asm} statement as unneeded
6777 (see @ref{Volatile}).
6778
6779 Examples:
6780
6781 This code makes no use of the optional asmSymbolicName. Therefore it
6782 references the first output operand as @code{%0} (were there a second, it
6783 would be @code{%1}, etc). The number of the first input operand is one greater
6784 than that of the last output operand. In this i386 example, that makes
6785 @var{Mask} @code{%1}:
6786
6787 @example
6788 uint32_t Mask = 1234;
6789 uint32_t Index;
6790
6791 asm ("bsfl %1, %0"
6792 : "=r" (Index)
6793 : "r" (Mask)
6794 : "cc");
6795 @end example
6796
6797 That code overwrites the variable Index ("="), placing the value in a register
6798 ("r"). The generic "r" constraint instead of a constraint for a specific
6799 register allows the compiler to pick the register to use, which can result
6800 in more efficient code. This may not be possible if an assembler instruction
6801 requires a specific register.
6802
6803 The following i386 example uses the asmSymbolicName operand. It produces the
6804 same result as the code above, but some may consider it more readable or more
6805 maintainable since reordering index numbers is not necessary when adding or
6806 removing operands. The names aIndex and aMask are only used to emphasize which
6807 names get used where. It is acceptable to reuse the names Index and Mask.
6808
6809 @example
6810 uint32_t Mask = 1234;
6811 uint32_t Index;
6812
6813 asm ("bsfl %[aMask], %[aIndex]"
6814 : [aIndex] "=r" (Index)
6815 : [aMask] "r" (Mask)
6816 : "cc");
6817 @end example
6818
6819 Here are some more examples of output operands.
6820
6821 @example
6822 uint32_t c = 1;
6823 uint32_t d;
6824 uint32_t *e = &c;
6825
6826 asm ("mov %[e], %[d]"
6827 : [d] "=rm" (d)
6828 : [e] "rm" (*e));
6829 @end example
6830
6831 Here, @var{d} may either be in a register or in memory. Since the compiler
6832 might already have the current value of the uint32_t pointed to by @var{e}
6833 in a register, you can enable it to choose the best location
6834 for @var{d} by specifying both constraints.
6835
6836 @anchor{InputOperands}
6837 @subsubsection Input Operands
6838 @cindex @code{asm} input operands
6839 @cindex @code{asm} expressions
6840
6841 Input operands make inputs from C variables and expressions available to the
6842 assembly code.
6843
6844 Specify input operands by using the format:
6845
6846 @example
6847 [ [asmSymbolicName] ] "constraint" (cexpression)
6848 @end example
6849
6850 @emph{asmSymbolicName}
6851 @*
6852 When not using asmSymbolicNames, use the (zero-based) position of the operand
6853 in the list of operands, including outputs, in the assembler template. For
6854 example, if there are two output parameters and three inputs, @code{%2} refers
6855 to the first input, @code{%3} to the second, and @code{%4} to the third.
6856 When using an asmSymbolicName, reference it by enclosing the name in square
6857 brackets (e.g. @code{%[Value]}). The scope of the name is the @code{asm}
6858 statement that contains the definition. Any valid C variable name is
6859 acceptable, including names already defined in the surrounding code. No two
6860 operands within the same @code{asm} statement can use the same symbolic name.
6861
6862 @emph{constraint}
6863 @*
6864 Input constraints must be a string containing one or more constraints
6865 (@pxref{Constraints}). When you give more than one possible constraint
6866 (for example, @code{"irm"}), the compiler will choose the most efficient
6867 method based on the current context. Input constraints may not begin with
6868 either "=" or "+". If you must use a specific register, but your Machine
6869 Constraints do not provide sufficient control to select the specific
6870 register you want, Local Reg Vars may provide a solution
6871 (@pxref{Local Reg Vars}).
6872
6873 Input constraints can also be digits (for example, @code{"0"}). This indicates
6874 that the specified input will be in the same place as the output constraint
6875 at the (zero-based) index in the output constraint list. When using
6876 asmSymbolicNames for the output operands, you may use these names (enclosed
6877 in brackets []) instead of digits.
6878
6879 @emph{cexpression}
6880 @*
6881 This is the C variable or expression being passed to the @code{asm} statement
6882 as input.
6883
6884 When the compiler selects the registers to use to represent the input
6885 operands, it will not use any of the clobbered registers (@pxref{Clobbers}).
6886
6887 If there are no output operands but there are input operands, place two
6888 consecutive colons where the output operands would go:
6889
6890 @example
6891 __asm__ ("some instructions"
6892 : /* No outputs. */
6893 : "r" (Offset / 8);
6894 @end example
6895
6896 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
6897 (except for inputs tied to outputs). The compiler assumes that on exit from
6898 the @code{asm} statement these operands will contain the same values as they
6899 had before executing the assembler. It is @emph{not} possible to use Clobbers
6900 to inform the compiler that the values in these inputs are changing. One
6901 common work-around is to tie the changing input variable to an output variable
6902 that never gets used. Note, however, that if the code that follows the
6903 @code{asm} statement makes no use of any of the output operands, the GCC
6904 optimizers may discard the @code{asm} statement as unneeded
6905 (see @ref{Volatile}).
6906
6907 Remarks:
6908
6909 The total number of input + output + goto operands has a limit of 30.
6910
6911 @code{asm} supports operand modifiers on operands (for example @code{%k2}
6912 instead of simply @code{%2}). Typically these qualifiers are hardware
6913 dependent. The list of supported modifiers for i386 is found at
6914 @ref{i386Operandmodifiers,i386 Operand modifiers}.
6915
6916 Examples:
6917
6918 In this example using the fictitious @code{combine} instruction, the
6919 constraint @code{"0"} for input operand 1 says that it must occupy the same
6920 location as output operand 0. Only input operands may use numbers in
6921 constraints, and they must each refer to an output operand. Only a number (or
6922 the symbolic assembler name) in the constraint can guarantee that one operand
6923 is in the same place as another. The mere fact that @var{foo} is the value of
6924 both operands is not enough to guarantee that they are in the same place in
6925 the generated assembler code.
6926
6927 @example
6928 asm ("combine %2, %0"
6929 : "=r" (foo)
6930 : "0" (foo), "g" (bar));
6931 @end example
6932
6933 Here is an example using symbolic names.
6934
6935 @example
6936 asm ("cmoveq %1, %2, %[result]"
6937 : [result] "=r"(result)
6938 : "r" (test), "r" (new), "[result]" (old));
6939 @end example
6940
6941 @anchor{Clobbers}
6942 @subsubsection Clobbers
6943 @cindex @code{asm} clobbers
6944
6945 While the compiler is aware of changes to entries listed in the output
6946 operands, the assembler code may modify more than just the outputs. For
6947 example, calculations may require additional registers, or the processor may
6948 overwrite a register as a side effect of a particular assembler instruction.
6949 In order to inform the compiler of these changes, list them in the clobber
6950 list. Clobber list items are either register names or the special clobbers
6951 (listed below). Each clobber list item is enclosed in double quotes and
6952 separated by commas.
6953
6954 Clobber descriptions may not in any way overlap with an input or output
6955 operand. For example, you may not have an operand describing a register class
6956 with one member when listing that register in the clobber list. Variables
6957 declared to live in specific registers (@pxref{Explicit Reg Vars}), and used
6958 as @code{asm} input or output operands, must have no part mentioned in the
6959 clobber description. In particular, there is no way to specify that input
6960 operands get modified without also specifying them as output operands.
6961
6962 When the compiler selects which registers to use to represent input and output
6963 operands, it will not use any of the clobbered registers. As a result,
6964 clobbered registers are available for any use in the assembler code.
6965
6966 Here is a realistic example for the VAX showing the use of clobbered
6967 registers:
6968
6969 @example
6970 asm volatile ("movc3 %0, %1, %2"
6971 : /* No outputs. */
6972 : "g" (from), "g" (to), "g" (count)
6973 : "r0", "r1", "r2", "r3", "r4", "r5");
6974 @end example
6975
6976 Also, there are two special clobber arguments:
6977
6978 @enumerate
6979 @item
6980 The @code{"cc"} clobber indicates that the assembler code modifies the flags
6981 register. On some machines, GCC represents the condition codes as a specific
6982 hardware register; "cc" serves to name this register. On other machines,
6983 condition code handling is different, and specifying "cc" has no effect. But
6984 it is valid no matter what the machine.
6985
6986 @item
6987 The "memory" clobber tells the compiler that the assembly code performs memory
6988 reads or writes to items other than those listed in the input and output
6989 operands (for example accessing the memory pointed to by one of the input
6990 parameters). To ensure memory contains correct values, GCC may need to flush
6991 specific register values to memory before executing the @code{asm}. Further,
6992 the compiler will not assume that any values read from memory before an
6993 @code{asm} will remain unchanged after that @code{asm}; it will reload them as
6994 needed. This effectively forms a read/write memory barrier for the compiler.
6995
6996 Note that this clobber does not prevent the @emph{processor} from doing
6997 speculative reads past the @code{asm} statement. To prevent that, you need
6998 processor-specific fence instructions.
6999
7000 Flushing registers to memory has performance implications and may be an issue
7001 for time-sensitive code. One trick to avoid this is available if the size of
7002 the memory being accessed is known at compile time. For example, if accessing
7003 ten bytes of a string, use a memory input like:
7004
7005 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
7006
7007 @end enumerate
7008
7009 @anchor{GotoLabels}
7010 @subsubsection Goto Labels
7011 @cindex @code{asm} goto labels
7012
7013 @code{asm goto} allows assembly code to jump to one or more C labels. The
7014 GotoLabels section in an @code{asm goto} statement contains a comma-separated
7015 list of all C labels to which the assembler code may jump. GCC assumes that
7016 @code{asm} execution falls through to the next statement (if this is not the
7017 case, consider using the @code{__builtin_unreachable} intrinsic after the
7018 @code{asm} statement). Optimization of @code{asm goto} may be improved by
7019 using the @code{hot} and @code{cold} label attributes (@pxref{Label
7020 Attributes}). The total number of input + output + goto operands has
7021 a limit of 30.
7022
7023 An @code{asm goto} statement can not have outputs (which means that the
7024 statement is implicitly volatile). This is due to an internal restriction of
7025 the compiler: control transfer instructions cannot have outputs. If the
7026 assembler code does modify anything, use the "memory" clobber to force the
7027 optimizers to flush all register values to memory, and reload them if
7028 necessary, after the @code{asm} statement.
7029
7030 To reference a label, prefix it with @code{%l} (that's a lowercase L) followed
7031 by its (zero-based) position in GotoLabels plus the number of input
7032 arguments. For example, if the @code{asm} has three inputs and references two
7033 labels, refer to the first label as @code{%l3} and the second as @code{%l4}).
7034
7035 @code{asm} statements may not perform jumps into other @code{asm} statements.
7036 GCC's optimizers do not know about these jumps; therefore they cannot take
7037 account of them when deciding how to optimize.
7038
7039 Example code for i386 might look like:
7040
7041 @example
7042 asm goto (
7043 "btl %1, %0\n\t"
7044 "jc %l2"
7045 : /* No outputs. */
7046 : "r" (p1), "r" (p2)
7047 : "cc"
7048 : carry);
7049
7050 return 0;
7051
7052 carry:
7053 return 1;
7054 @end example
7055
7056 The following example shows an @code{asm goto} that uses the memory clobber.
7057
7058 @example
7059 int frob(int x)
7060 @{
7061 int y;
7062 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
7063 : /* No outputs. */
7064 : "r"(x), "r"(&y)
7065 : "r5", "memory"
7066 : error);
7067 return y;
7068 error:
7069 return -1;
7070 @}
7071 @end example
7072
7073 @anchor{i386Operandmodifiers}
7074 @subsubsection i386 Operand modifiers
7075
7076 Input, output, and goto operands for extended @code{asm} statements can use
7077 modifiers to affect the code output to the assembler. For example, the
7078 following code uses the "h" and "b" modifiers for i386:
7079
7080 @example
7081 uint16_t num;
7082 asm volatile ("xchg %h0, %b0" : "+a" (num) );
7083 @end example
7084
7085 These modifiers generate this assembler code:
7086
7087 @example
7088 xchg %ah, %al
7089 @end example
7090
7091 The rest of this discussion uses the following code for illustrative purposes.
7092
7093 @example
7094 int main()
7095 @{
7096 int iInt = 1;
7097
7098 top:
7099
7100 asm volatile goto ("some assembler instructions here"
7101 : /* No outputs. */
7102 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
7103 : /* No clobbers. */
7104 : top);
7105 @}
7106 @end example
7107
7108 With no modifiers, this is what the output from the operands would be for the
7109 att and intel dialects of assembler:
7110
7111 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
7112 @headitem Operand @tab masm=att @tab masm=intel
7113 @item @code{%0}
7114 @tab @code{%eax}
7115 @tab @code{eax}
7116 @item @code{%1}
7117 @tab @code{$2}
7118 @tab @code{2}
7119 @item @code{%2}
7120 @tab @code{$.L2}
7121 @tab @code{OFFSET FLAT:.L2}
7122 @end multitable
7123
7124 The table below shows the list of supported modifiers and their effects.
7125
7126 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
7127 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
7128 @item @code{z}
7129 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
7130 @tab @code{%z0}
7131 @tab @code{l}
7132 @tab
7133 @item @code{b}
7134 @tab Print the QImode name of the register.
7135 @tab @code{%b0}
7136 @tab @code{%al}
7137 @tab @code{al}
7138 @item @code{h}
7139 @tab Print the QImode name for a ``high'' register.
7140 @tab @code{%h0}
7141 @tab @code{%ah}
7142 @tab @code{ah}
7143 @item @code{w}
7144 @tab Print the HImode name of the register.
7145 @tab @code{%w0}
7146 @tab @code{%ax}
7147 @tab @code{ax}
7148 @item @code{k}
7149 @tab Print the SImode name of the register.
7150 @tab @code{%k0}
7151 @tab @code{%eax}
7152 @tab @code{eax}
7153 @item @code{q}
7154 @tab Print the DImode name of the register.
7155 @tab @code{%q0}
7156 @tab @code{%rax}
7157 @tab @code{rax}
7158 @item @code{l}
7159 @tab Print the label name with no punctuation.
7160 @tab @code{%l2}
7161 @tab @code{.L2}
7162 @tab @code{.L2}
7163 @item @code{c}
7164 @tab Require a constant operand and print the constant expression with no punctuation.
7165 @tab @code{%c1}
7166 @tab @code{2}
7167 @tab @code{2}
7168 @end multitable
7169
7170 @anchor{i386floatingpointasmoperands}
7171 @subsubsection i386 floating-point asm operands
7172
7173 On i386 targets, there are several rules on the usage of stack-like registers
7174 in the operands of an @code{asm}. These rules apply only to the operands
7175 that are stack-like registers:
7176
7177 @enumerate
7178 @item
7179 Given a set of input registers that die in an @code{asm}, it is
7180 necessary to know which are implicitly popped by the @code{asm}, and
7181 which must be explicitly popped by GCC@.
7182
7183 An input register that is implicitly popped by the @code{asm} must be
7184 explicitly clobbered, unless it is constrained to match an
7185 output operand.
7186
7187 @item
7188 For any input register that is implicitly popped by an @code{asm}, it is
7189 necessary to know how to adjust the stack to compensate for the pop.
7190 If any non-popped input is closer to the top of the reg-stack than
7191 the implicitly popped register, it would not be possible to know what the
7192 stack looked like---it's not clear how the rest of the stack ``slides
7193 up''.
7194
7195 All implicitly popped input registers must be closer to the top of
7196 the reg-stack than any input that is not implicitly popped.
7197
7198 It is possible that if an input dies in an @code{asm}, the compiler might
7199 use the input register for an output reload. Consider this example:
7200
7201 @smallexample
7202 asm ("foo" : "=t" (a) : "f" (b));
7203 @end smallexample
7204
7205 @noindent
7206 This code says that input @code{b} is not popped by the @code{asm}, and that
7207 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
7208 deeper after the @code{asm} than it was before. But, it is possible that
7209 reload may think that it can use the same register for both the input and
7210 the output.
7211
7212 To prevent this from happening,
7213 if any input operand uses the @code{f} constraint, all output register
7214 constraints must use the @code{&} early-clobber modifier.
7215
7216 The example above would be correctly written as:
7217
7218 @smallexample
7219 asm ("foo" : "=&t" (a) : "f" (b));
7220 @end smallexample
7221
7222 @item
7223 Some operands need to be in particular places on the stack. All
7224 output operands fall in this category---GCC has no other way to
7225 know which registers the outputs appear in unless you indicate
7226 this in the constraints.
7227
7228 Output operands must specifically indicate which register an output
7229 appears in after an @code{asm}. @code{=f} is not allowed: the operand
7230 constraints must select a class with a single register.
7231
7232 @item
7233 Output operands may not be ``inserted'' between existing stack registers.
7234 Since no 387 opcode uses a read/write operand, all output operands
7235 are dead before the @code{asm}, and are pushed by the @code{asm}.
7236 It makes no sense to push anywhere but the top of the reg-stack.
7237
7238 Output operands must start at the top of the reg-stack: output
7239 operands may not ``skip'' a register.
7240
7241 @item
7242 Some @code{asm} statements may need extra stack space for internal
7243 calculations. This can be guaranteed by clobbering stack registers
7244 unrelated to the inputs and outputs.
7245
7246 @end enumerate
7247
7248 Here are a couple of reasonable @code{asm}s to want to write. This
7249 @code{asm}
7250 takes one input, which is internally popped, and produces two outputs.
7251
7252 @smallexample
7253 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
7254 @end smallexample
7255
7256 @noindent
7257 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
7258 and replaces them with one output. The @code{st(1)} clobber is necessary
7259 for the compiler to know that @code{fyl2xp1} pops both inputs.
7260
7261 @smallexample
7262 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
7263 @end smallexample
7264
7265 @lowersections
7266 @include md.texi
7267 @raisesections
7268
7269 @node Asm Labels
7270 @subsection Controlling Names Used in Assembler Code
7271 @cindex assembler names for identifiers
7272 @cindex names used in assembler code
7273 @cindex identifiers, names in assembler code
7274
7275 You can specify the name to be used in the assembler code for a C
7276 function or variable by writing the @code{asm} (or @code{__asm__})
7277 keyword after the declarator as follows:
7278
7279 @smallexample
7280 int foo asm ("myfoo") = 2;
7281 @end smallexample
7282
7283 @noindent
7284 This specifies that the name to be used for the variable @code{foo} in
7285 the assembler code should be @samp{myfoo} rather than the usual
7286 @samp{_foo}.
7287
7288 On systems where an underscore is normally prepended to the name of a C
7289 function or variable, this feature allows you to define names for the
7290 linker that do not start with an underscore.
7291
7292 It does not make sense to use this feature with a non-static local
7293 variable since such variables do not have assembler names. If you are
7294 trying to put the variable in a particular register, see @ref{Explicit
7295 Reg Vars}. GCC presently accepts such code with a warning, but will
7296 probably be changed to issue an error, rather than a warning, in the
7297 future.
7298
7299 You cannot use @code{asm} in this way in a function @emph{definition}; but
7300 you can get the same effect by writing a declaration for the function
7301 before its definition and putting @code{asm} there, like this:
7302
7303 @smallexample
7304 extern func () asm ("FUNC");
7305
7306 func (x, y)
7307 int x, y;
7308 /* @r{@dots{}} */
7309 @end smallexample
7310
7311 It is up to you to make sure that the assembler names you choose do not
7312 conflict with any other assembler symbols. Also, you must not use a
7313 register name; that would produce completely invalid assembler code. GCC
7314 does not as yet have the ability to store static variables in registers.
7315 Perhaps that will be added.
7316
7317 @node Explicit Reg Vars
7318 @subsection Variables in Specified Registers
7319 @cindex explicit register variables
7320 @cindex variables in specified registers
7321 @cindex specified registers
7322 @cindex registers, global allocation
7323
7324 GNU C allows you to put a few global variables into specified hardware
7325 registers. You can also specify the register in which an ordinary
7326 register variable should be allocated.
7327
7328 @itemize @bullet
7329 @item
7330 Global register variables reserve registers throughout the program.
7331 This may be useful in programs such as programming language
7332 interpreters that have a couple of global variables that are accessed
7333 very often.
7334
7335 @item
7336 Local register variables in specific registers do not reserve the
7337 registers, except at the point where they are used as input or output
7338 operands in an @code{asm} statement and the @code{asm} statement itself is
7339 not deleted. The compiler's data flow analysis is capable of determining
7340 where the specified registers contain live values, and where they are
7341 available for other uses. Stores into local register variables may be deleted
7342 when they appear to be dead according to dataflow analysis. References
7343 to local register variables may be deleted or moved or simplified.
7344
7345 These local variables are sometimes convenient for use with the extended
7346 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
7347 output of the assembler instruction directly into a particular register.
7348 (This works provided the register you specify fits the constraints
7349 specified for that operand in the @code{asm}.)
7350 @end itemize
7351
7352 @menu
7353 * Global Reg Vars::
7354 * Local Reg Vars::
7355 @end menu
7356
7357 @node Global Reg Vars
7358 @subsubsection Defining Global Register Variables
7359 @cindex global register variables
7360 @cindex registers, global variables in
7361
7362 You can define a global register variable in GNU C like this:
7363
7364 @smallexample
7365 register int *foo asm ("a5");
7366 @end smallexample
7367
7368 @noindent
7369 Here @code{a5} is the name of the register that should be used. Choose a
7370 register that is normally saved and restored by function calls on your
7371 machine, so that library routines will not clobber it.
7372
7373 Naturally the register name is cpu-dependent, so you need to
7374 conditionalize your program according to cpu type. The register
7375 @code{a5} is a good choice on a 68000 for a variable of pointer
7376 type. On machines with register windows, be sure to choose a ``global''
7377 register that is not affected magically by the function call mechanism.
7378
7379 In addition, different operating systems on the same CPU may differ in how they
7380 name the registers; then you need additional conditionals. For
7381 example, some 68000 operating systems call this register @code{%a5}.
7382
7383 Eventually there may be a way of asking the compiler to choose a register
7384 automatically, but first we need to figure out how it should choose and
7385 how to enable you to guide the choice. No solution is evident.
7386
7387 Defining a global register variable in a certain register reserves that
7388 register entirely for this use, at least within the current compilation.
7389 The register is not allocated for any other purpose in the functions
7390 in the current compilation, and is not saved and restored by
7391 these functions. Stores into this register are never deleted even if they
7392 appear to be dead, but references may be deleted or moved or
7393 simplified.
7394
7395 It is not safe to access the global register variables from signal
7396 handlers, or from more than one thread of control, because the system
7397 library routines may temporarily use the register for other things (unless
7398 you recompile them specially for the task at hand).
7399
7400 @cindex @code{qsort}, and global register variables
7401 It is not safe for one function that uses a global register variable to
7402 call another such function @code{foo} by way of a third function
7403 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
7404 different source file in which the variable isn't declared). This is
7405 because @code{lose} might save the register and put some other value there.
7406 For example, you can't expect a global register variable to be available in
7407 the comparison-function that you pass to @code{qsort}, since @code{qsort}
7408 might have put something else in that register. (If you are prepared to
7409 recompile @code{qsort} with the same global register variable, you can
7410 solve this problem.)
7411
7412 If you want to recompile @code{qsort} or other source files that do not
7413 actually use your global register variable, so that they do not use that
7414 register for any other purpose, then it suffices to specify the compiler
7415 option @option{-ffixed-@var{reg}}. You need not actually add a global
7416 register declaration to their source code.
7417
7418 A function that can alter the value of a global register variable cannot
7419 safely be called from a function compiled without this variable, because it
7420 could clobber the value the caller expects to find there on return.
7421 Therefore, the function that is the entry point into the part of the
7422 program that uses the global register variable must explicitly save and
7423 restore the value that belongs to its caller.
7424
7425 @cindex register variable after @code{longjmp}
7426 @cindex global register after @code{longjmp}
7427 @cindex value after @code{longjmp}
7428 @findex longjmp
7429 @findex setjmp
7430 On most machines, @code{longjmp} restores to each global register
7431 variable the value it had at the time of the @code{setjmp}. On some
7432 machines, however, @code{longjmp} does not change the value of global
7433 register variables. To be portable, the function that called @code{setjmp}
7434 should make other arrangements to save the values of the global register
7435 variables, and to restore them in a @code{longjmp}. This way, the same
7436 thing happens regardless of what @code{longjmp} does.
7437
7438 All global register variable declarations must precede all function
7439 definitions. If such a declaration could appear after function
7440 definitions, the declaration would be too late to prevent the register from
7441 being used for other purposes in the preceding functions.
7442
7443 Global register variables may not have initial values, because an
7444 executable file has no means to supply initial contents for a register.
7445
7446 On the SPARC, there are reports that g3 @dots{} g7 are suitable
7447 registers, but certain library functions, such as @code{getwd}, as well
7448 as the subroutines for division and remainder, modify g3 and g4. g1 and
7449 g2 are local temporaries.
7450
7451 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
7452 Of course, it does not do to use more than a few of those.
7453
7454 @node Local Reg Vars
7455 @subsubsection Specifying Registers for Local Variables
7456 @cindex local variables, specifying registers
7457 @cindex specifying registers for local variables
7458 @cindex registers for local variables
7459
7460 You can define a local register variable with a specified register
7461 like this:
7462
7463 @smallexample
7464 register int *foo asm ("a5");
7465 @end smallexample
7466
7467 @noindent
7468 Here @code{a5} is the name of the register that should be used. Note
7469 that this is the same syntax used for defining global register
7470 variables, but for a local variable it appears within a function.
7471
7472 Naturally the register name is cpu-dependent, but this is not a
7473 problem, since specific registers are most often useful with explicit
7474 assembler instructions (@pxref{Extended Asm}). Both of these things
7475 generally require that you conditionalize your program according to
7476 cpu type.
7477
7478 In addition, operating systems on one type of cpu may differ in how they
7479 name the registers; then you need additional conditionals. For
7480 example, some 68000 operating systems call this register @code{%a5}.
7481
7482 Defining such a register variable does not reserve the register; it
7483 remains available for other uses in places where flow control determines
7484 the variable's value is not live.
7485
7486 This option does not guarantee that GCC generates code that has
7487 this variable in the register you specify at all times. You may not
7488 code an explicit reference to this register in the @emph{assembler
7489 instruction template} part of an @code{asm} statement and assume it
7490 always refers to this variable. However, using the variable as an
7491 @code{asm} @emph{operand} guarantees that the specified register is used
7492 for the operand.
7493
7494 Stores into local register variables may be deleted when they appear to be dead
7495 according to dataflow analysis. References to local register variables may
7496 be deleted or moved or simplified.
7497
7498 As with global register variables, it is recommended that you choose a
7499 register that is normally saved and restored by function calls on
7500 your machine, so that library routines will not clobber it.
7501
7502 Sometimes when writing inline @code{asm} code, you need to make an operand be a
7503 specific register, but there's no matching constraint letter for that
7504 register. To force the operand into that register, create a local variable
7505 and specify the register in the variable's declaration. Then use the local
7506 variable for the asm operand and specify any constraint letter that matches
7507 the register:
7508
7509 @smallexample
7510 register int *p1 asm ("r0") = @dots{};
7511 register int *p2 asm ("r1") = @dots{};
7512 register int *result asm ("r0");
7513 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7514 @end smallexample
7515
7516 @emph{Warning:} In the above example, be aware that a register (for example r0) can be
7517 call-clobbered by subsequent code, including function calls and library calls
7518 for arithmetic operators on other variables (for example the initialization
7519 of p2). In this case, use temporary variables for expressions between the
7520 register assignments:
7521
7522 @smallexample
7523 int t1 = @dots{};
7524 register int *p1 asm ("r0") = @dots{};
7525 register int *p2 asm ("r1") = t1;
7526 register int *result asm ("r0");
7527 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7528 @end smallexample
7529
7530 @node Size of an asm
7531 @subsection Size of an @code{asm}
7532
7533 Some targets require that GCC track the size of each instruction used
7534 in order to generate correct code. Because the final length of the
7535 code produced by an @code{asm} statement is only known by the
7536 assembler, GCC must make an estimate as to how big it will be. It
7537 does this by counting the number of instructions in the pattern of the
7538 @code{asm} and multiplying that by the length of the longest
7539 instruction supported by that processor. (When working out the number
7540 of instructions, it assumes that any occurrence of a newline or of
7541 whatever statement separator character is supported by the assembler --
7542 typically @samp{;} --- indicates the end of an instruction.)
7543
7544 Normally, GCC's estimate is adequate to ensure that correct
7545 code is generated, but it is possible to confuse the compiler if you use
7546 pseudo instructions or assembler macros that expand into multiple real
7547 instructions, or if you use assembler directives that expand to more
7548 space in the object file than is needed for a single instruction.
7549 If this happens then the assembler may produce a diagnostic saying that
7550 a label is unreachable.
7551
7552 @node Alternate Keywords
7553 @section Alternate Keywords
7554 @cindex alternate keywords
7555 @cindex keywords, alternate
7556
7557 @option{-ansi} and the various @option{-std} options disable certain
7558 keywords. This causes trouble when you want to use GNU C extensions, or
7559 a general-purpose header file that should be usable by all programs,
7560 including ISO C programs. The keywords @code{asm}, @code{typeof} and
7561 @code{inline} are not available in programs compiled with
7562 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
7563 program compiled with @option{-std=c99} or @option{-std=c11}). The
7564 ISO C99 keyword
7565 @code{restrict} is only available when @option{-std=gnu99} (which will
7566 eventually be the default) or @option{-std=c99} (or the equivalent
7567 @option{-std=iso9899:1999}), or an option for a later standard
7568 version, is used.
7569
7570 The way to solve these problems is to put @samp{__} at the beginning and
7571 end of each problematical keyword. For example, use @code{__asm__}
7572 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
7573
7574 Other C compilers won't accept these alternative keywords; if you want to
7575 compile with another compiler, you can define the alternate keywords as
7576 macros to replace them with the customary keywords. It looks like this:
7577
7578 @smallexample
7579 #ifndef __GNUC__
7580 #define __asm__ asm
7581 #endif
7582 @end smallexample
7583
7584 @findex __extension__
7585 @opindex pedantic
7586 @option{-pedantic} and other options cause warnings for many GNU C extensions.
7587 You can
7588 prevent such warnings within one expression by writing
7589 @code{__extension__} before the expression. @code{__extension__} has no
7590 effect aside from this.
7591
7592 @node Incomplete Enums
7593 @section Incomplete @code{enum} Types
7594
7595 You can define an @code{enum} tag without specifying its possible values.
7596 This results in an incomplete type, much like what you get if you write
7597 @code{struct foo} without describing the elements. A later declaration
7598 that does specify the possible values completes the type.
7599
7600 You can't allocate variables or storage using the type while it is
7601 incomplete. However, you can work with pointers to that type.
7602
7603 This extension may not be very useful, but it makes the handling of
7604 @code{enum} more consistent with the way @code{struct} and @code{union}
7605 are handled.
7606
7607 This extension is not supported by GNU C++.
7608
7609 @node Function Names
7610 @section Function Names as Strings
7611 @cindex @code{__func__} identifier
7612 @cindex @code{__FUNCTION__} identifier
7613 @cindex @code{__PRETTY_FUNCTION__} identifier
7614
7615 GCC provides three magic variables that hold the name of the current
7616 function, as a string. The first of these is @code{__func__}, which
7617 is part of the C99 standard:
7618
7619 The identifier @code{__func__} is implicitly declared by the translator
7620 as if, immediately following the opening brace of each function
7621 definition, the declaration
7622
7623 @smallexample
7624 static const char __func__[] = "function-name";
7625 @end smallexample
7626
7627 @noindent
7628 appeared, where function-name is the name of the lexically-enclosing
7629 function. This name is the unadorned name of the function.
7630
7631 @code{__FUNCTION__} is another name for @code{__func__}. Older
7632 versions of GCC recognize only this name. However, it is not
7633 standardized. For maximum portability, we recommend you use
7634 @code{__func__}, but provide a fallback definition with the
7635 preprocessor:
7636
7637 @smallexample
7638 #if __STDC_VERSION__ < 199901L
7639 # if __GNUC__ >= 2
7640 # define __func__ __FUNCTION__
7641 # else
7642 # define __func__ "<unknown>"
7643 # endif
7644 #endif
7645 @end smallexample
7646
7647 In C, @code{__PRETTY_FUNCTION__} is yet another name for
7648 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
7649 the type signature of the function as well as its bare name. For
7650 example, this program:
7651
7652 @smallexample
7653 extern "C" @{
7654 extern int printf (char *, ...);
7655 @}
7656
7657 class a @{
7658 public:
7659 void sub (int i)
7660 @{
7661 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
7662 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
7663 @}
7664 @};
7665
7666 int
7667 main (void)
7668 @{
7669 a ax;
7670 ax.sub (0);
7671 return 0;
7672 @}
7673 @end smallexample
7674
7675 @noindent
7676 gives this output:
7677
7678 @smallexample
7679 __FUNCTION__ = sub
7680 __PRETTY_FUNCTION__ = void a::sub(int)
7681 @end smallexample
7682
7683 These identifiers are not preprocessor macros. In GCC 3.3 and
7684 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
7685 were treated as string literals; they could be used to initialize
7686 @code{char} arrays, and they could be concatenated with other string
7687 literals. GCC 3.4 and later treat them as variables, like
7688 @code{__func__}. In C++, @code{__FUNCTION__} and
7689 @code{__PRETTY_FUNCTION__} have always been variables.
7690
7691 @node Return Address
7692 @section Getting the Return or Frame Address of a Function
7693
7694 These functions may be used to get information about the callers of a
7695 function.
7696
7697 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
7698 This function returns the return address of the current function, or of
7699 one of its callers. The @var{level} argument is number of frames to
7700 scan up the call stack. A value of @code{0} yields the return address
7701 of the current function, a value of @code{1} yields the return address
7702 of the caller of the current function, and so forth. When inlining
7703 the expected behavior is that the function returns the address of
7704 the function that is returned to. To work around this behavior use
7705 the @code{noinline} function attribute.
7706
7707 The @var{level} argument must be a constant integer.
7708
7709 On some machines it may be impossible to determine the return address of
7710 any function other than the current one; in such cases, or when the top
7711 of the stack has been reached, this function returns @code{0} or a
7712 random value. In addition, @code{__builtin_frame_address} may be used
7713 to determine if the top of the stack has been reached.
7714
7715 Additional post-processing of the returned value may be needed, see
7716 @code{__builtin_extract_return_addr}.
7717
7718 This function should only be used with a nonzero argument for debugging
7719 purposes.
7720 @end deftypefn
7721
7722 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
7723 The address as returned by @code{__builtin_return_address} may have to be fed
7724 through this function to get the actual encoded address. For example, on the
7725 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
7726 platforms an offset has to be added for the true next instruction to be
7727 executed.
7728
7729 If no fixup is needed, this function simply passes through @var{addr}.
7730 @end deftypefn
7731
7732 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
7733 This function does the reverse of @code{__builtin_extract_return_addr}.
7734 @end deftypefn
7735
7736 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
7737 This function is similar to @code{__builtin_return_address}, but it
7738 returns the address of the function frame rather than the return address
7739 of the function. Calling @code{__builtin_frame_address} with a value of
7740 @code{0} yields the frame address of the current function, a value of
7741 @code{1} yields the frame address of the caller of the current function,
7742 and so forth.
7743
7744 The frame is the area on the stack that holds local variables and saved
7745 registers. The frame address is normally the address of the first word
7746 pushed on to the stack by the function. However, the exact definition
7747 depends upon the processor and the calling convention. If the processor
7748 has a dedicated frame pointer register, and the function has a frame,
7749 then @code{__builtin_frame_address} returns the value of the frame
7750 pointer register.
7751
7752 On some machines it may be impossible to determine the frame address of
7753 any function other than the current one; in such cases, or when the top
7754 of the stack has been reached, this function returns @code{0} if
7755 the first frame pointer is properly initialized by the startup code.
7756
7757 This function should only be used with a nonzero argument for debugging
7758 purposes.
7759 @end deftypefn
7760
7761 @node Vector Extensions
7762 @section Using Vector Instructions through Built-in Functions
7763
7764 On some targets, the instruction set contains SIMD vector instructions which
7765 operate on multiple values contained in one large register at the same time.
7766 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
7767 this way.
7768
7769 The first step in using these extensions is to provide the necessary data
7770 types. This should be done using an appropriate @code{typedef}:
7771
7772 @smallexample
7773 typedef int v4si __attribute__ ((vector_size (16)));
7774 @end smallexample
7775
7776 @noindent
7777 The @code{int} type specifies the base type, while the attribute specifies
7778 the vector size for the variable, measured in bytes. For example, the
7779 declaration above causes the compiler to set the mode for the @code{v4si}
7780 type to be 16 bytes wide and divided into @code{int} sized units. For
7781 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
7782 corresponding mode of @code{foo} is @acronym{V4SI}.
7783
7784 The @code{vector_size} attribute is only applicable to integral and
7785 float scalars, although arrays, pointers, and function return values
7786 are allowed in conjunction with this construct. Only sizes that are
7787 a power of two are currently allowed.
7788
7789 All the basic integer types can be used as base types, both as signed
7790 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
7791 @code{long long}. In addition, @code{float} and @code{double} can be
7792 used to build floating-point vector types.
7793
7794 Specifying a combination that is not valid for the current architecture
7795 causes GCC to synthesize the instructions using a narrower mode.
7796 For example, if you specify a variable of type @code{V4SI} and your
7797 architecture does not allow for this specific SIMD type, GCC
7798 produces code that uses 4 @code{SIs}.
7799
7800 The types defined in this manner can be used with a subset of normal C
7801 operations. Currently, GCC allows using the following operators
7802 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
7803
7804 The operations behave like C++ @code{valarrays}. Addition is defined as
7805 the addition of the corresponding elements of the operands. For
7806 example, in the code below, each of the 4 elements in @var{a} is
7807 added to the corresponding 4 elements in @var{b} and the resulting
7808 vector is stored in @var{c}.
7809
7810 @smallexample
7811 typedef int v4si __attribute__ ((vector_size (16)));
7812
7813 v4si a, b, c;
7814
7815 c = a + b;
7816 @end smallexample
7817
7818 Subtraction, multiplication, division, and the logical operations
7819 operate in a similar manner. Likewise, the result of using the unary
7820 minus or complement operators on a vector type is a vector whose
7821 elements are the negative or complemented values of the corresponding
7822 elements in the operand.
7823
7824 It is possible to use shifting operators @code{<<}, @code{>>} on
7825 integer-type vectors. The operation is defined as following: @code{@{a0,
7826 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
7827 @dots{}, an >> bn@}}@. Vector operands must have the same number of
7828 elements.
7829
7830 For convenience, it is allowed to use a binary vector operation
7831 where one operand is a scalar. In that case the compiler transforms
7832 the scalar operand into a vector where each element is the scalar from
7833 the operation. The transformation happens only if the scalar could be
7834 safely converted to the vector-element type.
7835 Consider the following code.
7836
7837 @smallexample
7838 typedef int v4si __attribute__ ((vector_size (16)));
7839
7840 v4si a, b, c;
7841 long l;
7842
7843 a = b + 1; /* a = b + @{1,1,1,1@}; */
7844 a = 2 * b; /* a = @{2,2,2,2@} * b; */
7845
7846 a = l + a; /* Error, cannot convert long to int. */
7847 @end smallexample
7848
7849 Vectors can be subscripted as if the vector were an array with
7850 the same number of elements and base type. Out of bound accesses
7851 invoke undefined behavior at run time. Warnings for out of bound
7852 accesses for vector subscription can be enabled with
7853 @option{-Warray-bounds}.
7854
7855 Vector comparison is supported with standard comparison
7856 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
7857 vector expressions of integer-type or real-type. Comparison between
7858 integer-type vectors and real-type vectors are not supported. The
7859 result of the comparison is a vector of the same width and number of
7860 elements as the comparison operands with a signed integral element
7861 type.
7862
7863 Vectors are compared element-wise producing 0 when comparison is false
7864 and -1 (constant of the appropriate type where all bits are set)
7865 otherwise. Consider the following example.
7866
7867 @smallexample
7868 typedef int v4si __attribute__ ((vector_size (16)));
7869
7870 v4si a = @{1,2,3,4@};
7871 v4si b = @{3,2,1,4@};
7872 v4si c;
7873
7874 c = a > b; /* The result would be @{0, 0,-1, 0@} */
7875 c = a == b; /* The result would be @{0,-1, 0,-1@} */
7876 @end smallexample
7877
7878 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
7879 @code{b} and @code{c} are vectors of the same type and @code{a} is an
7880 integer vector with the same number of elements of the same size as @code{b}
7881 and @code{c}, computes all three arguments and creates a vector
7882 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
7883 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
7884 As in the case of binary operations, this syntax is also accepted when
7885 one of @code{b} or @code{c} is a scalar that is then transformed into a
7886 vector. If both @code{b} and @code{c} are scalars and the type of
7887 @code{true?b:c} has the same size as the element type of @code{a}, then
7888 @code{b} and @code{c} are converted to a vector type whose elements have
7889 this type and with the same number of elements as @code{a}.
7890
7891 Vector shuffling is available using functions
7892 @code{__builtin_shuffle (vec, mask)} and
7893 @code{__builtin_shuffle (vec0, vec1, mask)}.
7894 Both functions construct a permutation of elements from one or two
7895 vectors and return a vector of the same type as the input vector(s).
7896 The @var{mask} is an integral vector with the same width (@var{W})
7897 and element count (@var{N}) as the output vector.
7898
7899 The elements of the input vectors are numbered in memory ordering of
7900 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
7901 elements of @var{mask} are considered modulo @var{N} in the single-operand
7902 case and modulo @math{2*@var{N}} in the two-operand case.
7903
7904 Consider the following example,
7905
7906 @smallexample
7907 typedef int v4si __attribute__ ((vector_size (16)));
7908
7909 v4si a = @{1,2,3,4@};
7910 v4si b = @{5,6,7,8@};
7911 v4si mask1 = @{0,1,1,3@};
7912 v4si mask2 = @{0,4,2,5@};
7913 v4si res;
7914
7915 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
7916 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
7917 @end smallexample
7918
7919 Note that @code{__builtin_shuffle} is intentionally semantically
7920 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
7921
7922 You can declare variables and use them in function calls and returns, as
7923 well as in assignments and some casts. You can specify a vector type as
7924 a return type for a function. Vector types can also be used as function
7925 arguments. It is possible to cast from one vector type to another,
7926 provided they are of the same size (in fact, you can also cast vectors
7927 to and from other datatypes of the same size).
7928
7929 You cannot operate between vectors of different lengths or different
7930 signedness without a cast.
7931
7932 @node Offsetof
7933 @section Offsetof
7934 @findex __builtin_offsetof
7935
7936 GCC implements for both C and C++ a syntactic extension to implement
7937 the @code{offsetof} macro.
7938
7939 @smallexample
7940 primary:
7941 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
7942
7943 offsetof_member_designator:
7944 @code{identifier}
7945 | offsetof_member_designator "." @code{identifier}
7946 | offsetof_member_designator "[" @code{expr} "]"
7947 @end smallexample
7948
7949 This extension is sufficient such that
7950
7951 @smallexample
7952 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
7953 @end smallexample
7954
7955 @noindent
7956 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
7957 may be dependent. In either case, @var{member} may consist of a single
7958 identifier, or a sequence of member accesses and array references.
7959
7960 @node __sync Builtins
7961 @section Legacy __sync Built-in Functions for Atomic Memory Access
7962
7963 The following built-in functions
7964 are intended to be compatible with those described
7965 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
7966 section 7.4. As such, they depart from the normal GCC practice of using
7967 the @samp{__builtin_} prefix, and further that they are overloaded such that
7968 they work on multiple types.
7969
7970 The definition given in the Intel documentation allows only for the use of
7971 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
7972 counterparts. GCC allows any integral scalar or pointer type that is
7973 1, 2, 4 or 8 bytes in length.
7974
7975 Not all operations are supported by all target processors. If a particular
7976 operation cannot be implemented on the target processor, a warning is
7977 generated and a call an external function is generated. The external
7978 function carries the same name as the built-in version,
7979 with an additional suffix
7980 @samp{_@var{n}} where @var{n} is the size of the data type.
7981
7982 @c ??? Should we have a mechanism to suppress this warning? This is almost
7983 @c useful for implementing the operation under the control of an external
7984 @c mutex.
7985
7986 In most cases, these built-in functions are considered a @dfn{full barrier}.
7987 That is,
7988 no memory operand is moved across the operation, either forward or
7989 backward. Further, instructions are issued as necessary to prevent the
7990 processor from speculating loads across the operation and from queuing stores
7991 after the operation.
7992
7993 All of the routines are described in the Intel documentation to take
7994 ``an optional list of variables protected by the memory barrier''. It's
7995 not clear what is meant by that; it could mean that @emph{only} the
7996 following variables are protected, or it could mean that these variables
7997 should in addition be protected. At present GCC ignores this list and
7998 protects all variables that are globally accessible. If in the future
7999 we make some use of this list, an empty list will continue to mean all
8000 globally accessible variables.
8001
8002 @table @code
8003 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
8004 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
8005 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
8006 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
8007 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
8008 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
8009 @findex __sync_fetch_and_add
8010 @findex __sync_fetch_and_sub
8011 @findex __sync_fetch_and_or
8012 @findex __sync_fetch_and_and
8013 @findex __sync_fetch_and_xor
8014 @findex __sync_fetch_and_nand
8015 These built-in functions perform the operation suggested by the name, and
8016 returns the value that had previously been in memory. That is,
8017
8018 @smallexample
8019 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
8020 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
8021 @end smallexample
8022
8023 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
8024 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
8025
8026 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
8027 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
8028 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
8029 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
8030 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
8031 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
8032 @findex __sync_add_and_fetch
8033 @findex __sync_sub_and_fetch
8034 @findex __sync_or_and_fetch
8035 @findex __sync_and_and_fetch
8036 @findex __sync_xor_and_fetch
8037 @findex __sync_nand_and_fetch
8038 These built-in functions perform the operation suggested by the name, and
8039 return the new value. That is,
8040
8041 @smallexample
8042 @{ *ptr @var{op}= value; return *ptr; @}
8043 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
8044 @end smallexample
8045
8046 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
8047 as @code{*ptr = ~(*ptr & value)} instead of
8048 @code{*ptr = ~*ptr & value}.
8049
8050 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8051 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8052 @findex __sync_bool_compare_and_swap
8053 @findex __sync_val_compare_and_swap
8054 These built-in functions perform an atomic compare and swap.
8055 That is, if the current
8056 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
8057 @code{*@var{ptr}}.
8058
8059 The ``bool'' version returns true if the comparison is successful and
8060 @var{newval} is written. The ``val'' version returns the contents
8061 of @code{*@var{ptr}} before the operation.
8062
8063 @item __sync_synchronize (...)
8064 @findex __sync_synchronize
8065 This built-in function issues a full memory barrier.
8066
8067 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
8068 @findex __sync_lock_test_and_set
8069 This built-in function, as described by Intel, is not a traditional test-and-set
8070 operation, but rather an atomic exchange operation. It writes @var{value}
8071 into @code{*@var{ptr}}, and returns the previous contents of
8072 @code{*@var{ptr}}.
8073
8074 Many targets have only minimal support for such locks, and do not support
8075 a full exchange operation. In this case, a target may support reduced
8076 functionality here by which the @emph{only} valid value to store is the
8077 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
8078 is implementation defined.
8079
8080 This built-in function is not a full barrier,
8081 but rather an @dfn{acquire barrier}.
8082 This means that references after the operation cannot move to (or be
8083 speculated to) before the operation, but previous memory stores may not
8084 be globally visible yet, and previous memory loads may not yet be
8085 satisfied.
8086
8087 @item void __sync_lock_release (@var{type} *ptr, ...)
8088 @findex __sync_lock_release
8089 This built-in function releases the lock acquired by
8090 @code{__sync_lock_test_and_set}.
8091 Normally this means writing the constant 0 to @code{*@var{ptr}}.
8092
8093 This built-in function is not a full barrier,
8094 but rather a @dfn{release barrier}.
8095 This means that all previous memory stores are globally visible, and all
8096 previous memory loads have been satisfied, but following memory reads
8097 are not prevented from being speculated to before the barrier.
8098 @end table
8099
8100 @node __atomic Builtins
8101 @section Built-in functions for memory model aware atomic operations
8102
8103 The following built-in functions approximately match the requirements for
8104 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
8105 functions, but all also have a memory model parameter. These are all
8106 identified by being prefixed with @samp{__atomic}, and most are overloaded
8107 such that they work with multiple types.
8108
8109 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
8110 bytes in length. 16-byte integral types are also allowed if
8111 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
8112
8113 Target architectures are encouraged to provide their own patterns for
8114 each of these built-in functions. If no target is provided, the original
8115 non-memory model set of @samp{__sync} atomic built-in functions are
8116 utilized, along with any required synchronization fences surrounding it in
8117 order to achieve the proper behavior. Execution in this case is subject
8118 to the same restrictions as those built-in functions.
8119
8120 If there is no pattern or mechanism to provide a lock free instruction
8121 sequence, a call is made to an external routine with the same parameters
8122 to be resolved at run time.
8123
8124 The four non-arithmetic functions (load, store, exchange, and
8125 compare_exchange) all have a generic version as well. This generic
8126 version works on any data type. If the data type size maps to one
8127 of the integral sizes that may have lock free support, the generic
8128 version utilizes the lock free built-in function. Otherwise an
8129 external call is left to be resolved at run time. This external call is
8130 the same format with the addition of a @samp{size_t} parameter inserted
8131 as the first parameter indicating the size of the object being pointed to.
8132 All objects must be the same size.
8133
8134 There are 6 different memory models that can be specified. These map
8135 to the same names in the C++11 standard. Refer there or to the
8136 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
8137 atomic synchronization} for more detailed definitions. These memory
8138 models integrate both barriers to code motion as well as synchronization
8139 requirements with other threads. These are listed in approximately
8140 ascending order of strength. It is also possible to use target specific
8141 flags for memory model flags, like Hardware Lock Elision.
8142
8143 @table @code
8144 @item __ATOMIC_RELAXED
8145 No barriers or synchronization.
8146 @item __ATOMIC_CONSUME
8147 Data dependency only for both barrier and synchronization with another
8148 thread.
8149 @item __ATOMIC_ACQUIRE
8150 Barrier to hoisting of code and synchronizes with release (or stronger)
8151 semantic stores from another thread.
8152 @item __ATOMIC_RELEASE
8153 Barrier to sinking of code and synchronizes with acquire (or stronger)
8154 semantic loads from another thread.
8155 @item __ATOMIC_ACQ_REL
8156 Full barrier in both directions and synchronizes with acquire loads and
8157 release stores in another thread.
8158 @item __ATOMIC_SEQ_CST
8159 Full barrier in both directions and synchronizes with acquire loads and
8160 release stores in all threads.
8161 @end table
8162
8163 When implementing patterns for these built-in functions, the memory model
8164 parameter can be ignored as long as the pattern implements the most
8165 restrictive @code{__ATOMIC_SEQ_CST} model. Any of the other memory models
8166 execute correctly with this memory model but they may not execute as
8167 efficiently as they could with a more appropriate implementation of the
8168 relaxed requirements.
8169
8170 Note that the C++11 standard allows for the memory model parameter to be
8171 determined at run time rather than at compile time. These built-in
8172 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
8173 than invoke a runtime library call or inline a switch statement. This is
8174 standard compliant, safe, and the simplest approach for now.
8175
8176 The memory model parameter is a signed int, but only the lower 8 bits are
8177 reserved for the memory model. The remainder of the signed int is reserved
8178 for future use and should be 0. Use of the predefined atomic values
8179 ensures proper usage.
8180
8181 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
8182 This built-in function implements an atomic load operation. It returns the
8183 contents of @code{*@var{ptr}}.
8184
8185 The valid memory model variants are
8186 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8187 and @code{__ATOMIC_CONSUME}.
8188
8189 @end deftypefn
8190
8191 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
8192 This is the generic version of an atomic load. It returns the
8193 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
8194
8195 @end deftypefn
8196
8197 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
8198 This built-in function implements an atomic store operation. It writes
8199 @code{@var{val}} into @code{*@var{ptr}}.
8200
8201 The valid memory model variants are
8202 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
8203
8204 @end deftypefn
8205
8206 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
8207 This is the generic version of an atomic store. It stores the value
8208 of @code{*@var{val}} into @code{*@var{ptr}}.
8209
8210 @end deftypefn
8211
8212 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
8213 This built-in function implements an atomic exchange operation. It writes
8214 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
8215 @code{*@var{ptr}}.
8216
8217 The valid memory model variants are
8218 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8219 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
8220
8221 @end deftypefn
8222
8223 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
8224 This is the generic version of an atomic exchange. It stores the
8225 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
8226 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
8227
8228 @end deftypefn
8229
8230 @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)
8231 This built-in function implements an atomic compare and exchange operation.
8232 This compares the contents of @code{*@var{ptr}} with the contents of
8233 @code{*@var{expected}} and if equal, writes @var{desired} into
8234 @code{*@var{ptr}}. If they are not equal, the current contents of
8235 @code{*@var{ptr}} is written into @code{*@var{expected}}. @var{weak} is true
8236 for weak compare_exchange, and false for the strong variation. Many targets
8237 only offer the strong variation and ignore the parameter. When in doubt, use
8238 the strong variation.
8239
8240 True is returned if @var{desired} is written into
8241 @code{*@var{ptr}} and the execution is considered to conform to the
8242 memory model specified by @var{success_memmodel}. There are no
8243 restrictions on what memory model can be used here.
8244
8245 False is returned otherwise, and the execution is considered to conform
8246 to @var{failure_memmodel}. This memory model cannot be
8247 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
8248 stronger model than that specified by @var{success_memmodel}.
8249
8250 @end deftypefn
8251
8252 @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)
8253 This built-in function implements the generic version of
8254 @code{__atomic_compare_exchange}. The function is virtually identical to
8255 @code{__atomic_compare_exchange_n}, except the desired value is also a
8256 pointer.
8257
8258 @end deftypefn
8259
8260 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8261 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8262 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8263 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8264 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8265 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8266 These built-in functions perform the operation suggested by the name, and
8267 return the result of the operation. That is,
8268
8269 @smallexample
8270 @{ *ptr @var{op}= val; return *ptr; @}
8271 @end smallexample
8272
8273 All memory models are valid.
8274
8275 @end deftypefn
8276
8277 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
8278 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
8279 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
8280 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
8281 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
8282 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
8283 These built-in functions perform the operation suggested by the name, and
8284 return the value that had previously been in @code{*@var{ptr}}. That is,
8285
8286 @smallexample
8287 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
8288 @end smallexample
8289
8290 All memory models are valid.
8291
8292 @end deftypefn
8293
8294 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
8295
8296 This built-in function performs an atomic test-and-set operation on
8297 the byte at @code{*@var{ptr}}. The byte is set to some implementation
8298 defined nonzero ``set'' value and the return value is @code{true} if and only
8299 if the previous contents were ``set''.
8300 It should be only used for operands of type @code{bool} or @code{char}. For
8301 other types only part of the value may be set.
8302
8303 All memory models are valid.
8304
8305 @end deftypefn
8306
8307 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
8308
8309 This built-in function performs an atomic clear operation on
8310 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
8311 It should be only used for operands of type @code{bool} or @code{char} and
8312 in conjunction with @code{__atomic_test_and_set}.
8313 For other types it may only clear partially. If the type is not @code{bool}
8314 prefer using @code{__atomic_store}.
8315
8316 The valid memory model variants are
8317 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
8318 @code{__ATOMIC_RELEASE}.
8319
8320 @end deftypefn
8321
8322 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
8323
8324 This built-in function acts as a synchronization fence between threads
8325 based on the specified memory model.
8326
8327 All memory orders are valid.
8328
8329 @end deftypefn
8330
8331 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
8332
8333 This built-in function acts as a synchronization fence between a thread
8334 and signal handlers based in the same thread.
8335
8336 All memory orders are valid.
8337
8338 @end deftypefn
8339
8340 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
8341
8342 This built-in function returns true if objects of @var{size} bytes always
8343 generate lock free atomic instructions for the target architecture.
8344 @var{size} must resolve to a compile-time constant and the result also
8345 resolves to a compile-time constant.
8346
8347 @var{ptr} is an optional pointer to the object that may be used to determine
8348 alignment. A value of 0 indicates typical alignment should be used. The
8349 compiler may also ignore this parameter.
8350
8351 @smallexample
8352 if (_atomic_always_lock_free (sizeof (long long), 0))
8353 @end smallexample
8354
8355 @end deftypefn
8356
8357 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
8358
8359 This built-in function returns true if objects of @var{size} bytes always
8360 generate lock free atomic instructions for the target architecture. If
8361 it is not known to be lock free a call is made to a runtime routine named
8362 @code{__atomic_is_lock_free}.
8363
8364 @var{ptr} is an optional pointer to the object that may be used to determine
8365 alignment. A value of 0 indicates typical alignment should be used. The
8366 compiler may also ignore this parameter.
8367 @end deftypefn
8368
8369 @node x86 specific memory model extensions for transactional memory
8370 @section x86 specific memory model extensions for transactional memory
8371
8372 The i386 architecture supports additional memory ordering flags
8373 to mark lock critical sections for hardware lock elision.
8374 These must be specified in addition to an existing memory model to
8375 atomic intrinsics.
8376
8377 @table @code
8378 @item __ATOMIC_HLE_ACQUIRE
8379 Start lock elision on a lock variable.
8380 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
8381 @item __ATOMIC_HLE_RELEASE
8382 End lock elision on a lock variable.
8383 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
8384 @end table
8385
8386 When a lock acquire fails it is required for good performance to abort
8387 the transaction quickly. This can be done with a @code{_mm_pause}
8388
8389 @smallexample
8390 #include <immintrin.h> // For _mm_pause
8391
8392 int lockvar;
8393
8394 /* Acquire lock with lock elision */
8395 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
8396 _mm_pause(); /* Abort failed transaction */
8397 ...
8398 /* Free lock with lock elision */
8399 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
8400 @end smallexample
8401
8402 @node Object Size Checking
8403 @section Object Size Checking Built-in Functions
8404 @findex __builtin_object_size
8405 @findex __builtin___memcpy_chk
8406 @findex __builtin___mempcpy_chk
8407 @findex __builtin___memmove_chk
8408 @findex __builtin___memset_chk
8409 @findex __builtin___strcpy_chk
8410 @findex __builtin___stpcpy_chk
8411 @findex __builtin___strncpy_chk
8412 @findex __builtin___strcat_chk
8413 @findex __builtin___strncat_chk
8414 @findex __builtin___sprintf_chk
8415 @findex __builtin___snprintf_chk
8416 @findex __builtin___vsprintf_chk
8417 @findex __builtin___vsnprintf_chk
8418 @findex __builtin___printf_chk
8419 @findex __builtin___vprintf_chk
8420 @findex __builtin___fprintf_chk
8421 @findex __builtin___vfprintf_chk
8422
8423 GCC implements a limited buffer overflow protection mechanism
8424 that can prevent some buffer overflow attacks.
8425
8426 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
8427 is a built-in construct that returns a constant number of bytes from
8428 @var{ptr} to the end of the object @var{ptr} pointer points to
8429 (if known at compile time). @code{__builtin_object_size} never evaluates
8430 its arguments for side-effects. If there are any side-effects in them, it
8431 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8432 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
8433 point to and all of them are known at compile time, the returned number
8434 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
8435 0 and minimum if nonzero. If it is not possible to determine which objects
8436 @var{ptr} points to at compile time, @code{__builtin_object_size} should
8437 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8438 for @var{type} 2 or 3.
8439
8440 @var{type} is an integer constant from 0 to 3. If the least significant
8441 bit is clear, objects are whole variables, if it is set, a closest
8442 surrounding subobject is considered the object a pointer points to.
8443 The second bit determines if maximum or minimum of remaining bytes
8444 is computed.
8445
8446 @smallexample
8447 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
8448 char *p = &var.buf1[1], *q = &var.b;
8449
8450 /* Here the object p points to is var. */
8451 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
8452 /* The subobject p points to is var.buf1. */
8453 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
8454 /* The object q points to is var. */
8455 assert (__builtin_object_size (q, 0)
8456 == (char *) (&var + 1) - (char *) &var.b);
8457 /* The subobject q points to is var.b. */
8458 assert (__builtin_object_size (q, 1) == sizeof (var.b));
8459 @end smallexample
8460 @end deftypefn
8461
8462 There are built-in functions added for many common string operation
8463 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
8464 built-in is provided. This built-in has an additional last argument,
8465 which is the number of bytes remaining in object the @var{dest}
8466 argument points to or @code{(size_t) -1} if the size is not known.
8467
8468 The built-in functions are optimized into the normal string functions
8469 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
8470 it is known at compile time that the destination object will not
8471 be overflown. If the compiler can determine at compile time the
8472 object will be always overflown, it issues a warning.
8473
8474 The intended use can be e.g.@:
8475
8476 @smallexample
8477 #undef memcpy
8478 #define bos0(dest) __builtin_object_size (dest, 0)
8479 #define memcpy(dest, src, n) \
8480 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
8481
8482 char *volatile p;
8483 char buf[10];
8484 /* It is unknown what object p points to, so this is optimized
8485 into plain memcpy - no checking is possible. */
8486 memcpy (p, "abcde", n);
8487 /* Destination is known and length too. It is known at compile
8488 time there will be no overflow. */
8489 memcpy (&buf[5], "abcde", 5);
8490 /* Destination is known, but the length is not known at compile time.
8491 This will result in __memcpy_chk call that can check for overflow
8492 at run time. */
8493 memcpy (&buf[5], "abcde", n);
8494 /* Destination is known and it is known at compile time there will
8495 be overflow. There will be a warning and __memcpy_chk call that
8496 will abort the program at run time. */
8497 memcpy (&buf[6], "abcde", 5);
8498 @end smallexample
8499
8500 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
8501 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
8502 @code{strcat} and @code{strncat}.
8503
8504 There are also checking built-in functions for formatted output functions.
8505 @smallexample
8506 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
8507 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8508 const char *fmt, ...);
8509 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
8510 va_list ap);
8511 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8512 const char *fmt, va_list ap);
8513 @end smallexample
8514
8515 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
8516 etc.@: functions and can contain implementation specific flags on what
8517 additional security measures the checking function might take, such as
8518 handling @code{%n} differently.
8519
8520 The @var{os} argument is the object size @var{s} points to, like in the
8521 other built-in functions. There is a small difference in the behavior
8522 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
8523 optimized into the non-checking functions only if @var{flag} is 0, otherwise
8524 the checking function is called with @var{os} argument set to
8525 @code{(size_t) -1}.
8526
8527 In addition to this, there are checking built-in functions
8528 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
8529 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
8530 These have just one additional argument, @var{flag}, right before
8531 format string @var{fmt}. If the compiler is able to optimize them to
8532 @code{fputc} etc.@: functions, it does, otherwise the checking function
8533 is called and the @var{flag} argument passed to it.
8534
8535 @node Cilk Plus Builtins
8536 @section Cilk Plus C/C++ language extension Built-in Functions.
8537
8538 GCC provides support for the following built-in reduction funtions if Cilk Plus
8539 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
8540
8541 @itemize @bullet
8542 @item __sec_implicit_index
8543 @item __sec_reduce
8544 @item __sec_reduce_add
8545 @item __sec_reduce_all_nonzero
8546 @item __sec_reduce_all_zero
8547 @item __sec_reduce_any_nonzero
8548 @item __sec_reduce_any_zero
8549 @item __sec_reduce_max
8550 @item __sec_reduce_min
8551 @item __sec_reduce_max_ind
8552 @item __sec_reduce_min_ind
8553 @item __sec_reduce_mul
8554 @item __sec_reduce_mutating
8555 @end itemize
8556
8557 Further details and examples about these built-in functions are described
8558 in the Cilk Plus language manual which can be found at
8559 @uref{http://www.cilkplus.org}.
8560
8561 @node Other Builtins
8562 @section Other Built-in Functions Provided by GCC
8563 @cindex built-in functions
8564 @findex __builtin_fpclassify
8565 @findex __builtin_isfinite
8566 @findex __builtin_isnormal
8567 @findex __builtin_isgreater
8568 @findex __builtin_isgreaterequal
8569 @findex __builtin_isinf_sign
8570 @findex __builtin_isless
8571 @findex __builtin_islessequal
8572 @findex __builtin_islessgreater
8573 @findex __builtin_isunordered
8574 @findex __builtin_powi
8575 @findex __builtin_powif
8576 @findex __builtin_powil
8577 @findex _Exit
8578 @findex _exit
8579 @findex abort
8580 @findex abs
8581 @findex acos
8582 @findex acosf
8583 @findex acosh
8584 @findex acoshf
8585 @findex acoshl
8586 @findex acosl
8587 @findex alloca
8588 @findex asin
8589 @findex asinf
8590 @findex asinh
8591 @findex asinhf
8592 @findex asinhl
8593 @findex asinl
8594 @findex atan
8595 @findex atan2
8596 @findex atan2f
8597 @findex atan2l
8598 @findex atanf
8599 @findex atanh
8600 @findex atanhf
8601 @findex atanhl
8602 @findex atanl
8603 @findex bcmp
8604 @findex bzero
8605 @findex cabs
8606 @findex cabsf
8607 @findex cabsl
8608 @findex cacos
8609 @findex cacosf
8610 @findex cacosh
8611 @findex cacoshf
8612 @findex cacoshl
8613 @findex cacosl
8614 @findex calloc
8615 @findex carg
8616 @findex cargf
8617 @findex cargl
8618 @findex casin
8619 @findex casinf
8620 @findex casinh
8621 @findex casinhf
8622 @findex casinhl
8623 @findex casinl
8624 @findex catan
8625 @findex catanf
8626 @findex catanh
8627 @findex catanhf
8628 @findex catanhl
8629 @findex catanl
8630 @findex cbrt
8631 @findex cbrtf
8632 @findex cbrtl
8633 @findex ccos
8634 @findex ccosf
8635 @findex ccosh
8636 @findex ccoshf
8637 @findex ccoshl
8638 @findex ccosl
8639 @findex ceil
8640 @findex ceilf
8641 @findex ceill
8642 @findex cexp
8643 @findex cexpf
8644 @findex cexpl
8645 @findex cimag
8646 @findex cimagf
8647 @findex cimagl
8648 @findex clog
8649 @findex clogf
8650 @findex clogl
8651 @findex conj
8652 @findex conjf
8653 @findex conjl
8654 @findex copysign
8655 @findex copysignf
8656 @findex copysignl
8657 @findex cos
8658 @findex cosf
8659 @findex cosh
8660 @findex coshf
8661 @findex coshl
8662 @findex cosl
8663 @findex cpow
8664 @findex cpowf
8665 @findex cpowl
8666 @findex cproj
8667 @findex cprojf
8668 @findex cprojl
8669 @findex creal
8670 @findex crealf
8671 @findex creall
8672 @findex csin
8673 @findex csinf
8674 @findex csinh
8675 @findex csinhf
8676 @findex csinhl
8677 @findex csinl
8678 @findex csqrt
8679 @findex csqrtf
8680 @findex csqrtl
8681 @findex ctan
8682 @findex ctanf
8683 @findex ctanh
8684 @findex ctanhf
8685 @findex ctanhl
8686 @findex ctanl
8687 @findex dcgettext
8688 @findex dgettext
8689 @findex drem
8690 @findex dremf
8691 @findex dreml
8692 @findex erf
8693 @findex erfc
8694 @findex erfcf
8695 @findex erfcl
8696 @findex erff
8697 @findex erfl
8698 @findex exit
8699 @findex exp
8700 @findex exp10
8701 @findex exp10f
8702 @findex exp10l
8703 @findex exp2
8704 @findex exp2f
8705 @findex exp2l
8706 @findex expf
8707 @findex expl
8708 @findex expm1
8709 @findex expm1f
8710 @findex expm1l
8711 @findex fabs
8712 @findex fabsf
8713 @findex fabsl
8714 @findex fdim
8715 @findex fdimf
8716 @findex fdiml
8717 @findex ffs
8718 @findex floor
8719 @findex floorf
8720 @findex floorl
8721 @findex fma
8722 @findex fmaf
8723 @findex fmal
8724 @findex fmax
8725 @findex fmaxf
8726 @findex fmaxl
8727 @findex fmin
8728 @findex fminf
8729 @findex fminl
8730 @findex fmod
8731 @findex fmodf
8732 @findex fmodl
8733 @findex fprintf
8734 @findex fprintf_unlocked
8735 @findex fputs
8736 @findex fputs_unlocked
8737 @findex frexp
8738 @findex frexpf
8739 @findex frexpl
8740 @findex fscanf
8741 @findex gamma
8742 @findex gammaf
8743 @findex gammal
8744 @findex gamma_r
8745 @findex gammaf_r
8746 @findex gammal_r
8747 @findex gettext
8748 @findex hypot
8749 @findex hypotf
8750 @findex hypotl
8751 @findex ilogb
8752 @findex ilogbf
8753 @findex ilogbl
8754 @findex imaxabs
8755 @findex index
8756 @findex isalnum
8757 @findex isalpha
8758 @findex isascii
8759 @findex isblank
8760 @findex iscntrl
8761 @findex isdigit
8762 @findex isgraph
8763 @findex islower
8764 @findex isprint
8765 @findex ispunct
8766 @findex isspace
8767 @findex isupper
8768 @findex iswalnum
8769 @findex iswalpha
8770 @findex iswblank
8771 @findex iswcntrl
8772 @findex iswdigit
8773 @findex iswgraph
8774 @findex iswlower
8775 @findex iswprint
8776 @findex iswpunct
8777 @findex iswspace
8778 @findex iswupper
8779 @findex iswxdigit
8780 @findex isxdigit
8781 @findex j0
8782 @findex j0f
8783 @findex j0l
8784 @findex j1
8785 @findex j1f
8786 @findex j1l
8787 @findex jn
8788 @findex jnf
8789 @findex jnl
8790 @findex labs
8791 @findex ldexp
8792 @findex ldexpf
8793 @findex ldexpl
8794 @findex lgamma
8795 @findex lgammaf
8796 @findex lgammal
8797 @findex lgamma_r
8798 @findex lgammaf_r
8799 @findex lgammal_r
8800 @findex llabs
8801 @findex llrint
8802 @findex llrintf
8803 @findex llrintl
8804 @findex llround
8805 @findex llroundf
8806 @findex llroundl
8807 @findex log
8808 @findex log10
8809 @findex log10f
8810 @findex log10l
8811 @findex log1p
8812 @findex log1pf
8813 @findex log1pl
8814 @findex log2
8815 @findex log2f
8816 @findex log2l
8817 @findex logb
8818 @findex logbf
8819 @findex logbl
8820 @findex logf
8821 @findex logl
8822 @findex lrint
8823 @findex lrintf
8824 @findex lrintl
8825 @findex lround
8826 @findex lroundf
8827 @findex lroundl
8828 @findex malloc
8829 @findex memchr
8830 @findex memcmp
8831 @findex memcpy
8832 @findex mempcpy
8833 @findex memset
8834 @findex modf
8835 @findex modff
8836 @findex modfl
8837 @findex nearbyint
8838 @findex nearbyintf
8839 @findex nearbyintl
8840 @findex nextafter
8841 @findex nextafterf
8842 @findex nextafterl
8843 @findex nexttoward
8844 @findex nexttowardf
8845 @findex nexttowardl
8846 @findex pow
8847 @findex pow10
8848 @findex pow10f
8849 @findex pow10l
8850 @findex powf
8851 @findex powl
8852 @findex printf
8853 @findex printf_unlocked
8854 @findex putchar
8855 @findex puts
8856 @findex remainder
8857 @findex remainderf
8858 @findex remainderl
8859 @findex remquo
8860 @findex remquof
8861 @findex remquol
8862 @findex rindex
8863 @findex rint
8864 @findex rintf
8865 @findex rintl
8866 @findex round
8867 @findex roundf
8868 @findex roundl
8869 @findex scalb
8870 @findex scalbf
8871 @findex scalbl
8872 @findex scalbln
8873 @findex scalblnf
8874 @findex scalblnf
8875 @findex scalbn
8876 @findex scalbnf
8877 @findex scanfnl
8878 @findex signbit
8879 @findex signbitf
8880 @findex signbitl
8881 @findex signbitd32
8882 @findex signbitd64
8883 @findex signbitd128
8884 @findex significand
8885 @findex significandf
8886 @findex significandl
8887 @findex sin
8888 @findex sincos
8889 @findex sincosf
8890 @findex sincosl
8891 @findex sinf
8892 @findex sinh
8893 @findex sinhf
8894 @findex sinhl
8895 @findex sinl
8896 @findex snprintf
8897 @findex sprintf
8898 @findex sqrt
8899 @findex sqrtf
8900 @findex sqrtl
8901 @findex sscanf
8902 @findex stpcpy
8903 @findex stpncpy
8904 @findex strcasecmp
8905 @findex strcat
8906 @findex strchr
8907 @findex strcmp
8908 @findex strcpy
8909 @findex strcspn
8910 @findex strdup
8911 @findex strfmon
8912 @findex strftime
8913 @findex strlen
8914 @findex strncasecmp
8915 @findex strncat
8916 @findex strncmp
8917 @findex strncpy
8918 @findex strndup
8919 @findex strpbrk
8920 @findex strrchr
8921 @findex strspn
8922 @findex strstr
8923 @findex tan
8924 @findex tanf
8925 @findex tanh
8926 @findex tanhf
8927 @findex tanhl
8928 @findex tanl
8929 @findex tgamma
8930 @findex tgammaf
8931 @findex tgammal
8932 @findex toascii
8933 @findex tolower
8934 @findex toupper
8935 @findex towlower
8936 @findex towupper
8937 @findex trunc
8938 @findex truncf
8939 @findex truncl
8940 @findex vfprintf
8941 @findex vfscanf
8942 @findex vprintf
8943 @findex vscanf
8944 @findex vsnprintf
8945 @findex vsprintf
8946 @findex vsscanf
8947 @findex y0
8948 @findex y0f
8949 @findex y0l
8950 @findex y1
8951 @findex y1f
8952 @findex y1l
8953 @findex yn
8954 @findex ynf
8955 @findex ynl
8956
8957 GCC provides a large number of built-in functions other than the ones
8958 mentioned above. Some of these are for internal use in the processing
8959 of exceptions or variable-length argument lists and are not
8960 documented here because they may change from time to time; we do not
8961 recommend general use of these functions.
8962
8963 The remaining functions are provided for optimization purposes.
8964
8965 @opindex fno-builtin
8966 GCC includes built-in versions of many of the functions in the standard
8967 C library. The versions prefixed with @code{__builtin_} are always
8968 treated as having the same meaning as the C library function even if you
8969 specify the @option{-fno-builtin} option. (@pxref{C Dialect Options})
8970 Many of these functions are only optimized in certain cases; if they are
8971 not optimized in a particular case, a call to the library function is
8972 emitted.
8973
8974 @opindex ansi
8975 @opindex std
8976 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
8977 @option{-std=c99} or @option{-std=c11}), the functions
8978 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
8979 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
8980 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
8981 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
8982 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
8983 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
8984 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
8985 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
8986 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
8987 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
8988 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
8989 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
8990 @code{signbitd64}, @code{signbitd128}, @code{significandf},
8991 @code{significandl}, @code{significand}, @code{sincosf},
8992 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
8993 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
8994 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
8995 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
8996 @code{yn}
8997 may be handled as built-in functions.
8998 All these functions have corresponding versions
8999 prefixed with @code{__builtin_}, which may be used even in strict C90
9000 mode.
9001
9002 The ISO C99 functions
9003 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
9004 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
9005 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
9006 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
9007 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
9008 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
9009 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
9010 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
9011 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
9012 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
9013 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
9014 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
9015 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
9016 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
9017 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
9018 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
9019 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
9020 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
9021 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
9022 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
9023 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
9024 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
9025 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
9026 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
9027 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
9028 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
9029 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
9030 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
9031 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
9032 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
9033 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
9034 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
9035 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
9036 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
9037 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
9038 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
9039 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
9040 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
9041 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
9042 are handled as built-in functions
9043 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9044
9045 There are also built-in versions of the ISO C99 functions
9046 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
9047 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
9048 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
9049 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
9050 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
9051 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
9052 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
9053 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
9054 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
9055 that are recognized in any mode since ISO C90 reserves these names for
9056 the purpose to which ISO C99 puts them. All these functions have
9057 corresponding versions prefixed with @code{__builtin_}.
9058
9059 The ISO C94 functions
9060 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
9061 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
9062 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
9063 @code{towupper}
9064 are handled as built-in functions
9065 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9066
9067 The ISO C90 functions
9068 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
9069 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
9070 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
9071 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
9072 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
9073 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
9074 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
9075 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
9076 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
9077 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
9078 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
9079 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
9080 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
9081 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
9082 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
9083 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
9084 are all recognized as built-in functions unless
9085 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
9086 is specified for an individual function). All of these functions have
9087 corresponding versions prefixed with @code{__builtin_}.
9088
9089 GCC provides built-in versions of the ISO C99 floating-point comparison
9090 macros that avoid raising exceptions for unordered operands. They have
9091 the same names as the standard macros ( @code{isgreater},
9092 @code{isgreaterequal}, @code{isless}, @code{islessequal},
9093 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
9094 prefixed. We intend for a library implementor to be able to simply
9095 @code{#define} each standard macro to its built-in equivalent.
9096 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
9097 @code{isinf_sign} and @code{isnormal} built-ins used with
9098 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
9099 built-in functions appear both with and without the @code{__builtin_} prefix.
9100
9101 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
9102
9103 You can use the built-in function @code{__builtin_types_compatible_p} to
9104 determine whether two types are the same.
9105
9106 This built-in function returns 1 if the unqualified versions of the
9107 types @var{type1} and @var{type2} (which are types, not expressions) are
9108 compatible, 0 otherwise. The result of this built-in function can be
9109 used in integer constant expressions.
9110
9111 This built-in function ignores top level qualifiers (e.g., @code{const},
9112 @code{volatile}). For example, @code{int} is equivalent to @code{const
9113 int}.
9114
9115 The type @code{int[]} and @code{int[5]} are compatible. On the other
9116 hand, @code{int} and @code{char *} are not compatible, even if the size
9117 of their types, on the particular architecture are the same. Also, the
9118 amount of pointer indirection is taken into account when determining
9119 similarity. Consequently, @code{short *} is not similar to
9120 @code{short **}. Furthermore, two types that are typedefed are
9121 considered compatible if their underlying types are compatible.
9122
9123 An @code{enum} type is not considered to be compatible with another
9124 @code{enum} type even if both are compatible with the same integer
9125 type; this is what the C standard specifies.
9126 For example, @code{enum @{foo, bar@}} is not similar to
9127 @code{enum @{hot, dog@}}.
9128
9129 You typically use this function in code whose execution varies
9130 depending on the arguments' types. For example:
9131
9132 @smallexample
9133 #define foo(x) \
9134 (@{ \
9135 typeof (x) tmp = (x); \
9136 if (__builtin_types_compatible_p (typeof (x), long double)) \
9137 tmp = foo_long_double (tmp); \
9138 else if (__builtin_types_compatible_p (typeof (x), double)) \
9139 tmp = foo_double (tmp); \
9140 else if (__builtin_types_compatible_p (typeof (x), float)) \
9141 tmp = foo_float (tmp); \
9142 else \
9143 abort (); \
9144 tmp; \
9145 @})
9146 @end smallexample
9147
9148 @emph{Note:} This construct is only available for C@.
9149
9150 @end deftypefn
9151
9152 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
9153
9154 You can use the built-in function @code{__builtin_choose_expr} to
9155 evaluate code depending on the value of a constant expression. This
9156 built-in function returns @var{exp1} if @var{const_exp}, which is an
9157 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
9158
9159 This built-in function is analogous to the @samp{? :} operator in C,
9160 except that the expression returned has its type unaltered by promotion
9161 rules. Also, the built-in function does not evaluate the expression
9162 that is not chosen. For example, if @var{const_exp} evaluates to true,
9163 @var{exp2} is not evaluated even if it has side-effects.
9164
9165 This built-in function can return an lvalue if the chosen argument is an
9166 lvalue.
9167
9168 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
9169 type. Similarly, if @var{exp2} is returned, its return type is the same
9170 as @var{exp2}.
9171
9172 Example:
9173
9174 @smallexample
9175 #define foo(x) \
9176 __builtin_choose_expr ( \
9177 __builtin_types_compatible_p (typeof (x), double), \
9178 foo_double (x), \
9179 __builtin_choose_expr ( \
9180 __builtin_types_compatible_p (typeof (x), float), \
9181 foo_float (x), \
9182 /* @r{The void expression results in a compile-time error} \
9183 @r{when assigning the result to something.} */ \
9184 (void)0))
9185 @end smallexample
9186
9187 @emph{Note:} This construct is only available for C@. Furthermore, the
9188 unused expression (@var{exp1} or @var{exp2} depending on the value of
9189 @var{const_exp}) may still generate syntax errors. This may change in
9190 future revisions.
9191
9192 @end deftypefn
9193
9194 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
9195
9196 The built-in function @code{__builtin_complex} is provided for use in
9197 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
9198 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
9199 real binary floating-point type, and the result has the corresponding
9200 complex type with real and imaginary parts @var{real} and @var{imag}.
9201 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
9202 infinities, NaNs and negative zeros are involved.
9203
9204 @end deftypefn
9205
9206 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
9207 You can use the built-in function @code{__builtin_constant_p} to
9208 determine if a value is known to be constant at compile time and hence
9209 that GCC can perform constant-folding on expressions involving that
9210 value. The argument of the function is the value to test. The function
9211 returns the integer 1 if the argument is known to be a compile-time
9212 constant and 0 if it is not known to be a compile-time constant. A
9213 return of 0 does not indicate that the value is @emph{not} a constant,
9214 but merely that GCC cannot prove it is a constant with the specified
9215 value of the @option{-O} option.
9216
9217 You typically use this function in an embedded application where
9218 memory is a critical resource. If you have some complex calculation,
9219 you may want it to be folded if it involves constants, but need to call
9220 a function if it does not. For example:
9221
9222 @smallexample
9223 #define Scale_Value(X) \
9224 (__builtin_constant_p (X) \
9225 ? ((X) * SCALE + OFFSET) : Scale (X))
9226 @end smallexample
9227
9228 You may use this built-in function in either a macro or an inline
9229 function. However, if you use it in an inlined function and pass an
9230 argument of the function as the argument to the built-in, GCC
9231 never returns 1 when you call the inline function with a string constant
9232 or compound literal (@pxref{Compound Literals}) and does not return 1
9233 when you pass a constant numeric value to the inline function unless you
9234 specify the @option{-O} option.
9235
9236 You may also use @code{__builtin_constant_p} in initializers for static
9237 data. For instance, you can write
9238
9239 @smallexample
9240 static const int table[] = @{
9241 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
9242 /* @r{@dots{}} */
9243 @};
9244 @end smallexample
9245
9246 @noindent
9247 This is an acceptable initializer even if @var{EXPRESSION} is not a
9248 constant expression, including the case where
9249 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
9250 folded to a constant but @var{EXPRESSION} contains operands that are
9251 not otherwise permitted in a static initializer (for example,
9252 @code{0 && foo ()}). GCC must be more conservative about evaluating the
9253 built-in in this case, because it has no opportunity to perform
9254 optimization.
9255
9256 Previous versions of GCC did not accept this built-in in data
9257 initializers. The earliest version where it is completely safe is
9258 3.0.1.
9259 @end deftypefn
9260
9261 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
9262 @opindex fprofile-arcs
9263 You may use @code{__builtin_expect} to provide the compiler with
9264 branch prediction information. In general, you should prefer to
9265 use actual profile feedback for this (@option{-fprofile-arcs}), as
9266 programmers are notoriously bad at predicting how their programs
9267 actually perform. However, there are applications in which this
9268 data is hard to collect.
9269
9270 The return value is the value of @var{exp}, which should be an integral
9271 expression. The semantics of the built-in are that it is expected that
9272 @var{exp} == @var{c}. For example:
9273
9274 @smallexample
9275 if (__builtin_expect (x, 0))
9276 foo ();
9277 @end smallexample
9278
9279 @noindent
9280 indicates that we do not expect to call @code{foo}, since
9281 we expect @code{x} to be zero. Since you are limited to integral
9282 expressions for @var{exp}, you should use constructions such as
9283
9284 @smallexample
9285 if (__builtin_expect (ptr != NULL, 1))
9286 foo (*ptr);
9287 @end smallexample
9288
9289 @noindent
9290 when testing pointer or floating-point values.
9291 @end deftypefn
9292
9293 @deftypefn {Built-in Function} void __builtin_trap (void)
9294 This function causes the program to exit abnormally. GCC implements
9295 this function by using a target-dependent mechanism (such as
9296 intentionally executing an illegal instruction) or by calling
9297 @code{abort}. The mechanism used may vary from release to release so
9298 you should not rely on any particular implementation.
9299 @end deftypefn
9300
9301 @deftypefn {Built-in Function} void __builtin_unreachable (void)
9302 If control flow reaches the point of the @code{__builtin_unreachable},
9303 the program is undefined. It is useful in situations where the
9304 compiler cannot deduce the unreachability of the code.
9305
9306 One such case is immediately following an @code{asm} statement that
9307 either never terminates, or one that transfers control elsewhere
9308 and never returns. In this example, without the
9309 @code{__builtin_unreachable}, GCC issues a warning that control
9310 reaches the end of a non-void function. It also generates code
9311 to return after the @code{asm}.
9312
9313 @smallexample
9314 int f (int c, int v)
9315 @{
9316 if (c)
9317 @{
9318 return v;
9319 @}
9320 else
9321 @{
9322 asm("jmp error_handler");
9323 __builtin_unreachable ();
9324 @}
9325 @}
9326 @end smallexample
9327
9328 @noindent
9329 Because the @code{asm} statement unconditionally transfers control out
9330 of the function, control never reaches the end of the function
9331 body. The @code{__builtin_unreachable} is in fact unreachable and
9332 communicates this fact to the compiler.
9333
9334 Another use for @code{__builtin_unreachable} is following a call a
9335 function that never returns but that is not declared
9336 @code{__attribute__((noreturn))}, as in this example:
9337
9338 @smallexample
9339 void function_that_never_returns (void);
9340
9341 int g (int c)
9342 @{
9343 if (c)
9344 @{
9345 return 1;
9346 @}
9347 else
9348 @{
9349 function_that_never_returns ();
9350 __builtin_unreachable ();
9351 @}
9352 @}
9353 @end smallexample
9354
9355 @end deftypefn
9356
9357 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
9358 This function returns its first argument, and allows the compiler
9359 to assume that the returned pointer is at least @var{align} bytes
9360 aligned. This built-in can have either two or three arguments,
9361 if it has three, the third argument should have integer type, and
9362 if it is nonzero means misalignment offset. For example:
9363
9364 @smallexample
9365 void *x = __builtin_assume_aligned (arg, 16);
9366 @end smallexample
9367
9368 @noindent
9369 means that the compiler can assume @code{x}, set to @code{arg}, is at least
9370 16-byte aligned, while:
9371
9372 @smallexample
9373 void *x = __builtin_assume_aligned (arg, 32, 8);
9374 @end smallexample
9375
9376 @noindent
9377 means that the compiler can assume for @code{x}, set to @code{arg}, that
9378 @code{(char *) x - 8} is 32-byte aligned.
9379 @end deftypefn
9380
9381 @deftypefn {Built-in Function} int __builtin_LINE ()
9382 This function is the equivalent to the preprocessor @code{__LINE__}
9383 macro and returns the line number of the invocation of the built-in.
9384 In a C++ default argument for a function @var{F}, it gets the line number of
9385 the call to @var{F}.
9386 @end deftypefn
9387
9388 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
9389 This function is the equivalent to the preprocessor @code{__FUNCTION__}
9390 macro and returns the function name the invocation of the built-in is in.
9391 @end deftypefn
9392
9393 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
9394 This function is the equivalent to the preprocessor @code{__FILE__}
9395 macro and returns the file name the invocation of the built-in is in.
9396 In a C++ default argument for a function @var{F}, it gets the file name of
9397 the call to @var{F}.
9398 @end deftypefn
9399
9400 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
9401 This function is used to flush the processor's instruction cache for
9402 the region of memory between @var{begin} inclusive and @var{end}
9403 exclusive. Some targets require that the instruction cache be
9404 flushed, after modifying memory containing code, in order to obtain
9405 deterministic behavior.
9406
9407 If the target does not require instruction cache flushes,
9408 @code{__builtin___clear_cache} has no effect. Otherwise either
9409 instructions are emitted in-line to clear the instruction cache or a
9410 call to the @code{__clear_cache} function in libgcc is made.
9411 @end deftypefn
9412
9413 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
9414 This function is used to minimize cache-miss latency by moving data into
9415 a cache before it is accessed.
9416 You can insert calls to @code{__builtin_prefetch} into code for which
9417 you know addresses of data in memory that is likely to be accessed soon.
9418 If the target supports them, data prefetch instructions are generated.
9419 If the prefetch is done early enough before the access then the data will
9420 be in the cache by the time it is accessed.
9421
9422 The value of @var{addr} is the address of the memory to prefetch.
9423 There are two optional arguments, @var{rw} and @var{locality}.
9424 The value of @var{rw} is a compile-time constant one or zero; one
9425 means that the prefetch is preparing for a write to the memory address
9426 and zero, the default, means that the prefetch is preparing for a read.
9427 The value @var{locality} must be a compile-time constant integer between
9428 zero and three. A value of zero means that the data has no temporal
9429 locality, so it need not be left in the cache after the access. A value
9430 of three means that the data has a high degree of temporal locality and
9431 should be left in all levels of cache possible. Values of one and two
9432 mean, respectively, a low or moderate degree of temporal locality. The
9433 default is three.
9434
9435 @smallexample
9436 for (i = 0; i < n; i++)
9437 @{
9438 a[i] = a[i] + b[i];
9439 __builtin_prefetch (&a[i+j], 1, 1);
9440 __builtin_prefetch (&b[i+j], 0, 1);
9441 /* @r{@dots{}} */
9442 @}
9443 @end smallexample
9444
9445 Data prefetch does not generate faults if @var{addr} is invalid, but
9446 the address expression itself must be valid. For example, a prefetch
9447 of @code{p->next} does not fault if @code{p->next} is not a valid
9448 address, but evaluation faults if @code{p} is not a valid address.
9449
9450 If the target does not support data prefetch, the address expression
9451 is evaluated if it includes side effects but no other code is generated
9452 and GCC does not issue a warning.
9453 @end deftypefn
9454
9455 @deftypefn {Built-in Function} double __builtin_huge_val (void)
9456 Returns a positive infinity, if supported by the floating-point format,
9457 else @code{DBL_MAX}. This function is suitable for implementing the
9458 ISO C macro @code{HUGE_VAL}.
9459 @end deftypefn
9460
9461 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
9462 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
9463 @end deftypefn
9464
9465 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
9466 Similar to @code{__builtin_huge_val}, except the return
9467 type is @code{long double}.
9468 @end deftypefn
9469
9470 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
9471 This built-in implements the C99 fpclassify functionality. The first
9472 five int arguments should be the target library's notion of the
9473 possible FP classes and are used for return values. They must be
9474 constant values and they must appear in this order: @code{FP_NAN},
9475 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
9476 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
9477 to classify. GCC treats the last argument as type-generic, which
9478 means it does not do default promotion from float to double.
9479 @end deftypefn
9480
9481 @deftypefn {Built-in Function} double __builtin_inf (void)
9482 Similar to @code{__builtin_huge_val}, except a warning is generated
9483 if the target floating-point format does not support infinities.
9484 @end deftypefn
9485
9486 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
9487 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
9488 @end deftypefn
9489
9490 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
9491 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
9492 @end deftypefn
9493
9494 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
9495 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
9496 @end deftypefn
9497
9498 @deftypefn {Built-in Function} float __builtin_inff (void)
9499 Similar to @code{__builtin_inf}, except the return type is @code{float}.
9500 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
9501 @end deftypefn
9502
9503 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
9504 Similar to @code{__builtin_inf}, except the return
9505 type is @code{long double}.
9506 @end deftypefn
9507
9508 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
9509 Similar to @code{isinf}, except the return value is -1 for
9510 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
9511 Note while the parameter list is an
9512 ellipsis, this function only accepts exactly one floating-point
9513 argument. GCC treats this parameter as type-generic, which means it
9514 does not do default promotion from float to double.
9515 @end deftypefn
9516
9517 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
9518 This is an implementation of the ISO C99 function @code{nan}.
9519
9520 Since ISO C99 defines this function in terms of @code{strtod}, which we
9521 do not implement, a description of the parsing is in order. The string
9522 is parsed as by @code{strtol}; that is, the base is recognized by
9523 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
9524 in the significand such that the least significant bit of the number
9525 is at the least significant bit of the significand. The number is
9526 truncated to fit the significand field provided. The significand is
9527 forced to be a quiet NaN@.
9528
9529 This function, if given a string literal all of which would have been
9530 consumed by @code{strtol}, is evaluated early enough that it is considered a
9531 compile-time constant.
9532 @end deftypefn
9533
9534 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
9535 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
9536 @end deftypefn
9537
9538 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
9539 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
9540 @end deftypefn
9541
9542 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
9543 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
9544 @end deftypefn
9545
9546 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
9547 Similar to @code{__builtin_nan}, except the return type is @code{float}.
9548 @end deftypefn
9549
9550 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
9551 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
9552 @end deftypefn
9553
9554 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
9555 Similar to @code{__builtin_nan}, except the significand is forced
9556 to be a signaling NaN@. The @code{nans} function is proposed by
9557 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
9558 @end deftypefn
9559
9560 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
9561 Similar to @code{__builtin_nans}, except the return type is @code{float}.
9562 @end deftypefn
9563
9564 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
9565 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
9566 @end deftypefn
9567
9568 @deftypefn {Built-in Function} int __builtin_ffs (int x)
9569 Returns one plus the index of the least significant 1-bit of @var{x}, or
9570 if @var{x} is zero, returns zero.
9571 @end deftypefn
9572
9573 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
9574 Returns the number of leading 0-bits in @var{x}, starting at the most
9575 significant bit position. If @var{x} is 0, the result is undefined.
9576 @end deftypefn
9577
9578 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
9579 Returns the number of trailing 0-bits in @var{x}, starting at the least
9580 significant bit position. If @var{x} is 0, the result is undefined.
9581 @end deftypefn
9582
9583 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
9584 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
9585 number of bits following the most significant bit that are identical
9586 to it. There are no special cases for 0 or other values.
9587 @end deftypefn
9588
9589 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
9590 Returns the number of 1-bits in @var{x}.
9591 @end deftypefn
9592
9593 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
9594 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
9595 modulo 2.
9596 @end deftypefn
9597
9598 @deftypefn {Built-in Function} int __builtin_ffsl (long)
9599 Similar to @code{__builtin_ffs}, except the argument type is
9600 @code{long}.
9601 @end deftypefn
9602
9603 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
9604 Similar to @code{__builtin_clz}, except the argument type is
9605 @code{unsigned long}.
9606 @end deftypefn
9607
9608 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
9609 Similar to @code{__builtin_ctz}, except the argument type is
9610 @code{unsigned long}.
9611 @end deftypefn
9612
9613 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
9614 Similar to @code{__builtin_clrsb}, except the argument type is
9615 @code{long}.
9616 @end deftypefn
9617
9618 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
9619 Similar to @code{__builtin_popcount}, except the argument type is
9620 @code{unsigned long}.
9621 @end deftypefn
9622
9623 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
9624 Similar to @code{__builtin_parity}, except the argument type is
9625 @code{unsigned long}.
9626 @end deftypefn
9627
9628 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
9629 Similar to @code{__builtin_ffs}, except the argument type is
9630 @code{long long}.
9631 @end deftypefn
9632
9633 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
9634 Similar to @code{__builtin_clz}, except the argument type is
9635 @code{unsigned long long}.
9636 @end deftypefn
9637
9638 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
9639 Similar to @code{__builtin_ctz}, except the argument type is
9640 @code{unsigned long long}.
9641 @end deftypefn
9642
9643 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
9644 Similar to @code{__builtin_clrsb}, except the argument type is
9645 @code{long long}.
9646 @end deftypefn
9647
9648 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
9649 Similar to @code{__builtin_popcount}, except the argument type is
9650 @code{unsigned long long}.
9651 @end deftypefn
9652
9653 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
9654 Similar to @code{__builtin_parity}, except the argument type is
9655 @code{unsigned long long}.
9656 @end deftypefn
9657
9658 @deftypefn {Built-in Function} double __builtin_powi (double, int)
9659 Returns the first argument raised to the power of the second. Unlike the
9660 @code{pow} function no guarantees about precision and rounding are made.
9661 @end deftypefn
9662
9663 @deftypefn {Built-in Function} float __builtin_powif (float, int)
9664 Similar to @code{__builtin_powi}, except the argument and return types
9665 are @code{float}.
9666 @end deftypefn
9667
9668 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
9669 Similar to @code{__builtin_powi}, except the argument and return types
9670 are @code{long double}.
9671 @end deftypefn
9672
9673 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
9674 Returns @var{x} with the order of the bytes reversed; for example,
9675 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
9676 exactly 8 bits.
9677 @end deftypefn
9678
9679 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
9680 Similar to @code{__builtin_bswap16}, except the argument and return types
9681 are 32 bit.
9682 @end deftypefn
9683
9684 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
9685 Similar to @code{__builtin_bswap32}, except the argument and return types
9686 are 64 bit.
9687 @end deftypefn
9688
9689 @node Target Builtins
9690 @section Built-in Functions Specific to Particular Target Machines
9691
9692 On some target machines, GCC supports many built-in functions specific
9693 to those machines. Generally these generate calls to specific machine
9694 instructions, but allow the compiler to schedule those calls.
9695
9696 @menu
9697 * AArch64 Built-in Functions::
9698 * Alpha Built-in Functions::
9699 * Altera Nios II Built-in Functions::
9700 * ARC Built-in Functions::
9701 * ARC SIMD Built-in Functions::
9702 * ARM iWMMXt Built-in Functions::
9703 * ARM NEON Intrinsics::
9704 * ARM ACLE Intrinsics::
9705 * AVR Built-in Functions::
9706 * Blackfin Built-in Functions::
9707 * FR-V Built-in Functions::
9708 * X86 Built-in Functions::
9709 * X86 transactional memory intrinsics::
9710 * MIPS DSP Built-in Functions::
9711 * MIPS Paired-Single Support::
9712 * MIPS Loongson Built-in Functions::
9713 * Other MIPS Built-in Functions::
9714 * MSP430 Built-in Functions::
9715 * NDS32 Built-in Functions::
9716 * picoChip Built-in Functions::
9717 * PowerPC Built-in Functions::
9718 * PowerPC AltiVec/VSX Built-in Functions::
9719 * PowerPC Hardware Transactional Memory Built-in Functions::
9720 * RX Built-in Functions::
9721 * S/390 System z Built-in Functions::
9722 * SH Built-in Functions::
9723 * SPARC VIS Built-in Functions::
9724 * SPU Built-in Functions::
9725 * TI C6X Built-in Functions::
9726 * TILE-Gx Built-in Functions::
9727 * TILEPro Built-in Functions::
9728 @end menu
9729
9730 @node AArch64 Built-in Functions
9731 @subsection AArch64 Built-in Functions
9732
9733 These built-in functions are available for the AArch64 family of
9734 processors.
9735 @smallexample
9736 unsigned int __builtin_aarch64_get_fpcr ()
9737 void __builtin_aarch64_set_fpcr (unsigned int)
9738 unsigned int __builtin_aarch64_get_fpsr ()
9739 void __builtin_aarch64_set_fpsr (unsigned int)
9740 @end smallexample
9741
9742 @node Alpha Built-in Functions
9743 @subsection Alpha Built-in Functions
9744
9745 These built-in functions are available for the Alpha family of
9746 processors, depending on the command-line switches used.
9747
9748 The following built-in functions are always available. They
9749 all generate the machine instruction that is part of the name.
9750
9751 @smallexample
9752 long __builtin_alpha_implver (void)
9753 long __builtin_alpha_rpcc (void)
9754 long __builtin_alpha_amask (long)
9755 long __builtin_alpha_cmpbge (long, long)
9756 long __builtin_alpha_extbl (long, long)
9757 long __builtin_alpha_extwl (long, long)
9758 long __builtin_alpha_extll (long, long)
9759 long __builtin_alpha_extql (long, long)
9760 long __builtin_alpha_extwh (long, long)
9761 long __builtin_alpha_extlh (long, long)
9762 long __builtin_alpha_extqh (long, long)
9763 long __builtin_alpha_insbl (long, long)
9764 long __builtin_alpha_inswl (long, long)
9765 long __builtin_alpha_insll (long, long)
9766 long __builtin_alpha_insql (long, long)
9767 long __builtin_alpha_inswh (long, long)
9768 long __builtin_alpha_inslh (long, long)
9769 long __builtin_alpha_insqh (long, long)
9770 long __builtin_alpha_mskbl (long, long)
9771 long __builtin_alpha_mskwl (long, long)
9772 long __builtin_alpha_mskll (long, long)
9773 long __builtin_alpha_mskql (long, long)
9774 long __builtin_alpha_mskwh (long, long)
9775 long __builtin_alpha_msklh (long, long)
9776 long __builtin_alpha_mskqh (long, long)
9777 long __builtin_alpha_umulh (long, long)
9778 long __builtin_alpha_zap (long, long)
9779 long __builtin_alpha_zapnot (long, long)
9780 @end smallexample
9781
9782 The following built-in functions are always with @option{-mmax}
9783 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
9784 later. They all generate the machine instruction that is part
9785 of the name.
9786
9787 @smallexample
9788 long __builtin_alpha_pklb (long)
9789 long __builtin_alpha_pkwb (long)
9790 long __builtin_alpha_unpkbl (long)
9791 long __builtin_alpha_unpkbw (long)
9792 long __builtin_alpha_minub8 (long, long)
9793 long __builtin_alpha_minsb8 (long, long)
9794 long __builtin_alpha_minuw4 (long, long)
9795 long __builtin_alpha_minsw4 (long, long)
9796 long __builtin_alpha_maxub8 (long, long)
9797 long __builtin_alpha_maxsb8 (long, long)
9798 long __builtin_alpha_maxuw4 (long, long)
9799 long __builtin_alpha_maxsw4 (long, long)
9800 long __builtin_alpha_perr (long, long)
9801 @end smallexample
9802
9803 The following built-in functions are always with @option{-mcix}
9804 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
9805 later. They all generate the machine instruction that is part
9806 of the name.
9807
9808 @smallexample
9809 long __builtin_alpha_cttz (long)
9810 long __builtin_alpha_ctlz (long)
9811 long __builtin_alpha_ctpop (long)
9812 @end smallexample
9813
9814 The following built-in functions are available on systems that use the OSF/1
9815 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
9816 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
9817 @code{rdval} and @code{wrval}.
9818
9819 @smallexample
9820 void *__builtin_thread_pointer (void)
9821 void __builtin_set_thread_pointer (void *)
9822 @end smallexample
9823
9824 @node Altera Nios II Built-in Functions
9825 @subsection Altera Nios II Built-in Functions
9826
9827 These built-in functions are available for the Altera Nios II
9828 family of processors.
9829
9830 The following built-in functions are always available. They
9831 all generate the machine instruction that is part of the name.
9832
9833 @example
9834 int __builtin_ldbio (volatile const void *)
9835 int __builtin_ldbuio (volatile const void *)
9836 int __builtin_ldhio (volatile const void *)
9837 int __builtin_ldhuio (volatile const void *)
9838 int __builtin_ldwio (volatile const void *)
9839 void __builtin_stbio (volatile void *, int)
9840 void __builtin_sthio (volatile void *, int)
9841 void __builtin_stwio (volatile void *, int)
9842 void __builtin_sync (void)
9843 int __builtin_rdctl (int)
9844 void __builtin_wrctl (int, int)
9845 @end example
9846
9847 The following built-in functions are always available. They
9848 all generate a Nios II Custom Instruction. The name of the
9849 function represents the types that the function takes and
9850 returns. The letter before the @code{n} is the return type
9851 or void if absent. The @code{n} represents the first parameter
9852 to all the custom instructions, the custom instruction number.
9853 The two letters after the @code{n} represent the up to two
9854 parameters to the function.
9855
9856 The letters represent the following data types:
9857 @table @code
9858 @item <no letter>
9859 @code{void} for return type and no parameter for parameter types.
9860
9861 @item i
9862 @code{int} for return type and parameter type
9863
9864 @item f
9865 @code{float} for return type and parameter type
9866
9867 @item p
9868 @code{void *} for return type and parameter type
9869
9870 @end table
9871
9872 And the function names are:
9873 @example
9874 void __builtin_custom_n (void)
9875 void __builtin_custom_ni (int)
9876 void __builtin_custom_nf (float)
9877 void __builtin_custom_np (void *)
9878 void __builtin_custom_nii (int, int)
9879 void __builtin_custom_nif (int, float)
9880 void __builtin_custom_nip (int, void *)
9881 void __builtin_custom_nfi (float, int)
9882 void __builtin_custom_nff (float, float)
9883 void __builtin_custom_nfp (float, void *)
9884 void __builtin_custom_npi (void *, int)
9885 void __builtin_custom_npf (void *, float)
9886 void __builtin_custom_npp (void *, void *)
9887 int __builtin_custom_in (void)
9888 int __builtin_custom_ini (int)
9889 int __builtin_custom_inf (float)
9890 int __builtin_custom_inp (void *)
9891 int __builtin_custom_inii (int, int)
9892 int __builtin_custom_inif (int, float)
9893 int __builtin_custom_inip (int, void *)
9894 int __builtin_custom_infi (float, int)
9895 int __builtin_custom_inff (float, float)
9896 int __builtin_custom_infp (float, void *)
9897 int __builtin_custom_inpi (void *, int)
9898 int __builtin_custom_inpf (void *, float)
9899 int __builtin_custom_inpp (void *, void *)
9900 float __builtin_custom_fn (void)
9901 float __builtin_custom_fni (int)
9902 float __builtin_custom_fnf (float)
9903 float __builtin_custom_fnp (void *)
9904 float __builtin_custom_fnii (int, int)
9905 float __builtin_custom_fnif (int, float)
9906 float __builtin_custom_fnip (int, void *)
9907 float __builtin_custom_fnfi (float, int)
9908 float __builtin_custom_fnff (float, float)
9909 float __builtin_custom_fnfp (float, void *)
9910 float __builtin_custom_fnpi (void *, int)
9911 float __builtin_custom_fnpf (void *, float)
9912 float __builtin_custom_fnpp (void *, void *)
9913 void * __builtin_custom_pn (void)
9914 void * __builtin_custom_pni (int)
9915 void * __builtin_custom_pnf (float)
9916 void * __builtin_custom_pnp (void *)
9917 void * __builtin_custom_pnii (int, int)
9918 void * __builtin_custom_pnif (int, float)
9919 void * __builtin_custom_pnip (int, void *)
9920 void * __builtin_custom_pnfi (float, int)
9921 void * __builtin_custom_pnff (float, float)
9922 void * __builtin_custom_pnfp (float, void *)
9923 void * __builtin_custom_pnpi (void *, int)
9924 void * __builtin_custom_pnpf (void *, float)
9925 void * __builtin_custom_pnpp (void *, void *)
9926 @end example
9927
9928 @node ARC Built-in Functions
9929 @subsection ARC Built-in Functions
9930
9931 The following built-in functions are provided for ARC targets. The
9932 built-ins generate the corresponding assembly instructions. In the
9933 examples given below, the generated code often requires an operand or
9934 result to be in a register. Where necessary further code will be
9935 generated to ensure this is true, but for brevity this is not
9936 described in each case.
9937
9938 @emph{Note:} Using a built-in to generate an instruction not supported
9939 by a target may cause problems. At present the compiler is not
9940 guaranteed to detect such misuse, and as a result an internal compiler
9941 error may be generated.
9942
9943 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
9944 Return 1 if @var{val} is known to have the byte alignment given
9945 by @var{alignval}, otherwise return 0.
9946 Note that this is different from
9947 @smallexample
9948 __alignof__(*(char *)@var{val}) >= alignval
9949 @end smallexample
9950 because __alignof__ sees only the type of the dereference, whereas
9951 __builtin_arc_align uses alignment information from the pointer
9952 as well as from the pointed-to type.
9953 The information available will depend on optimization level.
9954 @end deftypefn
9955
9956 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
9957 Generates
9958 @example
9959 brk
9960 @end example
9961 @end deftypefn
9962
9963 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
9964 The operand is the number of a register to be read. Generates:
9965 @example
9966 mov @var{dest}, r@var{regno}
9967 @end example
9968 where the value in @var{dest} will be the result returned from the
9969 built-in.
9970 @end deftypefn
9971
9972 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
9973 The first operand is the number of a register to be written, the
9974 second operand is a compile time constant to write into that
9975 register. Generates:
9976 @example
9977 mov r@var{regno}, @var{val}
9978 @end example
9979 @end deftypefn
9980
9981 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
9982 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
9983 Generates:
9984 @example
9985 divaw @var{dest}, @var{a}, @var{b}
9986 @end example
9987 where the value in @var{dest} will be the result returned from the
9988 built-in.
9989 @end deftypefn
9990
9991 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
9992 Generates
9993 @example
9994 flag @var{a}
9995 @end example
9996 @end deftypefn
9997
9998 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
9999 The operand, @var{auxv}, is the address of an auxiliary register and
10000 must be a compile time constant. Generates:
10001 @example
10002 lr @var{dest}, [@var{auxr}]
10003 @end example
10004 Where the value in @var{dest} will be the result returned from the
10005 built-in.
10006 @end deftypefn
10007
10008 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
10009 Only available with @option{-mmul64}. Generates:
10010 @example
10011 mul64 @var{a}, @var{b}
10012 @end example
10013 @end deftypefn
10014
10015 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
10016 Only available with @option{-mmul64}. Generates:
10017 @example
10018 mulu64 @var{a}, @var{b}
10019 @end example
10020 @end deftypefn
10021
10022 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
10023 Generates:
10024 @example
10025 nop
10026 @end example
10027 @end deftypefn
10028
10029 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
10030 Only valid if the @samp{norm} instruction is available through the
10031 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10032 Generates:
10033 @example
10034 norm @var{dest}, @var{src}
10035 @end example
10036 Where the value in @var{dest} will be the result returned from the
10037 built-in.
10038 @end deftypefn
10039
10040 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
10041 Only valid if the @samp{normw} instruction is available through the
10042 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10043 Generates:
10044 @example
10045 normw @var{dest}, @var{src}
10046 @end example
10047 Where the value in @var{dest} will be the result returned from the
10048 built-in.
10049 @end deftypefn
10050
10051 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
10052 Generates:
10053 @example
10054 rtie
10055 @end example
10056 @end deftypefn
10057
10058 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
10059 Generates:
10060 @example
10061 sleep @var{a}
10062 @end example
10063 @end deftypefn
10064
10065 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
10066 The first argument, @var{auxv}, is the address of an auxiliary
10067 register, the second argument, @var{val}, is a compile time constant
10068 to be written to the register. Generates:
10069 @example
10070 sr @var{auxr}, [@var{val}]
10071 @end example
10072 @end deftypefn
10073
10074 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
10075 Only valid with @option{-mswap}. Generates:
10076 @example
10077 swap @var{dest}, @var{src}
10078 @end example
10079 Where the value in @var{dest} will be the result returned from the
10080 built-in.
10081 @end deftypefn
10082
10083 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
10084 Generates:
10085 @example
10086 swi
10087 @end example
10088 @end deftypefn
10089
10090 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
10091 Only available with @option{-mcpu=ARC700}. Generates:
10092 @example
10093 sync
10094 @end example
10095 @end deftypefn
10096
10097 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
10098 Only available with @option{-mcpu=ARC700}. Generates:
10099 @example
10100 trap_s @var{c}
10101 @end example
10102 @end deftypefn
10103
10104 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
10105 Only available with @option{-mcpu=ARC700}. Generates:
10106 @example
10107 unimp_s
10108 @end example
10109 @end deftypefn
10110
10111 The instructions generated by the following builtins are not
10112 considered as candidates for scheduling. They are not moved around by
10113 the compiler during scheduling, and thus can be expected to appear
10114 where they are put in the C code:
10115 @example
10116 __builtin_arc_brk()
10117 __builtin_arc_core_read()
10118 __builtin_arc_core_write()
10119 __builtin_arc_flag()
10120 __builtin_arc_lr()
10121 __builtin_arc_sleep()
10122 __builtin_arc_sr()
10123 __builtin_arc_swi()
10124 @end example
10125
10126 @node ARC SIMD Built-in Functions
10127 @subsection ARC SIMD Built-in Functions
10128
10129 SIMD builtins provided by the compiler can be used to generate the
10130 vector instructions. This section describes the available builtins
10131 and their usage in programs. With the @option{-msimd} option, the
10132 compiler provides 128-bit vector types, which can be specified using
10133 the @code{vector_size} attribute. The header file @file{arc-simd.h}
10134 can be included to use the following predefined types:
10135 @example
10136 typedef int __v4si __attribute__((vector_size(16)));
10137 typedef short __v8hi __attribute__((vector_size(16)));
10138 @end example
10139
10140 These types can be used to define 128-bit variables. The built-in
10141 functions listed in the following section can be used on these
10142 variables to generate the vector operations.
10143
10144 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
10145 @file{arc-simd.h} also provides equivalent macros called
10146 @code{_@var{someinsn}} that can be used for programming ease and
10147 improved readability. The following macros for DMA control are also
10148 provided:
10149 @example
10150 #define _setup_dma_in_channel_reg _vdiwr
10151 #define _setup_dma_out_channel_reg _vdowr
10152 @end example
10153
10154 The following is a complete list of all the SIMD built-ins provided
10155 for ARC, grouped by calling signature.
10156
10157 The following take two @code{__v8hi} arguments and return a
10158 @code{__v8hi} result:
10159 @example
10160 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
10161 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
10162 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
10163 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
10164 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
10165 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
10166 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
10167 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
10168 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
10169 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
10170 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
10171 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
10172 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
10173 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
10174 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
10175 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
10176 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
10177 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
10178 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
10179 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
10180 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
10181 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
10182 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
10183 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
10184 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
10185 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
10186 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
10187 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
10188 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
10189 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
10190 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
10191 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
10192 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
10193 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
10194 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
10195 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
10196 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
10197 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
10198 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
10199 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
10200 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
10201 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
10202 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
10203 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
10204 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
10205 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
10206 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
10207 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
10208 @end example
10209
10210 The following take one @code{__v8hi} and one @code{int} argument and return a
10211 @code{__v8hi} result:
10212
10213 @example
10214 __v8hi __builtin_arc_vbaddw (__v8hi, int)
10215 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
10216 __v8hi __builtin_arc_vbminw (__v8hi, int)
10217 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
10218 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
10219 __v8hi __builtin_arc_vbmulw (__v8hi, int)
10220 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
10221 __v8hi __builtin_arc_vbsubw (__v8hi, int)
10222 @end example
10223
10224 The following take one @code{__v8hi} argument and one @code{int} argument which
10225 must be a 3-bit compile time constant indicating a register number
10226 I0-I7. They return a @code{__v8hi} result.
10227 @example
10228 __v8hi __builtin_arc_vasrw (__v8hi, const int)
10229 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
10230 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
10231 @end example
10232
10233 The following take one @code{__v8hi} argument and one @code{int}
10234 argument which must be a 6-bit compile time constant. They return a
10235 @code{__v8hi} result.
10236 @example
10237 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
10238 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
10239 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
10240 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
10241 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
10242 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
10243 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
10244 @end example
10245
10246 The following take one @code{__v8hi} argument and one @code{int} argument which
10247 must be a 8-bit compile time constant. They return a @code{__v8hi}
10248 result.
10249 @example
10250 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
10251 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
10252 __v8hi __builtin_arc_vmvw (__v8hi, const int)
10253 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
10254 @end example
10255
10256 The following take two @code{int} arguments, the second of which which
10257 must be a 8-bit compile time constant. They return a @code{__v8hi}
10258 result:
10259 @example
10260 __v8hi __builtin_arc_vmovaw (int, const int)
10261 __v8hi __builtin_arc_vmovw (int, const int)
10262 __v8hi __builtin_arc_vmovzw (int, const int)
10263 @end example
10264
10265 The following take a single @code{__v8hi} argument and return a
10266 @code{__v8hi} result:
10267 @example
10268 __v8hi __builtin_arc_vabsaw (__v8hi)
10269 __v8hi __builtin_arc_vabsw (__v8hi)
10270 __v8hi __builtin_arc_vaddsuw (__v8hi)
10271 __v8hi __builtin_arc_vexch1 (__v8hi)
10272 __v8hi __builtin_arc_vexch2 (__v8hi)
10273 __v8hi __builtin_arc_vexch4 (__v8hi)
10274 __v8hi __builtin_arc_vsignw (__v8hi)
10275 __v8hi __builtin_arc_vupbaw (__v8hi)
10276 __v8hi __builtin_arc_vupbw (__v8hi)
10277 __v8hi __builtin_arc_vupsbaw (__v8hi)
10278 __v8hi __builtin_arc_vupsbw (__v8hi)
10279 @end example
10280
10281 The followign take two @code{int} arguments and return no result:
10282 @example
10283 void __builtin_arc_vdirun (int, int)
10284 void __builtin_arc_vdorun (int, int)
10285 @end example
10286
10287 The following take two @code{int} arguments and return no result. The
10288 first argument must a 3-bit compile time constant indicating one of
10289 the DR0-DR7 DMA setup channels:
10290 @example
10291 void __builtin_arc_vdiwr (const int, int)
10292 void __builtin_arc_vdowr (const int, int)
10293 @end example
10294
10295 The following take an @code{int} argument and return no result:
10296 @example
10297 void __builtin_arc_vendrec (int)
10298 void __builtin_arc_vrec (int)
10299 void __builtin_arc_vrecrun (int)
10300 void __builtin_arc_vrun (int)
10301 @end example
10302
10303 The following take a @code{__v8hi} argument and two @code{int}
10304 arguments and return a @code{__v8hi} result. The second argument must
10305 be a 3-bit compile time constants, indicating one the registers I0-I7,
10306 and the third argument must be an 8-bit compile time constant.
10307
10308 @emph{Note:} Although the equivalent hardware instructions do not take
10309 an SIMD register as an operand, these builtins overwrite the relevant
10310 bits of the @code{__v8hi} register provided as the first argument with
10311 the value loaded from the @code{[Ib, u8]} location in the SDM.
10312
10313 @example
10314 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
10315 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
10316 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
10317 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
10318 @end example
10319
10320 The following take two @code{int} arguments and return a @code{__v8hi}
10321 result. The first argument must be a 3-bit compile time constants,
10322 indicating one the registers I0-I7, and the second argument must be an
10323 8-bit compile time constant.
10324
10325 @example
10326 __v8hi __builtin_arc_vld128 (const int, const int)
10327 __v8hi __builtin_arc_vld64w (const int, const int)
10328 @end example
10329
10330 The following take a @code{__v8hi} argument and two @code{int}
10331 arguments and return no result. The second argument must be a 3-bit
10332 compile time constants, indicating one the registers I0-I7, and the
10333 third argument must be an 8-bit compile time constant.
10334
10335 @example
10336 void __builtin_arc_vst128 (__v8hi, const int, const int)
10337 void __builtin_arc_vst64 (__v8hi, const int, const int)
10338 @end example
10339
10340 The following take a @code{__v8hi} argument and three @code{int}
10341 arguments and return no result. The second argument must be a 3-bit
10342 compile-time constant, identifying the 16-bit sub-register to be
10343 stored, the third argument must be a 3-bit compile time constants,
10344 indicating one the registers I0-I7, and the fourth argument must be an
10345 8-bit compile time constant.
10346
10347 @example
10348 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
10349 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
10350 @end example
10351
10352 @node ARM iWMMXt Built-in Functions
10353 @subsection ARM iWMMXt Built-in Functions
10354
10355 These built-in functions are available for the ARM family of
10356 processors when the @option{-mcpu=iwmmxt} switch is used:
10357
10358 @smallexample
10359 typedef int v2si __attribute__ ((vector_size (8)));
10360 typedef short v4hi __attribute__ ((vector_size (8)));
10361 typedef char v8qi __attribute__ ((vector_size (8)));
10362
10363 int __builtin_arm_getwcgr0 (void)
10364 void __builtin_arm_setwcgr0 (int)
10365 int __builtin_arm_getwcgr1 (void)
10366 void __builtin_arm_setwcgr1 (int)
10367 int __builtin_arm_getwcgr2 (void)
10368 void __builtin_arm_setwcgr2 (int)
10369 int __builtin_arm_getwcgr3 (void)
10370 void __builtin_arm_setwcgr3 (int)
10371 int __builtin_arm_textrmsb (v8qi, int)
10372 int __builtin_arm_textrmsh (v4hi, int)
10373 int __builtin_arm_textrmsw (v2si, int)
10374 int __builtin_arm_textrmub (v8qi, int)
10375 int __builtin_arm_textrmuh (v4hi, int)
10376 int __builtin_arm_textrmuw (v2si, int)
10377 v8qi __builtin_arm_tinsrb (v8qi, int, int)
10378 v4hi __builtin_arm_tinsrh (v4hi, int, int)
10379 v2si __builtin_arm_tinsrw (v2si, int, int)
10380 long long __builtin_arm_tmia (long long, int, int)
10381 long long __builtin_arm_tmiabb (long long, int, int)
10382 long long __builtin_arm_tmiabt (long long, int, int)
10383 long long __builtin_arm_tmiaph (long long, int, int)
10384 long long __builtin_arm_tmiatb (long long, int, int)
10385 long long __builtin_arm_tmiatt (long long, int, int)
10386 int __builtin_arm_tmovmskb (v8qi)
10387 int __builtin_arm_tmovmskh (v4hi)
10388 int __builtin_arm_tmovmskw (v2si)
10389 long long __builtin_arm_waccb (v8qi)
10390 long long __builtin_arm_wacch (v4hi)
10391 long long __builtin_arm_waccw (v2si)
10392 v8qi __builtin_arm_waddb (v8qi, v8qi)
10393 v8qi __builtin_arm_waddbss (v8qi, v8qi)
10394 v8qi __builtin_arm_waddbus (v8qi, v8qi)
10395 v4hi __builtin_arm_waddh (v4hi, v4hi)
10396 v4hi __builtin_arm_waddhss (v4hi, v4hi)
10397 v4hi __builtin_arm_waddhus (v4hi, v4hi)
10398 v2si __builtin_arm_waddw (v2si, v2si)
10399 v2si __builtin_arm_waddwss (v2si, v2si)
10400 v2si __builtin_arm_waddwus (v2si, v2si)
10401 v8qi __builtin_arm_walign (v8qi, v8qi, int)
10402 long long __builtin_arm_wand(long long, long long)
10403 long long __builtin_arm_wandn (long long, long long)
10404 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
10405 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
10406 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
10407 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
10408 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
10409 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
10410 v2si __builtin_arm_wcmpeqw (v2si, v2si)
10411 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
10412 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
10413 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
10414 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
10415 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
10416 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
10417 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
10418 long long __builtin_arm_wmacsz (v4hi, v4hi)
10419 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
10420 long long __builtin_arm_wmacuz (v4hi, v4hi)
10421 v4hi __builtin_arm_wmadds (v4hi, v4hi)
10422 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
10423 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
10424 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
10425 v2si __builtin_arm_wmaxsw (v2si, v2si)
10426 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
10427 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
10428 v2si __builtin_arm_wmaxuw (v2si, v2si)
10429 v8qi __builtin_arm_wminsb (v8qi, v8qi)
10430 v4hi __builtin_arm_wminsh (v4hi, v4hi)
10431 v2si __builtin_arm_wminsw (v2si, v2si)
10432 v8qi __builtin_arm_wminub (v8qi, v8qi)
10433 v4hi __builtin_arm_wminuh (v4hi, v4hi)
10434 v2si __builtin_arm_wminuw (v2si, v2si)
10435 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
10436 v4hi __builtin_arm_wmulul (v4hi, v4hi)
10437 v4hi __builtin_arm_wmulum (v4hi, v4hi)
10438 long long __builtin_arm_wor (long long, long long)
10439 v2si __builtin_arm_wpackdss (long long, long long)
10440 v2si __builtin_arm_wpackdus (long long, long long)
10441 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
10442 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
10443 v4hi __builtin_arm_wpackwss (v2si, v2si)
10444 v4hi __builtin_arm_wpackwus (v2si, v2si)
10445 long long __builtin_arm_wrord (long long, long long)
10446 long long __builtin_arm_wrordi (long long, int)
10447 v4hi __builtin_arm_wrorh (v4hi, long long)
10448 v4hi __builtin_arm_wrorhi (v4hi, int)
10449 v2si __builtin_arm_wrorw (v2si, long long)
10450 v2si __builtin_arm_wrorwi (v2si, int)
10451 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
10452 v2si __builtin_arm_wsadbz (v8qi, v8qi)
10453 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
10454 v2si __builtin_arm_wsadhz (v4hi, v4hi)
10455 v4hi __builtin_arm_wshufh (v4hi, int)
10456 long long __builtin_arm_wslld (long long, long long)
10457 long long __builtin_arm_wslldi (long long, int)
10458 v4hi __builtin_arm_wsllh (v4hi, long long)
10459 v4hi __builtin_arm_wsllhi (v4hi, int)
10460 v2si __builtin_arm_wsllw (v2si, long long)
10461 v2si __builtin_arm_wsllwi (v2si, int)
10462 long long __builtin_arm_wsrad (long long, long long)
10463 long long __builtin_arm_wsradi (long long, int)
10464 v4hi __builtin_arm_wsrah (v4hi, long long)
10465 v4hi __builtin_arm_wsrahi (v4hi, int)
10466 v2si __builtin_arm_wsraw (v2si, long long)
10467 v2si __builtin_arm_wsrawi (v2si, int)
10468 long long __builtin_arm_wsrld (long long, long long)
10469 long long __builtin_arm_wsrldi (long long, int)
10470 v4hi __builtin_arm_wsrlh (v4hi, long long)
10471 v4hi __builtin_arm_wsrlhi (v4hi, int)
10472 v2si __builtin_arm_wsrlw (v2si, long long)
10473 v2si __builtin_arm_wsrlwi (v2si, int)
10474 v8qi __builtin_arm_wsubb (v8qi, v8qi)
10475 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
10476 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
10477 v4hi __builtin_arm_wsubh (v4hi, v4hi)
10478 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
10479 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
10480 v2si __builtin_arm_wsubw (v2si, v2si)
10481 v2si __builtin_arm_wsubwss (v2si, v2si)
10482 v2si __builtin_arm_wsubwus (v2si, v2si)
10483 v4hi __builtin_arm_wunpckehsb (v8qi)
10484 v2si __builtin_arm_wunpckehsh (v4hi)
10485 long long __builtin_arm_wunpckehsw (v2si)
10486 v4hi __builtin_arm_wunpckehub (v8qi)
10487 v2si __builtin_arm_wunpckehuh (v4hi)
10488 long long __builtin_arm_wunpckehuw (v2si)
10489 v4hi __builtin_arm_wunpckelsb (v8qi)
10490 v2si __builtin_arm_wunpckelsh (v4hi)
10491 long long __builtin_arm_wunpckelsw (v2si)
10492 v4hi __builtin_arm_wunpckelub (v8qi)
10493 v2si __builtin_arm_wunpckeluh (v4hi)
10494 long long __builtin_arm_wunpckeluw (v2si)
10495 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
10496 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
10497 v2si __builtin_arm_wunpckihw (v2si, v2si)
10498 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
10499 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
10500 v2si __builtin_arm_wunpckilw (v2si, v2si)
10501 long long __builtin_arm_wxor (long long, long long)
10502 long long __builtin_arm_wzero ()
10503 @end smallexample
10504
10505 @node ARM NEON Intrinsics
10506 @subsection ARM NEON Intrinsics
10507
10508 These built-in intrinsics for the ARM Advanced SIMD extension are available
10509 when the @option{-mfpu=neon} switch is used:
10510
10511 @include arm-neon-intrinsics.texi
10512
10513 @node ARM ACLE Intrinsics
10514 @subsection ARM ACLE Intrinsics
10515
10516 These built-in intrinsics for the ARMv8-A CRC32 extension are available when
10517 the @option{-march=armv8-a+crc} switch is used:
10518
10519 @include arm-acle-intrinsics.texi
10520
10521 @node AVR Built-in Functions
10522 @subsection AVR Built-in Functions
10523
10524 For each built-in function for AVR, there is an equally named,
10525 uppercase built-in macro defined. That way users can easily query if
10526 or if not a specific built-in is implemented or not. For example, if
10527 @code{__builtin_avr_nop} is available the macro
10528 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
10529
10530 The following built-in functions map to the respective machine
10531 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
10532 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
10533 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
10534 as library call if no hardware multiplier is available.
10535
10536 @smallexample
10537 void __builtin_avr_nop (void)
10538 void __builtin_avr_sei (void)
10539 void __builtin_avr_cli (void)
10540 void __builtin_avr_sleep (void)
10541 void __builtin_avr_wdr (void)
10542 unsigned char __builtin_avr_swap (unsigned char)
10543 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
10544 int __builtin_avr_fmuls (char, char)
10545 int __builtin_avr_fmulsu (char, unsigned char)
10546 @end smallexample
10547
10548 In order to delay execution for a specific number of cycles, GCC
10549 implements
10550 @smallexample
10551 void __builtin_avr_delay_cycles (unsigned long ticks)
10552 @end smallexample
10553
10554 @noindent
10555 @code{ticks} is the number of ticks to delay execution. Note that this
10556 built-in does not take into account the effect of interrupts that
10557 might increase delay time. @code{ticks} must be a compile-time
10558 integer constant; delays with a variable number of cycles are not supported.
10559
10560 @smallexample
10561 char __builtin_avr_flash_segment (const __memx void*)
10562 @end smallexample
10563
10564 @noindent
10565 This built-in takes a byte address to the 24-bit
10566 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
10567 the number of the flash segment (the 64 KiB chunk) where the address
10568 points to. Counting starts at @code{0}.
10569 If the address does not point to flash memory, return @code{-1}.
10570
10571 @smallexample
10572 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
10573 @end smallexample
10574
10575 @noindent
10576 Insert bits from @var{bits} into @var{val} and return the resulting
10577 value. The nibbles of @var{map} determine how the insertion is
10578 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
10579 @enumerate
10580 @item If @var{X} is @code{0xf},
10581 then the @var{n}-th bit of @var{val} is returned unaltered.
10582
10583 @item If X is in the range 0@dots{}7,
10584 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
10585
10586 @item If X is in the range 8@dots{}@code{0xe},
10587 then the @var{n}-th result bit is undefined.
10588 @end enumerate
10589
10590 @noindent
10591 One typical use case for this built-in is adjusting input and
10592 output values to non-contiguous port layouts. Some examples:
10593
10594 @smallexample
10595 // same as val, bits is unused
10596 __builtin_avr_insert_bits (0xffffffff, bits, val)
10597 @end smallexample
10598
10599 @smallexample
10600 // same as bits, val is unused
10601 __builtin_avr_insert_bits (0x76543210, bits, val)
10602 @end smallexample
10603
10604 @smallexample
10605 // same as rotating bits by 4
10606 __builtin_avr_insert_bits (0x32107654, bits, 0)
10607 @end smallexample
10608
10609 @smallexample
10610 // high nibble of result is the high nibble of val
10611 // low nibble of result is the low nibble of bits
10612 __builtin_avr_insert_bits (0xffff3210, bits, val)
10613 @end smallexample
10614
10615 @smallexample
10616 // reverse the bit order of bits
10617 __builtin_avr_insert_bits (0x01234567, bits, 0)
10618 @end smallexample
10619
10620 @node Blackfin Built-in Functions
10621 @subsection Blackfin Built-in Functions
10622
10623 Currently, there are two Blackfin-specific built-in functions. These are
10624 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
10625 using inline assembly; by using these built-in functions the compiler can
10626 automatically add workarounds for hardware errata involving these
10627 instructions. These functions are named as follows:
10628
10629 @smallexample
10630 void __builtin_bfin_csync (void)
10631 void __builtin_bfin_ssync (void)
10632 @end smallexample
10633
10634 @node FR-V Built-in Functions
10635 @subsection FR-V Built-in Functions
10636
10637 GCC provides many FR-V-specific built-in functions. In general,
10638 these functions are intended to be compatible with those described
10639 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
10640 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
10641 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
10642 pointer rather than by value.
10643
10644 Most of the functions are named after specific FR-V instructions.
10645 Such functions are said to be ``directly mapped'' and are summarized
10646 here in tabular form.
10647
10648 @menu
10649 * Argument Types::
10650 * Directly-mapped Integer Functions::
10651 * Directly-mapped Media Functions::
10652 * Raw read/write Functions::
10653 * Other Built-in Functions::
10654 @end menu
10655
10656 @node Argument Types
10657 @subsubsection Argument Types
10658
10659 The arguments to the built-in functions can be divided into three groups:
10660 register numbers, compile-time constants and run-time values. In order
10661 to make this classification clear at a glance, the arguments and return
10662 values are given the following pseudo types:
10663
10664 @multitable @columnfractions .20 .30 .15 .35
10665 @item Pseudo type @tab Real C type @tab Constant? @tab Description
10666 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
10667 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
10668 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
10669 @item @code{uw2} @tab @code{unsigned long long} @tab No
10670 @tab an unsigned doubleword
10671 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
10672 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
10673 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
10674 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
10675 @end multitable
10676
10677 These pseudo types are not defined by GCC, they are simply a notational
10678 convenience used in this manual.
10679
10680 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
10681 and @code{sw2} are evaluated at run time. They correspond to
10682 register operands in the underlying FR-V instructions.
10683
10684 @code{const} arguments represent immediate operands in the underlying
10685 FR-V instructions. They must be compile-time constants.
10686
10687 @code{acc} arguments are evaluated at compile time and specify the number
10688 of an accumulator register. For example, an @code{acc} argument of 2
10689 selects the ACC2 register.
10690
10691 @code{iacc} arguments are similar to @code{acc} arguments but specify the
10692 number of an IACC register. See @pxref{Other Built-in Functions}
10693 for more details.
10694
10695 @node Directly-mapped Integer Functions
10696 @subsubsection Directly-mapped Integer Functions
10697
10698 The functions listed below map directly to FR-V I-type instructions.
10699
10700 @multitable @columnfractions .45 .32 .23
10701 @item Function prototype @tab Example usage @tab Assembly output
10702 @item @code{sw1 __ADDSS (sw1, sw1)}
10703 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
10704 @tab @code{ADDSS @var{a},@var{b},@var{c}}
10705 @item @code{sw1 __SCAN (sw1, sw1)}
10706 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
10707 @tab @code{SCAN @var{a},@var{b},@var{c}}
10708 @item @code{sw1 __SCUTSS (sw1)}
10709 @tab @code{@var{b} = __SCUTSS (@var{a})}
10710 @tab @code{SCUTSS @var{a},@var{b}}
10711 @item @code{sw1 __SLASS (sw1, sw1)}
10712 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
10713 @tab @code{SLASS @var{a},@var{b},@var{c}}
10714 @item @code{void __SMASS (sw1, sw1)}
10715 @tab @code{__SMASS (@var{a}, @var{b})}
10716 @tab @code{SMASS @var{a},@var{b}}
10717 @item @code{void __SMSSS (sw1, sw1)}
10718 @tab @code{__SMSSS (@var{a}, @var{b})}
10719 @tab @code{SMSSS @var{a},@var{b}}
10720 @item @code{void __SMU (sw1, sw1)}
10721 @tab @code{__SMU (@var{a}, @var{b})}
10722 @tab @code{SMU @var{a},@var{b}}
10723 @item @code{sw2 __SMUL (sw1, sw1)}
10724 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
10725 @tab @code{SMUL @var{a},@var{b},@var{c}}
10726 @item @code{sw1 __SUBSS (sw1, sw1)}
10727 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
10728 @tab @code{SUBSS @var{a},@var{b},@var{c}}
10729 @item @code{uw2 __UMUL (uw1, uw1)}
10730 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
10731 @tab @code{UMUL @var{a},@var{b},@var{c}}
10732 @end multitable
10733
10734 @node Directly-mapped Media Functions
10735 @subsubsection Directly-mapped Media Functions
10736
10737 The functions listed below map directly to FR-V M-type instructions.
10738
10739 @multitable @columnfractions .45 .32 .23
10740 @item Function prototype @tab Example usage @tab Assembly output
10741 @item @code{uw1 __MABSHS (sw1)}
10742 @tab @code{@var{b} = __MABSHS (@var{a})}
10743 @tab @code{MABSHS @var{a},@var{b}}
10744 @item @code{void __MADDACCS (acc, acc)}
10745 @tab @code{__MADDACCS (@var{b}, @var{a})}
10746 @tab @code{MADDACCS @var{a},@var{b}}
10747 @item @code{sw1 __MADDHSS (sw1, sw1)}
10748 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
10749 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
10750 @item @code{uw1 __MADDHUS (uw1, uw1)}
10751 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
10752 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
10753 @item @code{uw1 __MAND (uw1, uw1)}
10754 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
10755 @tab @code{MAND @var{a},@var{b},@var{c}}
10756 @item @code{void __MASACCS (acc, acc)}
10757 @tab @code{__MASACCS (@var{b}, @var{a})}
10758 @tab @code{MASACCS @var{a},@var{b}}
10759 @item @code{uw1 __MAVEH (uw1, uw1)}
10760 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
10761 @tab @code{MAVEH @var{a},@var{b},@var{c}}
10762 @item @code{uw2 __MBTOH (uw1)}
10763 @tab @code{@var{b} = __MBTOH (@var{a})}
10764 @tab @code{MBTOH @var{a},@var{b}}
10765 @item @code{void __MBTOHE (uw1 *, uw1)}
10766 @tab @code{__MBTOHE (&@var{b}, @var{a})}
10767 @tab @code{MBTOHE @var{a},@var{b}}
10768 @item @code{void __MCLRACC (acc)}
10769 @tab @code{__MCLRACC (@var{a})}
10770 @tab @code{MCLRACC @var{a}}
10771 @item @code{void __MCLRACCA (void)}
10772 @tab @code{__MCLRACCA ()}
10773 @tab @code{MCLRACCA}
10774 @item @code{uw1 __Mcop1 (uw1, uw1)}
10775 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
10776 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
10777 @item @code{uw1 __Mcop2 (uw1, uw1)}
10778 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
10779 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
10780 @item @code{uw1 __MCPLHI (uw2, const)}
10781 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
10782 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
10783 @item @code{uw1 __MCPLI (uw2, const)}
10784 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
10785 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
10786 @item @code{void __MCPXIS (acc, sw1, sw1)}
10787 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
10788 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
10789 @item @code{void __MCPXIU (acc, uw1, uw1)}
10790 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
10791 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
10792 @item @code{void __MCPXRS (acc, sw1, sw1)}
10793 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
10794 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
10795 @item @code{void __MCPXRU (acc, uw1, uw1)}
10796 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
10797 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
10798 @item @code{uw1 __MCUT (acc, uw1)}
10799 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
10800 @tab @code{MCUT @var{a},@var{b},@var{c}}
10801 @item @code{uw1 __MCUTSS (acc, sw1)}
10802 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
10803 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
10804 @item @code{void __MDADDACCS (acc, acc)}
10805 @tab @code{__MDADDACCS (@var{b}, @var{a})}
10806 @tab @code{MDADDACCS @var{a},@var{b}}
10807 @item @code{void __MDASACCS (acc, acc)}
10808 @tab @code{__MDASACCS (@var{b}, @var{a})}
10809 @tab @code{MDASACCS @var{a},@var{b}}
10810 @item @code{uw2 __MDCUTSSI (acc, const)}
10811 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
10812 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
10813 @item @code{uw2 __MDPACKH (uw2, uw2)}
10814 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
10815 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
10816 @item @code{uw2 __MDROTLI (uw2, const)}
10817 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
10818 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
10819 @item @code{void __MDSUBACCS (acc, acc)}
10820 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
10821 @tab @code{MDSUBACCS @var{a},@var{b}}
10822 @item @code{void __MDUNPACKH (uw1 *, uw2)}
10823 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
10824 @tab @code{MDUNPACKH @var{a},@var{b}}
10825 @item @code{uw2 __MEXPDHD (uw1, const)}
10826 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
10827 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
10828 @item @code{uw1 __MEXPDHW (uw1, const)}
10829 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
10830 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
10831 @item @code{uw1 __MHDSETH (uw1, const)}
10832 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
10833 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
10834 @item @code{sw1 __MHDSETS (const)}
10835 @tab @code{@var{b} = __MHDSETS (@var{a})}
10836 @tab @code{MHDSETS #@var{a},@var{b}}
10837 @item @code{uw1 __MHSETHIH (uw1, const)}
10838 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
10839 @tab @code{MHSETHIH #@var{a},@var{b}}
10840 @item @code{sw1 __MHSETHIS (sw1, const)}
10841 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
10842 @tab @code{MHSETHIS #@var{a},@var{b}}
10843 @item @code{uw1 __MHSETLOH (uw1, const)}
10844 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
10845 @tab @code{MHSETLOH #@var{a},@var{b}}
10846 @item @code{sw1 __MHSETLOS (sw1, const)}
10847 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
10848 @tab @code{MHSETLOS #@var{a},@var{b}}
10849 @item @code{uw1 __MHTOB (uw2)}
10850 @tab @code{@var{b} = __MHTOB (@var{a})}
10851 @tab @code{MHTOB @var{a},@var{b}}
10852 @item @code{void __MMACHS (acc, sw1, sw1)}
10853 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
10854 @tab @code{MMACHS @var{a},@var{b},@var{c}}
10855 @item @code{void __MMACHU (acc, uw1, uw1)}
10856 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
10857 @tab @code{MMACHU @var{a},@var{b},@var{c}}
10858 @item @code{void __MMRDHS (acc, sw1, sw1)}
10859 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
10860 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
10861 @item @code{void __MMRDHU (acc, uw1, uw1)}
10862 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
10863 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
10864 @item @code{void __MMULHS (acc, sw1, sw1)}
10865 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
10866 @tab @code{MMULHS @var{a},@var{b},@var{c}}
10867 @item @code{void __MMULHU (acc, uw1, uw1)}
10868 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
10869 @tab @code{MMULHU @var{a},@var{b},@var{c}}
10870 @item @code{void __MMULXHS (acc, sw1, sw1)}
10871 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
10872 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
10873 @item @code{void __MMULXHU (acc, uw1, uw1)}
10874 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
10875 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
10876 @item @code{uw1 __MNOT (uw1)}
10877 @tab @code{@var{b} = __MNOT (@var{a})}
10878 @tab @code{MNOT @var{a},@var{b}}
10879 @item @code{uw1 __MOR (uw1, uw1)}
10880 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
10881 @tab @code{MOR @var{a},@var{b},@var{c}}
10882 @item @code{uw1 __MPACKH (uh, uh)}
10883 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
10884 @tab @code{MPACKH @var{a},@var{b},@var{c}}
10885 @item @code{sw2 __MQADDHSS (sw2, sw2)}
10886 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
10887 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
10888 @item @code{uw2 __MQADDHUS (uw2, uw2)}
10889 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
10890 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
10891 @item @code{void __MQCPXIS (acc, sw2, sw2)}
10892 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
10893 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
10894 @item @code{void __MQCPXIU (acc, uw2, uw2)}
10895 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
10896 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
10897 @item @code{void __MQCPXRS (acc, sw2, sw2)}
10898 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
10899 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
10900 @item @code{void __MQCPXRU (acc, uw2, uw2)}
10901 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
10902 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
10903 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
10904 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
10905 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
10906 @item @code{sw2 __MQLMTHS (sw2, sw2)}
10907 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
10908 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
10909 @item @code{void __MQMACHS (acc, sw2, sw2)}
10910 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
10911 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
10912 @item @code{void __MQMACHU (acc, uw2, uw2)}
10913 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
10914 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
10915 @item @code{void __MQMACXHS (acc, sw2, sw2)}
10916 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
10917 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
10918 @item @code{void __MQMULHS (acc, sw2, sw2)}
10919 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
10920 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
10921 @item @code{void __MQMULHU (acc, uw2, uw2)}
10922 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
10923 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
10924 @item @code{void __MQMULXHS (acc, sw2, sw2)}
10925 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
10926 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
10927 @item @code{void __MQMULXHU (acc, uw2, uw2)}
10928 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
10929 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
10930 @item @code{sw2 __MQSATHS (sw2, sw2)}
10931 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
10932 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
10933 @item @code{uw2 __MQSLLHI (uw2, int)}
10934 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
10935 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
10936 @item @code{sw2 __MQSRAHI (sw2, int)}
10937 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
10938 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
10939 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
10940 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
10941 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
10942 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
10943 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
10944 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
10945 @item @code{void __MQXMACHS (acc, sw2, sw2)}
10946 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
10947 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
10948 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
10949 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
10950 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
10951 @item @code{uw1 __MRDACC (acc)}
10952 @tab @code{@var{b} = __MRDACC (@var{a})}
10953 @tab @code{MRDACC @var{a},@var{b}}
10954 @item @code{uw1 __MRDACCG (acc)}
10955 @tab @code{@var{b} = __MRDACCG (@var{a})}
10956 @tab @code{MRDACCG @var{a},@var{b}}
10957 @item @code{uw1 __MROTLI (uw1, const)}
10958 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
10959 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
10960 @item @code{uw1 __MROTRI (uw1, const)}
10961 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
10962 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
10963 @item @code{sw1 __MSATHS (sw1, sw1)}
10964 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
10965 @tab @code{MSATHS @var{a},@var{b},@var{c}}
10966 @item @code{uw1 __MSATHU (uw1, uw1)}
10967 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
10968 @tab @code{MSATHU @var{a},@var{b},@var{c}}
10969 @item @code{uw1 __MSLLHI (uw1, const)}
10970 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
10971 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
10972 @item @code{sw1 __MSRAHI (sw1, const)}
10973 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
10974 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
10975 @item @code{uw1 __MSRLHI (uw1, const)}
10976 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
10977 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
10978 @item @code{void __MSUBACCS (acc, acc)}
10979 @tab @code{__MSUBACCS (@var{b}, @var{a})}
10980 @tab @code{MSUBACCS @var{a},@var{b}}
10981 @item @code{sw1 __MSUBHSS (sw1, sw1)}
10982 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
10983 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
10984 @item @code{uw1 __MSUBHUS (uw1, uw1)}
10985 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
10986 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
10987 @item @code{void __MTRAP (void)}
10988 @tab @code{__MTRAP ()}
10989 @tab @code{MTRAP}
10990 @item @code{uw2 __MUNPACKH (uw1)}
10991 @tab @code{@var{b} = __MUNPACKH (@var{a})}
10992 @tab @code{MUNPACKH @var{a},@var{b}}
10993 @item @code{uw1 __MWCUT (uw2, uw1)}
10994 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
10995 @tab @code{MWCUT @var{a},@var{b},@var{c}}
10996 @item @code{void __MWTACC (acc, uw1)}
10997 @tab @code{__MWTACC (@var{b}, @var{a})}
10998 @tab @code{MWTACC @var{a},@var{b}}
10999 @item @code{void __MWTACCG (acc, uw1)}
11000 @tab @code{__MWTACCG (@var{b}, @var{a})}
11001 @tab @code{MWTACCG @var{a},@var{b}}
11002 @item @code{uw1 __MXOR (uw1, uw1)}
11003 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
11004 @tab @code{MXOR @var{a},@var{b},@var{c}}
11005 @end multitable
11006
11007 @node Raw read/write Functions
11008 @subsubsection Raw read/write Functions
11009
11010 This sections describes built-in functions related to read and write
11011 instructions to access memory. These functions generate
11012 @code{membar} instructions to flush the I/O load and stores where
11013 appropriate, as described in Fujitsu's manual described above.
11014
11015 @table @code
11016
11017 @item unsigned char __builtin_read8 (void *@var{data})
11018 @item unsigned short __builtin_read16 (void *@var{data})
11019 @item unsigned long __builtin_read32 (void *@var{data})
11020 @item unsigned long long __builtin_read64 (void *@var{data})
11021
11022 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
11023 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
11024 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
11025 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
11026 @end table
11027
11028 @node Other Built-in Functions
11029 @subsubsection Other Built-in Functions
11030
11031 This section describes built-in functions that are not named after
11032 a specific FR-V instruction.
11033
11034 @table @code
11035 @item sw2 __IACCreadll (iacc @var{reg})
11036 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
11037 for future expansion and must be 0.
11038
11039 @item sw1 __IACCreadl (iacc @var{reg})
11040 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
11041 Other values of @var{reg} are rejected as invalid.
11042
11043 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
11044 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
11045 is reserved for future expansion and must be 0.
11046
11047 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
11048 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
11049 is 1. Other values of @var{reg} are rejected as invalid.
11050
11051 @item void __data_prefetch0 (const void *@var{x})
11052 Use the @code{dcpl} instruction to load the contents of address @var{x}
11053 into the data cache.
11054
11055 @item void __data_prefetch (const void *@var{x})
11056 Use the @code{nldub} instruction to load the contents of address @var{x}
11057 into the data cache. The instruction is issued in slot I1@.
11058 @end table
11059
11060 @node X86 Built-in Functions
11061 @subsection X86 Built-in Functions
11062
11063 These built-in functions are available for the i386 and x86-64 family
11064 of computers, depending on the command-line switches used.
11065
11066 If you specify command-line switches such as @option{-msse},
11067 the compiler could use the extended instruction sets even if the built-ins
11068 are not used explicitly in the program. For this reason, applications
11069 that perform run-time CPU detection must compile separate files for each
11070 supported architecture, using the appropriate flags. In particular,
11071 the file containing the CPU detection code should be compiled without
11072 these options.
11073
11074 The following machine modes are available for use with MMX built-in functions
11075 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
11076 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
11077 vector of eight 8-bit integers. Some of the built-in functions operate on
11078 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
11079
11080 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
11081 of two 32-bit floating-point values.
11082
11083 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
11084 floating-point values. Some instructions use a vector of four 32-bit
11085 integers, these use @code{V4SI}. Finally, some instructions operate on an
11086 entire vector register, interpreting it as a 128-bit integer, these use mode
11087 @code{TI}.
11088
11089 In 64-bit mode, the x86-64 family of processors uses additional built-in
11090 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
11091 floating point and @code{TC} 128-bit complex floating-point values.
11092
11093 The following floating-point built-in functions are available in 64-bit
11094 mode. All of them implement the function that is part of the name.
11095
11096 @smallexample
11097 __float128 __builtin_fabsq (__float128)
11098 __float128 __builtin_copysignq (__float128, __float128)
11099 @end smallexample
11100
11101 The following built-in function is always available.
11102
11103 @table @code
11104 @item void __builtin_ia32_pause (void)
11105 Generates the @code{pause} machine instruction with a compiler memory
11106 barrier.
11107 @end table
11108
11109 The following floating-point built-in functions are made available in the
11110 64-bit mode.
11111
11112 @table @code
11113 @item __float128 __builtin_infq (void)
11114 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
11115 @findex __builtin_infq
11116
11117 @item __float128 __builtin_huge_valq (void)
11118 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
11119 @findex __builtin_huge_valq
11120 @end table
11121
11122 The following built-in functions are always available and can be used to
11123 check the target platform type.
11124
11125 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
11126 This function runs the CPU detection code to check the type of CPU and the
11127 features supported. This built-in function needs to be invoked along with the built-in functions
11128 to check CPU type and features, @code{__builtin_cpu_is} and
11129 @code{__builtin_cpu_supports}, only when used in a function that is
11130 executed before any constructors are called. The CPU detection code is
11131 automatically executed in a very high priority constructor.
11132
11133 For example, this function has to be used in @code{ifunc} resolvers that
11134 check for CPU type using the built-in functions @code{__builtin_cpu_is}
11135 and @code{__builtin_cpu_supports}, or in constructors on targets that
11136 don't support constructor priority.
11137 @smallexample
11138
11139 static void (*resolve_memcpy (void)) (void)
11140 @{
11141 // ifunc resolvers fire before constructors, explicitly call the init
11142 // function.
11143 __builtin_cpu_init ();
11144 if (__builtin_cpu_supports ("ssse3"))
11145 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
11146 else
11147 return default_memcpy;
11148 @}
11149
11150 void *memcpy (void *, const void *, size_t)
11151 __attribute__ ((ifunc ("resolve_memcpy")));
11152 @end smallexample
11153
11154 @end deftypefn
11155
11156 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
11157 This function returns a positive integer if the run-time CPU
11158 is of type @var{cpuname}
11159 and returns @code{0} otherwise. The following CPU names can be detected:
11160
11161 @table @samp
11162 @item intel
11163 Intel CPU.
11164
11165 @item atom
11166 Intel Atom CPU.
11167
11168 @item core2
11169 Intel Core 2 CPU.
11170
11171 @item corei7
11172 Intel Core i7 CPU.
11173
11174 @item nehalem
11175 Intel Core i7 Nehalem CPU.
11176
11177 @item westmere
11178 Intel Core i7 Westmere CPU.
11179
11180 @item sandybridge
11181 Intel Core i7 Sandy Bridge CPU.
11182
11183 @item amd
11184 AMD CPU.
11185
11186 @item amdfam10h
11187 AMD Family 10h CPU.
11188
11189 @item barcelona
11190 AMD Family 10h Barcelona CPU.
11191
11192 @item shanghai
11193 AMD Family 10h Shanghai CPU.
11194
11195 @item istanbul
11196 AMD Family 10h Istanbul CPU.
11197
11198 @item btver1
11199 AMD Family 14h CPU.
11200
11201 @item amdfam15h
11202 AMD Family 15h CPU.
11203
11204 @item bdver1
11205 AMD Family 15h Bulldozer version 1.
11206
11207 @item bdver2
11208 AMD Family 15h Bulldozer version 2.
11209
11210 @item bdver3
11211 AMD Family 15h Bulldozer version 3.
11212
11213 @item bdver4
11214 AMD Family 15h Bulldozer version 4.
11215
11216 @item btver2
11217 AMD Family 16h CPU.
11218 @end table
11219
11220 Here is an example:
11221 @smallexample
11222 if (__builtin_cpu_is ("corei7"))
11223 @{
11224 do_corei7 (); // Core i7 specific implementation.
11225 @}
11226 else
11227 @{
11228 do_generic (); // Generic implementation.
11229 @}
11230 @end smallexample
11231 @end deftypefn
11232
11233 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
11234 This function returns a positive integer if the run-time CPU
11235 supports @var{feature}
11236 and returns @code{0} otherwise. The following features can be detected:
11237
11238 @table @samp
11239 @item cmov
11240 CMOV instruction.
11241 @item mmx
11242 MMX instructions.
11243 @item popcnt
11244 POPCNT instruction.
11245 @item sse
11246 SSE instructions.
11247 @item sse2
11248 SSE2 instructions.
11249 @item sse3
11250 SSE3 instructions.
11251 @item ssse3
11252 SSSE3 instructions.
11253 @item sse4.1
11254 SSE4.1 instructions.
11255 @item sse4.2
11256 SSE4.2 instructions.
11257 @item avx
11258 AVX instructions.
11259 @item avx2
11260 AVX2 instructions.
11261 @end table
11262
11263 Here is an example:
11264 @smallexample
11265 if (__builtin_cpu_supports ("popcnt"))
11266 @{
11267 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
11268 @}
11269 else
11270 @{
11271 count = generic_countbits (n); //generic implementation.
11272 @}
11273 @end smallexample
11274 @end deftypefn
11275
11276
11277 The following built-in functions are made available by @option{-mmmx}.
11278 All of them generate the machine instruction that is part of the name.
11279
11280 @smallexample
11281 v8qi __builtin_ia32_paddb (v8qi, v8qi)
11282 v4hi __builtin_ia32_paddw (v4hi, v4hi)
11283 v2si __builtin_ia32_paddd (v2si, v2si)
11284 v8qi __builtin_ia32_psubb (v8qi, v8qi)
11285 v4hi __builtin_ia32_psubw (v4hi, v4hi)
11286 v2si __builtin_ia32_psubd (v2si, v2si)
11287 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
11288 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
11289 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
11290 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
11291 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
11292 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
11293 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
11294 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
11295 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
11296 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
11297 di __builtin_ia32_pand (di, di)
11298 di __builtin_ia32_pandn (di,di)
11299 di __builtin_ia32_por (di, di)
11300 di __builtin_ia32_pxor (di, di)
11301 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
11302 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
11303 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
11304 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
11305 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
11306 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
11307 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
11308 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
11309 v2si __builtin_ia32_punpckhdq (v2si, v2si)
11310 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
11311 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
11312 v2si __builtin_ia32_punpckldq (v2si, v2si)
11313 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
11314 v4hi __builtin_ia32_packssdw (v2si, v2si)
11315 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
11316
11317 v4hi __builtin_ia32_psllw (v4hi, v4hi)
11318 v2si __builtin_ia32_pslld (v2si, v2si)
11319 v1di __builtin_ia32_psllq (v1di, v1di)
11320 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
11321 v2si __builtin_ia32_psrld (v2si, v2si)
11322 v1di __builtin_ia32_psrlq (v1di, v1di)
11323 v4hi __builtin_ia32_psraw (v4hi, v4hi)
11324 v2si __builtin_ia32_psrad (v2si, v2si)
11325 v4hi __builtin_ia32_psllwi (v4hi, int)
11326 v2si __builtin_ia32_pslldi (v2si, int)
11327 v1di __builtin_ia32_psllqi (v1di, int)
11328 v4hi __builtin_ia32_psrlwi (v4hi, int)
11329 v2si __builtin_ia32_psrldi (v2si, int)
11330 v1di __builtin_ia32_psrlqi (v1di, int)
11331 v4hi __builtin_ia32_psrawi (v4hi, int)
11332 v2si __builtin_ia32_psradi (v2si, int)
11333
11334 @end smallexample
11335
11336 The following built-in functions are made available either with
11337 @option{-msse}, or with a combination of @option{-m3dnow} and
11338 @option{-march=athlon}. All of them generate the machine
11339 instruction that is part of the name.
11340
11341 @smallexample
11342 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
11343 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
11344 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
11345 v1di __builtin_ia32_psadbw (v8qi, v8qi)
11346 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
11347 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
11348 v8qi __builtin_ia32_pminub (v8qi, v8qi)
11349 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
11350 int __builtin_ia32_pmovmskb (v8qi)
11351 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
11352 void __builtin_ia32_movntq (di *, di)
11353 void __builtin_ia32_sfence (void)
11354 @end smallexample
11355
11356 The following built-in functions are available when @option{-msse} is used.
11357 All of them generate the machine instruction that is part of the name.
11358
11359 @smallexample
11360 int __builtin_ia32_comieq (v4sf, v4sf)
11361 int __builtin_ia32_comineq (v4sf, v4sf)
11362 int __builtin_ia32_comilt (v4sf, v4sf)
11363 int __builtin_ia32_comile (v4sf, v4sf)
11364 int __builtin_ia32_comigt (v4sf, v4sf)
11365 int __builtin_ia32_comige (v4sf, v4sf)
11366 int __builtin_ia32_ucomieq (v4sf, v4sf)
11367 int __builtin_ia32_ucomineq (v4sf, v4sf)
11368 int __builtin_ia32_ucomilt (v4sf, v4sf)
11369 int __builtin_ia32_ucomile (v4sf, v4sf)
11370 int __builtin_ia32_ucomigt (v4sf, v4sf)
11371 int __builtin_ia32_ucomige (v4sf, v4sf)
11372 v4sf __builtin_ia32_addps (v4sf, v4sf)
11373 v4sf __builtin_ia32_subps (v4sf, v4sf)
11374 v4sf __builtin_ia32_mulps (v4sf, v4sf)
11375 v4sf __builtin_ia32_divps (v4sf, v4sf)
11376 v4sf __builtin_ia32_addss (v4sf, v4sf)
11377 v4sf __builtin_ia32_subss (v4sf, v4sf)
11378 v4sf __builtin_ia32_mulss (v4sf, v4sf)
11379 v4sf __builtin_ia32_divss (v4sf, v4sf)
11380 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
11381 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
11382 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
11383 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
11384 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
11385 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
11386 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
11387 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
11388 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
11389 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
11390 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
11391 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
11392 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
11393 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
11394 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
11395 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
11396 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
11397 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
11398 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
11399 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
11400 v4sf __builtin_ia32_maxps (v4sf, v4sf)
11401 v4sf __builtin_ia32_maxss (v4sf, v4sf)
11402 v4sf __builtin_ia32_minps (v4sf, v4sf)
11403 v4sf __builtin_ia32_minss (v4sf, v4sf)
11404 v4sf __builtin_ia32_andps (v4sf, v4sf)
11405 v4sf __builtin_ia32_andnps (v4sf, v4sf)
11406 v4sf __builtin_ia32_orps (v4sf, v4sf)
11407 v4sf __builtin_ia32_xorps (v4sf, v4sf)
11408 v4sf __builtin_ia32_movss (v4sf, v4sf)
11409 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
11410 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
11411 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
11412 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
11413 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
11414 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
11415 v2si __builtin_ia32_cvtps2pi (v4sf)
11416 int __builtin_ia32_cvtss2si (v4sf)
11417 v2si __builtin_ia32_cvttps2pi (v4sf)
11418 int __builtin_ia32_cvttss2si (v4sf)
11419 v4sf __builtin_ia32_rcpps (v4sf)
11420 v4sf __builtin_ia32_rsqrtps (v4sf)
11421 v4sf __builtin_ia32_sqrtps (v4sf)
11422 v4sf __builtin_ia32_rcpss (v4sf)
11423 v4sf __builtin_ia32_rsqrtss (v4sf)
11424 v4sf __builtin_ia32_sqrtss (v4sf)
11425 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
11426 void __builtin_ia32_movntps (float *, v4sf)
11427 int __builtin_ia32_movmskps (v4sf)
11428 @end smallexample
11429
11430 The following built-in functions are available when @option{-msse} is used.
11431
11432 @table @code
11433 @item v4sf __builtin_ia32_loadups (float *)
11434 Generates the @code{movups} machine instruction as a load from memory.
11435 @item void __builtin_ia32_storeups (float *, v4sf)
11436 Generates the @code{movups} machine instruction as a store to memory.
11437 @item v4sf __builtin_ia32_loadss (float *)
11438 Generates the @code{movss} machine instruction as a load from memory.
11439 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
11440 Generates the @code{movhps} machine instruction as a load from memory.
11441 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
11442 Generates the @code{movlps} machine instruction as a load from memory
11443 @item void __builtin_ia32_storehps (v2sf *, v4sf)
11444 Generates the @code{movhps} machine instruction as a store to memory.
11445 @item void __builtin_ia32_storelps (v2sf *, v4sf)
11446 Generates the @code{movlps} machine instruction as a store to memory.
11447 @end table
11448
11449 The following built-in functions are available when @option{-msse2} is used.
11450 All of them generate the machine instruction that is part of the name.
11451
11452 @smallexample
11453 int __builtin_ia32_comisdeq (v2df, v2df)
11454 int __builtin_ia32_comisdlt (v2df, v2df)
11455 int __builtin_ia32_comisdle (v2df, v2df)
11456 int __builtin_ia32_comisdgt (v2df, v2df)
11457 int __builtin_ia32_comisdge (v2df, v2df)
11458 int __builtin_ia32_comisdneq (v2df, v2df)
11459 int __builtin_ia32_ucomisdeq (v2df, v2df)
11460 int __builtin_ia32_ucomisdlt (v2df, v2df)
11461 int __builtin_ia32_ucomisdle (v2df, v2df)
11462 int __builtin_ia32_ucomisdgt (v2df, v2df)
11463 int __builtin_ia32_ucomisdge (v2df, v2df)
11464 int __builtin_ia32_ucomisdneq (v2df, v2df)
11465 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
11466 v2df __builtin_ia32_cmpltpd (v2df, v2df)
11467 v2df __builtin_ia32_cmplepd (v2df, v2df)
11468 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
11469 v2df __builtin_ia32_cmpgepd (v2df, v2df)
11470 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
11471 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
11472 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
11473 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
11474 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
11475 v2df __builtin_ia32_cmpngepd (v2df, v2df)
11476 v2df __builtin_ia32_cmpordpd (v2df, v2df)
11477 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
11478 v2df __builtin_ia32_cmpltsd (v2df, v2df)
11479 v2df __builtin_ia32_cmplesd (v2df, v2df)
11480 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
11481 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
11482 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
11483 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
11484 v2df __builtin_ia32_cmpordsd (v2df, v2df)
11485 v2di __builtin_ia32_paddq (v2di, v2di)
11486 v2di __builtin_ia32_psubq (v2di, v2di)
11487 v2df __builtin_ia32_addpd (v2df, v2df)
11488 v2df __builtin_ia32_subpd (v2df, v2df)
11489 v2df __builtin_ia32_mulpd (v2df, v2df)
11490 v2df __builtin_ia32_divpd (v2df, v2df)
11491 v2df __builtin_ia32_addsd (v2df, v2df)
11492 v2df __builtin_ia32_subsd (v2df, v2df)
11493 v2df __builtin_ia32_mulsd (v2df, v2df)
11494 v2df __builtin_ia32_divsd (v2df, v2df)
11495 v2df __builtin_ia32_minpd (v2df, v2df)
11496 v2df __builtin_ia32_maxpd (v2df, v2df)
11497 v2df __builtin_ia32_minsd (v2df, v2df)
11498 v2df __builtin_ia32_maxsd (v2df, v2df)
11499 v2df __builtin_ia32_andpd (v2df, v2df)
11500 v2df __builtin_ia32_andnpd (v2df, v2df)
11501 v2df __builtin_ia32_orpd (v2df, v2df)
11502 v2df __builtin_ia32_xorpd (v2df, v2df)
11503 v2df __builtin_ia32_movsd (v2df, v2df)
11504 v2df __builtin_ia32_unpckhpd (v2df, v2df)
11505 v2df __builtin_ia32_unpcklpd (v2df, v2df)
11506 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
11507 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
11508 v4si __builtin_ia32_paddd128 (v4si, v4si)
11509 v2di __builtin_ia32_paddq128 (v2di, v2di)
11510 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
11511 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
11512 v4si __builtin_ia32_psubd128 (v4si, v4si)
11513 v2di __builtin_ia32_psubq128 (v2di, v2di)
11514 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
11515 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
11516 v2di __builtin_ia32_pand128 (v2di, v2di)
11517 v2di __builtin_ia32_pandn128 (v2di, v2di)
11518 v2di __builtin_ia32_por128 (v2di, v2di)
11519 v2di __builtin_ia32_pxor128 (v2di, v2di)
11520 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
11521 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
11522 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
11523 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
11524 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
11525 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
11526 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
11527 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
11528 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
11529 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
11530 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
11531 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
11532 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
11533 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
11534 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
11535 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
11536 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
11537 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
11538 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
11539 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
11540 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
11541 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
11542 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
11543 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
11544 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
11545 v2df __builtin_ia32_loadupd (double *)
11546 void __builtin_ia32_storeupd (double *, v2df)
11547 v2df __builtin_ia32_loadhpd (v2df, double const *)
11548 v2df __builtin_ia32_loadlpd (v2df, double const *)
11549 int __builtin_ia32_movmskpd (v2df)
11550 int __builtin_ia32_pmovmskb128 (v16qi)
11551 void __builtin_ia32_movnti (int *, int)
11552 void __builtin_ia32_movnti64 (long long int *, long long int)
11553 void __builtin_ia32_movntpd (double *, v2df)
11554 void __builtin_ia32_movntdq (v2df *, v2df)
11555 v4si __builtin_ia32_pshufd (v4si, int)
11556 v8hi __builtin_ia32_pshuflw (v8hi, int)
11557 v8hi __builtin_ia32_pshufhw (v8hi, int)
11558 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
11559 v2df __builtin_ia32_sqrtpd (v2df)
11560 v2df __builtin_ia32_sqrtsd (v2df)
11561 v2df __builtin_ia32_shufpd (v2df, v2df, int)
11562 v2df __builtin_ia32_cvtdq2pd (v4si)
11563 v4sf __builtin_ia32_cvtdq2ps (v4si)
11564 v4si __builtin_ia32_cvtpd2dq (v2df)
11565 v2si __builtin_ia32_cvtpd2pi (v2df)
11566 v4sf __builtin_ia32_cvtpd2ps (v2df)
11567 v4si __builtin_ia32_cvttpd2dq (v2df)
11568 v2si __builtin_ia32_cvttpd2pi (v2df)
11569 v2df __builtin_ia32_cvtpi2pd (v2si)
11570 int __builtin_ia32_cvtsd2si (v2df)
11571 int __builtin_ia32_cvttsd2si (v2df)
11572 long long __builtin_ia32_cvtsd2si64 (v2df)
11573 long long __builtin_ia32_cvttsd2si64 (v2df)
11574 v4si __builtin_ia32_cvtps2dq (v4sf)
11575 v2df __builtin_ia32_cvtps2pd (v4sf)
11576 v4si __builtin_ia32_cvttps2dq (v4sf)
11577 v2df __builtin_ia32_cvtsi2sd (v2df, int)
11578 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
11579 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
11580 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
11581 void __builtin_ia32_clflush (const void *)
11582 void __builtin_ia32_lfence (void)
11583 void __builtin_ia32_mfence (void)
11584 v16qi __builtin_ia32_loaddqu (const char *)
11585 void __builtin_ia32_storedqu (char *, v16qi)
11586 v1di __builtin_ia32_pmuludq (v2si, v2si)
11587 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
11588 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
11589 v4si __builtin_ia32_pslld128 (v4si, v4si)
11590 v2di __builtin_ia32_psllq128 (v2di, v2di)
11591 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
11592 v4si __builtin_ia32_psrld128 (v4si, v4si)
11593 v2di __builtin_ia32_psrlq128 (v2di, v2di)
11594 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
11595 v4si __builtin_ia32_psrad128 (v4si, v4si)
11596 v2di __builtin_ia32_pslldqi128 (v2di, int)
11597 v8hi __builtin_ia32_psllwi128 (v8hi, int)
11598 v4si __builtin_ia32_pslldi128 (v4si, int)
11599 v2di __builtin_ia32_psllqi128 (v2di, int)
11600 v2di __builtin_ia32_psrldqi128 (v2di, int)
11601 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
11602 v4si __builtin_ia32_psrldi128 (v4si, int)
11603 v2di __builtin_ia32_psrlqi128 (v2di, int)
11604 v8hi __builtin_ia32_psrawi128 (v8hi, int)
11605 v4si __builtin_ia32_psradi128 (v4si, int)
11606 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
11607 v2di __builtin_ia32_movq128 (v2di)
11608 @end smallexample
11609
11610 The following built-in functions are available when @option{-msse3} is used.
11611 All of them generate the machine instruction that is part of the name.
11612
11613 @smallexample
11614 v2df __builtin_ia32_addsubpd (v2df, v2df)
11615 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
11616 v2df __builtin_ia32_haddpd (v2df, v2df)
11617 v4sf __builtin_ia32_haddps (v4sf, v4sf)
11618 v2df __builtin_ia32_hsubpd (v2df, v2df)
11619 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
11620 v16qi __builtin_ia32_lddqu (char const *)
11621 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
11622 v4sf __builtin_ia32_movshdup (v4sf)
11623 v4sf __builtin_ia32_movsldup (v4sf)
11624 void __builtin_ia32_mwait (unsigned int, unsigned int)
11625 @end smallexample
11626
11627 The following built-in functions are available when @option{-mssse3} is used.
11628 All of them generate the machine instruction that is part of the name.
11629
11630 @smallexample
11631 v2si __builtin_ia32_phaddd (v2si, v2si)
11632 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
11633 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
11634 v2si __builtin_ia32_phsubd (v2si, v2si)
11635 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
11636 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
11637 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
11638 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
11639 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
11640 v8qi __builtin_ia32_psignb (v8qi, v8qi)
11641 v2si __builtin_ia32_psignd (v2si, v2si)
11642 v4hi __builtin_ia32_psignw (v4hi, v4hi)
11643 v1di __builtin_ia32_palignr (v1di, v1di, int)
11644 v8qi __builtin_ia32_pabsb (v8qi)
11645 v2si __builtin_ia32_pabsd (v2si)
11646 v4hi __builtin_ia32_pabsw (v4hi)
11647 @end smallexample
11648
11649 The following built-in functions are available when @option{-mssse3} is used.
11650 All of them generate the machine instruction that is part of the name.
11651
11652 @smallexample
11653 v4si __builtin_ia32_phaddd128 (v4si, v4si)
11654 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
11655 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
11656 v4si __builtin_ia32_phsubd128 (v4si, v4si)
11657 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
11658 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
11659 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
11660 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
11661 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
11662 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
11663 v4si __builtin_ia32_psignd128 (v4si, v4si)
11664 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
11665 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
11666 v16qi __builtin_ia32_pabsb128 (v16qi)
11667 v4si __builtin_ia32_pabsd128 (v4si)
11668 v8hi __builtin_ia32_pabsw128 (v8hi)
11669 @end smallexample
11670
11671 The following built-in functions are available when @option{-msse4.1} is
11672 used. All of them generate the machine instruction that is part of the
11673 name.
11674
11675 @smallexample
11676 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
11677 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
11678 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
11679 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
11680 v2df __builtin_ia32_dppd (v2df, v2df, const int)
11681 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
11682 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
11683 v2di __builtin_ia32_movntdqa (v2di *);
11684 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
11685 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
11686 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
11687 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
11688 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
11689 v8hi __builtin_ia32_phminposuw128 (v8hi)
11690 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
11691 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
11692 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
11693 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
11694 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
11695 v4si __builtin_ia32_pminsd128 (v4si, v4si)
11696 v4si __builtin_ia32_pminud128 (v4si, v4si)
11697 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
11698 v4si __builtin_ia32_pmovsxbd128 (v16qi)
11699 v2di __builtin_ia32_pmovsxbq128 (v16qi)
11700 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
11701 v2di __builtin_ia32_pmovsxdq128 (v4si)
11702 v4si __builtin_ia32_pmovsxwd128 (v8hi)
11703 v2di __builtin_ia32_pmovsxwq128 (v8hi)
11704 v4si __builtin_ia32_pmovzxbd128 (v16qi)
11705 v2di __builtin_ia32_pmovzxbq128 (v16qi)
11706 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
11707 v2di __builtin_ia32_pmovzxdq128 (v4si)
11708 v4si __builtin_ia32_pmovzxwd128 (v8hi)
11709 v2di __builtin_ia32_pmovzxwq128 (v8hi)
11710 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
11711 v4si __builtin_ia32_pmulld128 (v4si, v4si)
11712 int __builtin_ia32_ptestc128 (v2di, v2di)
11713 int __builtin_ia32_ptestnzc128 (v2di, v2di)
11714 int __builtin_ia32_ptestz128 (v2di, v2di)
11715 v2df __builtin_ia32_roundpd (v2df, const int)
11716 v4sf __builtin_ia32_roundps (v4sf, const int)
11717 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
11718 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
11719 @end smallexample
11720
11721 The following built-in functions are available when @option{-msse4.1} is
11722 used.
11723
11724 @table @code
11725 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
11726 Generates the @code{insertps} machine instruction.
11727 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
11728 Generates the @code{pextrb} machine instruction.
11729 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
11730 Generates the @code{pinsrb} machine instruction.
11731 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
11732 Generates the @code{pinsrd} machine instruction.
11733 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
11734 Generates the @code{pinsrq} machine instruction in 64bit mode.
11735 @end table
11736
11737 The following built-in functions are changed to generate new SSE4.1
11738 instructions when @option{-msse4.1} is used.
11739
11740 @table @code
11741 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
11742 Generates the @code{extractps} machine instruction.
11743 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
11744 Generates the @code{pextrd} machine instruction.
11745 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
11746 Generates the @code{pextrq} machine instruction in 64bit mode.
11747 @end table
11748
11749 The following built-in functions are available when @option{-msse4.2} is
11750 used. All of them generate the machine instruction that is part of the
11751 name.
11752
11753 @smallexample
11754 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
11755 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
11756 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
11757 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
11758 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
11759 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
11760 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
11761 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
11762 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
11763 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
11764 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
11765 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
11766 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
11767 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
11768 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
11769 @end smallexample
11770
11771 The following built-in functions are available when @option{-msse4.2} is
11772 used.
11773
11774 @table @code
11775 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
11776 Generates the @code{crc32b} machine instruction.
11777 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
11778 Generates the @code{crc32w} machine instruction.
11779 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
11780 Generates the @code{crc32l} machine instruction.
11781 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
11782 Generates the @code{crc32q} machine instruction.
11783 @end table
11784
11785 The following built-in functions are changed to generate new SSE4.2
11786 instructions when @option{-msse4.2} is used.
11787
11788 @table @code
11789 @item int __builtin_popcount (unsigned int)
11790 Generates the @code{popcntl} machine instruction.
11791 @item int __builtin_popcountl (unsigned long)
11792 Generates the @code{popcntl} or @code{popcntq} machine instruction,
11793 depending on the size of @code{unsigned long}.
11794 @item int __builtin_popcountll (unsigned long long)
11795 Generates the @code{popcntq} machine instruction.
11796 @end table
11797
11798 The following built-in functions are available when @option{-mavx} is
11799 used. All of them generate the machine instruction that is part of the
11800 name.
11801
11802 @smallexample
11803 v4df __builtin_ia32_addpd256 (v4df,v4df)
11804 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
11805 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
11806 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
11807 v4df __builtin_ia32_andnpd256 (v4df,v4df)
11808 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
11809 v4df __builtin_ia32_andpd256 (v4df,v4df)
11810 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
11811 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
11812 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
11813 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
11814 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
11815 v2df __builtin_ia32_cmppd (v2df,v2df,int)
11816 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
11817 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
11818 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
11819 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
11820 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
11821 v4df __builtin_ia32_cvtdq2pd256 (v4si)
11822 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
11823 v4si __builtin_ia32_cvtpd2dq256 (v4df)
11824 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
11825 v8si __builtin_ia32_cvtps2dq256 (v8sf)
11826 v4df __builtin_ia32_cvtps2pd256 (v4sf)
11827 v4si __builtin_ia32_cvttpd2dq256 (v4df)
11828 v8si __builtin_ia32_cvttps2dq256 (v8sf)
11829 v4df __builtin_ia32_divpd256 (v4df,v4df)
11830 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
11831 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
11832 v4df __builtin_ia32_haddpd256 (v4df,v4df)
11833 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
11834 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
11835 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
11836 v32qi __builtin_ia32_lddqu256 (pcchar)
11837 v32qi __builtin_ia32_loaddqu256 (pcchar)
11838 v4df __builtin_ia32_loadupd256 (pcdouble)
11839 v8sf __builtin_ia32_loadups256 (pcfloat)
11840 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
11841 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
11842 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
11843 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
11844 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
11845 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
11846 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
11847 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
11848 v4df __builtin_ia32_maxpd256 (v4df,v4df)
11849 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
11850 v4df __builtin_ia32_minpd256 (v4df,v4df)
11851 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
11852 v4df __builtin_ia32_movddup256 (v4df)
11853 int __builtin_ia32_movmskpd256 (v4df)
11854 int __builtin_ia32_movmskps256 (v8sf)
11855 v8sf __builtin_ia32_movshdup256 (v8sf)
11856 v8sf __builtin_ia32_movsldup256 (v8sf)
11857 v4df __builtin_ia32_mulpd256 (v4df,v4df)
11858 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
11859 v4df __builtin_ia32_orpd256 (v4df,v4df)
11860 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
11861 v2df __builtin_ia32_pd_pd256 (v4df)
11862 v4df __builtin_ia32_pd256_pd (v2df)
11863 v4sf __builtin_ia32_ps_ps256 (v8sf)
11864 v8sf __builtin_ia32_ps256_ps (v4sf)
11865 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
11866 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
11867 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
11868 v8sf __builtin_ia32_rcpps256 (v8sf)
11869 v4df __builtin_ia32_roundpd256 (v4df,int)
11870 v8sf __builtin_ia32_roundps256 (v8sf,int)
11871 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
11872 v8sf __builtin_ia32_rsqrtps256 (v8sf)
11873 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
11874 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
11875 v4si __builtin_ia32_si_si256 (v8si)
11876 v8si __builtin_ia32_si256_si (v4si)
11877 v4df __builtin_ia32_sqrtpd256 (v4df)
11878 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
11879 v8sf __builtin_ia32_sqrtps256 (v8sf)
11880 void __builtin_ia32_storedqu256 (pchar,v32qi)
11881 void __builtin_ia32_storeupd256 (pdouble,v4df)
11882 void __builtin_ia32_storeups256 (pfloat,v8sf)
11883 v4df __builtin_ia32_subpd256 (v4df,v4df)
11884 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
11885 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
11886 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
11887 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
11888 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
11889 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
11890 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
11891 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
11892 v4sf __builtin_ia32_vbroadcastss (pcfloat)
11893 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
11894 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
11895 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
11896 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
11897 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
11898 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
11899 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
11900 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
11901 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
11902 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
11903 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
11904 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
11905 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
11906 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
11907 v2df __builtin_ia32_vpermilpd (v2df,int)
11908 v4df __builtin_ia32_vpermilpd256 (v4df,int)
11909 v4sf __builtin_ia32_vpermilps (v4sf,int)
11910 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
11911 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
11912 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
11913 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
11914 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
11915 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
11916 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
11917 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
11918 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
11919 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
11920 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
11921 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
11922 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
11923 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
11924 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
11925 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
11926 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
11927 void __builtin_ia32_vzeroall (void)
11928 void __builtin_ia32_vzeroupper (void)
11929 v4df __builtin_ia32_xorpd256 (v4df,v4df)
11930 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
11931 @end smallexample
11932
11933 The following built-in functions are available when @option{-mavx2} is
11934 used. All of them generate the machine instruction that is part of the
11935 name.
11936
11937 @smallexample
11938 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
11939 v32qi __builtin_ia32_pabsb256 (v32qi)
11940 v16hi __builtin_ia32_pabsw256 (v16hi)
11941 v8si __builtin_ia32_pabsd256 (v8si)
11942 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
11943 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
11944 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
11945 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
11946 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
11947 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
11948 v8si __builtin_ia32_paddd256 (v8si,v8si)
11949 v4di __builtin_ia32_paddq256 (v4di,v4di)
11950 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
11951 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
11952 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
11953 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
11954 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
11955 v4di __builtin_ia32_andsi256 (v4di,v4di)
11956 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
11957 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
11958 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
11959 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
11960 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
11961 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
11962 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
11963 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
11964 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
11965 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
11966 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
11967 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
11968 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
11969 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
11970 v8si __builtin_ia32_phaddd256 (v8si,v8si)
11971 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
11972 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
11973 v8si __builtin_ia32_phsubd256 (v8si,v8si)
11974 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
11975 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
11976 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
11977 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
11978 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
11979 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
11980 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
11981 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
11982 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
11983 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
11984 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
11985 v8si __builtin_ia32_pminsd256 (v8si,v8si)
11986 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
11987 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
11988 v8si __builtin_ia32_pminud256 (v8si,v8si)
11989 int __builtin_ia32_pmovmskb256 (v32qi)
11990 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
11991 v8si __builtin_ia32_pmovsxbd256 (v16qi)
11992 v4di __builtin_ia32_pmovsxbq256 (v16qi)
11993 v8si __builtin_ia32_pmovsxwd256 (v8hi)
11994 v4di __builtin_ia32_pmovsxwq256 (v8hi)
11995 v4di __builtin_ia32_pmovsxdq256 (v4si)
11996 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
11997 v8si __builtin_ia32_pmovzxbd256 (v16qi)
11998 v4di __builtin_ia32_pmovzxbq256 (v16qi)
11999 v8si __builtin_ia32_pmovzxwd256 (v8hi)
12000 v4di __builtin_ia32_pmovzxwq256 (v8hi)
12001 v4di __builtin_ia32_pmovzxdq256 (v4si)
12002 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
12003 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
12004 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
12005 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
12006 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
12007 v8si __builtin_ia32_pmulld256 (v8si,v8si)
12008 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
12009 v4di __builtin_ia32_por256 (v4di,v4di)
12010 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
12011 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
12012 v8si __builtin_ia32_pshufd256 (v8si,int)
12013 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
12014 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
12015 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
12016 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
12017 v8si __builtin_ia32_psignd256 (v8si,v8si)
12018 v4di __builtin_ia32_pslldqi256 (v4di,int)
12019 v16hi __builtin_ia32_psllwi256 (16hi,int)
12020 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
12021 v8si __builtin_ia32_pslldi256 (v8si,int)
12022 v8si __builtin_ia32_pslld256(v8si,v4si)
12023 v4di __builtin_ia32_psllqi256 (v4di,int)
12024 v4di __builtin_ia32_psllq256(v4di,v2di)
12025 v16hi __builtin_ia32_psrawi256 (v16hi,int)
12026 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
12027 v8si __builtin_ia32_psradi256 (v8si,int)
12028 v8si __builtin_ia32_psrad256 (v8si,v4si)
12029 v4di __builtin_ia32_psrldqi256 (v4di, int)
12030 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
12031 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
12032 v8si __builtin_ia32_psrldi256 (v8si,int)
12033 v8si __builtin_ia32_psrld256 (v8si,v4si)
12034 v4di __builtin_ia32_psrlqi256 (v4di,int)
12035 v4di __builtin_ia32_psrlq256(v4di,v2di)
12036 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
12037 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
12038 v8si __builtin_ia32_psubd256 (v8si,v8si)
12039 v4di __builtin_ia32_psubq256 (v4di,v4di)
12040 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
12041 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
12042 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
12043 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
12044 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
12045 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
12046 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
12047 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
12048 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
12049 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
12050 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
12051 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
12052 v4di __builtin_ia32_pxor256 (v4di,v4di)
12053 v4di __builtin_ia32_movntdqa256 (pv4di)
12054 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
12055 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
12056 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
12057 v4di __builtin_ia32_vbroadcastsi256 (v2di)
12058 v4si __builtin_ia32_pblendd128 (v4si,v4si)
12059 v8si __builtin_ia32_pblendd256 (v8si,v8si)
12060 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
12061 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
12062 v8si __builtin_ia32_pbroadcastd256 (v4si)
12063 v4di __builtin_ia32_pbroadcastq256 (v2di)
12064 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
12065 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
12066 v4si __builtin_ia32_pbroadcastd128 (v4si)
12067 v2di __builtin_ia32_pbroadcastq128 (v2di)
12068 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
12069 v4df __builtin_ia32_permdf256 (v4df,int)
12070 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
12071 v4di __builtin_ia32_permdi256 (v4di,int)
12072 v4di __builtin_ia32_permti256 (v4di,v4di,int)
12073 v4di __builtin_ia32_extract128i256 (v4di,int)
12074 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
12075 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
12076 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
12077 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
12078 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
12079 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
12080 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
12081 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
12082 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
12083 v8si __builtin_ia32_psllv8si (v8si,v8si)
12084 v4si __builtin_ia32_psllv4si (v4si,v4si)
12085 v4di __builtin_ia32_psllv4di (v4di,v4di)
12086 v2di __builtin_ia32_psllv2di (v2di,v2di)
12087 v8si __builtin_ia32_psrav8si (v8si,v8si)
12088 v4si __builtin_ia32_psrav4si (v4si,v4si)
12089 v8si __builtin_ia32_psrlv8si (v8si,v8si)
12090 v4si __builtin_ia32_psrlv4si (v4si,v4si)
12091 v4di __builtin_ia32_psrlv4di (v4di,v4di)
12092 v2di __builtin_ia32_psrlv2di (v2di,v2di)
12093 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
12094 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
12095 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
12096 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
12097 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
12098 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
12099 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
12100 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
12101 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
12102 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
12103 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
12104 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
12105 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
12106 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
12107 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
12108 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
12109 @end smallexample
12110
12111 The following built-in functions are available when @option{-maes} is
12112 used. All of them generate the machine instruction that is part of the
12113 name.
12114
12115 @smallexample
12116 v2di __builtin_ia32_aesenc128 (v2di, v2di)
12117 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
12118 v2di __builtin_ia32_aesdec128 (v2di, v2di)
12119 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
12120 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
12121 v2di __builtin_ia32_aesimc128 (v2di)
12122 @end smallexample
12123
12124 The following built-in function is available when @option{-mpclmul} is
12125 used.
12126
12127 @table @code
12128 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
12129 Generates the @code{pclmulqdq} machine instruction.
12130 @end table
12131
12132 The following built-in function is available when @option{-mfsgsbase} is
12133 used. All of them generate the machine instruction that is part of the
12134 name.
12135
12136 @smallexample
12137 unsigned int __builtin_ia32_rdfsbase32 (void)
12138 unsigned long long __builtin_ia32_rdfsbase64 (void)
12139 unsigned int __builtin_ia32_rdgsbase32 (void)
12140 unsigned long long __builtin_ia32_rdgsbase64 (void)
12141 void _writefsbase_u32 (unsigned int)
12142 void _writefsbase_u64 (unsigned long long)
12143 void _writegsbase_u32 (unsigned int)
12144 void _writegsbase_u64 (unsigned long long)
12145 @end smallexample
12146
12147 The following built-in function is available when @option{-mrdrnd} is
12148 used. All of them generate the machine instruction that is part of the
12149 name.
12150
12151 @smallexample
12152 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
12153 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
12154 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
12155 @end smallexample
12156
12157 The following built-in functions are available when @option{-msse4a} is used.
12158 All of them generate the machine instruction that is part of the name.
12159
12160 @smallexample
12161 void __builtin_ia32_movntsd (double *, v2df)
12162 void __builtin_ia32_movntss (float *, v4sf)
12163 v2di __builtin_ia32_extrq (v2di, v16qi)
12164 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
12165 v2di __builtin_ia32_insertq (v2di, v2di)
12166 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
12167 @end smallexample
12168
12169 The following built-in functions are available when @option{-mxop} is used.
12170 @smallexample
12171 v2df __builtin_ia32_vfrczpd (v2df)
12172 v4sf __builtin_ia32_vfrczps (v4sf)
12173 v2df __builtin_ia32_vfrczsd (v2df)
12174 v4sf __builtin_ia32_vfrczss (v4sf)
12175 v4df __builtin_ia32_vfrczpd256 (v4df)
12176 v8sf __builtin_ia32_vfrczps256 (v8sf)
12177 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
12178 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
12179 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
12180 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
12181 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
12182 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
12183 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
12184 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
12185 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
12186 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
12187 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
12188 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
12189 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
12190 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
12191 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12192 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
12193 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
12194 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
12195 v4si __builtin_ia32_vpcomequd (v4si, v4si)
12196 v2di __builtin_ia32_vpcomequq (v2di, v2di)
12197 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
12198 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12199 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
12200 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
12201 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
12202 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
12203 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
12204 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
12205 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
12206 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
12207 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
12208 v4si __builtin_ia32_vpcomged (v4si, v4si)
12209 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
12210 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
12211 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
12212 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
12213 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
12214 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
12215 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
12216 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
12217 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
12218 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
12219 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
12220 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
12221 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
12222 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
12223 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
12224 v4si __builtin_ia32_vpcomled (v4si, v4si)
12225 v2di __builtin_ia32_vpcomleq (v2di, v2di)
12226 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
12227 v4si __builtin_ia32_vpcomleud (v4si, v4si)
12228 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
12229 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
12230 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
12231 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
12232 v4si __builtin_ia32_vpcomltd (v4si, v4si)
12233 v2di __builtin_ia32_vpcomltq (v2di, v2di)
12234 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
12235 v4si __builtin_ia32_vpcomltud (v4si, v4si)
12236 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
12237 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
12238 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
12239 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
12240 v4si __builtin_ia32_vpcomned (v4si, v4si)
12241 v2di __builtin_ia32_vpcomneq (v2di, v2di)
12242 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
12243 v4si __builtin_ia32_vpcomneud (v4si, v4si)
12244 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
12245 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
12246 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
12247 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
12248 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
12249 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
12250 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
12251 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
12252 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
12253 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
12254 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
12255 v4si __builtin_ia32_vphaddbd (v16qi)
12256 v2di __builtin_ia32_vphaddbq (v16qi)
12257 v8hi __builtin_ia32_vphaddbw (v16qi)
12258 v2di __builtin_ia32_vphadddq (v4si)
12259 v4si __builtin_ia32_vphaddubd (v16qi)
12260 v2di __builtin_ia32_vphaddubq (v16qi)
12261 v8hi __builtin_ia32_vphaddubw (v16qi)
12262 v2di __builtin_ia32_vphaddudq (v4si)
12263 v4si __builtin_ia32_vphadduwd (v8hi)
12264 v2di __builtin_ia32_vphadduwq (v8hi)
12265 v4si __builtin_ia32_vphaddwd (v8hi)
12266 v2di __builtin_ia32_vphaddwq (v8hi)
12267 v8hi __builtin_ia32_vphsubbw (v16qi)
12268 v2di __builtin_ia32_vphsubdq (v4si)
12269 v4si __builtin_ia32_vphsubwd (v8hi)
12270 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
12271 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
12272 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
12273 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
12274 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
12275 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
12276 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
12277 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
12278 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
12279 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
12280 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
12281 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
12282 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
12283 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
12284 v4si __builtin_ia32_vprotd (v4si, v4si)
12285 v2di __builtin_ia32_vprotq (v2di, v2di)
12286 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
12287 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
12288 v4si __builtin_ia32_vpshad (v4si, v4si)
12289 v2di __builtin_ia32_vpshaq (v2di, v2di)
12290 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
12291 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
12292 v4si __builtin_ia32_vpshld (v4si, v4si)
12293 v2di __builtin_ia32_vpshlq (v2di, v2di)
12294 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
12295 @end smallexample
12296
12297 The following built-in functions are available when @option{-mfma4} is used.
12298 All of them generate the machine instruction that is part of the name.
12299
12300 @smallexample
12301 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
12302 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
12303 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
12304 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
12305 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
12306 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
12307 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
12308 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
12309 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
12310 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
12311 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
12312 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
12313 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
12314 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
12315 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
12316 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
12317 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
12318 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
12319 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
12320 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
12321 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
12322 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
12323 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
12324 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
12325 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
12326 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
12327 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
12328 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
12329 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
12330 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
12331 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
12332 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
12333
12334 @end smallexample
12335
12336 The following built-in functions are available when @option{-mlwp} is used.
12337
12338 @smallexample
12339 void __builtin_ia32_llwpcb16 (void *);
12340 void __builtin_ia32_llwpcb32 (void *);
12341 void __builtin_ia32_llwpcb64 (void *);
12342 void * __builtin_ia32_llwpcb16 (void);
12343 void * __builtin_ia32_llwpcb32 (void);
12344 void * __builtin_ia32_llwpcb64 (void);
12345 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
12346 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
12347 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
12348 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
12349 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
12350 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
12351 @end smallexample
12352
12353 The following built-in functions are available when @option{-mbmi} is used.
12354 All of them generate the machine instruction that is part of the name.
12355 @smallexample
12356 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
12357 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
12358 @end smallexample
12359
12360 The following built-in functions are available when @option{-mbmi2} is used.
12361 All of them generate the machine instruction that is part of the name.
12362 @smallexample
12363 unsigned int _bzhi_u32 (unsigned int, unsigned int)
12364 unsigned int _pdep_u32 (unsigned int, unsigned int)
12365 unsigned int _pext_u32 (unsigned int, unsigned int)
12366 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
12367 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
12368 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
12369 @end smallexample
12370
12371 The following built-in functions are available when @option{-mlzcnt} is used.
12372 All of them generate the machine instruction that is part of the name.
12373 @smallexample
12374 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
12375 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
12376 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
12377 @end smallexample
12378
12379 The following built-in functions are available when @option{-mfxsr} is used.
12380 All of them generate the machine instruction that is part of the name.
12381 @smallexample
12382 void __builtin_ia32_fxsave (void *)
12383 void __builtin_ia32_fxrstor (void *)
12384 void __builtin_ia32_fxsave64 (void *)
12385 void __builtin_ia32_fxrstor64 (void *)
12386 @end smallexample
12387
12388 The following built-in functions are available when @option{-mxsave} is used.
12389 All of them generate the machine instruction that is part of the name.
12390 @smallexample
12391 void __builtin_ia32_xsave (void *, long long)
12392 void __builtin_ia32_xrstor (void *, long long)
12393 void __builtin_ia32_xsave64 (void *, long long)
12394 void __builtin_ia32_xrstor64 (void *, long long)
12395 @end smallexample
12396
12397 The following built-in functions are available when @option{-mxsaveopt} is used.
12398 All of them generate the machine instruction that is part of the name.
12399 @smallexample
12400 void __builtin_ia32_xsaveopt (void *, long long)
12401 void __builtin_ia32_xsaveopt64 (void *, long long)
12402 @end smallexample
12403
12404 The following built-in functions are available when @option{-mtbm} is used.
12405 Both of them generate the immediate form of the bextr machine instruction.
12406 @smallexample
12407 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
12408 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
12409 @end smallexample
12410
12411
12412 The following built-in functions are available when @option{-m3dnow} is used.
12413 All of them generate the machine instruction that is part of the name.
12414
12415 @smallexample
12416 void __builtin_ia32_femms (void)
12417 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
12418 v2si __builtin_ia32_pf2id (v2sf)
12419 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
12420 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
12421 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
12422 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
12423 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
12424 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
12425 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
12426 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
12427 v2sf __builtin_ia32_pfrcp (v2sf)
12428 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
12429 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
12430 v2sf __builtin_ia32_pfrsqrt (v2sf)
12431 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
12432 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
12433 v2sf __builtin_ia32_pi2fd (v2si)
12434 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
12435 @end smallexample
12436
12437 The following built-in functions are available when both @option{-m3dnow}
12438 and @option{-march=athlon} are used. All of them generate the machine
12439 instruction that is part of the name.
12440
12441 @smallexample
12442 v2si __builtin_ia32_pf2iw (v2sf)
12443 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
12444 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
12445 v2sf __builtin_ia32_pi2fw (v2si)
12446 v2sf __builtin_ia32_pswapdsf (v2sf)
12447 v2si __builtin_ia32_pswapdsi (v2si)
12448 @end smallexample
12449
12450 The following built-in functions are available when @option{-mrtm} is used
12451 They are used for restricted transactional memory. These are the internal
12452 low level functions. Normally the functions in
12453 @ref{X86 transactional memory intrinsics} should be used instead.
12454
12455 @smallexample
12456 int __builtin_ia32_xbegin ()
12457 void __builtin_ia32_xend ()
12458 void __builtin_ia32_xabort (status)
12459 int __builtin_ia32_xtest ()
12460 @end smallexample
12461
12462 @node X86 transactional memory intrinsics
12463 @subsection X86 transaction memory intrinsics
12464
12465 Hardware transactional memory intrinsics for i386. These allow to use
12466 memory transactions with RTM (Restricted Transactional Memory).
12467 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
12468 This support is enabled with the @option{-mrtm} option.
12469
12470 A memory transaction commits all changes to memory in an atomic way,
12471 as visible to other threads. If the transaction fails it is rolled back
12472 and all side effects discarded.
12473
12474 Generally there is no guarantee that a memory transaction ever succeeds
12475 and suitable fallback code always needs to be supplied.
12476
12477 @deftypefn {RTM Function} {unsigned} _xbegin ()
12478 Start a RTM (Restricted Transactional Memory) transaction.
12479 Returns _XBEGIN_STARTED when the transaction
12480 started successfully (note this is not 0, so the constant has to be
12481 explicitely tested). When the transaction aborts all side effects
12482 are undone and an abort code is returned. There is no guarantee
12483 any transaction ever succeeds, so there always needs to be a valid
12484 tested fallback path.
12485 @end deftypefn
12486
12487 @smallexample
12488 #include <immintrin.h>
12489
12490 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
12491 ... transaction code...
12492 _xend ();
12493 @} else @{
12494 ... non transactional fallback path...
12495 @}
12496 @end smallexample
12497
12498 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
12499
12500 @table @code
12501 @item _XABORT_EXPLICIT
12502 Transaction explicitely aborted with @code{_xabort}. The parameter passed
12503 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
12504 @item _XABORT_RETRY
12505 Transaction retry is possible.
12506 @item _XABORT_CONFLICT
12507 Transaction abort due to a memory conflict with another thread
12508 @item _XABORT_CAPACITY
12509 Transaction abort due to the transaction using too much memory
12510 @item _XABORT_DEBUG
12511 Transaction abort due to a debug trap
12512 @item _XABORT_NESTED
12513 Transaction abort in a inner nested transaction
12514 @end table
12515
12516 @deftypefn {RTM Function} {void} _xend ()
12517 Commit the current transaction. When no transaction is active this will
12518 fault. All memory side effects of the transactions will become visible
12519 to other threads in an atomic matter.
12520 @end deftypefn
12521
12522 @deftypefn {RTM Function} {int} _xtest ()
12523 Return a value not zero when a transaction is currently active, otherwise 0.
12524 @end deftypefn
12525
12526 @deftypefn {RTM Function} {void} _xabort (status)
12527 Abort the current transaction. When no transaction is active this is a no-op.
12528 status must be a 8bit constant, that is included in the status code returned
12529 by @code{_xbegin}
12530 @end deftypefn
12531
12532 @node MIPS DSP Built-in Functions
12533 @subsection MIPS DSP Built-in Functions
12534
12535 The MIPS DSP Application-Specific Extension (ASE) includes new
12536 instructions that are designed to improve the performance of DSP and
12537 media applications. It provides instructions that operate on packed
12538 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12539
12540 GCC supports MIPS DSP operations using both the generic
12541 vector extensions (@pxref{Vector Extensions}) and a collection of
12542 MIPS-specific built-in functions. Both kinds of support are
12543 enabled by the @option{-mdsp} command-line option.
12544
12545 Revision 2 of the ASE was introduced in the second half of 2006.
12546 This revision adds extra instructions to the original ASE, but is
12547 otherwise backwards-compatible with it. You can select revision 2
12548 using the command-line option @option{-mdspr2}; this option implies
12549 @option{-mdsp}.
12550
12551 The SCOUNT and POS bits of the DSP control register are global. The
12552 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12553 POS bits. During optimization, the compiler does not delete these
12554 instructions and it does not delete calls to functions containing
12555 these instructions.
12556
12557 At present, GCC only provides support for operations on 32-bit
12558 vectors. The vector type associated with 8-bit integer data is
12559 usually called @code{v4i8}, the vector type associated with Q7
12560 is usually called @code{v4q7}, the vector type associated with 16-bit
12561 integer data is usually called @code{v2i16}, and the vector type
12562 associated with Q15 is usually called @code{v2q15}. They can be
12563 defined in C as follows:
12564
12565 @smallexample
12566 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12567 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12568 typedef short v2i16 __attribute__ ((vector_size(4)));
12569 typedef short v2q15 __attribute__ ((vector_size(4)));
12570 @end smallexample
12571
12572 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12573 initialized in the same way as aggregates. For example:
12574
12575 @smallexample
12576 v4i8 a = @{1, 2, 3, 4@};
12577 v4i8 b;
12578 b = (v4i8) @{5, 6, 7, 8@};
12579
12580 v2q15 c = @{0x0fcb, 0x3a75@};
12581 v2q15 d;
12582 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12583 @end smallexample
12584
12585 @emph{Note:} The CPU's endianness determines the order in which values
12586 are packed. On little-endian targets, the first value is the least
12587 significant and the last value is the most significant. The opposite
12588 order applies to big-endian targets. For example, the code above
12589 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12590 and @code{4} on big-endian targets.
12591
12592 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12593 representation. As shown in this example, the integer representation
12594 of a Q7 value can be obtained by multiplying the fractional value by
12595 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
12596 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
12597 @code{0x1.0p31}.
12598
12599 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12600 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
12601 and @code{c} and @code{d} are @code{v2q15} values.
12602
12603 @multitable @columnfractions .50 .50
12604 @item C code @tab MIPS instruction
12605 @item @code{a + b} @tab @code{addu.qb}
12606 @item @code{c + d} @tab @code{addq.ph}
12607 @item @code{a - b} @tab @code{subu.qb}
12608 @item @code{c - d} @tab @code{subq.ph}
12609 @end multitable
12610
12611 The table below lists the @code{v2i16} operation for which
12612 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
12613 @code{v2i16} values.
12614
12615 @multitable @columnfractions .50 .50
12616 @item C code @tab MIPS instruction
12617 @item @code{e * f} @tab @code{mul.ph}
12618 @end multitable
12619
12620 It is easier to describe the DSP built-in functions if we first define
12621 the following types:
12622
12623 @smallexample
12624 typedef int q31;
12625 typedef int i32;
12626 typedef unsigned int ui32;
12627 typedef long long a64;
12628 @end smallexample
12629
12630 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12631 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12632 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
12633 @code{long long}, but we use @code{a64} to indicate values that are
12634 placed in one of the four DSP accumulators (@code{$ac0},
12635 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12636
12637 Also, some built-in functions prefer or require immediate numbers as
12638 parameters, because the corresponding DSP instructions accept both immediate
12639 numbers and register operands, or accept immediate numbers only. The
12640 immediate parameters are listed as follows.
12641
12642 @smallexample
12643 imm0_3: 0 to 3.
12644 imm0_7: 0 to 7.
12645 imm0_15: 0 to 15.
12646 imm0_31: 0 to 31.
12647 imm0_63: 0 to 63.
12648 imm0_255: 0 to 255.
12649 imm_n32_31: -32 to 31.
12650 imm_n512_511: -512 to 511.
12651 @end smallexample
12652
12653 The following built-in functions map directly to a particular MIPS DSP
12654 instruction. Please refer to the architecture specification
12655 for details on what each instruction does.
12656
12657 @smallexample
12658 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12659 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12660 q31 __builtin_mips_addq_s_w (q31, q31)
12661 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12662 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12663 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12664 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12665 q31 __builtin_mips_subq_s_w (q31, q31)
12666 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12667 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12668 i32 __builtin_mips_addsc (i32, i32)
12669 i32 __builtin_mips_addwc (i32, i32)
12670 i32 __builtin_mips_modsub (i32, i32)
12671 i32 __builtin_mips_raddu_w_qb (v4i8)
12672 v2q15 __builtin_mips_absq_s_ph (v2q15)
12673 q31 __builtin_mips_absq_s_w (q31)
12674 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12675 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12676 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12677 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12678 q31 __builtin_mips_preceq_w_phl (v2q15)
12679 q31 __builtin_mips_preceq_w_phr (v2q15)
12680 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12681 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12682 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12683 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12684 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12685 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12686 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12687 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12688 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12689 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12690 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12691 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12692 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12693 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12694 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12695 q31 __builtin_mips_shll_s_w (q31, i32)
12696 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12697 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12698 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12699 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12700 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12701 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12702 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12703 q31 __builtin_mips_shra_r_w (q31, i32)
12704 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12705 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12706 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12707 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12708 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12709 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12710 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12711 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12712 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12713 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12714 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12715 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12716 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12717 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12718 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12719 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12720 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12721 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12722 i32 __builtin_mips_bitrev (i32)
12723 i32 __builtin_mips_insv (i32, i32)
12724 v4i8 __builtin_mips_repl_qb (imm0_255)
12725 v4i8 __builtin_mips_repl_qb (i32)
12726 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12727 v2q15 __builtin_mips_repl_ph (i32)
12728 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12729 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12730 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12731 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
12732 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
12733 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
12734 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
12735 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
12736 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
12737 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
12738 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
12739 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
12740 i32 __builtin_mips_extr_w (a64, imm0_31)
12741 i32 __builtin_mips_extr_w (a64, i32)
12742 i32 __builtin_mips_extr_r_w (a64, imm0_31)
12743 i32 __builtin_mips_extr_s_h (a64, i32)
12744 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
12745 i32 __builtin_mips_extr_rs_w (a64, i32)
12746 i32 __builtin_mips_extr_s_h (a64, imm0_31)
12747 i32 __builtin_mips_extr_r_w (a64, i32)
12748 i32 __builtin_mips_extp (a64, imm0_31)
12749 i32 __builtin_mips_extp (a64, i32)
12750 i32 __builtin_mips_extpdp (a64, imm0_31)
12751 i32 __builtin_mips_extpdp (a64, i32)
12752 a64 __builtin_mips_shilo (a64, imm_n32_31)
12753 a64 __builtin_mips_shilo (a64, i32)
12754 a64 __builtin_mips_mthlip (a64, i32)
12755 void __builtin_mips_wrdsp (i32, imm0_63)
12756 i32 __builtin_mips_rddsp (imm0_63)
12757 i32 __builtin_mips_lbux (void *, i32)
12758 i32 __builtin_mips_lhx (void *, i32)
12759 i32 __builtin_mips_lwx (void *, i32)
12760 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
12761 i32 __builtin_mips_bposge32 (void)
12762 a64 __builtin_mips_madd (a64, i32, i32);
12763 a64 __builtin_mips_maddu (a64, ui32, ui32);
12764 a64 __builtin_mips_msub (a64, i32, i32);
12765 a64 __builtin_mips_msubu (a64, ui32, ui32);
12766 a64 __builtin_mips_mult (i32, i32);
12767 a64 __builtin_mips_multu (ui32, ui32);
12768 @end smallexample
12769
12770 The following built-in functions map directly to a particular MIPS DSP REV 2
12771 instruction. Please refer to the architecture specification
12772 for details on what each instruction does.
12773
12774 @smallexample
12775 v4q7 __builtin_mips_absq_s_qb (v4q7);
12776 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
12777 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
12778 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
12779 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
12780 i32 __builtin_mips_append (i32, i32, imm0_31);
12781 i32 __builtin_mips_balign (i32, i32, imm0_3);
12782 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
12783 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
12784 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
12785 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
12786 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
12787 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
12788 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
12789 q31 __builtin_mips_mulq_rs_w (q31, q31);
12790 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
12791 q31 __builtin_mips_mulq_s_w (q31, q31);
12792 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
12793 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
12794 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
12795 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
12796 i32 __builtin_mips_prepend (i32, i32, imm0_31);
12797 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
12798 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
12799 v4i8 __builtin_mips_shra_qb (v4i8, i32);
12800 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
12801 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
12802 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
12803 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
12804 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
12805 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
12806 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
12807 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
12808 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
12809 q31 __builtin_mips_addqh_w (q31, q31);
12810 q31 __builtin_mips_addqh_r_w (q31, q31);
12811 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
12812 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
12813 q31 __builtin_mips_subqh_w (q31, q31);
12814 q31 __builtin_mips_subqh_r_w (q31, q31);
12815 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
12816 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
12817 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
12818 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
12819 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
12820 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
12821 @end smallexample
12822
12823
12824 @node MIPS Paired-Single Support
12825 @subsection MIPS Paired-Single Support
12826
12827 The MIPS64 architecture includes a number of instructions that
12828 operate on pairs of single-precision floating-point values.
12829 Each pair is packed into a 64-bit floating-point register,
12830 with one element being designated the ``upper half'' and
12831 the other being designated the ``lower half''.
12832
12833 GCC supports paired-single operations using both the generic
12834 vector extensions (@pxref{Vector Extensions}) and a collection of
12835 MIPS-specific built-in functions. Both kinds of support are
12836 enabled by the @option{-mpaired-single} command-line option.
12837
12838 The vector type associated with paired-single values is usually
12839 called @code{v2sf}. It can be defined in C as follows:
12840
12841 @smallexample
12842 typedef float v2sf __attribute__ ((vector_size (8)));
12843 @end smallexample
12844
12845 @code{v2sf} values are initialized in the same way as aggregates.
12846 For example:
12847
12848 @smallexample
12849 v2sf a = @{1.5, 9.1@};
12850 v2sf b;
12851 float e, f;
12852 b = (v2sf) @{e, f@};
12853 @end smallexample
12854
12855 @emph{Note:} The CPU's endianness determines which value is stored in
12856 the upper half of a register and which value is stored in the lower half.
12857 On little-endian targets, the first value is the lower one and the second
12858 value is the upper one. The opposite order applies to big-endian targets.
12859 For example, the code above sets the lower half of @code{a} to
12860 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
12861
12862 @node MIPS Loongson Built-in Functions
12863 @subsection MIPS Loongson Built-in Functions
12864
12865 GCC provides intrinsics to access the SIMD instructions provided by the
12866 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
12867 available after inclusion of the @code{loongson.h} header file,
12868 operate on the following 64-bit vector types:
12869
12870 @itemize
12871 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
12872 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
12873 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
12874 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
12875 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
12876 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
12877 @end itemize
12878
12879 The intrinsics provided are listed below; each is named after the
12880 machine instruction to which it corresponds, with suffixes added as
12881 appropriate to distinguish intrinsics that expand to the same machine
12882 instruction yet have different argument types. Refer to the architecture
12883 documentation for a description of the functionality of each
12884 instruction.
12885
12886 @smallexample
12887 int16x4_t packsswh (int32x2_t s, int32x2_t t);
12888 int8x8_t packsshb (int16x4_t s, int16x4_t t);
12889 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
12890 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
12891 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
12892 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
12893 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
12894 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
12895 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
12896 uint64_t paddd_u (uint64_t s, uint64_t t);
12897 int64_t paddd_s (int64_t s, int64_t t);
12898 int16x4_t paddsh (int16x4_t s, int16x4_t t);
12899 int8x8_t paddsb (int8x8_t s, int8x8_t t);
12900 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
12901 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
12902 uint64_t pandn_ud (uint64_t s, uint64_t t);
12903 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
12904 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
12905 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
12906 int64_t pandn_sd (int64_t s, int64_t t);
12907 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
12908 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
12909 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
12910 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
12911 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
12912 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
12913 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
12914 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
12915 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
12916 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
12917 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
12918 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
12919 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
12920 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
12921 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
12922 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
12923 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
12924 uint16x4_t pextrh_u (uint16x4_t s, int field);
12925 int16x4_t pextrh_s (int16x4_t s, int field);
12926 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
12927 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
12928 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
12929 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
12930 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
12931 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
12932 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
12933 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
12934 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
12935 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
12936 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
12937 int16x4_t pminsh (int16x4_t s, int16x4_t t);
12938 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
12939 uint8x8_t pmovmskb_u (uint8x8_t s);
12940 int8x8_t pmovmskb_s (int8x8_t s);
12941 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
12942 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
12943 int16x4_t pmullh (int16x4_t s, int16x4_t t);
12944 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
12945 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
12946 uint16x4_t biadd (uint8x8_t s);
12947 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
12948 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
12949 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
12950 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
12951 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
12952 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
12953 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
12954 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
12955 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
12956 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
12957 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
12958 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
12959 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
12960 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
12961 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
12962 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
12963 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
12964 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
12965 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
12966 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
12967 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
12968 uint64_t psubd_u (uint64_t s, uint64_t t);
12969 int64_t psubd_s (int64_t s, int64_t t);
12970 int16x4_t psubsh (int16x4_t s, int16x4_t t);
12971 int8x8_t psubsb (int8x8_t s, int8x8_t t);
12972 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
12973 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
12974 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
12975 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
12976 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
12977 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
12978 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
12979 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
12980 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
12981 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
12982 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
12983 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
12984 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
12985 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
12986 @end smallexample
12987
12988 @menu
12989 * Paired-Single Arithmetic::
12990 * Paired-Single Built-in Functions::
12991 * MIPS-3D Built-in Functions::
12992 @end menu
12993
12994 @node Paired-Single Arithmetic
12995 @subsubsection Paired-Single Arithmetic
12996
12997 The table below lists the @code{v2sf} operations for which hardware
12998 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
12999 values and @code{x} is an integral value.
13000
13001 @multitable @columnfractions .50 .50
13002 @item C code @tab MIPS instruction
13003 @item @code{a + b} @tab @code{add.ps}
13004 @item @code{a - b} @tab @code{sub.ps}
13005 @item @code{-a} @tab @code{neg.ps}
13006 @item @code{a * b} @tab @code{mul.ps}
13007 @item @code{a * b + c} @tab @code{madd.ps}
13008 @item @code{a * b - c} @tab @code{msub.ps}
13009 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13010 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13011 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13012 @end multitable
13013
13014 Note that the multiply-accumulate instructions can be disabled
13015 using the command-line option @code{-mno-fused-madd}.
13016
13017 @node Paired-Single Built-in Functions
13018 @subsubsection Paired-Single Built-in Functions
13019
13020 The following paired-single functions map directly to a particular
13021 MIPS instruction. Please refer to the architecture specification
13022 for details on what each instruction does.
13023
13024 @table @code
13025 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13026 Pair lower lower (@code{pll.ps}).
13027
13028 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13029 Pair upper lower (@code{pul.ps}).
13030
13031 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13032 Pair lower upper (@code{plu.ps}).
13033
13034 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13035 Pair upper upper (@code{puu.ps}).
13036
13037 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13038 Convert pair to paired single (@code{cvt.ps.s}).
13039
13040 @item float __builtin_mips_cvt_s_pl (v2sf)
13041 Convert pair lower to single (@code{cvt.s.pl}).
13042
13043 @item float __builtin_mips_cvt_s_pu (v2sf)
13044 Convert pair upper to single (@code{cvt.s.pu}).
13045
13046 @item v2sf __builtin_mips_abs_ps (v2sf)
13047 Absolute value (@code{abs.ps}).
13048
13049 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13050 Align variable (@code{alnv.ps}).
13051
13052 @emph{Note:} The value of the third parameter must be 0 or 4
13053 modulo 8, otherwise the result is unpredictable. Please read the
13054 instruction description for details.
13055 @end table
13056
13057 The following multi-instruction functions are also available.
13058 In each case, @var{cond} can be any of the 16 floating-point conditions:
13059 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13060 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13061 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13062
13063 @table @code
13064 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13065 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13066 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13067 @code{movt.ps}/@code{movf.ps}).
13068
13069 The @code{movt} functions return the value @var{x} computed by:
13070
13071 @smallexample
13072 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13073 mov.ps @var{x},@var{c}
13074 movt.ps @var{x},@var{d},@var{cc}
13075 @end smallexample
13076
13077 The @code{movf} functions are similar but use @code{movf.ps} instead
13078 of @code{movt.ps}.
13079
13080 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13081 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13082 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13083 @code{bc1t}/@code{bc1f}).
13084
13085 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13086 and return either the upper or lower half of the result. For example:
13087
13088 @smallexample
13089 v2sf a, b;
13090 if (__builtin_mips_upper_c_eq_ps (a, b))
13091 upper_halves_are_equal ();
13092 else
13093 upper_halves_are_unequal ();
13094
13095 if (__builtin_mips_lower_c_eq_ps (a, b))
13096 lower_halves_are_equal ();
13097 else
13098 lower_halves_are_unequal ();
13099 @end smallexample
13100 @end table
13101
13102 @node MIPS-3D Built-in Functions
13103 @subsubsection MIPS-3D Built-in Functions
13104
13105 The MIPS-3D Application-Specific Extension (ASE) includes additional
13106 paired-single instructions that are designed to improve the performance
13107 of 3D graphics operations. Support for these instructions is controlled
13108 by the @option{-mips3d} command-line option.
13109
13110 The functions listed below map directly to a particular MIPS-3D
13111 instruction. Please refer to the architecture specification for
13112 more details on what each instruction does.
13113
13114 @table @code
13115 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13116 Reduction add (@code{addr.ps}).
13117
13118 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13119 Reduction multiply (@code{mulr.ps}).
13120
13121 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13122 Convert paired single to paired word (@code{cvt.pw.ps}).
13123
13124 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13125 Convert paired word to paired single (@code{cvt.ps.pw}).
13126
13127 @item float __builtin_mips_recip1_s (float)
13128 @itemx double __builtin_mips_recip1_d (double)
13129 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13130 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13131
13132 @item float __builtin_mips_recip2_s (float, float)
13133 @itemx double __builtin_mips_recip2_d (double, double)
13134 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13135 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13136
13137 @item float __builtin_mips_rsqrt1_s (float)
13138 @itemx double __builtin_mips_rsqrt1_d (double)
13139 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13140 Reduced-precision reciprocal square root (sequence step 1)
13141 (@code{rsqrt1.@var{fmt}}).
13142
13143 @item float __builtin_mips_rsqrt2_s (float, float)
13144 @itemx double __builtin_mips_rsqrt2_d (double, double)
13145 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13146 Reduced-precision reciprocal square root (sequence step 2)
13147 (@code{rsqrt2.@var{fmt}}).
13148 @end table
13149
13150 The following multi-instruction functions are also available.
13151 In each case, @var{cond} can be any of the 16 floating-point conditions:
13152 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13153 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13154 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13155
13156 @table @code
13157 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13158 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13159 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13160 @code{bc1t}/@code{bc1f}).
13161
13162 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13163 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13164 For example:
13165
13166 @smallexample
13167 float a, b;
13168 if (__builtin_mips_cabs_eq_s (a, b))
13169 true ();
13170 else
13171 false ();
13172 @end smallexample
13173
13174 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13175 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13176 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13177 @code{bc1t}/@code{bc1f}).
13178
13179 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13180 and return either the upper or lower half of the result. For example:
13181
13182 @smallexample
13183 v2sf a, b;
13184 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13185 upper_halves_are_equal ();
13186 else
13187 upper_halves_are_unequal ();
13188
13189 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13190 lower_halves_are_equal ();
13191 else
13192 lower_halves_are_unequal ();
13193 @end smallexample
13194
13195 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13196 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13197 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13198 @code{movt.ps}/@code{movf.ps}).
13199
13200 The @code{movt} functions return the value @var{x} computed by:
13201
13202 @smallexample
13203 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13204 mov.ps @var{x},@var{c}
13205 movt.ps @var{x},@var{d},@var{cc}
13206 @end smallexample
13207
13208 The @code{movf} functions are similar but use @code{movf.ps} instead
13209 of @code{movt.ps}.
13210
13211 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13212 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13213 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13214 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13215 Comparison of two paired-single values
13216 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13217 @code{bc1any2t}/@code{bc1any2f}).
13218
13219 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13220 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13221 result is true and the @code{all} forms return true if both results are true.
13222 For example:
13223
13224 @smallexample
13225 v2sf a, b;
13226 if (__builtin_mips_any_c_eq_ps (a, b))
13227 one_is_true ();
13228 else
13229 both_are_false ();
13230
13231 if (__builtin_mips_all_c_eq_ps (a, b))
13232 both_are_true ();
13233 else
13234 one_is_false ();
13235 @end smallexample
13236
13237 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13238 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13239 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13240 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13241 Comparison of four paired-single values
13242 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13243 @code{bc1any4t}/@code{bc1any4f}).
13244
13245 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13246 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13247 The @code{any} forms return true if any of the four results are true
13248 and the @code{all} forms return true if all four results are true.
13249 For example:
13250
13251 @smallexample
13252 v2sf a, b, c, d;
13253 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13254 some_are_true ();
13255 else
13256 all_are_false ();
13257
13258 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13259 all_are_true ();
13260 else
13261 some_are_false ();
13262 @end smallexample
13263 @end table
13264
13265 @node Other MIPS Built-in Functions
13266 @subsection Other MIPS Built-in Functions
13267
13268 GCC provides other MIPS-specific built-in functions:
13269
13270 @table @code
13271 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13272 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13273 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13274 when this function is available.
13275
13276 @item unsigned int __builtin_mips_get_fcsr (void)
13277 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13278 Get and set the contents of the floating-point control and status register
13279 (FPU control register 31). These functions are only available in hard-float
13280 code but can be called in both MIPS16 and non-MIPS16 contexts.
13281
13282 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13283 register except the condition codes, which GCC assumes are preserved.
13284 @end table
13285
13286 @node MSP430 Built-in Functions
13287 @subsection MSP430 Built-in Functions
13288
13289 GCC provides a couple of special builtin functions to aid in the
13290 writing of interrupt handlers in C.
13291
13292 @table @code
13293 @item __bic_SR_register_on_exit (int @var{mask})
13294 This clears the indicated bits in the saved copy of the status register
13295 currently residing on the stack. This only works inside interrupt
13296 handlers and the changes to the status register will only take affect
13297 once the handler returns.
13298
13299 @item __bis_SR_register_on_exit (int @var{mask})
13300 This sets the indicated bits in the saved copy of the status register
13301 currently residing on the stack. This only works inside interrupt
13302 handlers and the changes to the status register will only take affect
13303 once the handler returns.
13304
13305 @item __delay_cycles (long long @var{cycles})
13306 This inserts an instruction sequence that takes exactly @var{cycles}
13307 cycles (between 0 and about 17E9) to complete. The inserted sequence
13308 may use jumps, loops, or no-ops, and does not interfere with any other
13309 instructions. Note that @var{cycles} must be a compile-time constant
13310 integer - that is, you must pass a number, not a variable that may be
13311 optimized to a constant later. The number of cycles delayed by this
13312 builtin is exact.
13313 @end table
13314
13315 @node NDS32 Built-in Functions
13316 @subsection NDS32 Built-in Functions
13317
13318 These built-in functions are available for the NDS32 target:
13319
13320 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13321 Insert an ISYNC instruction into the instruction stream where
13322 @var{addr} is an instruction address for serialization.
13323 @end deftypefn
13324
13325 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13326 Insert an ISB instruction into the instruction stream.
13327 @end deftypefn
13328
13329 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13330 Return the content of a system register which is mapped by @var{sr}.
13331 @end deftypefn
13332
13333 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13334 Return the content of a user space register which is mapped by @var{usr}.
13335 @end deftypefn
13336
13337 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13338 Move the @var{value} to a system register which is mapped by @var{sr}.
13339 @end deftypefn
13340
13341 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13342 Move the @var{value} to a user space register which is mapped by @var{usr}.
13343 @end deftypefn
13344
13345 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13346 Enable global interrupt.
13347 @end deftypefn
13348
13349 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13350 Disable global interrupt.
13351 @end deftypefn
13352
13353 @node picoChip Built-in Functions
13354 @subsection picoChip Built-in Functions
13355
13356 GCC provides an interface to selected machine instructions from the
13357 picoChip instruction set.
13358
13359 @table @code
13360 @item int __builtin_sbc (int @var{value})
13361 Sign bit count. Return the number of consecutive bits in @var{value}
13362 that have the same value as the sign bit. The result is the number of
13363 leading sign bits minus one, giving the number of redundant sign bits in
13364 @var{value}.
13365
13366 @item int __builtin_byteswap (int @var{value})
13367 Byte swap. Return the result of swapping the upper and lower bytes of
13368 @var{value}.
13369
13370 @item int __builtin_brev (int @var{value})
13371 Bit reversal. Return the result of reversing the bits in
13372 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13373 and so on.
13374
13375 @item int __builtin_adds (int @var{x}, int @var{y})
13376 Saturating addition. Return the result of adding @var{x} and @var{y},
13377 storing the value 32767 if the result overflows.
13378
13379 @item int __builtin_subs (int @var{x}, int @var{y})
13380 Saturating subtraction. Return the result of subtracting @var{y} from
13381 @var{x}, storing the value @minus{}32768 if the result overflows.
13382
13383 @item void __builtin_halt (void)
13384 Halt. The processor stops execution. This built-in is useful for
13385 implementing assertions.
13386
13387 @end table
13388
13389 @node PowerPC Built-in Functions
13390 @subsection PowerPC Built-in Functions
13391
13392 These built-in functions are available for the PowerPC family of
13393 processors:
13394 @smallexample
13395 float __builtin_recipdivf (float, float);
13396 float __builtin_rsqrtf (float);
13397 double __builtin_recipdiv (double, double);
13398 double __builtin_rsqrt (double);
13399 uint64_t __builtin_ppc_get_timebase ();
13400 unsigned long __builtin_ppc_mftb ();
13401 double __builtin_unpack_longdouble (long double, int);
13402 double __builtin_longdouble_dw0 (long double);
13403 double __builtin_longdouble_dw1 (long double);
13404 long double __builtin_pack_longdouble (double, double);
13405 @end smallexample
13406
13407 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13408 @code{__builtin_rsqrtf} functions generate multiple instructions to
13409 implement the reciprocal sqrt functionality using reciprocal sqrt
13410 estimate instructions.
13411
13412 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13413 functions generate multiple instructions to implement division using
13414 the reciprocal estimate instructions.
13415
13416 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13417 functions generate instructions to read the Time Base Register. The
13418 @code{__builtin_ppc_get_timebase} function may generate multiple
13419 instructions and always returns the 64 bits of the Time Base Register.
13420 The @code{__builtin_ppc_mftb} function always generates one instruction and
13421 returns the Time Base Register value as an unsigned long, throwing away
13422 the most significant word on 32-bit environments.
13423
13424 The following built-in functions are available for the PowerPC family
13425 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13426 or @option{-mpopcntd}):
13427 @smallexample
13428 long __builtin_bpermd (long, long);
13429 int __builtin_divwe (int, int);
13430 int __builtin_divweo (int, int);
13431 unsigned int __builtin_divweu (unsigned int, unsigned int);
13432 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13433 long __builtin_divde (long, long);
13434 long __builtin_divdeo (long, long);
13435 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13436 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13437 unsigned int cdtbcd (unsigned int);
13438 unsigned int cbcdtd (unsigned int);
13439 unsigned int addg6s (unsigned int, unsigned int);
13440 @end smallexample
13441
13442 The @code{__builtin_divde}, @code{__builtin_divdeo},
13443 @code{__builitin_divdeu}, @code{__builtin_divdeou} functions require a
13444 64-bit environment support ISA 2.06 or later.
13445
13446 The following built-in functions are available for the PowerPC family
13447 of processors when hardware decimal floating point
13448 (@option{-mhard-dfp}) is available:
13449 @smallexample
13450 _Decimal64 __builtin_dxex (_Decimal64);
13451 _Decimal128 __builtin_dxexq (_Decimal128);
13452 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13453 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13454 _Decimal64 __builtin_denbcd (int, _Decimal64);
13455 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13456 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13457 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13458 _Decimal64 __builtin_dscli (_Decimal64, int);
13459 _Decimal128 __builitn_dscliq (_Decimal128, int);
13460 _Decimal64 __builtin_dscri (_Decimal64, int);
13461 _Decimal128 __builitn_dscriq (_Decimal128, int);
13462 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13463 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13464 @end smallexample
13465
13466 The following built-in functions are available for the PowerPC family
13467 of processors when the Vector Scalar (vsx) instruction set is
13468 available:
13469 @smallexample
13470 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13471 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13472 unsigned long long);
13473 @end smallexample
13474
13475 @node PowerPC AltiVec/VSX Built-in Functions
13476 @subsection PowerPC AltiVec Built-in Functions
13477
13478 GCC provides an interface for the PowerPC family of processors to access
13479 the AltiVec operations described in Motorola's AltiVec Programming
13480 Interface Manual. The interface is made available by including
13481 @code{<altivec.h>} and using @option{-maltivec} and
13482 @option{-mabi=altivec}. The interface supports the following vector
13483 types.
13484
13485 @smallexample
13486 vector unsigned char
13487 vector signed char
13488 vector bool char
13489
13490 vector unsigned short
13491 vector signed short
13492 vector bool short
13493 vector pixel
13494
13495 vector unsigned int
13496 vector signed int
13497 vector bool int
13498 vector float
13499 @end smallexample
13500
13501 If @option{-mvsx} is used the following additional vector types are
13502 implemented.
13503
13504 @smallexample
13505 vector unsigned long
13506 vector signed long
13507 vector double
13508 @end smallexample
13509
13510 The long types are only implemented for 64-bit code generation, and
13511 the long type is only used in the floating point/integer conversion
13512 instructions.
13513
13514 GCC's implementation of the high-level language interface available from
13515 C and C++ code differs from Motorola's documentation in several ways.
13516
13517 @itemize @bullet
13518
13519 @item
13520 A vector constant is a list of constant expressions within curly braces.
13521
13522 @item
13523 A vector initializer requires no cast if the vector constant is of the
13524 same type as the variable it is initializing.
13525
13526 @item
13527 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13528 vector type is the default signedness of the base type. The default
13529 varies depending on the operating system, so a portable program should
13530 always specify the signedness.
13531
13532 @item
13533 Compiling with @option{-maltivec} adds keywords @code{__vector},
13534 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13535 @code{bool}. When compiling ISO C, the context-sensitive substitution
13536 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13537 disabled. To use them, you must include @code{<altivec.h>} instead.
13538
13539 @item
13540 GCC allows using a @code{typedef} name as the type specifier for a
13541 vector type.
13542
13543 @item
13544 For C, overloaded functions are implemented with macros so the following
13545 does not work:
13546
13547 @smallexample
13548 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13549 @end smallexample
13550
13551 @noindent
13552 Since @code{vec_add} is a macro, the vector constant in the example
13553 is treated as four separate arguments. Wrap the entire argument in
13554 parentheses for this to work.
13555 @end itemize
13556
13557 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13558 Internally, GCC uses built-in functions to achieve the functionality in
13559 the aforementioned header file, but they are not supported and are
13560 subject to change without notice.
13561
13562 The following interfaces are supported for the generic and specific
13563 AltiVec operations and the AltiVec predicates. In cases where there
13564 is a direct mapping between generic and specific operations, only the
13565 generic names are shown here, although the specific operations can also
13566 be used.
13567
13568 Arguments that are documented as @code{const int} require literal
13569 integral values within the range required for that operation.
13570
13571 @smallexample
13572 vector signed char vec_abs (vector signed char);
13573 vector signed short vec_abs (vector signed short);
13574 vector signed int vec_abs (vector signed int);
13575 vector float vec_abs (vector float);
13576
13577 vector signed char vec_abss (vector signed char);
13578 vector signed short vec_abss (vector signed short);
13579 vector signed int vec_abss (vector signed int);
13580
13581 vector signed char vec_add (vector bool char, vector signed char);
13582 vector signed char vec_add (vector signed char, vector bool char);
13583 vector signed char vec_add (vector signed char, vector signed char);
13584 vector unsigned char vec_add (vector bool char, vector unsigned char);
13585 vector unsigned char vec_add (vector unsigned char, vector bool char);
13586 vector unsigned char vec_add (vector unsigned char,
13587 vector unsigned char);
13588 vector signed short vec_add (vector bool short, vector signed short);
13589 vector signed short vec_add (vector signed short, vector bool short);
13590 vector signed short vec_add (vector signed short, vector signed short);
13591 vector unsigned short vec_add (vector bool short,
13592 vector unsigned short);
13593 vector unsigned short vec_add (vector unsigned short,
13594 vector bool short);
13595 vector unsigned short vec_add (vector unsigned short,
13596 vector unsigned short);
13597 vector signed int vec_add (vector bool int, vector signed int);
13598 vector signed int vec_add (vector signed int, vector bool int);
13599 vector signed int vec_add (vector signed int, vector signed int);
13600 vector unsigned int vec_add (vector bool int, vector unsigned int);
13601 vector unsigned int vec_add (vector unsigned int, vector bool int);
13602 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13603 vector float vec_add (vector float, vector float);
13604
13605 vector float vec_vaddfp (vector float, vector float);
13606
13607 vector signed int vec_vadduwm (vector bool int, vector signed int);
13608 vector signed int vec_vadduwm (vector signed int, vector bool int);
13609 vector signed int vec_vadduwm (vector signed int, vector signed int);
13610 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13611 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
13612 vector unsigned int vec_vadduwm (vector unsigned int,
13613 vector unsigned int);
13614
13615 vector signed short vec_vadduhm (vector bool short,
13616 vector signed short);
13617 vector signed short vec_vadduhm (vector signed short,
13618 vector bool short);
13619 vector signed short vec_vadduhm (vector signed short,
13620 vector signed short);
13621 vector unsigned short vec_vadduhm (vector bool short,
13622 vector unsigned short);
13623 vector unsigned short vec_vadduhm (vector unsigned short,
13624 vector bool short);
13625 vector unsigned short vec_vadduhm (vector unsigned short,
13626 vector unsigned short);
13627
13628 vector signed char vec_vaddubm (vector bool char, vector signed char);
13629 vector signed char vec_vaddubm (vector signed char, vector bool char);
13630 vector signed char vec_vaddubm (vector signed char, vector signed char);
13631 vector unsigned char vec_vaddubm (vector bool char,
13632 vector unsigned char);
13633 vector unsigned char vec_vaddubm (vector unsigned char,
13634 vector bool char);
13635 vector unsigned char vec_vaddubm (vector unsigned char,
13636 vector unsigned char);
13637
13638 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
13639
13640 vector unsigned char vec_adds (vector bool char, vector unsigned char);
13641 vector unsigned char vec_adds (vector unsigned char, vector bool char);
13642 vector unsigned char vec_adds (vector unsigned char,
13643 vector unsigned char);
13644 vector signed char vec_adds (vector bool char, vector signed char);
13645 vector signed char vec_adds (vector signed char, vector bool char);
13646 vector signed char vec_adds (vector signed char, vector signed char);
13647 vector unsigned short vec_adds (vector bool short,
13648 vector unsigned short);
13649 vector unsigned short vec_adds (vector unsigned short,
13650 vector bool short);
13651 vector unsigned short vec_adds (vector unsigned short,
13652 vector unsigned short);
13653 vector signed short vec_adds (vector bool short, vector signed short);
13654 vector signed short vec_adds (vector signed short, vector bool short);
13655 vector signed short vec_adds (vector signed short, vector signed short);
13656 vector unsigned int vec_adds (vector bool int, vector unsigned int);
13657 vector unsigned int vec_adds (vector unsigned int, vector bool int);
13658 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
13659 vector signed int vec_adds (vector bool int, vector signed int);
13660 vector signed int vec_adds (vector signed int, vector bool int);
13661 vector signed int vec_adds (vector signed int, vector signed int);
13662
13663 vector signed int vec_vaddsws (vector bool int, vector signed int);
13664 vector signed int vec_vaddsws (vector signed int, vector bool int);
13665 vector signed int vec_vaddsws (vector signed int, vector signed int);
13666
13667 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
13668 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
13669 vector unsigned int vec_vadduws (vector unsigned int,
13670 vector unsigned int);
13671
13672 vector signed short vec_vaddshs (vector bool short,
13673 vector signed short);
13674 vector signed short vec_vaddshs (vector signed short,
13675 vector bool short);
13676 vector signed short vec_vaddshs (vector signed short,
13677 vector signed short);
13678
13679 vector unsigned short vec_vadduhs (vector bool short,
13680 vector unsigned short);
13681 vector unsigned short vec_vadduhs (vector unsigned short,
13682 vector bool short);
13683 vector unsigned short vec_vadduhs (vector unsigned short,
13684 vector unsigned short);
13685
13686 vector signed char vec_vaddsbs (vector bool char, vector signed char);
13687 vector signed char vec_vaddsbs (vector signed char, vector bool char);
13688 vector signed char vec_vaddsbs (vector signed char, vector signed char);
13689
13690 vector unsigned char vec_vaddubs (vector bool char,
13691 vector unsigned char);
13692 vector unsigned char vec_vaddubs (vector unsigned char,
13693 vector bool char);
13694 vector unsigned char vec_vaddubs (vector unsigned char,
13695 vector unsigned char);
13696
13697 vector float vec_and (vector float, vector float);
13698 vector float vec_and (vector float, vector bool int);
13699 vector float vec_and (vector bool int, vector float);
13700 vector bool int vec_and (vector bool int, vector bool int);
13701 vector signed int vec_and (vector bool int, vector signed int);
13702 vector signed int vec_and (vector signed int, vector bool int);
13703 vector signed int vec_and (vector signed int, vector signed int);
13704 vector unsigned int vec_and (vector bool int, vector unsigned int);
13705 vector unsigned int vec_and (vector unsigned int, vector bool int);
13706 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
13707 vector bool short vec_and (vector bool short, vector bool short);
13708 vector signed short vec_and (vector bool short, vector signed short);
13709 vector signed short vec_and (vector signed short, vector bool short);
13710 vector signed short vec_and (vector signed short, vector signed short);
13711 vector unsigned short vec_and (vector bool short,
13712 vector unsigned short);
13713 vector unsigned short vec_and (vector unsigned short,
13714 vector bool short);
13715 vector unsigned short vec_and (vector unsigned short,
13716 vector unsigned short);
13717 vector signed char vec_and (vector bool char, vector signed char);
13718 vector bool char vec_and (vector bool char, vector bool char);
13719 vector signed char vec_and (vector signed char, vector bool char);
13720 vector signed char vec_and (vector signed char, vector signed char);
13721 vector unsigned char vec_and (vector bool char, vector unsigned char);
13722 vector unsigned char vec_and (vector unsigned char, vector bool char);
13723 vector unsigned char vec_and (vector unsigned char,
13724 vector unsigned char);
13725
13726 vector float vec_andc (vector float, vector float);
13727 vector float vec_andc (vector float, vector bool int);
13728 vector float vec_andc (vector bool int, vector float);
13729 vector bool int vec_andc (vector bool int, vector bool int);
13730 vector signed int vec_andc (vector bool int, vector signed int);
13731 vector signed int vec_andc (vector signed int, vector bool int);
13732 vector signed int vec_andc (vector signed int, vector signed int);
13733 vector unsigned int vec_andc (vector bool int, vector unsigned int);
13734 vector unsigned int vec_andc (vector unsigned int, vector bool int);
13735 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
13736 vector bool short vec_andc (vector bool short, vector bool short);
13737 vector signed short vec_andc (vector bool short, vector signed short);
13738 vector signed short vec_andc (vector signed short, vector bool short);
13739 vector signed short vec_andc (vector signed short, vector signed short);
13740 vector unsigned short vec_andc (vector bool short,
13741 vector unsigned short);
13742 vector unsigned short vec_andc (vector unsigned short,
13743 vector bool short);
13744 vector unsigned short vec_andc (vector unsigned short,
13745 vector unsigned short);
13746 vector signed char vec_andc (vector bool char, vector signed char);
13747 vector bool char vec_andc (vector bool char, vector bool char);
13748 vector signed char vec_andc (vector signed char, vector bool char);
13749 vector signed char vec_andc (vector signed char, vector signed char);
13750 vector unsigned char vec_andc (vector bool char, vector unsigned char);
13751 vector unsigned char vec_andc (vector unsigned char, vector bool char);
13752 vector unsigned char vec_andc (vector unsigned char,
13753 vector unsigned char);
13754
13755 vector unsigned char vec_avg (vector unsigned char,
13756 vector unsigned char);
13757 vector signed char vec_avg (vector signed char, vector signed char);
13758 vector unsigned short vec_avg (vector unsigned short,
13759 vector unsigned short);
13760 vector signed short vec_avg (vector signed short, vector signed short);
13761 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
13762 vector signed int vec_avg (vector signed int, vector signed int);
13763
13764 vector signed int vec_vavgsw (vector signed int, vector signed int);
13765
13766 vector unsigned int vec_vavguw (vector unsigned int,
13767 vector unsigned int);
13768
13769 vector signed short vec_vavgsh (vector signed short,
13770 vector signed short);
13771
13772 vector unsigned short vec_vavguh (vector unsigned short,
13773 vector unsigned short);
13774
13775 vector signed char vec_vavgsb (vector signed char, vector signed char);
13776
13777 vector unsigned char vec_vavgub (vector unsigned char,
13778 vector unsigned char);
13779
13780 vector float vec_copysign (vector float);
13781
13782 vector float vec_ceil (vector float);
13783
13784 vector signed int vec_cmpb (vector float, vector float);
13785
13786 vector bool char vec_cmpeq (vector signed char, vector signed char);
13787 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
13788 vector bool short vec_cmpeq (vector signed short, vector signed short);
13789 vector bool short vec_cmpeq (vector unsigned short,
13790 vector unsigned short);
13791 vector bool int vec_cmpeq (vector signed int, vector signed int);
13792 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
13793 vector bool int vec_cmpeq (vector float, vector float);
13794
13795 vector bool int vec_vcmpeqfp (vector float, vector float);
13796
13797 vector bool int vec_vcmpequw (vector signed int, vector signed int);
13798 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
13799
13800 vector bool short vec_vcmpequh (vector signed short,
13801 vector signed short);
13802 vector bool short vec_vcmpequh (vector unsigned short,
13803 vector unsigned short);
13804
13805 vector bool char vec_vcmpequb (vector signed char, vector signed char);
13806 vector bool char vec_vcmpequb (vector unsigned char,
13807 vector unsigned char);
13808
13809 vector bool int vec_cmpge (vector float, vector float);
13810
13811 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
13812 vector bool char vec_cmpgt (vector signed char, vector signed char);
13813 vector bool short vec_cmpgt (vector unsigned short,
13814 vector unsigned short);
13815 vector bool short vec_cmpgt (vector signed short, vector signed short);
13816 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
13817 vector bool int vec_cmpgt (vector signed int, vector signed int);
13818 vector bool int vec_cmpgt (vector float, vector float);
13819
13820 vector bool int vec_vcmpgtfp (vector float, vector float);
13821
13822 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
13823
13824 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
13825
13826 vector bool short vec_vcmpgtsh (vector signed short,
13827 vector signed short);
13828
13829 vector bool short vec_vcmpgtuh (vector unsigned short,
13830 vector unsigned short);
13831
13832 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
13833
13834 vector bool char vec_vcmpgtub (vector unsigned char,
13835 vector unsigned char);
13836
13837 vector bool int vec_cmple (vector float, vector float);
13838
13839 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
13840 vector bool char vec_cmplt (vector signed char, vector signed char);
13841 vector bool short vec_cmplt (vector unsigned short,
13842 vector unsigned short);
13843 vector bool short vec_cmplt (vector signed short, vector signed short);
13844 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
13845 vector bool int vec_cmplt (vector signed int, vector signed int);
13846 vector bool int vec_cmplt (vector float, vector float);
13847
13848 vector float vec_ctf (vector unsigned int, const int);
13849 vector float vec_ctf (vector signed int, const int);
13850
13851 vector float vec_vcfsx (vector signed int, const int);
13852
13853 vector float vec_vcfux (vector unsigned int, const int);
13854
13855 vector signed int vec_cts (vector float, const int);
13856
13857 vector unsigned int vec_ctu (vector float, const int);
13858
13859 void vec_dss (const int);
13860
13861 void vec_dssall (void);
13862
13863 void vec_dst (const vector unsigned char *, int, const int);
13864 void vec_dst (const vector signed char *, int, const int);
13865 void vec_dst (const vector bool char *, int, const int);
13866 void vec_dst (const vector unsigned short *, int, const int);
13867 void vec_dst (const vector signed short *, int, const int);
13868 void vec_dst (const vector bool short *, int, const int);
13869 void vec_dst (const vector pixel *, int, const int);
13870 void vec_dst (const vector unsigned int *, int, const int);
13871 void vec_dst (const vector signed int *, int, const int);
13872 void vec_dst (const vector bool int *, int, const int);
13873 void vec_dst (const vector float *, int, const int);
13874 void vec_dst (const unsigned char *, int, const int);
13875 void vec_dst (const signed char *, int, const int);
13876 void vec_dst (const unsigned short *, int, const int);
13877 void vec_dst (const short *, int, const int);
13878 void vec_dst (const unsigned int *, int, const int);
13879 void vec_dst (const int *, int, const int);
13880 void vec_dst (const unsigned long *, int, const int);
13881 void vec_dst (const long *, int, const int);
13882 void vec_dst (const float *, int, const int);
13883
13884 void vec_dstst (const vector unsigned char *, int, const int);
13885 void vec_dstst (const vector signed char *, int, const int);
13886 void vec_dstst (const vector bool char *, int, const int);
13887 void vec_dstst (const vector unsigned short *, int, const int);
13888 void vec_dstst (const vector signed short *, int, const int);
13889 void vec_dstst (const vector bool short *, int, const int);
13890 void vec_dstst (const vector pixel *, int, const int);
13891 void vec_dstst (const vector unsigned int *, int, const int);
13892 void vec_dstst (const vector signed int *, int, const int);
13893 void vec_dstst (const vector bool int *, int, const int);
13894 void vec_dstst (const vector float *, int, const int);
13895 void vec_dstst (const unsigned char *, int, const int);
13896 void vec_dstst (const signed char *, int, const int);
13897 void vec_dstst (const unsigned short *, int, const int);
13898 void vec_dstst (const short *, int, const int);
13899 void vec_dstst (const unsigned int *, int, const int);
13900 void vec_dstst (const int *, int, const int);
13901 void vec_dstst (const unsigned long *, int, const int);
13902 void vec_dstst (const long *, int, const int);
13903 void vec_dstst (const float *, int, const int);
13904
13905 void vec_dststt (const vector unsigned char *, int, const int);
13906 void vec_dststt (const vector signed char *, int, const int);
13907 void vec_dststt (const vector bool char *, int, const int);
13908 void vec_dststt (const vector unsigned short *, int, const int);
13909 void vec_dststt (const vector signed short *, int, const int);
13910 void vec_dststt (const vector bool short *, int, const int);
13911 void vec_dststt (const vector pixel *, int, const int);
13912 void vec_dststt (const vector unsigned int *, int, const int);
13913 void vec_dststt (const vector signed int *, int, const int);
13914 void vec_dststt (const vector bool int *, int, const int);
13915 void vec_dststt (const vector float *, int, const int);
13916 void vec_dststt (const unsigned char *, int, const int);
13917 void vec_dststt (const signed char *, int, const int);
13918 void vec_dststt (const unsigned short *, int, const int);
13919 void vec_dststt (const short *, int, const int);
13920 void vec_dststt (const unsigned int *, int, const int);
13921 void vec_dststt (const int *, int, const int);
13922 void vec_dststt (const unsigned long *, int, const int);
13923 void vec_dststt (const long *, int, const int);
13924 void vec_dststt (const float *, int, const int);
13925
13926 void vec_dstt (const vector unsigned char *, int, const int);
13927 void vec_dstt (const vector signed char *, int, const int);
13928 void vec_dstt (const vector bool char *, int, const int);
13929 void vec_dstt (const vector unsigned short *, int, const int);
13930 void vec_dstt (const vector signed short *, int, const int);
13931 void vec_dstt (const vector bool short *, int, const int);
13932 void vec_dstt (const vector pixel *, int, const int);
13933 void vec_dstt (const vector unsigned int *, int, const int);
13934 void vec_dstt (const vector signed int *, int, const int);
13935 void vec_dstt (const vector bool int *, int, const int);
13936 void vec_dstt (const vector float *, int, const int);
13937 void vec_dstt (const unsigned char *, int, const int);
13938 void vec_dstt (const signed char *, int, const int);
13939 void vec_dstt (const unsigned short *, int, const int);
13940 void vec_dstt (const short *, int, const int);
13941 void vec_dstt (const unsigned int *, int, const int);
13942 void vec_dstt (const int *, int, const int);
13943 void vec_dstt (const unsigned long *, int, const int);
13944 void vec_dstt (const long *, int, const int);
13945 void vec_dstt (const float *, int, const int);
13946
13947 vector float vec_expte (vector float);
13948
13949 vector float vec_floor (vector float);
13950
13951 vector float vec_ld (int, const vector float *);
13952 vector float vec_ld (int, const float *);
13953 vector bool int vec_ld (int, const vector bool int *);
13954 vector signed int vec_ld (int, const vector signed int *);
13955 vector signed int vec_ld (int, const int *);
13956 vector signed int vec_ld (int, const long *);
13957 vector unsigned int vec_ld (int, const vector unsigned int *);
13958 vector unsigned int vec_ld (int, const unsigned int *);
13959 vector unsigned int vec_ld (int, const unsigned long *);
13960 vector bool short vec_ld (int, const vector bool short *);
13961 vector pixel vec_ld (int, const vector pixel *);
13962 vector signed short vec_ld (int, const vector signed short *);
13963 vector signed short vec_ld (int, const short *);
13964 vector unsigned short vec_ld (int, const vector unsigned short *);
13965 vector unsigned short vec_ld (int, const unsigned short *);
13966 vector bool char vec_ld (int, const vector bool char *);
13967 vector signed char vec_ld (int, const vector signed char *);
13968 vector signed char vec_ld (int, const signed char *);
13969 vector unsigned char vec_ld (int, const vector unsigned char *);
13970 vector unsigned char vec_ld (int, const unsigned char *);
13971
13972 vector signed char vec_lde (int, const signed char *);
13973 vector unsigned char vec_lde (int, const unsigned char *);
13974 vector signed short vec_lde (int, const short *);
13975 vector unsigned short vec_lde (int, const unsigned short *);
13976 vector float vec_lde (int, const float *);
13977 vector signed int vec_lde (int, const int *);
13978 vector unsigned int vec_lde (int, const unsigned int *);
13979 vector signed int vec_lde (int, const long *);
13980 vector unsigned int vec_lde (int, const unsigned long *);
13981
13982 vector float vec_lvewx (int, float *);
13983 vector signed int vec_lvewx (int, int *);
13984 vector unsigned int vec_lvewx (int, unsigned int *);
13985 vector signed int vec_lvewx (int, long *);
13986 vector unsigned int vec_lvewx (int, unsigned long *);
13987
13988 vector signed short vec_lvehx (int, short *);
13989 vector unsigned short vec_lvehx (int, unsigned short *);
13990
13991 vector signed char vec_lvebx (int, char *);
13992 vector unsigned char vec_lvebx (int, unsigned char *);
13993
13994 vector float vec_ldl (int, const vector float *);
13995 vector float vec_ldl (int, const float *);
13996 vector bool int vec_ldl (int, const vector bool int *);
13997 vector signed int vec_ldl (int, const vector signed int *);
13998 vector signed int vec_ldl (int, const int *);
13999 vector signed int vec_ldl (int, const long *);
14000 vector unsigned int vec_ldl (int, const vector unsigned int *);
14001 vector unsigned int vec_ldl (int, const unsigned int *);
14002 vector unsigned int vec_ldl (int, const unsigned long *);
14003 vector bool short vec_ldl (int, const vector bool short *);
14004 vector pixel vec_ldl (int, const vector pixel *);
14005 vector signed short vec_ldl (int, const vector signed short *);
14006 vector signed short vec_ldl (int, const short *);
14007 vector unsigned short vec_ldl (int, const vector unsigned short *);
14008 vector unsigned short vec_ldl (int, const unsigned short *);
14009 vector bool char vec_ldl (int, const vector bool char *);
14010 vector signed char vec_ldl (int, const vector signed char *);
14011 vector signed char vec_ldl (int, const signed char *);
14012 vector unsigned char vec_ldl (int, const vector unsigned char *);
14013 vector unsigned char vec_ldl (int, const unsigned char *);
14014
14015 vector float vec_loge (vector float);
14016
14017 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14018 vector unsigned char vec_lvsl (int, const volatile signed char *);
14019 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14020 vector unsigned char vec_lvsl (int, const volatile short *);
14021 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14022 vector unsigned char vec_lvsl (int, const volatile int *);
14023 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14024 vector unsigned char vec_lvsl (int, const volatile long *);
14025 vector unsigned char vec_lvsl (int, const volatile float *);
14026
14027 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14028 vector unsigned char vec_lvsr (int, const volatile signed char *);
14029 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14030 vector unsigned char vec_lvsr (int, const volatile short *);
14031 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14032 vector unsigned char vec_lvsr (int, const volatile int *);
14033 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14034 vector unsigned char vec_lvsr (int, const volatile long *);
14035 vector unsigned char vec_lvsr (int, const volatile float *);
14036
14037 vector float vec_madd (vector float, vector float, vector float);
14038
14039 vector signed short vec_madds (vector signed short,
14040 vector signed short,
14041 vector signed short);
14042
14043 vector unsigned char vec_max (vector bool char, vector unsigned char);
14044 vector unsigned char vec_max (vector unsigned char, vector bool char);
14045 vector unsigned char vec_max (vector unsigned char,
14046 vector unsigned char);
14047 vector signed char vec_max (vector bool char, vector signed char);
14048 vector signed char vec_max (vector signed char, vector bool char);
14049 vector signed char vec_max (vector signed char, vector signed char);
14050 vector unsigned short vec_max (vector bool short,
14051 vector unsigned short);
14052 vector unsigned short vec_max (vector unsigned short,
14053 vector bool short);
14054 vector unsigned short vec_max (vector unsigned short,
14055 vector unsigned short);
14056 vector signed short vec_max (vector bool short, vector signed short);
14057 vector signed short vec_max (vector signed short, vector bool short);
14058 vector signed short vec_max (vector signed short, vector signed short);
14059 vector unsigned int vec_max (vector bool int, vector unsigned int);
14060 vector unsigned int vec_max (vector unsigned int, vector bool int);
14061 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14062 vector signed int vec_max (vector bool int, vector signed int);
14063 vector signed int vec_max (vector signed int, vector bool int);
14064 vector signed int vec_max (vector signed int, vector signed int);
14065 vector float vec_max (vector float, vector float);
14066
14067 vector float vec_vmaxfp (vector float, vector float);
14068
14069 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14070 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14071 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14072
14073 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14074 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14075 vector unsigned int vec_vmaxuw (vector unsigned int,
14076 vector unsigned int);
14077
14078 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14079 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14080 vector signed short vec_vmaxsh (vector signed short,
14081 vector signed short);
14082
14083 vector unsigned short vec_vmaxuh (vector bool short,
14084 vector unsigned short);
14085 vector unsigned short vec_vmaxuh (vector unsigned short,
14086 vector bool short);
14087 vector unsigned short vec_vmaxuh (vector unsigned short,
14088 vector unsigned short);
14089
14090 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14091 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14092 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14093
14094 vector unsigned char vec_vmaxub (vector bool char,
14095 vector unsigned char);
14096 vector unsigned char vec_vmaxub (vector unsigned char,
14097 vector bool char);
14098 vector unsigned char vec_vmaxub (vector unsigned char,
14099 vector unsigned char);
14100
14101 vector bool char vec_mergeh (vector bool char, vector bool char);
14102 vector signed char vec_mergeh (vector signed char, vector signed char);
14103 vector unsigned char vec_mergeh (vector unsigned char,
14104 vector unsigned char);
14105 vector bool short vec_mergeh (vector bool short, vector bool short);
14106 vector pixel vec_mergeh (vector pixel, vector pixel);
14107 vector signed short vec_mergeh (vector signed short,
14108 vector signed short);
14109 vector unsigned short vec_mergeh (vector unsigned short,
14110 vector unsigned short);
14111 vector float vec_mergeh (vector float, vector float);
14112 vector bool int vec_mergeh (vector bool int, vector bool int);
14113 vector signed int vec_mergeh (vector signed int, vector signed int);
14114 vector unsigned int vec_mergeh (vector unsigned int,
14115 vector unsigned int);
14116
14117 vector float vec_vmrghw (vector float, vector float);
14118 vector bool int vec_vmrghw (vector bool int, vector bool int);
14119 vector signed int vec_vmrghw (vector signed int, vector signed int);
14120 vector unsigned int vec_vmrghw (vector unsigned int,
14121 vector unsigned int);
14122
14123 vector bool short vec_vmrghh (vector bool short, vector bool short);
14124 vector signed short vec_vmrghh (vector signed short,
14125 vector signed short);
14126 vector unsigned short vec_vmrghh (vector unsigned short,
14127 vector unsigned short);
14128 vector pixel vec_vmrghh (vector pixel, vector pixel);
14129
14130 vector bool char vec_vmrghb (vector bool char, vector bool char);
14131 vector signed char vec_vmrghb (vector signed char, vector signed char);
14132 vector unsigned char vec_vmrghb (vector unsigned char,
14133 vector unsigned char);
14134
14135 vector bool char vec_mergel (vector bool char, vector bool char);
14136 vector signed char vec_mergel (vector signed char, vector signed char);
14137 vector unsigned char vec_mergel (vector unsigned char,
14138 vector unsigned char);
14139 vector bool short vec_mergel (vector bool short, vector bool short);
14140 vector pixel vec_mergel (vector pixel, vector pixel);
14141 vector signed short vec_mergel (vector signed short,
14142 vector signed short);
14143 vector unsigned short vec_mergel (vector unsigned short,
14144 vector unsigned short);
14145 vector float vec_mergel (vector float, vector float);
14146 vector bool int vec_mergel (vector bool int, vector bool int);
14147 vector signed int vec_mergel (vector signed int, vector signed int);
14148 vector unsigned int vec_mergel (vector unsigned int,
14149 vector unsigned int);
14150
14151 vector float vec_vmrglw (vector float, vector float);
14152 vector signed int vec_vmrglw (vector signed int, vector signed int);
14153 vector unsigned int vec_vmrglw (vector unsigned int,
14154 vector unsigned int);
14155 vector bool int vec_vmrglw (vector bool int, vector bool int);
14156
14157 vector bool short vec_vmrglh (vector bool short, vector bool short);
14158 vector signed short vec_vmrglh (vector signed short,
14159 vector signed short);
14160 vector unsigned short vec_vmrglh (vector unsigned short,
14161 vector unsigned short);
14162 vector pixel vec_vmrglh (vector pixel, vector pixel);
14163
14164 vector bool char vec_vmrglb (vector bool char, vector bool char);
14165 vector signed char vec_vmrglb (vector signed char, vector signed char);
14166 vector unsigned char vec_vmrglb (vector unsigned char,
14167 vector unsigned char);
14168
14169 vector unsigned short vec_mfvscr (void);
14170
14171 vector unsigned char vec_min (vector bool char, vector unsigned char);
14172 vector unsigned char vec_min (vector unsigned char, vector bool char);
14173 vector unsigned char vec_min (vector unsigned char,
14174 vector unsigned char);
14175 vector signed char vec_min (vector bool char, vector signed char);
14176 vector signed char vec_min (vector signed char, vector bool char);
14177 vector signed char vec_min (vector signed char, vector signed char);
14178 vector unsigned short vec_min (vector bool short,
14179 vector unsigned short);
14180 vector unsigned short vec_min (vector unsigned short,
14181 vector bool short);
14182 vector unsigned short vec_min (vector unsigned short,
14183 vector unsigned short);
14184 vector signed short vec_min (vector bool short, vector signed short);
14185 vector signed short vec_min (vector signed short, vector bool short);
14186 vector signed short vec_min (vector signed short, vector signed short);
14187 vector unsigned int vec_min (vector bool int, vector unsigned int);
14188 vector unsigned int vec_min (vector unsigned int, vector bool int);
14189 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14190 vector signed int vec_min (vector bool int, vector signed int);
14191 vector signed int vec_min (vector signed int, vector bool int);
14192 vector signed int vec_min (vector signed int, vector signed int);
14193 vector float vec_min (vector float, vector float);
14194
14195 vector float vec_vminfp (vector float, vector float);
14196
14197 vector signed int vec_vminsw (vector bool int, vector signed int);
14198 vector signed int vec_vminsw (vector signed int, vector bool int);
14199 vector signed int vec_vminsw (vector signed int, vector signed int);
14200
14201 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14202 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14203 vector unsigned int vec_vminuw (vector unsigned int,
14204 vector unsigned int);
14205
14206 vector signed short vec_vminsh (vector bool short, vector signed short);
14207 vector signed short vec_vminsh (vector signed short, vector bool short);
14208 vector signed short vec_vminsh (vector signed short,
14209 vector signed short);
14210
14211 vector unsigned short vec_vminuh (vector bool short,
14212 vector unsigned short);
14213 vector unsigned short vec_vminuh (vector unsigned short,
14214 vector bool short);
14215 vector unsigned short vec_vminuh (vector unsigned short,
14216 vector unsigned short);
14217
14218 vector signed char vec_vminsb (vector bool char, vector signed char);
14219 vector signed char vec_vminsb (vector signed char, vector bool char);
14220 vector signed char vec_vminsb (vector signed char, vector signed char);
14221
14222 vector unsigned char vec_vminub (vector bool char,
14223 vector unsigned char);
14224 vector unsigned char vec_vminub (vector unsigned char,
14225 vector bool char);
14226 vector unsigned char vec_vminub (vector unsigned char,
14227 vector unsigned char);
14228
14229 vector signed short vec_mladd (vector signed short,
14230 vector signed short,
14231 vector signed short);
14232 vector signed short vec_mladd (vector signed short,
14233 vector unsigned short,
14234 vector unsigned short);
14235 vector signed short vec_mladd (vector unsigned short,
14236 vector signed short,
14237 vector signed short);
14238 vector unsigned short vec_mladd (vector unsigned short,
14239 vector unsigned short,
14240 vector unsigned short);
14241
14242 vector signed short vec_mradds (vector signed short,
14243 vector signed short,
14244 vector signed short);
14245
14246 vector unsigned int vec_msum (vector unsigned char,
14247 vector unsigned char,
14248 vector unsigned int);
14249 vector signed int vec_msum (vector signed char,
14250 vector unsigned char,
14251 vector signed int);
14252 vector unsigned int vec_msum (vector unsigned short,
14253 vector unsigned short,
14254 vector unsigned int);
14255 vector signed int vec_msum (vector signed short,
14256 vector signed short,
14257 vector signed int);
14258
14259 vector signed int vec_vmsumshm (vector signed short,
14260 vector signed short,
14261 vector signed int);
14262
14263 vector unsigned int vec_vmsumuhm (vector unsigned short,
14264 vector unsigned short,
14265 vector unsigned int);
14266
14267 vector signed int vec_vmsummbm (vector signed char,
14268 vector unsigned char,
14269 vector signed int);
14270
14271 vector unsigned int vec_vmsumubm (vector unsigned char,
14272 vector unsigned char,
14273 vector unsigned int);
14274
14275 vector unsigned int vec_msums (vector unsigned short,
14276 vector unsigned short,
14277 vector unsigned int);
14278 vector signed int vec_msums (vector signed short,
14279 vector signed short,
14280 vector signed int);
14281
14282 vector signed int vec_vmsumshs (vector signed short,
14283 vector signed short,
14284 vector signed int);
14285
14286 vector unsigned int vec_vmsumuhs (vector unsigned short,
14287 vector unsigned short,
14288 vector unsigned int);
14289
14290 void vec_mtvscr (vector signed int);
14291 void vec_mtvscr (vector unsigned int);
14292 void vec_mtvscr (vector bool int);
14293 void vec_mtvscr (vector signed short);
14294 void vec_mtvscr (vector unsigned short);
14295 void vec_mtvscr (vector bool short);
14296 void vec_mtvscr (vector pixel);
14297 void vec_mtvscr (vector signed char);
14298 void vec_mtvscr (vector unsigned char);
14299 void vec_mtvscr (vector bool char);
14300
14301 vector unsigned short vec_mule (vector unsigned char,
14302 vector unsigned char);
14303 vector signed short vec_mule (vector signed char,
14304 vector signed char);
14305 vector unsigned int vec_mule (vector unsigned short,
14306 vector unsigned short);
14307 vector signed int vec_mule (vector signed short, vector signed short);
14308
14309 vector signed int vec_vmulesh (vector signed short,
14310 vector signed short);
14311
14312 vector unsigned int vec_vmuleuh (vector unsigned short,
14313 vector unsigned short);
14314
14315 vector signed short vec_vmulesb (vector signed char,
14316 vector signed char);
14317
14318 vector unsigned short vec_vmuleub (vector unsigned char,
14319 vector unsigned char);
14320
14321 vector unsigned short vec_mulo (vector unsigned char,
14322 vector unsigned char);
14323 vector signed short vec_mulo (vector signed char, vector signed char);
14324 vector unsigned int vec_mulo (vector unsigned short,
14325 vector unsigned short);
14326 vector signed int vec_mulo (vector signed short, vector signed short);
14327
14328 vector signed int vec_vmulosh (vector signed short,
14329 vector signed short);
14330
14331 vector unsigned int vec_vmulouh (vector unsigned short,
14332 vector unsigned short);
14333
14334 vector signed short vec_vmulosb (vector signed char,
14335 vector signed char);
14336
14337 vector unsigned short vec_vmuloub (vector unsigned char,
14338 vector unsigned char);
14339
14340 vector float vec_nmsub (vector float, vector float, vector float);
14341
14342 vector float vec_nor (vector float, vector float);
14343 vector signed int vec_nor (vector signed int, vector signed int);
14344 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14345 vector bool int vec_nor (vector bool int, vector bool int);
14346 vector signed short vec_nor (vector signed short, vector signed short);
14347 vector unsigned short vec_nor (vector unsigned short,
14348 vector unsigned short);
14349 vector bool short vec_nor (vector bool short, vector bool short);
14350 vector signed char vec_nor (vector signed char, vector signed char);
14351 vector unsigned char vec_nor (vector unsigned char,
14352 vector unsigned char);
14353 vector bool char vec_nor (vector bool char, vector bool char);
14354
14355 vector float vec_or (vector float, vector float);
14356 vector float vec_or (vector float, vector bool int);
14357 vector float vec_or (vector bool int, vector float);
14358 vector bool int vec_or (vector bool int, vector bool int);
14359 vector signed int vec_or (vector bool int, vector signed int);
14360 vector signed int vec_or (vector signed int, vector bool int);
14361 vector signed int vec_or (vector signed int, vector signed int);
14362 vector unsigned int vec_or (vector bool int, vector unsigned int);
14363 vector unsigned int vec_or (vector unsigned int, vector bool int);
14364 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14365 vector bool short vec_or (vector bool short, vector bool short);
14366 vector signed short vec_or (vector bool short, vector signed short);
14367 vector signed short vec_or (vector signed short, vector bool short);
14368 vector signed short vec_or (vector signed short, vector signed short);
14369 vector unsigned short vec_or (vector bool short, vector unsigned short);
14370 vector unsigned short vec_or (vector unsigned short, vector bool short);
14371 vector unsigned short vec_or (vector unsigned short,
14372 vector unsigned short);
14373 vector signed char vec_or (vector bool char, vector signed char);
14374 vector bool char vec_or (vector bool char, vector bool char);
14375 vector signed char vec_or (vector signed char, vector bool char);
14376 vector signed char vec_or (vector signed char, vector signed char);
14377 vector unsigned char vec_or (vector bool char, vector unsigned char);
14378 vector unsigned char vec_or (vector unsigned char, vector bool char);
14379 vector unsigned char vec_or (vector unsigned char,
14380 vector unsigned char);
14381
14382 vector signed char vec_pack (vector signed short, vector signed short);
14383 vector unsigned char vec_pack (vector unsigned short,
14384 vector unsigned short);
14385 vector bool char vec_pack (vector bool short, vector bool short);
14386 vector signed short vec_pack (vector signed int, vector signed int);
14387 vector unsigned short vec_pack (vector unsigned int,
14388 vector unsigned int);
14389 vector bool short vec_pack (vector bool int, vector bool int);
14390
14391 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14392 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14393 vector unsigned short vec_vpkuwum (vector unsigned int,
14394 vector unsigned int);
14395
14396 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14397 vector signed char vec_vpkuhum (vector signed short,
14398 vector signed short);
14399 vector unsigned char vec_vpkuhum (vector unsigned short,
14400 vector unsigned short);
14401
14402 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14403
14404 vector unsigned char vec_packs (vector unsigned short,
14405 vector unsigned short);
14406 vector signed char vec_packs (vector signed short, vector signed short);
14407 vector unsigned short vec_packs (vector unsigned int,
14408 vector unsigned int);
14409 vector signed short vec_packs (vector signed int, vector signed int);
14410
14411 vector signed short vec_vpkswss (vector signed int, vector signed int);
14412
14413 vector unsigned short vec_vpkuwus (vector unsigned int,
14414 vector unsigned int);
14415
14416 vector signed char vec_vpkshss (vector signed short,
14417 vector signed short);
14418
14419 vector unsigned char vec_vpkuhus (vector unsigned short,
14420 vector unsigned short);
14421
14422 vector unsigned char vec_packsu (vector unsigned short,
14423 vector unsigned short);
14424 vector unsigned char vec_packsu (vector signed short,
14425 vector signed short);
14426 vector unsigned short vec_packsu (vector unsigned int,
14427 vector unsigned int);
14428 vector unsigned short vec_packsu (vector signed int, vector signed int);
14429
14430 vector unsigned short vec_vpkswus (vector signed int,
14431 vector signed int);
14432
14433 vector unsigned char vec_vpkshus (vector signed short,
14434 vector signed short);
14435
14436 vector float vec_perm (vector float,
14437 vector float,
14438 vector unsigned char);
14439 vector signed int vec_perm (vector signed int,
14440 vector signed int,
14441 vector unsigned char);
14442 vector unsigned int vec_perm (vector unsigned int,
14443 vector unsigned int,
14444 vector unsigned char);
14445 vector bool int vec_perm (vector bool int,
14446 vector bool int,
14447 vector unsigned char);
14448 vector signed short vec_perm (vector signed short,
14449 vector signed short,
14450 vector unsigned char);
14451 vector unsigned short vec_perm (vector unsigned short,
14452 vector unsigned short,
14453 vector unsigned char);
14454 vector bool short vec_perm (vector bool short,
14455 vector bool short,
14456 vector unsigned char);
14457 vector pixel vec_perm (vector pixel,
14458 vector pixel,
14459 vector unsigned char);
14460 vector signed char vec_perm (vector signed char,
14461 vector signed char,
14462 vector unsigned char);
14463 vector unsigned char vec_perm (vector unsigned char,
14464 vector unsigned char,
14465 vector unsigned char);
14466 vector bool char vec_perm (vector bool char,
14467 vector bool char,
14468 vector unsigned char);
14469
14470 vector float vec_re (vector float);
14471
14472 vector signed char vec_rl (vector signed char,
14473 vector unsigned char);
14474 vector unsigned char vec_rl (vector unsigned char,
14475 vector unsigned char);
14476 vector signed short vec_rl (vector signed short, vector unsigned short);
14477 vector unsigned short vec_rl (vector unsigned short,
14478 vector unsigned short);
14479 vector signed int vec_rl (vector signed int, vector unsigned int);
14480 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14481
14482 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14483 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14484
14485 vector signed short vec_vrlh (vector signed short,
14486 vector unsigned short);
14487 vector unsigned short vec_vrlh (vector unsigned short,
14488 vector unsigned short);
14489
14490 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14491 vector unsigned char vec_vrlb (vector unsigned char,
14492 vector unsigned char);
14493
14494 vector float vec_round (vector float);
14495
14496 vector float vec_recip (vector float, vector float);
14497
14498 vector float vec_rsqrt (vector float);
14499
14500 vector float vec_rsqrte (vector float);
14501
14502 vector float vec_sel (vector float, vector float, vector bool int);
14503 vector float vec_sel (vector float, vector float, vector unsigned int);
14504 vector signed int vec_sel (vector signed int,
14505 vector signed int,
14506 vector bool int);
14507 vector signed int vec_sel (vector signed int,
14508 vector signed int,
14509 vector unsigned int);
14510 vector unsigned int vec_sel (vector unsigned int,
14511 vector unsigned int,
14512 vector bool int);
14513 vector unsigned int vec_sel (vector unsigned int,
14514 vector unsigned int,
14515 vector unsigned int);
14516 vector bool int vec_sel (vector bool int,
14517 vector bool int,
14518 vector bool int);
14519 vector bool int vec_sel (vector bool int,
14520 vector bool int,
14521 vector unsigned int);
14522 vector signed short vec_sel (vector signed short,
14523 vector signed short,
14524 vector bool short);
14525 vector signed short vec_sel (vector signed short,
14526 vector signed short,
14527 vector unsigned short);
14528 vector unsigned short vec_sel (vector unsigned short,
14529 vector unsigned short,
14530 vector bool short);
14531 vector unsigned short vec_sel (vector unsigned short,
14532 vector unsigned short,
14533 vector unsigned short);
14534 vector bool short vec_sel (vector bool short,
14535 vector bool short,
14536 vector bool short);
14537 vector bool short vec_sel (vector bool short,
14538 vector bool short,
14539 vector unsigned short);
14540 vector signed char vec_sel (vector signed char,
14541 vector signed char,
14542 vector bool char);
14543 vector signed char vec_sel (vector signed char,
14544 vector signed char,
14545 vector unsigned char);
14546 vector unsigned char vec_sel (vector unsigned char,
14547 vector unsigned char,
14548 vector bool char);
14549 vector unsigned char vec_sel (vector unsigned char,
14550 vector unsigned char,
14551 vector unsigned char);
14552 vector bool char vec_sel (vector bool char,
14553 vector bool char,
14554 vector bool char);
14555 vector bool char vec_sel (vector bool char,
14556 vector bool char,
14557 vector unsigned char);
14558
14559 vector signed char vec_sl (vector signed char,
14560 vector unsigned char);
14561 vector unsigned char vec_sl (vector unsigned char,
14562 vector unsigned char);
14563 vector signed short vec_sl (vector signed short, vector unsigned short);
14564 vector unsigned short vec_sl (vector unsigned short,
14565 vector unsigned short);
14566 vector signed int vec_sl (vector signed int, vector unsigned int);
14567 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14568
14569 vector signed int vec_vslw (vector signed int, vector unsigned int);
14570 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14571
14572 vector signed short vec_vslh (vector signed short,
14573 vector unsigned short);
14574 vector unsigned short vec_vslh (vector unsigned short,
14575 vector unsigned short);
14576
14577 vector signed char vec_vslb (vector signed char, vector unsigned char);
14578 vector unsigned char vec_vslb (vector unsigned char,
14579 vector unsigned char);
14580
14581 vector float vec_sld (vector float, vector float, const int);
14582 vector signed int vec_sld (vector signed int,
14583 vector signed int,
14584 const int);
14585 vector unsigned int vec_sld (vector unsigned int,
14586 vector unsigned int,
14587 const int);
14588 vector bool int vec_sld (vector bool int,
14589 vector bool int,
14590 const int);
14591 vector signed short vec_sld (vector signed short,
14592 vector signed short,
14593 const int);
14594 vector unsigned short vec_sld (vector unsigned short,
14595 vector unsigned short,
14596 const int);
14597 vector bool short vec_sld (vector bool short,
14598 vector bool short,
14599 const int);
14600 vector pixel vec_sld (vector pixel,
14601 vector pixel,
14602 const int);
14603 vector signed char vec_sld (vector signed char,
14604 vector signed char,
14605 const int);
14606 vector unsigned char vec_sld (vector unsigned char,
14607 vector unsigned char,
14608 const int);
14609 vector bool char vec_sld (vector bool char,
14610 vector bool char,
14611 const int);
14612
14613 vector signed int vec_sll (vector signed int,
14614 vector unsigned int);
14615 vector signed int vec_sll (vector signed int,
14616 vector unsigned short);
14617 vector signed int vec_sll (vector signed int,
14618 vector unsigned char);
14619 vector unsigned int vec_sll (vector unsigned int,
14620 vector unsigned int);
14621 vector unsigned int vec_sll (vector unsigned int,
14622 vector unsigned short);
14623 vector unsigned int vec_sll (vector unsigned int,
14624 vector unsigned char);
14625 vector bool int vec_sll (vector bool int,
14626 vector unsigned int);
14627 vector bool int vec_sll (vector bool int,
14628 vector unsigned short);
14629 vector bool int vec_sll (vector bool int,
14630 vector unsigned char);
14631 vector signed short vec_sll (vector signed short,
14632 vector unsigned int);
14633 vector signed short vec_sll (vector signed short,
14634 vector unsigned short);
14635 vector signed short vec_sll (vector signed short,
14636 vector unsigned char);
14637 vector unsigned short vec_sll (vector unsigned short,
14638 vector unsigned int);
14639 vector unsigned short vec_sll (vector unsigned short,
14640 vector unsigned short);
14641 vector unsigned short vec_sll (vector unsigned short,
14642 vector unsigned char);
14643 vector bool short vec_sll (vector bool short, vector unsigned int);
14644 vector bool short vec_sll (vector bool short, vector unsigned short);
14645 vector bool short vec_sll (vector bool short, vector unsigned char);
14646 vector pixel vec_sll (vector pixel, vector unsigned int);
14647 vector pixel vec_sll (vector pixel, vector unsigned short);
14648 vector pixel vec_sll (vector pixel, vector unsigned char);
14649 vector signed char vec_sll (vector signed char, vector unsigned int);
14650 vector signed char vec_sll (vector signed char, vector unsigned short);
14651 vector signed char vec_sll (vector signed char, vector unsigned char);
14652 vector unsigned char vec_sll (vector unsigned char,
14653 vector unsigned int);
14654 vector unsigned char vec_sll (vector unsigned char,
14655 vector unsigned short);
14656 vector unsigned char vec_sll (vector unsigned char,
14657 vector unsigned char);
14658 vector bool char vec_sll (vector bool char, vector unsigned int);
14659 vector bool char vec_sll (vector bool char, vector unsigned short);
14660 vector bool char vec_sll (vector bool char, vector unsigned char);
14661
14662 vector float vec_slo (vector float, vector signed char);
14663 vector float vec_slo (vector float, vector unsigned char);
14664 vector signed int vec_slo (vector signed int, vector signed char);
14665 vector signed int vec_slo (vector signed int, vector unsigned char);
14666 vector unsigned int vec_slo (vector unsigned int, vector signed char);
14667 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
14668 vector signed short vec_slo (vector signed short, vector signed char);
14669 vector signed short vec_slo (vector signed short, vector unsigned char);
14670 vector unsigned short vec_slo (vector unsigned short,
14671 vector signed char);
14672 vector unsigned short vec_slo (vector unsigned short,
14673 vector unsigned char);
14674 vector pixel vec_slo (vector pixel, vector signed char);
14675 vector pixel vec_slo (vector pixel, vector unsigned char);
14676 vector signed char vec_slo (vector signed char, vector signed char);
14677 vector signed char vec_slo (vector signed char, vector unsigned char);
14678 vector unsigned char vec_slo (vector unsigned char, vector signed char);
14679 vector unsigned char vec_slo (vector unsigned char,
14680 vector unsigned char);
14681
14682 vector signed char vec_splat (vector signed char, const int);
14683 vector unsigned char vec_splat (vector unsigned char, const int);
14684 vector bool char vec_splat (vector bool char, const int);
14685 vector signed short vec_splat (vector signed short, const int);
14686 vector unsigned short vec_splat (vector unsigned short, const int);
14687 vector bool short vec_splat (vector bool short, const int);
14688 vector pixel vec_splat (vector pixel, const int);
14689 vector float vec_splat (vector float, const int);
14690 vector signed int vec_splat (vector signed int, const int);
14691 vector unsigned int vec_splat (vector unsigned int, const int);
14692 vector bool int vec_splat (vector bool int, const int);
14693
14694 vector float vec_vspltw (vector float, const int);
14695 vector signed int vec_vspltw (vector signed int, const int);
14696 vector unsigned int vec_vspltw (vector unsigned int, const int);
14697 vector bool int vec_vspltw (vector bool int, const int);
14698
14699 vector bool short vec_vsplth (vector bool short, const int);
14700 vector signed short vec_vsplth (vector signed short, const int);
14701 vector unsigned short vec_vsplth (vector unsigned short, const int);
14702 vector pixel vec_vsplth (vector pixel, const int);
14703
14704 vector signed char vec_vspltb (vector signed char, const int);
14705 vector unsigned char vec_vspltb (vector unsigned char, const int);
14706 vector bool char vec_vspltb (vector bool char, const int);
14707
14708 vector signed char vec_splat_s8 (const int);
14709
14710 vector signed short vec_splat_s16 (const int);
14711
14712 vector signed int vec_splat_s32 (const int);
14713
14714 vector unsigned char vec_splat_u8 (const int);
14715
14716 vector unsigned short vec_splat_u16 (const int);
14717
14718 vector unsigned int vec_splat_u32 (const int);
14719
14720 vector signed char vec_sr (vector signed char, vector unsigned char);
14721 vector unsigned char vec_sr (vector unsigned char,
14722 vector unsigned char);
14723 vector signed short vec_sr (vector signed short,
14724 vector unsigned short);
14725 vector unsigned short vec_sr (vector unsigned short,
14726 vector unsigned short);
14727 vector signed int vec_sr (vector signed int, vector unsigned int);
14728 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
14729
14730 vector signed int vec_vsrw (vector signed int, vector unsigned int);
14731 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
14732
14733 vector signed short vec_vsrh (vector signed short,
14734 vector unsigned short);
14735 vector unsigned short vec_vsrh (vector unsigned short,
14736 vector unsigned short);
14737
14738 vector signed char vec_vsrb (vector signed char, vector unsigned char);
14739 vector unsigned char vec_vsrb (vector unsigned char,
14740 vector unsigned char);
14741
14742 vector signed char vec_sra (vector signed char, vector unsigned char);
14743 vector unsigned char vec_sra (vector unsigned char,
14744 vector unsigned char);
14745 vector signed short vec_sra (vector signed short,
14746 vector unsigned short);
14747 vector unsigned short vec_sra (vector unsigned short,
14748 vector unsigned short);
14749 vector signed int vec_sra (vector signed int, vector unsigned int);
14750 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
14751
14752 vector signed int vec_vsraw (vector signed int, vector unsigned int);
14753 vector unsigned int vec_vsraw (vector unsigned int,
14754 vector unsigned int);
14755
14756 vector signed short vec_vsrah (vector signed short,
14757 vector unsigned short);
14758 vector unsigned short vec_vsrah (vector unsigned short,
14759 vector unsigned short);
14760
14761 vector signed char vec_vsrab (vector signed char, vector unsigned char);
14762 vector unsigned char vec_vsrab (vector unsigned char,
14763 vector unsigned char);
14764
14765 vector signed int vec_srl (vector signed int, vector unsigned int);
14766 vector signed int vec_srl (vector signed int, vector unsigned short);
14767 vector signed int vec_srl (vector signed int, vector unsigned char);
14768 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
14769 vector unsigned int vec_srl (vector unsigned int,
14770 vector unsigned short);
14771 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
14772 vector bool int vec_srl (vector bool int, vector unsigned int);
14773 vector bool int vec_srl (vector bool int, vector unsigned short);
14774 vector bool int vec_srl (vector bool int, vector unsigned char);
14775 vector signed short vec_srl (vector signed short, vector unsigned int);
14776 vector signed short vec_srl (vector signed short,
14777 vector unsigned short);
14778 vector signed short vec_srl (vector signed short, vector unsigned char);
14779 vector unsigned short vec_srl (vector unsigned short,
14780 vector unsigned int);
14781 vector unsigned short vec_srl (vector unsigned short,
14782 vector unsigned short);
14783 vector unsigned short vec_srl (vector unsigned short,
14784 vector unsigned char);
14785 vector bool short vec_srl (vector bool short, vector unsigned int);
14786 vector bool short vec_srl (vector bool short, vector unsigned short);
14787 vector bool short vec_srl (vector bool short, vector unsigned char);
14788 vector pixel vec_srl (vector pixel, vector unsigned int);
14789 vector pixel vec_srl (vector pixel, vector unsigned short);
14790 vector pixel vec_srl (vector pixel, vector unsigned char);
14791 vector signed char vec_srl (vector signed char, vector unsigned int);
14792 vector signed char vec_srl (vector signed char, vector unsigned short);
14793 vector signed char vec_srl (vector signed char, vector unsigned char);
14794 vector unsigned char vec_srl (vector unsigned char,
14795 vector unsigned int);
14796 vector unsigned char vec_srl (vector unsigned char,
14797 vector unsigned short);
14798 vector unsigned char vec_srl (vector unsigned char,
14799 vector unsigned char);
14800 vector bool char vec_srl (vector bool char, vector unsigned int);
14801 vector bool char vec_srl (vector bool char, vector unsigned short);
14802 vector bool char vec_srl (vector bool char, vector unsigned char);
14803
14804 vector float vec_sro (vector float, vector signed char);
14805 vector float vec_sro (vector float, vector unsigned char);
14806 vector signed int vec_sro (vector signed int, vector signed char);
14807 vector signed int vec_sro (vector signed int, vector unsigned char);
14808 vector unsigned int vec_sro (vector unsigned int, vector signed char);
14809 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
14810 vector signed short vec_sro (vector signed short, vector signed char);
14811 vector signed short vec_sro (vector signed short, vector unsigned char);
14812 vector unsigned short vec_sro (vector unsigned short,
14813 vector signed char);
14814 vector unsigned short vec_sro (vector unsigned short,
14815 vector unsigned char);
14816 vector pixel vec_sro (vector pixel, vector signed char);
14817 vector pixel vec_sro (vector pixel, vector unsigned char);
14818 vector signed char vec_sro (vector signed char, vector signed char);
14819 vector signed char vec_sro (vector signed char, vector unsigned char);
14820 vector unsigned char vec_sro (vector unsigned char, vector signed char);
14821 vector unsigned char vec_sro (vector unsigned char,
14822 vector unsigned char);
14823
14824 void vec_st (vector float, int, vector float *);
14825 void vec_st (vector float, int, float *);
14826 void vec_st (vector signed int, int, vector signed int *);
14827 void vec_st (vector signed int, int, int *);
14828 void vec_st (vector unsigned int, int, vector unsigned int *);
14829 void vec_st (vector unsigned int, int, unsigned int *);
14830 void vec_st (vector bool int, int, vector bool int *);
14831 void vec_st (vector bool int, int, unsigned int *);
14832 void vec_st (vector bool int, int, int *);
14833 void vec_st (vector signed short, int, vector signed short *);
14834 void vec_st (vector signed short, int, short *);
14835 void vec_st (vector unsigned short, int, vector unsigned short *);
14836 void vec_st (vector unsigned short, int, unsigned short *);
14837 void vec_st (vector bool short, int, vector bool short *);
14838 void vec_st (vector bool short, int, unsigned short *);
14839 void vec_st (vector pixel, int, vector pixel *);
14840 void vec_st (vector pixel, int, unsigned short *);
14841 void vec_st (vector pixel, int, short *);
14842 void vec_st (vector bool short, int, short *);
14843 void vec_st (vector signed char, int, vector signed char *);
14844 void vec_st (vector signed char, int, signed char *);
14845 void vec_st (vector unsigned char, int, vector unsigned char *);
14846 void vec_st (vector unsigned char, int, unsigned char *);
14847 void vec_st (vector bool char, int, vector bool char *);
14848 void vec_st (vector bool char, int, unsigned char *);
14849 void vec_st (vector bool char, int, signed char *);
14850
14851 void vec_ste (vector signed char, int, signed char *);
14852 void vec_ste (vector unsigned char, int, unsigned char *);
14853 void vec_ste (vector bool char, int, signed char *);
14854 void vec_ste (vector bool char, int, unsigned char *);
14855 void vec_ste (vector signed short, int, short *);
14856 void vec_ste (vector unsigned short, int, unsigned short *);
14857 void vec_ste (vector bool short, int, short *);
14858 void vec_ste (vector bool short, int, unsigned short *);
14859 void vec_ste (vector pixel, int, short *);
14860 void vec_ste (vector pixel, int, unsigned short *);
14861 void vec_ste (vector float, int, float *);
14862 void vec_ste (vector signed int, int, int *);
14863 void vec_ste (vector unsigned int, int, unsigned int *);
14864 void vec_ste (vector bool int, int, int *);
14865 void vec_ste (vector bool int, int, unsigned int *);
14866
14867 void vec_stvewx (vector float, int, float *);
14868 void vec_stvewx (vector signed int, int, int *);
14869 void vec_stvewx (vector unsigned int, int, unsigned int *);
14870 void vec_stvewx (vector bool int, int, int *);
14871 void vec_stvewx (vector bool int, int, unsigned int *);
14872
14873 void vec_stvehx (vector signed short, int, short *);
14874 void vec_stvehx (vector unsigned short, int, unsigned short *);
14875 void vec_stvehx (vector bool short, int, short *);
14876 void vec_stvehx (vector bool short, int, unsigned short *);
14877 void vec_stvehx (vector pixel, int, short *);
14878 void vec_stvehx (vector pixel, int, unsigned short *);
14879
14880 void vec_stvebx (vector signed char, int, signed char *);
14881 void vec_stvebx (vector unsigned char, int, unsigned char *);
14882 void vec_stvebx (vector bool char, int, signed char *);
14883 void vec_stvebx (vector bool char, int, unsigned char *);
14884
14885 void vec_stl (vector float, int, vector float *);
14886 void vec_stl (vector float, int, float *);
14887 void vec_stl (vector signed int, int, vector signed int *);
14888 void vec_stl (vector signed int, int, int *);
14889 void vec_stl (vector unsigned int, int, vector unsigned int *);
14890 void vec_stl (vector unsigned int, int, unsigned int *);
14891 void vec_stl (vector bool int, int, vector bool int *);
14892 void vec_stl (vector bool int, int, unsigned int *);
14893 void vec_stl (vector bool int, int, int *);
14894 void vec_stl (vector signed short, int, vector signed short *);
14895 void vec_stl (vector signed short, int, short *);
14896 void vec_stl (vector unsigned short, int, vector unsigned short *);
14897 void vec_stl (vector unsigned short, int, unsigned short *);
14898 void vec_stl (vector bool short, int, vector bool short *);
14899 void vec_stl (vector bool short, int, unsigned short *);
14900 void vec_stl (vector bool short, int, short *);
14901 void vec_stl (vector pixel, int, vector pixel *);
14902 void vec_stl (vector pixel, int, unsigned short *);
14903 void vec_stl (vector pixel, int, short *);
14904 void vec_stl (vector signed char, int, vector signed char *);
14905 void vec_stl (vector signed char, int, signed char *);
14906 void vec_stl (vector unsigned char, int, vector unsigned char *);
14907 void vec_stl (vector unsigned char, int, unsigned char *);
14908 void vec_stl (vector bool char, int, vector bool char *);
14909 void vec_stl (vector bool char, int, unsigned char *);
14910 void vec_stl (vector bool char, int, signed char *);
14911
14912 vector signed char vec_sub (vector bool char, vector signed char);
14913 vector signed char vec_sub (vector signed char, vector bool char);
14914 vector signed char vec_sub (vector signed char, vector signed char);
14915 vector unsigned char vec_sub (vector bool char, vector unsigned char);
14916 vector unsigned char vec_sub (vector unsigned char, vector bool char);
14917 vector unsigned char vec_sub (vector unsigned char,
14918 vector unsigned char);
14919 vector signed short vec_sub (vector bool short, vector signed short);
14920 vector signed short vec_sub (vector signed short, vector bool short);
14921 vector signed short vec_sub (vector signed short, vector signed short);
14922 vector unsigned short vec_sub (vector bool short,
14923 vector unsigned short);
14924 vector unsigned short vec_sub (vector unsigned short,
14925 vector bool short);
14926 vector unsigned short vec_sub (vector unsigned short,
14927 vector unsigned short);
14928 vector signed int vec_sub (vector bool int, vector signed int);
14929 vector signed int vec_sub (vector signed int, vector bool int);
14930 vector signed int vec_sub (vector signed int, vector signed int);
14931 vector unsigned int vec_sub (vector bool int, vector unsigned int);
14932 vector unsigned int vec_sub (vector unsigned int, vector bool int);
14933 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
14934 vector float vec_sub (vector float, vector float);
14935
14936 vector float vec_vsubfp (vector float, vector float);
14937
14938 vector signed int vec_vsubuwm (vector bool int, vector signed int);
14939 vector signed int vec_vsubuwm (vector signed int, vector bool int);
14940 vector signed int vec_vsubuwm (vector signed int, vector signed int);
14941 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
14942 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
14943 vector unsigned int vec_vsubuwm (vector unsigned int,
14944 vector unsigned int);
14945
14946 vector signed short vec_vsubuhm (vector bool short,
14947 vector signed short);
14948 vector signed short vec_vsubuhm (vector signed short,
14949 vector bool short);
14950 vector signed short vec_vsubuhm (vector signed short,
14951 vector signed short);
14952 vector unsigned short vec_vsubuhm (vector bool short,
14953 vector unsigned short);
14954 vector unsigned short vec_vsubuhm (vector unsigned short,
14955 vector bool short);
14956 vector unsigned short vec_vsubuhm (vector unsigned short,
14957 vector unsigned short);
14958
14959 vector signed char vec_vsububm (vector bool char, vector signed char);
14960 vector signed char vec_vsububm (vector signed char, vector bool char);
14961 vector signed char vec_vsububm (vector signed char, vector signed char);
14962 vector unsigned char vec_vsububm (vector bool char,
14963 vector unsigned char);
14964 vector unsigned char vec_vsububm (vector unsigned char,
14965 vector bool char);
14966 vector unsigned char vec_vsububm (vector unsigned char,
14967 vector unsigned char);
14968
14969 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
14970
14971 vector unsigned char vec_subs (vector bool char, vector unsigned char);
14972 vector unsigned char vec_subs (vector unsigned char, vector bool char);
14973 vector unsigned char vec_subs (vector unsigned char,
14974 vector unsigned char);
14975 vector signed char vec_subs (vector bool char, vector signed char);
14976 vector signed char vec_subs (vector signed char, vector bool char);
14977 vector signed char vec_subs (vector signed char, vector signed char);
14978 vector unsigned short vec_subs (vector bool short,
14979 vector unsigned short);
14980 vector unsigned short vec_subs (vector unsigned short,
14981 vector bool short);
14982 vector unsigned short vec_subs (vector unsigned short,
14983 vector unsigned short);
14984 vector signed short vec_subs (vector bool short, vector signed short);
14985 vector signed short vec_subs (vector signed short, vector bool short);
14986 vector signed short vec_subs (vector signed short, vector signed short);
14987 vector unsigned int vec_subs (vector bool int, vector unsigned int);
14988 vector unsigned int vec_subs (vector unsigned int, vector bool int);
14989 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
14990 vector signed int vec_subs (vector bool int, vector signed int);
14991 vector signed int vec_subs (vector signed int, vector bool int);
14992 vector signed int vec_subs (vector signed int, vector signed int);
14993
14994 vector signed int vec_vsubsws (vector bool int, vector signed int);
14995 vector signed int vec_vsubsws (vector signed int, vector bool int);
14996 vector signed int vec_vsubsws (vector signed int, vector signed int);
14997
14998 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
14999 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15000 vector unsigned int vec_vsubuws (vector unsigned int,
15001 vector unsigned int);
15002
15003 vector signed short vec_vsubshs (vector bool short,
15004 vector signed short);
15005 vector signed short vec_vsubshs (vector signed short,
15006 vector bool short);
15007 vector signed short vec_vsubshs (vector signed short,
15008 vector signed short);
15009
15010 vector unsigned short vec_vsubuhs (vector bool short,
15011 vector unsigned short);
15012 vector unsigned short vec_vsubuhs (vector unsigned short,
15013 vector bool short);
15014 vector unsigned short vec_vsubuhs (vector unsigned short,
15015 vector unsigned short);
15016
15017 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15018 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15019 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15020
15021 vector unsigned char vec_vsububs (vector bool char,
15022 vector unsigned char);
15023 vector unsigned char vec_vsububs (vector unsigned char,
15024 vector bool char);
15025 vector unsigned char vec_vsububs (vector unsigned char,
15026 vector unsigned char);
15027
15028 vector unsigned int vec_sum4s (vector unsigned char,
15029 vector unsigned int);
15030 vector signed int vec_sum4s (vector signed char, vector signed int);
15031 vector signed int vec_sum4s (vector signed short, vector signed int);
15032
15033 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15034
15035 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15036
15037 vector unsigned int vec_vsum4ubs (vector unsigned char,
15038 vector unsigned int);
15039
15040 vector signed int vec_sum2s (vector signed int, vector signed int);
15041
15042 vector signed int vec_sums (vector signed int, vector signed int);
15043
15044 vector float vec_trunc (vector float);
15045
15046 vector signed short vec_unpackh (vector signed char);
15047 vector bool short vec_unpackh (vector bool char);
15048 vector signed int vec_unpackh (vector signed short);
15049 vector bool int vec_unpackh (vector bool short);
15050 vector unsigned int vec_unpackh (vector pixel);
15051
15052 vector bool int vec_vupkhsh (vector bool short);
15053 vector signed int vec_vupkhsh (vector signed short);
15054
15055 vector unsigned int vec_vupkhpx (vector pixel);
15056
15057 vector bool short vec_vupkhsb (vector bool char);
15058 vector signed short vec_vupkhsb (vector signed char);
15059
15060 vector signed short vec_unpackl (vector signed char);
15061 vector bool short vec_unpackl (vector bool char);
15062 vector unsigned int vec_unpackl (vector pixel);
15063 vector signed int vec_unpackl (vector signed short);
15064 vector bool int vec_unpackl (vector bool short);
15065
15066 vector unsigned int vec_vupklpx (vector pixel);
15067
15068 vector bool int vec_vupklsh (vector bool short);
15069 vector signed int vec_vupklsh (vector signed short);
15070
15071 vector bool short vec_vupklsb (vector bool char);
15072 vector signed short vec_vupklsb (vector signed char);
15073
15074 vector float vec_xor (vector float, vector float);
15075 vector float vec_xor (vector float, vector bool int);
15076 vector float vec_xor (vector bool int, vector float);
15077 vector bool int vec_xor (vector bool int, vector bool int);
15078 vector signed int vec_xor (vector bool int, vector signed int);
15079 vector signed int vec_xor (vector signed int, vector bool int);
15080 vector signed int vec_xor (vector signed int, vector signed int);
15081 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15082 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15083 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15084 vector bool short vec_xor (vector bool short, vector bool short);
15085 vector signed short vec_xor (vector bool short, vector signed short);
15086 vector signed short vec_xor (vector signed short, vector bool short);
15087 vector signed short vec_xor (vector signed short, vector signed short);
15088 vector unsigned short vec_xor (vector bool short,
15089 vector unsigned short);
15090 vector unsigned short vec_xor (vector unsigned short,
15091 vector bool short);
15092 vector unsigned short vec_xor (vector unsigned short,
15093 vector unsigned short);
15094 vector signed char vec_xor (vector bool char, vector signed char);
15095 vector bool char vec_xor (vector bool char, vector bool char);
15096 vector signed char vec_xor (vector signed char, vector bool char);
15097 vector signed char vec_xor (vector signed char, vector signed char);
15098 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15099 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15100 vector unsigned char vec_xor (vector unsigned char,
15101 vector unsigned char);
15102
15103 int vec_all_eq (vector signed char, vector bool char);
15104 int vec_all_eq (vector signed char, vector signed char);
15105 int vec_all_eq (vector unsigned char, vector bool char);
15106 int vec_all_eq (vector unsigned char, vector unsigned char);
15107 int vec_all_eq (vector bool char, vector bool char);
15108 int vec_all_eq (vector bool char, vector unsigned char);
15109 int vec_all_eq (vector bool char, vector signed char);
15110 int vec_all_eq (vector signed short, vector bool short);
15111 int vec_all_eq (vector signed short, vector signed short);
15112 int vec_all_eq (vector unsigned short, vector bool short);
15113 int vec_all_eq (vector unsigned short, vector unsigned short);
15114 int vec_all_eq (vector bool short, vector bool short);
15115 int vec_all_eq (vector bool short, vector unsigned short);
15116 int vec_all_eq (vector bool short, vector signed short);
15117 int vec_all_eq (vector pixel, vector pixel);
15118 int vec_all_eq (vector signed int, vector bool int);
15119 int vec_all_eq (vector signed int, vector signed int);
15120 int vec_all_eq (vector unsigned int, vector bool int);
15121 int vec_all_eq (vector unsigned int, vector unsigned int);
15122 int vec_all_eq (vector bool int, vector bool int);
15123 int vec_all_eq (vector bool int, vector unsigned int);
15124 int vec_all_eq (vector bool int, vector signed int);
15125 int vec_all_eq (vector float, vector float);
15126
15127 int vec_all_ge (vector bool char, vector unsigned char);
15128 int vec_all_ge (vector unsigned char, vector bool char);
15129 int vec_all_ge (vector unsigned char, vector unsigned char);
15130 int vec_all_ge (vector bool char, vector signed char);
15131 int vec_all_ge (vector signed char, vector bool char);
15132 int vec_all_ge (vector signed char, vector signed char);
15133 int vec_all_ge (vector bool short, vector unsigned short);
15134 int vec_all_ge (vector unsigned short, vector bool short);
15135 int vec_all_ge (vector unsigned short, vector unsigned short);
15136 int vec_all_ge (vector signed short, vector signed short);
15137 int vec_all_ge (vector bool short, vector signed short);
15138 int vec_all_ge (vector signed short, vector bool short);
15139 int vec_all_ge (vector bool int, vector unsigned int);
15140 int vec_all_ge (vector unsigned int, vector bool int);
15141 int vec_all_ge (vector unsigned int, vector unsigned int);
15142 int vec_all_ge (vector bool int, vector signed int);
15143 int vec_all_ge (vector signed int, vector bool int);
15144 int vec_all_ge (vector signed int, vector signed int);
15145 int vec_all_ge (vector float, vector float);
15146
15147 int vec_all_gt (vector bool char, vector unsigned char);
15148 int vec_all_gt (vector unsigned char, vector bool char);
15149 int vec_all_gt (vector unsigned char, vector unsigned char);
15150 int vec_all_gt (vector bool char, vector signed char);
15151 int vec_all_gt (vector signed char, vector bool char);
15152 int vec_all_gt (vector signed char, vector signed char);
15153 int vec_all_gt (vector bool short, vector unsigned short);
15154 int vec_all_gt (vector unsigned short, vector bool short);
15155 int vec_all_gt (vector unsigned short, vector unsigned short);
15156 int vec_all_gt (vector bool short, vector signed short);
15157 int vec_all_gt (vector signed short, vector bool short);
15158 int vec_all_gt (vector signed short, vector signed short);
15159 int vec_all_gt (vector bool int, vector unsigned int);
15160 int vec_all_gt (vector unsigned int, vector bool int);
15161 int vec_all_gt (vector unsigned int, vector unsigned int);
15162 int vec_all_gt (vector bool int, vector signed int);
15163 int vec_all_gt (vector signed int, vector bool int);
15164 int vec_all_gt (vector signed int, vector signed int);
15165 int vec_all_gt (vector float, vector float);
15166
15167 int vec_all_in (vector float, vector float);
15168
15169 int vec_all_le (vector bool char, vector unsigned char);
15170 int vec_all_le (vector unsigned char, vector bool char);
15171 int vec_all_le (vector unsigned char, vector unsigned char);
15172 int vec_all_le (vector bool char, vector signed char);
15173 int vec_all_le (vector signed char, vector bool char);
15174 int vec_all_le (vector signed char, vector signed char);
15175 int vec_all_le (vector bool short, vector unsigned short);
15176 int vec_all_le (vector unsigned short, vector bool short);
15177 int vec_all_le (vector unsigned short, vector unsigned short);
15178 int vec_all_le (vector bool short, vector signed short);
15179 int vec_all_le (vector signed short, vector bool short);
15180 int vec_all_le (vector signed short, vector signed short);
15181 int vec_all_le (vector bool int, vector unsigned int);
15182 int vec_all_le (vector unsigned int, vector bool int);
15183 int vec_all_le (vector unsigned int, vector unsigned int);
15184 int vec_all_le (vector bool int, vector signed int);
15185 int vec_all_le (vector signed int, vector bool int);
15186 int vec_all_le (vector signed int, vector signed int);
15187 int vec_all_le (vector float, vector float);
15188
15189 int vec_all_lt (vector bool char, vector unsigned char);
15190 int vec_all_lt (vector unsigned char, vector bool char);
15191 int vec_all_lt (vector unsigned char, vector unsigned char);
15192 int vec_all_lt (vector bool char, vector signed char);
15193 int vec_all_lt (vector signed char, vector bool char);
15194 int vec_all_lt (vector signed char, vector signed char);
15195 int vec_all_lt (vector bool short, vector unsigned short);
15196 int vec_all_lt (vector unsigned short, vector bool short);
15197 int vec_all_lt (vector unsigned short, vector unsigned short);
15198 int vec_all_lt (vector bool short, vector signed short);
15199 int vec_all_lt (vector signed short, vector bool short);
15200 int vec_all_lt (vector signed short, vector signed short);
15201 int vec_all_lt (vector bool int, vector unsigned int);
15202 int vec_all_lt (vector unsigned int, vector bool int);
15203 int vec_all_lt (vector unsigned int, vector unsigned int);
15204 int vec_all_lt (vector bool int, vector signed int);
15205 int vec_all_lt (vector signed int, vector bool int);
15206 int vec_all_lt (vector signed int, vector signed int);
15207 int vec_all_lt (vector float, vector float);
15208
15209 int vec_all_nan (vector float);
15210
15211 int vec_all_ne (vector signed char, vector bool char);
15212 int vec_all_ne (vector signed char, vector signed char);
15213 int vec_all_ne (vector unsigned char, vector bool char);
15214 int vec_all_ne (vector unsigned char, vector unsigned char);
15215 int vec_all_ne (vector bool char, vector bool char);
15216 int vec_all_ne (vector bool char, vector unsigned char);
15217 int vec_all_ne (vector bool char, vector signed char);
15218 int vec_all_ne (vector signed short, vector bool short);
15219 int vec_all_ne (vector signed short, vector signed short);
15220 int vec_all_ne (vector unsigned short, vector bool short);
15221 int vec_all_ne (vector unsigned short, vector unsigned short);
15222 int vec_all_ne (vector bool short, vector bool short);
15223 int vec_all_ne (vector bool short, vector unsigned short);
15224 int vec_all_ne (vector bool short, vector signed short);
15225 int vec_all_ne (vector pixel, vector pixel);
15226 int vec_all_ne (vector signed int, vector bool int);
15227 int vec_all_ne (vector signed int, vector signed int);
15228 int vec_all_ne (vector unsigned int, vector bool int);
15229 int vec_all_ne (vector unsigned int, vector unsigned int);
15230 int vec_all_ne (vector bool int, vector bool int);
15231 int vec_all_ne (vector bool int, vector unsigned int);
15232 int vec_all_ne (vector bool int, vector signed int);
15233 int vec_all_ne (vector float, vector float);
15234
15235 int vec_all_nge (vector float, vector float);
15236
15237 int vec_all_ngt (vector float, vector float);
15238
15239 int vec_all_nle (vector float, vector float);
15240
15241 int vec_all_nlt (vector float, vector float);
15242
15243 int vec_all_numeric (vector float);
15244
15245 int vec_any_eq (vector signed char, vector bool char);
15246 int vec_any_eq (vector signed char, vector signed char);
15247 int vec_any_eq (vector unsigned char, vector bool char);
15248 int vec_any_eq (vector unsigned char, vector unsigned char);
15249 int vec_any_eq (vector bool char, vector bool char);
15250 int vec_any_eq (vector bool char, vector unsigned char);
15251 int vec_any_eq (vector bool char, vector signed char);
15252 int vec_any_eq (vector signed short, vector bool short);
15253 int vec_any_eq (vector signed short, vector signed short);
15254 int vec_any_eq (vector unsigned short, vector bool short);
15255 int vec_any_eq (vector unsigned short, vector unsigned short);
15256 int vec_any_eq (vector bool short, vector bool short);
15257 int vec_any_eq (vector bool short, vector unsigned short);
15258 int vec_any_eq (vector bool short, vector signed short);
15259 int vec_any_eq (vector pixel, vector pixel);
15260 int vec_any_eq (vector signed int, vector bool int);
15261 int vec_any_eq (vector signed int, vector signed int);
15262 int vec_any_eq (vector unsigned int, vector bool int);
15263 int vec_any_eq (vector unsigned int, vector unsigned int);
15264 int vec_any_eq (vector bool int, vector bool int);
15265 int vec_any_eq (vector bool int, vector unsigned int);
15266 int vec_any_eq (vector bool int, vector signed int);
15267 int vec_any_eq (vector float, vector float);
15268
15269 int vec_any_ge (vector signed char, vector bool char);
15270 int vec_any_ge (vector unsigned char, vector bool char);
15271 int vec_any_ge (vector unsigned char, vector unsigned char);
15272 int vec_any_ge (vector signed char, vector signed char);
15273 int vec_any_ge (vector bool char, vector unsigned char);
15274 int vec_any_ge (vector bool char, vector signed char);
15275 int vec_any_ge (vector unsigned short, vector bool short);
15276 int vec_any_ge (vector unsigned short, vector unsigned short);
15277 int vec_any_ge (vector signed short, vector signed short);
15278 int vec_any_ge (vector signed short, vector bool short);
15279 int vec_any_ge (vector bool short, vector unsigned short);
15280 int vec_any_ge (vector bool short, vector signed short);
15281 int vec_any_ge (vector signed int, vector bool int);
15282 int vec_any_ge (vector unsigned int, vector bool int);
15283 int vec_any_ge (vector unsigned int, vector unsigned int);
15284 int vec_any_ge (vector signed int, vector signed int);
15285 int vec_any_ge (vector bool int, vector unsigned int);
15286 int vec_any_ge (vector bool int, vector signed int);
15287 int vec_any_ge (vector float, vector float);
15288
15289 int vec_any_gt (vector bool char, vector unsigned char);
15290 int vec_any_gt (vector unsigned char, vector bool char);
15291 int vec_any_gt (vector unsigned char, vector unsigned char);
15292 int vec_any_gt (vector bool char, vector signed char);
15293 int vec_any_gt (vector signed char, vector bool char);
15294 int vec_any_gt (vector signed char, vector signed char);
15295 int vec_any_gt (vector bool short, vector unsigned short);
15296 int vec_any_gt (vector unsigned short, vector bool short);
15297 int vec_any_gt (vector unsigned short, vector unsigned short);
15298 int vec_any_gt (vector bool short, vector signed short);
15299 int vec_any_gt (vector signed short, vector bool short);
15300 int vec_any_gt (vector signed short, vector signed short);
15301 int vec_any_gt (vector bool int, vector unsigned int);
15302 int vec_any_gt (vector unsigned int, vector bool int);
15303 int vec_any_gt (vector unsigned int, vector unsigned int);
15304 int vec_any_gt (vector bool int, vector signed int);
15305 int vec_any_gt (vector signed int, vector bool int);
15306 int vec_any_gt (vector signed int, vector signed int);
15307 int vec_any_gt (vector float, vector float);
15308
15309 int vec_any_le (vector bool char, vector unsigned char);
15310 int vec_any_le (vector unsigned char, vector bool char);
15311 int vec_any_le (vector unsigned char, vector unsigned char);
15312 int vec_any_le (vector bool char, vector signed char);
15313 int vec_any_le (vector signed char, vector bool char);
15314 int vec_any_le (vector signed char, vector signed char);
15315 int vec_any_le (vector bool short, vector unsigned short);
15316 int vec_any_le (vector unsigned short, vector bool short);
15317 int vec_any_le (vector unsigned short, vector unsigned short);
15318 int vec_any_le (vector bool short, vector signed short);
15319 int vec_any_le (vector signed short, vector bool short);
15320 int vec_any_le (vector signed short, vector signed short);
15321 int vec_any_le (vector bool int, vector unsigned int);
15322 int vec_any_le (vector unsigned int, vector bool int);
15323 int vec_any_le (vector unsigned int, vector unsigned int);
15324 int vec_any_le (vector bool int, vector signed int);
15325 int vec_any_le (vector signed int, vector bool int);
15326 int vec_any_le (vector signed int, vector signed int);
15327 int vec_any_le (vector float, vector float);
15328
15329 int vec_any_lt (vector bool char, vector unsigned char);
15330 int vec_any_lt (vector unsigned char, vector bool char);
15331 int vec_any_lt (vector unsigned char, vector unsigned char);
15332 int vec_any_lt (vector bool char, vector signed char);
15333 int vec_any_lt (vector signed char, vector bool char);
15334 int vec_any_lt (vector signed char, vector signed char);
15335 int vec_any_lt (vector bool short, vector unsigned short);
15336 int vec_any_lt (vector unsigned short, vector bool short);
15337 int vec_any_lt (vector unsigned short, vector unsigned short);
15338 int vec_any_lt (vector bool short, vector signed short);
15339 int vec_any_lt (vector signed short, vector bool short);
15340 int vec_any_lt (vector signed short, vector signed short);
15341 int vec_any_lt (vector bool int, vector unsigned int);
15342 int vec_any_lt (vector unsigned int, vector bool int);
15343 int vec_any_lt (vector unsigned int, vector unsigned int);
15344 int vec_any_lt (vector bool int, vector signed int);
15345 int vec_any_lt (vector signed int, vector bool int);
15346 int vec_any_lt (vector signed int, vector signed int);
15347 int vec_any_lt (vector float, vector float);
15348
15349 int vec_any_nan (vector float);
15350
15351 int vec_any_ne (vector signed char, vector bool char);
15352 int vec_any_ne (vector signed char, vector signed char);
15353 int vec_any_ne (vector unsigned char, vector bool char);
15354 int vec_any_ne (vector unsigned char, vector unsigned char);
15355 int vec_any_ne (vector bool char, vector bool char);
15356 int vec_any_ne (vector bool char, vector unsigned char);
15357 int vec_any_ne (vector bool char, vector signed char);
15358 int vec_any_ne (vector signed short, vector bool short);
15359 int vec_any_ne (vector signed short, vector signed short);
15360 int vec_any_ne (vector unsigned short, vector bool short);
15361 int vec_any_ne (vector unsigned short, vector unsigned short);
15362 int vec_any_ne (vector bool short, vector bool short);
15363 int vec_any_ne (vector bool short, vector unsigned short);
15364 int vec_any_ne (vector bool short, vector signed short);
15365 int vec_any_ne (vector pixel, vector pixel);
15366 int vec_any_ne (vector signed int, vector bool int);
15367 int vec_any_ne (vector signed int, vector signed int);
15368 int vec_any_ne (vector unsigned int, vector bool int);
15369 int vec_any_ne (vector unsigned int, vector unsigned int);
15370 int vec_any_ne (vector bool int, vector bool int);
15371 int vec_any_ne (vector bool int, vector unsigned int);
15372 int vec_any_ne (vector bool int, vector signed int);
15373 int vec_any_ne (vector float, vector float);
15374
15375 int vec_any_nge (vector float, vector float);
15376
15377 int vec_any_ngt (vector float, vector float);
15378
15379 int vec_any_nle (vector float, vector float);
15380
15381 int vec_any_nlt (vector float, vector float);
15382
15383 int vec_any_numeric (vector float);
15384
15385 int vec_any_out (vector float, vector float);
15386 @end smallexample
15387
15388 If the vector/scalar (VSX) instruction set is available, the following
15389 additional functions are available:
15390
15391 @smallexample
15392 vector double vec_abs (vector double);
15393 vector double vec_add (vector double, vector double);
15394 vector double vec_and (vector double, vector double);
15395 vector double vec_and (vector double, vector bool long);
15396 vector double vec_and (vector bool long, vector double);
15397 vector double vec_andc (vector double, vector double);
15398 vector double vec_andc (vector double, vector bool long);
15399 vector double vec_andc (vector bool long, vector double);
15400 vector double vec_ceil (vector double);
15401 vector bool long vec_cmpeq (vector double, vector double);
15402 vector bool long vec_cmpge (vector double, vector double);
15403 vector bool long vec_cmpgt (vector double, vector double);
15404 vector bool long vec_cmple (vector double, vector double);
15405 vector bool long vec_cmplt (vector double, vector double);
15406 vector float vec_div (vector float, vector float);
15407 vector double vec_div (vector double, vector double);
15408 vector double vec_floor (vector double);
15409 vector double vec_ld (int, const vector double *);
15410 vector double vec_ld (int, const double *);
15411 vector double vec_ldl (int, const vector double *);
15412 vector double vec_ldl (int, const double *);
15413 vector unsigned char vec_lvsl (int, const volatile double *);
15414 vector unsigned char vec_lvsr (int, const volatile double *);
15415 vector double vec_madd (vector double, vector double, vector double);
15416 vector double vec_max (vector double, vector double);
15417 vector double vec_min (vector double, vector double);
15418 vector float vec_msub (vector float, vector float, vector float);
15419 vector double vec_msub (vector double, vector double, vector double);
15420 vector float vec_mul (vector float, vector float);
15421 vector double vec_mul (vector double, vector double);
15422 vector float vec_nearbyint (vector float);
15423 vector double vec_nearbyint (vector double);
15424 vector float vec_nmadd (vector float, vector float, vector float);
15425 vector double vec_nmadd (vector double, vector double, vector double);
15426 vector double vec_nmsub (vector double, vector double, vector double);
15427 vector double vec_nor (vector double, vector double);
15428 vector double vec_or (vector double, vector double);
15429 vector double vec_or (vector double, vector bool long);
15430 vector double vec_or (vector bool long, vector double);
15431 vector double vec_perm (vector double,
15432 vector double,
15433 vector unsigned char);
15434 vector double vec_rint (vector double);
15435 vector double vec_recip (vector double, vector double);
15436 vector double vec_rsqrt (vector double);
15437 vector double vec_rsqrte (vector double);
15438 vector double vec_sel (vector double, vector double, vector bool long);
15439 vector double vec_sel (vector double, vector double, vector unsigned long);
15440 vector double vec_sub (vector double, vector double);
15441 vector float vec_sqrt (vector float);
15442 vector double vec_sqrt (vector double);
15443 void vec_st (vector double, int, vector double *);
15444 void vec_st (vector double, int, double *);
15445 vector double vec_trunc (vector double);
15446 vector double vec_xor (vector double, vector double);
15447 vector double vec_xor (vector double, vector bool long);
15448 vector double vec_xor (vector bool long, vector double);
15449 int vec_all_eq (vector double, vector double);
15450 int vec_all_ge (vector double, vector double);
15451 int vec_all_gt (vector double, vector double);
15452 int vec_all_le (vector double, vector double);
15453 int vec_all_lt (vector double, vector double);
15454 int vec_all_nan (vector double);
15455 int vec_all_ne (vector double, vector double);
15456 int vec_all_nge (vector double, vector double);
15457 int vec_all_ngt (vector double, vector double);
15458 int vec_all_nle (vector double, vector double);
15459 int vec_all_nlt (vector double, vector double);
15460 int vec_all_numeric (vector double);
15461 int vec_any_eq (vector double, vector double);
15462 int vec_any_ge (vector double, vector double);
15463 int vec_any_gt (vector double, vector double);
15464 int vec_any_le (vector double, vector double);
15465 int vec_any_lt (vector double, vector double);
15466 int vec_any_nan (vector double);
15467 int vec_any_ne (vector double, vector double);
15468 int vec_any_nge (vector double, vector double);
15469 int vec_any_ngt (vector double, vector double);
15470 int vec_any_nle (vector double, vector double);
15471 int vec_any_nlt (vector double, vector double);
15472 int vec_any_numeric (vector double);
15473
15474 vector double vec_vsx_ld (int, const vector double *);
15475 vector double vec_vsx_ld (int, const double *);
15476 vector float vec_vsx_ld (int, const vector float *);
15477 vector float vec_vsx_ld (int, const float *);
15478 vector bool int vec_vsx_ld (int, const vector bool int *);
15479 vector signed int vec_vsx_ld (int, const vector signed int *);
15480 vector signed int vec_vsx_ld (int, const int *);
15481 vector signed int vec_vsx_ld (int, const long *);
15482 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15483 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15484 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15485 vector bool short vec_vsx_ld (int, const vector bool short *);
15486 vector pixel vec_vsx_ld (int, const vector pixel *);
15487 vector signed short vec_vsx_ld (int, const vector signed short *);
15488 vector signed short vec_vsx_ld (int, const short *);
15489 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15490 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15491 vector bool char vec_vsx_ld (int, const vector bool char *);
15492 vector signed char vec_vsx_ld (int, const vector signed char *);
15493 vector signed char vec_vsx_ld (int, const signed char *);
15494 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15495 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15496
15497 void vec_vsx_st (vector double, int, vector double *);
15498 void vec_vsx_st (vector double, int, double *);
15499 void vec_vsx_st (vector float, int, vector float *);
15500 void vec_vsx_st (vector float, int, float *);
15501 void vec_vsx_st (vector signed int, int, vector signed int *);
15502 void vec_vsx_st (vector signed int, int, int *);
15503 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15504 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15505 void vec_vsx_st (vector bool int, int, vector bool int *);
15506 void vec_vsx_st (vector bool int, int, unsigned int *);
15507 void vec_vsx_st (vector bool int, int, int *);
15508 void vec_vsx_st (vector signed short, int, vector signed short *);
15509 void vec_vsx_st (vector signed short, int, short *);
15510 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15511 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15512 void vec_vsx_st (vector bool short, int, vector bool short *);
15513 void vec_vsx_st (vector bool short, int, unsigned short *);
15514 void vec_vsx_st (vector pixel, int, vector pixel *);
15515 void vec_vsx_st (vector pixel, int, unsigned short *);
15516 void vec_vsx_st (vector pixel, int, short *);
15517 void vec_vsx_st (vector bool short, int, short *);
15518 void vec_vsx_st (vector signed char, int, vector signed char *);
15519 void vec_vsx_st (vector signed char, int, signed char *);
15520 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15521 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15522 void vec_vsx_st (vector bool char, int, vector bool char *);
15523 void vec_vsx_st (vector bool char, int, unsigned char *);
15524 void vec_vsx_st (vector bool char, int, signed char *);
15525
15526 vector double vec_xxpermdi (vector double, vector double, int);
15527 vector float vec_xxpermdi (vector float, vector float, int);
15528 vector long long vec_xxpermdi (vector long long, vector long long, int);
15529 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15530 vector unsigned long long, int);
15531 vector int vec_xxpermdi (vector int, vector int, int);
15532 vector unsigned int vec_xxpermdi (vector unsigned int,
15533 vector unsigned int, int);
15534 vector short vec_xxpermdi (vector short, vector short, int);
15535 vector unsigned short vec_xxpermdi (vector unsigned short,
15536 vector unsigned short, int);
15537 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
15538 vector unsigned char vec_xxpermdi (vector unsigned char,
15539 vector unsigned char, int);
15540
15541 vector double vec_xxsldi (vector double, vector double, int);
15542 vector float vec_xxsldi (vector float, vector float, int);
15543 vector long long vec_xxsldi (vector long long, vector long long, int);
15544 vector unsigned long long vec_xxsldi (vector unsigned long long,
15545 vector unsigned long long, int);
15546 vector int vec_xxsldi (vector int, vector int, int);
15547 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
15548 vector short vec_xxsldi (vector short, vector short, int);
15549 vector unsigned short vec_xxsldi (vector unsigned short,
15550 vector unsigned short, int);
15551 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
15552 vector unsigned char vec_xxsldi (vector unsigned char,
15553 vector unsigned char, int);
15554 @end smallexample
15555
15556 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
15557 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
15558 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
15559 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
15560 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
15561
15562 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15563 instruction set is available, the following additional functions are
15564 available for both 32-bit and 64-bit targets. For 64-bit targets, you
15565 can use @var{vector long} instead of @var{vector long long},
15566 @var{vector bool long} instead of @var{vector bool long long}, and
15567 @var{vector unsigned long} instead of @var{vector unsigned long long}.
15568
15569 @smallexample
15570 vector long long vec_abs (vector long long);
15571
15572 vector long long vec_add (vector long long, vector long long);
15573 vector unsigned long long vec_add (vector unsigned long long,
15574 vector unsigned long long);
15575
15576 int vec_all_eq (vector long long, vector long long);
15577 int vec_all_ge (vector long long, vector long long);
15578 int vec_all_gt (vector long long, vector long long);
15579 int vec_all_le (vector long long, vector long long);
15580 int vec_all_lt (vector long long, vector long long);
15581 int vec_all_ne (vector long long, vector long long);
15582 int vec_any_eq (vector long long, vector long long);
15583 int vec_any_ge (vector long long, vector long long);
15584 int vec_any_gt (vector long long, vector long long);
15585 int vec_any_le (vector long long, vector long long);
15586 int vec_any_lt (vector long long, vector long long);
15587 int vec_any_ne (vector long long, vector long long);
15588
15589 vector long long vec_eqv (vector long long, vector long long);
15590 vector long long vec_eqv (vector bool long long, vector long long);
15591 vector long long vec_eqv (vector long long, vector bool long long);
15592 vector unsigned long long vec_eqv (vector unsigned long long,
15593 vector unsigned long long);
15594 vector unsigned long long vec_eqv (vector bool long long,
15595 vector unsigned long long);
15596 vector unsigned long long vec_eqv (vector unsigned long long,
15597 vector bool long long);
15598 vector int vec_eqv (vector int, vector int);
15599 vector int vec_eqv (vector bool int, vector int);
15600 vector int vec_eqv (vector int, vector bool int);
15601 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
15602 vector unsigned int vec_eqv (vector bool unsigned int,
15603 vector unsigned int);
15604 vector unsigned int vec_eqv (vector unsigned int,
15605 vector bool unsigned int);
15606 vector short vec_eqv (vector short, vector short);
15607 vector short vec_eqv (vector bool short, vector short);
15608 vector short vec_eqv (vector short, vector bool short);
15609 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
15610 vector unsigned short vec_eqv (vector bool unsigned short,
15611 vector unsigned short);
15612 vector unsigned short vec_eqv (vector unsigned short,
15613 vector bool unsigned short);
15614 vector signed char vec_eqv (vector signed char, vector signed char);
15615 vector signed char vec_eqv (vector bool signed char, vector signed char);
15616 vector signed char vec_eqv (vector signed char, vector bool signed char);
15617 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
15618 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
15619 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
15620
15621 vector long long vec_max (vector long long, vector long long);
15622 vector unsigned long long vec_max (vector unsigned long long,
15623 vector unsigned long long);
15624
15625 vector long long vec_min (vector long long, vector long long);
15626 vector unsigned long long vec_min (vector unsigned long long,
15627 vector unsigned long long);
15628
15629 vector long long vec_nand (vector long long, vector long long);
15630 vector long long vec_nand (vector bool long long, vector long long);
15631 vector long long vec_nand (vector long long, vector bool long long);
15632 vector unsigned long long vec_nand (vector unsigned long long,
15633 vector unsigned long long);
15634 vector unsigned long long vec_nand (vector bool long long,
15635 vector unsigned long long);
15636 vector unsigned long long vec_nand (vector unsigned long long,
15637 vector bool long long);
15638 vector int vec_nand (vector int, vector int);
15639 vector int vec_nand (vector bool int, vector int);
15640 vector int vec_nand (vector int, vector bool int);
15641 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
15642 vector unsigned int vec_nand (vector bool unsigned int,
15643 vector unsigned int);
15644 vector unsigned int vec_nand (vector unsigned int,
15645 vector bool unsigned int);
15646 vector short vec_nand (vector short, vector short);
15647 vector short vec_nand (vector bool short, vector short);
15648 vector short vec_nand (vector short, vector bool short);
15649 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
15650 vector unsigned short vec_nand (vector bool unsigned short,
15651 vector unsigned short);
15652 vector unsigned short vec_nand (vector unsigned short,
15653 vector bool unsigned short);
15654 vector signed char vec_nand (vector signed char, vector signed char);
15655 vector signed char vec_nand (vector bool signed char, vector signed char);
15656 vector signed char vec_nand (vector signed char, vector bool signed char);
15657 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
15658 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
15659 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
15660
15661 vector long long vec_orc (vector long long, vector long long);
15662 vector long long vec_orc (vector bool long long, vector long long);
15663 vector long long vec_orc (vector long long, vector bool long long);
15664 vector unsigned long long vec_orc (vector unsigned long long,
15665 vector unsigned long long);
15666 vector unsigned long long vec_orc (vector bool long long,
15667 vector unsigned long long);
15668 vector unsigned long long vec_orc (vector unsigned long long,
15669 vector bool long long);
15670 vector int vec_orc (vector int, vector int);
15671 vector int vec_orc (vector bool int, vector int);
15672 vector int vec_orc (vector int, vector bool int);
15673 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
15674 vector unsigned int vec_orc (vector bool unsigned int,
15675 vector unsigned int);
15676 vector unsigned int vec_orc (vector unsigned int,
15677 vector bool unsigned int);
15678 vector short vec_orc (vector short, vector short);
15679 vector short vec_orc (vector bool short, vector short);
15680 vector short vec_orc (vector short, vector bool short);
15681 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
15682 vector unsigned short vec_orc (vector bool unsigned short,
15683 vector unsigned short);
15684 vector unsigned short vec_orc (vector unsigned short,
15685 vector bool unsigned short);
15686 vector signed char vec_orc (vector signed char, vector signed char);
15687 vector signed char vec_orc (vector bool signed char, vector signed char);
15688 vector signed char vec_orc (vector signed char, vector bool signed char);
15689 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
15690 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
15691 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
15692
15693 vector int vec_pack (vector long long, vector long long);
15694 vector unsigned int vec_pack (vector unsigned long long,
15695 vector unsigned long long);
15696 vector bool int vec_pack (vector bool long long, vector bool long long);
15697
15698 vector int vec_packs (vector long long, vector long long);
15699 vector unsigned int vec_packs (vector unsigned long long,
15700 vector unsigned long long);
15701
15702 vector unsigned int vec_packsu (vector long long, vector long long);
15703
15704 vector long long vec_rl (vector long long,
15705 vector unsigned long long);
15706 vector long long vec_rl (vector unsigned long long,
15707 vector unsigned long long);
15708
15709 vector long long vec_sl (vector long long, vector unsigned long long);
15710 vector long long vec_sl (vector unsigned long long,
15711 vector unsigned long long);
15712
15713 vector long long vec_sr (vector long long, vector unsigned long long);
15714 vector unsigned long long char vec_sr (vector unsigned long long,
15715 vector unsigned long long);
15716
15717 vector long long vec_sra (vector long long, vector unsigned long long);
15718 vector unsigned long long vec_sra (vector unsigned long long,
15719 vector unsigned long long);
15720
15721 vector long long vec_sub (vector long long, vector long long);
15722 vector unsigned long long vec_sub (vector unsigned long long,
15723 vector unsigned long long);
15724
15725 vector long long vec_unpackh (vector int);
15726 vector unsigned long long vec_unpackh (vector unsigned int);
15727
15728 vector long long vec_unpackl (vector int);
15729 vector unsigned long long vec_unpackl (vector unsigned int);
15730
15731 vector long long vec_vaddudm (vector long long, vector long long);
15732 vector long long vec_vaddudm (vector bool long long, vector long long);
15733 vector long long vec_vaddudm (vector long long, vector bool long long);
15734 vector unsigned long long vec_vaddudm (vector unsigned long long,
15735 vector unsigned long long);
15736 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
15737 vector unsigned long long);
15738 vector unsigned long long vec_vaddudm (vector unsigned long long,
15739 vector bool unsigned long long);
15740
15741 vector long long vec_vbpermq (vector signed char, vector signed char);
15742 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
15743
15744 vector long long vec_vclz (vector long long);
15745 vector unsigned long long vec_vclz (vector unsigned long long);
15746 vector int vec_vclz (vector int);
15747 vector unsigned int vec_vclz (vector int);
15748 vector short vec_vclz (vector short);
15749 vector unsigned short vec_vclz (vector unsigned short);
15750 vector signed char vec_vclz (vector signed char);
15751 vector unsigned char vec_vclz (vector unsigned char);
15752
15753 vector signed char vec_vclzb (vector signed char);
15754 vector unsigned char vec_vclzb (vector unsigned char);
15755
15756 vector long long vec_vclzd (vector long long);
15757 vector unsigned long long vec_vclzd (vector unsigned long long);
15758
15759 vector short vec_vclzh (vector short);
15760 vector unsigned short vec_vclzh (vector unsigned short);
15761
15762 vector int vec_vclzw (vector int);
15763 vector unsigned int vec_vclzw (vector int);
15764
15765 vector signed char vec_vgbbd (vector signed char);
15766 vector unsigned char vec_vgbbd (vector unsigned char);
15767
15768 vector long long vec_vmaxsd (vector long long, vector long long);
15769
15770 vector unsigned long long vec_vmaxud (vector unsigned long long,
15771 unsigned vector long long);
15772
15773 vector long long vec_vminsd (vector long long, vector long long);
15774
15775 vector unsigned long long vec_vminud (vector long long,
15776 vector long long);
15777
15778 vector int vec_vpksdss (vector long long, vector long long);
15779 vector unsigned int vec_vpksdss (vector long long, vector long long);
15780
15781 vector unsigned int vec_vpkudus (vector unsigned long long,
15782 vector unsigned long long);
15783
15784 vector int vec_vpkudum (vector long long, vector long long);
15785 vector unsigned int vec_vpkudum (vector unsigned long long,
15786 vector unsigned long long);
15787 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
15788
15789 vector long long vec_vpopcnt (vector long long);
15790 vector unsigned long long vec_vpopcnt (vector unsigned long long);
15791 vector int vec_vpopcnt (vector int);
15792 vector unsigned int vec_vpopcnt (vector int);
15793 vector short vec_vpopcnt (vector short);
15794 vector unsigned short vec_vpopcnt (vector unsigned short);
15795 vector signed char vec_vpopcnt (vector signed char);
15796 vector unsigned char vec_vpopcnt (vector unsigned char);
15797
15798 vector signed char vec_vpopcntb (vector signed char);
15799 vector unsigned char vec_vpopcntb (vector unsigned char);
15800
15801 vector long long vec_vpopcntd (vector long long);
15802 vector unsigned long long vec_vpopcntd (vector unsigned long long);
15803
15804 vector short vec_vpopcnth (vector short);
15805 vector unsigned short vec_vpopcnth (vector unsigned short);
15806
15807 vector int vec_vpopcntw (vector int);
15808 vector unsigned int vec_vpopcntw (vector int);
15809
15810 vector long long vec_vrld (vector long long, vector unsigned long long);
15811 vector unsigned long long vec_vrld (vector unsigned long long,
15812 vector unsigned long long);
15813
15814 vector long long vec_vsld (vector long long, vector unsigned long long);
15815 vector long long vec_vsld (vector unsigned long long,
15816 vector unsigned long long);
15817
15818 vector long long vec_vsrad (vector long long, vector unsigned long long);
15819 vector unsigned long long vec_vsrad (vector unsigned long long,
15820 vector unsigned long long);
15821
15822 vector long long vec_vsrd (vector long long, vector unsigned long long);
15823 vector unsigned long long char vec_vsrd (vector unsigned long long,
15824 vector unsigned long long);
15825
15826 vector long long vec_vsubudm (vector long long, vector long long);
15827 vector long long vec_vsubudm (vector bool long long, vector long long);
15828 vector long long vec_vsubudm (vector long long, vector bool long long);
15829 vector unsigned long long vec_vsubudm (vector unsigned long long,
15830 vector unsigned long long);
15831 vector unsigned long long vec_vsubudm (vector bool long long,
15832 vector unsigned long long);
15833 vector unsigned long long vec_vsubudm (vector unsigned long long,
15834 vector bool long long);
15835
15836 vector long long vec_vupkhsw (vector int);
15837 vector unsigned long long vec_vupkhsw (vector unsigned int);
15838
15839 vector long long vec_vupklsw (vector int);
15840 vector unsigned long long vec_vupklsw (vector int);
15841 @end smallexample
15842
15843 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15844 instruction set is available, the following additional functions are
15845 available for 64-bit targets. New vector types
15846 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
15847 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
15848 builtins.
15849
15850 The normal vector extract, and set operations work on
15851 @var{vector __int128_t} and @var{vector __uint128_t} types,
15852 but the index value must be 0.
15853
15854 @smallexample
15855 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
15856 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
15857
15858 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
15859 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
15860
15861 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
15862 vector __int128_t);
15863 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
15864 vector __uint128_t);
15865
15866 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
15867 vector __int128_t);
15868 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
15869 vector __uint128_t);
15870
15871 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
15872 vector __int128_t);
15873 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
15874 vector __uint128_t);
15875
15876 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
15877 vector __int128_t);
15878 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
15879 vector __uint128_t);
15880
15881 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
15882 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
15883
15884 __int128_t vec_vsubuqm (__int128_t, __int128_t);
15885 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
15886
15887 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
15888 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
15889 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
15890 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
15891 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
15892 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
15893 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
15894 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
15895 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
15896 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
15897 @end smallexample
15898
15899 If the cryptographic instructions are enabled (@option{-mcrypto} or
15900 @option{-mcpu=power8}), the following builtins are enabled.
15901
15902 @smallexample
15903 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
15904
15905 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
15906 vector unsigned long long);
15907
15908 vector unsigned long long __builtin_crypto_vcipherlast
15909 (vector unsigned long long,
15910 vector unsigned long long);
15911
15912 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
15913 vector unsigned long long);
15914
15915 vector unsigned long long __builtin_crypto_vncipherlast
15916 (vector unsigned long long,
15917 vector unsigned long long);
15918
15919 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
15920 vector unsigned char,
15921 vector unsigned char);
15922
15923 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
15924 vector unsigned short,
15925 vector unsigned short);
15926
15927 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
15928 vector unsigned int,
15929 vector unsigned int);
15930
15931 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
15932 vector unsigned long long,
15933 vector unsigned long long);
15934
15935 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
15936 vector unsigned char);
15937
15938 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
15939 vector unsigned short);
15940
15941 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
15942 vector unsigned int);
15943
15944 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
15945 vector unsigned long long);
15946
15947 vector unsigned long long __builtin_crypto_vshasigmad
15948 (vector unsigned long long, int, int);
15949
15950 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
15951 int, int);
15952 @end smallexample
15953
15954 The second argument to the @var{__builtin_crypto_vshasigmad} and
15955 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
15956 integer that is 0 or 1. The third argument to these builtin functions
15957 must be a constant integer in the range of 0 to 15.
15958
15959 @node PowerPC Hardware Transactional Memory Built-in Functions
15960 @subsection PowerPC Hardware Transactional Memory Built-in Functions
15961 GCC provides two interfaces for accessing the Hardware Transactional
15962 Memory (HTM) instructions available on some of the PowerPC family
15963 of prcoessors (eg, POWER8). The two interfaces come in a low level
15964 interface, consisting of built-in functions specific to PowerPC and a
15965 higher level interface consisting of inline functions that are common
15966 between PowerPC and S/390.
15967
15968 @subsubsection PowerPC HTM Low Level Built-in Functions
15969
15970 The following low level built-in functions are available with
15971 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
15972 They all generate the machine instruction that is part of the name.
15973
15974 The HTM built-ins return true or false depending on their success and
15975 their arguments match exactly the type and order of the associated
15976 hardware instruction's operands. Refer to the ISA manual for a
15977 description of each instruction's operands.
15978
15979 @smallexample
15980 unsigned int __builtin_tbegin (unsigned int)
15981 unsigned int __builtin_tend (unsigned int)
15982
15983 unsigned int __builtin_tabort (unsigned int)
15984 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
15985 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
15986 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
15987 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
15988
15989 unsigned int __builtin_tcheck (unsigned int)
15990 unsigned int __builtin_treclaim (unsigned int)
15991 unsigned int __builtin_trechkpt (void)
15992 unsigned int __builtin_tsr (unsigned int)
15993 @end smallexample
15994
15995 In addition to the above HTM built-ins, we have added built-ins for
15996 some common extended mnemonics of the HTM instructions:
15997
15998 @smallexample
15999 unsigned int __builtin_tendall (void)
16000 unsigned int __builtin_tresume (void)
16001 unsigned int __builtin_tsuspend (void)
16002 @end smallexample
16003
16004 The following set of built-in functions are available to gain access
16005 to the HTM specific special purpose registers.
16006
16007 @smallexample
16008 unsigned long __builtin_get_texasr (void)
16009 unsigned long __builtin_get_texasru (void)
16010 unsigned long __builtin_get_tfhar (void)
16011 unsigned long __builtin_get_tfiar (void)
16012
16013 void __builtin_set_texasr (unsigned long);
16014 void __builtin_set_texasru (unsigned long);
16015 void __builtin_set_tfhar (unsigned long);
16016 void __builtin_set_tfiar (unsigned long);
16017 @end smallexample
16018
16019 Example usage of these low level built-in functions may look like:
16020
16021 @smallexample
16022 #include <htmintrin.h>
16023
16024 int num_retries = 10;
16025
16026 while (1)
16027 @{
16028 if (__builtin_tbegin (0))
16029 @{
16030 /* Transaction State Initiated. */
16031 if (is_locked (lock))
16032 __builtin_tabort (0);
16033 ... transaction code...
16034 __builtin_tend (0);
16035 break;
16036 @}
16037 else
16038 @{
16039 /* Transaction State Failed. Use locks if the transaction
16040 failure is "persistent" or we've tried too many times. */
16041 if (num_retries-- <= 0
16042 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16043 @{
16044 acquire_lock (lock);
16045 ... non transactional fallback path...
16046 release_lock (lock);
16047 break;
16048 @}
16049 @}
16050 @}
16051 @end smallexample
16052
16053 One final built-in function has been added that returns the value of
16054 the 2-bit Transaction State field of the Machine Status Register (MSR)
16055 as stored in @code{CR0}.
16056
16057 @smallexample
16058 unsigned long __builtin_ttest (void)
16059 @end smallexample
16060
16061 This built-in can be used to determine the current transaction state
16062 using the following code example:
16063
16064 @smallexample
16065 #include <htmintrin.h>
16066
16067 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16068
16069 if (tx_state == _HTM_TRANSACTIONAL)
16070 @{
16071 /* Code to use in transactional state. */
16072 @}
16073 else if (tx_state == _HTM_NONTRANSACTIONAL)
16074 @{
16075 /* Code to use in non-transactional state. */
16076 @}
16077 else if (tx_state == _HTM_SUSPENDED)
16078 @{
16079 /* Code to use in transaction suspended state. */
16080 @}
16081 @end smallexample
16082
16083 @subsubsection PowerPC HTM High Level Inline Functions
16084
16085 The following high level HTM interface is made available by including
16086 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16087 where CPU is `power8' or later. This interface is common between PowerPC
16088 and S/390, allowing users to write one HTM source implementation that
16089 can be compiled and executed on either system.
16090
16091 @smallexample
16092 long __TM_simple_begin (void)
16093 long __TM_begin (void* const TM_buff)
16094 long __TM_end (void)
16095 void __TM_abort (void)
16096 void __TM_named_abort (unsigned char const code)
16097 void __TM_resume (void)
16098 void __TM_suspend (void)
16099
16100 long __TM_is_user_abort (void* const TM_buff)
16101 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16102 long __TM_is_illegal (void* const TM_buff)
16103 long __TM_is_footprint_exceeded (void* const TM_buff)
16104 long __TM_nesting_depth (void* const TM_buff)
16105 long __TM_is_nested_too_deep(void* const TM_buff)
16106 long __TM_is_conflict(void* const TM_buff)
16107 long __TM_is_failure_persistent(void* const TM_buff)
16108 long __TM_failure_address(void* const TM_buff)
16109 long long __TM_failure_code(void* const TM_buff)
16110 @end smallexample
16111
16112 Using these common set of HTM inline functions, we can create
16113 a more portable version of the HTM example in the previous
16114 section that will work on either PowerPC or S/390:
16115
16116 @smallexample
16117 #include <htmxlintrin.h>
16118
16119 int num_retries = 10;
16120 TM_buff_type TM_buff;
16121
16122 while (1)
16123 @{
16124 if (__TM_begin (TM_buff))
16125 @{
16126 /* Transaction State Initiated. */
16127 if (is_locked (lock))
16128 __TM_abort ();
16129 ... transaction code...
16130 __TM_end ();
16131 break;
16132 @}
16133 else
16134 @{
16135 /* Transaction State Failed. Use locks if the transaction
16136 failure is "persistent" or we've tried too many times. */
16137 if (num_retries-- <= 0
16138 || __TM_is_failure_persistent (TM_buff))
16139 @{
16140 acquire_lock (lock);
16141 ... non transactional fallback path...
16142 release_lock (lock);
16143 break;
16144 @}
16145 @}
16146 @}
16147 @end smallexample
16148
16149 @node RX Built-in Functions
16150 @subsection RX Built-in Functions
16151 GCC supports some of the RX instructions which cannot be expressed in
16152 the C programming language via the use of built-in functions. The
16153 following functions are supported:
16154
16155 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
16156 Generates the @code{brk} machine instruction.
16157 @end deftypefn
16158
16159 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
16160 Generates the @code{clrpsw} machine instruction to clear the specified
16161 bit in the processor status word.
16162 @end deftypefn
16163
16164 @deftypefn {Built-in Function} void __builtin_rx_int (int)
16165 Generates the @code{int} machine instruction to generate an interrupt
16166 with the specified value.
16167 @end deftypefn
16168
16169 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
16170 Generates the @code{machi} machine instruction to add the result of
16171 multiplying the top 16 bits of the two arguments into the
16172 accumulator.
16173 @end deftypefn
16174
16175 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
16176 Generates the @code{maclo} machine instruction to add the result of
16177 multiplying the bottom 16 bits of the two arguments into the
16178 accumulator.
16179 @end deftypefn
16180
16181 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
16182 Generates the @code{mulhi} machine instruction to place the result of
16183 multiplying the top 16 bits of the two arguments into the
16184 accumulator.
16185 @end deftypefn
16186
16187 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
16188 Generates the @code{mullo} machine instruction to place the result of
16189 multiplying the bottom 16 bits of the two arguments into the
16190 accumulator.
16191 @end deftypefn
16192
16193 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
16194 Generates the @code{mvfachi} machine instruction to read the top
16195 32 bits of the accumulator.
16196 @end deftypefn
16197
16198 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
16199 Generates the @code{mvfacmi} machine instruction to read the middle
16200 32 bits of the accumulator.
16201 @end deftypefn
16202
16203 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
16204 Generates the @code{mvfc} machine instruction which reads the control
16205 register specified in its argument and returns its value.
16206 @end deftypefn
16207
16208 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
16209 Generates the @code{mvtachi} machine instruction to set the top
16210 32 bits of the accumulator.
16211 @end deftypefn
16212
16213 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
16214 Generates the @code{mvtaclo} machine instruction to set the bottom
16215 32 bits of the accumulator.
16216 @end deftypefn
16217
16218 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
16219 Generates the @code{mvtc} machine instruction which sets control
16220 register number @code{reg} to @code{val}.
16221 @end deftypefn
16222
16223 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
16224 Generates the @code{mvtipl} machine instruction set the interrupt
16225 priority level.
16226 @end deftypefn
16227
16228 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
16229 Generates the @code{racw} machine instruction to round the accumulator
16230 according to the specified mode.
16231 @end deftypefn
16232
16233 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
16234 Generates the @code{revw} machine instruction which swaps the bytes in
16235 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16236 and also bits 16--23 occupy bits 24--31 and vice versa.
16237 @end deftypefn
16238
16239 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
16240 Generates the @code{rmpa} machine instruction which initiates a
16241 repeated multiply and accumulate sequence.
16242 @end deftypefn
16243
16244 @deftypefn {Built-in Function} void __builtin_rx_round (float)
16245 Generates the @code{round} machine instruction which returns the
16246 floating-point argument rounded according to the current rounding mode
16247 set in the floating-point status word register.
16248 @end deftypefn
16249
16250 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
16251 Generates the @code{sat} machine instruction which returns the
16252 saturated value of the argument.
16253 @end deftypefn
16254
16255 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
16256 Generates the @code{setpsw} machine instruction to set the specified
16257 bit in the processor status word.
16258 @end deftypefn
16259
16260 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
16261 Generates the @code{wait} machine instruction.
16262 @end deftypefn
16263
16264 @node S/390 System z Built-in Functions
16265 @subsection S/390 System z Built-in Functions
16266 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16267 Generates the @code{tbegin} machine instruction starting a
16268 non-constraint hardware transaction. If the parameter is non-NULL the
16269 memory area is used to store the transaction diagnostic buffer and
16270 will be passed as first operand to @code{tbegin}. This buffer can be
16271 defined using the @code{struct __htm_tdb} C struct defined in
16272 @code{htmintrin.h} and must reside on a double-word boundary. The
16273 second tbegin operand is set to @code{0xff0c}. This enables
16274 save/restore of all GPRs and disables aborts for FPR and AR
16275 manipulations inside the transaction body. The condition code set by
16276 the tbegin instruction is returned as integer value. The tbegin
16277 instruction by definition overwrites the content of all FPRs. The
16278 compiler will generate code which saves and restores the FPRs. For
16279 soft-float code it is recommended to used the @code{*_nofloat}
16280 variant. In order to prevent a TDB from being written it is required
16281 to pass an constant zero value as parameter. Passing the zero value
16282 through a variable is not sufficient. Although modifications of
16283 access registers inside the transaction will not trigger an
16284 transaction abort it is not supported to actually modify them. Access
16285 registers do not get saved when entering a transaction. They will have
16286 undefined state when reaching the abort code.
16287 @end deftypefn
16288
16289 Macros for the possible return codes of tbegin are defined in the
16290 @code{htmintrin.h} header file:
16291
16292 @table @code
16293 @item _HTM_TBEGIN_STARTED
16294 @code{tbegin} has been executed as part of normal processing. The
16295 transaction body is supposed to be executed.
16296 @item _HTM_TBEGIN_INDETERMINATE
16297 The transaction was aborted due to an indeterminate condition which
16298 might be persistent.
16299 @item _HTM_TBEGIN_TRANSIENT
16300 The transaction aborted due to a transient failure. The transaction
16301 should be re-executed in that case.
16302 @item _HTM_TBEGIN_PERSISTENT
16303 The transaction aborted due to a persistent failure. Re-execution
16304 under same circumstances will not be productive.
16305 @end table
16306
16307 @defmac _HTM_FIRST_USER_ABORT_CODE
16308 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16309 specifies the first abort code which can be used for
16310 @code{__builtin_tabort}. Values below this threshold are reserved for
16311 machine use.
16312 @end defmac
16313
16314 @deftp {Data type} {struct __htm_tdb}
16315 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16316 the structure of the transaction diagnostic block as specified in the
16317 Principles of Operation manual chapter 5-91.
16318 @end deftp
16319
16320 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16321 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16322 Using this variant in code making use of FPRs will leave the FPRs in
16323 undefined state when entering the transaction abort handler code.
16324 @end deftypefn
16325
16326 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16327 In addition to @code{__builtin_tbegin} a loop for transient failures
16328 is generated. If tbegin returns a condition code of 2 the transaction
16329 will be retried as often as specified in the second argument. The
16330 perform processor assist instruction is used to tell the CPU about the
16331 number of fails so far.
16332 @end deftypefn
16333
16334 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16335 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16336 restores. Using this variant in code making use of FPRs will leave
16337 the FPRs in undefined state when entering the transaction abort
16338 handler code.
16339 @end deftypefn
16340
16341 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16342 Generates the @code{tbeginc} machine instruction starting a constraint
16343 hardware transaction. The second operand is set to @code{0xff08}.
16344 @end deftypefn
16345
16346 @deftypefn {Built-in Function} int __builtin_tend (void)
16347 Generates the @code{tend} machine instruction finishing a transaction
16348 and making the changes visible to other threads. The condition code
16349 generated by tend is returned as integer value.
16350 @end deftypefn
16351
16352 @deftypefn {Built-in Function} void __builtin_tabort (int)
16353 Generates the @code{tabort} machine instruction with the specified
16354 abort code. Abort codes from 0 through 255 are reserved and will
16355 result in an error message.
16356 @end deftypefn
16357
16358 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16359 Generates the @code{ppa rX,rY,1} machine instruction. Where the
16360 integer parameter is loaded into rX and a value of zero is loaded into
16361 rY. The integer parameter specifies the number of times the
16362 transaction repeatedly aborted.
16363 @end deftypefn
16364
16365 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16366 Generates the @code{etnd} machine instruction. The current nesting
16367 depth is returned as integer value. For a nesting depth of 0 the code
16368 is not executed as part of an transaction.
16369 @end deftypefn
16370
16371 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16372
16373 Generates the @code{ntstg} machine instruction. The second argument
16374 is written to the first arguments location. The store operation will
16375 not be rolled-back in case of an transaction abort.
16376 @end deftypefn
16377
16378 @node SH Built-in Functions
16379 @subsection SH Built-in Functions
16380 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16381 families of processors:
16382
16383 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16384 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
16385 used by system code that manages threads and execution contexts. The compiler
16386 normally does not generate code that modifies the contents of @samp{GBR} and
16387 thus the value is preserved across function calls. Changing the @samp{GBR}
16388 value in user code must be done with caution, since the compiler might use
16389 @samp{GBR} in order to access thread local variables.
16390
16391 @end deftypefn
16392
16393 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16394 Returns the value that is currently set in the @samp{GBR} register.
16395 Memory loads and stores that use the thread pointer as a base address are
16396 turned into @samp{GBR} based displacement loads and stores, if possible.
16397 For example:
16398 @smallexample
16399 struct my_tcb
16400 @{
16401 int a, b, c, d, e;
16402 @};
16403
16404 int get_tcb_value (void)
16405 @{
16406 // Generate @samp{mov.l @@(8,gbr),r0} instruction
16407 return ((my_tcb*)__builtin_thread_pointer ())->c;
16408 @}
16409
16410 @end smallexample
16411 @end deftypefn
16412
16413 @node SPARC VIS Built-in Functions
16414 @subsection SPARC VIS Built-in Functions
16415
16416 GCC supports SIMD operations on the SPARC using both the generic vector
16417 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16418 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
16419 switch, the VIS extension is exposed as the following built-in functions:
16420
16421 @smallexample
16422 typedef int v1si __attribute__ ((vector_size (4)));
16423 typedef int v2si __attribute__ ((vector_size (8)));
16424 typedef short v4hi __attribute__ ((vector_size (8)));
16425 typedef short v2hi __attribute__ ((vector_size (4)));
16426 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16427 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16428
16429 void __builtin_vis_write_gsr (int64_t);
16430 int64_t __builtin_vis_read_gsr (void);
16431
16432 void * __builtin_vis_alignaddr (void *, long);
16433 void * __builtin_vis_alignaddrl (void *, long);
16434 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16435 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16436 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16437 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16438
16439 v4hi __builtin_vis_fexpand (v4qi);
16440
16441 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16442 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16443 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16444 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16445 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16446 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16447 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16448
16449 v4qi __builtin_vis_fpack16 (v4hi);
16450 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16451 v2hi __builtin_vis_fpackfix (v2si);
16452 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16453
16454 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16455
16456 long __builtin_vis_edge8 (void *, void *);
16457 long __builtin_vis_edge8l (void *, void *);
16458 long __builtin_vis_edge16 (void *, void *);
16459 long __builtin_vis_edge16l (void *, void *);
16460 long __builtin_vis_edge32 (void *, void *);
16461 long __builtin_vis_edge32l (void *, void *);
16462
16463 long __builtin_vis_fcmple16 (v4hi, v4hi);
16464 long __builtin_vis_fcmple32 (v2si, v2si);
16465 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16466 long __builtin_vis_fcmpne32 (v2si, v2si);
16467 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16468 long __builtin_vis_fcmpgt32 (v2si, v2si);
16469 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16470 long __builtin_vis_fcmpeq32 (v2si, v2si);
16471
16472 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16473 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16474 v2si __builtin_vis_fpadd32 (v2si, v2si);
16475 v1si __builtin_vis_fpadd32s (v1si, v1si);
16476 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
16477 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
16478 v2si __builtin_vis_fpsub32 (v2si, v2si);
16479 v1si __builtin_vis_fpsub32s (v1si, v1si);
16480
16481 long __builtin_vis_array8 (long, long);
16482 long __builtin_vis_array16 (long, long);
16483 long __builtin_vis_array32 (long, long);
16484 @end smallexample
16485
16486 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
16487 functions also become available:
16488
16489 @smallexample
16490 long __builtin_vis_bmask (long, long);
16491 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
16492 v2si __builtin_vis_bshufflev2si (v2si, v2si);
16493 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
16494 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
16495
16496 long __builtin_vis_edge8n (void *, void *);
16497 long __builtin_vis_edge8ln (void *, void *);
16498 long __builtin_vis_edge16n (void *, void *);
16499 long __builtin_vis_edge16ln (void *, void *);
16500 long __builtin_vis_edge32n (void *, void *);
16501 long __builtin_vis_edge32ln (void *, void *);
16502 @end smallexample
16503
16504 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
16505 functions also become available:
16506
16507 @smallexample
16508 void __builtin_vis_cmask8 (long);
16509 void __builtin_vis_cmask16 (long);
16510 void __builtin_vis_cmask32 (long);
16511
16512 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
16513
16514 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
16515 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
16516 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
16517 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
16518 v2si __builtin_vis_fsll16 (v2si, v2si);
16519 v2si __builtin_vis_fslas16 (v2si, v2si);
16520 v2si __builtin_vis_fsrl16 (v2si, v2si);
16521 v2si __builtin_vis_fsra16 (v2si, v2si);
16522
16523 long __builtin_vis_pdistn (v8qi, v8qi);
16524
16525 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
16526
16527 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
16528 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
16529
16530 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
16531 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
16532 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
16533 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
16534 v2si __builtin_vis_fpadds32 (v2si, v2si);
16535 v1si __builtin_vis_fpadds32s (v1si, v1si);
16536 v2si __builtin_vis_fpsubs32 (v2si, v2si);
16537 v1si __builtin_vis_fpsubs32s (v1si, v1si);
16538
16539 long __builtin_vis_fucmple8 (v8qi, v8qi);
16540 long __builtin_vis_fucmpne8 (v8qi, v8qi);
16541 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
16542 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
16543
16544 float __builtin_vis_fhadds (float, float);
16545 double __builtin_vis_fhaddd (double, double);
16546 float __builtin_vis_fhsubs (float, float);
16547 double __builtin_vis_fhsubd (double, double);
16548 float __builtin_vis_fnhadds (float, float);
16549 double __builtin_vis_fnhaddd (double, double);
16550
16551 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
16552 int64_t __builtin_vis_xmulx (int64_t, int64_t);
16553 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
16554 @end smallexample
16555
16556 @node SPU Built-in Functions
16557 @subsection SPU Built-in Functions
16558
16559 GCC provides extensions for the SPU processor as described in the
16560 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
16561 found at @uref{http://cell.scei.co.jp/} or
16562 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
16563 implementation differs in several ways.
16564
16565 @itemize @bullet
16566
16567 @item
16568 The optional extension of specifying vector constants in parentheses is
16569 not supported.
16570
16571 @item
16572 A vector initializer requires no cast if the vector constant is of the
16573 same type as the variable it is initializing.
16574
16575 @item
16576 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16577 vector type is the default signedness of the base type. The default
16578 varies depending on the operating system, so a portable program should
16579 always specify the signedness.
16580
16581 @item
16582 By default, the keyword @code{__vector} is added. The macro
16583 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
16584 undefined.
16585
16586 @item
16587 GCC allows using a @code{typedef} name as the type specifier for a
16588 vector type.
16589
16590 @item
16591 For C, overloaded functions are implemented with macros so the following
16592 does not work:
16593
16594 @smallexample
16595 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16596 @end smallexample
16597
16598 @noindent
16599 Since @code{spu_add} is a macro, the vector constant in the example
16600 is treated as four separate arguments. Wrap the entire argument in
16601 parentheses for this to work.
16602
16603 @item
16604 The extended version of @code{__builtin_expect} is not supported.
16605
16606 @end itemize
16607
16608 @emph{Note:} Only the interface described in the aforementioned
16609 specification is supported. Internally, GCC uses built-in functions to
16610 implement the required functionality, but these are not supported and
16611 are subject to change without notice.
16612
16613 @node TI C6X Built-in Functions
16614 @subsection TI C6X Built-in Functions
16615
16616 GCC provides intrinsics to access certain instructions of the TI C6X
16617 processors. These intrinsics, listed below, are available after
16618 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
16619 to C6X instructions.
16620
16621 @smallexample
16622
16623 int _sadd (int, int)
16624 int _ssub (int, int)
16625 int _sadd2 (int, int)
16626 int _ssub2 (int, int)
16627 long long _mpy2 (int, int)
16628 long long _smpy2 (int, int)
16629 int _add4 (int, int)
16630 int _sub4 (int, int)
16631 int _saddu4 (int, int)
16632
16633 int _smpy (int, int)
16634 int _smpyh (int, int)
16635 int _smpyhl (int, int)
16636 int _smpylh (int, int)
16637
16638 int _sshl (int, int)
16639 int _subc (int, int)
16640
16641 int _avg2 (int, int)
16642 int _avgu4 (int, int)
16643
16644 int _clrr (int, int)
16645 int _extr (int, int)
16646 int _extru (int, int)
16647 int _abs (int)
16648 int _abs2 (int)
16649
16650 @end smallexample
16651
16652 @node TILE-Gx Built-in Functions
16653 @subsection TILE-Gx Built-in Functions
16654
16655 GCC provides intrinsics to access every instruction of the TILE-Gx
16656 processor. The intrinsics are of the form:
16657
16658 @smallexample
16659
16660 unsigned long long __insn_@var{op} (...)
16661
16662 @end smallexample
16663
16664 Where @var{op} is the name of the instruction. Refer to the ISA manual
16665 for the complete list of instructions.
16666
16667 GCC also provides intrinsics to directly access the network registers.
16668 The intrinsics are:
16669
16670 @smallexample
16671
16672 unsigned long long __tile_idn0_receive (void)
16673 unsigned long long __tile_idn1_receive (void)
16674 unsigned long long __tile_udn0_receive (void)
16675 unsigned long long __tile_udn1_receive (void)
16676 unsigned long long __tile_udn2_receive (void)
16677 unsigned long long __tile_udn3_receive (void)
16678 void __tile_idn_send (unsigned long long)
16679 void __tile_udn_send (unsigned long long)
16680
16681 @end smallexample
16682
16683 The intrinsic @code{void __tile_network_barrier (void)} is used to
16684 guarantee that no network operations before it are reordered with
16685 those after it.
16686
16687 @node TILEPro Built-in Functions
16688 @subsection TILEPro Built-in Functions
16689
16690 GCC provides intrinsics to access every instruction of the TILEPro
16691 processor. The intrinsics are of the form:
16692
16693 @smallexample
16694
16695 unsigned __insn_@var{op} (...)
16696
16697 @end smallexample
16698
16699 @noindent
16700 where @var{op} is the name of the instruction. Refer to the ISA manual
16701 for the complete list of instructions.
16702
16703 GCC also provides intrinsics to directly access the network registers.
16704 The intrinsics are:
16705
16706 @smallexample
16707
16708 unsigned __tile_idn0_receive (void)
16709 unsigned __tile_idn1_receive (void)
16710 unsigned __tile_sn_receive (void)
16711 unsigned __tile_udn0_receive (void)
16712 unsigned __tile_udn1_receive (void)
16713 unsigned __tile_udn2_receive (void)
16714 unsigned __tile_udn3_receive (void)
16715 void __tile_idn_send (unsigned)
16716 void __tile_sn_send (unsigned)
16717 void __tile_udn_send (unsigned)
16718
16719 @end smallexample
16720
16721 The intrinsic @code{void __tile_network_barrier (void)} is used to
16722 guarantee that no network operations before it are reordered with
16723 those after it.
16724
16725 @node Target Format Checks
16726 @section Format Checks Specific to Particular Target Machines
16727
16728 For some target machines, GCC supports additional options to the
16729 format attribute
16730 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
16731
16732 @menu
16733 * Solaris Format Checks::
16734 * Darwin Format Checks::
16735 @end menu
16736
16737 @node Solaris Format Checks
16738 @subsection Solaris Format Checks
16739
16740 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
16741 check. @code{cmn_err} accepts a subset of the standard @code{printf}
16742 conversions, and the two-argument @code{%b} conversion for displaying
16743 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
16744
16745 @node Darwin Format Checks
16746 @subsection Darwin Format Checks
16747
16748 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
16749 attribute context. Declarations made with such attribution are parsed for correct syntax
16750 and format argument types. However, parsing of the format string itself is currently undefined
16751 and is not carried out by this version of the compiler.
16752
16753 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
16754 also be used as format arguments. Note that the relevant headers are only likely to be
16755 available on Darwin (OSX) installations. On such installations, the XCode and system
16756 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
16757 associated functions.
16758
16759 @node Pragmas
16760 @section Pragmas Accepted by GCC
16761 @cindex pragmas
16762 @cindex @code{#pragma}
16763
16764 GCC supports several types of pragmas, primarily in order to compile
16765 code originally written for other compilers. Note that in general
16766 we do not recommend the use of pragmas; @xref{Function Attributes},
16767 for further explanation.
16768
16769 @menu
16770 * ARM Pragmas::
16771 * M32C Pragmas::
16772 * MeP Pragmas::
16773 * RS/6000 and PowerPC Pragmas::
16774 * Darwin Pragmas::
16775 * Solaris Pragmas::
16776 * Symbol-Renaming Pragmas::
16777 * Structure-Packing Pragmas::
16778 * Weak Pragmas::
16779 * Diagnostic Pragmas::
16780 * Visibility Pragmas::
16781 * Push/Pop Macro Pragmas::
16782 * Function Specific Option Pragmas::
16783 * Loop-Specific Pragmas::
16784 @end menu
16785
16786 @node ARM Pragmas
16787 @subsection ARM Pragmas
16788
16789 The ARM target defines pragmas for controlling the default addition of
16790 @code{long_call} and @code{short_call} attributes to functions.
16791 @xref{Function Attributes}, for information about the effects of these
16792 attributes.
16793
16794 @table @code
16795 @item long_calls
16796 @cindex pragma, long_calls
16797 Set all subsequent functions to have the @code{long_call} attribute.
16798
16799 @item no_long_calls
16800 @cindex pragma, no_long_calls
16801 Set all subsequent functions to have the @code{short_call} attribute.
16802
16803 @item long_calls_off
16804 @cindex pragma, long_calls_off
16805 Do not affect the @code{long_call} or @code{short_call} attributes of
16806 subsequent functions.
16807 @end table
16808
16809 @node M32C Pragmas
16810 @subsection M32C Pragmas
16811
16812 @table @code
16813 @item GCC memregs @var{number}
16814 @cindex pragma, memregs
16815 Overrides the command-line option @code{-memregs=} for the current
16816 file. Use with care! This pragma must be before any function in the
16817 file, and mixing different memregs values in different objects may
16818 make them incompatible. This pragma is useful when a
16819 performance-critical function uses a memreg for temporary values,
16820 as it may allow you to reduce the number of memregs used.
16821
16822 @item ADDRESS @var{name} @var{address}
16823 @cindex pragma, address
16824 For any declared symbols matching @var{name}, this does three things
16825 to that symbol: it forces the symbol to be located at the given
16826 address (a number), it forces the symbol to be volatile, and it
16827 changes the symbol's scope to be static. This pragma exists for
16828 compatibility with other compilers, but note that the common
16829 @code{1234H} numeric syntax is not supported (use @code{0x1234}
16830 instead). Example:
16831
16832 @smallexample
16833 #pragma ADDRESS port3 0x103
16834 char port3;
16835 @end smallexample
16836
16837 @end table
16838
16839 @node MeP Pragmas
16840 @subsection MeP Pragmas
16841
16842 @table @code
16843
16844 @item custom io_volatile (on|off)
16845 @cindex pragma, custom io_volatile
16846 Overrides the command-line option @code{-mio-volatile} for the current
16847 file. Note that for compatibility with future GCC releases, this
16848 option should only be used once before any @code{io} variables in each
16849 file.
16850
16851 @item GCC coprocessor available @var{registers}
16852 @cindex pragma, coprocessor available
16853 Specifies which coprocessor registers are available to the register
16854 allocator. @var{registers} may be a single register, register range
16855 separated by ellipses, or comma-separated list of those. Example:
16856
16857 @smallexample
16858 #pragma GCC coprocessor available $c0...$c10, $c28
16859 @end smallexample
16860
16861 @item GCC coprocessor call_saved @var{registers}
16862 @cindex pragma, coprocessor call_saved
16863 Specifies which coprocessor registers are to be saved and restored by
16864 any function using them. @var{registers} may be a single register,
16865 register range separated by ellipses, or comma-separated list of
16866 those. Example:
16867
16868 @smallexample
16869 #pragma GCC coprocessor call_saved $c4...$c6, $c31
16870 @end smallexample
16871
16872 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
16873 @cindex pragma, coprocessor subclass
16874 Creates and defines a register class. These register classes can be
16875 used by inline @code{asm} constructs. @var{registers} may be a single
16876 register, register range separated by ellipses, or comma-separated
16877 list of those. Example:
16878
16879 @smallexample
16880 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
16881
16882 asm ("cpfoo %0" : "=B" (x));
16883 @end smallexample
16884
16885 @item GCC disinterrupt @var{name} , @var{name} @dots{}
16886 @cindex pragma, disinterrupt
16887 For the named functions, the compiler adds code to disable interrupts
16888 for the duration of those functions. If any functions so named
16889 are not encountered in the source, a warning is emitted that the pragma is
16890 not used. Examples:
16891
16892 @smallexample
16893 #pragma disinterrupt foo
16894 #pragma disinterrupt bar, grill
16895 int foo () @{ @dots{} @}
16896 @end smallexample
16897
16898 @item GCC call @var{name} , @var{name} @dots{}
16899 @cindex pragma, call
16900 For the named functions, the compiler always uses a register-indirect
16901 call model when calling the named functions. Examples:
16902
16903 @smallexample
16904 extern int foo ();
16905 #pragma call foo
16906 @end smallexample
16907
16908 @end table
16909
16910 @node RS/6000 and PowerPC Pragmas
16911 @subsection RS/6000 and PowerPC Pragmas
16912
16913 The RS/6000 and PowerPC targets define one pragma for controlling
16914 whether or not the @code{longcall} attribute is added to function
16915 declarations by default. This pragma overrides the @option{-mlongcall}
16916 option, but not the @code{longcall} and @code{shortcall} attributes.
16917 @xref{RS/6000 and PowerPC Options}, for more information about when long
16918 calls are and are not necessary.
16919
16920 @table @code
16921 @item longcall (1)
16922 @cindex pragma, longcall
16923 Apply the @code{longcall} attribute to all subsequent function
16924 declarations.
16925
16926 @item longcall (0)
16927 Do not apply the @code{longcall} attribute to subsequent function
16928 declarations.
16929 @end table
16930
16931 @c Describe h8300 pragmas here.
16932 @c Describe sh pragmas here.
16933 @c Describe v850 pragmas here.
16934
16935 @node Darwin Pragmas
16936 @subsection Darwin Pragmas
16937
16938 The following pragmas are available for all architectures running the
16939 Darwin operating system. These are useful for compatibility with other
16940 Mac OS compilers.
16941
16942 @table @code
16943 @item mark @var{tokens}@dots{}
16944 @cindex pragma, mark
16945 This pragma is accepted, but has no effect.
16946
16947 @item options align=@var{alignment}
16948 @cindex pragma, options align
16949 This pragma sets the alignment of fields in structures. The values of
16950 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
16951 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
16952 properly; to restore the previous setting, use @code{reset} for the
16953 @var{alignment}.
16954
16955 @item segment @var{tokens}@dots{}
16956 @cindex pragma, segment
16957 This pragma is accepted, but has no effect.
16958
16959 @item unused (@var{var} [, @var{var}]@dots{})
16960 @cindex pragma, unused
16961 This pragma declares variables to be possibly unused. GCC does not
16962 produce warnings for the listed variables. The effect is similar to
16963 that of the @code{unused} attribute, except that this pragma may appear
16964 anywhere within the variables' scopes.
16965 @end table
16966
16967 @node Solaris Pragmas
16968 @subsection Solaris Pragmas
16969
16970 The Solaris target supports @code{#pragma redefine_extname}
16971 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
16972 @code{#pragma} directives for compatibility with the system compiler.
16973
16974 @table @code
16975 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
16976 @cindex pragma, align
16977
16978 Increase the minimum alignment of each @var{variable} to @var{alignment}.
16979 This is the same as GCC's @code{aligned} attribute @pxref{Variable
16980 Attributes}). Macro expansion occurs on the arguments to this pragma
16981 when compiling C and Objective-C@. It does not currently occur when
16982 compiling C++, but this is a bug which may be fixed in a future
16983 release.
16984
16985 @item fini (@var{function} [, @var{function}]...)
16986 @cindex pragma, fini
16987
16988 This pragma causes each listed @var{function} to be called after
16989 main, or during shared module unloading, by adding a call to the
16990 @code{.fini} section.
16991
16992 @item init (@var{function} [, @var{function}]...)
16993 @cindex pragma, init
16994
16995 This pragma causes each listed @var{function} to be called during
16996 initialization (before @code{main}) or during shared module loading, by
16997 adding a call to the @code{.init} section.
16998
16999 @end table
17000
17001 @node Symbol-Renaming Pragmas
17002 @subsection Symbol-Renaming Pragmas
17003
17004 GCC supports a @code{#pragma} directive that changes the name used in
17005 assembly for a given declaration. This effect can also be achieved
17006 using the asm labels extension (@pxref{Asm Labels}).
17007
17008 @table @code
17009 @item redefine_extname @var{oldname} @var{newname}
17010 @cindex pragma, redefine_extname
17011
17012 This pragma gives the C function @var{oldname} the assembly symbol
17013 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
17014 is defined if this pragma is available (currently on all platforms).
17015 @end table
17016
17017 This pragma and the asm labels extension interact in a complicated
17018 manner. Here are some corner cases you may want to be aware of:
17019
17020 @enumerate
17021 @item This pragma silently applies only to declarations with external
17022 linkage. Asm labels do not have this restriction.
17023
17024 @item In C++, this pragma silently applies only to declarations with
17025 ``C'' linkage. Again, asm labels do not have this restriction.
17026
17027 @item If either of the ways of changing the assembly name of a
17028 declaration are applied to a declaration whose assembly name has
17029 already been determined (either by a previous use of one of these
17030 features, or because the compiler needed the assembly name in order to
17031 generate code), and the new name is different, a warning issues and
17032 the name does not change.
17033
17034 @item The @var{oldname} used by @code{#pragma redefine_extname} is
17035 always the C-language name.
17036 @end enumerate
17037
17038 @node Structure-Packing Pragmas
17039 @subsection Structure-Packing Pragmas
17040
17041 For compatibility with Microsoft Windows compilers, GCC supports a
17042 set of @code{#pragma} directives that change the maximum alignment of
17043 members of structures (other than zero-width bit-fields), unions, and
17044 classes subsequently defined. The @var{n} value below always is required
17045 to be a small power of two and specifies the new alignment in bytes.
17046
17047 @enumerate
17048 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
17049 @item @code{#pragma pack()} sets the alignment to the one that was in
17050 effect when compilation started (see also command-line option
17051 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
17052 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
17053 setting on an internal stack and then optionally sets the new alignment.
17054 @item @code{#pragma pack(pop)} restores the alignment setting to the one
17055 saved at the top of the internal stack (and removes that stack entry).
17056 Note that @code{#pragma pack([@var{n}])} does not influence this internal
17057 stack; thus it is possible to have @code{#pragma pack(push)} followed by
17058 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
17059 @code{#pragma pack(pop)}.
17060 @end enumerate
17061
17062 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
17063 @code{#pragma} which lays out a structure as the documented
17064 @code{__attribute__ ((ms_struct))}.
17065 @enumerate
17066 @item @code{#pragma ms_struct on} turns on the layout for structures
17067 declared.
17068 @item @code{#pragma ms_struct off} turns off the layout for structures
17069 declared.
17070 @item @code{#pragma ms_struct reset} goes back to the default layout.
17071 @end enumerate
17072
17073 @node Weak Pragmas
17074 @subsection Weak Pragmas
17075
17076 For compatibility with SVR4, GCC supports a set of @code{#pragma}
17077 directives for declaring symbols to be weak, and defining weak
17078 aliases.
17079
17080 @table @code
17081 @item #pragma weak @var{symbol}
17082 @cindex pragma, weak
17083 This pragma declares @var{symbol} to be weak, as if the declaration
17084 had the attribute of the same name. The pragma may appear before
17085 or after the declaration of @var{symbol}. It is not an error for
17086 @var{symbol} to never be defined at all.
17087
17088 @item #pragma weak @var{symbol1} = @var{symbol2}
17089 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
17090 It is an error if @var{symbol2} is not defined in the current
17091 translation unit.
17092 @end table
17093
17094 @node Diagnostic Pragmas
17095 @subsection Diagnostic Pragmas
17096
17097 GCC allows the user to selectively enable or disable certain types of
17098 diagnostics, and change the kind of the diagnostic. For example, a
17099 project's policy might require that all sources compile with
17100 @option{-Werror} but certain files might have exceptions allowing
17101 specific types of warnings. Or, a project might selectively enable
17102 diagnostics and treat them as errors depending on which preprocessor
17103 macros are defined.
17104
17105 @table @code
17106 @item #pragma GCC diagnostic @var{kind} @var{option}
17107 @cindex pragma, diagnostic
17108
17109 Modifies the disposition of a diagnostic. Note that not all
17110 diagnostics are modifiable; at the moment only warnings (normally
17111 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
17112 Use @option{-fdiagnostics-show-option} to determine which diagnostics
17113 are controllable and which option controls them.
17114
17115 @var{kind} is @samp{error} to treat this diagnostic as an error,
17116 @samp{warning} to treat it like a warning (even if @option{-Werror} is
17117 in effect), or @samp{ignored} if the diagnostic is to be ignored.
17118 @var{option} is a double quoted string that matches the command-line
17119 option.
17120
17121 @smallexample
17122 #pragma GCC diagnostic warning "-Wformat"
17123 #pragma GCC diagnostic error "-Wformat"
17124 #pragma GCC diagnostic ignored "-Wformat"
17125 @end smallexample
17126
17127 Note that these pragmas override any command-line options. GCC keeps
17128 track of the location of each pragma, and issues diagnostics according
17129 to the state as of that point in the source file. Thus, pragmas occurring
17130 after a line do not affect diagnostics caused by that line.
17131
17132 @item #pragma GCC diagnostic push
17133 @itemx #pragma GCC diagnostic pop
17134
17135 Causes GCC to remember the state of the diagnostics as of each
17136 @code{push}, and restore to that point at each @code{pop}. If a
17137 @code{pop} has no matching @code{push}, the command-line options are
17138 restored.
17139
17140 @smallexample
17141 #pragma GCC diagnostic error "-Wuninitialized"
17142 foo(a); /* error is given for this one */
17143 #pragma GCC diagnostic push
17144 #pragma GCC diagnostic ignored "-Wuninitialized"
17145 foo(b); /* no diagnostic for this one */
17146 #pragma GCC diagnostic pop
17147 foo(c); /* error is given for this one */
17148 #pragma GCC diagnostic pop
17149 foo(d); /* depends on command-line options */
17150 @end smallexample
17151
17152 @end table
17153
17154 GCC also offers a simple mechanism for printing messages during
17155 compilation.
17156
17157 @table @code
17158 @item #pragma message @var{string}
17159 @cindex pragma, diagnostic
17160
17161 Prints @var{string} as a compiler message on compilation. The message
17162 is informational only, and is neither a compilation warning nor an error.
17163
17164 @smallexample
17165 #pragma message "Compiling " __FILE__ "..."
17166 @end smallexample
17167
17168 @var{string} may be parenthesized, and is printed with location
17169 information. For example,
17170
17171 @smallexample
17172 #define DO_PRAGMA(x) _Pragma (#x)
17173 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
17174
17175 TODO(Remember to fix this)
17176 @end smallexample
17177
17178 @noindent
17179 prints @samp{/tmp/file.c:4: note: #pragma message:
17180 TODO - Remember to fix this}.
17181
17182 @end table
17183
17184 @node Visibility Pragmas
17185 @subsection Visibility Pragmas
17186
17187 @table @code
17188 @item #pragma GCC visibility push(@var{visibility})
17189 @itemx #pragma GCC visibility pop
17190 @cindex pragma, visibility
17191
17192 This pragma allows the user to set the visibility for multiple
17193 declarations without having to give each a visibility attribute
17194 (@pxref{Function Attributes}).
17195
17196 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
17197 declarations. Class members and template specializations are not
17198 affected; if you want to override the visibility for a particular
17199 member or instantiation, you must use an attribute.
17200
17201 @end table
17202
17203
17204 @node Push/Pop Macro Pragmas
17205 @subsection Push/Pop Macro Pragmas
17206
17207 For compatibility with Microsoft Windows compilers, GCC supports
17208 @samp{#pragma push_macro(@var{"macro_name"})}
17209 and @samp{#pragma pop_macro(@var{"macro_name"})}.
17210
17211 @table @code
17212 @item #pragma push_macro(@var{"macro_name"})
17213 @cindex pragma, push_macro
17214 This pragma saves the value of the macro named as @var{macro_name} to
17215 the top of the stack for this macro.
17216
17217 @item #pragma pop_macro(@var{"macro_name"})
17218 @cindex pragma, pop_macro
17219 This pragma sets the value of the macro named as @var{macro_name} to
17220 the value on top of the stack for this macro. If the stack for
17221 @var{macro_name} is empty, the value of the macro remains unchanged.
17222 @end table
17223
17224 For example:
17225
17226 @smallexample
17227 #define X 1
17228 #pragma push_macro("X")
17229 #undef X
17230 #define X -1
17231 #pragma pop_macro("X")
17232 int x [X];
17233 @end smallexample
17234
17235 @noindent
17236 In this example, the definition of X as 1 is saved by @code{#pragma
17237 push_macro} and restored by @code{#pragma pop_macro}.
17238
17239 @node Function Specific Option Pragmas
17240 @subsection Function Specific Option Pragmas
17241
17242 @table @code
17243 @item #pragma GCC target (@var{"string"}...)
17244 @cindex pragma GCC target
17245
17246 This pragma allows you to set target specific options for functions
17247 defined later in the source file. One or more strings can be
17248 specified. Each function that is defined after this point is as
17249 if @code{attribute((target("STRING")))} was specified for that
17250 function. The parenthesis around the options is optional.
17251 @xref{Function Attributes}, for more information about the
17252 @code{target} attribute and the attribute syntax.
17253
17254 The @code{#pragma GCC target} pragma is presently implemented for
17255 i386/x86_64, PowerPC, and Nios II targets only.
17256 @end table
17257
17258 @table @code
17259 @item #pragma GCC optimize (@var{"string"}...)
17260 @cindex pragma GCC optimize
17261
17262 This pragma allows you to set global optimization options for functions
17263 defined later in the source file. One or more strings can be
17264 specified. Each function that is defined after this point is as
17265 if @code{attribute((optimize("STRING")))} was specified for that
17266 function. The parenthesis around the options is optional.
17267 @xref{Function Attributes}, for more information about the
17268 @code{optimize} attribute and the attribute syntax.
17269
17270 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
17271 versions earlier than 4.4.
17272 @end table
17273
17274 @table @code
17275 @item #pragma GCC push_options
17276 @itemx #pragma GCC pop_options
17277 @cindex pragma GCC push_options
17278 @cindex pragma GCC pop_options
17279
17280 These pragmas maintain a stack of the current target and optimization
17281 options. It is intended for include files where you temporarily want
17282 to switch to using a different @samp{#pragma GCC target} or
17283 @samp{#pragma GCC optimize} and then to pop back to the previous
17284 options.
17285
17286 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
17287 pragmas are not implemented in GCC versions earlier than 4.4.
17288 @end table
17289
17290 @table @code
17291 @item #pragma GCC reset_options
17292 @cindex pragma GCC reset_options
17293
17294 This pragma clears the current @code{#pragma GCC target} and
17295 @code{#pragma GCC optimize} to use the default switches as specified
17296 on the command line.
17297
17298 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
17299 versions earlier than 4.4.
17300 @end table
17301
17302 @node Loop-Specific Pragmas
17303 @subsection Loop-Specific Pragmas
17304
17305 @table @code
17306 @item #pragma GCC ivdep
17307 @cindex pragma GCC ivdep
17308 @end table
17309
17310 With this pragma, the programmer asserts that there are no loop-carried
17311 dependencies which would prevent that consecutive iterations of
17312 the following loop can be executed concurrently with SIMD
17313 (single instruction multiple data) instructions.
17314
17315 For example, the compiler can only unconditionally vectorize the following
17316 loop with the pragma:
17317
17318 @smallexample
17319 void foo (int n, int *a, int *b, int *c)
17320 @{
17321 int i, j;
17322 #pragma GCC ivdep
17323 for (i = 0; i < n; ++i)
17324 a[i] = b[i] + c[i];
17325 @}
17326 @end smallexample
17327
17328 @noindent
17329 In this example, using the @code{restrict} qualifier had the same
17330 effect. In the following example, that would not be possible. Assume
17331 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
17332 that it can unconditionally vectorize the following loop:
17333
17334 @smallexample
17335 void ignore_vec_dep (int *a, int k, int c, int m)
17336 @{
17337 #pragma GCC ivdep
17338 for (int i = 0; i < m; i++)
17339 a[i] = a[i + k] * c;
17340 @}
17341 @end smallexample
17342
17343
17344 @node Unnamed Fields
17345 @section Unnamed struct/union fields within structs/unions
17346 @cindex @code{struct}
17347 @cindex @code{union}
17348
17349 As permitted by ISO C11 and for compatibility with other compilers,
17350 GCC allows you to define
17351 a structure or union that contains, as fields, structures and unions
17352 without names. For example:
17353
17354 @smallexample
17355 struct @{
17356 int a;
17357 union @{
17358 int b;
17359 float c;
17360 @};
17361 int d;
17362 @} foo;
17363 @end smallexample
17364
17365 @noindent
17366 In this example, you are able to access members of the unnamed
17367 union with code like @samp{foo.b}. Note that only unnamed structs and
17368 unions are allowed, you may not have, for example, an unnamed
17369 @code{int}.
17370
17371 You must never create such structures that cause ambiguous field definitions.
17372 For example, in this structure:
17373
17374 @smallexample
17375 struct @{
17376 int a;
17377 struct @{
17378 int a;
17379 @};
17380 @} foo;
17381 @end smallexample
17382
17383 @noindent
17384 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
17385 The compiler gives errors for such constructs.
17386
17387 @opindex fms-extensions
17388 Unless @option{-fms-extensions} is used, the unnamed field must be a
17389 structure or union definition without a tag (for example, @samp{struct
17390 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
17391 also be a definition with a tag such as @samp{struct foo @{ int a;
17392 @};}, a reference to a previously defined structure or union such as
17393 @samp{struct foo;}, or a reference to a @code{typedef} name for a
17394 previously defined structure or union type.
17395
17396 @opindex fplan9-extensions
17397 The option @option{-fplan9-extensions} enables
17398 @option{-fms-extensions} as well as two other extensions. First, a
17399 pointer to a structure is automatically converted to a pointer to an
17400 anonymous field for assignments and function calls. For example:
17401
17402 @smallexample
17403 struct s1 @{ int a; @};
17404 struct s2 @{ struct s1; @};
17405 extern void f1 (struct s1 *);
17406 void f2 (struct s2 *p) @{ f1 (p); @}
17407 @end smallexample
17408
17409 @noindent
17410 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
17411 converted into a pointer to the anonymous field.
17412
17413 Second, when the type of an anonymous field is a @code{typedef} for a
17414 @code{struct} or @code{union}, code may refer to the field using the
17415 name of the @code{typedef}.
17416
17417 @smallexample
17418 typedef struct @{ int a; @} s1;
17419 struct s2 @{ s1; @};
17420 s1 f1 (struct s2 *p) @{ return p->s1; @}
17421 @end smallexample
17422
17423 These usages are only permitted when they are not ambiguous.
17424
17425 @node Thread-Local
17426 @section Thread-Local Storage
17427 @cindex Thread-Local Storage
17428 @cindex @acronym{TLS}
17429 @cindex @code{__thread}
17430
17431 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
17432 are allocated such that there is one instance of the variable per extant
17433 thread. The runtime model GCC uses to implement this originates
17434 in the IA-64 processor-specific ABI, but has since been migrated
17435 to other processors as well. It requires significant support from
17436 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
17437 system libraries (@file{libc.so} and @file{libpthread.so}), so it
17438 is not available everywhere.
17439
17440 At the user level, the extension is visible with a new storage
17441 class keyword: @code{__thread}. For example:
17442
17443 @smallexample
17444 __thread int i;
17445 extern __thread struct state s;
17446 static __thread char *p;
17447 @end smallexample
17448
17449 The @code{__thread} specifier may be used alone, with the @code{extern}
17450 or @code{static} specifiers, but with no other storage class specifier.
17451 When used with @code{extern} or @code{static}, @code{__thread} must appear
17452 immediately after the other storage class specifier.
17453
17454 The @code{__thread} specifier may be applied to any global, file-scoped
17455 static, function-scoped static, or static data member of a class. It may
17456 not be applied to block-scoped automatic or non-static data member.
17457
17458 When the address-of operator is applied to a thread-local variable, it is
17459 evaluated at run time and returns the address of the current thread's
17460 instance of that variable. An address so obtained may be used by any
17461 thread. When a thread terminates, any pointers to thread-local variables
17462 in that thread become invalid.
17463
17464 No static initialization may refer to the address of a thread-local variable.
17465
17466 In C++, if an initializer is present for a thread-local variable, it must
17467 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
17468 standard.
17469
17470 See @uref{http://www.akkadia.org/drepper/tls.pdf,
17471 ELF Handling For Thread-Local Storage} for a detailed explanation of
17472 the four thread-local storage addressing models, and how the runtime
17473 is expected to function.
17474
17475 @menu
17476 * C99 Thread-Local Edits::
17477 * C++98 Thread-Local Edits::
17478 @end menu
17479
17480 @node C99 Thread-Local Edits
17481 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
17482
17483 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
17484 that document the exact semantics of the language extension.
17485
17486 @itemize @bullet
17487 @item
17488 @cite{5.1.2 Execution environments}
17489
17490 Add new text after paragraph 1
17491
17492 @quotation
17493 Within either execution environment, a @dfn{thread} is a flow of
17494 control within a program. It is implementation defined whether
17495 or not there may be more than one thread associated with a program.
17496 It is implementation defined how threads beyond the first are
17497 created, the name and type of the function called at thread
17498 startup, and how threads may be terminated. However, objects
17499 with thread storage duration shall be initialized before thread
17500 startup.
17501 @end quotation
17502
17503 @item
17504 @cite{6.2.4 Storage durations of objects}
17505
17506 Add new text before paragraph 3
17507
17508 @quotation
17509 An object whose identifier is declared with the storage-class
17510 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
17511 Its lifetime is the entire execution of the thread, and its
17512 stored value is initialized only once, prior to thread startup.
17513 @end quotation
17514
17515 @item
17516 @cite{6.4.1 Keywords}
17517
17518 Add @code{__thread}.
17519
17520 @item
17521 @cite{6.7.1 Storage-class specifiers}
17522
17523 Add @code{__thread} to the list of storage class specifiers in
17524 paragraph 1.
17525
17526 Change paragraph 2 to
17527
17528 @quotation
17529 With the exception of @code{__thread}, at most one storage-class
17530 specifier may be given [@dots{}]. The @code{__thread} specifier may
17531 be used alone, or immediately following @code{extern} or
17532 @code{static}.
17533 @end quotation
17534
17535 Add new text after paragraph 6
17536
17537 @quotation
17538 The declaration of an identifier for a variable that has
17539 block scope that specifies @code{__thread} shall also
17540 specify either @code{extern} or @code{static}.
17541
17542 The @code{__thread} specifier shall be used only with
17543 variables.
17544 @end quotation
17545 @end itemize
17546
17547 @node C++98 Thread-Local Edits
17548 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
17549
17550 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
17551 that document the exact semantics of the language extension.
17552
17553 @itemize @bullet
17554 @item
17555 @b{[intro.execution]}
17556
17557 New text after paragraph 4
17558
17559 @quotation
17560 A @dfn{thread} is a flow of control within the abstract machine.
17561 It is implementation defined whether or not there may be more than
17562 one thread.
17563 @end quotation
17564
17565 New text after paragraph 7
17566
17567 @quotation
17568 It is unspecified whether additional action must be taken to
17569 ensure when and whether side effects are visible to other threads.
17570 @end quotation
17571
17572 @item
17573 @b{[lex.key]}
17574
17575 Add @code{__thread}.
17576
17577 @item
17578 @b{[basic.start.main]}
17579
17580 Add after paragraph 5
17581
17582 @quotation
17583 The thread that begins execution at the @code{main} function is called
17584 the @dfn{main thread}. It is implementation defined how functions
17585 beginning threads other than the main thread are designated or typed.
17586 A function so designated, as well as the @code{main} function, is called
17587 a @dfn{thread startup function}. It is implementation defined what
17588 happens if a thread startup function returns. It is implementation
17589 defined what happens to other threads when any thread calls @code{exit}.
17590 @end quotation
17591
17592 @item
17593 @b{[basic.start.init]}
17594
17595 Add after paragraph 4
17596
17597 @quotation
17598 The storage for an object of thread storage duration shall be
17599 statically initialized before the first statement of the thread startup
17600 function. An object of thread storage duration shall not require
17601 dynamic initialization.
17602 @end quotation
17603
17604 @item
17605 @b{[basic.start.term]}
17606
17607 Add after paragraph 3
17608
17609 @quotation
17610 The type of an object with thread storage duration shall not have a
17611 non-trivial destructor, nor shall it be an array type whose elements
17612 (directly or indirectly) have non-trivial destructors.
17613 @end quotation
17614
17615 @item
17616 @b{[basic.stc]}
17617
17618 Add ``thread storage duration'' to the list in paragraph 1.
17619
17620 Change paragraph 2
17621
17622 @quotation
17623 Thread, static, and automatic storage durations are associated with
17624 objects introduced by declarations [@dots{}].
17625 @end quotation
17626
17627 Add @code{__thread} to the list of specifiers in paragraph 3.
17628
17629 @item
17630 @b{[basic.stc.thread]}
17631
17632 New section before @b{[basic.stc.static]}
17633
17634 @quotation
17635 The keyword @code{__thread} applied to a non-local object gives the
17636 object thread storage duration.
17637
17638 A local variable or class data member declared both @code{static}
17639 and @code{__thread} gives the variable or member thread storage
17640 duration.
17641 @end quotation
17642
17643 @item
17644 @b{[basic.stc.static]}
17645
17646 Change paragraph 1
17647
17648 @quotation
17649 All objects that have neither thread storage duration, dynamic
17650 storage duration nor are local [@dots{}].
17651 @end quotation
17652
17653 @item
17654 @b{[dcl.stc]}
17655
17656 Add @code{__thread} to the list in paragraph 1.
17657
17658 Change paragraph 1
17659
17660 @quotation
17661 With the exception of @code{__thread}, at most one
17662 @var{storage-class-specifier} shall appear in a given
17663 @var{decl-specifier-seq}. The @code{__thread} specifier may
17664 be used alone, or immediately following the @code{extern} or
17665 @code{static} specifiers. [@dots{}]
17666 @end quotation
17667
17668 Add after paragraph 5
17669
17670 @quotation
17671 The @code{__thread} specifier can be applied only to the names of objects
17672 and to anonymous unions.
17673 @end quotation
17674
17675 @item
17676 @b{[class.mem]}
17677
17678 Add after paragraph 6
17679
17680 @quotation
17681 Non-@code{static} members shall not be @code{__thread}.
17682 @end quotation
17683 @end itemize
17684
17685 @node Binary constants
17686 @section Binary constants using the @samp{0b} prefix
17687 @cindex Binary constants using the @samp{0b} prefix
17688
17689 Integer constants can be written as binary constants, consisting of a
17690 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
17691 @samp{0B}. This is particularly useful in environments that operate a
17692 lot on the bit level (like microcontrollers).
17693
17694 The following statements are identical:
17695
17696 @smallexample
17697 i = 42;
17698 i = 0x2a;
17699 i = 052;
17700 i = 0b101010;
17701 @end smallexample
17702
17703 The type of these constants follows the same rules as for octal or
17704 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
17705 can be applied.
17706
17707 @node C++ Extensions
17708 @chapter Extensions to the C++ Language
17709 @cindex extensions, C++ language
17710 @cindex C++ language extensions
17711
17712 The GNU compiler provides these extensions to the C++ language (and you
17713 can also use most of the C language extensions in your C++ programs). If you
17714 want to write code that checks whether these features are available, you can
17715 test for the GNU compiler the same way as for C programs: check for a
17716 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
17717 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
17718 Predefined Macros,cpp,The GNU C Preprocessor}).
17719
17720 @menu
17721 * C++ Volatiles:: What constitutes an access to a volatile object.
17722 * Restricted Pointers:: C99 restricted pointers and references.
17723 * Vague Linkage:: Where G++ puts inlines, vtables and such.
17724 * C++ Interface:: You can use a single C++ header file for both
17725 declarations and definitions.
17726 * Template Instantiation:: Methods for ensuring that exactly one copy of
17727 each needed template instantiation is emitted.
17728 * Bound member functions:: You can extract a function pointer to the
17729 method denoted by a @samp{->*} or @samp{.*} expression.
17730 * C++ Attributes:: Variable, function, and type attributes for C++ only.
17731 * Function Multiversioning:: Declaring multiple function versions.
17732 * Namespace Association:: Strong using-directives for namespace association.
17733 * Type Traits:: Compiler support for type traits
17734 * Java Exceptions:: Tweaking exception handling to work with Java.
17735 * Deprecated Features:: Things will disappear from G++.
17736 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
17737 @end menu
17738
17739 @node C++ Volatiles
17740 @section When is a Volatile C++ Object Accessed?
17741 @cindex accessing volatiles
17742 @cindex volatile read
17743 @cindex volatile write
17744 @cindex volatile access
17745
17746 The C++ standard differs from the C standard in its treatment of
17747 volatile objects. It fails to specify what constitutes a volatile
17748 access, except to say that C++ should behave in a similar manner to C
17749 with respect to volatiles, where possible. However, the different
17750 lvalueness of expressions between C and C++ complicate the behavior.
17751 G++ behaves the same as GCC for volatile access, @xref{C
17752 Extensions,,Volatiles}, for a description of GCC's behavior.
17753
17754 The C and C++ language specifications differ when an object is
17755 accessed in a void context:
17756
17757 @smallexample
17758 volatile int *src = @var{somevalue};
17759 *src;
17760 @end smallexample
17761
17762 The C++ standard specifies that such expressions do not undergo lvalue
17763 to rvalue conversion, and that the type of the dereferenced object may
17764 be incomplete. The C++ standard does not specify explicitly that it
17765 is lvalue to rvalue conversion that is responsible for causing an
17766 access. There is reason to believe that it is, because otherwise
17767 certain simple expressions become undefined. However, because it
17768 would surprise most programmers, G++ treats dereferencing a pointer to
17769 volatile object of complete type as GCC would do for an equivalent
17770 type in C@. When the object has incomplete type, G++ issues a
17771 warning; if you wish to force an error, you must force a conversion to
17772 rvalue with, for instance, a static cast.
17773
17774 When using a reference to volatile, G++ does not treat equivalent
17775 expressions as accesses to volatiles, but instead issues a warning that
17776 no volatile is accessed. The rationale for this is that otherwise it
17777 becomes difficult to determine where volatile access occur, and not
17778 possible to ignore the return value from functions returning volatile
17779 references. Again, if you wish to force a read, cast the reference to
17780 an rvalue.
17781
17782 G++ implements the same behavior as GCC does when assigning to a
17783 volatile object---there is no reread of the assigned-to object, the
17784 assigned rvalue is reused. Note that in C++ assignment expressions
17785 are lvalues, and if used as an lvalue, the volatile object is
17786 referred to. For instance, @var{vref} refers to @var{vobj}, as
17787 expected, in the following example:
17788
17789 @smallexample
17790 volatile int vobj;
17791 volatile int &vref = vobj = @var{something};
17792 @end smallexample
17793
17794 @node Restricted Pointers
17795 @section Restricting Pointer Aliasing
17796 @cindex restricted pointers
17797 @cindex restricted references
17798 @cindex restricted this pointer
17799
17800 As with the C front end, G++ understands the C99 feature of restricted pointers,
17801 specified with the @code{__restrict__}, or @code{__restrict} type
17802 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
17803 language flag, @code{restrict} is not a keyword in C++.
17804
17805 In addition to allowing restricted pointers, you can specify restricted
17806 references, which indicate that the reference is not aliased in the local
17807 context.
17808
17809 @smallexample
17810 void fn (int *__restrict__ rptr, int &__restrict__ rref)
17811 @{
17812 /* @r{@dots{}} */
17813 @}
17814 @end smallexample
17815
17816 @noindent
17817 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
17818 @var{rref} refers to a (different) unaliased integer.
17819
17820 You may also specify whether a member function's @var{this} pointer is
17821 unaliased by using @code{__restrict__} as a member function qualifier.
17822
17823 @smallexample
17824 void T::fn () __restrict__
17825 @{
17826 /* @r{@dots{}} */
17827 @}
17828 @end smallexample
17829
17830 @noindent
17831 Within the body of @code{T::fn}, @var{this} has the effective
17832 definition @code{T *__restrict__ const this}. Notice that the
17833 interpretation of a @code{__restrict__} member function qualifier is
17834 different to that of @code{const} or @code{volatile} qualifier, in that it
17835 is applied to the pointer rather than the object. This is consistent with
17836 other compilers that implement restricted pointers.
17837
17838 As with all outermost parameter qualifiers, @code{__restrict__} is
17839 ignored in function definition matching. This means you only need to
17840 specify @code{__restrict__} in a function definition, rather than
17841 in a function prototype as well.
17842
17843 @node Vague Linkage
17844 @section Vague Linkage
17845 @cindex vague linkage
17846
17847 There are several constructs in C++ that require space in the object
17848 file but are not clearly tied to a single translation unit. We say that
17849 these constructs have ``vague linkage''. Typically such constructs are
17850 emitted wherever they are needed, though sometimes we can be more
17851 clever.
17852
17853 @table @asis
17854 @item Inline Functions
17855 Inline functions are typically defined in a header file which can be
17856 included in many different compilations. Hopefully they can usually be
17857 inlined, but sometimes an out-of-line copy is necessary, if the address
17858 of the function is taken or if inlining fails. In general, we emit an
17859 out-of-line copy in all translation units where one is needed. As an
17860 exception, we only emit inline virtual functions with the vtable, since
17861 it always requires a copy.
17862
17863 Local static variables and string constants used in an inline function
17864 are also considered to have vague linkage, since they must be shared
17865 between all inlined and out-of-line instances of the function.
17866
17867 @item VTables
17868 @cindex vtable
17869 C++ virtual functions are implemented in most compilers using a lookup
17870 table, known as a vtable. The vtable contains pointers to the virtual
17871 functions provided by a class, and each object of the class contains a
17872 pointer to its vtable (or vtables, in some multiple-inheritance
17873 situations). If the class declares any non-inline, non-pure virtual
17874 functions, the first one is chosen as the ``key method'' for the class,
17875 and the vtable is only emitted in the translation unit where the key
17876 method is defined.
17877
17878 @emph{Note:} If the chosen key method is later defined as inline, the
17879 vtable is still emitted in every translation unit that defines it.
17880 Make sure that any inline virtuals are declared inline in the class
17881 body, even if they are not defined there.
17882
17883 @item @code{type_info} objects
17884 @cindex @code{type_info}
17885 @cindex RTTI
17886 C++ requires information about types to be written out in order to
17887 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
17888 For polymorphic classes (classes with virtual functions), the @samp{type_info}
17889 object is written out along with the vtable so that @samp{dynamic_cast}
17890 can determine the dynamic type of a class object at run time. For all
17891 other types, we write out the @samp{type_info} object when it is used: when
17892 applying @samp{typeid} to an expression, throwing an object, or
17893 referring to a type in a catch clause or exception specification.
17894
17895 @item Template Instantiations
17896 Most everything in this section also applies to template instantiations,
17897 but there are other options as well.
17898 @xref{Template Instantiation,,Where's the Template?}.
17899
17900 @end table
17901
17902 When used with GNU ld version 2.8 or later on an ELF system such as
17903 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
17904 these constructs will be discarded at link time. This is known as
17905 COMDAT support.
17906
17907 On targets that don't support COMDAT, but do support weak symbols, GCC
17908 uses them. This way one copy overrides all the others, but
17909 the unused copies still take up space in the executable.
17910
17911 For targets that do not support either COMDAT or weak symbols,
17912 most entities with vague linkage are emitted as local symbols to
17913 avoid duplicate definition errors from the linker. This does not happen
17914 for local statics in inlines, however, as having multiple copies
17915 almost certainly breaks things.
17916
17917 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
17918 another way to control placement of these constructs.
17919
17920 @node C++ Interface
17921 @section #pragma interface and implementation
17922
17923 @cindex interface and implementation headers, C++
17924 @cindex C++ interface and implementation headers
17925 @cindex pragmas, interface and implementation
17926
17927 @code{#pragma interface} and @code{#pragma implementation} provide the
17928 user with a way of explicitly directing the compiler to emit entities
17929 with vague linkage (and debugging information) in a particular
17930 translation unit.
17931
17932 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
17933 most cases, because of COMDAT support and the ``key method'' heuristic
17934 mentioned in @ref{Vague Linkage}. Using them can actually cause your
17935 program to grow due to unnecessary out-of-line copies of inline
17936 functions. Currently (3.4) the only benefit of these
17937 @code{#pragma}s is reduced duplication of debugging information, and
17938 that should be addressed soon on DWARF 2 targets with the use of
17939 COMDAT groups.
17940
17941 @table @code
17942 @item #pragma interface
17943 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
17944 @kindex #pragma interface
17945 Use this directive in @emph{header files} that define object classes, to save
17946 space in most of the object files that use those classes. Normally,
17947 local copies of certain information (backup copies of inline member
17948 functions, debugging information, and the internal tables that implement
17949 virtual functions) must be kept in each object file that includes class
17950 definitions. You can use this pragma to avoid such duplication. When a
17951 header file containing @samp{#pragma interface} is included in a
17952 compilation, this auxiliary information is not generated (unless
17953 the main input source file itself uses @samp{#pragma implementation}).
17954 Instead, the object files contain references to be resolved at link
17955 time.
17956
17957 The second form of this directive is useful for the case where you have
17958 multiple headers with the same name in different directories. If you
17959 use this form, you must specify the same string to @samp{#pragma
17960 implementation}.
17961
17962 @item #pragma implementation
17963 @itemx #pragma implementation "@var{objects}.h"
17964 @kindex #pragma implementation
17965 Use this pragma in a @emph{main input file}, when you want full output from
17966 included header files to be generated (and made globally visible). The
17967 included header file, in turn, should use @samp{#pragma interface}.
17968 Backup copies of inline member functions, debugging information, and the
17969 internal tables used to implement virtual functions are all generated in
17970 implementation files.
17971
17972 @cindex implied @code{#pragma implementation}
17973 @cindex @code{#pragma implementation}, implied
17974 @cindex naming convention, implementation headers
17975 If you use @samp{#pragma implementation} with no argument, it applies to
17976 an include file with the same basename@footnote{A file's @dfn{basename}
17977 is the name stripped of all leading path information and of trailing
17978 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
17979 file. For example, in @file{allclass.cc}, giving just
17980 @samp{#pragma implementation}
17981 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
17982
17983 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
17984 an implementation file whenever you would include it from
17985 @file{allclass.cc} even if you never specified @samp{#pragma
17986 implementation}. This was deemed to be more trouble than it was worth,
17987 however, and disabled.
17988
17989 Use the string argument if you want a single implementation file to
17990 include code from multiple header files. (You must also use
17991 @samp{#include} to include the header file; @samp{#pragma
17992 implementation} only specifies how to use the file---it doesn't actually
17993 include it.)
17994
17995 There is no way to split up the contents of a single header file into
17996 multiple implementation files.
17997 @end table
17998
17999 @cindex inlining and C++ pragmas
18000 @cindex C++ pragmas, effect on inlining
18001 @cindex pragmas in C++, effect on inlining
18002 @samp{#pragma implementation} and @samp{#pragma interface} also have an
18003 effect on function inlining.
18004
18005 If you define a class in a header file marked with @samp{#pragma
18006 interface}, the effect on an inline function defined in that class is
18007 similar to an explicit @code{extern} declaration---the compiler emits
18008 no code at all to define an independent version of the function. Its
18009 definition is used only for inlining with its callers.
18010
18011 @opindex fno-implement-inlines
18012 Conversely, when you include the same header file in a main source file
18013 that declares it as @samp{#pragma implementation}, the compiler emits
18014 code for the function itself; this defines a version of the function
18015 that can be found via pointers (or by callers compiled without
18016 inlining). If all calls to the function can be inlined, you can avoid
18017 emitting the function by compiling with @option{-fno-implement-inlines}.
18018 If any calls are not inlined, you will get linker errors.
18019
18020 @node Template Instantiation
18021 @section Where's the Template?
18022 @cindex template instantiation
18023
18024 C++ templates are the first language feature to require more
18025 intelligence from the environment than one usually finds on a UNIX
18026 system. Somehow the compiler and linker have to make sure that each
18027 template instance occurs exactly once in the executable if it is needed,
18028 and not at all otherwise. There are two basic approaches to this
18029 problem, which are referred to as the Borland model and the Cfront model.
18030
18031 @table @asis
18032 @item Borland model
18033 Borland C++ solved the template instantiation problem by adding the code
18034 equivalent of common blocks to their linker; the compiler emits template
18035 instances in each translation unit that uses them, and the linker
18036 collapses them together. The advantage of this model is that the linker
18037 only has to consider the object files themselves; there is no external
18038 complexity to worry about. This disadvantage is that compilation time
18039 is increased because the template code is being compiled repeatedly.
18040 Code written for this model tends to include definitions of all
18041 templates in the header file, since they must be seen to be
18042 instantiated.
18043
18044 @item Cfront model
18045 The AT&T C++ translator, Cfront, solved the template instantiation
18046 problem by creating the notion of a template repository, an
18047 automatically maintained place where template instances are stored. A
18048 more modern version of the repository works as follows: As individual
18049 object files are built, the compiler places any template definitions and
18050 instantiations encountered in the repository. At link time, the link
18051 wrapper adds in the objects in the repository and compiles any needed
18052 instances that were not previously emitted. The advantages of this
18053 model are more optimal compilation speed and the ability to use the
18054 system linker; to implement the Borland model a compiler vendor also
18055 needs to replace the linker. The disadvantages are vastly increased
18056 complexity, and thus potential for error; for some code this can be
18057 just as transparent, but in practice it can been very difficult to build
18058 multiple programs in one directory and one program in multiple
18059 directories. Code written for this model tends to separate definitions
18060 of non-inline member templates into a separate file, which should be
18061 compiled separately.
18062 @end table
18063
18064 When used with GNU ld version 2.8 or later on an ELF system such as
18065 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
18066 Borland model. On other systems, G++ implements neither automatic
18067 model.
18068
18069 You have the following options for dealing with template instantiations:
18070
18071 @enumerate
18072 @item
18073 @opindex frepo
18074 Compile your template-using code with @option{-frepo}. The compiler
18075 generates files with the extension @samp{.rpo} listing all of the
18076 template instantiations used in the corresponding object files that
18077 could be instantiated there; the link wrapper, @samp{collect2},
18078 then updates the @samp{.rpo} files to tell the compiler where to place
18079 those instantiations and rebuild any affected object files. The
18080 link-time overhead is negligible after the first pass, as the compiler
18081 continues to place the instantiations in the same files.
18082
18083 This is your best option for application code written for the Borland
18084 model, as it just works. Code written for the Cfront model
18085 needs to be modified so that the template definitions are available at
18086 one or more points of instantiation; usually this is as simple as adding
18087 @code{#include <tmethods.cc>} to the end of each template header.
18088
18089 For library code, if you want the library to provide all of the template
18090 instantiations it needs, just try to link all of its object files
18091 together; the link will fail, but cause the instantiations to be
18092 generated as a side effect. Be warned, however, that this may cause
18093 conflicts if multiple libraries try to provide the same instantiations.
18094 For greater control, use explicit instantiation as described in the next
18095 option.
18096
18097 @item
18098 @opindex fno-implicit-templates
18099 Compile your code with @option{-fno-implicit-templates} to disable the
18100 implicit generation of template instances, and explicitly instantiate
18101 all the ones you use. This approach requires more knowledge of exactly
18102 which instances you need than do the others, but it's less
18103 mysterious and allows greater control. You can scatter the explicit
18104 instantiations throughout your program, perhaps putting them in the
18105 translation units where the instances are used or the translation units
18106 that define the templates themselves; you can put all of the explicit
18107 instantiations you need into one big file; or you can create small files
18108 like
18109
18110 @smallexample
18111 #include "Foo.h"
18112 #include "Foo.cc"
18113
18114 template class Foo<int>;
18115 template ostream& operator <<
18116 (ostream&, const Foo<int>&);
18117 @end smallexample
18118
18119 @noindent
18120 for each of the instances you need, and create a template instantiation
18121 library from those.
18122
18123 If you are using Cfront-model code, you can probably get away with not
18124 using @option{-fno-implicit-templates} when compiling files that don't
18125 @samp{#include} the member template definitions.
18126
18127 If you use one big file to do the instantiations, you may want to
18128 compile it without @option{-fno-implicit-templates} so you get all of the
18129 instances required by your explicit instantiations (but not by any
18130 other files) without having to specify them as well.
18131
18132 The ISO C++ 2011 standard allows forward declaration of explicit
18133 instantiations (with @code{extern}). G++ supports explicit instantiation
18134 declarations in C++98 mode and has extended the template instantiation
18135 syntax to support instantiation of the compiler support data for a
18136 template class (i.e.@: the vtable) without instantiating any of its
18137 members (with @code{inline}), and instantiation of only the static data
18138 members of a template class, without the support data or member
18139 functions (with (@code{static}):
18140
18141 @smallexample
18142 extern template int max (int, int);
18143 inline template class Foo<int>;
18144 static template class Foo<int>;
18145 @end smallexample
18146
18147 @item
18148 Do nothing. Pretend G++ does implement automatic instantiation
18149 management. Code written for the Borland model works fine, but
18150 each translation unit contains instances of each of the templates it
18151 uses. In a large program, this can lead to an unacceptable amount of code
18152 duplication.
18153 @end enumerate
18154
18155 @node Bound member functions
18156 @section Extracting the function pointer from a bound pointer to member function
18157 @cindex pmf
18158 @cindex pointer to member function
18159 @cindex bound pointer to member function
18160
18161 In C++, pointer to member functions (PMFs) are implemented using a wide
18162 pointer of sorts to handle all the possible call mechanisms; the PMF
18163 needs to store information about how to adjust the @samp{this} pointer,
18164 and if the function pointed to is virtual, where to find the vtable, and
18165 where in the vtable to look for the member function. If you are using
18166 PMFs in an inner loop, you should really reconsider that decision. If
18167 that is not an option, you can extract the pointer to the function that
18168 would be called for a given object/PMF pair and call it directly inside
18169 the inner loop, to save a bit of time.
18170
18171 Note that you still pay the penalty for the call through a
18172 function pointer; on most modern architectures, such a call defeats the
18173 branch prediction features of the CPU@. This is also true of normal
18174 virtual function calls.
18175
18176 The syntax for this extension is
18177
18178 @smallexample
18179 extern A a;
18180 extern int (A::*fp)();
18181 typedef int (*fptr)(A *);
18182
18183 fptr p = (fptr)(a.*fp);
18184 @end smallexample
18185
18186 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
18187 no object is needed to obtain the address of the function. They can be
18188 converted to function pointers directly:
18189
18190 @smallexample
18191 fptr p1 = (fptr)(&A::foo);
18192 @end smallexample
18193
18194 @opindex Wno-pmf-conversions
18195 You must specify @option{-Wno-pmf-conversions} to use this extension.
18196
18197 @node C++ Attributes
18198 @section C++-Specific Variable, Function, and Type Attributes
18199
18200 Some attributes only make sense for C++ programs.
18201
18202 @table @code
18203 @item abi_tag ("@var{tag}", ...)
18204 @cindex @code{abi_tag} attribute
18205 The @code{abi_tag} attribute can be applied to a function or class
18206 declaration. It modifies the mangled name of the function or class to
18207 incorporate the tag name, in order to distinguish the function or
18208 class from an earlier version with a different ABI; perhaps the class
18209 has changed size, or the function has a different return type that is
18210 not encoded in the mangled name.
18211
18212 The argument can be a list of strings of arbitrary length. The
18213 strings are sorted on output, so the order of the list is
18214 unimportant.
18215
18216 A redeclaration of a function or class must not add new ABI tags,
18217 since doing so would change the mangled name.
18218
18219 The ABI tags apply to a name, so all instantiations and
18220 specializations of a template have the same tags. The attribute will
18221 be ignored if applied to an explicit specialization or instantiation.
18222
18223 The @option{-Wabi-tag} flag enables a warning about a class which does
18224 not have all the ABI tags used by its subobjects and virtual functions; for users with code
18225 that needs to coexist with an earlier ABI, using this option can help
18226 to find all affected types that need to be tagged.
18227
18228 @item init_priority (@var{priority})
18229 @cindex @code{init_priority} attribute
18230
18231
18232 In Standard C++, objects defined at namespace scope are guaranteed to be
18233 initialized in an order in strict accordance with that of their definitions
18234 @emph{in a given translation unit}. No guarantee is made for initializations
18235 across translation units. However, GNU C++ allows users to control the
18236 order of initialization of objects defined at namespace scope with the
18237 @code{init_priority} attribute by specifying a relative @var{priority},
18238 a constant integral expression currently bounded between 101 and 65535
18239 inclusive. Lower numbers indicate a higher priority.
18240
18241 In the following example, @code{A} would normally be created before
18242 @code{B}, but the @code{init_priority} attribute reverses that order:
18243
18244 @smallexample
18245 Some_Class A __attribute__ ((init_priority (2000)));
18246 Some_Class B __attribute__ ((init_priority (543)));
18247 @end smallexample
18248
18249 @noindent
18250 Note that the particular values of @var{priority} do not matter; only their
18251 relative ordering.
18252
18253 @item java_interface
18254 @cindex @code{java_interface} attribute
18255
18256 This type attribute informs C++ that the class is a Java interface. It may
18257 only be applied to classes declared within an @code{extern "Java"} block.
18258 Calls to methods declared in this interface are dispatched using GCJ's
18259 interface table mechanism, instead of regular virtual table dispatch.
18260
18261 @item warn_unused
18262 @cindex @code{warn_unused} attribute
18263
18264 For C++ types with non-trivial constructors and/or destructors it is
18265 impossible for the compiler to determine whether a variable of this
18266 type is truly unused if it is not referenced. This type attribute
18267 informs the compiler that variables of this type should be warned
18268 about if they appear to be unused, just like variables of fundamental
18269 types.
18270
18271 This attribute is appropriate for types which just represent a value,
18272 such as @code{std::string}; it is not appropriate for types which
18273 control a resource, such as @code{std::mutex}.
18274
18275 This attribute is also accepted in C, but it is unnecessary because C
18276 does not have constructors or destructors.
18277
18278 @end table
18279
18280 See also @ref{Namespace Association}.
18281
18282 @node Function Multiversioning
18283 @section Function Multiversioning
18284 @cindex function versions
18285
18286 With the GNU C++ front end, for target i386, you may specify multiple
18287 versions of a function, where each function is specialized for a
18288 specific target feature. At runtime, the appropriate version of the
18289 function is automatically executed depending on the characteristics of
18290 the execution platform. Here is an example.
18291
18292 @smallexample
18293 __attribute__ ((target ("default")))
18294 int foo ()
18295 @{
18296 // The default version of foo.
18297 return 0;
18298 @}
18299
18300 __attribute__ ((target ("sse4.2")))
18301 int foo ()
18302 @{
18303 // foo version for SSE4.2
18304 return 1;
18305 @}
18306
18307 __attribute__ ((target ("arch=atom")))
18308 int foo ()
18309 @{
18310 // foo version for the Intel ATOM processor
18311 return 2;
18312 @}
18313
18314 __attribute__ ((target ("arch=amdfam10")))
18315 int foo ()
18316 @{
18317 // foo version for the AMD Family 0x10 processors.
18318 return 3;
18319 @}
18320
18321 int main ()
18322 @{
18323 int (*p)() = &foo;
18324 assert ((*p) () == foo ());
18325 return 0;
18326 @}
18327 @end smallexample
18328
18329 In the above example, four versions of function foo are created. The
18330 first version of foo with the target attribute "default" is the default
18331 version. This version gets executed when no other target specific
18332 version qualifies for execution on a particular platform. A new version
18333 of foo is created by using the same function signature but with a
18334 different target string. Function foo is called or a pointer to it is
18335 taken just like a regular function. GCC takes care of doing the
18336 dispatching to call the right version at runtime. Refer to the
18337 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
18338 Function Multiversioning} for more details.
18339
18340 @node Namespace Association
18341 @section Namespace Association
18342
18343 @strong{Caution:} The semantics of this extension are equivalent
18344 to C++ 2011 inline namespaces. Users should use inline namespaces
18345 instead as this extension will be removed in future versions of G++.
18346
18347 A using-directive with @code{__attribute ((strong))} is stronger
18348 than a normal using-directive in two ways:
18349
18350 @itemize @bullet
18351 @item
18352 Templates from the used namespace can be specialized and explicitly
18353 instantiated as though they were members of the using namespace.
18354
18355 @item
18356 The using namespace is considered an associated namespace of all
18357 templates in the used namespace for purposes of argument-dependent
18358 name lookup.
18359 @end itemize
18360
18361 The used namespace must be nested within the using namespace so that
18362 normal unqualified lookup works properly.
18363
18364 This is useful for composing a namespace transparently from
18365 implementation namespaces. For example:
18366
18367 @smallexample
18368 namespace std @{
18369 namespace debug @{
18370 template <class T> struct A @{ @};
18371 @}
18372 using namespace debug __attribute ((__strong__));
18373 template <> struct A<int> @{ @}; // @r{OK to specialize}
18374
18375 template <class T> void f (A<T>);
18376 @}
18377
18378 int main()
18379 @{
18380 f (std::A<float>()); // @r{lookup finds} std::f
18381 f (std::A<int>());
18382 @}
18383 @end smallexample
18384
18385 @node Type Traits
18386 @section Type Traits
18387
18388 The C++ front end implements syntactic extensions that allow
18389 compile-time determination of
18390 various characteristics of a type (or of a
18391 pair of types).
18392
18393 @table @code
18394 @item __has_nothrow_assign (type)
18395 If @code{type} is const qualified or is a reference type then the trait is
18396 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
18397 is true, else if @code{type} is a cv class or union type with copy assignment
18398 operators that are known not to throw an exception then the trait is true,
18399 else it is false. Requires: @code{type} shall be a complete type,
18400 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18401
18402 @item __has_nothrow_copy (type)
18403 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
18404 @code{type} is a cv class or union type with copy constructors that
18405 are known not to throw an exception then the trait is true, else it is false.
18406 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
18407 @code{void}, or an array of unknown bound.
18408
18409 @item __has_nothrow_constructor (type)
18410 If @code{__has_trivial_constructor (type)} is true then the trait is
18411 true, else if @code{type} is a cv class or union type (or array
18412 thereof) with a default constructor that is known not to throw an
18413 exception then the trait is true, else it is false. Requires:
18414 @code{type} shall be a complete type, (possibly cv-qualified)
18415 @code{void}, or an array of unknown bound.
18416
18417 @item __has_trivial_assign (type)
18418 If @code{type} is const qualified or is a reference type then the trait is
18419 false. Otherwise if @code{__is_pod (type)} is true then the trait is
18420 true, else if @code{type} is a cv class or union type with a trivial
18421 copy assignment ([class.copy]) then the trait is true, else it is
18422 false. Requires: @code{type} shall be a complete type, (possibly
18423 cv-qualified) @code{void}, or an array of unknown bound.
18424
18425 @item __has_trivial_copy (type)
18426 If @code{__is_pod (type)} is true or @code{type} is a reference type
18427 then the trait is true, else if @code{type} is a cv class or union type
18428 with a trivial copy constructor ([class.copy]) then the trait
18429 is true, else it is false. Requires: @code{type} shall be a complete
18430 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18431
18432 @item __has_trivial_constructor (type)
18433 If @code{__is_pod (type)} is true then the trait is true, else if
18434 @code{type} is a cv class or union type (or array thereof) with a
18435 trivial default constructor ([class.ctor]) then the trait is true,
18436 else it is false. Requires: @code{type} shall be a complete
18437 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18438
18439 @item __has_trivial_destructor (type)
18440 If @code{__is_pod (type)} is true or @code{type} is a reference type then
18441 the trait is true, else if @code{type} is a cv class or union type (or
18442 array thereof) with a trivial destructor ([class.dtor]) then the trait
18443 is true, else it is false. Requires: @code{type} shall be a complete
18444 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18445
18446 @item __has_virtual_destructor (type)
18447 If @code{type} is a class type with a virtual destructor
18448 ([class.dtor]) then the trait is true, else it is false. Requires:
18449 @code{type} shall be a complete type, (possibly cv-qualified)
18450 @code{void}, or an array of unknown bound.
18451
18452 @item __is_abstract (type)
18453 If @code{type} is an abstract class ([class.abstract]) then the trait
18454 is true, else it is false. Requires: @code{type} shall be a complete
18455 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18456
18457 @item __is_base_of (base_type, derived_type)
18458 If @code{base_type} is a base class of @code{derived_type}
18459 ([class.derived]) then the trait is true, otherwise it is false.
18460 Top-level cv qualifications of @code{base_type} and
18461 @code{derived_type} are ignored. For the purposes of this trait, a
18462 class type is considered is own base. Requires: if @code{__is_class
18463 (base_type)} and @code{__is_class (derived_type)} are true and
18464 @code{base_type} and @code{derived_type} are not the same type
18465 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
18466 type. Diagnostic is produced if this requirement is not met.
18467
18468 @item __is_class (type)
18469 If @code{type} is a cv class type, and not a union type
18470 ([basic.compound]) the trait is true, else it is false.
18471
18472 @item __is_empty (type)
18473 If @code{__is_class (type)} is false then the trait is false.
18474 Otherwise @code{type} is considered empty if and only if: @code{type}
18475 has no non-static data members, or all non-static data members, if
18476 any, are bit-fields of length 0, and @code{type} has no virtual
18477 members, and @code{type} has no virtual base classes, and @code{type}
18478 has no base classes @code{base_type} for which
18479 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
18480 be a complete type, (possibly cv-qualified) @code{void}, or an array
18481 of unknown bound.
18482
18483 @item __is_enum (type)
18484 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
18485 true, else it is false.
18486
18487 @item __is_literal_type (type)
18488 If @code{type} is a literal type ([basic.types]) the trait is
18489 true, else it is false. Requires: @code{type} shall be a complete type,
18490 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18491
18492 @item __is_pod (type)
18493 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
18494 else it is false. Requires: @code{type} shall be a complete type,
18495 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18496
18497 @item __is_polymorphic (type)
18498 If @code{type} is a polymorphic class ([class.virtual]) then the trait
18499 is true, else it is false. Requires: @code{type} shall be a complete
18500 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18501
18502 @item __is_standard_layout (type)
18503 If @code{type} is a standard-layout type ([basic.types]) the trait is
18504 true, else it is false. Requires: @code{type} shall be a complete
18505 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18506
18507 @item __is_trivial (type)
18508 If @code{type} is a trivial type ([basic.types]) the trait is
18509 true, else it is false. Requires: @code{type} shall be a complete
18510 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18511
18512 @item __is_union (type)
18513 If @code{type} is a cv union type ([basic.compound]) the trait is
18514 true, else it is false.
18515
18516 @item __underlying_type (type)
18517 The underlying type of @code{type}. Requires: @code{type} shall be
18518 an enumeration type ([dcl.enum]).
18519
18520 @end table
18521
18522 @node Java Exceptions
18523 @section Java Exceptions
18524
18525 The Java language uses a slightly different exception handling model
18526 from C++. Normally, GNU C++ automatically detects when you are
18527 writing C++ code that uses Java exceptions, and handle them
18528 appropriately. However, if C++ code only needs to execute destructors
18529 when Java exceptions are thrown through it, GCC guesses incorrectly.
18530 Sample problematic code is:
18531
18532 @smallexample
18533 struct S @{ ~S(); @};
18534 extern void bar(); // @r{is written in Java, and may throw exceptions}
18535 void foo()
18536 @{
18537 S s;
18538 bar();
18539 @}
18540 @end smallexample
18541
18542 @noindent
18543 The usual effect of an incorrect guess is a link failure, complaining of
18544 a missing routine called @samp{__gxx_personality_v0}.
18545
18546 You can inform the compiler that Java exceptions are to be used in a
18547 translation unit, irrespective of what it might think, by writing
18548 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
18549 @samp{#pragma} must appear before any functions that throw or catch
18550 exceptions, or run destructors when exceptions are thrown through them.
18551
18552 You cannot mix Java and C++ exceptions in the same translation unit. It
18553 is believed to be safe to throw a C++ exception from one file through
18554 another file compiled for the Java exception model, or vice versa, but
18555 there may be bugs in this area.
18556
18557 @node Deprecated Features
18558 @section Deprecated Features
18559
18560 In the past, the GNU C++ compiler was extended to experiment with new
18561 features, at a time when the C++ language was still evolving. Now that
18562 the C++ standard is complete, some of those features are superseded by
18563 superior alternatives. Using the old features might cause a warning in
18564 some cases that the feature will be dropped in the future. In other
18565 cases, the feature might be gone already.
18566
18567 While the list below is not exhaustive, it documents some of the options
18568 that are now deprecated:
18569
18570 @table @code
18571 @item -fexternal-templates
18572 @itemx -falt-external-templates
18573 These are two of the many ways for G++ to implement template
18574 instantiation. @xref{Template Instantiation}. The C++ standard clearly
18575 defines how template definitions have to be organized across
18576 implementation units. G++ has an implicit instantiation mechanism that
18577 should work just fine for standard-conforming code.
18578
18579 @item -fstrict-prototype
18580 @itemx -fno-strict-prototype
18581 Previously it was possible to use an empty prototype parameter list to
18582 indicate an unspecified number of parameters (like C), rather than no
18583 parameters, as C++ demands. This feature has been removed, except where
18584 it is required for backwards compatibility. @xref{Backwards Compatibility}.
18585 @end table
18586
18587 G++ allows a virtual function returning @samp{void *} to be overridden
18588 by one returning a different pointer type. This extension to the
18589 covariant return type rules is now deprecated and will be removed from a
18590 future version.
18591
18592 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
18593 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
18594 and are now removed from G++. Code using these operators should be
18595 modified to use @code{std::min} and @code{std::max} instead.
18596
18597 The named return value extension has been deprecated, and is now
18598 removed from G++.
18599
18600 The use of initializer lists with new expressions has been deprecated,
18601 and is now removed from G++.
18602
18603 Floating and complex non-type template parameters have been deprecated,
18604 and are now removed from G++.
18605
18606 The implicit typename extension has been deprecated and is now
18607 removed from G++.
18608
18609 The use of default arguments in function pointers, function typedefs
18610 and other places where they are not permitted by the standard is
18611 deprecated and will be removed from a future version of G++.
18612
18613 G++ allows floating-point literals to appear in integral constant expressions,
18614 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
18615 This extension is deprecated and will be removed from a future version.
18616
18617 G++ allows static data members of const floating-point type to be declared
18618 with an initializer in a class definition. The standard only allows
18619 initializers for static members of const integral types and const
18620 enumeration types so this extension has been deprecated and will be removed
18621 from a future version.
18622
18623 @node Backwards Compatibility
18624 @section Backwards Compatibility
18625 @cindex Backwards Compatibility
18626 @cindex ARM [Annotated C++ Reference Manual]
18627
18628 Now that there is a definitive ISO standard C++, G++ has a specification
18629 to adhere to. The C++ language evolved over time, and features that
18630 used to be acceptable in previous drafts of the standard, such as the ARM
18631 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
18632 compilation of C++ written to such drafts, G++ contains some backwards
18633 compatibilities. @emph{All such backwards compatibility features are
18634 liable to disappear in future versions of G++.} They should be considered
18635 deprecated. @xref{Deprecated Features}.
18636
18637 @table @code
18638 @item For scope
18639 If a variable is declared at for scope, it used to remain in scope until
18640 the end of the scope that contained the for statement (rather than just
18641 within the for scope). G++ retains this, but issues a warning, if such a
18642 variable is accessed outside the for scope.
18643
18644 @item Implicit C language
18645 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
18646 scope to set the language. On such systems, all header files are
18647 implicitly scoped inside a C language scope. Also, an empty prototype
18648 @code{()} is treated as an unspecified number of arguments, rather
18649 than no arguments, as C++ demands.
18650 @end table
18651
18652 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
18653 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr followign