rx.c (add_vector_labels): New.
[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
377 The @code{&&foo} expressions for the same label might have different
378 values if the containing function is inlined or cloned. If a program
379 relies on them being always the same,
380 @code{__attribute__((__noinline__,__noclone__))} should be used to
381 prevent inlining and cloning. If @code{&&foo} is used in a static
382 variable initializer, inlining and cloning is forbidden.
383
384 @node Nested Functions
385 @section Nested Functions
386 @cindex nested functions
387 @cindex downward funargs
388 @cindex thunks
389
390 A @dfn{nested function} is a function defined inside another function.
391 Nested functions are supported as an extension in GNU C, but are not
392 supported by GNU C++.
393
394 The nested function's name is local to the block where it is defined.
395 For example, here we define a nested function named @code{square}, and
396 call it twice:
397
398 @smallexample
399 @group
400 foo (double a, double b)
401 @{
402 double square (double z) @{ return z * z; @}
403
404 return square (a) + square (b);
405 @}
406 @end group
407 @end smallexample
408
409 The nested function can access all the variables of the containing
410 function that are visible at the point of its definition. This is
411 called @dfn{lexical scoping}. For example, here we show a nested
412 function which uses an inherited variable named @code{offset}:
413
414 @smallexample
415 @group
416 bar (int *array, int offset, int size)
417 @{
418 int access (int *array, int index)
419 @{ return array[index + offset]; @}
420 int i;
421 /* @r{@dots{}} */
422 for (i = 0; i < size; i++)
423 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
424 @}
425 @end group
426 @end smallexample
427
428 Nested function definitions are permitted within functions in the places
429 where variable definitions are allowed; that is, in any block, mixed
430 with the other declarations and statements in the block.
431
432 It is possible to call the nested function from outside the scope of its
433 name by storing its address or passing the address to another function:
434
435 @smallexample
436 hack (int *array, int size)
437 @{
438 void store (int index, int value)
439 @{ array[index] = value; @}
440
441 intermediate (store, size);
442 @}
443 @end smallexample
444
445 Here, the function @code{intermediate} receives the address of
446 @code{store} as an argument. If @code{intermediate} calls @code{store},
447 the arguments given to @code{store} are used to store into @code{array}.
448 But this technique works only so long as the containing function
449 (@code{hack}, in this example) does not exit.
450
451 If you try to call the nested function through its address after the
452 containing function exits, all hell breaks loose. If you try
453 to call it after a containing scope level exits, and if it refers
454 to some of the variables that are no longer in scope, you may be lucky,
455 but it's not wise to take the risk. If, however, the nested function
456 does not refer to anything that has gone out of scope, you should be
457 safe.
458
459 GCC implements taking the address of a nested function using a technique
460 called @dfn{trampolines}. This technique was described in
461 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
462 C++ Conference Proceedings, October 17-21, 1988).
463
464 A nested function can jump to a label inherited from a containing
465 function, provided the label is explicitly declared in the containing
466 function (@pxref{Local Labels}). Such a jump returns instantly to the
467 containing function, exiting the nested function that did the
468 @code{goto} and any intermediate functions as well. Here is an example:
469
470 @smallexample
471 @group
472 bar (int *array, int offset, int size)
473 @{
474 __label__ failure;
475 int access (int *array, int index)
476 @{
477 if (index > size)
478 goto failure;
479 return array[index + offset];
480 @}
481 int i;
482 /* @r{@dots{}} */
483 for (i = 0; i < size; i++)
484 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
485 /* @r{@dots{}} */
486 return 0;
487
488 /* @r{Control comes here from @code{access}
489 if it detects an error.} */
490 failure:
491 return -1;
492 @}
493 @end group
494 @end smallexample
495
496 A nested function always has no linkage. Declaring one with
497 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
498 before its definition, use @code{auto} (which is otherwise meaningless
499 for function declarations).
500
501 @smallexample
502 bar (int *array, int offset, int size)
503 @{
504 __label__ failure;
505 auto int access (int *, int);
506 /* @r{@dots{}} */
507 int access (int *array, int index)
508 @{
509 if (index > size)
510 goto failure;
511 return array[index + offset];
512 @}
513 /* @r{@dots{}} */
514 @}
515 @end smallexample
516
517 @node Constructing Calls
518 @section Constructing Function Calls
519 @cindex constructing calls
520 @cindex forwarding calls
521
522 Using the built-in functions described below, you can record
523 the arguments a function received, and call another function
524 with the same arguments, without knowing the number or types
525 of the arguments.
526
527 You can also record the return value of that function call,
528 and later return that value, without knowing what data type
529 the function tried to return (as long as your caller expects
530 that data type).
531
532 However, these built-in functions may interact badly with some
533 sophisticated features or other extensions of the language. It
534 is, therefore, not recommended to use them outside very simple
535 functions acting as mere forwarders for their arguments.
536
537 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
538 This built-in function returns a pointer to data
539 describing how to perform a call with the same arguments as are passed
540 to the current function.
541
542 The function saves the arg pointer register, structure value address,
543 and all registers that might be used to pass arguments to a function
544 into a block of memory allocated on the stack. Then it returns the
545 address of that block.
546 @end deftypefn
547
548 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
549 This built-in function invokes @var{function}
550 with a copy of the parameters described by @var{arguments}
551 and @var{size}.
552
553 The value of @var{arguments} should be the value returned by
554 @code{__builtin_apply_args}. The argument @var{size} specifies the size
555 of the stack argument data, in bytes.
556
557 This function returns a pointer to data describing
558 how to return whatever value is returned by @var{function}. The data
559 is saved in a block of memory allocated on the stack.
560
561 It is not always simple to compute the proper value for @var{size}. The
562 value is used by @code{__builtin_apply} to compute the amount of data
563 that should be pushed on the stack and copied from the incoming argument
564 area.
565 @end deftypefn
566
567 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
568 This built-in function returns the value described by @var{result} from
569 the containing function. You should specify, for @var{result}, a value
570 returned by @code{__builtin_apply}.
571 @end deftypefn
572
573 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
574 This built-in function represents all anonymous arguments of an inline
575 function. It can be used only in inline functions that are always
576 inlined, never compiled as a separate function, such as those using
577 @code{__attribute__ ((__always_inline__))} or
578 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
579 It must be only passed as last argument to some other function
580 with variable arguments. This is useful for writing small wrapper
581 inlines for variable argument functions, when using preprocessor
582 macros is undesirable. For example:
583 @smallexample
584 extern int myprintf (FILE *f, const char *format, ...);
585 extern inline __attribute__ ((__gnu_inline__)) int
586 myprintf (FILE *f, const char *format, ...)
587 @{
588 int r = fprintf (f, "myprintf: ");
589 if (r < 0)
590 return r;
591 int s = fprintf (f, format, __builtin_va_arg_pack ());
592 if (s < 0)
593 return s;
594 return r + s;
595 @}
596 @end smallexample
597 @end deftypefn
598
599 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
600 This built-in function returns the number of anonymous arguments of
601 an inline function. It can be used only in inline functions that
602 are always inlined, never compiled as a separate function, such
603 as those using @code{__attribute__ ((__always_inline__))} or
604 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
605 For example following does link- or run-time checking of open
606 arguments for optimized code:
607 @smallexample
608 #ifdef __OPTIMIZE__
609 extern inline __attribute__((__gnu_inline__)) int
610 myopen (const char *path, int oflag, ...)
611 @{
612 if (__builtin_va_arg_pack_len () > 1)
613 warn_open_too_many_arguments ();
614
615 if (__builtin_constant_p (oflag))
616 @{
617 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
618 @{
619 warn_open_missing_mode ();
620 return __open_2 (path, oflag);
621 @}
622 return open (path, oflag, __builtin_va_arg_pack ());
623 @}
624
625 if (__builtin_va_arg_pack_len () < 1)
626 return __open_2 (path, oflag);
627
628 return open (path, oflag, __builtin_va_arg_pack ());
629 @}
630 #endif
631 @end smallexample
632 @end deftypefn
633
634 @node Typeof
635 @section Referring to a Type with @code{typeof}
636 @findex typeof
637 @findex sizeof
638 @cindex macros, types of arguments
639
640 Another way to refer to the type of an expression is with @code{typeof}.
641 The syntax of using of this keyword looks like @code{sizeof}, but the
642 construct acts semantically like a type name defined with @code{typedef}.
643
644 There are two ways of writing the argument to @code{typeof}: with an
645 expression or with a type. Here is an example with an expression:
646
647 @smallexample
648 typeof (x[0](1))
649 @end smallexample
650
651 @noindent
652 This assumes that @code{x} is an array of pointers to functions;
653 the type described is that of the values of the functions.
654
655 Here is an example with a typename as the argument:
656
657 @smallexample
658 typeof (int *)
659 @end smallexample
660
661 @noindent
662 Here the type described is that of pointers to @code{int}.
663
664 If you are writing a header file that must work when included in ISO C
665 programs, write @code{__typeof__} instead of @code{typeof}.
666 @xref{Alternate Keywords}.
667
668 A @code{typeof} construct can be used anywhere a typedef name can be
669 used. For example, you can use it in a declaration, in a cast, or inside
670 of @code{sizeof} or @code{typeof}.
671
672 The operand of @code{typeof} is evaluated for its side effects if and
673 only if it is an expression of variably modified type or the name of
674 such a type.
675
676 @code{typeof} is often useful in conjunction with
677 statement expressions (@pxref{Statement Exprs}).
678 Here is how the two together can
679 be used to define a safe ``maximum'' macro which operates on any
680 arithmetic type and evaluates each of its arguments exactly once:
681
682 @smallexample
683 #define max(a,b) \
684 (@{ typeof (a) _a = (a); \
685 typeof (b) _b = (b); \
686 _a > _b ? _a : _b; @})
687 @end smallexample
688
689 @cindex underscores in variables in macros
690 @cindex @samp{_} in variables in macros
691 @cindex local variables in macros
692 @cindex variables, local, in macros
693 @cindex macros, local variables in
694
695 The reason for using names that start with underscores for the local
696 variables is to avoid conflicts with variable names that occur within the
697 expressions that are substituted for @code{a} and @code{b}. Eventually we
698 hope to design a new form of declaration syntax that allows you to declare
699 variables whose scopes start only after their initializers; this will be a
700 more reliable way to prevent such conflicts.
701
702 @noindent
703 Some more examples of the use of @code{typeof}:
704
705 @itemize @bullet
706 @item
707 This declares @code{y} with the type of what @code{x} points to.
708
709 @smallexample
710 typeof (*x) y;
711 @end smallexample
712
713 @item
714 This declares @code{y} as an array of such values.
715
716 @smallexample
717 typeof (*x) y[4];
718 @end smallexample
719
720 @item
721 This declares @code{y} as an array of pointers to characters:
722
723 @smallexample
724 typeof (typeof (char *)[4]) y;
725 @end smallexample
726
727 @noindent
728 It is equivalent to the following traditional C declaration:
729
730 @smallexample
731 char *y[4];
732 @end smallexample
733
734 To see the meaning of the declaration using @code{typeof}, and why it
735 might be a useful way to write, rewrite it with these macros:
736
737 @smallexample
738 #define pointer(T) typeof(T *)
739 #define array(T, N) typeof(T [N])
740 @end smallexample
741
742 @noindent
743 Now the declaration can be rewritten this way:
744
745 @smallexample
746 array (pointer (char), 4) y;
747 @end smallexample
748
749 @noindent
750 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
751 pointers to @code{char}.
752 @end itemize
753
754 In GNU C, but not GNU C++, you may also declare the type of a variable
755 as @code{__auto_type}. In that case, the declaration must declare
756 only one variable, whose declarator must just be an identifier, the
757 declaration must be initialized, and the type of the variable is
758 determined by the initializer; the name of the variable is not in
759 scope until after the initializer. (In C++, you should use C++11
760 @code{auto} for this purpose.) Using @code{__auto_type}, the
761 ``maximum'' macro above could be written as:
762
763 @smallexample
764 #define max(a,b) \
765 (@{ __auto_type _a = (a); \
766 __auto_type _b = (b); \
767 _a > _b ? _a : _b; @})
768 @end smallexample
769
770 Using @code{__auto_type} instead of @code{typeof} has two advantages:
771
772 @itemize @bullet
773 @item Each argument to the macro appears only once in the expansion of
774 the macro. This prevents the size of the macro expansion growing
775 exponentially when calls to such macros are nested inside arguments of
776 such macros.
777
778 @item If the argument to the macro has variably modified type, it is
779 evaluated only once when using @code{__auto_type}, but twice if
780 @code{typeof} is used.
781 @end itemize
782
783 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
784 a more limited extension that permitted one to write
785
786 @smallexample
787 typedef @var{T} = @var{expr};
788 @end smallexample
789
790 @noindent
791 with the effect of declaring @var{T} to have the type of the expression
792 @var{expr}. This extension does not work with GCC 3 (versions between
793 3.0 and 3.2 crash; 3.2.1 and later give an error). Code that
794 relies on it should be rewritten to use @code{typeof}:
795
796 @smallexample
797 typedef typeof(@var{expr}) @var{T};
798 @end smallexample
799
800 @noindent
801 This works with all versions of GCC@.
802
803 @node Conditionals
804 @section Conditionals with Omitted Operands
805 @cindex conditional expressions, extensions
806 @cindex omitted middle-operands
807 @cindex middle-operands, omitted
808 @cindex extensions, @code{?:}
809 @cindex @code{?:} extensions
810
811 The middle operand in a conditional expression may be omitted. Then
812 if the first operand is nonzero, its value is the value of the conditional
813 expression.
814
815 Therefore, the expression
816
817 @smallexample
818 x ? : y
819 @end smallexample
820
821 @noindent
822 has the value of @code{x} if that is nonzero; otherwise, the value of
823 @code{y}.
824
825 This example is perfectly equivalent to
826
827 @smallexample
828 x ? x : y
829 @end smallexample
830
831 @cindex side effect in @code{?:}
832 @cindex @code{?:} side effect
833 @noindent
834 In this simple case, the ability to omit the middle operand is not
835 especially useful. When it becomes useful is when the first operand does,
836 or may (if it is a macro argument), contain a side effect. Then repeating
837 the operand in the middle would perform the side effect twice. Omitting
838 the middle operand uses the value already computed without the undesirable
839 effects of recomputing it.
840
841 @node __int128
842 @section 128-bit integers
843 @cindex @code{__int128} data types
844
845 As an extension the integer scalar type @code{__int128} is supported for
846 targets which have an integer mode wide enough to hold 128 bits.
847 Simply write @code{__int128} for a signed 128-bit integer, or
848 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
849 support in GCC for expressing an integer constant of type @code{__int128}
850 for targets with @code{long long} integer less than 128 bits wide.
851
852 @node Long Long
853 @section Double-Word Integers
854 @cindex @code{long long} data types
855 @cindex double-word arithmetic
856 @cindex multiprecision arithmetic
857 @cindex @code{LL} integer suffix
858 @cindex @code{ULL} integer suffix
859
860 ISO C99 supports data types for integers that are at least 64 bits wide,
861 and as an extension GCC supports them in C90 mode and in C++.
862 Simply write @code{long long int} for a signed integer, or
863 @code{unsigned long long int} for an unsigned integer. To make an
864 integer constant of type @code{long long int}, add the suffix @samp{LL}
865 to the integer. To make an integer constant of type @code{unsigned long
866 long int}, add the suffix @samp{ULL} to the integer.
867
868 You can use these types in arithmetic like any other integer types.
869 Addition, subtraction, and bitwise boolean operations on these types
870 are open-coded on all types of machines. Multiplication is open-coded
871 if the machine supports a fullword-to-doubleword widening multiply
872 instruction. Division and shifts are open-coded only on machines that
873 provide special support. The operations that are not open-coded use
874 special library routines that come with GCC@.
875
876 There may be pitfalls when you use @code{long long} types for function
877 arguments without function prototypes. If a function
878 expects type @code{int} for its argument, and you pass a value of type
879 @code{long long int}, confusion results because the caller and the
880 subroutine disagree about the number of bytes for the argument.
881 Likewise, if the function expects @code{long long int} and you pass
882 @code{int}. The best way to avoid such problems is to use prototypes.
883
884 @node Complex
885 @section Complex Numbers
886 @cindex complex numbers
887 @cindex @code{_Complex} keyword
888 @cindex @code{__complex__} keyword
889
890 ISO C99 supports complex floating data types, and as an extension GCC
891 supports them in C90 mode and in C++. GCC also supports complex integer data
892 types which are not part of ISO C99. You can declare complex types
893 using the keyword @code{_Complex}. As an extension, the older GNU
894 keyword @code{__complex__} is also supported.
895
896 For example, @samp{_Complex double x;} declares @code{x} as a
897 variable whose real part and imaginary part are both of type
898 @code{double}. @samp{_Complex short int y;} declares @code{y} to
899 have real and imaginary parts of type @code{short int}; this is not
900 likely to be useful, but it shows that the set of complex types is
901 complete.
902
903 To write a constant with a complex data type, use the suffix @samp{i} or
904 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
905 has type @code{_Complex float} and @code{3i} has type
906 @code{_Complex int}. Such a constant always has a pure imaginary
907 value, but you can form any complex value you like by adding one to a
908 real constant. This is a GNU extension; if you have an ISO C99
909 conforming C library (such as the GNU C Library), and want to construct complex
910 constants of floating type, you should include @code{<complex.h>} and
911 use the macros @code{I} or @code{_Complex_I} instead.
912
913 @cindex @code{__real__} keyword
914 @cindex @code{__imag__} keyword
915 To extract the real part of a complex-valued expression @var{exp}, write
916 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
917 extract the imaginary part. This is a GNU extension; for values of
918 floating type, you should use the ISO C99 functions @code{crealf},
919 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
920 @code{cimagl}, declared in @code{<complex.h>} and also provided as
921 built-in functions by GCC@.
922
923 @cindex complex conjugation
924 The operator @samp{~} performs complex conjugation when used on a value
925 with a complex type. This is a GNU extension; for values of
926 floating type, you should use the ISO C99 functions @code{conjf},
927 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
928 provided as built-in functions by GCC@.
929
930 GCC can allocate complex automatic variables in a noncontiguous
931 fashion; it's even possible for the real part to be in a register while
932 the imaginary part is on the stack (or vice versa). Only the DWARF 2
933 debug info format can represent this, so use of DWARF 2 is recommended.
934 If you are using the stabs debug info format, GCC describes a noncontiguous
935 complex variable as if it were two separate variables of noncomplex type.
936 If the variable's actual name is @code{foo}, the two fictitious
937 variables are named @code{foo$real} and @code{foo$imag}. You can
938 examine and set these two fictitious variables with your debugger.
939
940 @node Floating Types
941 @section Additional Floating Types
942 @cindex additional floating types
943 @cindex @code{__float80} data type
944 @cindex @code{__float128} data type
945 @cindex @code{w} floating point suffix
946 @cindex @code{q} floating point suffix
947 @cindex @code{W} floating point suffix
948 @cindex @code{Q} floating point suffix
949
950 As an extension, GNU C supports additional floating
951 types, @code{__float80} and @code{__float128} to support 80-bit
952 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
953 Support for additional types includes the arithmetic operators:
954 add, subtract, multiply, divide; unary arithmetic operators;
955 relational operators; equality operators; and conversions to and from
956 integer and other floating types. Use a suffix @samp{w} or @samp{W}
957 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
958 for @code{_float128}. You can declare complex types using the
959 corresponding internal complex type, @code{XCmode} for @code{__float80}
960 type and @code{TCmode} for @code{__float128} type:
961
962 @smallexample
963 typedef _Complex float __attribute__((mode(TC))) _Complex128;
964 typedef _Complex float __attribute__((mode(XC))) _Complex80;
965 @end smallexample
966
967 Not all targets support additional floating-point types. @code{__float80}
968 and @code{__float128} types are supported on i386, x86_64 and IA-64 targets.
969 The @code{__float128} type is supported on hppa HP-UX targets.
970
971 @node Half-Precision
972 @section Half-Precision Floating Point
973 @cindex half-precision floating point
974 @cindex @code{__fp16} data type
975
976 On ARM targets, GCC supports half-precision (16-bit) floating point via
977 the @code{__fp16} type. You must enable this type explicitly
978 with the @option{-mfp16-format} command-line option in order to use it.
979
980 ARM supports two incompatible representations for half-precision
981 floating-point values. You must choose one of the representations and
982 use it consistently in your program.
983
984 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
985 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
986 There are 11 bits of significand precision, approximately 3
987 decimal digits.
988
989 Specifying @option{-mfp16-format=alternative} selects the ARM
990 alternative format. This representation is similar to the IEEE
991 format, but does not support infinities or NaNs. Instead, the range
992 of exponents is extended, so that this format can represent normalized
993 values in the range of @math{2^{-14}} to 131008.
994
995 The @code{__fp16} type is a storage format only. For purposes
996 of arithmetic and other operations, @code{__fp16} values in C or C++
997 expressions are automatically promoted to @code{float}. In addition,
998 you cannot declare a function with a return value or parameters
999 of type @code{__fp16}.
1000
1001 Note that conversions from @code{double} to @code{__fp16}
1002 involve an intermediate conversion to @code{float}. Because
1003 of rounding, this can sometimes produce a different result than a
1004 direct conversion.
1005
1006 ARM provides hardware support for conversions between
1007 @code{__fp16} and @code{float} values
1008 as an extension to VFP and NEON (Advanced SIMD). GCC generates
1009 code using these hardware instructions if you compile with
1010 options to select an FPU that provides them;
1011 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1012 in addition to the @option{-mfp16-format} option to select
1013 a half-precision format.
1014
1015 Language-level support for the @code{__fp16} data type is
1016 independent of whether GCC generates code using hardware floating-point
1017 instructions. In cases where hardware support is not specified, GCC
1018 implements conversions between @code{__fp16} and @code{float} values
1019 as library calls.
1020
1021 @node Decimal Float
1022 @section Decimal Floating Types
1023 @cindex decimal floating types
1024 @cindex @code{_Decimal32} data type
1025 @cindex @code{_Decimal64} data type
1026 @cindex @code{_Decimal128} data type
1027 @cindex @code{df} integer suffix
1028 @cindex @code{dd} integer suffix
1029 @cindex @code{dl} integer suffix
1030 @cindex @code{DF} integer suffix
1031 @cindex @code{DD} integer suffix
1032 @cindex @code{DL} integer suffix
1033
1034 As an extension, GNU C supports decimal floating types as
1035 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1036 floating types in GCC will evolve as the draft technical report changes.
1037 Calling conventions for any target might also change. Not all targets
1038 support decimal floating types.
1039
1040 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1041 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1042 @code{float}, @code{double}, and @code{long double} whose radix is not
1043 specified by the C standard but is usually two.
1044
1045 Support for decimal floating types includes the arithmetic operators
1046 add, subtract, multiply, divide; unary arithmetic operators;
1047 relational operators; equality operators; and conversions to and from
1048 integer and other floating types. Use a suffix @samp{df} or
1049 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1050 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1051 @code{_Decimal128}.
1052
1053 GCC support of decimal float as specified by the draft technical report
1054 is incomplete:
1055
1056 @itemize @bullet
1057 @item
1058 When the value of a decimal floating type cannot be represented in the
1059 integer type to which it is being converted, the result is undefined
1060 rather than the result value specified by the draft technical report.
1061
1062 @item
1063 GCC does not provide the C library functionality associated with
1064 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1065 @file{wchar.h}, which must come from a separate C library implementation.
1066 Because of this the GNU C compiler does not define macro
1067 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1068 the technical report.
1069 @end itemize
1070
1071 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1072 are supported by the DWARF 2 debug information format.
1073
1074 @node Hex Floats
1075 @section Hex Floats
1076 @cindex hex floats
1077
1078 ISO C99 supports floating-point numbers written not only in the usual
1079 decimal notation, such as @code{1.55e1}, but also numbers such as
1080 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1081 supports this in C90 mode (except in some cases when strictly
1082 conforming) and in C++. In that format the
1083 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1084 mandatory. The exponent is a decimal number that indicates the power of
1085 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1086 @tex
1087 $1 {15\over16}$,
1088 @end tex
1089 @ifnottex
1090 1 15/16,
1091 @end ifnottex
1092 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1093 is the same as @code{1.55e1}.
1094
1095 Unlike for floating-point numbers in the decimal notation the exponent
1096 is always required in the hexadecimal notation. Otherwise the compiler
1097 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1098 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1099 extension for floating-point constants of type @code{float}.
1100
1101 @node Fixed-Point
1102 @section Fixed-Point Types
1103 @cindex fixed-point types
1104 @cindex @code{_Fract} data type
1105 @cindex @code{_Accum} data type
1106 @cindex @code{_Sat} data type
1107 @cindex @code{hr} fixed-suffix
1108 @cindex @code{r} fixed-suffix
1109 @cindex @code{lr} fixed-suffix
1110 @cindex @code{llr} fixed-suffix
1111 @cindex @code{uhr} fixed-suffix
1112 @cindex @code{ur} fixed-suffix
1113 @cindex @code{ulr} fixed-suffix
1114 @cindex @code{ullr} fixed-suffix
1115 @cindex @code{hk} fixed-suffix
1116 @cindex @code{k} fixed-suffix
1117 @cindex @code{lk} fixed-suffix
1118 @cindex @code{llk} fixed-suffix
1119 @cindex @code{uhk} fixed-suffix
1120 @cindex @code{uk} fixed-suffix
1121 @cindex @code{ulk} fixed-suffix
1122 @cindex @code{ullk} fixed-suffix
1123 @cindex @code{HR} fixed-suffix
1124 @cindex @code{R} fixed-suffix
1125 @cindex @code{LR} fixed-suffix
1126 @cindex @code{LLR} fixed-suffix
1127 @cindex @code{UHR} fixed-suffix
1128 @cindex @code{UR} fixed-suffix
1129 @cindex @code{ULR} fixed-suffix
1130 @cindex @code{ULLR} fixed-suffix
1131 @cindex @code{HK} fixed-suffix
1132 @cindex @code{K} fixed-suffix
1133 @cindex @code{LK} fixed-suffix
1134 @cindex @code{LLK} fixed-suffix
1135 @cindex @code{UHK} fixed-suffix
1136 @cindex @code{UK} fixed-suffix
1137 @cindex @code{ULK} fixed-suffix
1138 @cindex @code{ULLK} fixed-suffix
1139
1140 As an extension, GNU C supports fixed-point types as
1141 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1142 types in GCC will evolve as the draft technical report changes.
1143 Calling conventions for any target might also change. Not all targets
1144 support fixed-point types.
1145
1146 The fixed-point types are
1147 @code{short _Fract},
1148 @code{_Fract},
1149 @code{long _Fract},
1150 @code{long long _Fract},
1151 @code{unsigned short _Fract},
1152 @code{unsigned _Fract},
1153 @code{unsigned long _Fract},
1154 @code{unsigned long long _Fract},
1155 @code{_Sat short _Fract},
1156 @code{_Sat _Fract},
1157 @code{_Sat long _Fract},
1158 @code{_Sat long long _Fract},
1159 @code{_Sat unsigned short _Fract},
1160 @code{_Sat unsigned _Fract},
1161 @code{_Sat unsigned long _Fract},
1162 @code{_Sat unsigned long long _Fract},
1163 @code{short _Accum},
1164 @code{_Accum},
1165 @code{long _Accum},
1166 @code{long long _Accum},
1167 @code{unsigned short _Accum},
1168 @code{unsigned _Accum},
1169 @code{unsigned long _Accum},
1170 @code{unsigned long long _Accum},
1171 @code{_Sat short _Accum},
1172 @code{_Sat _Accum},
1173 @code{_Sat long _Accum},
1174 @code{_Sat long long _Accum},
1175 @code{_Sat unsigned short _Accum},
1176 @code{_Sat unsigned _Accum},
1177 @code{_Sat unsigned long _Accum},
1178 @code{_Sat unsigned long long _Accum}.
1179
1180 Fixed-point data values contain fractional and optional integral parts.
1181 The format of fixed-point data varies and depends on the target machine.
1182
1183 Support for fixed-point types includes:
1184 @itemize @bullet
1185 @item
1186 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1187 @item
1188 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1189 @item
1190 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1191 @item
1192 binary shift operators (@code{<<}, @code{>>})
1193 @item
1194 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1195 @item
1196 equality operators (@code{==}, @code{!=})
1197 @item
1198 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1199 @code{<<=}, @code{>>=})
1200 @item
1201 conversions to and from integer, floating-point, or fixed-point types
1202 @end itemize
1203
1204 Use a suffix in a fixed-point literal constant:
1205 @itemize
1206 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1207 @code{_Sat short _Fract}
1208 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1209 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1210 @code{_Sat long _Fract}
1211 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1212 @code{_Sat long long _Fract}
1213 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1214 @code{_Sat unsigned short _Fract}
1215 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1216 @code{_Sat unsigned _Fract}
1217 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1218 @code{_Sat unsigned long _Fract}
1219 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1220 and @code{_Sat unsigned long long _Fract}
1221 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1222 @code{_Sat short _Accum}
1223 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1224 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1225 @code{_Sat long _Accum}
1226 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1227 @code{_Sat long long _Accum}
1228 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1229 @code{_Sat unsigned short _Accum}
1230 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1231 @code{_Sat unsigned _Accum}
1232 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1233 @code{_Sat unsigned long _Accum}
1234 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1235 and @code{_Sat unsigned long long _Accum}
1236 @end itemize
1237
1238 GCC support of fixed-point types as specified by the draft technical report
1239 is incomplete:
1240
1241 @itemize @bullet
1242 @item
1243 Pragmas to control overflow and rounding behaviors are not implemented.
1244 @end itemize
1245
1246 Fixed-point types are supported by the DWARF 2 debug information format.
1247
1248 @node Named Address Spaces
1249 @section Named Address Spaces
1250 @cindex Named Address Spaces
1251
1252 As an extension, GNU C supports named address spaces as
1253 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1254 address spaces in GCC will evolve as the draft technical report
1255 changes. Calling conventions for any target might also change. At
1256 present, only the AVR, SPU, M32C, and RL78 targets support address
1257 spaces other than the generic address space.
1258
1259 Address space identifiers may be used exactly like any other C type
1260 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1261 document for more details.
1262
1263 @anchor{AVR Named Address Spaces}
1264 @subsection AVR Named Address Spaces
1265
1266 On the AVR target, there are several address spaces that can be used
1267 in order to put read-only data into the flash memory and access that
1268 data by means of the special instructions @code{LPM} or @code{ELPM}
1269 needed to read from flash.
1270
1271 Per default, any data including read-only data is located in RAM
1272 (the generic address space) so that non-generic address spaces are
1273 needed to locate read-only data in flash memory
1274 @emph{and} to generate the right instructions to access this data
1275 without using (inline) assembler code.
1276
1277 @table @code
1278 @item __flash
1279 @cindex @code{__flash} AVR Named Address Spaces
1280 The @code{__flash} qualifier locates data in the
1281 @code{.progmem.data} section. Data is read using the @code{LPM}
1282 instruction. Pointers to this address space are 16 bits wide.
1283
1284 @item __flash1
1285 @itemx __flash2
1286 @itemx __flash3
1287 @itemx __flash4
1288 @itemx __flash5
1289 @cindex @code{__flash1} AVR Named Address Spaces
1290 @cindex @code{__flash2} AVR Named Address Spaces
1291 @cindex @code{__flash3} AVR Named Address Spaces
1292 @cindex @code{__flash4} AVR Named Address Spaces
1293 @cindex @code{__flash5} AVR Named Address Spaces
1294 These are 16-bit address spaces locating data in section
1295 @code{.progmem@var{N}.data} where @var{N} refers to
1296 address space @code{__flash@var{N}}.
1297 The compiler sets the @code{RAMPZ} segment register appropriately
1298 before reading data by means of the @code{ELPM} instruction.
1299
1300 @item __memx
1301 @cindex @code{__memx} AVR Named Address Spaces
1302 This is a 24-bit address space that linearizes flash and RAM:
1303 If the high bit of the address is set, data is read from
1304 RAM using the lower two bytes as RAM address.
1305 If the high bit of the address is clear, data is read from flash
1306 with @code{RAMPZ} set according to the high byte of the address.
1307 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1308
1309 Objects in this address space are located in @code{.progmemx.data}.
1310 @end table
1311
1312 @b{Example}
1313
1314 @smallexample
1315 char my_read (const __flash char ** p)
1316 @{
1317 /* p is a pointer to RAM that points to a pointer to flash.
1318 The first indirection of p reads that flash pointer
1319 from RAM and the second indirection reads a char from this
1320 flash address. */
1321
1322 return **p;
1323 @}
1324
1325 /* Locate array[] in flash memory */
1326 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1327
1328 int i = 1;
1329
1330 int main (void)
1331 @{
1332 /* Return 17 by reading from flash memory */
1333 return array[array[i]];
1334 @}
1335 @end smallexample
1336
1337 @noindent
1338 For each named address space supported by avr-gcc there is an equally
1339 named but uppercase built-in macro defined.
1340 The purpose is to facilitate testing if respective address space
1341 support is available or not:
1342
1343 @smallexample
1344 #ifdef __FLASH
1345 const __flash int var = 1;
1346
1347 int read_var (void)
1348 @{
1349 return var;
1350 @}
1351 #else
1352 #include <avr/pgmspace.h> /* From AVR-LibC */
1353
1354 const int var PROGMEM = 1;
1355
1356 int read_var (void)
1357 @{
1358 return (int) pgm_read_word (&var);
1359 @}
1360 #endif /* __FLASH */
1361 @end smallexample
1362
1363 @noindent
1364 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1365 locates data in flash but
1366 accesses to these data read from generic address space, i.e.@:
1367 from RAM,
1368 so that you need special accessors like @code{pgm_read_byte}
1369 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1370 together with attribute @code{progmem}.
1371
1372 @noindent
1373 @b{Limitations and caveats}
1374
1375 @itemize
1376 @item
1377 Reading across the 64@tie{}KiB section boundary of
1378 the @code{__flash} or @code{__flash@var{N}} address spaces
1379 shows undefined behavior. The only address space that
1380 supports reading across the 64@tie{}KiB flash segment boundaries is
1381 @code{__memx}.
1382
1383 @item
1384 If you use one of the @code{__flash@var{N}} address spaces
1385 you must arrange your linker script to locate the
1386 @code{.progmem@var{N}.data} sections according to your needs.
1387
1388 @item
1389 Any data or pointers to the non-generic address spaces must
1390 be qualified as @code{const}, i.e.@: as read-only data.
1391 This still applies if the data in one of these address
1392 spaces like software version number or calibration lookup table are intended to
1393 be changed after load time by, say, a boot loader. In this case
1394 the right qualification is @code{const} @code{volatile} so that the compiler
1395 must not optimize away known values or insert them
1396 as immediates into operands of instructions.
1397
1398 @item
1399 The following code initializes a variable @code{pfoo}
1400 located in static storage with a 24-bit address:
1401 @smallexample
1402 extern const __memx char foo;
1403 const __memx void *pfoo = &foo;
1404 @end smallexample
1405
1406 @noindent
1407 Such code requires at least binutils 2.23, see
1408 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1409
1410 @end itemize
1411
1412 @subsection M32C Named Address Spaces
1413 @cindex @code{__far} M32C Named Address Spaces
1414
1415 On the M32C target, with the R8C and M16C CPU variants, variables
1416 qualified with @code{__far} are accessed using 32-bit addresses in
1417 order to access memory beyond the first 64@tie{}Ki bytes. If
1418 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1419 effect.
1420
1421 @subsection RL78 Named Address Spaces
1422 @cindex @code{__far} RL78 Named Address Spaces
1423
1424 On the RL78 target, variables qualified with @code{__far} are accessed
1425 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1426 addresses. Non-far variables are assumed to appear in the topmost
1427 64@tie{}KiB of the address space.
1428
1429 @subsection SPU Named Address Spaces
1430 @cindex @code{__ea} SPU Named Address Spaces
1431
1432 On the SPU target variables may be declared as
1433 belonging to another address space by qualifying the type with the
1434 @code{__ea} address space identifier:
1435
1436 @smallexample
1437 extern int __ea i;
1438 @end smallexample
1439
1440 @noindent
1441 The compiler generates special code to access the variable @code{i}.
1442 It may use runtime library
1443 support, or generate special machine instructions to access that address
1444 space.
1445
1446 @node Zero Length
1447 @section Arrays of Length Zero
1448 @cindex arrays of length zero
1449 @cindex zero-length arrays
1450 @cindex length-zero arrays
1451 @cindex flexible array members
1452
1453 Zero-length arrays are allowed in GNU C@. They are very useful as the
1454 last element of a structure that is really a header for a variable-length
1455 object:
1456
1457 @smallexample
1458 struct line @{
1459 int length;
1460 char contents[0];
1461 @};
1462
1463 struct line *thisline = (struct line *)
1464 malloc (sizeof (struct line) + this_length);
1465 thisline->length = this_length;
1466 @end smallexample
1467
1468 In ISO C90, you would have to give @code{contents} a length of 1, which
1469 means either you waste space or complicate the argument to @code{malloc}.
1470
1471 In ISO C99, you would use a @dfn{flexible array member}, which is
1472 slightly different in syntax and semantics:
1473
1474 @itemize @bullet
1475 @item
1476 Flexible array members are written as @code{contents[]} without
1477 the @code{0}.
1478
1479 @item
1480 Flexible array members have incomplete type, and so the @code{sizeof}
1481 operator may not be applied. As a quirk of the original implementation
1482 of zero-length arrays, @code{sizeof} evaluates to zero.
1483
1484 @item
1485 Flexible array members may only appear as the last member of a
1486 @code{struct} that is otherwise non-empty.
1487
1488 @item
1489 A structure containing a flexible array member, or a union containing
1490 such a structure (possibly recursively), may not be a member of a
1491 structure or an element of an array. (However, these uses are
1492 permitted by GCC as extensions.)
1493 @end itemize
1494
1495 GCC versions before 3.0 allowed zero-length arrays to be statically
1496 initialized, as if they were flexible arrays. In addition to those
1497 cases that were useful, it also allowed initializations in situations
1498 that would corrupt later data. Non-empty initialization of zero-length
1499 arrays is now treated like any case where there are more initializer
1500 elements than the array holds, in that a suitable warning about ``excess
1501 elements in array'' is given, and the excess elements (all of them, in
1502 this case) are ignored.
1503
1504 Instead GCC allows static initialization of flexible array members.
1505 This is equivalent to defining a new structure containing the original
1506 structure followed by an array of sufficient size to contain the data.
1507 E.g.@: in the following, @code{f1} is constructed as if it were declared
1508 like @code{f2}.
1509
1510 @smallexample
1511 struct f1 @{
1512 int x; int y[];
1513 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1514
1515 struct f2 @{
1516 struct f1 f1; int data[3];
1517 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1518 @end smallexample
1519
1520 @noindent
1521 The convenience of this extension is that @code{f1} has the desired
1522 type, eliminating the need to consistently refer to @code{f2.f1}.
1523
1524 This has symmetry with normal static arrays, in that an array of
1525 unknown size is also written with @code{[]}.
1526
1527 Of course, this extension only makes sense if the extra data comes at
1528 the end of a top-level object, as otherwise we would be overwriting
1529 data at subsequent offsets. To avoid undue complication and confusion
1530 with initialization of deeply nested arrays, we simply disallow any
1531 non-empty initialization except when the structure is the top-level
1532 object. For example:
1533
1534 @smallexample
1535 struct foo @{ int x; int y[]; @};
1536 struct bar @{ struct foo z; @};
1537
1538 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1539 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1540 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1541 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1542 @end smallexample
1543
1544 @node Empty Structures
1545 @section Structures With No Members
1546 @cindex empty structures
1547 @cindex zero-size structures
1548
1549 GCC permits a C structure to have no members:
1550
1551 @smallexample
1552 struct empty @{
1553 @};
1554 @end smallexample
1555
1556 The structure has size zero. In C++, empty structures are part
1557 of the language. G++ treats empty structures as if they had a single
1558 member of type @code{char}.
1559
1560 @node Variable Length
1561 @section Arrays of Variable Length
1562 @cindex variable-length arrays
1563 @cindex arrays of variable length
1564 @cindex VLAs
1565
1566 Variable-length automatic arrays are allowed in ISO C99, and as an
1567 extension GCC accepts them in C90 mode and in C++. These arrays are
1568 declared like any other automatic arrays, but with a length that is not
1569 a constant expression. The storage is allocated at the point of
1570 declaration and deallocated when the block scope containing the declaration
1571 exits. For
1572 example:
1573
1574 @smallexample
1575 FILE *
1576 concat_fopen (char *s1, char *s2, char *mode)
1577 @{
1578 char str[strlen (s1) + strlen (s2) + 1];
1579 strcpy (str, s1);
1580 strcat (str, s2);
1581 return fopen (str, mode);
1582 @}
1583 @end smallexample
1584
1585 @cindex scope of a variable length array
1586 @cindex variable-length array scope
1587 @cindex deallocating variable length arrays
1588 Jumping or breaking out of the scope of the array name deallocates the
1589 storage. Jumping into the scope is not allowed; you get an error
1590 message for it.
1591
1592 @cindex variable-length array in a structure
1593 As an extension, GCC accepts variable-length arrays as a member of
1594 a structure or a union. For example:
1595
1596 @smallexample
1597 void
1598 foo (int n)
1599 @{
1600 struct S @{ int x[n]; @};
1601 @}
1602 @end smallexample
1603
1604 @cindex @code{alloca} vs variable-length arrays
1605 You can use the function @code{alloca} to get an effect much like
1606 variable-length arrays. The function @code{alloca} is available in
1607 many other C implementations (but not in all). On the other hand,
1608 variable-length arrays are more elegant.
1609
1610 There are other differences between these two methods. Space allocated
1611 with @code{alloca} exists until the containing @emph{function} returns.
1612 The space for a variable-length array is deallocated as soon as the array
1613 name's scope ends. (If you use both variable-length arrays and
1614 @code{alloca} in the same function, deallocation of a variable-length array
1615 also deallocates anything more recently allocated with @code{alloca}.)
1616
1617 You can also use variable-length arrays as arguments to functions:
1618
1619 @smallexample
1620 struct entry
1621 tester (int len, char data[len][len])
1622 @{
1623 /* @r{@dots{}} */
1624 @}
1625 @end smallexample
1626
1627 The length of an array is computed once when the storage is allocated
1628 and is remembered for the scope of the array in case you access it with
1629 @code{sizeof}.
1630
1631 If you want to pass the array first and the length afterward, you can
1632 use a forward declaration in the parameter list---another GNU extension.
1633
1634 @smallexample
1635 struct entry
1636 tester (int len; char data[len][len], int len)
1637 @{
1638 /* @r{@dots{}} */
1639 @}
1640 @end smallexample
1641
1642 @cindex parameter forward declaration
1643 The @samp{int len} before the semicolon is a @dfn{parameter forward
1644 declaration}, and it serves the purpose of making the name @code{len}
1645 known when the declaration of @code{data} is parsed.
1646
1647 You can write any number of such parameter forward declarations in the
1648 parameter list. They can be separated by commas or semicolons, but the
1649 last one must end with a semicolon, which is followed by the ``real''
1650 parameter declarations. Each forward declaration must match a ``real''
1651 declaration in parameter name and data type. ISO C99 does not support
1652 parameter forward declarations.
1653
1654 @node Variadic Macros
1655 @section Macros with a Variable Number of Arguments.
1656 @cindex variable number of arguments
1657 @cindex macro with variable arguments
1658 @cindex rest argument (in macro)
1659 @cindex variadic macros
1660
1661 In the ISO C standard of 1999, a macro can be declared to accept a
1662 variable number of arguments much as a function can. The syntax for
1663 defining the macro is similar to that of a function. Here is an
1664 example:
1665
1666 @smallexample
1667 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1668 @end smallexample
1669
1670 @noindent
1671 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1672 such a macro, it represents the zero or more tokens until the closing
1673 parenthesis that ends the invocation, including any commas. This set of
1674 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1675 wherever it appears. See the CPP manual for more information.
1676
1677 GCC has long supported variadic macros, and used a different syntax that
1678 allowed you to give a name to the variable arguments just like any other
1679 argument. Here is an example:
1680
1681 @smallexample
1682 #define debug(format, args...) fprintf (stderr, format, args)
1683 @end smallexample
1684
1685 @noindent
1686 This is in all ways equivalent to the ISO C example above, but arguably
1687 more readable and descriptive.
1688
1689 GNU CPP has two further variadic macro extensions, and permits them to
1690 be used with either of the above forms of macro definition.
1691
1692 In standard C, you are not allowed to leave the variable argument out
1693 entirely; but you are allowed to pass an empty argument. For example,
1694 this invocation is invalid in ISO C, because there is no comma after
1695 the string:
1696
1697 @smallexample
1698 debug ("A message")
1699 @end smallexample
1700
1701 GNU CPP permits you to completely omit the variable arguments in this
1702 way. In the above examples, the compiler would complain, though since
1703 the expansion of the macro still has the extra comma after the format
1704 string.
1705
1706 To help solve this problem, CPP behaves specially for variable arguments
1707 used with the token paste operator, @samp{##}. If instead you write
1708
1709 @smallexample
1710 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1711 @end smallexample
1712
1713 @noindent
1714 and if the variable arguments are omitted or empty, the @samp{##}
1715 operator causes the preprocessor to remove the comma before it. If you
1716 do provide some variable arguments in your macro invocation, GNU CPP
1717 does not complain about the paste operation and instead places the
1718 variable arguments after the comma. Just like any other pasted macro
1719 argument, these arguments are not macro expanded.
1720
1721 @node Escaped Newlines
1722 @section Slightly Looser Rules for Escaped Newlines
1723 @cindex escaped newlines
1724 @cindex newlines (escaped)
1725
1726 Recently, the preprocessor has relaxed its treatment of escaped
1727 newlines. Previously, the newline had to immediately follow a
1728 backslash. The current implementation allows whitespace in the form
1729 of spaces, horizontal and vertical tabs, and form feeds between the
1730 backslash and the subsequent newline. The preprocessor issues a
1731 warning, but treats it as a valid escaped newline and combines the two
1732 lines to form a single logical line. This works within comments and
1733 tokens, as well as between tokens. Comments are @emph{not} treated as
1734 whitespace for the purposes of this relaxation, since they have not
1735 yet been replaced with spaces.
1736
1737 @node Subscripting
1738 @section Non-Lvalue Arrays May Have Subscripts
1739 @cindex subscripting
1740 @cindex arrays, non-lvalue
1741
1742 @cindex subscripting and function values
1743 In ISO C99, arrays that are not lvalues still decay to pointers, and
1744 may be subscripted, although they may not be modified or used after
1745 the next sequence point and the unary @samp{&} operator may not be
1746 applied to them. As an extension, GNU C allows such arrays to be
1747 subscripted in C90 mode, though otherwise they do not decay to
1748 pointers outside C99 mode. For example,
1749 this is valid in GNU C though not valid in C90:
1750
1751 @smallexample
1752 @group
1753 struct foo @{int a[4];@};
1754
1755 struct foo f();
1756
1757 bar (int index)
1758 @{
1759 return f().a[index];
1760 @}
1761 @end group
1762 @end smallexample
1763
1764 @node Pointer Arith
1765 @section Arithmetic on @code{void}- and Function-Pointers
1766 @cindex void pointers, arithmetic
1767 @cindex void, size of pointer to
1768 @cindex function pointers, arithmetic
1769 @cindex function, size of pointer to
1770
1771 In GNU C, addition and subtraction operations are supported on pointers to
1772 @code{void} and on pointers to functions. This is done by treating the
1773 size of a @code{void} or of a function as 1.
1774
1775 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1776 and on function types, and returns 1.
1777
1778 @opindex Wpointer-arith
1779 The option @option{-Wpointer-arith} requests a warning if these extensions
1780 are used.
1781
1782 @node Initializers
1783 @section Non-Constant Initializers
1784 @cindex initializers, non-constant
1785 @cindex non-constant initializers
1786
1787 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1788 automatic variable are not required to be constant expressions in GNU C@.
1789 Here is an example of an initializer with run-time varying elements:
1790
1791 @smallexample
1792 foo (float f, float g)
1793 @{
1794 float beat_freqs[2] = @{ f-g, f+g @};
1795 /* @r{@dots{}} */
1796 @}
1797 @end smallexample
1798
1799 @node Compound Literals
1800 @section Compound Literals
1801 @cindex constructor expressions
1802 @cindex initializations in expressions
1803 @cindex structures, constructor expression
1804 @cindex expressions, constructor
1805 @cindex compound literals
1806 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1807
1808 ISO C99 supports compound literals. A compound literal looks like
1809 a cast containing an initializer. Its value is an object of the
1810 type specified in the cast, containing the elements specified in
1811 the initializer; it is an lvalue. As an extension, GCC supports
1812 compound literals in C90 mode and in C++, though the semantics are
1813 somewhat different in C++.
1814
1815 Usually, the specified type is a structure. Assume that
1816 @code{struct foo} and @code{structure} are declared as shown:
1817
1818 @smallexample
1819 struct foo @{int a; char b[2];@} structure;
1820 @end smallexample
1821
1822 @noindent
1823 Here is an example of constructing a @code{struct foo} with a compound literal:
1824
1825 @smallexample
1826 structure = ((struct foo) @{x + y, 'a', 0@});
1827 @end smallexample
1828
1829 @noindent
1830 This is equivalent to writing the following:
1831
1832 @smallexample
1833 @{
1834 struct foo temp = @{x + y, 'a', 0@};
1835 structure = temp;
1836 @}
1837 @end smallexample
1838
1839 You can also construct an array, though this is dangerous in C++, as
1840 explained below. If all the elements of the compound literal are
1841 (made up of) simple constant expressions, suitable for use in
1842 initializers of objects of static storage duration, then the compound
1843 literal can be coerced to a pointer to its first element and used in
1844 such an initializer, as shown here:
1845
1846 @smallexample
1847 char **foo = (char *[]) @{ "x", "y", "z" @};
1848 @end smallexample
1849
1850 Compound literals for scalar types and union types are
1851 also allowed, but then the compound literal is equivalent
1852 to a cast.
1853
1854 As a GNU extension, GCC allows initialization of objects with static storage
1855 duration by compound literals (which is not possible in ISO C99, because
1856 the initializer is not a constant).
1857 It is handled as if the object is initialized only with the bracket
1858 enclosed list if the types of the compound literal and the object match.
1859 The initializer list of the compound literal must be constant.
1860 If the object being initialized has array type of unknown size, the size is
1861 determined by compound literal size.
1862
1863 @smallexample
1864 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1865 static int y[] = (int []) @{1, 2, 3@};
1866 static int z[] = (int [3]) @{1@};
1867 @end smallexample
1868
1869 @noindent
1870 The above lines are equivalent to the following:
1871 @smallexample
1872 static struct foo x = @{1, 'a', 'b'@};
1873 static int y[] = @{1, 2, 3@};
1874 static int z[] = @{1, 0, 0@};
1875 @end smallexample
1876
1877 In C, a compound literal designates an unnamed object with static or
1878 automatic storage duration. In C++, a compound literal designates a
1879 temporary object, which only lives until the end of its
1880 full-expression. As a result, well-defined C code that takes the
1881 address of a subobject of a compound literal can be undefined in C++.
1882 For instance, if the array compound literal example above appeared
1883 inside a function, any subsequent use of @samp{foo} in C++ has
1884 undefined behavior because the lifetime of the array ends after the
1885 declaration of @samp{foo}. As a result, the C++ compiler now rejects
1886 the conversion of a temporary array to a pointer.
1887
1888 As an optimization, the C++ compiler sometimes gives array compound
1889 literals longer lifetimes: when the array either appears outside a
1890 function or has const-qualified type. If @samp{foo} and its
1891 initializer had elements of @samp{char *const} type rather than
1892 @samp{char *}, or if @samp{foo} were a global variable, the array
1893 would have static storage duration. But it is probably safest just to
1894 avoid the use of array compound literals in code compiled as C++.
1895
1896 @node Designated Inits
1897 @section Designated Initializers
1898 @cindex initializers with labeled elements
1899 @cindex labeled elements in initializers
1900 @cindex case labels in initializers
1901 @cindex designated initializers
1902
1903 Standard C90 requires the elements of an initializer to appear in a fixed
1904 order, the same as the order of the elements in the array or structure
1905 being initialized.
1906
1907 In ISO C99 you can give the elements in any order, specifying the array
1908 indices or structure field names they apply to, and GNU C allows this as
1909 an extension in C90 mode as well. This extension is not
1910 implemented in GNU C++.
1911
1912 To specify an array index, write
1913 @samp{[@var{index}] =} before the element value. For example,
1914
1915 @smallexample
1916 int a[6] = @{ [4] = 29, [2] = 15 @};
1917 @end smallexample
1918
1919 @noindent
1920 is equivalent to
1921
1922 @smallexample
1923 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1924 @end smallexample
1925
1926 @noindent
1927 The index values must be constant expressions, even if the array being
1928 initialized is automatic.
1929
1930 An alternative syntax for this that has been obsolete since GCC 2.5 but
1931 GCC still accepts is to write @samp{[@var{index}]} before the element
1932 value, with no @samp{=}.
1933
1934 To initialize a range of elements to the same value, write
1935 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
1936 extension. For example,
1937
1938 @smallexample
1939 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1940 @end smallexample
1941
1942 @noindent
1943 If the value in it has side-effects, the side-effects happen only once,
1944 not for each initialized field by the range initializer.
1945
1946 @noindent
1947 Note that the length of the array is the highest value specified
1948 plus one.
1949
1950 In a structure initializer, specify the name of a field to initialize
1951 with @samp{.@var{fieldname} =} before the element value. For example,
1952 given the following structure,
1953
1954 @smallexample
1955 struct point @{ int x, y; @};
1956 @end smallexample
1957
1958 @noindent
1959 the following initialization
1960
1961 @smallexample
1962 struct point p = @{ .y = yvalue, .x = xvalue @};
1963 @end smallexample
1964
1965 @noindent
1966 is equivalent to
1967
1968 @smallexample
1969 struct point p = @{ xvalue, yvalue @};
1970 @end smallexample
1971
1972 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1973 @samp{@var{fieldname}:}, as shown here:
1974
1975 @smallexample
1976 struct point p = @{ y: yvalue, x: xvalue @};
1977 @end smallexample
1978
1979 Omitted field members are implicitly initialized the same as objects
1980 that have static storage duration.
1981
1982 @cindex designators
1983 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1984 @dfn{designator}. You can also use a designator (or the obsolete colon
1985 syntax) when initializing a union, to specify which element of the union
1986 should be used. For example,
1987
1988 @smallexample
1989 union foo @{ int i; double d; @};
1990
1991 union foo f = @{ .d = 4 @};
1992 @end smallexample
1993
1994 @noindent
1995 converts 4 to a @code{double} to store it in the union using
1996 the second element. By contrast, casting 4 to type @code{union foo}
1997 stores it into the union as the integer @code{i}, since it is
1998 an integer. (@xref{Cast to Union}.)
1999
2000 You can combine this technique of naming elements with ordinary C
2001 initialization of successive elements. Each initializer element that
2002 does not have a designator applies to the next consecutive element of the
2003 array or structure. For example,
2004
2005 @smallexample
2006 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2007 @end smallexample
2008
2009 @noindent
2010 is equivalent to
2011
2012 @smallexample
2013 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2014 @end smallexample
2015
2016 Labeling the elements of an array initializer is especially useful
2017 when the indices are characters or belong to an @code{enum} type.
2018 For example:
2019
2020 @smallexample
2021 int whitespace[256]
2022 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2023 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2024 @end smallexample
2025
2026 @cindex designator lists
2027 You can also write a series of @samp{.@var{fieldname}} and
2028 @samp{[@var{index}]} designators before an @samp{=} to specify a
2029 nested subobject to initialize; the list is taken relative to the
2030 subobject corresponding to the closest surrounding brace pair. For
2031 example, with the @samp{struct point} declaration above:
2032
2033 @smallexample
2034 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2035 @end smallexample
2036
2037 @noindent
2038 If the same field is initialized multiple times, it has the value from
2039 the last initialization. If any such overridden initialization has
2040 side-effect, it is unspecified whether the side-effect happens or not.
2041 Currently, GCC discards them and issues a warning.
2042
2043 @node Case Ranges
2044 @section Case Ranges
2045 @cindex case ranges
2046 @cindex ranges in case statements
2047
2048 You can specify a range of consecutive values in a single @code{case} label,
2049 like this:
2050
2051 @smallexample
2052 case @var{low} ... @var{high}:
2053 @end smallexample
2054
2055 @noindent
2056 This has the same effect as the proper number of individual @code{case}
2057 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2058
2059 This feature is especially useful for ranges of ASCII character codes:
2060
2061 @smallexample
2062 case 'A' ... 'Z':
2063 @end smallexample
2064
2065 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2066 it may be parsed wrong when you use it with integer values. For example,
2067 write this:
2068
2069 @smallexample
2070 case 1 ... 5:
2071 @end smallexample
2072
2073 @noindent
2074 rather than this:
2075
2076 @smallexample
2077 case 1...5:
2078 @end smallexample
2079
2080 @node Cast to Union
2081 @section Cast to a Union Type
2082 @cindex cast to a union
2083 @cindex union, casting to a
2084
2085 A cast to union type is similar to other casts, except that the type
2086 specified is a union type. You can specify the type either with
2087 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2088 a constructor, not a cast, and hence does not yield an lvalue like
2089 normal casts. (@xref{Compound Literals}.)
2090
2091 The types that may be cast to the union type are those of the members
2092 of the union. Thus, given the following union and variables:
2093
2094 @smallexample
2095 union foo @{ int i; double d; @};
2096 int x;
2097 double y;
2098 @end smallexample
2099
2100 @noindent
2101 both @code{x} and @code{y} can be cast to type @code{union foo}.
2102
2103 Using the cast as the right-hand side of an assignment to a variable of
2104 union type is equivalent to storing in a member of the union:
2105
2106 @smallexample
2107 union foo u;
2108 /* @r{@dots{}} */
2109 u = (union foo) x @equiv{} u.i = x
2110 u = (union foo) y @equiv{} u.d = y
2111 @end smallexample
2112
2113 You can also use the union cast as a function argument:
2114
2115 @smallexample
2116 void hack (union foo);
2117 /* @r{@dots{}} */
2118 hack ((union foo) x);
2119 @end smallexample
2120
2121 @node Mixed Declarations
2122 @section Mixed Declarations and Code
2123 @cindex mixed declarations and code
2124 @cindex declarations, mixed with code
2125 @cindex code, mixed with declarations
2126
2127 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2128 within compound statements. As an extension, GNU C also allows this in
2129 C90 mode. For example, you could do:
2130
2131 @smallexample
2132 int i;
2133 /* @r{@dots{}} */
2134 i++;
2135 int j = i + 2;
2136 @end smallexample
2137
2138 Each identifier is visible from where it is declared until the end of
2139 the enclosing block.
2140
2141 @node Function Attributes
2142 @section Declaring Attributes of Functions
2143 @cindex function attributes
2144 @cindex declaring attributes of functions
2145 @cindex functions that never return
2146 @cindex functions that return more than once
2147 @cindex functions that have no side effects
2148 @cindex functions in arbitrary sections
2149 @cindex functions that behave like malloc
2150 @cindex @code{volatile} applied to function
2151 @cindex @code{const} applied to function
2152 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2153 @cindex functions with non-null pointer arguments
2154 @cindex functions that are passed arguments in registers on the 386
2155 @cindex functions that pop the argument stack on the 386
2156 @cindex functions that do not pop the argument stack on the 386
2157 @cindex functions that have different compilation options on the 386
2158 @cindex functions that have different optimization options
2159 @cindex functions that are dynamically resolved
2160
2161 In GNU C, you declare certain things about functions called in your program
2162 which help the compiler optimize function calls and check your code more
2163 carefully.
2164
2165 The keyword @code{__attribute__} allows you to specify special
2166 attributes when making a declaration. This keyword is followed by an
2167 attribute specification inside double parentheses. The following
2168 attributes are currently defined for functions on all targets:
2169 @code{aligned}, @code{alloc_size}, @code{alloc_align}, @code{assume_aligned},
2170 @code{noreturn}, @code{returns_twice}, @code{noinline}, @code{noclone},
2171 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2172 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2173 @code{no_instrument_function}, @code{no_split_stack},
2174 @code{section}, @code{constructor},
2175 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2176 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2177 @code{warn_unused_result}, @code{nonnull},
2178 @code{returns_nonnull}, @code{gnu_inline},
2179 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2180 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2181 @code{no_sanitize_undefined},
2182 @code{error} and @code{warning}.
2183 Several other attributes are defined for functions on particular
2184 target systems. Other attributes, including @code{section} are
2185 supported for variables declarations (@pxref{Variable Attributes}),
2186 labels (@pxref{Label Attributes})
2187 and for types (@pxref{Type Attributes}).
2188
2189 GCC plugins may provide their own attributes.
2190
2191 You may also specify attributes with @samp{__} preceding and following
2192 each keyword. This allows you to use them in header files without
2193 being concerned about a possible macro of the same name. For example,
2194 you may use @code{__noreturn__} instead of @code{noreturn}.
2195
2196 @xref{Attribute Syntax}, for details of the exact syntax for using
2197 attributes.
2198
2199 @table @code
2200 @c Keep this table alphabetized by attribute name. Treat _ as space.
2201
2202 @item alias ("@var{target}")
2203 @cindex @code{alias} attribute
2204 The @code{alias} attribute causes the declaration to be emitted as an
2205 alias for another symbol, which must be specified. For instance,
2206
2207 @smallexample
2208 void __f () @{ /* @r{Do something.} */; @}
2209 void f () __attribute__ ((weak, alias ("__f")));
2210 @end smallexample
2211
2212 @noindent
2213 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2214 mangled name for the target must be used. It is an error if @samp{__f}
2215 is not defined in the same translation unit.
2216
2217 Not all target machines support this attribute.
2218
2219 @item aligned (@var{alignment})
2220 @cindex @code{aligned} attribute
2221 This attribute specifies a minimum alignment for the function,
2222 measured in bytes.
2223
2224 You cannot use this attribute to decrease the alignment of a function,
2225 only to increase it. However, when you explicitly specify a function
2226 alignment this overrides the effect of the
2227 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2228 function.
2229
2230 Note that the effectiveness of @code{aligned} attributes may be
2231 limited by inherent limitations in your linker. On many systems, the
2232 linker is only able to arrange for functions to be aligned up to a
2233 certain maximum alignment. (For some linkers, the maximum supported
2234 alignment may be very very small.) See your linker documentation for
2235 further information.
2236
2237 The @code{aligned} attribute can also be used for variables and fields
2238 (@pxref{Variable Attributes}.)
2239
2240 @item alloc_size
2241 @cindex @code{alloc_size} attribute
2242 The @code{alloc_size} attribute is used to tell the compiler that the
2243 function return value points to memory, where the size is given by
2244 one or two of the functions parameters. GCC uses this
2245 information to improve the correctness of @code{__builtin_object_size}.
2246
2247 The function parameter(s) denoting the allocated size are specified by
2248 one or two integer arguments supplied to the attribute. The allocated size
2249 is either the value of the single function argument specified or the product
2250 of the two function arguments specified. Argument numbering starts at
2251 one.
2252
2253 For instance,
2254
2255 @smallexample
2256 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2257 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2258 @end smallexample
2259
2260 @noindent
2261 declares that @code{my_calloc} returns memory of the size given by
2262 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2263 of the size given by parameter 2.
2264
2265 @item alloc_align
2266 @cindex @code{alloc_align} attribute
2267 The @code{alloc_align} attribute is used to tell the compiler that the
2268 function return value points to memory, where the returned pointer minimum
2269 alignment is given by one of the functions parameters. GCC uses this
2270 information to improve pointer alignment analysis.
2271
2272 The function parameter denoting the allocated alignment is specified by
2273 one integer argument, whose number is the argument of the attribute.
2274 Argument numbering starts at one.
2275
2276 For instance,
2277
2278 @smallexample
2279 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2280 @end smallexample
2281
2282 @noindent
2283 declares that @code{my_memalign} returns memory with minimum alignment
2284 given by parameter 1.
2285
2286 @item assume_aligned
2287 @cindex @code{assume_aligned} attribute
2288 The @code{assume_aligned} attribute is used to tell the compiler that the
2289 function return value points to memory, where the returned pointer minimum
2290 alignment is given by the first argument.
2291 If the attribute has two arguments, the second argument is misalignment offset.
2292
2293 For instance
2294
2295 @smallexample
2296 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2297 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2298 @end smallexample
2299
2300 @noindent
2301 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2302 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2303 to 8.
2304
2305 @item always_inline
2306 @cindex @code{always_inline} function attribute
2307 Generally, functions are not inlined unless optimization is specified.
2308 For functions declared inline, this attribute inlines the function even
2309 if no optimization level is specified.
2310
2311 @item gnu_inline
2312 @cindex @code{gnu_inline} function attribute
2313 This attribute should be used with a function that is also declared
2314 with the @code{inline} keyword. It directs GCC to treat the function
2315 as if it were defined in gnu90 mode even when compiling in C99 or
2316 gnu99 mode.
2317
2318 If the function is declared @code{extern}, then this definition of the
2319 function is used only for inlining. In no case is the function
2320 compiled as a standalone function, not even if you take its address
2321 explicitly. Such an address becomes an external reference, as if you
2322 had only declared the function, and had not defined it. This has
2323 almost the effect of a macro. The way to use this is to put a
2324 function definition in a header file with this attribute, and put
2325 another copy of the function, without @code{extern}, in a library
2326 file. The definition in the header file causes most calls to the
2327 function to be inlined. If any uses of the function remain, they
2328 refer to the single copy in the library. Note that the two
2329 definitions of the functions need not be precisely the same, although
2330 if they do not have the same effect your program may behave oddly.
2331
2332 In C, if the function is neither @code{extern} nor @code{static}, then
2333 the function is compiled as a standalone function, as well as being
2334 inlined where possible.
2335
2336 This is how GCC traditionally handled functions declared
2337 @code{inline}. Since ISO C99 specifies a different semantics for
2338 @code{inline}, this function attribute is provided as a transition
2339 measure and as a useful feature in its own right. This attribute is
2340 available in GCC 4.1.3 and later. It is available if either of the
2341 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2342 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2343 Function is As Fast As a Macro}.
2344
2345 In C++, this attribute does not depend on @code{extern} in any way,
2346 but it still requires the @code{inline} keyword to enable its special
2347 behavior.
2348
2349 @item artificial
2350 @cindex @code{artificial} function attribute
2351 This attribute is useful for small inline wrappers that if possible
2352 should appear during debugging as a unit. Depending on the debug
2353 info format it either means marking the function as artificial
2354 or using the caller location for all instructions within the inlined
2355 body.
2356
2357 @item bank_switch
2358 @cindex interrupt handler functions
2359 When added to an interrupt handler with the M32C port, causes the
2360 prologue and epilogue to use bank switching to preserve the registers
2361 rather than saving them on the stack.
2362
2363 @item flatten
2364 @cindex @code{flatten} function attribute
2365 Generally, inlining into a function is limited. For a function marked with
2366 this attribute, every call inside this function is inlined, if possible.
2367 Whether the function itself is considered for inlining depends on its size and
2368 the current inlining parameters.
2369
2370 @item error ("@var{message}")
2371 @cindex @code{error} function attribute
2372 If this attribute is used on a function declaration and a call to such a function
2373 is not eliminated through dead code elimination or other optimizations, an error
2374 that includes @var{message} is diagnosed. This is useful
2375 for compile-time checking, especially together with @code{__builtin_constant_p}
2376 and inline functions where checking the inline function arguments is not
2377 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2378 While it is possible to leave the function undefined and thus invoke
2379 a link failure, when using this attribute the problem is diagnosed
2380 earlier and with exact location of the call even in presence of inline
2381 functions or when not emitting debugging information.
2382
2383 @item warning ("@var{message}")
2384 @cindex @code{warning} function attribute
2385 If this attribute is used on a function declaration and a call to such a function
2386 is not eliminated through dead code elimination or other optimizations, a warning
2387 that includes @var{message} is diagnosed. This is useful
2388 for compile-time checking, especially together with @code{__builtin_constant_p}
2389 and inline functions. While it is possible to define the function with
2390 a message in @code{.gnu.warning*} section, when using this attribute the problem
2391 is diagnosed earlier and with exact location of the call even in presence
2392 of inline functions or when not emitting debugging information.
2393
2394 @item cdecl
2395 @cindex functions that do pop the argument stack on the 386
2396 @opindex mrtd
2397 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2398 assume that the calling function pops off the stack space used to
2399 pass arguments. This is
2400 useful to override the effects of the @option{-mrtd} switch.
2401
2402 @item const
2403 @cindex @code{const} function attribute
2404 Many functions do not examine any values except their arguments, and
2405 have no effects except the return value. Basically this is just slightly
2406 more strict class than the @code{pure} attribute below, since function is not
2407 allowed to read global memory.
2408
2409 @cindex pointer arguments
2410 Note that a function that has pointer arguments and examines the data
2411 pointed to must @emph{not} be declared @code{const}. Likewise, a
2412 function that calls a non-@code{const} function usually must not be
2413 @code{const}. It does not make sense for a @code{const} function to
2414 return @code{void}.
2415
2416 The attribute @code{const} is not implemented in GCC versions earlier
2417 than 2.5. An alternative way to declare that a function has no side
2418 effects, which works in the current version and in some older versions,
2419 is as follows:
2420
2421 @smallexample
2422 typedef int intfn ();
2423
2424 extern const intfn square;
2425 @end smallexample
2426
2427 @noindent
2428 This approach does not work in GNU C++ from 2.6.0 on, since the language
2429 specifies that the @samp{const} must be attached to the return value.
2430
2431 @item constructor
2432 @itemx destructor
2433 @itemx constructor (@var{priority})
2434 @itemx destructor (@var{priority})
2435 @cindex @code{constructor} function attribute
2436 @cindex @code{destructor} function attribute
2437 The @code{constructor} attribute causes the function to be called
2438 automatically before execution enters @code{main ()}. Similarly, the
2439 @code{destructor} attribute causes the function to be called
2440 automatically after @code{main ()} completes or @code{exit ()} is
2441 called. Functions with these attributes are useful for
2442 initializing data that is used implicitly during the execution of
2443 the program.
2444
2445 You may provide an optional integer priority to control the order in
2446 which constructor and destructor functions are run. A constructor
2447 with a smaller priority number runs before a constructor with a larger
2448 priority number; the opposite relationship holds for destructors. So,
2449 if you have a constructor that allocates a resource and a destructor
2450 that deallocates the same resource, both functions typically have the
2451 same priority. The priorities for constructor and destructor
2452 functions are the same as those specified for namespace-scope C++
2453 objects (@pxref{C++ Attributes}).
2454
2455 These attributes are not currently implemented for Objective-C@.
2456
2457 @item deprecated
2458 @itemx deprecated (@var{msg})
2459 @cindex @code{deprecated} attribute.
2460 The @code{deprecated} attribute results in a warning if the function
2461 is used anywhere in the source file. This is useful when identifying
2462 functions that are expected to be removed in a future version of a
2463 program. The warning also includes the location of the declaration
2464 of the deprecated function, to enable users to easily find further
2465 information about why the function is deprecated, or what they should
2466 do instead. Note that the warnings only occurs for uses:
2467
2468 @smallexample
2469 int old_fn () __attribute__ ((deprecated));
2470 int old_fn ();
2471 int (*fn_ptr)() = old_fn;
2472 @end smallexample
2473
2474 @noindent
2475 results in a warning on line 3 but not line 2. The optional @var{msg}
2476 argument, which must be a string, is printed in the warning if
2477 present.
2478
2479 The @code{deprecated} attribute can also be used for variables and
2480 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2481
2482 @item disinterrupt
2483 @cindex @code{disinterrupt} attribute
2484 On Epiphany and MeP targets, this attribute causes the compiler to emit
2485 instructions to disable interrupts for the duration of the given
2486 function.
2487
2488 @item dllexport
2489 @cindex @code{__declspec(dllexport)}
2490 On Microsoft Windows targets and Symbian OS targets the
2491 @code{dllexport} attribute causes the compiler to provide a global
2492 pointer to a pointer in a DLL, so that it can be referenced with the
2493 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
2494 name is formed by combining @code{_imp__} and the function or variable
2495 name.
2496
2497 You can use @code{__declspec(dllexport)} as a synonym for
2498 @code{__attribute__ ((dllexport))} for compatibility with other
2499 compilers.
2500
2501 On systems that support the @code{visibility} attribute, this
2502 attribute also implies ``default'' visibility. It is an error to
2503 explicitly specify any other visibility.
2504
2505 In previous versions of GCC, the @code{dllexport} attribute was ignored
2506 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2507 had been used. The default behavior now is to emit all dllexported
2508 inline functions; however, this can cause object file-size bloat, in
2509 which case the old behavior can be restored by using
2510 @option{-fno-keep-inline-dllexport}.
2511
2512 The attribute is also ignored for undefined symbols.
2513
2514 When applied to C++ classes, the attribute marks defined non-inlined
2515 member functions and static data members as exports. Static consts
2516 initialized in-class are not marked unless they are also defined
2517 out-of-class.
2518
2519 For Microsoft Windows targets there are alternative methods for
2520 including the symbol in the DLL's export table such as using a
2521 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2522 the @option{--export-all} linker flag.
2523
2524 @item dllimport
2525 @cindex @code{__declspec(dllimport)}
2526 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2527 attribute causes the compiler to reference a function or variable via
2528 a global pointer to a pointer that is set up by the DLL exporting the
2529 symbol. The attribute implies @code{extern}. On Microsoft Windows
2530 targets, the pointer name is formed by combining @code{_imp__} and the
2531 function or variable name.
2532
2533 You can use @code{__declspec(dllimport)} as a synonym for
2534 @code{__attribute__ ((dllimport))} for compatibility with other
2535 compilers.
2536
2537 On systems that support the @code{visibility} attribute, this
2538 attribute also implies ``default'' visibility. It is an error to
2539 explicitly specify any other visibility.
2540
2541 Currently, the attribute is ignored for inlined functions. If the
2542 attribute is applied to a symbol @emph{definition}, an error is reported.
2543 If a symbol previously declared @code{dllimport} is later defined, the
2544 attribute is ignored in subsequent references, and a warning is emitted.
2545 The attribute is also overridden by a subsequent declaration as
2546 @code{dllexport}.
2547
2548 When applied to C++ classes, the attribute marks non-inlined
2549 member functions and static data members as imports. However, the
2550 attribute is ignored for virtual methods to allow creation of vtables
2551 using thunks.
2552
2553 On the SH Symbian OS target the @code{dllimport} attribute also has
2554 another affect---it can cause the vtable and run-time type information
2555 for a class to be exported. This happens when the class has a
2556 dllimported constructor or a non-inline, non-pure virtual function
2557 and, for either of those two conditions, the class also has an inline
2558 constructor or destructor and has a key function that is defined in
2559 the current translation unit.
2560
2561 For Microsoft Windows targets the use of the @code{dllimport}
2562 attribute on functions is not necessary, but provides a small
2563 performance benefit by eliminating a thunk in the DLL@. The use of the
2564 @code{dllimport} attribute on imported variables was required on older
2565 versions of the GNU linker, but can now be avoided by passing the
2566 @option{--enable-auto-import} switch to the GNU linker. As with
2567 functions, using the attribute for a variable eliminates a thunk in
2568 the DLL@.
2569
2570 One drawback to using this attribute is that a pointer to a
2571 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2572 address. However, a pointer to a @emph{function} with the
2573 @code{dllimport} attribute can be used as a constant initializer; in
2574 this case, the address of a stub function in the import lib is
2575 referenced. On Microsoft Windows targets, the attribute can be disabled
2576 for functions by setting the @option{-mnop-fun-dllimport} flag.
2577
2578 @item eightbit_data
2579 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2580 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2581 variable should be placed into the eight-bit data section.
2582 The compiler generates more efficient code for certain operations
2583 on data in the eight-bit data area. Note the eight-bit data area is limited to
2584 256 bytes of data.
2585
2586 You must use GAS and GLD from GNU binutils version 2.7 or later for
2587 this attribute to work correctly.
2588
2589 @item exception
2590 @cindex exception handler functions
2591 Use this attribute on the NDS32 target to indicate that the specified function
2592 is an exception handler. The compiler will generate corresponding sections
2593 for use in an exception handler.
2594
2595 @item exception_handler
2596 @cindex exception handler functions on the Blackfin processor
2597 Use this attribute on the Blackfin to indicate that the specified function
2598 is an exception handler. The compiler generates function entry and
2599 exit sequences suitable for use in an exception handler when this
2600 attribute is present.
2601
2602 @item externally_visible
2603 @cindex @code{externally_visible} attribute.
2604 This attribute, attached to a global variable or function, nullifies
2605 the effect of the @option{-fwhole-program} command-line option, so the
2606 object remains visible outside the current compilation unit.
2607
2608 If @option{-fwhole-program} is used together with @option{-flto} and
2609 @command{gold} is used as the linker plugin,
2610 @code{externally_visible} attributes are automatically added to functions
2611 (not variable yet due to a current @command{gold} issue)
2612 that are accessed outside of LTO objects according to resolution file
2613 produced by @command{gold}.
2614 For other linkers that cannot generate resolution file,
2615 explicit @code{externally_visible} attributes are still necessary.
2616
2617 @item far
2618 @cindex functions that handle memory bank switching
2619 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2620 use a calling convention that takes care of switching memory banks when
2621 entering and leaving a function. This calling convention is also the
2622 default when using the @option{-mlong-calls} option.
2623
2624 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2625 to call and return from a function.
2626
2627 On 68HC11 the compiler generates a sequence of instructions
2628 to invoke a board-specific routine to switch the memory bank and call the
2629 real function. The board-specific routine simulates a @code{call}.
2630 At the end of a function, it jumps to a board-specific routine
2631 instead of using @code{rts}. The board-specific return routine simulates
2632 the @code{rtc}.
2633
2634 On MeP targets this causes the compiler to use a calling convention
2635 that assumes the called function is too far away for the built-in
2636 addressing modes.
2637
2638 @item fast_interrupt
2639 @cindex interrupt handler functions
2640 Use this attribute on the M32C and RX ports to indicate that the specified
2641 function is a fast interrupt handler. This is just like the
2642 @code{interrupt} attribute, except that @code{freit} is used to return
2643 instead of @code{reit}.
2644
2645 @item fastcall
2646 @cindex functions that pop the argument stack on the 386
2647 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2648 pass the first argument (if of integral type) in the register ECX and
2649 the second argument (if of integral type) in the register EDX@. Subsequent
2650 and other typed arguments are passed on the stack. The called function
2651 pops the arguments off the stack. If the number of arguments is variable all
2652 arguments are pushed on the stack.
2653
2654 @item thiscall
2655 @cindex functions that pop the argument stack on the 386
2656 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2657 pass the first argument (if of integral type) in the register ECX.
2658 Subsequent and other typed arguments are passed on the stack. The called
2659 function pops the arguments off the stack.
2660 If the number of arguments is variable all arguments are pushed on the
2661 stack.
2662 The @code{thiscall} attribute is intended for C++ non-static member functions.
2663 As a GCC extension, this calling convention can be used for C functions
2664 and for static member methods.
2665
2666 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2667 @cindex @code{format} function attribute
2668 @opindex Wformat
2669 The @code{format} attribute specifies that a function takes @code{printf},
2670 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2671 should be type-checked against a format string. For example, the
2672 declaration:
2673
2674 @smallexample
2675 extern int
2676 my_printf (void *my_object, const char *my_format, ...)
2677 __attribute__ ((format (printf, 2, 3)));
2678 @end smallexample
2679
2680 @noindent
2681 causes the compiler to check the arguments in calls to @code{my_printf}
2682 for consistency with the @code{printf} style format string argument
2683 @code{my_format}.
2684
2685 The parameter @var{archetype} determines how the format string is
2686 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2687 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2688 @code{strfmon}. (You can also use @code{__printf__},
2689 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2690 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2691 @code{ms_strftime} are also present.
2692 @var{archetype} values such as @code{printf} refer to the formats accepted
2693 by the system's C runtime library,
2694 while values prefixed with @samp{gnu_} always refer
2695 to the formats accepted by the GNU C Library. On Microsoft Windows
2696 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2697 @file{msvcrt.dll} library.
2698 The parameter @var{string-index}
2699 specifies which argument is the format string argument (starting
2700 from 1), while @var{first-to-check} is the number of the first
2701 argument to check against the format string. For functions
2702 where the arguments are not available to be checked (such as
2703 @code{vprintf}), specify the third parameter as zero. In this case the
2704 compiler only checks the format string for consistency. For
2705 @code{strftime} formats, the third parameter is required to be zero.
2706 Since non-static C++ methods have an implicit @code{this} argument, the
2707 arguments of such methods should be counted from two, not one, when
2708 giving values for @var{string-index} and @var{first-to-check}.
2709
2710 In the example above, the format string (@code{my_format}) is the second
2711 argument of the function @code{my_print}, and the arguments to check
2712 start with the third argument, so the correct parameters for the format
2713 attribute are 2 and 3.
2714
2715 @opindex ffreestanding
2716 @opindex fno-builtin
2717 The @code{format} attribute allows you to identify your own functions
2718 that take format strings as arguments, so that GCC can check the
2719 calls to these functions for errors. The compiler always (unless
2720 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2721 for the standard library functions @code{printf}, @code{fprintf},
2722 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2723 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2724 warnings are requested (using @option{-Wformat}), so there is no need to
2725 modify the header file @file{stdio.h}. In C99 mode, the functions
2726 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2727 @code{vsscanf} are also checked. Except in strictly conforming C
2728 standard modes, the X/Open function @code{strfmon} is also checked as
2729 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2730 @xref{C Dialect Options,,Options Controlling C Dialect}.
2731
2732 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2733 recognized in the same context. Declarations including these format attributes
2734 are parsed for correct syntax, however the result of checking of such format
2735 strings is not yet defined, and is not carried out by this version of the
2736 compiler.
2737
2738 The target may also provide additional types of format checks.
2739 @xref{Target Format Checks,,Format Checks Specific to Particular
2740 Target Machines}.
2741
2742 @item format_arg (@var{string-index})
2743 @cindex @code{format_arg} function attribute
2744 @opindex Wformat-nonliteral
2745 The @code{format_arg} attribute specifies that a function takes a format
2746 string for a @code{printf}, @code{scanf}, @code{strftime} or
2747 @code{strfmon} style function and modifies it (for example, to translate
2748 it into another language), so the result can be passed to a
2749 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2750 function (with the remaining arguments to the format function the same
2751 as they would have been for the unmodified string). For example, the
2752 declaration:
2753
2754 @smallexample
2755 extern char *
2756 my_dgettext (char *my_domain, const char *my_format)
2757 __attribute__ ((format_arg (2)));
2758 @end smallexample
2759
2760 @noindent
2761 causes the compiler to check the arguments in calls to a @code{printf},
2762 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2763 format string argument is a call to the @code{my_dgettext} function, for
2764 consistency with the format string argument @code{my_format}. If the
2765 @code{format_arg} attribute had not been specified, all the compiler
2766 could tell in such calls to format functions would be that the format
2767 string argument is not constant; this would generate a warning when
2768 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2769 without the attribute.
2770
2771 The parameter @var{string-index} specifies which argument is the format
2772 string argument (starting from one). Since non-static C++ methods have
2773 an implicit @code{this} argument, the arguments of such methods should
2774 be counted from two.
2775
2776 The @code{format_arg} attribute allows you to identify your own
2777 functions that modify format strings, so that GCC can check the
2778 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2779 type function whose operands are a call to one of your own function.
2780 The compiler always treats @code{gettext}, @code{dgettext}, and
2781 @code{dcgettext} in this manner except when strict ISO C support is
2782 requested by @option{-ansi} or an appropriate @option{-std} option, or
2783 @option{-ffreestanding} or @option{-fno-builtin}
2784 is used. @xref{C Dialect Options,,Options
2785 Controlling C Dialect}.
2786
2787 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2788 @code{NSString} reference for compatibility with the @code{format} attribute
2789 above.
2790
2791 The target may also allow additional types in @code{format-arg} attributes.
2792 @xref{Target Format Checks,,Format Checks Specific to Particular
2793 Target Machines}.
2794
2795 @item function_vector
2796 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2797 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2798 function should be called through the function vector. Calling a
2799 function through the function vector reduces code size, however;
2800 the function vector has a limited size (maximum 128 entries on the H8/300
2801 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2802
2803 On SH2A targets, this attribute declares a function to be called using the
2804 TBR relative addressing mode. The argument to this attribute is the entry
2805 number of the same function in a vector table containing all the TBR
2806 relative addressable functions. For correct operation the TBR must be setup
2807 accordingly to point to the start of the vector table before any functions with
2808 this attribute are invoked. Usually a good place to do the initialization is
2809 the startup routine. The TBR relative vector table can have at max 256 function
2810 entries. The jumps to these functions are generated using a SH2A specific,
2811 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
2812 from GNU binutils version 2.7 or later for this attribute to work correctly.
2813
2814 Please refer the example of M16C target, to see the use of this
2815 attribute while declaring a function,
2816
2817 In an application, for a function being called once, this attribute
2818 saves at least 8 bytes of code; and if other successive calls are being
2819 made to the same function, it saves 2 bytes of code per each of these
2820 calls.
2821
2822 On M16C/M32C targets, the @code{function_vector} attribute declares a
2823 special page subroutine call function. Use of this attribute reduces
2824 the code size by 2 bytes for each call generated to the
2825 subroutine. The argument to the attribute is the vector number entry
2826 from the special page vector table which contains the 16 low-order
2827 bits of the subroutine's entry address. Each vector table has special
2828 page number (18 to 255) that is used in @code{jsrs} instructions.
2829 Jump addresses of the routines are generated by adding 0x0F0000 (in
2830 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2831 2-byte addresses set in the vector table. Therefore you need to ensure
2832 that all the special page vector routines should get mapped within the
2833 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2834 (for M32C).
2835
2836 In the following example 2 bytes are saved for each call to
2837 function @code{foo}.
2838
2839 @smallexample
2840 void foo (void) __attribute__((function_vector(0x18)));
2841 void foo (void)
2842 @{
2843 @}
2844
2845 void bar (void)
2846 @{
2847 foo();
2848 @}
2849 @end smallexample
2850
2851 If functions are defined in one file and are called in another file,
2852 then be sure to write this declaration in both files.
2853
2854 This attribute is ignored for R8C target.
2855
2856 @item ifunc ("@var{resolver}")
2857 @cindex @code{ifunc} attribute
2858 The @code{ifunc} attribute is used to mark a function as an indirect
2859 function using the STT_GNU_IFUNC symbol type extension to the ELF
2860 standard. This allows the resolution of the symbol value to be
2861 determined dynamically at load time, and an optimized version of the
2862 routine can be selected for the particular processor or other system
2863 characteristics determined then. To use this attribute, first define
2864 the implementation functions available, and a resolver function that
2865 returns a pointer to the selected implementation function. The
2866 implementation functions' declarations must match the API of the
2867 function being implemented, the resolver's declaration is be a
2868 function returning pointer to void function returning void:
2869
2870 @smallexample
2871 void *my_memcpy (void *dst, const void *src, size_t len)
2872 @{
2873 @dots{}
2874 @}
2875
2876 static void (*resolve_memcpy (void)) (void)
2877 @{
2878 return my_memcpy; // we'll just always select this routine
2879 @}
2880 @end smallexample
2881
2882 @noindent
2883 The exported header file declaring the function the user calls would
2884 contain:
2885
2886 @smallexample
2887 extern void *memcpy (void *, const void *, size_t);
2888 @end smallexample
2889
2890 @noindent
2891 allowing the user to call this as a regular function, unaware of the
2892 implementation. Finally, the indirect function needs to be defined in
2893 the same translation unit as the resolver function:
2894
2895 @smallexample
2896 void *memcpy (void *, const void *, size_t)
2897 __attribute__ ((ifunc ("resolve_memcpy")));
2898 @end smallexample
2899
2900 Indirect functions cannot be weak, and require a recent binutils (at
2901 least version 2.20.1), and GNU C library (at least version 2.11.1).
2902
2903 @item interrupt
2904 @cindex interrupt handler functions
2905 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2906 m68k, MeP, MIPS, MSP430, RL78, RX and Xstormy16 ports to indicate that
2907 the specified function is an
2908 interrupt handler. The compiler generates function entry and exit
2909 sequences suitable for use in an interrupt handler when this attribute
2910 is present. With Epiphany targets it may also generate a special section with
2911 code to initialize the interrupt vector table.
2912
2913 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2914 and SH processors can be specified via the @code{interrupt_handler} attribute.
2915
2916 Note, on the ARC, you must specify the kind of interrupt to be handled
2917 in a parameter to the interrupt attribute like this:
2918
2919 @smallexample
2920 void f () __attribute__ ((interrupt ("ilink1")));
2921 @end smallexample
2922
2923 Permissible values for this parameter are: @w{@code{ilink1}} and
2924 @w{@code{ilink2}}.
2925
2926 Note, on the AVR, the hardware globally disables interrupts when an
2927 interrupt is executed. The first instruction of an interrupt handler
2928 declared with this attribute is a @code{SEI} instruction to
2929 re-enable interrupts. See also the @code{signal} function attribute
2930 that does not insert a @code{SEI} instruction. If both @code{signal} and
2931 @code{interrupt} are specified for the same function, @code{signal}
2932 is silently ignored.
2933
2934 Note, for the ARM, you can specify the kind of interrupt to be handled by
2935 adding an optional parameter to the interrupt attribute like this:
2936
2937 @smallexample
2938 void f () __attribute__ ((interrupt ("IRQ")));
2939 @end smallexample
2940
2941 @noindent
2942 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2943 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2944
2945 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2946 may be called with a word-aligned stack pointer.
2947
2948 Note, for the MSP430 you can provide an argument to the interrupt
2949 attribute which specifies a name or number. If the argument is a
2950 number it indicates the slot in the interrupt vector table (0 - 31) to
2951 which this handler should be assigned. If the argument is a name it
2952 is treated as a symbolic name for the vector slot. These names should
2953 match up with appropriate entries in the linker script. By default
2954 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2955 @code{reset} for vector 31 are recognised.
2956
2957 You can also use the following function attributes to modify how
2958 normal functions interact with interrupt functions:
2959
2960 @table @code
2961 @item critical
2962 @cindex @code{critical} attribute
2963 Critical functions disable interrupts upon entry and restore the
2964 previous interrupt state upon exit. Critical functions cannot also
2965 have the @code{naked} or @code{reentrant} attributes. They can have
2966 the @code{interrupt} attribute.
2967
2968 @item reentrant
2969 @cindex @code{reentrant} attribute
2970 Reentrant functions disable interrupts upon entry and enable them
2971 upon exit. Reentrant functions cannot also have the @code{naked}
2972 or @code{critical} attributes. They can have the @code{interrupt}
2973 attribute.
2974
2975 @item wakeup
2976 @cindex @code{wakeup} attribute
2977 This attribute only applies to interrupt functions. It is silently
2978 ignored if applied to a non-interrupt function. A wakeup interrupt
2979 function will rouse the processor from any low-power state that it
2980 might be in when the function exits.
2981
2982 @end table
2983
2984 On Epiphany targets one or more optional parameters can be added like this:
2985
2986 @smallexample
2987 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2988 @end smallexample
2989
2990 Permissible values for these parameters are: @w{@code{reset}},
2991 @w{@code{software_exception}}, @w{@code{page_miss}},
2992 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
2993 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
2994 Multiple parameters indicate that multiple entries in the interrupt
2995 vector table should be initialized for this function, i.e.@: for each
2996 parameter @w{@var{name}}, a jump to the function is emitted in
2997 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
2998 entirely, in which case no interrupt vector table entry is provided.
2999
3000 Note, on Epiphany targets, interrupts are enabled inside the function
3001 unless the @code{disinterrupt} attribute is also specified.
3002
3003 On Epiphany targets, you can also use the following attribute to
3004 modify the behavior of an interrupt handler:
3005 @table @code
3006 @item forwarder_section
3007 @cindex @code{forwarder_section} attribute
3008 The interrupt handler may be in external memory which cannot be
3009 reached by a branch instruction, so generate a local memory trampoline
3010 to transfer control. The single parameter identifies the section where
3011 the trampoline is placed.
3012 @end table
3013
3014 The following examples are all valid uses of these attributes on
3015 Epiphany targets:
3016 @smallexample
3017 void __attribute__ ((interrupt)) universal_handler ();
3018 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3019 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3020 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3021 fast_timer_handler ();
3022 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
3023 external_dma_handler ();
3024 @end smallexample
3025
3026 On MIPS targets, you can use the following attributes to modify the behavior
3027 of an interrupt handler:
3028 @table @code
3029 @item use_shadow_register_set
3030 @cindex @code{use_shadow_register_set} attribute
3031 Assume that the handler uses a shadow register set, instead of
3032 the main general-purpose registers.
3033
3034 @item keep_interrupts_masked
3035 @cindex @code{keep_interrupts_masked} attribute
3036 Keep interrupts masked for the whole function. Without this attribute,
3037 GCC tries to reenable interrupts for as much of the function as it can.
3038
3039 @item use_debug_exception_return
3040 @cindex @code{use_debug_exception_return} attribute
3041 Return using the @code{deret} instruction. Interrupt handlers that don't
3042 have this attribute return using @code{eret} instead.
3043 @end table
3044
3045 You can use any combination of these attributes, as shown below:
3046 @smallexample
3047 void __attribute__ ((interrupt)) v0 ();
3048 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
3049 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
3050 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
3051 void __attribute__ ((interrupt, use_shadow_register_set,
3052 keep_interrupts_masked)) v4 ();
3053 void __attribute__ ((interrupt, use_shadow_register_set,
3054 use_debug_exception_return)) v5 ();
3055 void __attribute__ ((interrupt, keep_interrupts_masked,
3056 use_debug_exception_return)) v6 ();
3057 void __attribute__ ((interrupt, use_shadow_register_set,
3058 keep_interrupts_masked,
3059 use_debug_exception_return)) v7 ();
3060 @end smallexample
3061
3062 On NDS32 target, this attribute is to indicate that the specified function
3063 is an interrupt handler. The compiler will generate corresponding sections
3064 for use in an interrupt handler. You can use the following attributes
3065 to modify the behavior:
3066 @table @code
3067 @item nested
3068 @cindex @code{nested} attribute
3069 This interrupt service routine is interruptible.
3070 @item not_nested
3071 @cindex @code{not_nested} attribute
3072 This interrupt service routine is not interruptible.
3073 @item nested_ready
3074 @cindex @code{nested_ready} attribute
3075 This interrupt service routine is interruptible after @code{PSW.GIE}
3076 (global interrupt enable) is set. This allows interrupt service routine to
3077 finish some short critical code before enabling interrupts.
3078 @item save_all
3079 @cindex @code{save_all} attribute
3080 The system will help save all registers into stack before entering
3081 interrupt handler.
3082 @item partial_save
3083 @cindex @code{partial_save} attribute
3084 The system will help save caller registers into stack before entering
3085 interrupt handler.
3086 @end table
3087
3088 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
3089 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
3090 that must end with @code{RETB} instead of @code{RETI}).
3091
3092 On RX targets, you may specify one or more vector numbers as arguments
3093 to the attribute, as well as naming an alternate table name.
3094 Parameters are handled sequentially, so one handler can be assigned to
3095 multiple entries in multiple tables. One may also pass the magic
3096 string @code{"$default"} which causes the function to be used for any
3097 unfilled slots in the current table.
3098
3099 This example shows a simple assignment of a function to one vector in
3100 the default table (note that preprocessor macros may be used for
3101 chip-specific symbolic vector names):
3102 @smallexample
3103 void __attribute__ ((interrupt (5))) txd1_handler ();
3104 @end smallexample
3105
3106 This example assigns a function to two slots in the default table
3107 (using preprocessor macros defined elsewhere) and makes it the default
3108 for the @code{dct} table:
3109 @smallexample
3110 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
3111 txd1_handler ();
3112 @end smallexample
3113
3114 @item interrupt_handler
3115 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
3116 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
3117 indicate that the specified function is an interrupt handler. The compiler
3118 generates function entry and exit sequences suitable for use in an
3119 interrupt handler when this attribute is present.
3120
3121 @item interrupt_thread
3122 @cindex interrupt thread functions on fido
3123 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3124 that the specified function is an interrupt handler that is designed
3125 to run as a thread. The compiler omits generate prologue/epilogue
3126 sequences and replaces the return instruction with a @code{sleep}
3127 instruction. This attribute is available only on fido.
3128
3129 @item isr
3130 @cindex interrupt service routines on ARM
3131 Use this attribute on ARM to write Interrupt Service Routines. This is an
3132 alias to the @code{interrupt} attribute above.
3133
3134 @item kspisusp
3135 @cindex User stack pointer in interrupts on the Blackfin
3136 When used together with @code{interrupt_handler}, @code{exception_handler}
3137 or @code{nmi_handler}, code is generated to load the stack pointer
3138 from the USP register in the function prologue.
3139
3140 @item l1_text
3141 @cindex @code{l1_text} function attribute
3142 This attribute specifies a function to be placed into L1 Instruction
3143 SRAM@. The function is put into a specific section named @code{.l1.text}.
3144 With @option{-mfdpic}, function calls with a such function as the callee
3145 or caller uses inlined PLT.
3146
3147 @item l2
3148 @cindex @code{l2} function attribute
3149 On the Blackfin, this attribute specifies a function to be placed into L2
3150 SRAM. The function is put into a specific section named
3151 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3152 an inlined PLT.
3153
3154 @item leaf
3155 @cindex @code{leaf} function attribute
3156 Calls to external functions with this attribute must return to the current
3157 compilation unit only by return or by exception handling. In particular, leaf
3158 functions are not allowed to call callback function passed to it from the current
3159 compilation unit or directly call functions exported by the unit or longjmp
3160 into the unit. Leaf function might still call functions from other compilation
3161 units and thus they are not necessarily leaf in the sense that they contain no
3162 function calls at all.
3163
3164 The attribute is intended for library functions to improve dataflow analysis.
3165 The compiler takes the hint that any data not escaping the current compilation unit can
3166 not be used or modified by the leaf function. For example, the @code{sin} function
3167 is a leaf function, but @code{qsort} is not.
3168
3169 Note that leaf functions might invoke signals and signal handlers might be
3170 defined in the current compilation unit and use static variables. The only
3171 compliant way to write such a signal handler is to declare such variables
3172 @code{volatile}.
3173
3174 The attribute has no effect on functions defined within the current compilation
3175 unit. This is to allow easy merging of multiple compilation units into one,
3176 for example, by using the link-time optimization. For this reason the
3177 attribute is not allowed on types to annotate indirect calls.
3178
3179 @item long_call/medium_call/short_call
3180 @cindex indirect calls on ARC
3181 @cindex indirect calls on ARM
3182 @cindex indirect calls on Epiphany
3183 These attributes specify how a particular function is called on
3184 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3185 These attributes override the
3186 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3187 and @option{-mmedium-calls} (@pxref{ARC Options})
3188 command-line switches and @code{#pragma long_calls} settings. For ARM, the
3189 @code{long_call} attribute indicates that the function might be far
3190 away from the call site and require a different (more expensive)
3191 calling sequence. The @code{short_call} attribute always places
3192 the offset to the function from the call site into the @samp{BL}
3193 instruction directly.
3194
3195 For ARC, a function marked with the @code{long_call} attribute is
3196 always called using register-indirect jump-and-link instructions,
3197 thereby enabling the called function to be placed anywhere within the
3198 32-bit address space. A function marked with the @code{medium_call}
3199 attribute will always be close enough to be called with an unconditional
3200 branch-and-link instruction, which has a 25-bit offset from
3201 the call site. A function marked with the @code{short_call}
3202 attribute will always be close enough to be called with a conditional
3203 branch-and-link instruction, which has a 21-bit offset from
3204 the call site.
3205
3206 @item longcall/shortcall
3207 @cindex functions called via pointer on the RS/6000 and PowerPC
3208 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3209 indicates that the function might be far away from the call site and
3210 require a different (more expensive) calling sequence. The
3211 @code{shortcall} attribute indicates that the function is always close
3212 enough for the shorter calling sequence to be used. These attributes
3213 override both the @option{-mlongcall} switch and, on the RS/6000 and
3214 PowerPC, the @code{#pragma longcall} setting.
3215
3216 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3217 calls are necessary.
3218
3219 @item long_call/near/far
3220 @cindex indirect calls on MIPS
3221 These attributes specify how a particular function is called on MIPS@.
3222 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3223 command-line switch. The @code{long_call} and @code{far} attributes are
3224 synonyms, and cause the compiler to always call
3225 the function by first loading its address into a register, and then using
3226 the contents of that register. The @code{near} attribute has the opposite
3227 effect; it specifies that non-PIC calls should be made using the more
3228 efficient @code{jal} instruction.
3229
3230 @item malloc
3231 @cindex @code{malloc} attribute
3232 This tells the compiler that a function is @code{malloc}-like, i.e.,
3233 that the pointer @var{P} returned by the function cannot alias any
3234 other pointer valid when the function returns, and moreover no
3235 pointers to valid objects occur in any storage addressed by @var{P}.
3236
3237 Using this attribute can improve optimization. Functions like
3238 @code{malloc} and @code{calloc} have this property because they return
3239 a pointer to uninitialized or zeroed-out storage. However, functions
3240 like @code{realloc} do not have this property, as they can return a
3241 pointer to storage containing pointers.
3242
3243 @item mips16/nomips16
3244 @cindex @code{mips16} attribute
3245 @cindex @code{nomips16} attribute
3246
3247 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3248 function attributes to locally select or turn off MIPS16 code generation.
3249 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3250 while MIPS16 code generation is disabled for functions with the
3251 @code{nomips16} attribute. These attributes override the
3252 @option{-mips16} and @option{-mno-mips16} options on the command line
3253 (@pxref{MIPS Options}).
3254
3255 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3256 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3257 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
3258 may interact badly with some GCC extensions such as @code{__builtin_apply}
3259 (@pxref{Constructing Calls}).
3260
3261 @item micromips/nomicromips
3262 @cindex @code{micromips} attribute
3263 @cindex @code{nomicromips} attribute
3264
3265 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3266 function attributes to locally select or turn off microMIPS code generation.
3267 A function with the @code{micromips} attribute is emitted as microMIPS code,
3268 while microMIPS code generation is disabled for functions with the
3269 @code{nomicromips} attribute. These attributes override the
3270 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3271 (@pxref{MIPS Options}).
3272
3273 When compiling files containing mixed microMIPS and non-microMIPS code, the
3274 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3275 command line,
3276 not that within individual functions. Mixed microMIPS and non-microMIPS code
3277 may interact badly with some GCC extensions such as @code{__builtin_apply}
3278 (@pxref{Constructing Calls}).
3279
3280 @item model (@var{model-name})
3281 @cindex function addressability on the M32R/D
3282 @cindex variable addressability on the IA-64
3283
3284 On the M32R/D, use this attribute to set the addressability of an
3285 object, and of the code generated for a function. The identifier
3286 @var{model-name} is one of @code{small}, @code{medium}, or
3287 @code{large}, representing each of the code models.
3288
3289 Small model objects live in the lower 16MB of memory (so that their
3290 addresses can be loaded with the @code{ld24} instruction), and are
3291 callable with the @code{bl} instruction.
3292
3293 Medium model objects may live anywhere in the 32-bit address space (the
3294 compiler generates @code{seth/add3} instructions to load their addresses),
3295 and are callable with the @code{bl} instruction.
3296
3297 Large model objects may live anywhere in the 32-bit address space (the
3298 compiler generates @code{seth/add3} instructions to load their addresses),
3299 and may not be reachable with the @code{bl} instruction (the compiler
3300 generates the much slower @code{seth/add3/jl} instruction sequence).
3301
3302 On IA-64, use this attribute to set the addressability of an object.
3303 At present, the only supported identifier for @var{model-name} is
3304 @code{small}, indicating addressability via ``small'' (22-bit)
3305 addresses (so that their addresses can be loaded with the @code{addl}
3306 instruction). Caveat: such addressing is by definition not position
3307 independent and hence this attribute must not be used for objects
3308 defined by shared libraries.
3309
3310 @item ms_abi/sysv_abi
3311 @cindex @code{ms_abi} attribute
3312 @cindex @code{sysv_abi} attribute
3313
3314 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3315 to indicate which calling convention should be used for a function. The
3316 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3317 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3318 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
3319 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
3320
3321 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3322 requires the @option{-maccumulate-outgoing-args} option.
3323
3324 @item callee_pop_aggregate_return (@var{number})
3325 @cindex @code{callee_pop_aggregate_return} attribute
3326
3327 On 32-bit i?86-*-* targets, you can use this attribute to control how
3328 aggregates are returned in memory. If the caller is responsible for
3329 popping the hidden pointer together with the rest of the arguments, specify
3330 @var{number} equal to zero. If callee is responsible for popping the
3331 hidden pointer, specify @var{number} equal to one.
3332
3333 The default i386 ABI assumes that the callee pops the
3334 stack for hidden pointer. However, on 32-bit i386 Microsoft Windows targets,
3335 the compiler assumes that the
3336 caller pops the stack for hidden pointer.
3337
3338 @item ms_hook_prologue
3339 @cindex @code{ms_hook_prologue} attribute
3340
3341 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3342 this function attribute to make GCC generate the ``hot-patching'' function
3343 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3344 and newer.
3345
3346 @item hotpatch [(@var{prologue-halfwords})]
3347 @cindex @code{hotpatch} attribute
3348
3349 On S/390 System z targets, you can use this function attribute to
3350 make GCC generate a ``hot-patching'' function prologue. The
3351 @code{hotpatch} has no effect on funtions that are explicitly
3352 inline. If the @option{-mhotpatch} or @option{-mno-hotpatch}
3353 command-line option is used at the same time, the @code{hotpatch}
3354 attribute takes precedence. If an argument is given, the maximum
3355 allowed value is 1000000.
3356
3357 @item naked
3358 @cindex function without a prologue/epilogue code
3359 Use this attribute on the ARM, AVR, MCORE, MSP430, NDS32, RL78, RX and SPU
3360 ports to indicate that the specified function does not need prologue/epilogue
3361 sequences generated by the compiler.
3362 It is up to the programmer to provide these sequences. The
3363 only statements that can be safely included in naked functions are
3364 @code{asm} statements that do not have operands. All other statements,
3365 including declarations of local variables, @code{if} statements, and so
3366 forth, should be avoided. Naked functions should be used to implement the
3367 body of an assembly function, while allowing the compiler to construct
3368 the requisite function declaration for the assembler.
3369
3370 @item near
3371 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3372 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3373 use the normal calling convention based on @code{jsr} and @code{rts}.
3374 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3375 option.
3376
3377 On MeP targets this attribute causes the compiler to assume the called
3378 function is close enough to use the normal calling convention,
3379 overriding the @option{-mtf} command-line option.
3380
3381 @item nesting
3382 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3383 Use this attribute together with @code{interrupt_handler},
3384 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3385 entry code should enable nested interrupts or exceptions.
3386
3387 @item nmi_handler
3388 @cindex NMI handler functions on the Blackfin processor
3389 Use this attribute on the Blackfin to indicate that the specified function
3390 is an NMI handler. The compiler generates function entry and
3391 exit sequences suitable for use in an NMI handler when this
3392 attribute is present.
3393
3394 @item nocompression
3395 @cindex @code{nocompression} attribute
3396 On MIPS targets, you can use the @code{nocompression} function attribute
3397 to locally turn off MIPS16 and microMIPS code generation. This attribute
3398 overrides the @option{-mips16} and @option{-mmicromips} options on the
3399 command line (@pxref{MIPS Options}).
3400
3401 @item no_instrument_function
3402 @cindex @code{no_instrument_function} function attribute
3403 @opindex finstrument-functions
3404 If @option{-finstrument-functions} is given, profiling function calls are
3405 generated at entry and exit of most user-compiled functions.
3406 Functions with this attribute are not so instrumented.
3407
3408 @item no_split_stack
3409 @cindex @code{no_split_stack} function attribute
3410 @opindex fsplit-stack
3411 If @option{-fsplit-stack} is given, functions have a small
3412 prologue which decides whether to split the stack. Functions with the
3413 @code{no_split_stack} attribute do not have that prologue, and thus
3414 may run with only a small amount of stack space available.
3415
3416 @item noinline
3417 @cindex @code{noinline} function attribute
3418 This function attribute prevents a function from being considered for
3419 inlining.
3420 @c Don't enumerate the optimizations by name here; we try to be
3421 @c future-compatible with this mechanism.
3422 If the function does not have side-effects, there are optimizations
3423 other than inlining that cause function calls to be optimized away,
3424 although the function call is live. To keep such calls from being
3425 optimized away, put
3426 @smallexample
3427 asm ("");
3428 @end smallexample
3429
3430 @noindent
3431 (@pxref{Extended Asm}) in the called function, to serve as a special
3432 side-effect.
3433
3434 @item noclone
3435 @cindex @code{noclone} function attribute
3436 This function attribute prevents a function from being considered for
3437 cloning---a mechanism that produces specialized copies of functions
3438 and which is (currently) performed by interprocedural constant
3439 propagation.
3440
3441 @item nonnull (@var{arg-index}, @dots{})
3442 @cindex @code{nonnull} function attribute
3443 The @code{nonnull} attribute specifies that some function parameters should
3444 be non-null pointers. For instance, the declaration:
3445
3446 @smallexample
3447 extern void *
3448 my_memcpy (void *dest, const void *src, size_t len)
3449 __attribute__((nonnull (1, 2)));
3450 @end smallexample
3451
3452 @noindent
3453 causes the compiler to check that, in calls to @code{my_memcpy},
3454 arguments @var{dest} and @var{src} are non-null. If the compiler
3455 determines that a null pointer is passed in an argument slot marked
3456 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3457 is issued. The compiler may also choose to make optimizations based
3458 on the knowledge that certain function arguments will never be null.
3459
3460 If no argument index list is given to the @code{nonnull} attribute,
3461 all pointer arguments are marked as non-null. To illustrate, the
3462 following declaration is equivalent to the previous example:
3463
3464 @smallexample
3465 extern void *
3466 my_memcpy (void *dest, const void *src, size_t len)
3467 __attribute__((nonnull));
3468 @end smallexample
3469
3470 @item returns_nonnull
3471 @cindex @code{returns_nonnull} function attribute
3472 The @code{returns_nonnull} attribute specifies that the function
3473 return value should be a non-null pointer. For instance, the declaration:
3474
3475 @smallexample
3476 extern void *
3477 mymalloc (size_t len) __attribute__((returns_nonnull));
3478 @end smallexample
3479
3480 @noindent
3481 lets the compiler optimize callers based on the knowledge
3482 that the return value will never be null.
3483
3484 @item noreturn
3485 @cindex @code{noreturn} function attribute
3486 A few standard library functions, such as @code{abort} and @code{exit},
3487 cannot return. GCC knows this automatically. Some programs define
3488 their own functions that never return. You can declare them
3489 @code{noreturn} to tell the compiler this fact. For example,
3490
3491 @smallexample
3492 @group
3493 void fatal () __attribute__ ((noreturn));
3494
3495 void
3496 fatal (/* @r{@dots{}} */)
3497 @{
3498 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3499 exit (1);
3500 @}
3501 @end group
3502 @end smallexample
3503
3504 The @code{noreturn} keyword tells the compiler to assume that
3505 @code{fatal} cannot return. It can then optimize without regard to what
3506 would happen if @code{fatal} ever did return. This makes slightly
3507 better code. More importantly, it helps avoid spurious warnings of
3508 uninitialized variables.
3509
3510 The @code{noreturn} keyword does not affect the exceptional path when that
3511 applies: a @code{noreturn}-marked function may still return to the caller
3512 by throwing an exception or calling @code{longjmp}.
3513
3514 Do not assume that registers saved by the calling function are
3515 restored before calling the @code{noreturn} function.
3516
3517 It does not make sense for a @code{noreturn} function to have a return
3518 type other than @code{void}.
3519
3520 The attribute @code{noreturn} is not implemented in GCC versions
3521 earlier than 2.5. An alternative way to declare that a function does
3522 not return, which works in the current version and in some older
3523 versions, is as follows:
3524
3525 @smallexample
3526 typedef void voidfn ();
3527
3528 volatile voidfn fatal;
3529 @end smallexample
3530
3531 @noindent
3532 This approach does not work in GNU C++.
3533
3534 @item nothrow
3535 @cindex @code{nothrow} function attribute
3536 The @code{nothrow} attribute is used to inform the compiler that a
3537 function cannot throw an exception. For example, most functions in
3538 the standard C library can be guaranteed not to throw an exception
3539 with the notable exceptions of @code{qsort} and @code{bsearch} that
3540 take function pointer arguments. The @code{nothrow} attribute is not
3541 implemented in GCC versions earlier than 3.3.
3542
3543 @item nosave_low_regs
3544 @cindex @code{nosave_low_regs} attribute
3545 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3546 function should not save and restore registers R0..R7. This can be used on SH3*
3547 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3548 interrupt handlers.
3549
3550 @item optimize
3551 @cindex @code{optimize} function attribute
3552 The @code{optimize} attribute is used to specify that a function is to
3553 be compiled with different optimization options than specified on the
3554 command line. Arguments can either be numbers or strings. Numbers
3555 are assumed to be an optimization level. Strings that begin with
3556 @code{O} are assumed to be an optimization option, while other options
3557 are assumed to be used with a @code{-f} prefix. You can also use the
3558 @samp{#pragma GCC optimize} pragma to set the optimization options
3559 that affect more than one function.
3560 @xref{Function Specific Option Pragmas}, for details about the
3561 @samp{#pragma GCC optimize} pragma.
3562
3563 This can be used for instance to have frequently-executed functions
3564 compiled with more aggressive optimization options that produce faster
3565 and larger code, while other functions can be compiled with less
3566 aggressive options.
3567
3568 @item OS_main/OS_task
3569 @cindex @code{OS_main} AVR function attribute
3570 @cindex @code{OS_task} AVR function attribute
3571 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3572 do not save/restore any call-saved register in their prologue/epilogue.
3573
3574 The @code{OS_main} attribute can be used when there @emph{is
3575 guarantee} that interrupts are disabled at the time when the function
3576 is entered. This saves resources when the stack pointer has to be
3577 changed to set up a frame for local variables.
3578
3579 The @code{OS_task} attribute can be used when there is @emph{no
3580 guarantee} that interrupts are disabled at that time when the function
3581 is entered like for, e@.g@. task functions in a multi-threading operating
3582 system. In that case, changing the stack pointer register is
3583 guarded by save/clear/restore of the global interrupt enable flag.
3584
3585 The differences to the @code{naked} function attribute are:
3586 @itemize @bullet
3587 @item @code{naked} functions do not have a return instruction whereas
3588 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3589 @code{RETI} return instruction.
3590 @item @code{naked} functions do not set up a frame for local variables
3591 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3592 as needed.
3593 @end itemize
3594
3595 @item pcs
3596 @cindex @code{pcs} function attribute
3597
3598 The @code{pcs} attribute can be used to control the calling convention
3599 used for a function on ARM. The attribute takes an argument that specifies
3600 the calling convention to use.
3601
3602 When compiling using the AAPCS ABI (or a variant of it) then valid
3603 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3604 order to use a variant other than @code{"aapcs"} then the compiler must
3605 be permitted to use the appropriate co-processor registers (i.e., the
3606 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3607 For example,
3608
3609 @smallexample
3610 /* Argument passed in r0, and result returned in r0+r1. */
3611 double f2d (float) __attribute__((pcs("aapcs")));
3612 @end smallexample
3613
3614 Variadic functions always use the @code{"aapcs"} calling convention and
3615 the compiler rejects attempts to specify an alternative.
3616
3617 @item pure
3618 @cindex @code{pure} function attribute
3619 Many functions have no effects except the return value and their
3620 return value depends only on the parameters and/or global variables.
3621 Such a function can be subject
3622 to common subexpression elimination and loop optimization just as an
3623 arithmetic operator would be. These functions should be declared
3624 with the attribute @code{pure}. For example,
3625
3626 @smallexample
3627 int square (int) __attribute__ ((pure));
3628 @end smallexample
3629
3630 @noindent
3631 says that the hypothetical function @code{square} is safe to call
3632 fewer times than the program says.
3633
3634 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3635 Interesting non-pure functions are functions with infinite loops or those
3636 depending on volatile memory or other system resource, that may change between
3637 two consecutive calls (such as @code{feof} in a multithreading environment).
3638
3639 The attribute @code{pure} is not implemented in GCC versions earlier
3640 than 2.96.
3641
3642 @item hot
3643 @cindex @code{hot} function attribute
3644 The @code{hot} attribute on a function is used to inform the compiler that
3645 the function is a hot spot of the compiled program. The function is
3646 optimized more aggressively and on many targets it is placed into a special
3647 subsection of the text section so all hot functions appear close together,
3648 improving locality.
3649
3650 When profile feedback is available, via @option{-fprofile-use}, hot functions
3651 are automatically detected and this attribute is ignored.
3652
3653 The @code{hot} attribute on functions is not implemented in GCC versions
3654 earlier than 4.3.
3655
3656 @item cold
3657 @cindex @code{cold} function attribute
3658 The @code{cold} attribute on functions is used to inform the compiler that
3659 the function is unlikely to be executed. The function is optimized for
3660 size rather than speed and on many targets it is placed into a special
3661 subsection of the text section so all cold functions appear close together,
3662 improving code locality of non-cold parts of program. The paths leading
3663 to calls of cold functions within code are marked as unlikely by the branch
3664 prediction mechanism. It is thus useful to mark functions used to handle
3665 unlikely conditions, such as @code{perror}, as cold to improve optimization
3666 of hot functions that do call marked functions in rare occasions.
3667
3668 When profile feedback is available, via @option{-fprofile-use}, cold functions
3669 are automatically detected and this attribute is ignored.
3670
3671 The @code{cold} attribute on functions is not implemented in GCC versions
3672 earlier than 4.3.
3673
3674 @item no_sanitize_address
3675 @itemx no_address_safety_analysis
3676 @cindex @code{no_sanitize_address} function attribute
3677 The @code{no_sanitize_address} attribute on functions is used
3678 to inform the compiler that it should not instrument memory accesses
3679 in the function when compiling with the @option{-fsanitize=address} option.
3680 The @code{no_address_safety_analysis} is a deprecated alias of the
3681 @code{no_sanitize_address} attribute, new code should use
3682 @code{no_sanitize_address}.
3683
3684 @item no_sanitize_undefined
3685 @cindex @code{no_sanitize_undefined} function attribute
3686 The @code{no_sanitize_undefined} attribute on functions is used
3687 to inform the compiler that it should not check for undefined behavior
3688 in the function when compiling with the @option{-fsanitize=undefined} option.
3689
3690 @item regparm (@var{number})
3691 @cindex @code{regparm} attribute
3692 @cindex functions that are passed arguments in registers on the 386
3693 On the Intel 386, the @code{regparm} attribute causes the compiler to
3694 pass arguments number one to @var{number} if they are of integral type
3695 in registers EAX, EDX, and ECX instead of on the stack. Functions that
3696 take a variable number of arguments continue to be passed all of their
3697 arguments on the stack.
3698
3699 Beware that on some ELF systems this attribute is unsuitable for
3700 global functions in shared libraries with lazy binding (which is the
3701 default). Lazy binding sends the first call via resolving code in
3702 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3703 per the standard calling conventions. Solaris 8 is affected by this.
3704 Systems with the GNU C Library version 2.1 or higher
3705 and FreeBSD are believed to be
3706 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
3707 disabled with the linker or the loader if desired, to avoid the
3708 problem.)
3709
3710 @item reset
3711 @cindex reset handler functions
3712 Use this attribute on the NDS32 target to indicate that the specified function
3713 is a reset handler. The compiler will generate corresponding sections
3714 for use in a reset handler. You can use the following attributes
3715 to provide extra exception handling:
3716 @table @code
3717 @item nmi
3718 @cindex @code{nmi} attribute
3719 Provide a user-defined function to handle NMI exception.
3720 @item warm
3721 @cindex @code{warm} attribute
3722 Provide a user-defined function to handle warm reset exception.
3723 @end table
3724
3725 @item sseregparm
3726 @cindex @code{sseregparm} attribute
3727 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3728 causes the compiler to pass up to 3 floating-point arguments in
3729 SSE registers instead of on the stack. Functions that take a
3730 variable number of arguments continue to pass all of their
3731 floating-point arguments on the stack.
3732
3733 @item force_align_arg_pointer
3734 @cindex @code{force_align_arg_pointer} attribute
3735 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3736 applied to individual function definitions, generating an alternate
3737 prologue and epilogue that realigns the run-time stack if necessary.
3738 This supports mixing legacy codes that run with a 4-byte aligned stack
3739 with modern codes that keep a 16-byte stack for SSE compatibility.
3740
3741 @item renesas
3742 @cindex @code{renesas} attribute
3743 On SH targets this attribute specifies that the function or struct follows the
3744 Renesas ABI.
3745
3746 @item resbank
3747 @cindex @code{resbank} attribute
3748 On the SH2A target, this attribute enables the high-speed register
3749 saving and restoration using a register bank for @code{interrupt_handler}
3750 routines. Saving to the bank is performed automatically after the CPU
3751 accepts an interrupt that uses a register bank.
3752
3753 The nineteen 32-bit registers comprising general register R0 to R14,
3754 control register GBR, and system registers MACH, MACL, and PR and the
3755 vector table address offset are saved into a register bank. Register
3756 banks are stacked in first-in last-out (FILO) sequence. Restoration
3757 from the bank is executed by issuing a RESBANK instruction.
3758
3759 @item returns_twice
3760 @cindex @code{returns_twice} attribute
3761 The @code{returns_twice} attribute tells the compiler that a function may
3762 return more than one time. The compiler ensures that all registers
3763 are dead before calling such a function and emits a warning about
3764 the variables that may be clobbered after the second return from the
3765 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3766 The @code{longjmp}-like counterpart of such function, if any, might need
3767 to be marked with the @code{noreturn} attribute.
3768
3769 @item saveall
3770 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3771 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3772 all registers except the stack pointer should be saved in the prologue
3773 regardless of whether they are used or not.
3774
3775 @item save_volatiles
3776 @cindex save volatile registers on the MicroBlaze
3777 Use this attribute on the MicroBlaze to indicate that the function is
3778 an interrupt handler. All volatile registers (in addition to non-volatile
3779 registers) are saved in the function prologue. If the function is a leaf
3780 function, only volatiles used by the function are saved. A normal function
3781 return is generated instead of a return from interrupt.
3782
3783 @item break_handler
3784 @cindex break handler functions
3785 Use this attribute on the MicroBlaze ports to indicate that
3786 the specified function is an break handler. The compiler generates function
3787 entry and exit sequences suitable for use in an break handler when this
3788 attribute is present. The return from @code{break_handler} is done through
3789 the @code{rtbd} instead of @code{rtsd}.
3790
3791 @smallexample
3792 void f () __attribute__ ((break_handler));
3793 @end smallexample
3794
3795 @item section ("@var{section-name}")
3796 @cindex @code{section} function attribute
3797 Normally, the compiler places the code it generates in the @code{text} section.
3798 Sometimes, however, you need additional sections, or you need certain
3799 particular functions to appear in special sections. The @code{section}
3800 attribute specifies that a function lives in a particular section.
3801 For example, the declaration:
3802
3803 @smallexample
3804 extern void foobar (void) __attribute__ ((section ("bar")));
3805 @end smallexample
3806
3807 @noindent
3808 puts the function @code{foobar} in the @code{bar} section.
3809
3810 Some file formats do not support arbitrary sections so the @code{section}
3811 attribute is not available on all platforms.
3812 If you need to map the entire contents of a module to a particular
3813 section, consider using the facilities of the linker instead.
3814
3815 @item sentinel
3816 @cindex @code{sentinel} function attribute
3817 This function attribute ensures that a parameter in a function call is
3818 an explicit @code{NULL}. The attribute is only valid on variadic
3819 functions. By default, the sentinel is located at position zero, the
3820 last parameter of the function call. If an optional integer position
3821 argument P is supplied to the attribute, the sentinel must be located at
3822 position P counting backwards from the end of the argument list.
3823
3824 @smallexample
3825 __attribute__ ((sentinel))
3826 is equivalent to
3827 __attribute__ ((sentinel(0)))
3828 @end smallexample
3829
3830 The attribute is automatically set with a position of 0 for the built-in
3831 functions @code{execl} and @code{execlp}. The built-in function
3832 @code{execle} has the attribute set with a position of 1.
3833
3834 A valid @code{NULL} in this context is defined as zero with any pointer
3835 type. If your system defines the @code{NULL} macro with an integer type
3836 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3837 with a copy that redefines NULL appropriately.
3838
3839 The warnings for missing or incorrect sentinels are enabled with
3840 @option{-Wformat}.
3841
3842 @item short_call
3843 See @code{long_call/short_call}.
3844
3845 @item shortcall
3846 See @code{longcall/shortcall}.
3847
3848 @item signal
3849 @cindex interrupt handler functions on the AVR processors
3850 Use this attribute on the AVR to indicate that the specified
3851 function is an interrupt handler. The compiler generates function
3852 entry and exit sequences suitable for use in an interrupt handler when this
3853 attribute is present.
3854
3855 See also the @code{interrupt} function attribute.
3856
3857 The AVR hardware globally disables interrupts when an interrupt is executed.
3858 Interrupt handler functions defined with the @code{signal} attribute
3859 do not re-enable interrupts. It is save to enable interrupts in a
3860 @code{signal} handler. This ``save'' only applies to the code
3861 generated by the compiler and not to the IRQ layout of the
3862 application which is responsibility of the application.
3863
3864 If both @code{signal} and @code{interrupt} are specified for the same
3865 function, @code{signal} is silently ignored.
3866
3867 @item sp_switch
3868 @cindex @code{sp_switch} attribute
3869 Use this attribute on the SH to indicate an @code{interrupt_handler}
3870 function should switch to an alternate stack. It expects a string
3871 argument that names a global variable holding the address of the
3872 alternate stack.
3873
3874 @smallexample
3875 void *alt_stack;
3876 void f () __attribute__ ((interrupt_handler,
3877 sp_switch ("alt_stack")));
3878 @end smallexample
3879
3880 @item stdcall
3881 @cindex functions that pop the argument stack on the 386
3882 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3883 assume that the called function pops off the stack space used to
3884 pass arguments, unless it takes a variable number of arguments.
3885
3886 @item syscall_linkage
3887 @cindex @code{syscall_linkage} attribute
3888 This attribute is used to modify the IA-64 calling convention by marking
3889 all input registers as live at all function exits. This makes it possible
3890 to restart a system call after an interrupt without having to save/restore
3891 the input registers. This also prevents kernel data from leaking into
3892 application code.
3893
3894 @item target
3895 @cindex @code{target} function attribute
3896 The @code{target} attribute is used to specify that a function is to
3897 be compiled with different target options than specified on the
3898 command line. This can be used for instance to have functions
3899 compiled with a different ISA (instruction set architecture) than the
3900 default. You can also use the @samp{#pragma GCC target} pragma to set
3901 more than one function to be compiled with specific target options.
3902 @xref{Function Specific Option Pragmas}, for details about the
3903 @samp{#pragma GCC target} pragma.
3904
3905 For instance on a 386, you could compile one function with
3906 @code{target("sse4.1,arch=core2")} and another with
3907 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3908 compiling the first function with @option{-msse4.1} and
3909 @option{-march=core2} options, and the second function with
3910 @option{-msse4a} and @option{-march=amdfam10} options. It is up to the
3911 user to make sure that a function is only invoked on a machine that
3912 supports the particular ISA it is compiled for (for example by using
3913 @code{cpuid} on 386 to determine what feature bits and architecture
3914 family are used).
3915
3916 @smallexample
3917 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3918 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3919 @end smallexample
3920
3921 You can either use multiple
3922 strings to specify multiple options, or separate the options
3923 with a comma (@samp{,}).
3924
3925 The @code{target} attribute is presently implemented for
3926 i386/x86_64, PowerPC, and Nios II targets only.
3927 The options supported are specific to each target.
3928
3929 On the 386, the following options are allowed:
3930
3931 @table @samp
3932 @item abm
3933 @itemx no-abm
3934 @cindex @code{target("abm")} attribute
3935 Enable/disable the generation of the advanced bit instructions.
3936
3937 @item aes
3938 @itemx no-aes
3939 @cindex @code{target("aes")} attribute
3940 Enable/disable the generation of the AES instructions.
3941
3942 @item default
3943 @cindex @code{target("default")} attribute
3944 @xref{Function Multiversioning}, where it is used to specify the
3945 default function version.
3946
3947 @item mmx
3948 @itemx no-mmx
3949 @cindex @code{target("mmx")} attribute
3950 Enable/disable the generation of the MMX instructions.
3951
3952 @item pclmul
3953 @itemx no-pclmul
3954 @cindex @code{target("pclmul")} attribute
3955 Enable/disable the generation of the PCLMUL instructions.
3956
3957 @item popcnt
3958 @itemx no-popcnt
3959 @cindex @code{target("popcnt")} attribute
3960 Enable/disable the generation of the POPCNT instruction.
3961
3962 @item sse
3963 @itemx no-sse
3964 @cindex @code{target("sse")} attribute
3965 Enable/disable the generation of the SSE instructions.
3966
3967 @item sse2
3968 @itemx no-sse2
3969 @cindex @code{target("sse2")} attribute
3970 Enable/disable the generation of the SSE2 instructions.
3971
3972 @item sse3
3973 @itemx no-sse3
3974 @cindex @code{target("sse3")} attribute
3975 Enable/disable the generation of the SSE3 instructions.
3976
3977 @item sse4
3978 @itemx no-sse4
3979 @cindex @code{target("sse4")} attribute
3980 Enable/disable the generation of the SSE4 instructions (both SSE4.1
3981 and SSE4.2).
3982
3983 @item sse4.1
3984 @itemx no-sse4.1
3985 @cindex @code{target("sse4.1")} attribute
3986 Enable/disable the generation of the sse4.1 instructions.
3987
3988 @item sse4.2
3989 @itemx no-sse4.2
3990 @cindex @code{target("sse4.2")} attribute
3991 Enable/disable the generation of the sse4.2 instructions.
3992
3993 @item sse4a
3994 @itemx no-sse4a
3995 @cindex @code{target("sse4a")} attribute
3996 Enable/disable the generation of the SSE4A instructions.
3997
3998 @item fma4
3999 @itemx no-fma4
4000 @cindex @code{target("fma4")} attribute
4001 Enable/disable the generation of the FMA4 instructions.
4002
4003 @item xop
4004 @itemx no-xop
4005 @cindex @code{target("xop")} attribute
4006 Enable/disable the generation of the XOP instructions.
4007
4008 @item lwp
4009 @itemx no-lwp
4010 @cindex @code{target("lwp")} attribute
4011 Enable/disable the generation of the LWP instructions.
4012
4013 @item ssse3
4014 @itemx no-ssse3
4015 @cindex @code{target("ssse3")} attribute
4016 Enable/disable the generation of the SSSE3 instructions.
4017
4018 @item cld
4019 @itemx no-cld
4020 @cindex @code{target("cld")} attribute
4021 Enable/disable the generation of the CLD before string moves.
4022
4023 @item fancy-math-387
4024 @itemx no-fancy-math-387
4025 @cindex @code{target("fancy-math-387")} attribute
4026 Enable/disable the generation of the @code{sin}, @code{cos}, and
4027 @code{sqrt} instructions on the 387 floating-point unit.
4028
4029 @item fused-madd
4030 @itemx no-fused-madd
4031 @cindex @code{target("fused-madd")} attribute
4032 Enable/disable the generation of the fused multiply/add instructions.
4033
4034 @item ieee-fp
4035 @itemx no-ieee-fp
4036 @cindex @code{target("ieee-fp")} attribute
4037 Enable/disable the generation of floating point that depends on IEEE arithmetic.
4038
4039 @item inline-all-stringops
4040 @itemx no-inline-all-stringops
4041 @cindex @code{target("inline-all-stringops")} attribute
4042 Enable/disable inlining of string operations.
4043
4044 @item inline-stringops-dynamically
4045 @itemx no-inline-stringops-dynamically
4046 @cindex @code{target("inline-stringops-dynamically")} attribute
4047 Enable/disable the generation of the inline code to do small string
4048 operations and calling the library routines for large operations.
4049
4050 @item align-stringops
4051 @itemx no-align-stringops
4052 @cindex @code{target("align-stringops")} attribute
4053 Do/do not align destination of inlined string operations.
4054
4055 @item recip
4056 @itemx no-recip
4057 @cindex @code{target("recip")} attribute
4058 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
4059 instructions followed an additional Newton-Raphson step instead of
4060 doing a floating-point division.
4061
4062 @item arch=@var{ARCH}
4063 @cindex @code{target("arch=@var{ARCH}")} attribute
4064 Specify the architecture to generate code for in compiling the function.
4065
4066 @item tune=@var{TUNE}
4067 @cindex @code{target("tune=@var{TUNE}")} attribute
4068 Specify the architecture to tune for in compiling the function.
4069
4070 @item fpmath=@var{FPMATH}
4071 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
4072 Specify which floating-point unit to use. The
4073 @code{target("fpmath=sse,387")} option must be specified as
4074 @code{target("fpmath=sse+387")} because the comma would separate
4075 different options.
4076 @end table
4077
4078 On the PowerPC, the following options are allowed:
4079
4080 @table @samp
4081 @item altivec
4082 @itemx no-altivec
4083 @cindex @code{target("altivec")} attribute
4084 Generate code that uses (does not use) AltiVec instructions. In
4085 32-bit code, you cannot enable AltiVec instructions unless
4086 @option{-mabi=altivec} is used on the command line.
4087
4088 @item cmpb
4089 @itemx no-cmpb
4090 @cindex @code{target("cmpb")} attribute
4091 Generate code that uses (does not use) the compare bytes instruction
4092 implemented on the POWER6 processor and other processors that support
4093 the PowerPC V2.05 architecture.
4094
4095 @item dlmzb
4096 @itemx no-dlmzb
4097 @cindex @code{target("dlmzb")} attribute
4098 Generate code that uses (does not use) the string-search @samp{dlmzb}
4099 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4100 generated by default when targeting those processors.
4101
4102 @item fprnd
4103 @itemx no-fprnd
4104 @cindex @code{target("fprnd")} attribute
4105 Generate code that uses (does not use) the FP round to integer
4106 instructions implemented on the POWER5+ processor and other processors
4107 that support the PowerPC V2.03 architecture.
4108
4109 @item hard-dfp
4110 @itemx no-hard-dfp
4111 @cindex @code{target("hard-dfp")} attribute
4112 Generate code that uses (does not use) the decimal floating-point
4113 instructions implemented on some POWER processors.
4114
4115 @item isel
4116 @itemx no-isel
4117 @cindex @code{target("isel")} attribute
4118 Generate code that uses (does not use) ISEL instruction.
4119
4120 @item mfcrf
4121 @itemx no-mfcrf
4122 @cindex @code{target("mfcrf")} attribute
4123 Generate code that uses (does not use) the move from condition
4124 register field instruction implemented on the POWER4 processor and
4125 other processors that support the PowerPC V2.01 architecture.
4126
4127 @item mfpgpr
4128 @itemx no-mfpgpr
4129 @cindex @code{target("mfpgpr")} attribute
4130 Generate code that uses (does not use) the FP move to/from general
4131 purpose register instructions implemented on the POWER6X processor and
4132 other processors that support the extended PowerPC V2.05 architecture.
4133
4134 @item mulhw
4135 @itemx no-mulhw
4136 @cindex @code{target("mulhw")} attribute
4137 Generate code that uses (does not use) the half-word multiply and
4138 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4139 These instructions are generated by default when targeting those
4140 processors.
4141
4142 @item multiple
4143 @itemx no-multiple
4144 @cindex @code{target("multiple")} attribute
4145 Generate code that uses (does not use) the load multiple word
4146 instructions and the store multiple word instructions.
4147
4148 @item update
4149 @itemx no-update
4150 @cindex @code{target("update")} attribute
4151 Generate code that uses (does not use) the load or store instructions
4152 that update the base register to the address of the calculated memory
4153 location.
4154
4155 @item popcntb
4156 @itemx no-popcntb
4157 @cindex @code{target("popcntb")} attribute
4158 Generate code that uses (does not use) the popcount and double-precision
4159 FP reciprocal estimate instruction implemented on the POWER5
4160 processor and other processors that support the PowerPC V2.02
4161 architecture.
4162
4163 @item popcntd
4164 @itemx no-popcntd
4165 @cindex @code{target("popcntd")} attribute
4166 Generate code that uses (does not use) the popcount instruction
4167 implemented on the POWER7 processor and other processors that support
4168 the PowerPC V2.06 architecture.
4169
4170 @item powerpc-gfxopt
4171 @itemx no-powerpc-gfxopt
4172 @cindex @code{target("powerpc-gfxopt")} attribute
4173 Generate code that uses (does not use) the optional PowerPC
4174 architecture instructions in the Graphics group, including
4175 floating-point select.
4176
4177 @item powerpc-gpopt
4178 @itemx no-powerpc-gpopt
4179 @cindex @code{target("powerpc-gpopt")} attribute
4180 Generate code that uses (does not use) the optional PowerPC
4181 architecture instructions in the General Purpose group, including
4182 floating-point square root.
4183
4184 @item recip-precision
4185 @itemx no-recip-precision
4186 @cindex @code{target("recip-precision")} attribute
4187 Assume (do not assume) that the reciprocal estimate instructions
4188 provide higher-precision estimates than is mandated by the powerpc
4189 ABI.
4190
4191 @item string
4192 @itemx no-string
4193 @cindex @code{target("string")} attribute
4194 Generate code that uses (does not use) the load string instructions
4195 and the store string word instructions to save multiple registers and
4196 do small block moves.
4197
4198 @item vsx
4199 @itemx no-vsx
4200 @cindex @code{target("vsx")} attribute
4201 Generate code that uses (does not use) vector/scalar (VSX)
4202 instructions, and also enable the use of built-in functions that allow
4203 more direct access to the VSX instruction set. In 32-bit code, you
4204 cannot enable VSX or AltiVec instructions unless
4205 @option{-mabi=altivec} is used on the command line.
4206
4207 @item friz
4208 @itemx no-friz
4209 @cindex @code{target("friz")} attribute
4210 Generate (do not generate) the @code{friz} instruction when the
4211 @option{-funsafe-math-optimizations} option is used to optimize
4212 rounding a floating-point value to 64-bit integer and back to floating
4213 point. The @code{friz} instruction does not return the same value if
4214 the floating-point number is too large to fit in an integer.
4215
4216 @item avoid-indexed-addresses
4217 @itemx no-avoid-indexed-addresses
4218 @cindex @code{target("avoid-indexed-addresses")} attribute
4219 Generate code that tries to avoid (not avoid) the use of indexed load
4220 or store instructions.
4221
4222 @item paired
4223 @itemx no-paired
4224 @cindex @code{target("paired")} attribute
4225 Generate code that uses (does not use) the generation of PAIRED simd
4226 instructions.
4227
4228 @item longcall
4229 @itemx no-longcall
4230 @cindex @code{target("longcall")} attribute
4231 Generate code that assumes (does not assume) that all calls are far
4232 away so that a longer more expensive calling sequence is required.
4233
4234 @item cpu=@var{CPU}
4235 @cindex @code{target("cpu=@var{CPU}")} attribute
4236 Specify the architecture to generate code for when compiling the
4237 function. If you select the @code{target("cpu=power7")} attribute when
4238 generating 32-bit code, VSX and AltiVec instructions are not generated
4239 unless you use the @option{-mabi=altivec} option on the command line.
4240
4241 @item tune=@var{TUNE}
4242 @cindex @code{target("tune=@var{TUNE}")} attribute
4243 Specify the architecture to tune for when compiling the function. If
4244 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4245 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4246 compilation tunes for the @var{CPU} architecture, and not the
4247 default tuning specified on the command line.
4248 @end table
4249
4250 When compiling for Nios II, the following options are allowed:
4251
4252 @table @samp
4253 @item custom-@var{insn}=@var{N}
4254 @itemx no-custom-@var{insn}
4255 @cindex @code{target("custom-@var{insn}=@var{N}")} attribute
4256 @cindex @code{target("no-custom-@var{insn}")} attribute
4257 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4258 custom instruction with encoding @var{N} when generating code that uses
4259 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4260 the custom instruction @var{insn}.
4261 These target attributes correspond to the
4262 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4263 command-line options, and support the same set of @var{insn} keywords.
4264 @xref{Nios II Options}, for more information.
4265
4266 @item custom-fpu-cfg=@var{name}
4267 @cindex @code{target("custom-fpu-cfg=@var{name}")} attribute
4268 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4269 command-line option, to select a predefined set of custom instructions
4270 named @var{name}.
4271 @xref{Nios II Options}, for more information.
4272 @end table
4273
4274 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
4275 function that has different target options than the caller, unless the
4276 callee has a subset of the target options of the caller. For example
4277 a function declared with @code{target("sse3")} can inline a function
4278 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4279
4280 @item tiny_data
4281 @cindex tiny data section on the H8/300H and H8S
4282 Use this attribute on the H8/300H and H8S to indicate that the specified
4283 variable should be placed into the tiny data section.
4284 The compiler generates more efficient code for loads and stores
4285 on data in the tiny data section. Note the tiny data area is limited to
4286 slightly under 32KB of data.
4287
4288 @item trap_exit
4289 @cindex @code{trap_exit} attribute
4290 Use this attribute on the SH for an @code{interrupt_handler} to return using
4291 @code{trapa} instead of @code{rte}. This attribute expects an integer
4292 argument specifying the trap number to be used.
4293
4294 @item trapa_handler
4295 @cindex @code{trapa_handler} attribute
4296 On SH targets this function attribute is similar to @code{interrupt_handler}
4297 but it does not save and restore all registers.
4298
4299 @item unused
4300 @cindex @code{unused} attribute.
4301 This attribute, attached to a function, means that the function is meant
4302 to be possibly unused. GCC does not produce a warning for this
4303 function.
4304
4305 @item used
4306 @cindex @code{used} attribute.
4307 This attribute, attached to a function, means that code must be emitted
4308 for the function even if it appears that the function is not referenced.
4309 This is useful, for example, when the function is referenced only in
4310 inline assembly.
4311
4312 When applied to a member function of a C++ class template, the
4313 attribute also means that the function is instantiated if the
4314 class itself is instantiated.
4315
4316 @item vector
4317 @cindex @code{vector} attibute
4318 This RX attribute is similar to the @code{attribute}, including its
4319 parameters, but does not make the function an interrupt-handler type
4320 function (i.e. it retains the normal C function calling ABI). See the
4321 @code{interrupt} attribute for a description of its arguments.
4322
4323 @item version_id
4324 @cindex @code{version_id} attribute
4325 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4326 symbol to contain a version string, thus allowing for function level
4327 versioning. HP-UX system header files may use function level versioning
4328 for some system calls.
4329
4330 @smallexample
4331 extern int foo () __attribute__((version_id ("20040821")));
4332 @end smallexample
4333
4334 @noindent
4335 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4336
4337 @item visibility ("@var{visibility_type}")
4338 @cindex @code{visibility} attribute
4339 This attribute affects the linkage of the declaration to which it is attached.
4340 There are four supported @var{visibility_type} values: default,
4341 hidden, protected or internal visibility.
4342
4343 @smallexample
4344 void __attribute__ ((visibility ("protected")))
4345 f () @{ /* @r{Do something.} */; @}
4346 int i __attribute__ ((visibility ("hidden")));
4347 @end smallexample
4348
4349 The possible values of @var{visibility_type} correspond to the
4350 visibility settings in the ELF gABI.
4351
4352 @table @dfn
4353 @c keep this list of visibilities in alphabetical order.
4354
4355 @item default
4356 Default visibility is the normal case for the object file format.
4357 This value is available for the visibility attribute to override other
4358 options that may change the assumed visibility of entities.
4359
4360 On ELF, default visibility means that the declaration is visible to other
4361 modules and, in shared libraries, means that the declared entity may be
4362 overridden.
4363
4364 On Darwin, default visibility means that the declaration is visible to
4365 other modules.
4366
4367 Default visibility corresponds to ``external linkage'' in the language.
4368
4369 @item hidden
4370 Hidden visibility indicates that the entity declared has a new
4371 form of linkage, which we call ``hidden linkage''. Two
4372 declarations of an object with hidden linkage refer to the same object
4373 if they are in the same shared object.
4374
4375 @item internal
4376 Internal visibility is like hidden visibility, but with additional
4377 processor specific semantics. Unless otherwise specified by the
4378 psABI, GCC defines internal visibility to mean that a function is
4379 @emph{never} called from another module. Compare this with hidden
4380 functions which, while they cannot be referenced directly by other
4381 modules, can be referenced indirectly via function pointers. By
4382 indicating that a function cannot be called from outside the module,
4383 GCC may for instance omit the load of a PIC register since it is known
4384 that the calling function loaded the correct value.
4385
4386 @item protected
4387 Protected visibility is like default visibility except that it
4388 indicates that references within the defining module bind to the
4389 definition in that module. That is, the declared entity cannot be
4390 overridden by another module.
4391
4392 @end table
4393
4394 All visibilities are supported on many, but not all, ELF targets
4395 (supported when the assembler supports the @samp{.visibility}
4396 pseudo-op). Default visibility is supported everywhere. Hidden
4397 visibility is supported on Darwin targets.
4398
4399 The visibility attribute should be applied only to declarations that
4400 would otherwise have external linkage. The attribute should be applied
4401 consistently, so that the same entity should not be declared with
4402 different settings of the attribute.
4403
4404 In C++, the visibility attribute applies to types as well as functions
4405 and objects, because in C++ types have linkage. A class must not have
4406 greater visibility than its non-static data member types and bases,
4407 and class members default to the visibility of their class. Also, a
4408 declaration without explicit visibility is limited to the visibility
4409 of its type.
4410
4411 In C++, you can mark member functions and static member variables of a
4412 class with the visibility attribute. This is useful if you know a
4413 particular method or static member variable should only be used from
4414 one shared object; then you can mark it hidden while the rest of the
4415 class has default visibility. Care must be taken to avoid breaking
4416 the One Definition Rule; for example, it is usually not useful to mark
4417 an inline method as hidden without marking the whole class as hidden.
4418
4419 A C++ namespace declaration can also have the visibility attribute.
4420
4421 @smallexample
4422 namespace nspace1 __attribute__ ((visibility ("protected")))
4423 @{ /* @r{Do something.} */; @}
4424 @end smallexample
4425
4426 This attribute applies only to the particular namespace body, not to
4427 other definitions of the same namespace; it is equivalent to using
4428 @samp{#pragma GCC visibility} before and after the namespace
4429 definition (@pxref{Visibility Pragmas}).
4430
4431 In C++, if a template argument has limited visibility, this
4432 restriction is implicitly propagated to the template instantiation.
4433 Otherwise, template instantiations and specializations default to the
4434 visibility of their template.
4435
4436 If both the template and enclosing class have explicit visibility, the
4437 visibility from the template is used.
4438
4439 @item vliw
4440 @cindex @code{vliw} attribute
4441 On MeP, the @code{vliw} attribute tells the compiler to emit
4442 instructions in VLIW mode instead of core mode. Note that this
4443 attribute is not allowed unless a VLIW coprocessor has been configured
4444 and enabled through command-line options.
4445
4446 @item warn_unused_result
4447 @cindex @code{warn_unused_result} attribute
4448 The @code{warn_unused_result} attribute causes a warning to be emitted
4449 if a caller of the function with this attribute does not use its
4450 return value. This is useful for functions where not checking
4451 the result is either a security problem or always a bug, such as
4452 @code{realloc}.
4453
4454 @smallexample
4455 int fn () __attribute__ ((warn_unused_result));
4456 int foo ()
4457 @{
4458 if (fn () < 0) return -1;
4459 fn ();
4460 return 0;
4461 @}
4462 @end smallexample
4463
4464 @noindent
4465 results in warning on line 5.
4466
4467 @item weak
4468 @cindex @code{weak} attribute
4469 The @code{weak} attribute causes the declaration to be emitted as a weak
4470 symbol rather than a global. This is primarily useful in defining
4471 library functions that can be overridden in user code, though it can
4472 also be used with non-function declarations. Weak symbols are supported
4473 for ELF targets, and also for a.out targets when using the GNU assembler
4474 and linker.
4475
4476 @item weakref
4477 @itemx weakref ("@var{target}")
4478 @cindex @code{weakref} attribute
4479 The @code{weakref} attribute marks a declaration as a weak reference.
4480 Without arguments, it should be accompanied by an @code{alias} attribute
4481 naming the target symbol. Optionally, the @var{target} may be given as
4482 an argument to @code{weakref} itself. In either case, @code{weakref}
4483 implicitly marks the declaration as @code{weak}. Without a
4484 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4485 @code{weakref} is equivalent to @code{weak}.
4486
4487 @smallexample
4488 static int x() __attribute__ ((weakref ("y")));
4489 /* is equivalent to... */
4490 static int x() __attribute__ ((weak, weakref, alias ("y")));
4491 /* and to... */
4492 static int x() __attribute__ ((weakref));
4493 static int x() __attribute__ ((alias ("y")));
4494 @end smallexample
4495
4496 A weak reference is an alias that does not by itself require a
4497 definition to be given for the target symbol. If the target symbol is
4498 only referenced through weak references, then it becomes a @code{weak}
4499 undefined symbol. If it is directly referenced, however, then such
4500 strong references prevail, and a definition is required for the
4501 symbol, not necessarily in the same translation unit.
4502
4503 The effect is equivalent to moving all references to the alias to a
4504 separate translation unit, renaming the alias to the aliased symbol,
4505 declaring it as weak, compiling the two separate translation units and
4506 performing a reloadable link on them.
4507
4508 At present, a declaration to which @code{weakref} is attached can
4509 only be @code{static}.
4510
4511 @end table
4512
4513 You can specify multiple attributes in a declaration by separating them
4514 by commas within the double parentheses or by immediately following an
4515 attribute declaration with another attribute declaration.
4516
4517 @cindex @code{#pragma}, reason for not using
4518 @cindex pragma, reason for not using
4519 Some people object to the @code{__attribute__} feature, suggesting that
4520 ISO C's @code{#pragma} should be used instead. At the time
4521 @code{__attribute__} was designed, there were two reasons for not doing
4522 this.
4523
4524 @enumerate
4525 @item
4526 It is impossible to generate @code{#pragma} commands from a macro.
4527
4528 @item
4529 There is no telling what the same @code{#pragma} might mean in another
4530 compiler.
4531 @end enumerate
4532
4533 These two reasons applied to almost any application that might have been
4534 proposed for @code{#pragma}. It was basically a mistake to use
4535 @code{#pragma} for @emph{anything}.
4536
4537 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4538 to be generated from macros. In addition, a @code{#pragma GCC}
4539 namespace is now in use for GCC-specific pragmas. However, it has been
4540 found convenient to use @code{__attribute__} to achieve a natural
4541 attachment of attributes to their corresponding declarations, whereas
4542 @code{#pragma GCC} is of use for constructs that do not naturally form
4543 part of the grammar. @xref{Pragmas,,Pragmas Accepted by GCC}.
4544
4545 @node Label Attributes
4546 @section Label Attributes
4547 @cindex Label Attributes
4548
4549 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
4550 details of the exact syntax for using attributes. Other attributes are
4551 available for functions (@pxref{Function Attributes}), variables
4552 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
4553
4554 This example uses the @code{cold} label attribute to indicate the
4555 @code{ErrorHandling} branch is unlikely to be taken and that the
4556 @code{ErrorHandling} label is unused:
4557
4558 @smallexample
4559
4560 asm goto ("some asm" : : : : NoError);
4561
4562 /* This branch (the fallthru from the asm) is less commonly used */
4563 ErrorHandling:
4564 __attribute__((cold, unused)); /* Semi-colon is required here */
4565 printf("error\n");
4566 return 0;
4567
4568 NoError:
4569 printf("no error\n");
4570 return 1;
4571 @end smallexample
4572
4573 @table @code
4574 @item unused
4575 @cindex @code{unused} label attribute
4576 This feature is intended for program-generated code that may contain
4577 unused labels, but which is compiled with @option{-Wall}. It is
4578 not normally appropriate to use in it human-written code, though it
4579 could be useful in cases where the code that jumps to the label is
4580 contained within an @code{#ifdef} conditional.
4581
4582 @item hot
4583 @cindex @code{hot} label attribute
4584 The @code{hot} attribute on a label is used to inform the compiler that
4585 the path following the label is more likely than paths that are not so
4586 annotated. This attribute is used in cases where @code{__builtin_expect}
4587 cannot be used, for instance with computed goto or @code{asm goto}.
4588
4589 The @code{hot} attribute on labels is not implemented in GCC versions
4590 earlier than 4.8.
4591
4592 @item cold
4593 @cindex @code{cold} label attribute
4594 The @code{cold} attribute on labels is used to inform the compiler that
4595 the path following the label is unlikely to be executed. This attribute
4596 is used in cases where @code{__builtin_expect} cannot be used, for instance
4597 with computed goto or @code{asm goto}.
4598
4599 The @code{cold} attribute on labels is not implemented in GCC versions
4600 earlier than 4.8.
4601
4602 @end table
4603
4604 @node Attribute Syntax
4605 @section Attribute Syntax
4606 @cindex attribute syntax
4607
4608 This section describes the syntax with which @code{__attribute__} may be
4609 used, and the constructs to which attribute specifiers bind, for the C
4610 language. Some details may vary for C++ and Objective-C@. Because of
4611 infelicities in the grammar for attributes, some forms described here
4612 may not be successfully parsed in all cases.
4613
4614 There are some problems with the semantics of attributes in C++. For
4615 example, there are no manglings for attributes, although they may affect
4616 code generation, so problems may arise when attributed types are used in
4617 conjunction with templates or overloading. Similarly, @code{typeid}
4618 does not distinguish between types with different attributes. Support
4619 for attributes in C++ may be restricted in future to attributes on
4620 declarations only, but not on nested declarators.
4621
4622 @xref{Function Attributes}, for details of the semantics of attributes
4623 applying to functions. @xref{Variable Attributes}, for details of the
4624 semantics of attributes applying to variables. @xref{Type Attributes},
4625 for details of the semantics of attributes applying to structure, union
4626 and enumerated types.
4627 @xref{Label Attributes}, for details of the semantics of attributes
4628 applying to labels.
4629
4630 An @dfn{attribute specifier} is of the form
4631 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
4632 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4633 each attribute is one of the following:
4634
4635 @itemize @bullet
4636 @item
4637 Empty. Empty attributes are ignored.
4638
4639 @item
4640 A word (which may be an identifier such as @code{unused}, or a reserved
4641 word such as @code{const}).
4642
4643 @item
4644 A word, followed by, in parentheses, parameters for the attribute.
4645 These parameters take one of the following forms:
4646
4647 @itemize @bullet
4648 @item
4649 An identifier. For example, @code{mode} attributes use this form.
4650
4651 @item
4652 An identifier followed by a comma and a non-empty comma-separated list
4653 of expressions. For example, @code{format} attributes use this form.
4654
4655 @item
4656 A possibly empty comma-separated list of expressions. For example,
4657 @code{format_arg} attributes use this form with the list being a single
4658 integer constant expression, and @code{alias} attributes use this form
4659 with the list being a single string constant.
4660 @end itemize
4661 @end itemize
4662
4663 An @dfn{attribute specifier list} is a sequence of one or more attribute
4664 specifiers, not separated by any other tokens.
4665
4666 @subsubheading Label Attributes
4667
4668 In GNU C, an attribute specifier list may appear after the colon following a
4669 label, other than a @code{case} or @code{default} label. GNU C++ only permits
4670 attributes on labels if the attribute specifier is immediately
4671 followed by a semicolon (i.e., the label applies to an empty
4672 statement). If the semicolon is missing, C++ label attributes are
4673 ambiguous, as it is permissible for a declaration, which could begin
4674 with an attribute list, to be labelled in C++. Declarations cannot be
4675 labelled in C90 or C99, so the ambiguity does not arise there.
4676
4677 @subsubheading Type Attributes
4678
4679 An attribute specifier list may appear as part of a @code{struct},
4680 @code{union} or @code{enum} specifier. It may go either immediately
4681 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4682 the closing brace. The former syntax is preferred.
4683 Where attribute specifiers follow the closing brace, they are considered
4684 to relate to the structure, union or enumerated type defined, not to any
4685 enclosing declaration the type specifier appears in, and the type
4686 defined is not complete until after the attribute specifiers.
4687 @c Otherwise, there would be the following problems: a shift/reduce
4688 @c conflict between attributes binding the struct/union/enum and
4689 @c binding to the list of specifiers/qualifiers; and "aligned"
4690 @c attributes could use sizeof for the structure, but the size could be
4691 @c changed later by "packed" attributes.
4692
4693
4694 @subsubheading All other attributes
4695
4696 Otherwise, an attribute specifier appears as part of a declaration,
4697 counting declarations of unnamed parameters and type names, and relates
4698 to that declaration (which may be nested in another declaration, for
4699 example in the case of a parameter declaration), or to a particular declarator
4700 within a declaration. Where an
4701 attribute specifier is applied to a parameter declared as a function or
4702 an array, it should apply to the function or array rather than the
4703 pointer to which the parameter is implicitly converted, but this is not
4704 yet correctly implemented.
4705
4706 Any list of specifiers and qualifiers at the start of a declaration may
4707 contain attribute specifiers, whether or not such a list may in that
4708 context contain storage class specifiers. (Some attributes, however,
4709 are essentially in the nature of storage class specifiers, and only make
4710 sense where storage class specifiers may be used; for example,
4711 @code{section}.) There is one necessary limitation to this syntax: the
4712 first old-style parameter declaration in a function definition cannot
4713 begin with an attribute specifier, because such an attribute applies to
4714 the function instead by syntax described below (which, however, is not
4715 yet implemented in this case). In some other cases, attribute
4716 specifiers are permitted by this grammar but not yet supported by the
4717 compiler. All attribute specifiers in this place relate to the
4718 declaration as a whole. In the obsolescent usage where a type of
4719 @code{int} is implied by the absence of type specifiers, such a list of
4720 specifiers and qualifiers may be an attribute specifier list with no
4721 other specifiers or qualifiers.
4722
4723 At present, the first parameter in a function prototype must have some
4724 type specifier that is not an attribute specifier; this resolves an
4725 ambiguity in the interpretation of @code{void f(int
4726 (__attribute__((foo)) x))}, but is subject to change. At present, if
4727 the parentheses of a function declarator contain only attributes then
4728 those attributes are ignored, rather than yielding an error or warning
4729 or implying a single parameter of type int, but this is subject to
4730 change.
4731
4732 An attribute specifier list may appear immediately before a declarator
4733 (other than the first) in a comma-separated list of declarators in a
4734 declaration of more than one identifier using a single list of
4735 specifiers and qualifiers. Such attribute specifiers apply
4736 only to the identifier before whose declarator they appear. For
4737 example, in
4738
4739 @smallexample
4740 __attribute__((noreturn)) void d0 (void),
4741 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4742 d2 (void)
4743 @end smallexample
4744
4745 @noindent
4746 the @code{noreturn} attribute applies to all the functions
4747 declared; the @code{format} attribute only applies to @code{d1}.
4748
4749 An attribute specifier list may appear immediately before the comma,
4750 @code{=} or semicolon terminating the declaration of an identifier other
4751 than a function definition. Such attribute specifiers apply
4752 to the declared object or function. Where an
4753 assembler name for an object or function is specified (@pxref{Asm
4754 Labels}), the attribute must follow the @code{asm}
4755 specification.
4756
4757 An attribute specifier list may, in future, be permitted to appear after
4758 the declarator in a function definition (before any old-style parameter
4759 declarations or the function body).
4760
4761 Attribute specifiers may be mixed with type qualifiers appearing inside
4762 the @code{[]} of a parameter array declarator, in the C99 construct by
4763 which such qualifiers are applied to the pointer to which the array is
4764 implicitly converted. Such attribute specifiers apply to the pointer,
4765 not to the array, but at present this is not implemented and they are
4766 ignored.
4767
4768 An attribute specifier list may appear at the start of a nested
4769 declarator. At present, there are some limitations in this usage: the
4770 attributes correctly apply to the declarator, but for most individual
4771 attributes the semantics this implies are not implemented.
4772 When attribute specifiers follow the @code{*} of a pointer
4773 declarator, they may be mixed with any type qualifiers present.
4774 The following describes the formal semantics of this syntax. It makes the
4775 most sense if you are familiar with the formal specification of
4776 declarators in the ISO C standard.
4777
4778 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4779 D1}, where @code{T} contains declaration specifiers that specify a type
4780 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4781 contains an identifier @var{ident}. The type specified for @var{ident}
4782 for derived declarators whose type does not include an attribute
4783 specifier is as in the ISO C standard.
4784
4785 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4786 and the declaration @code{T D} specifies the type
4787 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4788 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4789 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4790
4791 If @code{D1} has the form @code{*
4792 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4793 declaration @code{T D} specifies the type
4794 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4795 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4796 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4797 @var{ident}.
4798
4799 For example,
4800
4801 @smallexample
4802 void (__attribute__((noreturn)) ****f) (void);
4803 @end smallexample
4804
4805 @noindent
4806 specifies the type ``pointer to pointer to pointer to pointer to
4807 non-returning function returning @code{void}''. As another example,
4808
4809 @smallexample
4810 char *__attribute__((aligned(8))) *f;
4811 @end smallexample
4812
4813 @noindent
4814 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4815 Note again that this does not work with most attributes; for example,
4816 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4817 is not yet supported.
4818
4819 For compatibility with existing code written for compiler versions that
4820 did not implement attributes on nested declarators, some laxity is
4821 allowed in the placing of attributes. If an attribute that only applies
4822 to types is applied to a declaration, it is treated as applying to
4823 the type of that declaration. If an attribute that only applies to
4824 declarations is applied to the type of a declaration, it is treated
4825 as applying to that declaration; and, for compatibility with code
4826 placing the attributes immediately before the identifier declared, such
4827 an attribute applied to a function return type is treated as
4828 applying to the function type, and such an attribute applied to an array
4829 element type is treated as applying to the array type. If an
4830 attribute that only applies to function types is applied to a
4831 pointer-to-function type, it is treated as applying to the pointer
4832 target type; if such an attribute is applied to a function return type
4833 that is not a pointer-to-function type, it is treated as applying
4834 to the function type.
4835
4836 @node Function Prototypes
4837 @section Prototypes and Old-Style Function Definitions
4838 @cindex function prototype declarations
4839 @cindex old-style function definitions
4840 @cindex promotion of formal parameters
4841
4842 GNU C extends ISO C to allow a function prototype to override a later
4843 old-style non-prototype definition. Consider the following example:
4844
4845 @smallexample
4846 /* @r{Use prototypes unless the compiler is old-fashioned.} */
4847 #ifdef __STDC__
4848 #define P(x) x
4849 #else
4850 #define P(x) ()
4851 #endif
4852
4853 /* @r{Prototype function declaration.} */
4854 int isroot P((uid_t));
4855
4856 /* @r{Old-style function definition.} */
4857 int
4858 isroot (x) /* @r{??? lossage here ???} */
4859 uid_t x;
4860 @{
4861 return x == 0;
4862 @}
4863 @end smallexample
4864
4865 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
4866 not allow this example, because subword arguments in old-style
4867 non-prototype definitions are promoted. Therefore in this example the
4868 function definition's argument is really an @code{int}, which does not
4869 match the prototype argument type of @code{short}.
4870
4871 This restriction of ISO C makes it hard to write code that is portable
4872 to traditional C compilers, because the programmer does not know
4873 whether the @code{uid_t} type is @code{short}, @code{int}, or
4874 @code{long}. Therefore, in cases like these GNU C allows a prototype
4875 to override a later old-style definition. More precisely, in GNU C, a
4876 function prototype argument type overrides the argument type specified
4877 by a later old-style definition if the former type is the same as the
4878 latter type before promotion. Thus in GNU C the above example is
4879 equivalent to the following:
4880
4881 @smallexample
4882 int isroot (uid_t);
4883
4884 int
4885 isroot (uid_t x)
4886 @{
4887 return x == 0;
4888 @}
4889 @end smallexample
4890
4891 @noindent
4892 GNU C++ does not support old-style function definitions, so this
4893 extension is irrelevant.
4894
4895 @node C++ Comments
4896 @section C++ Style Comments
4897 @cindex @code{//}
4898 @cindex C++ comments
4899 @cindex comments, C++ style
4900
4901 In GNU C, you may use C++ style comments, which start with @samp{//} and
4902 continue until the end of the line. Many other C implementations allow
4903 such comments, and they are included in the 1999 C standard. However,
4904 C++ style comments are not recognized if you specify an @option{-std}
4905 option specifying a version of ISO C before C99, or @option{-ansi}
4906 (equivalent to @option{-std=c90}).
4907
4908 @node Dollar Signs
4909 @section Dollar Signs in Identifier Names
4910 @cindex $
4911 @cindex dollar signs in identifier names
4912 @cindex identifier names, dollar signs in
4913
4914 In GNU C, you may normally use dollar signs in identifier names.
4915 This is because many traditional C implementations allow such identifiers.
4916 However, dollar signs in identifiers are not supported on a few target
4917 machines, typically because the target assembler does not allow them.
4918
4919 @node Character Escapes
4920 @section The Character @key{ESC} in Constants
4921
4922 You can use the sequence @samp{\e} in a string or character constant to
4923 stand for the ASCII character @key{ESC}.
4924
4925 @node Variable Attributes
4926 @section Specifying Attributes of Variables
4927 @cindex attribute of variables
4928 @cindex variable attributes
4929
4930 The keyword @code{__attribute__} allows you to specify special
4931 attributes of variables or structure fields. This keyword is followed
4932 by an attribute specification inside double parentheses. Some
4933 attributes are currently defined generically for variables.
4934 Other attributes are defined for variables on particular target
4935 systems. Other attributes are available for functions
4936 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for
4937 types (@pxref{Type Attributes}).
4938 Other front ends might define more attributes
4939 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4940
4941 You may also specify attributes with @samp{__} preceding and following
4942 each keyword. This allows you to use them in header files without
4943 being concerned about a possible macro of the same name. For example,
4944 you may use @code{__aligned__} instead of @code{aligned}.
4945
4946 @xref{Attribute Syntax}, for details of the exact syntax for using
4947 attributes.
4948
4949 @table @code
4950 @cindex @code{aligned} attribute
4951 @item aligned (@var{alignment})
4952 This attribute specifies a minimum alignment for the variable or
4953 structure field, measured in bytes. For example, the declaration:
4954
4955 @smallexample
4956 int x __attribute__ ((aligned (16))) = 0;
4957 @end smallexample
4958
4959 @noindent
4960 causes the compiler to allocate the global variable @code{x} on a
4961 16-byte boundary. On a 68040, this could be used in conjunction with
4962 an @code{asm} expression to access the @code{move16} instruction which
4963 requires 16-byte aligned operands.
4964
4965 You can also specify the alignment of structure fields. For example, to
4966 create a double-word aligned @code{int} pair, you could write:
4967
4968 @smallexample
4969 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
4970 @end smallexample
4971
4972 @noindent
4973 This is an alternative to creating a union with a @code{double} member,
4974 which forces the union to be double-word aligned.
4975
4976 As in the preceding examples, you can explicitly specify the alignment
4977 (in bytes) that you wish the compiler to use for a given variable or
4978 structure field. Alternatively, you can leave out the alignment factor
4979 and just ask the compiler to align a variable or field to the
4980 default alignment for the target architecture you are compiling for.
4981 The default alignment is sufficient for all scalar types, but may not be
4982 enough for all vector types on a target that supports vector operations.
4983 The default alignment is fixed for a particular target ABI.
4984
4985 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
4986 which is the largest alignment ever used for any data type on the
4987 target machine you are compiling for. For example, you could write:
4988
4989 @smallexample
4990 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
4991 @end smallexample
4992
4993 The compiler automatically sets the alignment for the declared
4994 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
4995 often make copy operations more efficient, because the compiler can
4996 use whatever instructions copy the biggest chunks of memory when
4997 performing copies to or from the variables or fields that you have
4998 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
4999 may change depending on command-line options.
5000
5001 When used on a struct, or struct member, the @code{aligned} attribute can
5002 only increase the alignment; in order to decrease it, the @code{packed}
5003 attribute must be specified as well. When used as part of a typedef, the
5004 @code{aligned} attribute can both increase and decrease alignment, and
5005 specifying the @code{packed} attribute generates a warning.
5006
5007 Note that the effectiveness of @code{aligned} attributes may be limited
5008 by inherent limitations in your linker. On many systems, the linker is
5009 only able to arrange for variables to be aligned up to a certain maximum
5010 alignment. (For some linkers, the maximum supported alignment may
5011 be very very small.) If your linker is only able to align variables
5012 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5013 in an @code{__attribute__} still only provides you with 8-byte
5014 alignment. See your linker documentation for further information.
5015
5016 The @code{aligned} attribute can also be used for functions
5017 (@pxref{Function Attributes}.)
5018
5019 @item cleanup (@var{cleanup_function})
5020 @cindex @code{cleanup} attribute
5021 The @code{cleanup} attribute runs a function when the variable goes
5022 out of scope. This attribute can only be applied to auto function
5023 scope variables; it may not be applied to parameters or variables
5024 with static storage duration. The function must take one parameter,
5025 a pointer to a type compatible with the variable. The return value
5026 of the function (if any) is ignored.
5027
5028 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5029 is run during the stack unwinding that happens during the
5030 processing of the exception. Note that the @code{cleanup} attribute
5031 does not allow the exception to be caught, only to perform an action.
5032 It is undefined what happens if @var{cleanup_function} does not
5033 return normally.
5034
5035 @item common
5036 @itemx nocommon
5037 @cindex @code{common} attribute
5038 @cindex @code{nocommon} attribute
5039 @opindex fcommon
5040 @opindex fno-common
5041 The @code{common} attribute requests GCC to place a variable in
5042 ``common'' storage. The @code{nocommon} attribute requests the
5043 opposite---to allocate space for it directly.
5044
5045 These attributes override the default chosen by the
5046 @option{-fno-common} and @option{-fcommon} flags respectively.
5047
5048 @item deprecated
5049 @itemx deprecated (@var{msg})
5050 @cindex @code{deprecated} attribute
5051 The @code{deprecated} attribute results in a warning if the variable
5052 is used anywhere in the source file. This is useful when identifying
5053 variables that are expected to be removed in a future version of a
5054 program. The warning also includes the location of the declaration
5055 of the deprecated variable, to enable users to easily find further
5056 information about why the variable is deprecated, or what they should
5057 do instead. Note that the warning only occurs for uses:
5058
5059 @smallexample
5060 extern int old_var __attribute__ ((deprecated));
5061 extern int old_var;
5062 int new_fn () @{ return old_var; @}
5063 @end smallexample
5064
5065 @noindent
5066 results in a warning on line 3 but not line 2. The optional @var{msg}
5067 argument, which must be a string, is printed in the warning if
5068 present.
5069
5070 The @code{deprecated} attribute can also be used for functions and
5071 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
5072
5073 @item mode (@var{mode})
5074 @cindex @code{mode} attribute
5075 This attribute specifies the data type for the declaration---whichever
5076 type corresponds to the mode @var{mode}. This in effect lets you
5077 request an integer or floating-point type according to its width.
5078
5079 You may also specify a mode of @code{byte} or @code{__byte__} to
5080 indicate the mode corresponding to a one-byte integer, @code{word} or
5081 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5082 or @code{__pointer__} for the mode used to represent pointers.
5083
5084 @item packed
5085 @cindex @code{packed} attribute
5086 The @code{packed} attribute specifies that a variable or structure field
5087 should have the smallest possible alignment---one byte for a variable,
5088 and one bit for a field, unless you specify a larger value with the
5089 @code{aligned} attribute.
5090
5091 Here is a structure in which the field @code{x} is packed, so that it
5092 immediately follows @code{a}:
5093
5094 @smallexample
5095 struct foo
5096 @{
5097 char a;
5098 int x[2] __attribute__ ((packed));
5099 @};
5100 @end smallexample
5101
5102 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5103 @code{packed} attribute on bit-fields of type @code{char}. This has
5104 been fixed in GCC 4.4 but the change can lead to differences in the
5105 structure layout. See the documentation of
5106 @option{-Wpacked-bitfield-compat} for more information.
5107
5108 @item section ("@var{section-name}")
5109 @cindex @code{section} variable attribute
5110 Normally, the compiler places the objects it generates in sections like
5111 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5112 or you need certain particular variables to appear in special sections,
5113 for example to map to special hardware. The @code{section}
5114 attribute specifies that a variable (or function) lives in a particular
5115 section. For example, this small program uses several specific section names:
5116
5117 @smallexample
5118 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5119 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5120 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5121 int init_data __attribute__ ((section ("INITDATA")));
5122
5123 main()
5124 @{
5125 /* @r{Initialize stack pointer} */
5126 init_sp (stack + sizeof (stack));
5127
5128 /* @r{Initialize initialized data} */
5129 memcpy (&init_data, &data, &edata - &data);
5130
5131 /* @r{Turn on the serial ports} */
5132 init_duart (&a);
5133 init_duart (&b);
5134 @}
5135 @end smallexample
5136
5137 @noindent
5138 Use the @code{section} attribute with
5139 @emph{global} variables and not @emph{local} variables,
5140 as shown in the example.
5141
5142 You may use the @code{section} attribute with initialized or
5143 uninitialized global variables but the linker requires
5144 each object be defined once, with the exception that uninitialized
5145 variables tentatively go in the @code{common} (or @code{bss}) section
5146 and can be multiply ``defined''. Using the @code{section} attribute
5147 changes what section the variable goes into and may cause the
5148 linker to issue an error if an uninitialized variable has multiple
5149 definitions. You can force a variable to be initialized with the
5150 @option{-fno-common} flag or the @code{nocommon} attribute.
5151
5152 Some file formats do not support arbitrary sections so the @code{section}
5153 attribute is not available on all platforms.
5154 If you need to map the entire contents of a module to a particular
5155 section, consider using the facilities of the linker instead.
5156
5157 @item shared
5158 @cindex @code{shared} variable attribute
5159 On Microsoft Windows, in addition to putting variable definitions in a named
5160 section, the section can also be shared among all running copies of an
5161 executable or DLL@. For example, this small program defines shared data
5162 by putting it in a named section @code{shared} and marking the section
5163 shareable:
5164
5165 @smallexample
5166 int foo __attribute__((section ("shared"), shared)) = 0;
5167
5168 int
5169 main()
5170 @{
5171 /* @r{Read and write foo. All running
5172 copies see the same value.} */
5173 return 0;
5174 @}
5175 @end smallexample
5176
5177 @noindent
5178 You may only use the @code{shared} attribute along with @code{section}
5179 attribute with a fully-initialized global definition because of the way
5180 linkers work. See @code{section} attribute for more information.
5181
5182 The @code{shared} attribute is only available on Microsoft Windows@.
5183
5184 @item tls_model ("@var{tls_model}")
5185 @cindex @code{tls_model} attribute
5186 The @code{tls_model} attribute sets thread-local storage model
5187 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5188 overriding @option{-ftls-model=} command-line switch on a per-variable
5189 basis.
5190 The @var{tls_model} argument should be one of @code{global-dynamic},
5191 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5192
5193 Not all targets support this attribute.
5194
5195 @item unused
5196 This attribute, attached to a variable, means that the variable is meant
5197 to be possibly unused. GCC does not produce a warning for this
5198 variable.
5199
5200 @item used
5201 This attribute, attached to a variable with the static storage, means that
5202 the variable must be emitted even if it appears that the variable is not
5203 referenced.
5204
5205 When applied to a static data member of a C++ class template, the
5206 attribute also means that the member is instantiated if the
5207 class itself is instantiated.
5208
5209 @item vector_size (@var{bytes})
5210 This attribute specifies the vector size for the variable, measured in
5211 bytes. For example, the declaration:
5212
5213 @smallexample
5214 int foo __attribute__ ((vector_size (16)));
5215 @end smallexample
5216
5217 @noindent
5218 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5219 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5220 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5221
5222 This attribute is only applicable to integral and float scalars,
5223 although arrays, pointers, and function return values are allowed in
5224 conjunction with this construct.
5225
5226 Aggregates with this attribute are invalid, even if they are of the same
5227 size as a corresponding scalar. For example, the declaration:
5228
5229 @smallexample
5230 struct S @{ int a; @};
5231 struct S __attribute__ ((vector_size (16))) foo;
5232 @end smallexample
5233
5234 @noindent
5235 is invalid even if the size of the structure is the same as the size of
5236 the @code{int}.
5237
5238 @item selectany
5239 The @code{selectany} attribute causes an initialized global variable to
5240 have link-once semantics. When multiple definitions of the variable are
5241 encountered by the linker, the first is selected and the remainder are
5242 discarded. Following usage by the Microsoft compiler, the linker is told
5243 @emph{not} to warn about size or content differences of the multiple
5244 definitions.
5245
5246 Although the primary usage of this attribute is for POD types, the
5247 attribute can also be applied to global C++ objects that are initialized
5248 by a constructor. In this case, the static initialization and destruction
5249 code for the object is emitted in each translation defining the object,
5250 but the calls to the constructor and destructor are protected by a
5251 link-once guard variable.
5252
5253 The @code{selectany} attribute is only available on Microsoft Windows
5254 targets. You can use @code{__declspec (selectany)} as a synonym for
5255 @code{__attribute__ ((selectany))} for compatibility with other
5256 compilers.
5257
5258 @item weak
5259 The @code{weak} attribute is described in @ref{Function Attributes}.
5260
5261 @item dllimport
5262 The @code{dllimport} attribute is described in @ref{Function Attributes}.
5263
5264 @item dllexport
5265 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5266
5267 @end table
5268
5269 @anchor{AVR Variable Attributes}
5270 @subsection AVR Variable Attributes
5271
5272 @table @code
5273 @item progmem
5274 @cindex @code{progmem} AVR variable attribute
5275 The @code{progmem} attribute is used on the AVR to place read-only
5276 data in the non-volatile program memory (flash). The @code{progmem}
5277 attribute accomplishes this by putting respective variables into a
5278 section whose name starts with @code{.progmem}.
5279
5280 This attribute works similar to the @code{section} attribute
5281 but adds additional checking. Notice that just like the
5282 @code{section} attribute, @code{progmem} affects the location
5283 of the data but not how this data is accessed.
5284
5285 In order to read data located with the @code{progmem} attribute
5286 (inline) assembler must be used.
5287 @smallexample
5288 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5289 #include <avr/pgmspace.h>
5290
5291 /* Locate var in flash memory */
5292 const int var[2] PROGMEM = @{ 1, 2 @};
5293
5294 int read_var (int i)
5295 @{
5296 /* Access var[] by accessor macro from avr/pgmspace.h */
5297 return (int) pgm_read_word (& var[i]);
5298 @}
5299 @end smallexample
5300
5301 AVR is a Harvard architecture processor and data and read-only data
5302 normally resides in the data memory (RAM).
5303
5304 See also the @ref{AVR Named Address Spaces} section for
5305 an alternate way to locate and access data in flash memory.
5306 @end table
5307
5308 @subsection Blackfin Variable Attributes
5309
5310 Three attributes are currently defined for the Blackfin.
5311
5312 @table @code
5313 @item l1_data
5314 @itemx l1_data_A
5315 @itemx l1_data_B
5316 @cindex @code{l1_data} variable attribute
5317 @cindex @code{l1_data_A} variable attribute
5318 @cindex @code{l1_data_B} variable attribute
5319 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5320 Variables with @code{l1_data} attribute are put into the specific section
5321 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5322 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5323 attribute are put into the specific section named @code{.l1.data.B}.
5324
5325 @item l2
5326 @cindex @code{l2} variable attribute
5327 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5328 Variables with @code{l2} attribute are put into the specific section
5329 named @code{.l2.data}.
5330 @end table
5331
5332 @subsection M32R/D Variable Attributes
5333
5334 One attribute is currently defined for the M32R/D@.
5335
5336 @table @code
5337 @item model (@var{model-name})
5338 @cindex variable addressability on the M32R/D
5339 Use this attribute on the M32R/D to set the addressability of an object.
5340 The identifier @var{model-name} is one of @code{small}, @code{medium},
5341 or @code{large}, representing each of the code models.
5342
5343 Small model objects live in the lower 16MB of memory (so that their
5344 addresses can be loaded with the @code{ld24} instruction).
5345
5346 Medium and large model objects may live anywhere in the 32-bit address space
5347 (the compiler generates @code{seth/add3} instructions to load their
5348 addresses).
5349 @end table
5350
5351 @anchor{MeP Variable Attributes}
5352 @subsection MeP Variable Attributes
5353
5354 The MeP target has a number of addressing modes and busses. The
5355 @code{near} space spans the standard memory space's first 16 megabytes
5356 (24 bits). The @code{far} space spans the entire 32-bit memory space.
5357 The @code{based} space is a 128-byte region in the memory space that
5358 is addressed relative to the @code{$tp} register. The @code{tiny}
5359 space is a 65536-byte region relative to the @code{$gp} register. In
5360 addition to these memory regions, the MeP target has a separate 16-bit
5361 control bus which is specified with @code{cb} attributes.
5362
5363 @table @code
5364
5365 @item based
5366 Any variable with the @code{based} attribute is assigned to the
5367 @code{.based} section, and is accessed with relative to the
5368 @code{$tp} register.
5369
5370 @item tiny
5371 Likewise, the @code{tiny} attribute assigned variables to the
5372 @code{.tiny} section, relative to the @code{$gp} register.
5373
5374 @item near
5375 Variables with the @code{near} attribute are assumed to have addresses
5376 that fit in a 24-bit addressing mode. This is the default for large
5377 variables (@code{-mtiny=4} is the default) but this attribute can
5378 override @code{-mtiny=} for small variables, or override @code{-ml}.
5379
5380 @item far
5381 Variables with the @code{far} attribute are addressed using a full
5382 32-bit address. Since this covers the entire memory space, this
5383 allows modules to make no assumptions about where variables might be
5384 stored.
5385
5386 @item io
5387 @itemx io (@var{addr})
5388 Variables with the @code{io} attribute are used to address
5389 memory-mapped peripherals. If an address is specified, the variable
5390 is assigned that address, else it is not assigned an address (it is
5391 assumed some other module assigns an address). Example:
5392
5393 @smallexample
5394 int timer_count __attribute__((io(0x123)));
5395 @end smallexample
5396
5397 @item cb
5398 @itemx cb (@var{addr})
5399 Variables with the @code{cb} attribute are used to access the control
5400 bus, using special instructions. @code{addr} indicates the control bus
5401 address. Example:
5402
5403 @smallexample
5404 int cpu_clock __attribute__((cb(0x123)));
5405 @end smallexample
5406
5407 @end table
5408
5409 @anchor{i386 Variable Attributes}
5410 @subsection i386 Variable Attributes
5411
5412 Two attributes are currently defined for i386 configurations:
5413 @code{ms_struct} and @code{gcc_struct}
5414
5415 @table @code
5416 @item ms_struct
5417 @itemx gcc_struct
5418 @cindex @code{ms_struct} attribute
5419 @cindex @code{gcc_struct} attribute
5420
5421 If @code{packed} is used on a structure, or if bit-fields are used,
5422 it may be that the Microsoft ABI lays out the structure differently
5423 than the way GCC normally does. Particularly when moving packed
5424 data between functions compiled with GCC and the native Microsoft compiler
5425 (either via function call or as data in a file), it may be necessary to access
5426 either format.
5427
5428 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5429 compilers to match the native Microsoft compiler.
5430
5431 The Microsoft structure layout algorithm is fairly simple with the exception
5432 of the bit-field packing.
5433 The padding and alignment of members of structures and whether a bit-field
5434 can straddle a storage-unit boundary are determine by these rules:
5435
5436 @enumerate
5437 @item Structure members are stored sequentially in the order in which they are
5438 declared: the first member has the lowest memory address and the last member
5439 the highest.
5440
5441 @item Every data object has an alignment requirement. The alignment requirement
5442 for all data except structures, unions, and arrays is either the size of the
5443 object or the current packing size (specified with either the
5444 @code{aligned} attribute or the @code{pack} pragma),
5445 whichever is less. For structures, unions, and arrays,
5446 the alignment requirement is the largest alignment requirement of its members.
5447 Every object is allocated an offset so that:
5448
5449 @smallexample
5450 offset % alignment_requirement == 0
5451 @end smallexample
5452
5453 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5454 unit if the integral types are the same size and if the next bit-field fits
5455 into the current allocation unit without crossing the boundary imposed by the
5456 common alignment requirements of the bit-fields.
5457 @end enumerate
5458
5459 MSVC interprets zero-length bit-fields in the following ways:
5460
5461 @enumerate
5462 @item If a zero-length bit-field is inserted between two bit-fields that
5463 are normally coalesced, the bit-fields are not coalesced.
5464
5465 For example:
5466
5467 @smallexample
5468 struct
5469 @{
5470 unsigned long bf_1 : 12;
5471 unsigned long : 0;
5472 unsigned long bf_2 : 12;
5473 @} t1;
5474 @end smallexample
5475
5476 @noindent
5477 The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
5478 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5479
5480 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5481 alignment of the zero-length bit-field is greater than the member that follows it,
5482 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5483
5484 For example:
5485
5486 @smallexample
5487 struct
5488 @{
5489 char foo : 4;
5490 short : 0;
5491 char bar;
5492 @} t2;
5493
5494 struct
5495 @{
5496 char foo : 4;
5497 short : 0;
5498 double bar;
5499 @} t3;
5500 @end smallexample
5501
5502 @noindent
5503 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5504 Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
5505 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5506 of the structure.
5507
5508 Taking this into account, it is important to note the following:
5509
5510 @enumerate
5511 @item If a zero-length bit-field follows a normal bit-field, the type of the
5512 zero-length bit-field may affect the alignment of the structure as whole. For
5513 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5514 normal bit-field, and is of type short.
5515
5516 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5517 still affect the alignment of the structure:
5518
5519 @smallexample
5520 struct
5521 @{
5522 char foo : 6;
5523 long : 0;
5524 @} t4;
5525 @end smallexample
5526
5527 @noindent
5528 Here, @code{t4} takes up 4 bytes.
5529 @end enumerate
5530
5531 @item Zero-length bit-fields following non-bit-field members are ignored:
5532
5533 @smallexample
5534 struct
5535 @{
5536 char foo;
5537 long : 0;
5538 char bar;
5539 @} t5;
5540 @end smallexample
5541
5542 @noindent
5543 Here, @code{t5} takes up 2 bytes.
5544 @end enumerate
5545 @end table
5546
5547 @subsection PowerPC Variable Attributes
5548
5549 Three attributes currently are defined for PowerPC configurations:
5550 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5551
5552 For full documentation of the struct attributes please see the
5553 documentation in @ref{i386 Variable Attributes}.
5554
5555 For documentation of @code{altivec} attribute please see the
5556 documentation in @ref{PowerPC Type Attributes}.
5557
5558 @subsection SPU Variable Attributes
5559
5560 The SPU supports the @code{spu_vector} attribute for variables. For
5561 documentation of this attribute please see the documentation in
5562 @ref{SPU Type Attributes}.
5563
5564 @subsection Xstormy16 Variable Attributes
5565
5566 One attribute is currently defined for xstormy16 configurations:
5567 @code{below100}.
5568
5569 @table @code
5570 @item below100
5571 @cindex @code{below100} attribute
5572
5573 If a variable has the @code{below100} attribute (@code{BELOW100} is
5574 allowed also), GCC places the variable in the first 0x100 bytes of
5575 memory and use special opcodes to access it. Such variables are
5576 placed in either the @code{.bss_below100} section or the
5577 @code{.data_below100} section.
5578
5579 @end table
5580
5581 @node Type Attributes
5582 @section Specifying Attributes of Types
5583 @cindex attribute of types
5584 @cindex type attributes
5585
5586 The keyword @code{__attribute__} allows you to specify special
5587 attributes of @code{struct} and @code{union} types when you define
5588 such types. This keyword is followed by an attribute specification
5589 inside double parentheses. Seven attributes are currently defined for
5590 types: @code{aligned}, @code{packed}, @code{transparent_union},
5591 @code{unused}, @code{deprecated}, @code{visibility}, and
5592 @code{may_alias}. Other attributes are defined for functions
5593 (@pxref{Function Attributes}), labels (@pxref{Label
5594 Attributes}) and for variables (@pxref{Variable Attributes}).
5595
5596 You may also specify any one of these attributes with @samp{__}
5597 preceding and following its keyword. This allows you to use these
5598 attributes in header files without being concerned about a possible
5599 macro of the same name. For example, you may use @code{__aligned__}
5600 instead of @code{aligned}.
5601
5602 You may specify type attributes in an enum, struct or union type
5603 declaration or definition, or for other types in a @code{typedef}
5604 declaration.
5605
5606 For an enum, struct or union type, you may specify attributes either
5607 between the enum, struct or union tag and the name of the type, or
5608 just past the closing curly brace of the @emph{definition}. The
5609 former syntax is preferred.
5610
5611 @xref{Attribute Syntax}, for details of the exact syntax for using
5612 attributes.
5613
5614 @table @code
5615 @cindex @code{aligned} attribute
5616 @item aligned (@var{alignment})
5617 This attribute specifies a minimum alignment (in bytes) for variables
5618 of the specified type. For example, the declarations:
5619
5620 @smallexample
5621 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5622 typedef int more_aligned_int __attribute__ ((aligned (8)));
5623 @end smallexample
5624
5625 @noindent
5626 force the compiler to ensure (as far as it can) that each variable whose
5627 type is @code{struct S} or @code{more_aligned_int} is allocated and
5628 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
5629 variables of type @code{struct S} aligned to 8-byte boundaries allows
5630 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5631 store) instructions when copying one variable of type @code{struct S} to
5632 another, thus improving run-time efficiency.
5633
5634 Note that the alignment of any given @code{struct} or @code{union} type
5635 is required by the ISO C standard to be at least a perfect multiple of
5636 the lowest common multiple of the alignments of all of the members of
5637 the @code{struct} or @code{union} in question. This means that you @emph{can}
5638 effectively adjust the alignment of a @code{struct} or @code{union}
5639 type by attaching an @code{aligned} attribute to any one of the members
5640 of such a type, but the notation illustrated in the example above is a
5641 more obvious, intuitive, and readable way to request the compiler to
5642 adjust the alignment of an entire @code{struct} or @code{union} type.
5643
5644 As in the preceding example, you can explicitly specify the alignment
5645 (in bytes) that you wish the compiler to use for a given @code{struct}
5646 or @code{union} type. Alternatively, you can leave out the alignment factor
5647 and just ask the compiler to align a type to the maximum
5648 useful alignment for the target machine you are compiling for. For
5649 example, you could write:
5650
5651 @smallexample
5652 struct S @{ short f[3]; @} __attribute__ ((aligned));
5653 @end smallexample
5654
5655 Whenever you leave out the alignment factor in an @code{aligned}
5656 attribute specification, the compiler automatically sets the alignment
5657 for the type to the largest alignment that is ever used for any data
5658 type on the target machine you are compiling for. Doing this can often
5659 make copy operations more efficient, because the compiler can use
5660 whatever instructions copy the biggest chunks of memory when performing
5661 copies to or from the variables that have types that you have aligned
5662 this way.
5663
5664 In the example above, if the size of each @code{short} is 2 bytes, then
5665 the size of the entire @code{struct S} type is 6 bytes. The smallest
5666 power of two that is greater than or equal to that is 8, so the
5667 compiler sets the alignment for the entire @code{struct S} type to 8
5668 bytes.
5669
5670 Note that although you can ask the compiler to select a time-efficient
5671 alignment for a given type and then declare only individual stand-alone
5672 objects of that type, the compiler's ability to select a time-efficient
5673 alignment is primarily useful only when you plan to create arrays of
5674 variables having the relevant (efficiently aligned) type. If you
5675 declare or use arrays of variables of an efficiently-aligned type, then
5676 it is likely that your program also does pointer arithmetic (or
5677 subscripting, which amounts to the same thing) on pointers to the
5678 relevant type, and the code that the compiler generates for these
5679 pointer arithmetic operations is often more efficient for
5680 efficiently-aligned types than for other types.
5681
5682 The @code{aligned} attribute can only increase the alignment; but you
5683 can decrease it by specifying @code{packed} as well. See below.
5684
5685 Note that the effectiveness of @code{aligned} attributes may be limited
5686 by inherent limitations in your linker. On many systems, the linker is
5687 only able to arrange for variables to be aligned up to a certain maximum
5688 alignment. (For some linkers, the maximum supported alignment may
5689 be very very small.) If your linker is only able to align variables
5690 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5691 in an @code{__attribute__} still only provides you with 8-byte
5692 alignment. See your linker documentation for further information.
5693
5694 @item packed
5695 This attribute, attached to @code{struct} or @code{union} type
5696 definition, specifies that each member (other than zero-width bit-fields)
5697 of the structure or union is placed to minimize the memory required. When
5698 attached to an @code{enum} definition, it indicates that the smallest
5699 integral type should be used.
5700
5701 @opindex fshort-enums
5702 Specifying this attribute for @code{struct} and @code{union} types is
5703 equivalent to specifying the @code{packed} attribute on each of the
5704 structure or union members. Specifying the @option{-fshort-enums}
5705 flag on the line is equivalent to specifying the @code{packed}
5706 attribute on all @code{enum} definitions.
5707
5708 In the following example @code{struct my_packed_struct}'s members are
5709 packed closely together, but the internal layout of its @code{s} member
5710 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5711 be packed too.
5712
5713 @smallexample
5714 struct my_unpacked_struct
5715 @{
5716 char c;
5717 int i;
5718 @};
5719
5720 struct __attribute__ ((__packed__)) my_packed_struct
5721 @{
5722 char c;
5723 int i;
5724 struct my_unpacked_struct s;
5725 @};
5726 @end smallexample
5727
5728 You may only specify this attribute on the definition of an @code{enum},
5729 @code{struct} or @code{union}, not on a @code{typedef} that does not
5730 also define the enumerated type, structure or union.
5731
5732 @item transparent_union
5733 This attribute, attached to a @code{union} type definition, indicates
5734 that any function parameter having that union type causes calls to that
5735 function to be treated in a special way.
5736
5737 First, the argument corresponding to a transparent union type can be of
5738 any type in the union; no cast is required. Also, if the union contains
5739 a pointer type, the corresponding argument can be a null pointer
5740 constant or a void pointer expression; and if the union contains a void
5741 pointer type, the corresponding argument can be any pointer expression.
5742 If the union member type is a pointer, qualifiers like @code{const} on
5743 the referenced type must be respected, just as with normal pointer
5744 conversions.
5745
5746 Second, the argument is passed to the function using the calling
5747 conventions of the first member of the transparent union, not the calling
5748 conventions of the union itself. All members of the union must have the
5749 same machine representation; this is necessary for this argument passing
5750 to work properly.
5751
5752 Transparent unions are designed for library functions that have multiple
5753 interfaces for compatibility reasons. For example, suppose the
5754 @code{wait} function must accept either a value of type @code{int *} to
5755 comply with POSIX, or a value of type @code{union wait *} to comply with
5756 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
5757 @code{wait} would accept both kinds of arguments, but it would also
5758 accept any other pointer type and this would make argument type checking
5759 less useful. Instead, @code{<sys/wait.h>} might define the interface
5760 as follows:
5761
5762 @smallexample
5763 typedef union __attribute__ ((__transparent_union__))
5764 @{
5765 int *__ip;
5766 union wait *__up;
5767 @} wait_status_ptr_t;
5768
5769 pid_t wait (wait_status_ptr_t);
5770 @end smallexample
5771
5772 @noindent
5773 This interface allows either @code{int *} or @code{union wait *}
5774 arguments to be passed, using the @code{int *} calling convention.
5775 The program can call @code{wait} with arguments of either type:
5776
5777 @smallexample
5778 int w1 () @{ int w; return wait (&w); @}
5779 int w2 () @{ union wait w; return wait (&w); @}
5780 @end smallexample
5781
5782 @noindent
5783 With this interface, @code{wait}'s implementation might look like this:
5784
5785 @smallexample
5786 pid_t wait (wait_status_ptr_t p)
5787 @{
5788 return waitpid (-1, p.__ip, 0);
5789 @}
5790 @end smallexample
5791
5792 @item unused
5793 When attached to a type (including a @code{union} or a @code{struct}),
5794 this attribute means that variables of that type are meant to appear
5795 possibly unused. GCC does not produce a warning for any variables of
5796 that type, even if the variable appears to do nothing. This is often
5797 the case with lock or thread classes, which are usually defined and then
5798 not referenced, but contain constructors and destructors that have
5799 nontrivial bookkeeping functions.
5800
5801 @item deprecated
5802 @itemx deprecated (@var{msg})
5803 The @code{deprecated} attribute results in a warning if the type
5804 is used anywhere in the source file. This is useful when identifying
5805 types that are expected to be removed in a future version of a program.
5806 If possible, the warning also includes the location of the declaration
5807 of the deprecated type, to enable users to easily find further
5808 information about why the type is deprecated, or what they should do
5809 instead. Note that the warnings only occur for uses and then only
5810 if the type is being applied to an identifier that itself is not being
5811 declared as deprecated.
5812
5813 @smallexample
5814 typedef int T1 __attribute__ ((deprecated));
5815 T1 x;
5816 typedef T1 T2;
5817 T2 y;
5818 typedef T1 T3 __attribute__ ((deprecated));
5819 T3 z __attribute__ ((deprecated));
5820 @end smallexample
5821
5822 @noindent
5823 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
5824 warning is issued for line 4 because T2 is not explicitly
5825 deprecated. Line 5 has no warning because T3 is explicitly
5826 deprecated. Similarly for line 6. The optional @var{msg}
5827 argument, which must be a string, is printed in the warning if
5828 present.
5829
5830 The @code{deprecated} attribute can also be used for functions and
5831 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5832
5833 @item may_alias
5834 Accesses through pointers to types with this attribute are not subject
5835 to type-based alias analysis, but are instead assumed to be able to alias
5836 any other type of objects.
5837 In the context of section 6.5 paragraph 7 of the C99 standard,
5838 an lvalue expression
5839 dereferencing such a pointer is treated like having a character type.
5840 See @option{-fstrict-aliasing} for more information on aliasing issues.
5841 This extension exists to support some vector APIs, in which pointers to
5842 one vector type are permitted to alias pointers to a different vector type.
5843
5844 Note that an object of a type with this attribute does not have any
5845 special semantics.
5846
5847 Example of use:
5848
5849 @smallexample
5850 typedef short __attribute__((__may_alias__)) short_a;
5851
5852 int
5853 main (void)
5854 @{
5855 int a = 0x12345678;
5856 short_a *b = (short_a *) &a;
5857
5858 b[1] = 0;
5859
5860 if (a == 0x12345678)
5861 abort();
5862
5863 exit(0);
5864 @}
5865 @end smallexample
5866
5867 @noindent
5868 If you replaced @code{short_a} with @code{short} in the variable
5869 declaration, the above program would abort when compiled with
5870 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5871 above in recent GCC versions.
5872
5873 @item visibility
5874 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5875 applied to class, struct, union and enum types. Unlike other type
5876 attributes, the attribute must appear between the initial keyword and
5877 the name of the type; it cannot appear after the body of the type.
5878
5879 Note that the type visibility is applied to vague linkage entities
5880 associated with the class (vtable, typeinfo node, etc.). In
5881 particular, if a class is thrown as an exception in one shared object
5882 and caught in another, the class must have default visibility.
5883 Otherwise the two shared objects are unable to use the same
5884 typeinfo node and exception handling will break.
5885
5886 @end table
5887
5888 To specify multiple attributes, separate them by commas within the
5889 double parentheses: for example, @samp{__attribute__ ((aligned (16),
5890 packed))}.
5891
5892 @subsection ARM Type Attributes
5893
5894 On those ARM targets that support @code{dllimport} (such as Symbian
5895 OS), you can use the @code{notshared} attribute to indicate that the
5896 virtual table and other similar data for a class should not be
5897 exported from a DLL@. For example:
5898
5899 @smallexample
5900 class __declspec(notshared) C @{
5901 public:
5902 __declspec(dllimport) C();
5903 virtual void f();
5904 @}
5905
5906 __declspec(dllexport)
5907 C::C() @{@}
5908 @end smallexample
5909
5910 @noindent
5911 In this code, @code{C::C} is exported from the current DLL, but the
5912 virtual table for @code{C} is not exported. (You can use
5913 @code{__attribute__} instead of @code{__declspec} if you prefer, but
5914 most Symbian OS code uses @code{__declspec}.)
5915
5916 @anchor{MeP Type Attributes}
5917 @subsection MeP Type Attributes
5918
5919 Many of the MeP variable attributes may be applied to types as well.
5920 Specifically, the @code{based}, @code{tiny}, @code{near}, and
5921 @code{far} attributes may be applied to either. The @code{io} and
5922 @code{cb} attributes may not be applied to types.
5923
5924 @anchor{i386 Type Attributes}
5925 @subsection i386 Type Attributes
5926
5927 Two attributes are currently defined for i386 configurations:
5928 @code{ms_struct} and @code{gcc_struct}.
5929
5930 @table @code
5931
5932 @item ms_struct
5933 @itemx gcc_struct
5934 @cindex @code{ms_struct}
5935 @cindex @code{gcc_struct}
5936
5937 If @code{packed} is used on a structure, or if bit-fields are used
5938 it may be that the Microsoft ABI packs them differently
5939 than GCC normally packs them. Particularly when moving packed
5940 data between functions compiled with GCC and the native Microsoft compiler
5941 (either via function call or as data in a file), it may be necessary to access
5942 either format.
5943
5944 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5945 compilers to match the native Microsoft compiler.
5946 @end table
5947
5948 @anchor{PowerPC Type Attributes}
5949 @subsection PowerPC Type Attributes
5950
5951 Three attributes currently are defined for PowerPC configurations:
5952 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5953
5954 For full documentation of the @code{ms_struct} and @code{gcc_struct}
5955 attributes please see the documentation in @ref{i386 Type Attributes}.
5956
5957 The @code{altivec} attribute allows one to declare AltiVec vector data
5958 types supported by the AltiVec Programming Interface Manual. The
5959 attribute requires an argument to specify one of three vector types:
5960 @code{vector__}, @code{pixel__} (always followed by unsigned short),
5961 and @code{bool__} (always followed by unsigned).
5962
5963 @smallexample
5964 __attribute__((altivec(vector__)))
5965 __attribute__((altivec(pixel__))) unsigned short
5966 __attribute__((altivec(bool__))) unsigned
5967 @end smallexample
5968
5969 These attributes mainly are intended to support the @code{__vector},
5970 @code{__pixel}, and @code{__bool} AltiVec keywords.
5971
5972 @anchor{SPU Type Attributes}
5973 @subsection SPU Type Attributes
5974
5975 The SPU supports the @code{spu_vector} attribute for types. This attribute
5976 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
5977 Language Extensions Specification. It is intended to support the
5978 @code{__vector} keyword.
5979
5980 @node Alignment
5981 @section Inquiring on Alignment of Types or Variables
5982 @cindex alignment
5983 @cindex type alignment
5984 @cindex variable alignment
5985
5986 The keyword @code{__alignof__} allows you to inquire about how an object
5987 is aligned, or the minimum alignment usually required by a type. Its
5988 syntax is just like @code{sizeof}.
5989
5990 For example, if the target machine requires a @code{double} value to be
5991 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
5992 This is true on many RISC machines. On more traditional machine
5993 designs, @code{__alignof__ (double)} is 4 or even 2.
5994
5995 Some machines never actually require alignment; they allow reference to any
5996 data type even at an odd address. For these machines, @code{__alignof__}
5997 reports the smallest alignment that GCC gives the data type, usually as
5998 mandated by the target ABI.
5999
6000 If the operand of @code{__alignof__} is an lvalue rather than a type,
6001 its value is the required alignment for its type, taking into account
6002 any minimum alignment specified with GCC's @code{__attribute__}
6003 extension (@pxref{Variable Attributes}). For example, after this
6004 declaration:
6005
6006 @smallexample
6007 struct foo @{ int x; char y; @} foo1;
6008 @end smallexample
6009
6010 @noindent
6011 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6012 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6013
6014 It is an error to ask for the alignment of an incomplete type.
6015
6016
6017 @node Inline
6018 @section An Inline Function is As Fast As a Macro
6019 @cindex inline functions
6020 @cindex integrating function code
6021 @cindex open coding
6022 @cindex macros, inline alternative
6023
6024 By declaring a function inline, you can direct GCC to make
6025 calls to that function faster. One way GCC can achieve this is to
6026 integrate that function's code into the code for its callers. This
6027 makes execution faster by eliminating the function-call overhead; in
6028 addition, if any of the actual argument values are constant, their
6029 known values may permit simplifications at compile time so that not
6030 all of the inline function's code needs to be included. The effect on
6031 code size is less predictable; object code may be larger or smaller
6032 with function inlining, depending on the particular case. You can
6033 also direct GCC to try to integrate all ``simple enough'' functions
6034 into their callers with the option @option{-finline-functions}.
6035
6036 GCC implements three different semantics of declaring a function
6037 inline. One is available with @option{-std=gnu89} or
6038 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6039 on all inline declarations, another when
6040 @option{-std=c99}, @option{-std=c11},
6041 @option{-std=gnu99} or @option{-std=gnu11}
6042 (without @option{-fgnu89-inline}), and the third
6043 is used when compiling C++.
6044
6045 To declare a function inline, use the @code{inline} keyword in its
6046 declaration, like this:
6047
6048 @smallexample
6049 static inline int
6050 inc (int *a)
6051 @{
6052 return (*a)++;
6053 @}
6054 @end smallexample
6055
6056 If you are writing a header file to be included in ISO C90 programs, write
6057 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
6058
6059 The three types of inlining behave similarly in two important cases:
6060 when the @code{inline} keyword is used on a @code{static} function,
6061 like the example above, and when a function is first declared without
6062 using the @code{inline} keyword and then is defined with
6063 @code{inline}, like this:
6064
6065 @smallexample
6066 extern int inc (int *a);
6067 inline int
6068 inc (int *a)
6069 @{
6070 return (*a)++;
6071 @}
6072 @end smallexample
6073
6074 In both of these common cases, the program behaves the same as if you
6075 had not used the @code{inline} keyword, except for its speed.
6076
6077 @cindex inline functions, omission of
6078 @opindex fkeep-inline-functions
6079 When a function is both inline and @code{static}, if all calls to the
6080 function are integrated into the caller, and the function's address is
6081 never used, then the function's own assembler code is never referenced.
6082 In this case, GCC does not actually output assembler code for the
6083 function, unless you specify the option @option{-fkeep-inline-functions}.
6084 Some calls cannot be integrated for various reasons (in particular,
6085 calls that precede the function's definition cannot be integrated, and
6086 neither can recursive calls within the definition). If there is a
6087 nonintegrated call, then the function is compiled to assembler code as
6088 usual. The function must also be compiled as usual if the program
6089 refers to its address, because that can't be inlined.
6090
6091 @opindex Winline
6092 Note that certain usages in a function definition can make it unsuitable
6093 for inline substitution. Among these usages are: variadic functions, use of
6094 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6095 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6096 and nested functions (@pxref{Nested Functions}). Using @option{-Winline}
6097 warns when a function marked @code{inline} could not be substituted,
6098 and gives the reason for the failure.
6099
6100 @cindex automatic @code{inline} for C++ member fns
6101 @cindex @code{inline} automatic for C++ member fns
6102 @cindex member fns, automatically @code{inline}
6103 @cindex C++ member fns, automatically @code{inline}
6104 @opindex fno-default-inline
6105 As required by ISO C++, GCC considers member functions defined within
6106 the body of a class to be marked inline even if they are
6107 not explicitly declared with the @code{inline} keyword. You can
6108 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6109 Options,,Options Controlling C++ Dialect}.
6110
6111 GCC does not inline any functions when not optimizing unless you specify
6112 the @samp{always_inline} attribute for the function, like this:
6113
6114 @smallexample
6115 /* @r{Prototype.} */
6116 inline void foo (const char) __attribute__((always_inline));
6117 @end smallexample
6118
6119 The remainder of this section is specific to GNU C90 inlining.
6120
6121 @cindex non-static inline function
6122 When an inline function is not @code{static}, then the compiler must assume
6123 that there may be calls from other source files; since a global symbol can
6124 be defined only once in any program, the function must not be defined in
6125 the other source files, so the calls therein cannot be integrated.
6126 Therefore, a non-@code{static} inline function is always compiled on its
6127 own in the usual fashion.
6128
6129 If you specify both @code{inline} and @code{extern} in the function
6130 definition, then the definition is used only for inlining. In no case
6131 is the function compiled on its own, not even if you refer to its
6132 address explicitly. Such an address becomes an external reference, as
6133 if you had only declared the function, and had not defined it.
6134
6135 This combination of @code{inline} and @code{extern} has almost the
6136 effect of a macro. The way to use it is to put a function definition in
6137 a header file with these keywords, and put another copy of the
6138 definition (lacking @code{inline} and @code{extern}) in a library file.
6139 The definition in the header file causes most calls to the function
6140 to be inlined. If any uses of the function remain, they refer to
6141 the single copy in the library.
6142
6143 @node Volatiles
6144 @section When is a Volatile Object Accessed?
6145 @cindex accessing volatiles
6146 @cindex volatile read
6147 @cindex volatile write
6148 @cindex volatile access
6149
6150 C has the concept of volatile objects. These are normally accessed by
6151 pointers and used for accessing hardware or inter-thread
6152 communication. The standard encourages compilers to refrain from
6153 optimizations concerning accesses to volatile objects, but leaves it
6154 implementation defined as to what constitutes a volatile access. The
6155 minimum requirement is that at a sequence point all previous accesses
6156 to volatile objects have stabilized and no subsequent accesses have
6157 occurred. Thus an implementation is free to reorder and combine
6158 volatile accesses that occur between sequence points, but cannot do
6159 so for accesses across a sequence point. The use of volatile does
6160 not allow you to violate the restriction on updating objects multiple
6161 times between two sequence points.
6162
6163 Accesses to non-volatile objects are not ordered with respect to
6164 volatile accesses. You cannot use a volatile object as a memory
6165 barrier to order a sequence of writes to non-volatile memory. For
6166 instance:
6167
6168 @smallexample
6169 int *ptr = @var{something};
6170 volatile int vobj;
6171 *ptr = @var{something};
6172 vobj = 1;
6173 @end smallexample
6174
6175 @noindent
6176 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6177 that the write to @var{*ptr} occurs by the time the update
6178 of @var{vobj} happens. If you need this guarantee, you must use
6179 a stronger memory barrier such as:
6180
6181 @smallexample
6182 int *ptr = @var{something};
6183 volatile int vobj;
6184 *ptr = @var{something};
6185 asm volatile ("" : : : "memory");
6186 vobj = 1;
6187 @end smallexample
6188
6189 A scalar volatile object is read when it is accessed in a void context:
6190
6191 @smallexample
6192 volatile int *src = @var{somevalue};
6193 *src;
6194 @end smallexample
6195
6196 Such expressions are rvalues, and GCC implements this as a
6197 read of the volatile object being pointed to.
6198
6199 Assignments are also expressions and have an rvalue. However when
6200 assigning to a scalar volatile, the volatile object is not reread,
6201 regardless of whether the assignment expression's rvalue is used or
6202 not. If the assignment's rvalue is used, the value is that assigned
6203 to the volatile object. For instance, there is no read of @var{vobj}
6204 in all the following cases:
6205
6206 @smallexample
6207 int obj;
6208 volatile int vobj;
6209 vobj = @var{something};
6210 obj = vobj = @var{something};
6211 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6212 obj = (@var{something}, vobj = @var{anotherthing});
6213 @end smallexample
6214
6215 If you need to read the volatile object after an assignment has
6216 occurred, you must use a separate expression with an intervening
6217 sequence point.
6218
6219 As bit-fields are not individually addressable, volatile bit-fields may
6220 be implicitly read when written to, or when adjacent bit-fields are
6221 accessed. Bit-field operations may be optimized such that adjacent
6222 bit-fields are only partially accessed, if they straddle a storage unit
6223 boundary. For these reasons it is unwise to use volatile bit-fields to
6224 access hardware.
6225
6226 @node Using Assembly Language with C
6227 @section How to Use Inline Assembly Language in C Code
6228
6229 GCC provides various extensions that allow you to embed assembler within
6230 C code.
6231
6232 @menu
6233 * Basic Asm:: Inline assembler with no operands.
6234 * Extended Asm:: Inline assembler with operands.
6235 * Constraints:: Constraints for @code{asm} operands
6236 * Asm Labels:: Specifying the assembler name to use for a C symbol.
6237 * Explicit Reg Vars:: Defining variables residing in specified registers.
6238 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
6239 @end menu
6240
6241 @node Basic Asm
6242 @subsection Basic Asm --- Assembler Instructions with No Operands
6243 @cindex basic @code{asm}
6244
6245 The @code{asm} keyword allows you to embed assembler instructions within
6246 C code.
6247
6248 @example
6249 asm [ volatile ] ( AssemblerInstructions )
6250 @end example
6251
6252 To create headers compatible with ISO C, write @code{__asm__} instead of
6253 @code{asm} (@pxref{Alternate Keywords}).
6254
6255 By definition, a Basic @code{asm} statement is one with no operands.
6256 @code{asm} statements that contain one or more colons (used to delineate
6257 operands) are considered to be Extended (for example, @code{asm("int $3")}
6258 is Basic, and @code{asm("int $3" : )} is Extended). @xref{Extended Asm}.
6259
6260 @subsubheading Qualifiers
6261 @emph{volatile}
6262 @*
6263 This optional qualifier has no effect. All Basic @code{asm} blocks are
6264 implicitly volatile.
6265
6266 @subsubheading Parameters
6267 @emph{AssemblerInstructions}
6268 @*
6269 This is a literal string that specifies the assembler code. The string can
6270 contain any instructions recognized by the assembler, including directives.
6271 GCC does not parse the assembler instructions themselves and
6272 does not know what they mean or even whether they are valid assembler input.
6273 The compiler copies it verbatim to the assembly language output file, without
6274 processing dialects or any of the "%" operators that are available with
6275 Extended @code{asm}. This results in minor differences between Basic
6276 @code{asm} strings and Extended @code{asm} templates. For example, to refer to
6277 registers you might use %%eax in Extended @code{asm} and %eax in Basic
6278 @code{asm}.
6279
6280 You may place multiple assembler instructions together in a single @code{asm}
6281 string, separated by the characters normally used in assembly code for the
6282 system. A combination that works in most places is a newline to break the
6283 line, plus a tab character (written as "\n\t").
6284 Some assemblers allow semicolons as a line separator. However,
6285 note that some assembler dialects use semicolons to start a comment.
6286
6287 Do not expect a sequence of @code{asm} statements to remain perfectly
6288 consecutive after compilation. If certain instructions need to remain
6289 consecutive in the output, put them in a single multi-instruction asm
6290 statement. Note that GCC's optimizers can move @code{asm} statements
6291 relative to other code, including across jumps.
6292
6293 @code{asm} statements may not perform jumps into other @code{asm} statements.
6294 GCC does not know about these jumps, and therefore cannot take
6295 account of them when deciding how to optimize. Jumps from @code{asm} to C
6296 labels are only supported in Extended @code{asm}.
6297
6298 @subsubheading Remarks
6299 Using Extended @code{asm} will typically produce smaller, safer, and more
6300 efficient code, and in most cases it is a better solution. When writing
6301 inline assembly language outside of C functions, however, you must use Basic
6302 @code{asm}. Extended @code{asm} statements have to be inside a C function.
6303
6304 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
6305 assembly code when optimizing. This can lead to unexpected duplicate
6306 symbol errors during compilation if your assembly code defines symbols or
6307 labels.
6308
6309 Safely accessing C data and calling functions from Basic @code{asm} is more
6310 complex than it may appear. To access C data, it is better to use Extended
6311 @code{asm}.
6312
6313 Since GCC does not parse the AssemblerInstructions, it has no
6314 visibility of any symbols it references. This may result in GCC discarding
6315 those symbols as unreferenced.
6316
6317 Unlike Extended @code{asm}, all Basic @code{asm} blocks are implicitly
6318 volatile. @xref{Volatile}. Similarly, Basic @code{asm} blocks are not treated
6319 as though they used a "memory" clobber (@pxref{Clobbers}).
6320
6321 All Basic @code{asm} blocks use the assembler dialect specified by the
6322 @option{-masm} command-line option. Basic @code{asm} provides no
6323 mechanism to provide different assembler strings for different dialects.
6324
6325 Here is an example of Basic @code{asm} for i386:
6326
6327 @example
6328 /* Note that this code will not compile with -masm=intel */
6329 #define DebugBreak() asm("int $3")
6330 @end example
6331
6332 @node Extended Asm
6333 @subsection Extended Asm - Assembler Instructions with C Expression Operands
6334 @cindex @code{asm} keyword
6335 @cindex extended @code{asm}
6336 @cindex assembler instructions
6337
6338 The @code{asm} keyword allows you to embed assembler instructions within C
6339 code. With Extended @code{asm} you can read and write C variables from
6340 assembler and perform jumps from assembler code to C labels.
6341
6342 @example
6343 @ifhtml
6344 asm [volatile] ( AssemblerTemplate : [OutputOperands] [ : [InputOperands] [ : [Clobbers] ] ] )
6345
6346 asm [volatile] goto ( AssemblerTemplate : : [InputOperands] : [Clobbers] : GotoLabels )
6347 @end ifhtml
6348 @ifnothtml
6349 asm [volatile] ( AssemblerTemplate
6350 : [OutputOperands]
6351 [ : [InputOperands]
6352 [ : [Clobbers] ] ])
6353
6354 asm [volatile] goto ( AssemblerTemplate
6355 :
6356 : [InputOperands]
6357 : [Clobbers]
6358 : GotoLabels)
6359 @end ifnothtml
6360 @end example
6361
6362 To create headers compatible with ISO C, write @code{__asm__} instead of
6363 @code{asm} and @code{__volatile__} instead of @code{volatile}
6364 (@pxref{Alternate Keywords}). There is no alternate for @code{goto}.
6365
6366 By definition, Extended @code{asm} is an @code{asm} statement that contains
6367 operands. To separate the classes of operands, you use colons. Basic
6368 @code{asm} statements contain no colons. (So, for example,
6369 @code{asm("int $3")} is Basic @code{asm}, and @code{asm("int $3" : )} is
6370 Extended @code{asm}. @pxref{Basic Asm}.)
6371
6372 @subsubheading Qualifiers
6373 @emph{volatile}
6374 @*
6375 The typical use of Extended @code{asm} statements is to manipulate input
6376 values to produce output values. However, your @code{asm} statements may
6377 also produce side effects. If so, you may need to use the @code{volatile}
6378 qualifier to disable certain optimizations. @xref{Volatile}.
6379
6380 @emph{goto}
6381 @*
6382 This qualifier informs the compiler that the @code{asm} statement may
6383 perform a jump to one of the labels listed in the GotoLabels section.
6384 @xref{GotoLabels}.
6385
6386 @subsubheading Parameters
6387 @emph{AssemblerTemplate}
6388 @*
6389 This is a literal string that contains the assembler code. It is a
6390 combination of fixed text and tokens that refer to the input, output,
6391 and goto parameters. @xref{AssemblerTemplate}.
6392
6393 @emph{OutputOperands}
6394 @*
6395 A comma-separated list of the C variables modified by the instructions in the
6396 AssemblerTemplate. @xref{OutputOperands}.
6397
6398 @emph{InputOperands}
6399 @*
6400 A comma-separated list of C expressions read by the instructions in the
6401 AssemblerTemplate. @xref{InputOperands}.
6402
6403 @emph{Clobbers}
6404 @*
6405 A comma-separated list of registers or other values changed by the
6406 AssemblerTemplate, beyond those listed as outputs. @xref{Clobbers}.
6407
6408 @emph{GotoLabels}
6409 @*
6410 When you are using the @code{goto} form of @code{asm}, this section contains
6411 the list of all C labels to which the AssemblerTemplate may jump.
6412 @xref{GotoLabels}.
6413
6414 @subsubheading Remarks
6415 The @code{asm} statement allows you to include assembly instructions directly
6416 within C code. This may help you to maximize performance in time-sensitive
6417 code or to access assembly instructions that are not readily available to C
6418 programs.
6419
6420 Note that Extended @code{asm} statements must be inside a function. Only
6421 Basic @code{asm} may be outside functions (@pxref{Basic Asm}).
6422
6423 While the uses of @code{asm} are many and varied, it may help to think of an
6424 @code{asm} statement as a series of low-level instructions that convert input
6425 parameters to output parameters. So a simple (if not particularly useful)
6426 example for i386 using @code{asm} might look like this:
6427
6428 @example
6429 int src = 1;
6430 int dst;
6431
6432 asm ("mov %1, %0\n\t"
6433 "add $1, %0"
6434 : "=r" (dst)
6435 : "r" (src));
6436
6437 printf("%d\n", dst);
6438 @end example
6439
6440 This code will copy @var{src} to @var{dst} and add 1 to @var{dst}.
6441
6442 @anchor{Volatile}
6443 @subsubsection Volatile
6444 @cindex volatile @code{asm}
6445 @cindex @code{asm} volatile
6446
6447 GCC's optimizers sometimes discard @code{asm} statements if they determine
6448 there is no need for the output variables. Also, the optimizers may move
6449 code out of loops if they believe that the code will always return the same
6450 result (i.e. none of its input values change between calls). Using the
6451 @code{volatile} qualifier disables these optimizations. @code{asm} statements
6452 that have no output operands are implicitly volatile.
6453
6454 Examples:
6455
6456 This i386 code demonstrates a case that does not use (or require) the
6457 @code{volatile} qualifier. If it is performing assertion checking, this code
6458 uses @code{asm} to perform the validation. Otherwise, @var{dwRes} is
6459 unreferenced by any code. As a result, the optimizers can discard the
6460 @code{asm} statement, which in turn removes the need for the entire
6461 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
6462 isn't needed you allow the optimizers to produce the most efficient code
6463 possible.
6464
6465 @example
6466 void DoCheck(uint32_t dwSomeValue)
6467 @{
6468 uint32_t dwRes;
6469
6470 // Assumes dwSomeValue is not zero.
6471 asm ("bsfl %1,%0"
6472 : "=r" (dwRes)
6473 : "r" (dwSomeValue)
6474 : "cc");
6475
6476 assert(dwRes > 3);
6477 @}
6478 @end example
6479
6480 The next example shows a case where the optimizers can recognize that the input
6481 (@var{dwSomeValue}) never changes during the execution of the function and can
6482 therefore move the @code{asm} outside the loop to produce more efficient code.
6483 Again, using @code{volatile} disables this type of optimization.
6484
6485 @example
6486 void do_print(uint32_t dwSomeValue)
6487 @{
6488 uint32_t dwRes;
6489
6490 for (uint32_t x=0; x < 5; x++)
6491 @{
6492 // Assumes dwSomeValue is not zero.
6493 asm ("bsfl %1,%0"
6494 : "=r" (dwRes)
6495 : "r" (dwSomeValue)
6496 : "cc");
6497
6498 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
6499 @}
6500 @}
6501 @end example
6502
6503 The following example demonstrates a case where you need to use the
6504 @code{volatile} qualifier. It uses the i386 RDTSC instruction, which reads
6505 the computer's time-stamp counter. Without the @code{volatile} qualifier,
6506 the optimizers might assume that the @code{asm} block will always return the
6507 same value and therefore optimize away the second call.
6508
6509 @example
6510 uint64_t msr;
6511
6512 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
6513 "shl $32, %%rdx\n\t" // Shift the upper bits left.
6514 "or %%rdx, %0" // 'Or' in the lower bits.
6515 : "=a" (msr)
6516 :
6517 : "rdx");
6518
6519 printf("msr: %llx\n", msr);
6520
6521 // Do other work...
6522
6523 // Reprint the timestamp
6524 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
6525 "shl $32, %%rdx\n\t" // Shift the upper bits left.
6526 "or %%rdx, %0" // 'Or' in the lower bits.
6527 : "=a" (msr)
6528 :
6529 : "rdx");
6530
6531 printf("msr: %llx\n", msr);
6532 @end example
6533
6534 GCC's optimizers will not treat this code like the non-volatile code in the
6535 earlier examples. They do not move it out of loops or omit it on the
6536 assumption that the result from a previous call is still valid.
6537
6538 Note that the compiler can move even volatile @code{asm} instructions relative
6539 to other code, including across jump instructions. For example, on many
6540 targets there is a system register that controls the rounding mode of
6541 floating-point operations. Setting it with a volatile @code{asm}, as in the
6542 following PowerPC example, will not work reliably.
6543
6544 @example
6545 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
6546 sum = x + y;
6547 @end example
6548
6549 The compiler may move the addition back before the volatile @code{asm}. To
6550 make it work as expected, add an artificial dependency to the @code{asm} by
6551 referencing a variable in the subsequent code, for example:
6552
6553 @example
6554 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
6555 sum = x + y;
6556 @end example
6557
6558 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
6559 assembly code when optimizing. This can lead to unexpected duplicate symbol
6560 errors during compilation if your asm code defines symbols or labels. Using %=
6561 (@pxref{AssemblerTemplate}) may help resolve this problem.
6562
6563 @anchor{AssemblerTemplate}
6564 @subsubsection Assembler Template
6565 @cindex @code{asm} assembler template
6566
6567 An assembler template is a literal string containing assembler instructions.
6568 The compiler will replace any references to inputs, outputs, and goto labels
6569 in the template, and then output the resulting string to the assembler. The
6570 string can contain any instructions recognized by the assembler, including
6571 directives. GCC does not parse the assembler instructions
6572 themselves and does not know what they mean or even whether they are valid
6573 assembler input. However, it does count the statements
6574 (@pxref{Size of an asm}).
6575
6576 You may place multiple assembler instructions together in a single @code{asm}
6577 string, separated by the characters normally used in assembly code for the
6578 system. A combination that works in most places is a newline to break the
6579 line, plus a tab character to move to the instruction field (written as
6580 "\n\t"). Some assemblers allow semicolons as a line separator. However, note
6581 that some assembler dialects use semicolons to start a comment.
6582
6583 Do not expect a sequence of @code{asm} statements to remain perfectly
6584 consecutive after compilation, even when you are using the @code{volatile}
6585 qualifier. If certain instructions need to remain consecutive in the output,
6586 put them in a single multi-instruction asm statement.
6587
6588 Accessing data from C programs without using input/output operands (such as
6589 by using global symbols directly from the assembler template) may not work as
6590 expected. Similarly, calling functions directly from an assembler template
6591 requires a detailed understanding of the target assembler and ABI.
6592
6593 Since GCC does not parse the AssemblerTemplate, it has no visibility of any
6594 symbols it references. This may result in GCC discarding those symbols as
6595 unreferenced unless they are also listed as input, output, or goto operands.
6596
6597 GCC can support multiple assembler dialects (for example, GCC for i386
6598 supports "att" and "intel" dialects) for inline assembler. In builds that
6599 support this capability, the @option{-masm} option controls which dialect
6600 GCC uses as its default. The hardware-specific documentation for the
6601 @option{-masm} option contains the list of supported dialects, as well as the
6602 default dialect if the option is not specified. This information may be
6603 important to understand, since assembler code that works correctly when
6604 compiled using one dialect will likely fail if compiled using another.
6605
6606 @subsubheading Using braces in @code{asm} templates
6607
6608 If your code needs to support multiple assembler dialects (for example, if
6609 you are writing public headers that need to support a variety of compilation
6610 options), use constructs of this form:
6611
6612 @example
6613 @{ dialect0 | dialect1 | dialect2... @}
6614 @end example
6615
6616 This construct outputs 'dialect0' when using dialect #0 to compile the code,
6617 'dialect1' for dialect #1, etc. If there are fewer alternatives within the
6618 braces than the number of dialects the compiler supports, the construct
6619 outputs nothing.
6620
6621 For example, if an i386 compiler supports two dialects (att, intel), an
6622 assembler template such as this:
6623
6624 @example
6625 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
6626 @end example
6627
6628 would produce the output:
6629
6630 @example
6631 For att: "btl %[Offset],%[Base] ; jc %l2"
6632 For intel: "bt %[Base],%[Offset]; jc %l2"
6633 @end example
6634
6635 Using that same compiler, this code:
6636
6637 @example
6638 "xchg@{l@}\t@{%%@}ebx, %1"
6639 @end example
6640
6641 would produce
6642
6643 @example
6644 For att: "xchgl\t%%ebx, %1"
6645 For intel: "xchg\tebx, %1"
6646 @end example
6647
6648 There is no support for nesting dialect alternatives. Also, there is no
6649 ``escape'' for an open brace (@{), so do not use open braces in an Extended
6650 @code{asm} template other than as a dialect indicator.
6651
6652 @subsubheading Other format strings
6653
6654 In addition to the tokens described by the input, output, and goto operands,
6655 there are a few special cases:
6656
6657 @itemize
6658 @item
6659 "%%" outputs a single "%" into the assembler code.
6660
6661 @item
6662 "%=" outputs a number that is unique to each instance of the @code{asm}
6663 statement in the entire compilation. This option is useful when creating local
6664 labels and referring to them multiple times in a single template that
6665 generates multiple assembler instructions.
6666
6667 @end itemize
6668
6669 @anchor{OutputOperands}
6670 @subsubsection Output Operands
6671 @cindex @code{asm} output operands
6672
6673 An @code{asm} statement has zero or more output operands indicating the names
6674 of C variables modified by the assembler code.
6675
6676 In this i386 example, @var{old} (referred to in the template string as
6677 @code{%0}) and @var{*Base} (as @code{%1}) are outputs and @var{Offset}
6678 (@code{%2}) is an input:
6679
6680 @example
6681 bool old;
6682
6683 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
6684 "sbb %0,%0" // Use the CF to calculate old.
6685 : "=r" (old), "+rm" (*Base)
6686 : "Ir" (Offset)
6687 : "cc");
6688
6689 return old;
6690 @end example
6691
6692 Operands use this format:
6693
6694 @example
6695 [ [asmSymbolicName] ] "constraint" (cvariablename)
6696 @end example
6697
6698 @emph{asmSymbolicName}
6699 @*
6700
6701 When not using asmSymbolicNames, use the (zero-based) position of the operand
6702 in the list of operands in the assembler template. For example if there are
6703 three output operands, use @code{%0} in the template to refer to the first,
6704 @code{%1} for the second, and @code{%2} for the third. When using an
6705 asmSymbolicName, reference it by enclosing the name in square brackets
6706 (i.e. @code{%[Value]}). The scope of the name is the @code{asm} statement
6707 that contains the definition. Any valid C variable name is acceptable,
6708 including names already defined in the surrounding code. No two operands
6709 within the same @code{asm} statement can use the same symbolic name.
6710
6711 @emph{constraint}
6712 @*
6713 Output constraints must begin with either @code{"="} (a variable overwriting an
6714 existing value) or @code{"+"} (when reading and writing). When using
6715 @code{"="}, do not assume the location will contain the existing value (except
6716 when tying the variable to an input; @pxref{InputOperands,,Input Operands}).
6717
6718 After the prefix, there must be one or more additional constraints
6719 (@pxref{Constraints}) that describe where the value resides. Common
6720 constraints include @code{"r"} for register and @code{"m"} for memory.
6721 When you list more than one possible location (for example @code{"=rm"}), the
6722 compiler chooses the most efficient one based on the current context. If you
6723 list as many alternates as the @code{asm} statement allows, you will permit
6724 the optimizers to produce the best possible code. If you must use a specific
6725 register, but your Machine Constraints do not provide sufficient
6726 control to select the specific register you want, Local Reg Vars may provide
6727 a solution (@pxref{Local Reg Vars}).
6728
6729 @emph{cvariablename}
6730 @*
6731 Specifies the C variable name of the output (enclosed by parentheses). Accepts
6732 any (non-constant) variable within scope.
6733
6734 Remarks:
6735
6736 The total number of input + output + goto operands has a limit of 30. Commas
6737 separate the operands. When the compiler selects the registers to use to
6738 represent the output operands, it will not use any of the clobbered registers
6739 (@pxref{Clobbers}).
6740
6741 Output operand expressions must be lvalues. The compiler cannot check whether
6742 the operands have data types that are reasonable for the instruction being
6743 executed. For output expressions that are not directly addressable (for
6744 example a bit-field), the constraint must allow a register. In that case, GCC
6745 uses the register as the output of the @code{asm}, and then stores that
6746 register into the output.
6747
6748 Unless an output operand has the '@code{&}' constraint modifier
6749 (@pxref{Modifiers}), GCC may allocate it in the same register as an unrelated
6750 input operand, on the assumption that the assembler code will consume its
6751 inputs before producing outputs. This assumption may be false if the assembler
6752 code actually consists of more than one instruction. In this case, use
6753 '@code{&}' on each output operand that must not overlap an input.
6754
6755 The same problem can occur if one output parameter (@var{a}) allows a register
6756 constraint and another output parameter (@var{b}) allows a memory constraint.
6757 The code generated by GCC to access the memory address in @var{b} can contain
6758 registers which @emph{might} be shared by @var{a}, and GCC considers those
6759 registers to be inputs to the asm. As above, GCC assumes that such input
6760 registers are consumed before any outputs are written. This assumption may
6761 result in incorrect behavior if the asm writes to @var{a} before using
6762 @var{b}. Combining the `@code{&}' constraint with the register constraint
6763 ensures that modifying @var{a} will not affect what address is referenced by
6764 @var{b}. Omitting the `@code{&}' constraint means that the location of @var{b}
6765 will be undefined if @var{a} is modified before using @var{b}.
6766
6767 @code{asm} supports operand modifiers on operands (for example @code{%k2}
6768 instead of simply @code{%2}). Typically these qualifiers are hardware
6769 dependent. The list of supported modifiers for i386 is found at
6770 @ref{i386Operandmodifiers,i386 Operand modifiers}.
6771
6772 If the C code that follows the @code{asm} makes no use of any of the output
6773 operands, use @code{volatile} for the @code{asm} statement to prevent the
6774 optimizers from discarding the @code{asm} statement as unneeded
6775 (see @ref{Volatile}).
6776
6777 Examples:
6778
6779 This code makes no use of the optional asmSymbolicName. Therefore it
6780 references the first output operand as @code{%0} (were there a second, it
6781 would be @code{%1}, etc). The number of the first input operand is one greater
6782 than that of the last output operand. In this i386 example, that makes
6783 @var{Mask} @code{%1}:
6784
6785 @example
6786 uint32_t Mask = 1234;
6787 uint32_t Index;
6788
6789 asm ("bsfl %1, %0"
6790 : "=r" (Index)
6791 : "r" (Mask)
6792 : "cc");
6793 @end example
6794
6795 That code overwrites the variable Index ("="), placing the value in a register
6796 ("r"). The generic "r" constraint instead of a constraint for a specific
6797 register allows the compiler to pick the register to use, which can result
6798 in more efficient code. This may not be possible if an assembler instruction
6799 requires a specific register.
6800
6801 The following i386 example uses the asmSymbolicName operand. It produces the
6802 same result as the code above, but some may consider it more readable or more
6803 maintainable since reordering index numbers is not necessary when adding or
6804 removing operands. The names aIndex and aMask are only used to emphasize which
6805 names get used where. It is acceptable to reuse the names Index and Mask.
6806
6807 @example
6808 uint32_t Mask = 1234;
6809 uint32_t Index;
6810
6811 asm ("bsfl %[aMask], %[aIndex]"
6812 : [aIndex] "=r" (Index)
6813 : [aMask] "r" (Mask)
6814 : "cc");
6815 @end example
6816
6817 Here are some more examples of output operands.
6818
6819 @example
6820 uint32_t c = 1;
6821 uint32_t d;
6822 uint32_t *e = &c;
6823
6824 asm ("mov %[e], %[d]"
6825 : [d] "=rm" (d)
6826 : [e] "rm" (*e));
6827 @end example
6828
6829 Here, @var{d} may either be in a register or in memory. Since the compiler
6830 might already have the current value of the uint32_t pointed to by @var{e}
6831 in a register, you can enable it to choose the best location
6832 for @var{d} by specifying both constraints.
6833
6834 @anchor{InputOperands}
6835 @subsubsection Input Operands
6836 @cindex @code{asm} input operands
6837 @cindex @code{asm} expressions
6838
6839 Input operands make inputs from C variables and expressions available to the
6840 assembly code.
6841
6842 Specify input operands by using the format:
6843
6844 @example
6845 [ [asmSymbolicName] ] "constraint" (cexpression)
6846 @end example
6847
6848 @emph{asmSymbolicName}
6849 @*
6850 When not using asmSymbolicNames, use the (zero-based) position of the operand
6851 in the list of operands, including outputs, in the assembler template. For
6852 example, if there are two output parameters and three inputs, @code{%2} refers
6853 to the first input, @code{%3} to the second, and @code{%4} to the third.
6854 When using an asmSymbolicName, reference it by enclosing the name in square
6855 brackets (e.g. @code{%[Value]}). The scope of the name is the @code{asm}
6856 statement that contains the definition. Any valid C variable name is
6857 acceptable, including names already defined in the surrounding code. No two
6858 operands within the same @code{asm} statement can use the same symbolic name.
6859
6860 @emph{constraint}
6861 @*
6862 Input constraints must be a string containing one or more constraints
6863 (@pxref{Constraints}). When you give more than one possible constraint
6864 (for example, @code{"irm"}), the compiler will choose the most efficient
6865 method based on the current context. Input constraints may not begin with
6866 either "=" or "+". If you must use a specific register, but your Machine
6867 Constraints do not provide sufficient control to select the specific
6868 register you want, Local Reg Vars may provide a solution
6869 (@pxref{Local Reg Vars}).
6870
6871 Input constraints can also be digits (for example, @code{"0"}). This indicates
6872 that the specified input will be in the same place as the output constraint
6873 at the (zero-based) index in the output constraint list. When using
6874 asmSymbolicNames for the output operands, you may use these names (enclosed
6875 in brackets []) instead of digits.
6876
6877 @emph{cexpression}
6878 @*
6879 This is the C variable or expression being passed to the @code{asm} statement
6880 as input.
6881
6882 When the compiler selects the registers to use to represent the input
6883 operands, it will not use any of the clobbered registers (@pxref{Clobbers}).
6884
6885 If there are no output operands but there are input operands, place two
6886 consecutive colons where the output operands would go:
6887
6888 @example
6889 __asm__ ("some instructions"
6890 : /* No outputs. */
6891 : "r" (Offset / 8);
6892 @end example
6893
6894 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
6895 (except for inputs tied to outputs). The compiler assumes that on exit from
6896 the @code{asm} statement these operands will contain the same values as they
6897 had before executing the assembler. It is @emph{not} possible to use Clobbers
6898 to inform the compiler that the values in these inputs are changing. One
6899 common work-around is to tie the changing input variable to an output variable
6900 that never gets used. Note, however, that if the code that follows the
6901 @code{asm} statement makes no use of any of the output operands, the GCC
6902 optimizers may discard the @code{asm} statement as unneeded
6903 (see @ref{Volatile}).
6904
6905 Remarks:
6906
6907 The total number of input + output + goto operands has a limit of 30.
6908
6909 @code{asm} supports operand modifiers on operands (for example @code{%k2}
6910 instead of simply @code{%2}). Typically these qualifiers are hardware
6911 dependent. The list of supported modifiers for i386 is found at
6912 @ref{i386Operandmodifiers,i386 Operand modifiers}.
6913
6914 Examples:
6915
6916 In this example using the fictitious @code{combine} instruction, the
6917 constraint @code{"0"} for input operand 1 says that it must occupy the same
6918 location as output operand 0. Only input operands may use numbers in
6919 constraints, and they must each refer to an output operand. Only a number (or
6920 the symbolic assembler name) in the constraint can guarantee that one operand
6921 is in the same place as another. The mere fact that @var{foo} is the value of
6922 both operands is not enough to guarantee that they are in the same place in
6923 the generated assembler code.
6924
6925 @example
6926 asm ("combine %2, %0"
6927 : "=r" (foo)
6928 : "0" (foo), "g" (bar));
6929 @end example
6930
6931 Here is an example using symbolic names.
6932
6933 @example
6934 asm ("cmoveq %1, %2, %[result]"
6935 : [result] "=r"(result)
6936 : "r" (test), "r" (new), "[result]" (old));
6937 @end example
6938
6939 @anchor{Clobbers}
6940 @subsubsection Clobbers
6941 @cindex @code{asm} clobbers
6942
6943 While the compiler is aware of changes to entries listed in the output
6944 operands, the assembler code may modify more than just the outputs. For
6945 example, calculations may require additional registers, or the processor may
6946 overwrite a register as a side effect of a particular assembler instruction.
6947 In order to inform the compiler of these changes, list them in the clobber
6948 list. Clobber list items are either register names or the special clobbers
6949 (listed below). Each clobber list item is enclosed in double quotes and
6950 separated by commas.
6951
6952 Clobber descriptions may not in any way overlap with an input or output
6953 operand. For example, you may not have an operand describing a register class
6954 with one member when listing that register in the clobber list. Variables
6955 declared to live in specific registers (@pxref{Explicit Reg Vars}), and used
6956 as @code{asm} input or output operands, must have no part mentioned in the
6957 clobber description. In particular, there is no way to specify that input
6958 operands get modified without also specifying them as output operands.
6959
6960 When the compiler selects which registers to use to represent input and output
6961 operands, it will not use any of the clobbered registers. As a result,
6962 clobbered registers are available for any use in the assembler code.
6963
6964 Here is a realistic example for the VAX showing the use of clobbered
6965 registers:
6966
6967 @example
6968 asm volatile ("movc3 %0, %1, %2"
6969 : /* No outputs. */
6970 : "g" (from), "g" (to), "g" (count)
6971 : "r0", "r1", "r2", "r3", "r4", "r5");
6972 @end example
6973
6974 Also, there are two special clobber arguments:
6975
6976 @enumerate
6977 @item
6978 The @code{"cc"} clobber indicates that the assembler code modifies the flags
6979 register. On some machines, GCC represents the condition codes as a specific
6980 hardware register; "cc" serves to name this register. On other machines,
6981 condition code handling is different, and specifying "cc" has no effect. But
6982 it is valid no matter what the machine.
6983
6984 @item
6985 The "memory" clobber tells the compiler that the assembly code performs memory
6986 reads or writes to items other than those listed in the input and output
6987 operands (for example accessing the memory pointed to by one of the input
6988 parameters). To ensure memory contains correct values, GCC may need to flush
6989 specific register values to memory before executing the @code{asm}. Further,
6990 the compiler will not assume that any values read from memory before an
6991 @code{asm} will remain unchanged after that @code{asm}; it will reload them as
6992 needed. This effectively forms a read/write memory barrier for the compiler.
6993
6994 Note that this clobber does not prevent the @emph{processor} from doing
6995 speculative reads past the @code{asm} statement. To prevent that, you need
6996 processor-specific fence instructions.
6997
6998 Flushing registers to memory has performance implications and may be an issue
6999 for time-sensitive code. One trick to avoid this is available if the size of
7000 the memory being accessed is known at compile time. For example, if accessing
7001 ten bytes of a string, use a memory input like:
7002
7003 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
7004
7005 @end enumerate
7006
7007 @anchor{GotoLabels}
7008 @subsubsection Goto Labels
7009 @cindex @code{asm} goto labels
7010
7011 @code{asm goto} allows assembly code to jump to one or more C labels. The
7012 GotoLabels section in an @code{asm goto} statement contains a comma-separated
7013 list of all C labels to which the assembler code may jump. GCC assumes that
7014 @code{asm} execution falls through to the next statement (if this is not the
7015 case, consider using the @code{__builtin_unreachable} intrinsic after the
7016 @code{asm} statement). Optimization of @code{asm goto} may be improved by
7017 using the @code{hot} and @code{cold} label attributes (@pxref{Label
7018 Attributes}). The total number of input + output + goto operands has
7019 a limit of 30.
7020
7021 An @code{asm goto} statement can not have outputs (which means that the
7022 statement is implicitly volatile). This is due to an internal restriction of
7023 the compiler: control transfer instructions cannot have outputs. If the
7024 assembler code does modify anything, use the "memory" clobber to force the
7025 optimizers to flush all register values to memory, and reload them if
7026 necessary, after the @code{asm} statement.
7027
7028 To reference a label, prefix it with @code{%l} (that's a lowercase L) followed
7029 by its (zero-based) position in GotoLabels plus the number of input
7030 arguments. For example, if the @code{asm} has three inputs and references two
7031 labels, refer to the first label as @code{%l3} and the second as @code{%l4}).
7032
7033 @code{asm} statements may not perform jumps into other @code{asm} statements.
7034 GCC's optimizers do not know about these jumps; therefore they cannot take
7035 account of them when deciding how to optimize.
7036
7037 Example code for i386 might look like:
7038
7039 @example
7040 asm goto (
7041 "btl %1, %0\n\t"
7042 "jc %l2"
7043 : /* No outputs. */
7044 : "r" (p1), "r" (p2)
7045 : "cc"
7046 : carry);
7047
7048 return 0;
7049
7050 carry:
7051 return 1;
7052 @end example
7053
7054 The following example shows an @code{asm goto} that uses the memory clobber.
7055
7056 @example
7057 int frob(int x)
7058 @{
7059 int y;
7060 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
7061 : /* No outputs. */
7062 : "r"(x), "r"(&y)
7063 : "r5", "memory"
7064 : error);
7065 return y;
7066 error:
7067 return -1;
7068 @}
7069 @end example
7070
7071 @anchor{i386Operandmodifiers}
7072 @subsubsection i386 Operand modifiers
7073
7074 Input, output, and goto operands for extended @code{asm} statements can use
7075 modifiers to affect the code output to the assembler. For example, the
7076 following code uses the "h" and "b" modifiers for i386:
7077
7078 @example
7079 uint16_t num;
7080 asm volatile ("xchg %h0, %b0" : "+a" (num) );
7081 @end example
7082
7083 These modifiers generate this assembler code:
7084
7085 @example
7086 xchg %ah, %al
7087 @end example
7088
7089 The rest of this discussion uses the following code for illustrative purposes.
7090
7091 @example
7092 int main()
7093 @{
7094 int iInt = 1;
7095
7096 top:
7097
7098 asm volatile goto ("some assembler instructions here"
7099 : /* No outputs. */
7100 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
7101 : /* No clobbers. */
7102 : top);
7103 @}
7104 @end example
7105
7106 With no modifiers, this is what the output from the operands would be for the
7107 att and intel dialects of assembler:
7108
7109 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
7110 @headitem Operand @tab masm=att @tab masm=intel
7111 @item @code{%0}
7112 @tab @code{%eax}
7113 @tab @code{eax}
7114 @item @code{%1}
7115 @tab @code{$2}
7116 @tab @code{2}
7117 @item @code{%2}
7118 @tab @code{$.L2}
7119 @tab @code{OFFSET FLAT:.L2}
7120 @end multitable
7121
7122 The table below shows the list of supported modifiers and their effects.
7123
7124 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
7125 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
7126 @item @code{z}
7127 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
7128 @tab @code{%z0}
7129 @tab @code{l}
7130 @tab
7131 @item @code{b}
7132 @tab Print the QImode name of the register.
7133 @tab @code{%b0}
7134 @tab @code{%al}
7135 @tab @code{al}
7136 @item @code{h}
7137 @tab Print the QImode name for a ``high'' register.
7138 @tab @code{%h0}
7139 @tab @code{%ah}
7140 @tab @code{ah}
7141 @item @code{w}
7142 @tab Print the HImode name of the register.
7143 @tab @code{%w0}
7144 @tab @code{%ax}
7145 @tab @code{ax}
7146 @item @code{k}
7147 @tab Print the SImode name of the register.
7148 @tab @code{%k0}
7149 @tab @code{%eax}
7150 @tab @code{eax}
7151 @item @code{q}
7152 @tab Print the DImode name of the register.
7153 @tab @code{%q0}
7154 @tab @code{%rax}
7155 @tab @code{rax}
7156 @item @code{l}
7157 @tab Print the label name with no punctuation.
7158 @tab @code{%l2}
7159 @tab @code{.L2}
7160 @tab @code{.L2}
7161 @item @code{c}
7162 @tab Require a constant operand and print the constant expression with no punctuation.
7163 @tab @code{%c1}
7164 @tab @code{2}
7165 @tab @code{2}
7166 @end multitable
7167
7168 @anchor{i386floatingpointasmoperands}
7169 @subsubsection i386 floating-point asm operands
7170
7171 On i386 targets, there are several rules on the usage of stack-like registers
7172 in the operands of an @code{asm}. These rules apply only to the operands
7173 that are stack-like registers:
7174
7175 @enumerate
7176 @item
7177 Given a set of input registers that die in an @code{asm}, it is
7178 necessary to know which are implicitly popped by the @code{asm}, and
7179 which must be explicitly popped by GCC@.
7180
7181 An input register that is implicitly popped by the @code{asm} must be
7182 explicitly clobbered, unless it is constrained to match an
7183 output operand.
7184
7185 @item
7186 For any input register that is implicitly popped by an @code{asm}, it is
7187 necessary to know how to adjust the stack to compensate for the pop.
7188 If any non-popped input is closer to the top of the reg-stack than
7189 the implicitly popped register, it would not be possible to know what the
7190 stack looked like---it's not clear how the rest of the stack ``slides
7191 up''.
7192
7193 All implicitly popped input registers must be closer to the top of
7194 the reg-stack than any input that is not implicitly popped.
7195
7196 It is possible that if an input dies in an @code{asm}, the compiler might
7197 use the input register for an output reload. Consider this example:
7198
7199 @smallexample
7200 asm ("foo" : "=t" (a) : "f" (b));
7201 @end smallexample
7202
7203 @noindent
7204 This code says that input @code{b} is not popped by the @code{asm}, and that
7205 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
7206 deeper after the @code{asm} than it was before. But, it is possible that
7207 reload may think that it can use the same register for both the input and
7208 the output.
7209
7210 To prevent this from happening,
7211 if any input operand uses the @code{f} constraint, all output register
7212 constraints must use the @code{&} early-clobber modifier.
7213
7214 The example above would be correctly written as:
7215
7216 @smallexample
7217 asm ("foo" : "=&t" (a) : "f" (b));
7218 @end smallexample
7219
7220 @item
7221 Some operands need to be in particular places on the stack. All
7222 output operands fall in this category---GCC has no other way to
7223 know which registers the outputs appear in unless you indicate
7224 this in the constraints.
7225
7226 Output operands must specifically indicate which register an output
7227 appears in after an @code{asm}. @code{=f} is not allowed: the operand
7228 constraints must select a class with a single register.
7229
7230 @item
7231 Output operands may not be ``inserted'' between existing stack registers.
7232 Since no 387 opcode uses a read/write operand, all output operands
7233 are dead before the @code{asm}, and are pushed by the @code{asm}.
7234 It makes no sense to push anywhere but the top of the reg-stack.
7235
7236 Output operands must start at the top of the reg-stack: output
7237 operands may not ``skip'' a register.
7238
7239 @item
7240 Some @code{asm} statements may need extra stack space for internal
7241 calculations. This can be guaranteed by clobbering stack registers
7242 unrelated to the inputs and outputs.
7243
7244 @end enumerate
7245
7246 Here are a couple of reasonable @code{asm}s to want to write. This
7247 @code{asm}
7248 takes one input, which is internally popped, and produces two outputs.
7249
7250 @smallexample
7251 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
7252 @end smallexample
7253
7254 @noindent
7255 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
7256 and replaces them with one output. The @code{st(1)} clobber is necessary
7257 for the compiler to know that @code{fyl2xp1} pops both inputs.
7258
7259 @smallexample
7260 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
7261 @end smallexample
7262
7263 @lowersections
7264 @include md.texi
7265 @raisesections
7266
7267 @node Asm Labels
7268 @subsection Controlling Names Used in Assembler Code
7269 @cindex assembler names for identifiers
7270 @cindex names used in assembler code
7271 @cindex identifiers, names in assembler code
7272
7273 You can specify the name to be used in the assembler code for a C
7274 function or variable by writing the @code{asm} (or @code{__asm__})
7275 keyword after the declarator as follows:
7276
7277 @smallexample
7278 int foo asm ("myfoo") = 2;
7279 @end smallexample
7280
7281 @noindent
7282 This specifies that the name to be used for the variable @code{foo} in
7283 the assembler code should be @samp{myfoo} rather than the usual
7284 @samp{_foo}.
7285
7286 On systems where an underscore is normally prepended to the name of a C
7287 function or variable, this feature allows you to define names for the
7288 linker that do not start with an underscore.
7289
7290 It does not make sense to use this feature with a non-static local
7291 variable since such variables do not have assembler names. If you are
7292 trying to put the variable in a particular register, see @ref{Explicit
7293 Reg Vars}. GCC presently accepts such code with a warning, but will
7294 probably be changed to issue an error, rather than a warning, in the
7295 future.
7296
7297 You cannot use @code{asm} in this way in a function @emph{definition}; but
7298 you can get the same effect by writing a declaration for the function
7299 before its definition and putting @code{asm} there, like this:
7300
7301 @smallexample
7302 extern func () asm ("FUNC");
7303
7304 func (x, y)
7305 int x, y;
7306 /* @r{@dots{}} */
7307 @end smallexample
7308
7309 It is up to you to make sure that the assembler names you choose do not
7310 conflict with any other assembler symbols. Also, you must not use a
7311 register name; that would produce completely invalid assembler code. GCC
7312 does not as yet have the ability to store static variables in registers.
7313 Perhaps that will be added.
7314
7315 @node Explicit Reg Vars
7316 @subsection Variables in Specified Registers
7317 @cindex explicit register variables
7318 @cindex variables in specified registers
7319 @cindex specified registers
7320 @cindex registers, global allocation
7321
7322 GNU C allows you to put a few global variables into specified hardware
7323 registers. You can also specify the register in which an ordinary
7324 register variable should be allocated.
7325
7326 @itemize @bullet
7327 @item
7328 Global register variables reserve registers throughout the program.
7329 This may be useful in programs such as programming language
7330 interpreters that have a couple of global variables that are accessed
7331 very often.
7332
7333 @item
7334 Local register variables in specific registers do not reserve the
7335 registers, except at the point where they are used as input or output
7336 operands in an @code{asm} statement and the @code{asm} statement itself is
7337 not deleted. The compiler's data flow analysis is capable of determining
7338 where the specified registers contain live values, and where they are
7339 available for other uses. Stores into local register variables may be deleted
7340 when they appear to be dead according to dataflow analysis. References
7341 to local register variables may be deleted or moved or simplified.
7342
7343 These local variables are sometimes convenient for use with the extended
7344 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
7345 output of the assembler instruction directly into a particular register.
7346 (This works provided the register you specify fits the constraints
7347 specified for that operand in the @code{asm}.)
7348 @end itemize
7349
7350 @menu
7351 * Global Reg Vars::
7352 * Local Reg Vars::
7353 @end menu
7354
7355 @node Global Reg Vars
7356 @subsubsection Defining Global Register Variables
7357 @cindex global register variables
7358 @cindex registers, global variables in
7359
7360 You can define a global register variable in GNU C like this:
7361
7362 @smallexample
7363 register int *foo asm ("a5");
7364 @end smallexample
7365
7366 @noindent
7367 Here @code{a5} is the name of the register that should be used. Choose a
7368 register that is normally saved and restored by function calls on your
7369 machine, so that library routines will not clobber it.
7370
7371 Naturally the register name is cpu-dependent, so you need to
7372 conditionalize your program according to cpu type. The register
7373 @code{a5} is a good choice on a 68000 for a variable of pointer
7374 type. On machines with register windows, be sure to choose a ``global''
7375 register that is not affected magically by the function call mechanism.
7376
7377 In addition, different operating systems on the same CPU may differ in how they
7378 name the registers; then you need additional conditionals. For
7379 example, some 68000 operating systems call this register @code{%a5}.
7380
7381 Eventually there may be a way of asking the compiler to choose a register
7382 automatically, but first we need to figure out how it should choose and
7383 how to enable you to guide the choice. No solution is evident.
7384
7385 Defining a global register variable in a certain register reserves that
7386 register entirely for this use, at least within the current compilation.
7387 The register is not allocated for any other purpose in the functions
7388 in the current compilation, and is not saved and restored by
7389 these functions. Stores into this register are never deleted even if they
7390 appear to be dead, but references may be deleted or moved or
7391 simplified.
7392
7393 It is not safe to access the global register variables from signal
7394 handlers, or from more than one thread of control, because the system
7395 library routines may temporarily use the register for other things (unless
7396 you recompile them specially for the task at hand).
7397
7398 @cindex @code{qsort}, and global register variables
7399 It is not safe for one function that uses a global register variable to
7400 call another such function @code{foo} by way of a third function
7401 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
7402 different source file in which the variable isn't declared). This is
7403 because @code{lose} might save the register and put some other value there.
7404 For example, you can't expect a global register variable to be available in
7405 the comparison-function that you pass to @code{qsort}, since @code{qsort}
7406 might have put something else in that register. (If you are prepared to
7407 recompile @code{qsort} with the same global register variable, you can
7408 solve this problem.)
7409
7410 If you want to recompile @code{qsort} or other source files that do not
7411 actually use your global register variable, so that they do not use that
7412 register for any other purpose, then it suffices to specify the compiler
7413 option @option{-ffixed-@var{reg}}. You need not actually add a global
7414 register declaration to their source code.
7415
7416 A function that can alter the value of a global register variable cannot
7417 safely be called from a function compiled without this variable, because it
7418 could clobber the value the caller expects to find there on return.
7419 Therefore, the function that is the entry point into the part of the
7420 program that uses the global register variable must explicitly save and
7421 restore the value that belongs to its caller.
7422
7423 @cindex register variable after @code{longjmp}
7424 @cindex global register after @code{longjmp}
7425 @cindex value after @code{longjmp}
7426 @findex longjmp
7427 @findex setjmp
7428 On most machines, @code{longjmp} restores to each global register
7429 variable the value it had at the time of the @code{setjmp}. On some
7430 machines, however, @code{longjmp} does not change the value of global
7431 register variables. To be portable, the function that called @code{setjmp}
7432 should make other arrangements to save the values of the global register
7433 variables, and to restore them in a @code{longjmp}. This way, the same
7434 thing happens regardless of what @code{longjmp} does.
7435
7436 All global register variable declarations must precede all function
7437 definitions. If such a declaration could appear after function
7438 definitions, the declaration would be too late to prevent the register from
7439 being used for other purposes in the preceding functions.
7440
7441 Global register variables may not have initial values, because an
7442 executable file has no means to supply initial contents for a register.
7443
7444 On the SPARC, there are reports that g3 @dots{} g7 are suitable
7445 registers, but certain library functions, such as @code{getwd}, as well
7446 as the subroutines for division and remainder, modify g3 and g4. g1 and
7447 g2 are local temporaries.
7448
7449 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
7450 Of course, it does not do to use more than a few of those.
7451
7452 @node Local Reg Vars
7453 @subsubsection Specifying Registers for Local Variables
7454 @cindex local variables, specifying registers
7455 @cindex specifying registers for local variables
7456 @cindex registers for local variables
7457
7458 You can define a local register variable with a specified register
7459 like this:
7460
7461 @smallexample
7462 register int *foo asm ("a5");
7463 @end smallexample
7464
7465 @noindent
7466 Here @code{a5} is the name of the register that should be used. Note
7467 that this is the same syntax used for defining global register
7468 variables, but for a local variable it appears within a function.
7469
7470 Naturally the register name is cpu-dependent, but this is not a
7471 problem, since specific registers are most often useful with explicit
7472 assembler instructions (@pxref{Extended Asm}). Both of these things
7473 generally require that you conditionalize your program according to
7474 cpu type.
7475
7476 In addition, operating systems on one type of cpu may differ in how they
7477 name the registers; then you need additional conditionals. For
7478 example, some 68000 operating systems call this register @code{%a5}.
7479
7480 Defining such a register variable does not reserve the register; it
7481 remains available for other uses in places where flow control determines
7482 the variable's value is not live.
7483
7484 This option does not guarantee that GCC generates code that has
7485 this variable in the register you specify at all times. You may not
7486 code an explicit reference to this register in the @emph{assembler
7487 instruction template} part of an @code{asm} statement and assume it
7488 always refers to this variable. However, using the variable as an
7489 @code{asm} @emph{operand} guarantees that the specified register is used
7490 for the operand.
7491
7492 Stores into local register variables may be deleted when they appear to be dead
7493 according to dataflow analysis. References to local register variables may
7494 be deleted or moved or simplified.
7495
7496 As with global register variables, it is recommended that you choose a
7497 register that is normally saved and restored by function calls on
7498 your machine, so that library routines will not clobber it.
7499
7500 Sometimes when writing inline @code{asm} code, you need to make an operand be a
7501 specific register, but there's no matching constraint letter for that
7502 register. To force the operand into that register, create a local variable
7503 and specify the register in the variable's declaration. Then use the local
7504 variable for the asm operand and specify any constraint letter that matches
7505 the register:
7506
7507 @smallexample
7508 register int *p1 asm ("r0") = @dots{};
7509 register int *p2 asm ("r1") = @dots{};
7510 register int *result asm ("r0");
7511 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7512 @end smallexample
7513
7514 @emph{Warning:} In the above example, be aware that a register (for example r0) can be
7515 call-clobbered by subsequent code, including function calls and library calls
7516 for arithmetic operators on other variables (for example the initialization
7517 of p2). In this case, use temporary variables for expressions between the
7518 register assignments:
7519
7520 @smallexample
7521 int t1 = @dots{};
7522 register int *p1 asm ("r0") = @dots{};
7523 register int *p2 asm ("r1") = t1;
7524 register int *result asm ("r0");
7525 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7526 @end smallexample
7527
7528 @node Size of an asm
7529 @subsection Size of an @code{asm}
7530
7531 Some targets require that GCC track the size of each instruction used
7532 in order to generate correct code. Because the final length of the
7533 code produced by an @code{asm} statement is only known by the
7534 assembler, GCC must make an estimate as to how big it will be. It
7535 does this by counting the number of instructions in the pattern of the
7536 @code{asm} and multiplying that by the length of the longest
7537 instruction supported by that processor. (When working out the number
7538 of instructions, it assumes that any occurrence of a newline or of
7539 whatever statement separator character is supported by the assembler --
7540 typically @samp{;} --- indicates the end of an instruction.)
7541
7542 Normally, GCC's estimate is adequate to ensure that correct
7543 code is generated, but it is possible to confuse the compiler if you use
7544 pseudo instructions or assembler macros that expand into multiple real
7545 instructions, or if you use assembler directives that expand to more
7546 space in the object file than is needed for a single instruction.
7547 If this happens then the assembler may produce a diagnostic saying that
7548 a label is unreachable.
7549
7550 @node Alternate Keywords
7551 @section Alternate Keywords
7552 @cindex alternate keywords
7553 @cindex keywords, alternate
7554
7555 @option{-ansi} and the various @option{-std} options disable certain
7556 keywords. This causes trouble when you want to use GNU C extensions, or
7557 a general-purpose header file that should be usable by all programs,
7558 including ISO C programs. The keywords @code{asm}, @code{typeof} and
7559 @code{inline} are not available in programs compiled with
7560 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
7561 program compiled with @option{-std=c99} or @option{-std=c11}). The
7562 ISO C99 keyword
7563 @code{restrict} is only available when @option{-std=gnu99} (which will
7564 eventually be the default) or @option{-std=c99} (or the equivalent
7565 @option{-std=iso9899:1999}), or an option for a later standard
7566 version, is used.
7567
7568 The way to solve these problems is to put @samp{__} at the beginning and
7569 end of each problematical keyword. For example, use @code{__asm__}
7570 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
7571
7572 Other C compilers won't accept these alternative keywords; if you want to
7573 compile with another compiler, you can define the alternate keywords as
7574 macros to replace them with the customary keywords. It looks like this:
7575
7576 @smallexample
7577 #ifndef __GNUC__
7578 #define __asm__ asm
7579 #endif
7580 @end smallexample
7581
7582 @findex __extension__
7583 @opindex pedantic
7584 @option{-pedantic} and other options cause warnings for many GNU C extensions.
7585 You can
7586 prevent such warnings within one expression by writing
7587 @code{__extension__} before the expression. @code{__extension__} has no
7588 effect aside from this.
7589
7590 @node Incomplete Enums
7591 @section Incomplete @code{enum} Types
7592
7593 You can define an @code{enum} tag without specifying its possible values.
7594 This results in an incomplete type, much like what you get if you write
7595 @code{struct foo} without describing the elements. A later declaration
7596 that does specify the possible values completes the type.
7597
7598 You can't allocate variables or storage using the type while it is
7599 incomplete. However, you can work with pointers to that type.
7600
7601 This extension may not be very useful, but it makes the handling of
7602 @code{enum} more consistent with the way @code{struct} and @code{union}
7603 are handled.
7604
7605 This extension is not supported by GNU C++.
7606
7607 @node Function Names
7608 @section Function Names as Strings
7609 @cindex @code{__func__} identifier
7610 @cindex @code{__FUNCTION__} identifier
7611 @cindex @code{__PRETTY_FUNCTION__} identifier
7612
7613 GCC provides three magic variables that hold the name of the current
7614 function, as a string. The first of these is @code{__func__}, which
7615 is part of the C99 standard:
7616
7617 The identifier @code{__func__} is implicitly declared by the translator
7618 as if, immediately following the opening brace of each function
7619 definition, the declaration
7620
7621 @smallexample
7622 static const char __func__[] = "function-name";
7623 @end smallexample
7624
7625 @noindent
7626 appeared, where function-name is the name of the lexically-enclosing
7627 function. This name is the unadorned name of the function.
7628
7629 @code{__FUNCTION__} is another name for @code{__func__}. Older
7630 versions of GCC recognize only this name. However, it is not
7631 standardized. For maximum portability, we recommend you use
7632 @code{__func__}, but provide a fallback definition with the
7633 preprocessor:
7634
7635 @smallexample
7636 #if __STDC_VERSION__ < 199901L
7637 # if __GNUC__ >= 2
7638 # define __func__ __FUNCTION__
7639 # else
7640 # define __func__ "<unknown>"
7641 # endif
7642 #endif
7643 @end smallexample
7644
7645 In C, @code{__PRETTY_FUNCTION__} is yet another name for
7646 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
7647 the type signature of the function as well as its bare name. For
7648 example, this program:
7649
7650 @smallexample
7651 extern "C" @{
7652 extern int printf (char *, ...);
7653 @}
7654
7655 class a @{
7656 public:
7657 void sub (int i)
7658 @{
7659 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
7660 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
7661 @}
7662 @};
7663
7664 int
7665 main (void)
7666 @{
7667 a ax;
7668 ax.sub (0);
7669 return 0;
7670 @}
7671 @end smallexample
7672
7673 @noindent
7674 gives this output:
7675
7676 @smallexample
7677 __FUNCTION__ = sub
7678 __PRETTY_FUNCTION__ = void a::sub(int)
7679 @end smallexample
7680
7681 These identifiers are not preprocessor macros. In GCC 3.3 and
7682 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
7683 were treated as string literals; they could be used to initialize
7684 @code{char} arrays, and they could be concatenated with other string
7685 literals. GCC 3.4 and later treat them as variables, like
7686 @code{__func__}. In C++, @code{__FUNCTION__} and
7687 @code{__PRETTY_FUNCTION__} have always been variables.
7688
7689 @node Return Address
7690 @section Getting the Return or Frame Address of a Function
7691
7692 These functions may be used to get information about the callers of a
7693 function.
7694
7695 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
7696 This function returns the return address of the current function, or of
7697 one of its callers. The @var{level} argument is number of frames to
7698 scan up the call stack. A value of @code{0} yields the return address
7699 of the current function, a value of @code{1} yields the return address
7700 of the caller of the current function, and so forth. When inlining
7701 the expected behavior is that the function returns the address of
7702 the function that is returned to. To work around this behavior use
7703 the @code{noinline} function attribute.
7704
7705 The @var{level} argument must be a constant integer.
7706
7707 On some machines it may be impossible to determine the return address of
7708 any function other than the current one; in such cases, or when the top
7709 of the stack has been reached, this function returns @code{0} or a
7710 random value. In addition, @code{__builtin_frame_address} may be used
7711 to determine if the top of the stack has been reached.
7712
7713 Additional post-processing of the returned value may be needed, see
7714 @code{__builtin_extract_return_addr}.
7715
7716 This function should only be used with a nonzero argument for debugging
7717 purposes.
7718 @end deftypefn
7719
7720 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
7721 The address as returned by @code{__builtin_return_address} may have to be fed
7722 through this function to get the actual encoded address. For example, on the
7723 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
7724 platforms an offset has to be added for the true next instruction to be
7725 executed.
7726
7727 If no fixup is needed, this function simply passes through @var{addr}.
7728 @end deftypefn
7729
7730 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
7731 This function does the reverse of @code{__builtin_extract_return_addr}.
7732 @end deftypefn
7733
7734 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
7735 This function is similar to @code{__builtin_return_address}, but it
7736 returns the address of the function frame rather than the return address
7737 of the function. Calling @code{__builtin_frame_address} with a value of
7738 @code{0} yields the frame address of the current function, a value of
7739 @code{1} yields the frame address of the caller of the current function,
7740 and so forth.
7741
7742 The frame is the area on the stack that holds local variables and saved
7743 registers. The frame address is normally the address of the first word
7744 pushed on to the stack by the function. However, the exact definition
7745 depends upon the processor and the calling convention. If the processor
7746 has a dedicated frame pointer register, and the function has a frame,
7747 then @code{__builtin_frame_address} returns the value of the frame
7748 pointer register.
7749
7750 On some machines it may be impossible to determine the frame address of
7751 any function other than the current one; in such cases, or when the top
7752 of the stack has been reached, this function returns @code{0} if
7753 the first frame pointer is properly initialized by the startup code.
7754
7755 This function should only be used with a nonzero argument for debugging
7756 purposes.
7757 @end deftypefn
7758
7759 @node Vector Extensions
7760 @section Using Vector Instructions through Built-in Functions
7761
7762 On some targets, the instruction set contains SIMD vector instructions which
7763 operate on multiple values contained in one large register at the same time.
7764 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
7765 this way.
7766
7767 The first step in using these extensions is to provide the necessary data
7768 types. This should be done using an appropriate @code{typedef}:
7769
7770 @smallexample
7771 typedef int v4si __attribute__ ((vector_size (16)));
7772 @end smallexample
7773
7774 @noindent
7775 The @code{int} type specifies the base type, while the attribute specifies
7776 the vector size for the variable, measured in bytes. For example, the
7777 declaration above causes the compiler to set the mode for the @code{v4si}
7778 type to be 16 bytes wide and divided into @code{int} sized units. For
7779 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
7780 corresponding mode of @code{foo} is @acronym{V4SI}.
7781
7782 The @code{vector_size} attribute is only applicable to integral and
7783 float scalars, although arrays, pointers, and function return values
7784 are allowed in conjunction with this construct. Only sizes that are
7785 a power of two are currently allowed.
7786
7787 All the basic integer types can be used as base types, both as signed
7788 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
7789 @code{long long}. In addition, @code{float} and @code{double} can be
7790 used to build floating-point vector types.
7791
7792 Specifying a combination that is not valid for the current architecture
7793 causes GCC to synthesize the instructions using a narrower mode.
7794 For example, if you specify a variable of type @code{V4SI} and your
7795 architecture does not allow for this specific SIMD type, GCC
7796 produces code that uses 4 @code{SIs}.
7797
7798 The types defined in this manner can be used with a subset of normal C
7799 operations. Currently, GCC allows using the following operators
7800 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
7801
7802 The operations behave like C++ @code{valarrays}. Addition is defined as
7803 the addition of the corresponding elements of the operands. For
7804 example, in the code below, each of the 4 elements in @var{a} is
7805 added to the corresponding 4 elements in @var{b} and the resulting
7806 vector is stored in @var{c}.
7807
7808 @smallexample
7809 typedef int v4si __attribute__ ((vector_size (16)));
7810
7811 v4si a, b, c;
7812
7813 c = a + b;
7814 @end smallexample
7815
7816 Subtraction, multiplication, division, and the logical operations
7817 operate in a similar manner. Likewise, the result of using the unary
7818 minus or complement operators on a vector type is a vector whose
7819 elements are the negative or complemented values of the corresponding
7820 elements in the operand.
7821
7822 It is possible to use shifting operators @code{<<}, @code{>>} on
7823 integer-type vectors. The operation is defined as following: @code{@{a0,
7824 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
7825 @dots{}, an >> bn@}}@. Vector operands must have the same number of
7826 elements.
7827
7828 For convenience, it is allowed to use a binary vector operation
7829 where one operand is a scalar. In that case the compiler transforms
7830 the scalar operand into a vector where each element is the scalar from
7831 the operation. The transformation happens only if the scalar could be
7832 safely converted to the vector-element type.
7833 Consider the following code.
7834
7835 @smallexample
7836 typedef int v4si __attribute__ ((vector_size (16)));
7837
7838 v4si a, b, c;
7839 long l;
7840
7841 a = b + 1; /* a = b + @{1,1,1,1@}; */
7842 a = 2 * b; /* a = @{2,2,2,2@} * b; */
7843
7844 a = l + a; /* Error, cannot convert long to int. */
7845 @end smallexample
7846
7847 Vectors can be subscripted as if the vector were an array with
7848 the same number of elements and base type. Out of bound accesses
7849 invoke undefined behavior at run time. Warnings for out of bound
7850 accesses for vector subscription can be enabled with
7851 @option{-Warray-bounds}.
7852
7853 Vector comparison is supported with standard comparison
7854 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
7855 vector expressions of integer-type or real-type. Comparison between
7856 integer-type vectors and real-type vectors are not supported. The
7857 result of the comparison is a vector of the same width and number of
7858 elements as the comparison operands with a signed integral element
7859 type.
7860
7861 Vectors are compared element-wise producing 0 when comparison is false
7862 and -1 (constant of the appropriate type where all bits are set)
7863 otherwise. Consider the following example.
7864
7865 @smallexample
7866 typedef int v4si __attribute__ ((vector_size (16)));
7867
7868 v4si a = @{1,2,3,4@};
7869 v4si b = @{3,2,1,4@};
7870 v4si c;
7871
7872 c = a > b; /* The result would be @{0, 0,-1, 0@} */
7873 c = a == b; /* The result would be @{0,-1, 0,-1@} */
7874 @end smallexample
7875
7876 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
7877 @code{b} and @code{c} are vectors of the same type and @code{a} is an
7878 integer vector with the same number of elements of the same size as @code{b}
7879 and @code{c}, computes all three arguments and creates a vector
7880 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
7881 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
7882 As in the case of binary operations, this syntax is also accepted when
7883 one of @code{b} or @code{c} is a scalar that is then transformed into a
7884 vector. If both @code{b} and @code{c} are scalars and the type of
7885 @code{true?b:c} has the same size as the element type of @code{a}, then
7886 @code{b} and @code{c} are converted to a vector type whose elements have
7887 this type and with the same number of elements as @code{a}.
7888
7889 Vector shuffling is available using functions
7890 @code{__builtin_shuffle (vec, mask)} and
7891 @code{__builtin_shuffle (vec0, vec1, mask)}.
7892 Both functions construct a permutation of elements from one or two
7893 vectors and return a vector of the same type as the input vector(s).
7894 The @var{mask} is an integral vector with the same width (@var{W})
7895 and element count (@var{N}) as the output vector.
7896
7897 The elements of the input vectors are numbered in memory ordering of
7898 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
7899 elements of @var{mask} are considered modulo @var{N} in the single-operand
7900 case and modulo @math{2*@var{N}} in the two-operand case.
7901
7902 Consider the following example,
7903
7904 @smallexample
7905 typedef int v4si __attribute__ ((vector_size (16)));
7906
7907 v4si a = @{1,2,3,4@};
7908 v4si b = @{5,6,7,8@};
7909 v4si mask1 = @{0,1,1,3@};
7910 v4si mask2 = @{0,4,2,5@};
7911 v4si res;
7912
7913 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
7914 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
7915 @end smallexample
7916
7917 Note that @code{__builtin_shuffle} is intentionally semantically
7918 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
7919
7920 You can declare variables and use them in function calls and returns, as
7921 well as in assignments and some casts. You can specify a vector type as
7922 a return type for a function. Vector types can also be used as function
7923 arguments. It is possible to cast from one vector type to another,
7924 provided they are of the same size (in fact, you can also cast vectors
7925 to and from other datatypes of the same size).
7926
7927 You cannot operate between vectors of different lengths or different
7928 signedness without a cast.
7929
7930 @node Offsetof
7931 @section Offsetof
7932 @findex __builtin_offsetof
7933
7934 GCC implements for both C and C++ a syntactic extension to implement
7935 the @code{offsetof} macro.
7936
7937 @smallexample
7938 primary:
7939 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
7940
7941 offsetof_member_designator:
7942 @code{identifier}
7943 | offsetof_member_designator "." @code{identifier}
7944 | offsetof_member_designator "[" @code{expr} "]"
7945 @end smallexample
7946
7947 This extension is sufficient such that
7948
7949 @smallexample
7950 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
7951 @end smallexample
7952
7953 @noindent
7954 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
7955 may be dependent. In either case, @var{member} may consist of a single
7956 identifier, or a sequence of member accesses and array references.
7957
7958 @node __sync Builtins
7959 @section Legacy __sync Built-in Functions for Atomic Memory Access
7960
7961 The following built-in functions
7962 are intended to be compatible with those described
7963 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
7964 section 7.4. As such, they depart from the normal GCC practice of using
7965 the @samp{__builtin_} prefix, and further that they are overloaded such that
7966 they work on multiple types.
7967
7968 The definition given in the Intel documentation allows only for the use of
7969 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
7970 counterparts. GCC allows any integral scalar or pointer type that is
7971 1, 2, 4 or 8 bytes in length.
7972
7973 Not all operations are supported by all target processors. If a particular
7974 operation cannot be implemented on the target processor, a warning is
7975 generated and a call an external function is generated. The external
7976 function carries the same name as the built-in version,
7977 with an additional suffix
7978 @samp{_@var{n}} where @var{n} is the size of the data type.
7979
7980 @c ??? Should we have a mechanism to suppress this warning? This is almost
7981 @c useful for implementing the operation under the control of an external
7982 @c mutex.
7983
7984 In most cases, these built-in functions are considered a @dfn{full barrier}.
7985 That is,
7986 no memory operand is moved across the operation, either forward or
7987 backward. Further, instructions are issued as necessary to prevent the
7988 processor from speculating loads across the operation and from queuing stores
7989 after the operation.
7990
7991 All of the routines are described in the Intel documentation to take
7992 ``an optional list of variables protected by the memory barrier''. It's
7993 not clear what is meant by that; it could mean that @emph{only} the
7994 following variables are protected, or it could mean that these variables
7995 should in addition be protected. At present GCC ignores this list and
7996 protects all variables that are globally accessible. If in the future
7997 we make some use of this list, an empty list will continue to mean all
7998 globally accessible variables.
7999
8000 @table @code
8001 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
8002 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
8003 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
8004 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
8005 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
8006 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
8007 @findex __sync_fetch_and_add
8008 @findex __sync_fetch_and_sub
8009 @findex __sync_fetch_and_or
8010 @findex __sync_fetch_and_and
8011 @findex __sync_fetch_and_xor
8012 @findex __sync_fetch_and_nand
8013 These built-in functions perform the operation suggested by the name, and
8014 returns the value that had previously been in memory. That is,
8015
8016 @smallexample
8017 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
8018 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
8019 @end smallexample
8020
8021 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
8022 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
8023
8024 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
8025 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
8026 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
8027 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
8028 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
8029 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
8030 @findex __sync_add_and_fetch
8031 @findex __sync_sub_and_fetch
8032 @findex __sync_or_and_fetch
8033 @findex __sync_and_and_fetch
8034 @findex __sync_xor_and_fetch
8035 @findex __sync_nand_and_fetch
8036 These built-in functions perform the operation suggested by the name, and
8037 return the new value. That is,
8038
8039 @smallexample
8040 @{ *ptr @var{op}= value; return *ptr; @}
8041 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
8042 @end smallexample
8043
8044 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
8045 as @code{*ptr = ~(*ptr & value)} instead of
8046 @code{*ptr = ~*ptr & value}.
8047
8048 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8049 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8050 @findex __sync_bool_compare_and_swap
8051 @findex __sync_val_compare_and_swap
8052 These built-in functions perform an atomic compare and swap.
8053 That is, if the current
8054 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
8055 @code{*@var{ptr}}.
8056
8057 The ``bool'' version returns true if the comparison is successful and
8058 @var{newval} is written. The ``val'' version returns the contents
8059 of @code{*@var{ptr}} before the operation.
8060
8061 @item __sync_synchronize (...)
8062 @findex __sync_synchronize
8063 This built-in function issues a full memory barrier.
8064
8065 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
8066 @findex __sync_lock_test_and_set
8067 This built-in function, as described by Intel, is not a traditional test-and-set
8068 operation, but rather an atomic exchange operation. It writes @var{value}
8069 into @code{*@var{ptr}}, and returns the previous contents of
8070 @code{*@var{ptr}}.
8071
8072 Many targets have only minimal support for such locks, and do not support
8073 a full exchange operation. In this case, a target may support reduced
8074 functionality here by which the @emph{only} valid value to store is the
8075 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
8076 is implementation defined.
8077
8078 This built-in function is not a full barrier,
8079 but rather an @dfn{acquire barrier}.
8080 This means that references after the operation cannot move to (or be
8081 speculated to) before the operation, but previous memory stores may not
8082 be globally visible yet, and previous memory loads may not yet be
8083 satisfied.
8084
8085 @item void __sync_lock_release (@var{type} *ptr, ...)
8086 @findex __sync_lock_release
8087 This built-in function releases the lock acquired by
8088 @code{__sync_lock_test_and_set}.
8089 Normally this means writing the constant 0 to @code{*@var{ptr}}.
8090
8091 This built-in function is not a full barrier,
8092 but rather a @dfn{release barrier}.
8093 This means that all previous memory stores are globally visible, and all
8094 previous memory loads have been satisfied, but following memory reads
8095 are not prevented from being speculated to before the barrier.
8096 @end table
8097
8098 @node __atomic Builtins
8099 @section Built-in functions for memory model aware atomic operations
8100
8101 The following built-in functions approximately match the requirements for
8102 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
8103 functions, but all also have a memory model parameter. These are all
8104 identified by being prefixed with @samp{__atomic}, and most are overloaded
8105 such that they work with multiple types.
8106
8107 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
8108 bytes in length. 16-byte integral types are also allowed if
8109 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
8110
8111 Target architectures are encouraged to provide their own patterns for
8112 each of these built-in functions. If no target is provided, the original
8113 non-memory model set of @samp{__sync} atomic built-in functions are
8114 utilized, along with any required synchronization fences surrounding it in
8115 order to achieve the proper behavior. Execution in this case is subject
8116 to the same restrictions as those built-in functions.
8117
8118 If there is no pattern or mechanism to provide a lock free instruction
8119 sequence, a call is made to an external routine with the same parameters
8120 to be resolved at run time.
8121
8122 The four non-arithmetic functions (load, store, exchange, and
8123 compare_exchange) all have a generic version as well. This generic
8124 version works on any data type. If the data type size maps to one
8125 of the integral sizes that may have lock free support, the generic
8126 version utilizes the lock free built-in function. Otherwise an
8127 external call is left to be resolved at run time. This external call is
8128 the same format with the addition of a @samp{size_t} parameter inserted
8129 as the first parameter indicating the size of the object being pointed to.
8130 All objects must be the same size.
8131
8132 There are 6 different memory models that can be specified. These map
8133 to the same names in the C++11 standard. Refer there or to the
8134 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
8135 atomic synchronization} for more detailed definitions. These memory
8136 models integrate both barriers to code motion as well as synchronization
8137 requirements with other threads. These are listed in approximately
8138 ascending order of strength. It is also possible to use target specific
8139 flags for memory model flags, like Hardware Lock Elision.
8140
8141 @table @code
8142 @item __ATOMIC_RELAXED
8143 No barriers or synchronization.
8144 @item __ATOMIC_CONSUME
8145 Data dependency only for both barrier and synchronization with another
8146 thread.
8147 @item __ATOMIC_ACQUIRE
8148 Barrier to hoisting of code and synchronizes with release (or stronger)
8149 semantic stores from another thread.
8150 @item __ATOMIC_RELEASE
8151 Barrier to sinking of code and synchronizes with acquire (or stronger)
8152 semantic loads from another thread.
8153 @item __ATOMIC_ACQ_REL
8154 Full barrier in both directions and synchronizes with acquire loads and
8155 release stores in another thread.
8156 @item __ATOMIC_SEQ_CST
8157 Full barrier in both directions and synchronizes with acquire loads and
8158 release stores in all threads.
8159 @end table
8160
8161 When implementing patterns for these built-in functions, the memory model
8162 parameter can be ignored as long as the pattern implements the most
8163 restrictive @code{__ATOMIC_SEQ_CST} model. Any of the other memory models
8164 execute correctly with this memory model but they may not execute as
8165 efficiently as they could with a more appropriate implementation of the
8166 relaxed requirements.
8167
8168 Note that the C++11 standard allows for the memory model parameter to be
8169 determined at run time rather than at compile time. These built-in
8170 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
8171 than invoke a runtime library call or inline a switch statement. This is
8172 standard compliant, safe, and the simplest approach for now.
8173
8174 The memory model parameter is a signed int, but only the lower 8 bits are
8175 reserved for the memory model. The remainder of the signed int is reserved
8176 for future use and should be 0. Use of the predefined atomic values
8177 ensures proper usage.
8178
8179 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
8180 This built-in function implements an atomic load operation. It returns the
8181 contents of @code{*@var{ptr}}.
8182
8183 The valid memory model variants are
8184 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8185 and @code{__ATOMIC_CONSUME}.
8186
8187 @end deftypefn
8188
8189 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
8190 This is the generic version of an atomic load. It returns the
8191 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
8192
8193 @end deftypefn
8194
8195 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
8196 This built-in function implements an atomic store operation. It writes
8197 @code{@var{val}} into @code{*@var{ptr}}.
8198
8199 The valid memory model variants are
8200 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
8201
8202 @end deftypefn
8203
8204 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
8205 This is the generic version of an atomic store. It stores the value
8206 of @code{*@var{val}} into @code{*@var{ptr}}.
8207
8208 @end deftypefn
8209
8210 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
8211 This built-in function implements an atomic exchange operation. It writes
8212 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
8213 @code{*@var{ptr}}.
8214
8215 The valid memory model variants are
8216 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8217 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
8218
8219 @end deftypefn
8220
8221 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
8222 This is the generic version of an atomic exchange. It stores the
8223 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
8224 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
8225
8226 @end deftypefn
8227
8228 @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)
8229 This built-in function implements an atomic compare and exchange operation.
8230 This compares the contents of @code{*@var{ptr}} with the contents of
8231 @code{*@var{expected}} and if equal, writes @var{desired} into
8232 @code{*@var{ptr}}. If they are not equal, the current contents of
8233 @code{*@var{ptr}} is written into @code{*@var{expected}}. @var{weak} is true
8234 for weak compare_exchange, and false for the strong variation. Many targets
8235 only offer the strong variation and ignore the parameter. When in doubt, use
8236 the strong variation.
8237
8238 True is returned if @var{desired} is written into
8239 @code{*@var{ptr}} and the execution is considered to conform to the
8240 memory model specified by @var{success_memmodel}. There are no
8241 restrictions on what memory model can be used here.
8242
8243 False is returned otherwise, and the execution is considered to conform
8244 to @var{failure_memmodel}. This memory model cannot be
8245 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
8246 stronger model than that specified by @var{success_memmodel}.
8247
8248 @end deftypefn
8249
8250 @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)
8251 This built-in function implements the generic version of
8252 @code{__atomic_compare_exchange}. The function is virtually identical to
8253 @code{__atomic_compare_exchange_n}, except the desired value is also a
8254 pointer.
8255
8256 @end deftypefn
8257
8258 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8259 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8260 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8261 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8262 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8263 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8264 These built-in functions perform the operation suggested by the name, and
8265 return the result of the operation. That is,
8266
8267 @smallexample
8268 @{ *ptr @var{op}= val; return *ptr; @}
8269 @end smallexample
8270
8271 All memory models are valid.
8272
8273 @end deftypefn
8274
8275 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
8276 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
8277 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
8278 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
8279 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
8280 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
8281 These built-in functions perform the operation suggested by the name, and
8282 return the value that had previously been in @code{*@var{ptr}}. That is,
8283
8284 @smallexample
8285 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
8286 @end smallexample
8287
8288 All memory models are valid.
8289
8290 @end deftypefn
8291
8292 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
8293
8294 This built-in function performs an atomic test-and-set operation on
8295 the byte at @code{*@var{ptr}}. The byte is set to some implementation
8296 defined nonzero ``set'' value and the return value is @code{true} if and only
8297 if the previous contents were ``set''.
8298 It should be only used for operands of type @code{bool} or @code{char}. For
8299 other types only part of the value may be set.
8300
8301 All memory models are valid.
8302
8303 @end deftypefn
8304
8305 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
8306
8307 This built-in function performs an atomic clear operation on
8308 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
8309 It should be only used for operands of type @code{bool} or @code{char} and
8310 in conjunction with @code{__atomic_test_and_set}.
8311 For other types it may only clear partially. If the type is not @code{bool}
8312 prefer using @code{__atomic_store}.
8313
8314 The valid memory model variants are
8315 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
8316 @code{__ATOMIC_RELEASE}.
8317
8318 @end deftypefn
8319
8320 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
8321
8322 This built-in function acts as a synchronization fence between threads
8323 based on the specified memory model.
8324
8325 All memory orders are valid.
8326
8327 @end deftypefn
8328
8329 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
8330
8331 This built-in function acts as a synchronization fence between a thread
8332 and signal handlers based in the same thread.
8333
8334 All memory orders are valid.
8335
8336 @end deftypefn
8337
8338 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
8339
8340 This built-in function returns true if objects of @var{size} bytes always
8341 generate lock free atomic instructions for the target architecture.
8342 @var{size} must resolve to a compile-time constant and the result also
8343 resolves to a compile-time constant.
8344
8345 @var{ptr} is an optional pointer to the object that may be used to determine
8346 alignment. A value of 0 indicates typical alignment should be used. The
8347 compiler may also ignore this parameter.
8348
8349 @smallexample
8350 if (_atomic_always_lock_free (sizeof (long long), 0))
8351 @end smallexample
8352
8353 @end deftypefn
8354
8355 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
8356
8357 This built-in function returns true if objects of @var{size} bytes always
8358 generate lock free atomic instructions for the target architecture. If
8359 it is not known to be lock free a call is made to a runtime routine named
8360 @code{__atomic_is_lock_free}.
8361
8362 @var{ptr} is an optional pointer to the object that may be used to determine
8363 alignment. A value of 0 indicates typical alignment should be used. The
8364 compiler may also ignore this parameter.
8365 @end deftypefn
8366
8367 @node x86 specific memory model extensions for transactional memory
8368 @section x86 specific memory model extensions for transactional memory
8369
8370 The i386 architecture supports additional memory ordering flags
8371 to mark lock critical sections for hardware lock elision.
8372 These must be specified in addition to an existing memory model to
8373 atomic intrinsics.
8374
8375 @table @code
8376 @item __ATOMIC_HLE_ACQUIRE
8377 Start lock elision on a lock variable.
8378 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
8379 @item __ATOMIC_HLE_RELEASE
8380 End lock elision on a lock variable.
8381 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
8382 @end table
8383
8384 When a lock acquire fails it is required for good performance to abort
8385 the transaction quickly. This can be done with a @code{_mm_pause}
8386
8387 @smallexample
8388 #include <immintrin.h> // For _mm_pause
8389
8390 int lockvar;
8391
8392 /* Acquire lock with lock elision */
8393 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
8394 _mm_pause(); /* Abort failed transaction */
8395 ...
8396 /* Free lock with lock elision */
8397 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
8398 @end smallexample
8399
8400 @node Object Size Checking
8401 @section Object Size Checking Built-in Functions
8402 @findex __builtin_object_size
8403 @findex __builtin___memcpy_chk
8404 @findex __builtin___mempcpy_chk
8405 @findex __builtin___memmove_chk
8406 @findex __builtin___memset_chk
8407 @findex __builtin___strcpy_chk
8408 @findex __builtin___stpcpy_chk
8409 @findex __builtin___strncpy_chk
8410 @findex __builtin___strcat_chk
8411 @findex __builtin___strncat_chk
8412 @findex __builtin___sprintf_chk
8413 @findex __builtin___snprintf_chk
8414 @findex __builtin___vsprintf_chk
8415 @findex __builtin___vsnprintf_chk
8416 @findex __builtin___printf_chk
8417 @findex __builtin___vprintf_chk
8418 @findex __builtin___fprintf_chk
8419 @findex __builtin___vfprintf_chk
8420
8421 GCC implements a limited buffer overflow protection mechanism
8422 that can prevent some buffer overflow attacks.
8423
8424 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
8425 is a built-in construct that returns a constant number of bytes from
8426 @var{ptr} to the end of the object @var{ptr} pointer points to
8427 (if known at compile time). @code{__builtin_object_size} never evaluates
8428 its arguments for side-effects. If there are any side-effects in them, it
8429 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8430 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
8431 point to and all of them are known at compile time, the returned number
8432 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
8433 0 and minimum if nonzero. If it is not possible to determine which objects
8434 @var{ptr} points to at compile time, @code{__builtin_object_size} should
8435 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8436 for @var{type} 2 or 3.
8437
8438 @var{type} is an integer constant from 0 to 3. If the least significant
8439 bit is clear, objects are whole variables, if it is set, a closest
8440 surrounding subobject is considered the object a pointer points to.
8441 The second bit determines if maximum or minimum of remaining bytes
8442 is computed.
8443
8444 @smallexample
8445 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
8446 char *p = &var.buf1[1], *q = &var.b;
8447
8448 /* Here the object p points to is var. */
8449 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
8450 /* The subobject p points to is var.buf1. */
8451 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
8452 /* The object q points to is var. */
8453 assert (__builtin_object_size (q, 0)
8454 == (char *) (&var + 1) - (char *) &var.b);
8455 /* The subobject q points to is var.b. */
8456 assert (__builtin_object_size (q, 1) == sizeof (var.b));
8457 @end smallexample
8458 @end deftypefn
8459
8460 There are built-in functions added for many common string operation
8461 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
8462 built-in is provided. This built-in has an additional last argument,
8463 which is the number of bytes remaining in object the @var{dest}
8464 argument points to or @code{(size_t) -1} if the size is not known.
8465
8466 The built-in functions are optimized into the normal string functions
8467 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
8468 it is known at compile time that the destination object will not
8469 be overflown. If the compiler can determine at compile time the
8470 object will be always overflown, it issues a warning.
8471
8472 The intended use can be e.g.@:
8473
8474 @smallexample
8475 #undef memcpy
8476 #define bos0(dest) __builtin_object_size (dest, 0)
8477 #define memcpy(dest, src, n) \
8478 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
8479
8480 char *volatile p;
8481 char buf[10];
8482 /* It is unknown what object p points to, so this is optimized
8483 into plain memcpy - no checking is possible. */
8484 memcpy (p, "abcde", n);
8485 /* Destination is known and length too. It is known at compile
8486 time there will be no overflow. */
8487 memcpy (&buf[5], "abcde", 5);
8488 /* Destination is known, but the length is not known at compile time.
8489 This will result in __memcpy_chk call that can check for overflow
8490 at run time. */
8491 memcpy (&buf[5], "abcde", n);
8492 /* Destination is known and it is known at compile time there will
8493 be overflow. There will be a warning and __memcpy_chk call that
8494 will abort the program at run time. */
8495 memcpy (&buf[6], "abcde", 5);
8496 @end smallexample
8497
8498 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
8499 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
8500 @code{strcat} and @code{strncat}.
8501
8502 There are also checking built-in functions for formatted output functions.
8503 @smallexample
8504 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
8505 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8506 const char *fmt, ...);
8507 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
8508 va_list ap);
8509 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8510 const char *fmt, va_list ap);
8511 @end smallexample
8512
8513 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
8514 etc.@: functions and can contain implementation specific flags on what
8515 additional security measures the checking function might take, such as
8516 handling @code{%n} differently.
8517
8518 The @var{os} argument is the object size @var{s} points to, like in the
8519 other built-in functions. There is a small difference in the behavior
8520 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
8521 optimized into the non-checking functions only if @var{flag} is 0, otherwise
8522 the checking function is called with @var{os} argument set to
8523 @code{(size_t) -1}.
8524
8525 In addition to this, there are checking built-in functions
8526 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
8527 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
8528 These have just one additional argument, @var{flag}, right before
8529 format string @var{fmt}. If the compiler is able to optimize them to
8530 @code{fputc} etc.@: functions, it does, otherwise the checking function
8531 is called and the @var{flag} argument passed to it.
8532
8533 @node Cilk Plus Builtins
8534 @section Cilk Plus C/C++ language extension Built-in Functions.
8535
8536 GCC provides support for the following built-in reduction funtions if Cilk Plus
8537 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
8538
8539 @itemize @bullet
8540 @item __sec_implicit_index
8541 @item __sec_reduce
8542 @item __sec_reduce_add
8543 @item __sec_reduce_all_nonzero
8544 @item __sec_reduce_all_zero
8545 @item __sec_reduce_any_nonzero
8546 @item __sec_reduce_any_zero
8547 @item __sec_reduce_max
8548 @item __sec_reduce_min
8549 @item __sec_reduce_max_ind
8550 @item __sec_reduce_min_ind
8551 @item __sec_reduce_mul
8552 @item __sec_reduce_mutating
8553 @end itemize
8554
8555 Further details and examples about these built-in functions are described
8556 in the Cilk Plus language manual which can be found at
8557 @uref{http://www.cilkplus.org}.
8558
8559 @node Other Builtins
8560 @section Other Built-in Functions Provided by GCC
8561 @cindex built-in functions
8562 @findex __builtin_fpclassify
8563 @findex __builtin_isfinite
8564 @findex __builtin_isnormal
8565 @findex __builtin_isgreater
8566 @findex __builtin_isgreaterequal
8567 @findex __builtin_isinf_sign
8568 @findex __builtin_isless
8569 @findex __builtin_islessequal
8570 @findex __builtin_islessgreater
8571 @findex __builtin_isunordered
8572 @findex __builtin_powi
8573 @findex __builtin_powif
8574 @findex __builtin_powil
8575 @findex _Exit
8576 @findex _exit
8577 @findex abort
8578 @findex abs
8579 @findex acos
8580 @findex acosf
8581 @findex acosh
8582 @findex acoshf
8583 @findex acoshl
8584 @findex acosl
8585 @findex alloca
8586 @findex asin
8587 @findex asinf
8588 @findex asinh
8589 @findex asinhf
8590 @findex asinhl
8591 @findex asinl
8592 @findex atan
8593 @findex atan2
8594 @findex atan2f
8595 @findex atan2l
8596 @findex atanf
8597 @findex atanh
8598 @findex atanhf
8599 @findex atanhl
8600 @findex atanl
8601 @findex bcmp
8602 @findex bzero
8603 @findex cabs
8604 @findex cabsf
8605 @findex cabsl
8606 @findex cacos
8607 @findex cacosf
8608 @findex cacosh
8609 @findex cacoshf
8610 @findex cacoshl
8611 @findex cacosl
8612 @findex calloc
8613 @findex carg
8614 @findex cargf
8615 @findex cargl
8616 @findex casin
8617 @findex casinf
8618 @findex casinh
8619 @findex casinhf
8620 @findex casinhl
8621 @findex casinl
8622 @findex catan
8623 @findex catanf
8624 @findex catanh
8625 @findex catanhf
8626 @findex catanhl
8627 @findex catanl
8628 @findex cbrt
8629 @findex cbrtf
8630 @findex cbrtl
8631 @findex ccos
8632 @findex ccosf
8633 @findex ccosh
8634 @findex ccoshf
8635 @findex ccoshl
8636 @findex ccosl
8637 @findex ceil
8638 @findex ceilf
8639 @findex ceill
8640 @findex cexp
8641 @findex cexpf
8642 @findex cexpl
8643 @findex cimag
8644 @findex cimagf
8645 @findex cimagl
8646 @findex clog
8647 @findex clogf
8648 @findex clogl
8649 @findex conj
8650 @findex conjf
8651 @findex conjl
8652 @findex copysign
8653 @findex copysignf
8654 @findex copysignl
8655 @findex cos
8656 @findex cosf
8657 @findex cosh
8658 @findex coshf
8659 @findex coshl
8660 @findex cosl
8661 @findex cpow
8662 @findex cpowf
8663 @findex cpowl
8664 @findex cproj
8665 @findex cprojf
8666 @findex cprojl
8667 @findex creal
8668 @findex crealf
8669 @findex creall
8670 @findex csin
8671 @findex csinf
8672 @findex csinh
8673 @findex csinhf
8674 @findex csinhl
8675 @findex csinl
8676 @findex csqrt
8677 @findex csqrtf
8678 @findex csqrtl
8679 @findex ctan
8680 @findex ctanf
8681 @findex ctanh
8682 @findex ctanhf
8683 @findex ctanhl
8684 @findex ctanl
8685 @findex dcgettext
8686 @findex dgettext
8687 @findex drem
8688 @findex dremf
8689 @findex dreml
8690 @findex erf
8691 @findex erfc
8692 @findex erfcf
8693 @findex erfcl
8694 @findex erff
8695 @findex erfl
8696 @findex exit
8697 @findex exp
8698 @findex exp10
8699 @findex exp10f
8700 @findex exp10l
8701 @findex exp2
8702 @findex exp2f
8703 @findex exp2l
8704 @findex expf
8705 @findex expl
8706 @findex expm1
8707 @findex expm1f
8708 @findex expm1l
8709 @findex fabs
8710 @findex fabsf
8711 @findex fabsl
8712 @findex fdim
8713 @findex fdimf
8714 @findex fdiml
8715 @findex ffs
8716 @findex floor
8717 @findex floorf
8718 @findex floorl
8719 @findex fma
8720 @findex fmaf
8721 @findex fmal
8722 @findex fmax
8723 @findex fmaxf
8724 @findex fmaxl
8725 @findex fmin
8726 @findex fminf
8727 @findex fminl
8728 @findex fmod
8729 @findex fmodf
8730 @findex fmodl
8731 @findex fprintf
8732 @findex fprintf_unlocked
8733 @findex fputs
8734 @findex fputs_unlocked
8735 @findex frexp
8736 @findex frexpf
8737 @findex frexpl
8738 @findex fscanf
8739 @findex gamma
8740 @findex gammaf
8741 @findex gammal
8742 @findex gamma_r
8743 @findex gammaf_r
8744 @findex gammal_r
8745 @findex gettext
8746 @findex hypot
8747 @findex hypotf
8748 @findex hypotl
8749 @findex ilogb
8750 @findex ilogbf
8751 @findex ilogbl
8752 @findex imaxabs
8753 @findex index
8754 @findex isalnum
8755 @findex isalpha
8756 @findex isascii
8757 @findex isblank
8758 @findex iscntrl
8759 @findex isdigit
8760 @findex isgraph
8761 @findex islower
8762 @findex isprint
8763 @findex ispunct
8764 @findex isspace
8765 @findex isupper
8766 @findex iswalnum
8767 @findex iswalpha
8768 @findex iswblank
8769 @findex iswcntrl
8770 @findex iswdigit
8771 @findex iswgraph
8772 @findex iswlower
8773 @findex iswprint
8774 @findex iswpunct
8775 @findex iswspace
8776 @findex iswupper
8777 @findex iswxdigit
8778 @findex isxdigit
8779 @findex j0
8780 @findex j0f
8781 @findex j0l
8782 @findex j1
8783 @findex j1f
8784 @findex j1l
8785 @findex jn
8786 @findex jnf
8787 @findex jnl
8788 @findex labs
8789 @findex ldexp
8790 @findex ldexpf
8791 @findex ldexpl
8792 @findex lgamma
8793 @findex lgammaf
8794 @findex lgammal
8795 @findex lgamma_r
8796 @findex lgammaf_r
8797 @findex lgammal_r
8798 @findex llabs
8799 @findex llrint
8800 @findex llrintf
8801 @findex llrintl
8802 @findex llround
8803 @findex llroundf
8804 @findex llroundl
8805 @findex log
8806 @findex log10
8807 @findex log10f
8808 @findex log10l
8809 @findex log1p
8810 @findex log1pf
8811 @findex log1pl
8812 @findex log2
8813 @findex log2f
8814 @findex log2l
8815 @findex logb
8816 @findex logbf
8817 @findex logbl
8818 @findex logf
8819 @findex logl
8820 @findex lrint
8821 @findex lrintf
8822 @findex lrintl
8823 @findex lround
8824 @findex lroundf
8825 @findex lroundl
8826 @findex malloc
8827 @findex memchr
8828 @findex memcmp
8829 @findex memcpy
8830 @findex mempcpy
8831 @findex memset
8832 @findex modf
8833 @findex modff
8834 @findex modfl
8835 @findex nearbyint
8836 @findex nearbyintf
8837 @findex nearbyintl
8838 @findex nextafter
8839 @findex nextafterf
8840 @findex nextafterl
8841 @findex nexttoward
8842 @findex nexttowardf
8843 @findex nexttowardl
8844 @findex pow
8845 @findex pow10
8846 @findex pow10f
8847 @findex pow10l
8848 @findex powf
8849 @findex powl
8850 @findex printf
8851 @findex printf_unlocked
8852 @findex putchar
8853 @findex puts
8854 @findex remainder
8855 @findex remainderf
8856 @findex remainderl
8857 @findex remquo
8858 @findex remquof
8859 @findex remquol
8860 @findex rindex
8861 @findex rint
8862 @findex rintf
8863 @findex rintl
8864 @findex round
8865 @findex roundf
8866 @findex roundl
8867 @findex scalb
8868 @findex scalbf
8869 @findex scalbl
8870 @findex scalbln
8871 @findex scalblnf
8872 @findex scalblnf
8873 @findex scalbn
8874 @findex scalbnf
8875 @findex scanfnl
8876 @findex signbit
8877 @findex signbitf
8878 @findex signbitl
8879 @findex signbitd32
8880 @findex signbitd64
8881 @findex signbitd128
8882 @findex significand
8883 @findex significandf
8884 @findex significandl
8885 @findex sin
8886 @findex sincos
8887 @findex sincosf
8888 @findex sincosl
8889 @findex sinf
8890 @findex sinh
8891 @findex sinhf
8892 @findex sinhl
8893 @findex sinl
8894 @findex snprintf
8895 @findex sprintf
8896 @findex sqrt
8897 @findex sqrtf
8898 @findex sqrtl
8899 @findex sscanf
8900 @findex stpcpy
8901 @findex stpncpy
8902 @findex strcasecmp
8903 @findex strcat
8904 @findex strchr
8905 @findex strcmp
8906 @findex strcpy
8907 @findex strcspn
8908 @findex strdup
8909 @findex strfmon
8910 @findex strftime
8911 @findex strlen
8912 @findex strncasecmp
8913 @findex strncat
8914 @findex strncmp
8915 @findex strncpy
8916 @findex strndup
8917 @findex strpbrk
8918 @findex strrchr
8919 @findex strspn
8920 @findex strstr
8921 @findex tan
8922 @findex tanf
8923 @findex tanh
8924 @findex tanhf
8925 @findex tanhl
8926 @findex tanl
8927 @findex tgamma
8928 @findex tgammaf
8929 @findex tgammal
8930 @findex toascii
8931 @findex tolower
8932 @findex toupper
8933 @findex towlower
8934 @findex towupper
8935 @findex trunc
8936 @findex truncf
8937 @findex truncl
8938 @findex vfprintf
8939 @findex vfscanf
8940 @findex vprintf
8941 @findex vscanf
8942 @findex vsnprintf
8943 @findex vsprintf
8944 @findex vsscanf
8945 @findex y0
8946 @findex y0f
8947 @findex y0l
8948 @findex y1
8949 @findex y1f
8950 @findex y1l
8951 @findex yn
8952 @findex ynf
8953 @findex ynl
8954
8955 GCC provides a large number of built-in functions other than the ones
8956 mentioned above. Some of these are for internal use in the processing
8957 of exceptions or variable-length argument lists and are not
8958 documented here because they may change from time to time; we do not
8959 recommend general use of these functions.
8960
8961 The remaining functions are provided for optimization purposes.
8962
8963 @opindex fno-builtin
8964 GCC includes built-in versions of many of the functions in the standard
8965 C library. The versions prefixed with @code{__builtin_} are always
8966 treated as having the same meaning as the C library function even if you
8967 specify the @option{-fno-builtin} option. (@pxref{C Dialect Options})
8968 Many of these functions are only optimized in certain cases; if they are
8969 not optimized in a particular case, a call to the library function is
8970 emitted.
8971
8972 @opindex ansi
8973 @opindex std
8974 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
8975 @option{-std=c99} or @option{-std=c11}), the functions
8976 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
8977 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
8978 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
8979 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
8980 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
8981 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
8982 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
8983 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
8984 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
8985 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
8986 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
8987 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
8988 @code{signbitd64}, @code{signbitd128}, @code{significandf},
8989 @code{significandl}, @code{significand}, @code{sincosf},
8990 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
8991 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
8992 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
8993 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
8994 @code{yn}
8995 may be handled as built-in functions.
8996 All these functions have corresponding versions
8997 prefixed with @code{__builtin_}, which may be used even in strict C90
8998 mode.
8999
9000 The ISO C99 functions
9001 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
9002 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
9003 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
9004 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
9005 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
9006 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
9007 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
9008 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
9009 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
9010 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
9011 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
9012 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
9013 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
9014 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
9015 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
9016 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
9017 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
9018 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
9019 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
9020 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
9021 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
9022 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
9023 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
9024 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
9025 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
9026 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
9027 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
9028 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
9029 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
9030 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
9031 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
9032 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
9033 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
9034 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
9035 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
9036 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
9037 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
9038 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
9039 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
9040 are handled as built-in functions
9041 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9042
9043 There are also built-in versions of the ISO C99 functions
9044 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
9045 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
9046 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
9047 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
9048 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
9049 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
9050 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
9051 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
9052 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
9053 that are recognized in any mode since ISO C90 reserves these names for
9054 the purpose to which ISO C99 puts them. All these functions have
9055 corresponding versions prefixed with @code{__builtin_}.
9056
9057 The ISO C94 functions
9058 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
9059 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
9060 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
9061 @code{towupper}
9062 are handled as built-in functions
9063 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9064
9065 The ISO C90 functions
9066 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
9067 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
9068 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
9069 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
9070 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
9071 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
9072 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
9073 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
9074 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
9075 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
9076 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
9077 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
9078 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
9079 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
9080 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
9081 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
9082 are all recognized as built-in functions unless
9083 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
9084 is specified for an individual function). All of these functions have
9085 corresponding versions prefixed with @code{__builtin_}.
9086
9087 GCC provides built-in versions of the ISO C99 floating-point comparison
9088 macros that avoid raising exceptions for unordered operands. They have
9089 the same names as the standard macros ( @code{isgreater},
9090 @code{isgreaterequal}, @code{isless}, @code{islessequal},
9091 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
9092 prefixed. We intend for a library implementor to be able to simply
9093 @code{#define} each standard macro to its built-in equivalent.
9094 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
9095 @code{isinf_sign} and @code{isnormal} built-ins used with
9096 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
9097 built-in functions appear both with and without the @code{__builtin_} prefix.
9098
9099 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
9100
9101 You can use the built-in function @code{__builtin_types_compatible_p} to
9102 determine whether two types are the same.
9103
9104 This built-in function returns 1 if the unqualified versions of the
9105 types @var{type1} and @var{type2} (which are types, not expressions) are
9106 compatible, 0 otherwise. The result of this built-in function can be
9107 used in integer constant expressions.
9108
9109 This built-in function ignores top level qualifiers (e.g., @code{const},
9110 @code{volatile}). For example, @code{int} is equivalent to @code{const
9111 int}.
9112
9113 The type @code{int[]} and @code{int[5]} are compatible. On the other
9114 hand, @code{int} and @code{char *} are not compatible, even if the size
9115 of their types, on the particular architecture are the same. Also, the
9116 amount of pointer indirection is taken into account when determining
9117 similarity. Consequently, @code{short *} is not similar to
9118 @code{short **}. Furthermore, two types that are typedefed are
9119 considered compatible if their underlying types are compatible.
9120
9121 An @code{enum} type is not considered to be compatible with another
9122 @code{enum} type even if both are compatible with the same integer
9123 type; this is what the C standard specifies.
9124 For example, @code{enum @{foo, bar@}} is not similar to
9125 @code{enum @{hot, dog@}}.
9126
9127 You typically use this function in code whose execution varies
9128 depending on the arguments' types. For example:
9129
9130 @smallexample
9131 #define foo(x) \
9132 (@{ \
9133 typeof (x) tmp = (x); \
9134 if (__builtin_types_compatible_p (typeof (x), long double)) \
9135 tmp = foo_long_double (tmp); \
9136 else if (__builtin_types_compatible_p (typeof (x), double)) \
9137 tmp = foo_double (tmp); \
9138 else if (__builtin_types_compatible_p (typeof (x), float)) \
9139 tmp = foo_float (tmp); \
9140 else \
9141 abort (); \
9142 tmp; \
9143 @})
9144 @end smallexample
9145
9146 @emph{Note:} This construct is only available for C@.
9147
9148 @end deftypefn
9149
9150 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
9151
9152 You can use the built-in function @code{__builtin_choose_expr} to
9153 evaluate code depending on the value of a constant expression. This
9154 built-in function returns @var{exp1} if @var{const_exp}, which is an
9155 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
9156
9157 This built-in function is analogous to the @samp{? :} operator in C,
9158 except that the expression returned has its type unaltered by promotion
9159 rules. Also, the built-in function does not evaluate the expression
9160 that is not chosen. For example, if @var{const_exp} evaluates to true,
9161 @var{exp2} is not evaluated even if it has side-effects.
9162
9163 This built-in function can return an lvalue if the chosen argument is an
9164 lvalue.
9165
9166 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
9167 type. Similarly, if @var{exp2} is returned, its return type is the same
9168 as @var{exp2}.
9169
9170 Example:
9171
9172 @smallexample
9173 #define foo(x) \
9174 __builtin_choose_expr ( \
9175 __builtin_types_compatible_p (typeof (x), double), \
9176 foo_double (x), \
9177 __builtin_choose_expr ( \
9178 __builtin_types_compatible_p (typeof (x), float), \
9179 foo_float (x), \
9180 /* @r{The void expression results in a compile-time error} \
9181 @r{when assigning the result to something.} */ \
9182 (void)0))
9183 @end smallexample
9184
9185 @emph{Note:} This construct is only available for C@. Furthermore, the
9186 unused expression (@var{exp1} or @var{exp2} depending on the value of
9187 @var{const_exp}) may still generate syntax errors. This may change in
9188 future revisions.
9189
9190 @end deftypefn
9191
9192 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
9193
9194 The built-in function @code{__builtin_complex} is provided for use in
9195 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
9196 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
9197 real binary floating-point type, and the result has the corresponding
9198 complex type with real and imaginary parts @var{real} and @var{imag}.
9199 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
9200 infinities, NaNs and negative zeros are involved.
9201
9202 @end deftypefn
9203
9204 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
9205 You can use the built-in function @code{__builtin_constant_p} to
9206 determine if a value is known to be constant at compile time and hence
9207 that GCC can perform constant-folding on expressions involving that
9208 value. The argument of the function is the value to test. The function
9209 returns the integer 1 if the argument is known to be a compile-time
9210 constant and 0 if it is not known to be a compile-time constant. A
9211 return of 0 does not indicate that the value is @emph{not} a constant,
9212 but merely that GCC cannot prove it is a constant with the specified
9213 value of the @option{-O} option.
9214
9215 You typically use this function in an embedded application where
9216 memory is a critical resource. If you have some complex calculation,
9217 you may want it to be folded if it involves constants, but need to call
9218 a function if it does not. For example:
9219
9220 @smallexample
9221 #define Scale_Value(X) \
9222 (__builtin_constant_p (X) \
9223 ? ((X) * SCALE + OFFSET) : Scale (X))
9224 @end smallexample
9225
9226 You may use this built-in function in either a macro or an inline
9227 function. However, if you use it in an inlined function and pass an
9228 argument of the function as the argument to the built-in, GCC
9229 never returns 1 when you call the inline function with a string constant
9230 or compound literal (@pxref{Compound Literals}) and does not return 1
9231 when you pass a constant numeric value to the inline function unless you
9232 specify the @option{-O} option.
9233
9234 You may also use @code{__builtin_constant_p} in initializers for static
9235 data. For instance, you can write
9236
9237 @smallexample
9238 static const int table[] = @{
9239 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
9240 /* @r{@dots{}} */
9241 @};
9242 @end smallexample
9243
9244 @noindent
9245 This is an acceptable initializer even if @var{EXPRESSION} is not a
9246 constant expression, including the case where
9247 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
9248 folded to a constant but @var{EXPRESSION} contains operands that are
9249 not otherwise permitted in a static initializer (for example,
9250 @code{0 && foo ()}). GCC must be more conservative about evaluating the
9251 built-in in this case, because it has no opportunity to perform
9252 optimization.
9253
9254 Previous versions of GCC did not accept this built-in in data
9255 initializers. The earliest version where it is completely safe is
9256 3.0.1.
9257 @end deftypefn
9258
9259 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
9260 @opindex fprofile-arcs
9261 You may use @code{__builtin_expect} to provide the compiler with
9262 branch prediction information. In general, you should prefer to
9263 use actual profile feedback for this (@option{-fprofile-arcs}), as
9264 programmers are notoriously bad at predicting how their programs
9265 actually perform. However, there are applications in which this
9266 data is hard to collect.
9267
9268 The return value is the value of @var{exp}, which should be an integral
9269 expression. The semantics of the built-in are that it is expected that
9270 @var{exp} == @var{c}. For example:
9271
9272 @smallexample
9273 if (__builtin_expect (x, 0))
9274 foo ();
9275 @end smallexample
9276
9277 @noindent
9278 indicates that we do not expect to call @code{foo}, since
9279 we expect @code{x} to be zero. Since you are limited to integral
9280 expressions for @var{exp}, you should use constructions such as
9281
9282 @smallexample
9283 if (__builtin_expect (ptr != NULL, 1))
9284 foo (*ptr);
9285 @end smallexample
9286
9287 @noindent
9288 when testing pointer or floating-point values.
9289 @end deftypefn
9290
9291 @deftypefn {Built-in Function} void __builtin_trap (void)
9292 This function causes the program to exit abnormally. GCC implements
9293 this function by using a target-dependent mechanism (such as
9294 intentionally executing an illegal instruction) or by calling
9295 @code{abort}. The mechanism used may vary from release to release so
9296 you should not rely on any particular implementation.
9297 @end deftypefn
9298
9299 @deftypefn {Built-in Function} void __builtin_unreachable (void)
9300 If control flow reaches the point of the @code{__builtin_unreachable},
9301 the program is undefined. It is useful in situations where the
9302 compiler cannot deduce the unreachability of the code.
9303
9304 One such case is immediately following an @code{asm} statement that
9305 either never terminates, or one that transfers control elsewhere
9306 and never returns. In this example, without the
9307 @code{__builtin_unreachable}, GCC issues a warning that control
9308 reaches the end of a non-void function. It also generates code
9309 to return after the @code{asm}.
9310
9311 @smallexample
9312 int f (int c, int v)
9313 @{
9314 if (c)
9315 @{
9316 return v;
9317 @}
9318 else
9319 @{
9320 asm("jmp error_handler");
9321 __builtin_unreachable ();
9322 @}
9323 @}
9324 @end smallexample
9325
9326 @noindent
9327 Because the @code{asm} statement unconditionally transfers control out
9328 of the function, control never reaches the end of the function
9329 body. The @code{__builtin_unreachable} is in fact unreachable and
9330 communicates this fact to the compiler.
9331
9332 Another use for @code{__builtin_unreachable} is following a call a
9333 function that never returns but that is not declared
9334 @code{__attribute__((noreturn))}, as in this example:
9335
9336 @smallexample
9337 void function_that_never_returns (void);
9338
9339 int g (int c)
9340 @{
9341 if (c)
9342 @{
9343 return 1;
9344 @}
9345 else
9346 @{
9347 function_that_never_returns ();
9348 __builtin_unreachable ();
9349 @}
9350 @}
9351 @end smallexample
9352
9353 @end deftypefn
9354
9355 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
9356 This function returns its first argument, and allows the compiler
9357 to assume that the returned pointer is at least @var{align} bytes
9358 aligned. This built-in can have either two or three arguments,
9359 if it has three, the third argument should have integer type, and
9360 if it is nonzero means misalignment offset. For example:
9361
9362 @smallexample
9363 void *x = __builtin_assume_aligned (arg, 16);
9364 @end smallexample
9365
9366 @noindent
9367 means that the compiler can assume @code{x}, set to @code{arg}, is at least
9368 16-byte aligned, while:
9369
9370 @smallexample
9371 void *x = __builtin_assume_aligned (arg, 32, 8);
9372 @end smallexample
9373
9374 @noindent
9375 means that the compiler can assume for @code{x}, set to @code{arg}, that
9376 @code{(char *) x - 8} is 32-byte aligned.
9377 @end deftypefn
9378
9379 @deftypefn {Built-in Function} int __builtin_LINE ()
9380 This function is the equivalent to the preprocessor @code{__LINE__}
9381 macro and returns the line number of the invocation of the built-in.
9382 In a C++ default argument for a function @var{F}, it gets the line number of
9383 the call to @var{F}.
9384 @end deftypefn
9385
9386 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
9387 This function is the equivalent to the preprocessor @code{__FUNCTION__}
9388 macro and returns the function name the invocation of the built-in is in.
9389 @end deftypefn
9390
9391 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
9392 This function is the equivalent to the preprocessor @code{__FILE__}
9393 macro and returns the file name the invocation of the built-in is in.
9394 In a C++ default argument for a function @var{F}, it gets the file name of
9395 the call to @var{F}.
9396 @end deftypefn
9397
9398 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
9399 This function is used to flush the processor's instruction cache for
9400 the region of memory between @var{begin} inclusive and @var{end}
9401 exclusive. Some targets require that the instruction cache be
9402 flushed, after modifying memory containing code, in order to obtain
9403 deterministic behavior.
9404
9405 If the target does not require instruction cache flushes,
9406 @code{__builtin___clear_cache} has no effect. Otherwise either
9407 instructions are emitted in-line to clear the instruction cache or a
9408 call to the @code{__clear_cache} function in libgcc is made.
9409 @end deftypefn
9410
9411 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
9412 This function is used to minimize cache-miss latency by moving data into
9413 a cache before it is accessed.
9414 You can insert calls to @code{__builtin_prefetch} into code for which
9415 you know addresses of data in memory that is likely to be accessed soon.
9416 If the target supports them, data prefetch instructions are generated.
9417 If the prefetch is done early enough before the access then the data will
9418 be in the cache by the time it is accessed.
9419
9420 The value of @var{addr} is the address of the memory to prefetch.
9421 There are two optional arguments, @var{rw} and @var{locality}.
9422 The value of @var{rw} is a compile-time constant one or zero; one
9423 means that the prefetch is preparing for a write to the memory address
9424 and zero, the default, means that the prefetch is preparing for a read.
9425 The value @var{locality} must be a compile-time constant integer between
9426 zero and three. A value of zero means that the data has no temporal
9427 locality, so it need not be left in the cache after the access. A value
9428 of three means that the data has a high degree of temporal locality and
9429 should be left in all levels of cache possible. Values of one and two
9430 mean, respectively, a low or moderate degree of temporal locality. The
9431 default is three.
9432
9433 @smallexample
9434 for (i = 0; i < n; i++)
9435 @{
9436 a[i] = a[i] + b[i];
9437 __builtin_prefetch (&a[i+j], 1, 1);
9438 __builtin_prefetch (&b[i+j], 0, 1);
9439 /* @r{@dots{}} */
9440 @}
9441 @end smallexample
9442
9443 Data prefetch does not generate faults if @var{addr} is invalid, but
9444 the address expression itself must be valid. For example, a prefetch
9445 of @code{p->next} does not fault if @code{p->next} is not a valid
9446 address, but evaluation faults if @code{p} is not a valid address.
9447
9448 If the target does not support data prefetch, the address expression
9449 is evaluated if it includes side effects but no other code is generated
9450 and GCC does not issue a warning.
9451 @end deftypefn
9452
9453 @deftypefn {Built-in Function} double __builtin_huge_val (void)
9454 Returns a positive infinity, if supported by the floating-point format,
9455 else @code{DBL_MAX}. This function is suitable for implementing the
9456 ISO C macro @code{HUGE_VAL}.
9457 @end deftypefn
9458
9459 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
9460 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
9461 @end deftypefn
9462
9463 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
9464 Similar to @code{__builtin_huge_val}, except the return
9465 type is @code{long double}.
9466 @end deftypefn
9467
9468 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
9469 This built-in implements the C99 fpclassify functionality. The first
9470 five int arguments should be the target library's notion of the
9471 possible FP classes and are used for return values. They must be
9472 constant values and they must appear in this order: @code{FP_NAN},
9473 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
9474 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
9475 to classify. GCC treats the last argument as type-generic, which
9476 means it does not do default promotion from float to double.
9477 @end deftypefn
9478
9479 @deftypefn {Built-in Function} double __builtin_inf (void)
9480 Similar to @code{__builtin_huge_val}, except a warning is generated
9481 if the target floating-point format does not support infinities.
9482 @end deftypefn
9483
9484 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
9485 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
9486 @end deftypefn
9487
9488 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
9489 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
9490 @end deftypefn
9491
9492 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
9493 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
9494 @end deftypefn
9495
9496 @deftypefn {Built-in Function} float __builtin_inff (void)
9497 Similar to @code{__builtin_inf}, except the return type is @code{float}.
9498 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
9499 @end deftypefn
9500
9501 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
9502 Similar to @code{__builtin_inf}, except the return
9503 type is @code{long double}.
9504 @end deftypefn
9505
9506 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
9507 Similar to @code{isinf}, except the return value is -1 for
9508 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
9509 Note while the parameter list is an
9510 ellipsis, this function only accepts exactly one floating-point
9511 argument. GCC treats this parameter as type-generic, which means it
9512 does not do default promotion from float to double.
9513 @end deftypefn
9514
9515 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
9516 This is an implementation of the ISO C99 function @code{nan}.
9517
9518 Since ISO C99 defines this function in terms of @code{strtod}, which we
9519 do not implement, a description of the parsing is in order. The string
9520 is parsed as by @code{strtol}; that is, the base is recognized by
9521 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
9522 in the significand such that the least significant bit of the number
9523 is at the least significant bit of the significand. The number is
9524 truncated to fit the significand field provided. The significand is
9525 forced to be a quiet NaN@.
9526
9527 This function, if given a string literal all of which would have been
9528 consumed by @code{strtol}, is evaluated early enough that it is considered a
9529 compile-time constant.
9530 @end deftypefn
9531
9532 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
9533 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
9534 @end deftypefn
9535
9536 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
9537 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
9538 @end deftypefn
9539
9540 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
9541 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
9542 @end deftypefn
9543
9544 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
9545 Similar to @code{__builtin_nan}, except the return type is @code{float}.
9546 @end deftypefn
9547
9548 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
9549 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
9550 @end deftypefn
9551
9552 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
9553 Similar to @code{__builtin_nan}, except the significand is forced
9554 to be a signaling NaN@. The @code{nans} function is proposed by
9555 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
9556 @end deftypefn
9557
9558 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
9559 Similar to @code{__builtin_nans}, except the return type is @code{float}.
9560 @end deftypefn
9561
9562 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
9563 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
9564 @end deftypefn
9565
9566 @deftypefn {Built-in Function} int __builtin_ffs (int x)
9567 Returns one plus the index of the least significant 1-bit of @var{x}, or
9568 if @var{x} is zero, returns zero.
9569 @end deftypefn
9570
9571 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
9572 Returns the number of leading 0-bits in @var{x}, starting at the most
9573 significant bit position. If @var{x} is 0, the result is undefined.
9574 @end deftypefn
9575
9576 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
9577 Returns the number of trailing 0-bits in @var{x}, starting at the least
9578 significant bit position. If @var{x} is 0, the result is undefined.
9579 @end deftypefn
9580
9581 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
9582 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
9583 number of bits following the most significant bit that are identical
9584 to it. There are no special cases for 0 or other values.
9585 @end deftypefn
9586
9587 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
9588 Returns the number of 1-bits in @var{x}.
9589 @end deftypefn
9590
9591 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
9592 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
9593 modulo 2.
9594 @end deftypefn
9595
9596 @deftypefn {Built-in Function} int __builtin_ffsl (long)
9597 Similar to @code{__builtin_ffs}, except the argument type is
9598 @code{long}.
9599 @end deftypefn
9600
9601 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
9602 Similar to @code{__builtin_clz}, except the argument type is
9603 @code{unsigned long}.
9604 @end deftypefn
9605
9606 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
9607 Similar to @code{__builtin_ctz}, except the argument type is
9608 @code{unsigned long}.
9609 @end deftypefn
9610
9611 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
9612 Similar to @code{__builtin_clrsb}, except the argument type is
9613 @code{long}.
9614 @end deftypefn
9615
9616 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
9617 Similar to @code{__builtin_popcount}, except the argument type is
9618 @code{unsigned long}.
9619 @end deftypefn
9620
9621 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
9622 Similar to @code{__builtin_parity}, except the argument type is
9623 @code{unsigned long}.
9624 @end deftypefn
9625
9626 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
9627 Similar to @code{__builtin_ffs}, except the argument type is
9628 @code{long long}.
9629 @end deftypefn
9630
9631 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
9632 Similar to @code{__builtin_clz}, except the argument type is
9633 @code{unsigned long long}.
9634 @end deftypefn
9635
9636 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
9637 Similar to @code{__builtin_ctz}, except the argument type is
9638 @code{unsigned long long}.
9639 @end deftypefn
9640
9641 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
9642 Similar to @code{__builtin_clrsb}, except the argument type is
9643 @code{long long}.
9644 @end deftypefn
9645
9646 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
9647 Similar to @code{__builtin_popcount}, except the argument type is
9648 @code{unsigned long long}.
9649 @end deftypefn
9650
9651 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
9652 Similar to @code{__builtin_parity}, except the argument type is
9653 @code{unsigned long long}.
9654 @end deftypefn
9655
9656 @deftypefn {Built-in Function} double __builtin_powi (double, int)
9657 Returns the first argument raised to the power of the second. Unlike the
9658 @code{pow} function no guarantees about precision and rounding are made.
9659 @end deftypefn
9660
9661 @deftypefn {Built-in Function} float __builtin_powif (float, int)
9662 Similar to @code{__builtin_powi}, except the argument and return types
9663 are @code{float}.
9664 @end deftypefn
9665
9666 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
9667 Similar to @code{__builtin_powi}, except the argument and return types
9668 are @code{long double}.
9669 @end deftypefn
9670
9671 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
9672 Returns @var{x} with the order of the bytes reversed; for example,
9673 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
9674 exactly 8 bits.
9675 @end deftypefn
9676
9677 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
9678 Similar to @code{__builtin_bswap16}, except the argument and return types
9679 are 32 bit.
9680 @end deftypefn
9681
9682 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
9683 Similar to @code{__builtin_bswap32}, except the argument and return types
9684 are 64 bit.
9685 @end deftypefn
9686
9687 @node Target Builtins
9688 @section Built-in Functions Specific to Particular Target Machines
9689
9690 On some target machines, GCC supports many built-in functions specific
9691 to those machines. Generally these generate calls to specific machine
9692 instructions, but allow the compiler to schedule those calls.
9693
9694 @menu
9695 * AArch64 Built-in Functions::
9696 * Alpha Built-in Functions::
9697 * Altera Nios II Built-in Functions::
9698 * ARC Built-in Functions::
9699 * ARC SIMD Built-in Functions::
9700 * ARM iWMMXt Built-in Functions::
9701 * ARM NEON Intrinsics::
9702 * ARM ACLE Intrinsics::
9703 * AVR Built-in Functions::
9704 * Blackfin Built-in Functions::
9705 * FR-V Built-in Functions::
9706 * X86 Built-in Functions::
9707 * X86 transactional memory intrinsics::
9708 * MIPS DSP Built-in Functions::
9709 * MIPS Paired-Single Support::
9710 * MIPS Loongson Built-in Functions::
9711 * Other MIPS Built-in Functions::
9712 * MSP430 Built-in Functions::
9713 * NDS32 Built-in Functions::
9714 * picoChip Built-in Functions::
9715 * PowerPC Built-in Functions::
9716 * PowerPC AltiVec/VSX Built-in Functions::
9717 * PowerPC Hardware Transactional Memory Built-in Functions::
9718 * RX Built-in Functions::
9719 * S/390 System z Built-in Functions::
9720 * SH Built-in Functions::
9721 * SPARC VIS Built-in Functions::
9722 * SPU Built-in Functions::
9723 * TI C6X Built-in Functions::
9724 * TILE-Gx Built-in Functions::
9725 * TILEPro Built-in Functions::
9726 @end menu
9727
9728 @node AArch64 Built-in Functions
9729 @subsection AArch64 Built-in Functions
9730
9731 These built-in functions are available for the AArch64 family of
9732 processors.
9733 @smallexample
9734 unsigned int __builtin_aarch64_get_fpcr ()
9735 void __builtin_aarch64_set_fpcr (unsigned int)
9736 unsigned int __builtin_aarch64_get_fpsr ()
9737 void __builtin_aarch64_set_fpsr (unsigned int)
9738 @end smallexample
9739
9740 @node Alpha Built-in Functions
9741 @subsection Alpha Built-in Functions
9742
9743 These built-in functions are available for the Alpha family of
9744 processors, depending on the command-line switches used.
9745
9746 The following built-in functions are always available. They
9747 all generate the machine instruction that is part of the name.
9748
9749 @smallexample
9750 long __builtin_alpha_implver (void)
9751 long __builtin_alpha_rpcc (void)
9752 long __builtin_alpha_amask (long)
9753 long __builtin_alpha_cmpbge (long, long)
9754 long __builtin_alpha_extbl (long, long)
9755 long __builtin_alpha_extwl (long, long)
9756 long __builtin_alpha_extll (long, long)
9757 long __builtin_alpha_extql (long, long)
9758 long __builtin_alpha_extwh (long, long)
9759 long __builtin_alpha_extlh (long, long)
9760 long __builtin_alpha_extqh (long, long)
9761 long __builtin_alpha_insbl (long, long)
9762 long __builtin_alpha_inswl (long, long)
9763 long __builtin_alpha_insll (long, long)
9764 long __builtin_alpha_insql (long, long)
9765 long __builtin_alpha_inswh (long, long)
9766 long __builtin_alpha_inslh (long, long)
9767 long __builtin_alpha_insqh (long, long)
9768 long __builtin_alpha_mskbl (long, long)
9769 long __builtin_alpha_mskwl (long, long)
9770 long __builtin_alpha_mskll (long, long)
9771 long __builtin_alpha_mskql (long, long)
9772 long __builtin_alpha_mskwh (long, long)
9773 long __builtin_alpha_msklh (long, long)
9774 long __builtin_alpha_mskqh (long, long)
9775 long __builtin_alpha_umulh (long, long)
9776 long __builtin_alpha_zap (long, long)
9777 long __builtin_alpha_zapnot (long, long)
9778 @end smallexample
9779
9780 The following built-in functions are always with @option{-mmax}
9781 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
9782 later. They all generate the machine instruction that is part
9783 of the name.
9784
9785 @smallexample
9786 long __builtin_alpha_pklb (long)
9787 long __builtin_alpha_pkwb (long)
9788 long __builtin_alpha_unpkbl (long)
9789 long __builtin_alpha_unpkbw (long)
9790 long __builtin_alpha_minub8 (long, long)
9791 long __builtin_alpha_minsb8 (long, long)
9792 long __builtin_alpha_minuw4 (long, long)
9793 long __builtin_alpha_minsw4 (long, long)
9794 long __builtin_alpha_maxub8 (long, long)
9795 long __builtin_alpha_maxsb8 (long, long)
9796 long __builtin_alpha_maxuw4 (long, long)
9797 long __builtin_alpha_maxsw4 (long, long)
9798 long __builtin_alpha_perr (long, long)
9799 @end smallexample
9800
9801 The following built-in functions are always with @option{-mcix}
9802 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
9803 later. They all generate the machine instruction that is part
9804 of the name.
9805
9806 @smallexample
9807 long __builtin_alpha_cttz (long)
9808 long __builtin_alpha_ctlz (long)
9809 long __builtin_alpha_ctpop (long)
9810 @end smallexample
9811
9812 The following built-in functions are available on systems that use the OSF/1
9813 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
9814 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
9815 @code{rdval} and @code{wrval}.
9816
9817 @smallexample
9818 void *__builtin_thread_pointer (void)
9819 void __builtin_set_thread_pointer (void *)
9820 @end smallexample
9821
9822 @node Altera Nios II Built-in Functions
9823 @subsection Altera Nios II Built-in Functions
9824
9825 These built-in functions are available for the Altera Nios II
9826 family of processors.
9827
9828 The following built-in functions are always available. They
9829 all generate the machine instruction that is part of the name.
9830
9831 @example
9832 int __builtin_ldbio (volatile const void *)
9833 int __builtin_ldbuio (volatile const void *)
9834 int __builtin_ldhio (volatile const void *)
9835 int __builtin_ldhuio (volatile const void *)
9836 int __builtin_ldwio (volatile const void *)
9837 void __builtin_stbio (volatile void *, int)
9838 void __builtin_sthio (volatile void *, int)
9839 void __builtin_stwio (volatile void *, int)
9840 void __builtin_sync (void)
9841 int __builtin_rdctl (int)
9842 void __builtin_wrctl (int, int)
9843 @end example
9844
9845 The following built-in functions are always available. They
9846 all generate a Nios II Custom Instruction. The name of the
9847 function represents the types that the function takes and
9848 returns. The letter before the @code{n} is the return type
9849 or void if absent. The @code{n} represents the first parameter
9850 to all the custom instructions, the custom instruction number.
9851 The two letters after the @code{n} represent the up to two
9852 parameters to the function.
9853
9854 The letters represent the following data types:
9855 @table @code
9856 @item <no letter>
9857 @code{void} for return type and no parameter for parameter types.
9858
9859 @item i
9860 @code{int} for return type and parameter type
9861
9862 @item f
9863 @code{float} for return type and parameter type
9864
9865 @item p
9866 @code{void *} for return type and parameter type
9867
9868 @end table
9869
9870 And the function names are:
9871 @example
9872 void __builtin_custom_n (void)
9873 void __builtin_custom_ni (int)
9874 void __builtin_custom_nf (float)
9875 void __builtin_custom_np (void *)
9876 void __builtin_custom_nii (int, int)
9877 void __builtin_custom_nif (int, float)
9878 void __builtin_custom_nip (int, void *)
9879 void __builtin_custom_nfi (float, int)
9880 void __builtin_custom_nff (float, float)
9881 void __builtin_custom_nfp (float, void *)
9882 void __builtin_custom_npi (void *, int)
9883 void __builtin_custom_npf (void *, float)
9884 void __builtin_custom_npp (void *, void *)
9885 int __builtin_custom_in (void)
9886 int __builtin_custom_ini (int)
9887 int __builtin_custom_inf (float)
9888 int __builtin_custom_inp (void *)
9889 int __builtin_custom_inii (int, int)
9890 int __builtin_custom_inif (int, float)
9891 int __builtin_custom_inip (int, void *)
9892 int __builtin_custom_infi (float, int)
9893 int __builtin_custom_inff (float, float)
9894 int __builtin_custom_infp (float, void *)
9895 int __builtin_custom_inpi (void *, int)
9896 int __builtin_custom_inpf (void *, float)
9897 int __builtin_custom_inpp (void *, void *)
9898 float __builtin_custom_fn (void)
9899 float __builtin_custom_fni (int)
9900 float __builtin_custom_fnf (float)
9901 float __builtin_custom_fnp (void *)
9902 float __builtin_custom_fnii (int, int)
9903 float __builtin_custom_fnif (int, float)
9904 float __builtin_custom_fnip (int, void *)
9905 float __builtin_custom_fnfi (float, int)
9906 float __builtin_custom_fnff (float, float)
9907 float __builtin_custom_fnfp (float, void *)
9908 float __builtin_custom_fnpi (void *, int)
9909 float __builtin_custom_fnpf (void *, float)
9910 float __builtin_custom_fnpp (void *, void *)
9911 void * __builtin_custom_pn (void)
9912 void * __builtin_custom_pni (int)
9913 void * __builtin_custom_pnf (float)
9914 void * __builtin_custom_pnp (void *)
9915 void * __builtin_custom_pnii (int, int)
9916 void * __builtin_custom_pnif (int, float)
9917 void * __builtin_custom_pnip (int, void *)
9918 void * __builtin_custom_pnfi (float, int)
9919 void * __builtin_custom_pnff (float, float)
9920 void * __builtin_custom_pnfp (float, void *)
9921 void * __builtin_custom_pnpi (void *, int)
9922 void * __builtin_custom_pnpf (void *, float)
9923 void * __builtin_custom_pnpp (void *, void *)
9924 @end example
9925
9926 @node ARC Built-in Functions
9927 @subsection ARC Built-in Functions
9928
9929 The following built-in functions are provided for ARC targets. The
9930 built-ins generate the corresponding assembly instructions. In the
9931 examples given below, the generated code often requires an operand or
9932 result to be in a register. Where necessary further code will be
9933 generated to ensure this is true, but for brevity this is not
9934 described in each case.
9935
9936 @emph{Note:} Using a built-in to generate an instruction not supported
9937 by a target may cause problems. At present the compiler is not
9938 guaranteed to detect such misuse, and as a result an internal compiler
9939 error may be generated.
9940
9941 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
9942 Return 1 if @var{val} is known to have the byte alignment given
9943 by @var{alignval}, otherwise return 0.
9944 Note that this is different from
9945 @smallexample
9946 __alignof__(*(char *)@var{val}) >= alignval
9947 @end smallexample
9948 because __alignof__ sees only the type of the dereference, whereas
9949 __builtin_arc_align uses alignment information from the pointer
9950 as well as from the pointed-to type.
9951 The information available will depend on optimization level.
9952 @end deftypefn
9953
9954 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
9955 Generates
9956 @example
9957 brk
9958 @end example
9959 @end deftypefn
9960
9961 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
9962 The operand is the number of a register to be read. Generates:
9963 @example
9964 mov @var{dest}, r@var{regno}
9965 @end example
9966 where the value in @var{dest} will be the result returned from the
9967 built-in.
9968 @end deftypefn
9969
9970 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
9971 The first operand is the number of a register to be written, the
9972 second operand is a compile time constant to write into that
9973 register. Generates:
9974 @example
9975 mov r@var{regno}, @var{val}
9976 @end example
9977 @end deftypefn
9978
9979 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
9980 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
9981 Generates:
9982 @example
9983 divaw @var{dest}, @var{a}, @var{b}
9984 @end example
9985 where the value in @var{dest} will be the result returned from the
9986 built-in.
9987 @end deftypefn
9988
9989 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
9990 Generates
9991 @example
9992 flag @var{a}
9993 @end example
9994 @end deftypefn
9995
9996 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
9997 The operand, @var{auxv}, is the address of an auxiliary register and
9998 must be a compile time constant. Generates:
9999 @example
10000 lr @var{dest}, [@var{auxr}]
10001 @end example
10002 Where the value in @var{dest} will be the result returned from the
10003 built-in.
10004 @end deftypefn
10005
10006 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
10007 Only available with @option{-mmul64}. Generates:
10008 @example
10009 mul64 @var{a}, @var{b}
10010 @end example
10011 @end deftypefn
10012
10013 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
10014 Only available with @option{-mmul64}. Generates:
10015 @example
10016 mulu64 @var{a}, @var{b}
10017 @end example
10018 @end deftypefn
10019
10020 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
10021 Generates:
10022 @example
10023 nop
10024 @end example
10025 @end deftypefn
10026
10027 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
10028 Only valid if the @samp{norm} instruction is available through the
10029 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10030 Generates:
10031 @example
10032 norm @var{dest}, @var{src}
10033 @end example
10034 Where the value in @var{dest} will be the result returned from the
10035 built-in.
10036 @end deftypefn
10037
10038 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
10039 Only valid if the @samp{normw} instruction is available through the
10040 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10041 Generates:
10042 @example
10043 normw @var{dest}, @var{src}
10044 @end example
10045 Where the value in @var{dest} will be the result returned from the
10046 built-in.
10047 @end deftypefn
10048
10049 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
10050 Generates:
10051 @example
10052 rtie
10053 @end example
10054 @end deftypefn
10055
10056 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
10057 Generates:
10058 @example
10059 sleep @var{a}
10060 @end example
10061 @end deftypefn
10062
10063 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
10064 The first argument, @var{auxv}, is the address of an auxiliary
10065 register, the second argument, @var{val}, is a compile time constant
10066 to be written to the register. Generates:
10067 @example
10068 sr @var{auxr}, [@var{val}]
10069 @end example
10070 @end deftypefn
10071
10072 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
10073 Only valid with @option{-mswap}. Generates:
10074 @example
10075 swap @var{dest}, @var{src}
10076 @end example
10077 Where the value in @var{dest} will be the result returned from the
10078 built-in.
10079 @end deftypefn
10080
10081 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
10082 Generates:
10083 @example
10084 swi
10085 @end example
10086 @end deftypefn
10087
10088 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
10089 Only available with @option{-mcpu=ARC700}. Generates:
10090 @example
10091 sync
10092 @end example
10093 @end deftypefn
10094
10095 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
10096 Only available with @option{-mcpu=ARC700}. Generates:
10097 @example
10098 trap_s @var{c}
10099 @end example
10100 @end deftypefn
10101
10102 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
10103 Only available with @option{-mcpu=ARC700}. Generates:
10104 @example
10105 unimp_s
10106 @end example
10107 @end deftypefn
10108
10109 The instructions generated by the following builtins are not
10110 considered as candidates for scheduling. They are not moved around by
10111 the compiler during scheduling, and thus can be expected to appear
10112 where they are put in the C code:
10113 @example
10114 __builtin_arc_brk()
10115 __builtin_arc_core_read()
10116 __builtin_arc_core_write()
10117 __builtin_arc_flag()
10118 __builtin_arc_lr()
10119 __builtin_arc_sleep()
10120 __builtin_arc_sr()
10121 __builtin_arc_swi()
10122 @end example
10123
10124 @node ARC SIMD Built-in Functions
10125 @subsection ARC SIMD Built-in Functions
10126
10127 SIMD builtins provided by the compiler can be used to generate the
10128 vector instructions. This section describes the available builtins
10129 and their usage in programs. With the @option{-msimd} option, the
10130 compiler provides 128-bit vector types, which can be specified using
10131 the @code{vector_size} attribute. The header file @file{arc-simd.h}
10132 can be included to use the following predefined types:
10133 @example
10134 typedef int __v4si __attribute__((vector_size(16)));
10135 typedef short __v8hi __attribute__((vector_size(16)));
10136 @end example
10137
10138 These types can be used to define 128-bit variables. The built-in
10139 functions listed in the following section can be used on these
10140 variables to generate the vector operations.
10141
10142 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
10143 @file{arc-simd.h} also provides equivalent macros called
10144 @code{_@var{someinsn}} that can be used for programming ease and
10145 improved readability. The following macros for DMA control are also
10146 provided:
10147 @example
10148 #define _setup_dma_in_channel_reg _vdiwr
10149 #define _setup_dma_out_channel_reg _vdowr
10150 @end example
10151
10152 The following is a complete list of all the SIMD built-ins provided
10153 for ARC, grouped by calling signature.
10154
10155 The following take two @code{__v8hi} arguments and return a
10156 @code{__v8hi} result:
10157 @example
10158 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
10159 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
10160 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
10161 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
10162 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
10163 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
10164 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
10165 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
10166 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
10167 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
10168 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
10169 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
10170 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
10171 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
10172 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
10173 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
10174 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
10175 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
10176 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
10177 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
10178 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
10179 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
10180 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
10181 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
10182 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
10183 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
10184 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
10185 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
10186 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
10187 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
10188 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
10189 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
10190 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
10191 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
10192 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
10193 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
10194 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
10195 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
10196 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
10197 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
10198 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
10199 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
10200 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
10201 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
10202 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
10203 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
10204 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
10205 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
10206 @end example
10207
10208 The following take one @code{__v8hi} and one @code{int} argument and return a
10209 @code{__v8hi} result:
10210
10211 @example
10212 __v8hi __builtin_arc_vbaddw (__v8hi, int)
10213 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
10214 __v8hi __builtin_arc_vbminw (__v8hi, int)
10215 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
10216 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
10217 __v8hi __builtin_arc_vbmulw (__v8hi, int)
10218 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
10219 __v8hi __builtin_arc_vbsubw (__v8hi, int)
10220 @end example
10221
10222 The following take one @code{__v8hi} argument and one @code{int} argument which
10223 must be a 3-bit compile time constant indicating a register number
10224 I0-I7. They return a @code{__v8hi} result.
10225 @example
10226 __v8hi __builtin_arc_vasrw (__v8hi, const int)
10227 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
10228 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
10229 @end example
10230
10231 The following take one @code{__v8hi} argument and one @code{int}
10232 argument which must be a 6-bit compile time constant. They return a
10233 @code{__v8hi} result.
10234 @example
10235 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
10236 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
10237 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
10238 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
10239 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
10240 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
10241 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
10242 @end example
10243
10244 The following take one @code{__v8hi} argument and one @code{int} argument which
10245 must be a 8-bit compile time constant. They return a @code{__v8hi}
10246 result.
10247 @example
10248 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
10249 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
10250 __v8hi __builtin_arc_vmvw (__v8hi, const int)
10251 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
10252 @end example
10253
10254 The following take two @code{int} arguments, the second of which which
10255 must be a 8-bit compile time constant. They return a @code{__v8hi}
10256 result:
10257 @example
10258 __v8hi __builtin_arc_vmovaw (int, const int)
10259 __v8hi __builtin_arc_vmovw (int, const int)
10260 __v8hi __builtin_arc_vmovzw (int, const int)
10261 @end example
10262
10263 The following take a single @code{__v8hi} argument and return a
10264 @code{__v8hi} result:
10265 @example
10266 __v8hi __builtin_arc_vabsaw (__v8hi)
10267 __v8hi __builtin_arc_vabsw (__v8hi)
10268 __v8hi __builtin_arc_vaddsuw (__v8hi)
10269 __v8hi __builtin_arc_vexch1 (__v8hi)
10270 __v8hi __builtin_arc_vexch2 (__v8hi)
10271 __v8hi __builtin_arc_vexch4 (__v8hi)
10272 __v8hi __builtin_arc_vsignw (__v8hi)
10273 __v8hi __builtin_arc_vupbaw (__v8hi)
10274 __v8hi __builtin_arc_vupbw (__v8hi)
10275 __v8hi __builtin_arc_vupsbaw (__v8hi)
10276 __v8hi __builtin_arc_vupsbw (__v8hi)
10277 @end example
10278
10279 The followign take two @code{int} arguments and return no result:
10280 @example
10281 void __builtin_arc_vdirun (int, int)
10282 void __builtin_arc_vdorun (int, int)
10283 @end example
10284
10285 The following take two @code{int} arguments and return no result. The
10286 first argument must a 3-bit compile time constant indicating one of
10287 the DR0-DR7 DMA setup channels:
10288 @example
10289 void __builtin_arc_vdiwr (const int, int)
10290 void __builtin_arc_vdowr (const int, int)
10291 @end example
10292
10293 The following take an @code{int} argument and return no result:
10294 @example
10295 void __builtin_arc_vendrec (int)
10296 void __builtin_arc_vrec (int)
10297 void __builtin_arc_vrecrun (int)
10298 void __builtin_arc_vrun (int)
10299 @end example
10300
10301 The following take a @code{__v8hi} argument and two @code{int}
10302 arguments and return a @code{__v8hi} result. The second argument must
10303 be a 3-bit compile time constants, indicating one the registers I0-I7,
10304 and the third argument must be an 8-bit compile time constant.
10305
10306 @emph{Note:} Although the equivalent hardware instructions do not take
10307 an SIMD register as an operand, these builtins overwrite the relevant
10308 bits of the @code{__v8hi} register provided as the first argument with
10309 the value loaded from the @code{[Ib, u8]} location in the SDM.
10310
10311 @example
10312 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
10313 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
10314 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
10315 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
10316 @end example
10317
10318 The following take two @code{int} arguments and return a @code{__v8hi}
10319 result. The first argument must be a 3-bit compile time constants,
10320 indicating one the registers I0-I7, and the second argument must be an
10321 8-bit compile time constant.
10322
10323 @example
10324 __v8hi __builtin_arc_vld128 (const int, const int)
10325 __v8hi __builtin_arc_vld64w (const int, const int)
10326 @end example
10327
10328 The following take a @code{__v8hi} argument and two @code{int}
10329 arguments and return no result. The second argument must be a 3-bit
10330 compile time constants, indicating one the registers I0-I7, and the
10331 third argument must be an 8-bit compile time constant.
10332
10333 @example
10334 void __builtin_arc_vst128 (__v8hi, const int, const int)
10335 void __builtin_arc_vst64 (__v8hi, const int, const int)
10336 @end example
10337
10338 The following take a @code{__v8hi} argument and three @code{int}
10339 arguments and return no result. The second argument must be a 3-bit
10340 compile-time constant, identifying the 16-bit sub-register to be
10341 stored, the third argument must be a 3-bit compile time constants,
10342 indicating one the registers I0-I7, and the fourth argument must be an
10343 8-bit compile time constant.
10344
10345 @example
10346 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
10347 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
10348 @end example
10349
10350 @node ARM iWMMXt Built-in Functions
10351 @subsection ARM iWMMXt Built-in Functions
10352
10353 These built-in functions are available for the ARM family of
10354 processors when the @option{-mcpu=iwmmxt} switch is used:
10355
10356 @smallexample
10357 typedef int v2si __attribute__ ((vector_size (8)));
10358 typedef short v4hi __attribute__ ((vector_size (8)));
10359 typedef char v8qi __attribute__ ((vector_size (8)));
10360
10361 int __builtin_arm_getwcgr0 (void)
10362 void __builtin_arm_setwcgr0 (int)
10363 int __builtin_arm_getwcgr1 (void)
10364 void __builtin_arm_setwcgr1 (int)
10365 int __builtin_arm_getwcgr2 (void)
10366 void __builtin_arm_setwcgr2 (int)
10367 int __builtin_arm_getwcgr3 (void)
10368 void __builtin_arm_setwcgr3 (int)
10369 int __builtin_arm_textrmsb (v8qi, int)
10370 int __builtin_arm_textrmsh (v4hi, int)
10371 int __builtin_arm_textrmsw (v2si, int)
10372 int __builtin_arm_textrmub (v8qi, int)
10373 int __builtin_arm_textrmuh (v4hi, int)
10374 int __builtin_arm_textrmuw (v2si, int)
10375 v8qi __builtin_arm_tinsrb (v8qi, int, int)
10376 v4hi __builtin_arm_tinsrh (v4hi, int, int)
10377 v2si __builtin_arm_tinsrw (v2si, int, int)
10378 long long __builtin_arm_tmia (long long, int, int)
10379 long long __builtin_arm_tmiabb (long long, int, int)
10380 long long __builtin_arm_tmiabt (long long, int, int)
10381 long long __builtin_arm_tmiaph (long long, int, int)
10382 long long __builtin_arm_tmiatb (long long, int, int)
10383 long long __builtin_arm_tmiatt (long long, int, int)
10384 int __builtin_arm_tmovmskb (v8qi)
10385 int __builtin_arm_tmovmskh (v4hi)
10386 int __builtin_arm_tmovmskw (v2si)
10387 long long __builtin_arm_waccb (v8qi)
10388 long long __builtin_arm_wacch (v4hi)
10389 long long __builtin_arm_waccw (v2si)
10390 v8qi __builtin_arm_waddb (v8qi, v8qi)
10391 v8qi __builtin_arm_waddbss (v8qi, v8qi)
10392 v8qi __builtin_arm_waddbus (v8qi, v8qi)
10393 v4hi __builtin_arm_waddh (v4hi, v4hi)
10394 v4hi __builtin_arm_waddhss (v4hi, v4hi)
10395 v4hi __builtin_arm_waddhus (v4hi, v4hi)
10396 v2si __builtin_arm_waddw (v2si, v2si)
10397 v2si __builtin_arm_waddwss (v2si, v2si)
10398 v2si __builtin_arm_waddwus (v2si, v2si)
10399 v8qi __builtin_arm_walign (v8qi, v8qi, int)
10400 long long __builtin_arm_wand(long long, long long)
10401 long long __builtin_arm_wandn (long long, long long)
10402 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
10403 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
10404 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
10405 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
10406 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
10407 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
10408 v2si __builtin_arm_wcmpeqw (v2si, v2si)
10409 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
10410 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
10411 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
10412 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
10413 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
10414 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
10415 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
10416 long long __builtin_arm_wmacsz (v4hi, v4hi)
10417 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
10418 long long __builtin_arm_wmacuz (v4hi, v4hi)
10419 v4hi __builtin_arm_wmadds (v4hi, v4hi)
10420 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
10421 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
10422 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
10423 v2si __builtin_arm_wmaxsw (v2si, v2si)
10424 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
10425 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
10426 v2si __builtin_arm_wmaxuw (v2si, v2si)
10427 v8qi __builtin_arm_wminsb (v8qi, v8qi)
10428 v4hi __builtin_arm_wminsh (v4hi, v4hi)
10429 v2si __builtin_arm_wminsw (v2si, v2si)
10430 v8qi __builtin_arm_wminub (v8qi, v8qi)
10431 v4hi __builtin_arm_wminuh (v4hi, v4hi)
10432 v2si __builtin_arm_wminuw (v2si, v2si)
10433 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
10434 v4hi __builtin_arm_wmulul (v4hi, v4hi)
10435 v4hi __builtin_arm_wmulum (v4hi, v4hi)
10436 long long __builtin_arm_wor (long long, long long)
10437 v2si __builtin_arm_wpackdss (long long, long long)
10438 v2si __builtin_arm_wpackdus (long long, long long)
10439 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
10440 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
10441 v4hi __builtin_arm_wpackwss (v2si, v2si)
10442 v4hi __builtin_arm_wpackwus (v2si, v2si)
10443 long long __builtin_arm_wrord (long long, long long)
10444 long long __builtin_arm_wrordi (long long, int)
10445 v4hi __builtin_arm_wrorh (v4hi, long long)
10446 v4hi __builtin_arm_wrorhi (v4hi, int)
10447 v2si __builtin_arm_wrorw (v2si, long long)
10448 v2si __builtin_arm_wrorwi (v2si, int)
10449 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
10450 v2si __builtin_arm_wsadbz (v8qi, v8qi)
10451 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
10452 v2si __builtin_arm_wsadhz (v4hi, v4hi)
10453 v4hi __builtin_arm_wshufh (v4hi, int)
10454 long long __builtin_arm_wslld (long long, long long)
10455 long long __builtin_arm_wslldi (long long, int)
10456 v4hi __builtin_arm_wsllh (v4hi, long long)
10457 v4hi __builtin_arm_wsllhi (v4hi, int)
10458 v2si __builtin_arm_wsllw (v2si, long long)
10459 v2si __builtin_arm_wsllwi (v2si, int)
10460 long long __builtin_arm_wsrad (long long, long long)
10461 long long __builtin_arm_wsradi (long long, int)
10462 v4hi __builtin_arm_wsrah (v4hi, long long)
10463 v4hi __builtin_arm_wsrahi (v4hi, int)
10464 v2si __builtin_arm_wsraw (v2si, long long)
10465 v2si __builtin_arm_wsrawi (v2si, int)
10466 long long __builtin_arm_wsrld (long long, long long)
10467 long long __builtin_arm_wsrldi (long long, int)
10468 v4hi __builtin_arm_wsrlh (v4hi, long long)
10469 v4hi __builtin_arm_wsrlhi (v4hi, int)
10470 v2si __builtin_arm_wsrlw (v2si, long long)
10471 v2si __builtin_arm_wsrlwi (v2si, int)
10472 v8qi __builtin_arm_wsubb (v8qi, v8qi)
10473 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
10474 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
10475 v4hi __builtin_arm_wsubh (v4hi, v4hi)
10476 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
10477 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
10478 v2si __builtin_arm_wsubw (v2si, v2si)
10479 v2si __builtin_arm_wsubwss (v2si, v2si)
10480 v2si __builtin_arm_wsubwus (v2si, v2si)
10481 v4hi __builtin_arm_wunpckehsb (v8qi)
10482 v2si __builtin_arm_wunpckehsh (v4hi)
10483 long long __builtin_arm_wunpckehsw (v2si)
10484 v4hi __builtin_arm_wunpckehub (v8qi)
10485 v2si __builtin_arm_wunpckehuh (v4hi)
10486 long long __builtin_arm_wunpckehuw (v2si)
10487 v4hi __builtin_arm_wunpckelsb (v8qi)
10488 v2si __builtin_arm_wunpckelsh (v4hi)
10489 long long __builtin_arm_wunpckelsw (v2si)
10490 v4hi __builtin_arm_wunpckelub (v8qi)
10491 v2si __builtin_arm_wunpckeluh (v4hi)
10492 long long __builtin_arm_wunpckeluw (v2si)
10493 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
10494 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
10495 v2si __builtin_arm_wunpckihw (v2si, v2si)
10496 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
10497 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
10498 v2si __builtin_arm_wunpckilw (v2si, v2si)
10499 long long __builtin_arm_wxor (long long, long long)
10500 long long __builtin_arm_wzero ()
10501 @end smallexample
10502
10503 @node ARM NEON Intrinsics
10504 @subsection ARM NEON Intrinsics
10505
10506 These built-in intrinsics for the ARM Advanced SIMD extension are available
10507 when the @option{-mfpu=neon} switch is used:
10508
10509 @include arm-neon-intrinsics.texi
10510
10511 @node ARM ACLE Intrinsics
10512 @subsection ARM ACLE Intrinsics
10513
10514 These built-in intrinsics for the ARMv8-A CRC32 extension are available when
10515 the @option{-march=armv8-a+crc} switch is used:
10516
10517 @include arm-acle-intrinsics.texi
10518
10519 @node AVR Built-in Functions
10520 @subsection AVR Built-in Functions
10521
10522 For each built-in function for AVR, there is an equally named,
10523 uppercase built-in macro defined. That way users can easily query if
10524 or if not a specific built-in is implemented or not. For example, if
10525 @code{__builtin_avr_nop} is available the macro
10526 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
10527
10528 The following built-in functions map to the respective machine
10529 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
10530 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
10531 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
10532 as library call if no hardware multiplier is available.
10533
10534 @smallexample
10535 void __builtin_avr_nop (void)
10536 void __builtin_avr_sei (void)
10537 void __builtin_avr_cli (void)
10538 void __builtin_avr_sleep (void)
10539 void __builtin_avr_wdr (void)
10540 unsigned char __builtin_avr_swap (unsigned char)
10541 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
10542 int __builtin_avr_fmuls (char, char)
10543 int __builtin_avr_fmulsu (char, unsigned char)
10544 @end smallexample
10545
10546 In order to delay execution for a specific number of cycles, GCC
10547 implements
10548 @smallexample
10549 void __builtin_avr_delay_cycles (unsigned long ticks)
10550 @end smallexample
10551
10552 @noindent
10553 @code{ticks} is the number of ticks to delay execution. Note that this
10554 built-in does not take into account the effect of interrupts that
10555 might increase delay time. @code{ticks} must be a compile-time
10556 integer constant; delays with a variable number of cycles are not supported.
10557
10558 @smallexample
10559 char __builtin_avr_flash_segment (const __memx void*)
10560 @end smallexample
10561
10562 @noindent
10563 This built-in takes a byte address to the 24-bit
10564 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
10565 the number of the flash segment (the 64 KiB chunk) where the address
10566 points to. Counting starts at @code{0}.
10567 If the address does not point to flash memory, return @code{-1}.
10568
10569 @smallexample
10570 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
10571 @end smallexample
10572
10573 @noindent
10574 Insert bits from @var{bits} into @var{val} and return the resulting
10575 value. The nibbles of @var{map} determine how the insertion is
10576 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
10577 @enumerate
10578 @item If @var{X} is @code{0xf},
10579 then the @var{n}-th bit of @var{val} is returned unaltered.
10580
10581 @item If X is in the range 0@dots{}7,
10582 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
10583
10584 @item If X is in the range 8@dots{}@code{0xe},
10585 then the @var{n}-th result bit is undefined.
10586 @end enumerate
10587
10588 @noindent
10589 One typical use case for this built-in is adjusting input and
10590 output values to non-contiguous port layouts. Some examples:
10591
10592 @smallexample
10593 // same as val, bits is unused
10594 __builtin_avr_insert_bits (0xffffffff, bits, val)
10595 @end smallexample
10596
10597 @smallexample
10598 // same as bits, val is unused
10599 __builtin_avr_insert_bits (0x76543210, bits, val)
10600 @end smallexample
10601
10602 @smallexample
10603 // same as rotating bits by 4
10604 __builtin_avr_insert_bits (0x32107654, bits, 0)
10605 @end smallexample
10606
10607 @smallexample
10608 // high nibble of result is the high nibble of val
10609 // low nibble of result is the low nibble of bits
10610 __builtin_avr_insert_bits (0xffff3210, bits, val)
10611 @end smallexample
10612
10613 @smallexample
10614 // reverse the bit order of bits
10615 __builtin_avr_insert_bits (0x01234567, bits, 0)
10616 @end smallexample
10617
10618 @node Blackfin Built-in Functions
10619 @subsection Blackfin Built-in Functions
10620
10621 Currently, there are two Blackfin-specific built-in functions. These are
10622 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
10623 using inline assembly; by using these built-in functions the compiler can
10624 automatically add workarounds for hardware errata involving these
10625 instructions. These functions are named as follows:
10626
10627 @smallexample
10628 void __builtin_bfin_csync (void)
10629 void __builtin_bfin_ssync (void)
10630 @end smallexample
10631
10632 @node FR-V Built-in Functions
10633 @subsection FR-V Built-in Functions
10634
10635 GCC provides many FR-V-specific built-in functions. In general,
10636 these functions are intended to be compatible with those described
10637 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
10638 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
10639 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
10640 pointer rather than by value.
10641
10642 Most of the functions are named after specific FR-V instructions.
10643 Such functions are said to be ``directly mapped'' and are summarized
10644 here in tabular form.
10645
10646 @menu
10647 * Argument Types::
10648 * Directly-mapped Integer Functions::
10649 * Directly-mapped Media Functions::
10650 * Raw read/write Functions::
10651 * Other Built-in Functions::
10652 @end menu
10653
10654 @node Argument Types
10655 @subsubsection Argument Types
10656
10657 The arguments to the built-in functions can be divided into three groups:
10658 register numbers, compile-time constants and run-time values. In order
10659 to make this classification clear at a glance, the arguments and return
10660 values are given the following pseudo types:
10661
10662 @multitable @columnfractions .20 .30 .15 .35
10663 @item Pseudo type @tab Real C type @tab Constant? @tab Description
10664 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
10665 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
10666 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
10667 @item @code{uw2} @tab @code{unsigned long long} @tab No
10668 @tab an unsigned doubleword
10669 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
10670 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
10671 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
10672 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
10673 @end multitable
10674
10675 These pseudo types are not defined by GCC, they are simply a notational
10676 convenience used in this manual.
10677
10678 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
10679 and @code{sw2} are evaluated at run time. They correspond to
10680 register operands in the underlying FR-V instructions.
10681
10682 @code{const} arguments represent immediate operands in the underlying
10683 FR-V instructions. They must be compile-time constants.
10684
10685 @code{acc} arguments are evaluated at compile time and specify the number
10686 of an accumulator register. For example, an @code{acc} argument of 2
10687 selects the ACC2 register.
10688
10689 @code{iacc} arguments are similar to @code{acc} arguments but specify the
10690 number of an IACC register. See @pxref{Other Built-in Functions}
10691 for more details.
10692
10693 @node Directly-mapped Integer Functions
10694 @subsubsection Directly-mapped Integer Functions
10695
10696 The functions listed below map directly to FR-V I-type instructions.
10697
10698 @multitable @columnfractions .45 .32 .23
10699 @item Function prototype @tab Example usage @tab Assembly output
10700 @item @code{sw1 __ADDSS (sw1, sw1)}
10701 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
10702 @tab @code{ADDSS @var{a},@var{b},@var{c}}
10703 @item @code{sw1 __SCAN (sw1, sw1)}
10704 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
10705 @tab @code{SCAN @var{a},@var{b},@var{c}}
10706 @item @code{sw1 __SCUTSS (sw1)}
10707 @tab @code{@var{b} = __SCUTSS (@var{a})}
10708 @tab @code{SCUTSS @var{a},@var{b}}
10709 @item @code{sw1 __SLASS (sw1, sw1)}
10710 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
10711 @tab @code{SLASS @var{a},@var{b},@var{c}}
10712 @item @code{void __SMASS (sw1, sw1)}
10713 @tab @code{__SMASS (@var{a}, @var{b})}
10714 @tab @code{SMASS @var{a},@var{b}}
10715 @item @code{void __SMSSS (sw1, sw1)}
10716 @tab @code{__SMSSS (@var{a}, @var{b})}
10717 @tab @code{SMSSS @var{a},@var{b}}
10718 @item @code{void __SMU (sw1, sw1)}
10719 @tab @code{__SMU (@var{a}, @var{b})}
10720 @tab @code{SMU @var{a},@var{b}}
10721 @item @code{sw2 __SMUL (sw1, sw1)}
10722 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
10723 @tab @code{SMUL @var{a},@var{b},@var{c}}
10724 @item @code{sw1 __SUBSS (sw1, sw1)}
10725 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
10726 @tab @code{SUBSS @var{a},@var{b},@var{c}}
10727 @item @code{uw2 __UMUL (uw1, uw1)}
10728 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
10729 @tab @code{UMUL @var{a},@var{b},@var{c}}
10730 @end multitable
10731
10732 @node Directly-mapped Media Functions
10733 @subsubsection Directly-mapped Media Functions
10734
10735 The functions listed below map directly to FR-V M-type instructions.
10736
10737 @multitable @columnfractions .45 .32 .23
10738 @item Function prototype @tab Example usage @tab Assembly output
10739 @item @code{uw1 __MABSHS (sw1)}
10740 @tab @code{@var{b} = __MABSHS (@var{a})}
10741 @tab @code{MABSHS @var{a},@var{b}}
10742 @item @code{void __MADDACCS (acc, acc)}
10743 @tab @code{__MADDACCS (@var{b}, @var{a})}
10744 @tab @code{MADDACCS @var{a},@var{b}}
10745 @item @code{sw1 __MADDHSS (sw1, sw1)}
10746 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
10747 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
10748 @item @code{uw1 __MADDHUS (uw1, uw1)}
10749 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
10750 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
10751 @item @code{uw1 __MAND (uw1, uw1)}
10752 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
10753 @tab @code{MAND @var{a},@var{b},@var{c}}
10754 @item @code{void __MASACCS (acc, acc)}
10755 @tab @code{__MASACCS (@var{b}, @var{a})}
10756 @tab @code{MASACCS @var{a},@var{b}}
10757 @item @code{uw1 __MAVEH (uw1, uw1)}
10758 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
10759 @tab @code{MAVEH @var{a},@var{b},@var{c}}
10760 @item @code{uw2 __MBTOH (uw1)}
10761 @tab @code{@var{b} = __MBTOH (@var{a})}
10762 @tab @code{MBTOH @var{a},@var{b}}
10763 @item @code{void __MBTOHE (uw1 *, uw1)}
10764 @tab @code{__MBTOHE (&@var{b}, @var{a})}
10765 @tab @code{MBTOHE @var{a},@var{b}}
10766 @item @code{void __MCLRACC (acc)}
10767 @tab @code{__MCLRACC (@var{a})}
10768 @tab @code{MCLRACC @var{a}}
10769 @item @code{void __MCLRACCA (void)}
10770 @tab @code{__MCLRACCA ()}
10771 @tab @code{MCLRACCA}
10772 @item @code{uw1 __Mcop1 (uw1, uw1)}
10773 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
10774 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
10775 @item @code{uw1 __Mcop2 (uw1, uw1)}
10776 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
10777 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
10778 @item @code{uw1 __MCPLHI (uw2, const)}
10779 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
10780 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
10781 @item @code{uw1 __MCPLI (uw2, const)}
10782 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
10783 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
10784 @item @code{void __MCPXIS (acc, sw1, sw1)}
10785 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
10786 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
10787 @item @code{void __MCPXIU (acc, uw1, uw1)}
10788 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
10789 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
10790 @item @code{void __MCPXRS (acc, sw1, sw1)}
10791 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
10792 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
10793 @item @code{void __MCPXRU (acc, uw1, uw1)}
10794 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
10795 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
10796 @item @code{uw1 __MCUT (acc, uw1)}
10797 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
10798 @tab @code{MCUT @var{a},@var{b},@var{c}}
10799 @item @code{uw1 __MCUTSS (acc, sw1)}
10800 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
10801 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
10802 @item @code{void __MDADDACCS (acc, acc)}
10803 @tab @code{__MDADDACCS (@var{b}, @var{a})}
10804 @tab @code{MDADDACCS @var{a},@var{b}}
10805 @item @code{void __MDASACCS (acc, acc)}
10806 @tab @code{__MDASACCS (@var{b}, @var{a})}
10807 @tab @code{MDASACCS @var{a},@var{b}}
10808 @item @code{uw2 __MDCUTSSI (acc, const)}
10809 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
10810 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
10811 @item @code{uw2 __MDPACKH (uw2, uw2)}
10812 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
10813 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
10814 @item @code{uw2 __MDROTLI (uw2, const)}
10815 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
10816 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
10817 @item @code{void __MDSUBACCS (acc, acc)}
10818 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
10819 @tab @code{MDSUBACCS @var{a},@var{b}}
10820 @item @code{void __MDUNPACKH (uw1 *, uw2)}
10821 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
10822 @tab @code{MDUNPACKH @var{a},@var{b}}
10823 @item @code{uw2 __MEXPDHD (uw1, const)}
10824 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
10825 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
10826 @item @code{uw1 __MEXPDHW (uw1, const)}
10827 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
10828 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
10829 @item @code{uw1 __MHDSETH (uw1, const)}
10830 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
10831 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
10832 @item @code{sw1 __MHDSETS (const)}
10833 @tab @code{@var{b} = __MHDSETS (@var{a})}
10834 @tab @code{MHDSETS #@var{a},@var{b}}
10835 @item @code{uw1 __MHSETHIH (uw1, const)}
10836 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
10837 @tab @code{MHSETHIH #@var{a},@var{b}}
10838 @item @code{sw1 __MHSETHIS (sw1, const)}
10839 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
10840 @tab @code{MHSETHIS #@var{a},@var{b}}
10841 @item @code{uw1 __MHSETLOH (uw1, const)}
10842 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
10843 @tab @code{MHSETLOH #@var{a},@var{b}}
10844 @item @code{sw1 __MHSETLOS (sw1, const)}
10845 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
10846 @tab @code{MHSETLOS #@var{a},@var{b}}
10847 @item @code{uw1 __MHTOB (uw2)}
10848 @tab @code{@var{b} = __MHTOB (@var{a})}
10849 @tab @code{MHTOB @var{a},@var{b}}
10850 @item @code{void __MMACHS (acc, sw1, sw1)}
10851 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
10852 @tab @code{MMACHS @var{a},@var{b},@var{c}}
10853 @item @code{void __MMACHU (acc, uw1, uw1)}
10854 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
10855 @tab @code{MMACHU @var{a},@var{b},@var{c}}
10856 @item @code{void __MMRDHS (acc, sw1, sw1)}
10857 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
10858 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
10859 @item @code{void __MMRDHU (acc, uw1, uw1)}
10860 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
10861 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
10862 @item @code{void __MMULHS (acc, sw1, sw1)}
10863 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
10864 @tab @code{MMULHS @var{a},@var{b},@var{c}}
10865 @item @code{void __MMULHU (acc, uw1, uw1)}
10866 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
10867 @tab @code{MMULHU @var{a},@var{b},@var{c}}
10868 @item @code{void __MMULXHS (acc, sw1, sw1)}
10869 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
10870 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
10871 @item @code{void __MMULXHU (acc, uw1, uw1)}
10872 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
10873 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
10874 @item @code{uw1 __MNOT (uw1)}
10875 @tab @code{@var{b} = __MNOT (@var{a})}
10876 @tab @code{MNOT @var{a},@var{b}}
10877 @item @code{uw1 __MOR (uw1, uw1)}
10878 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
10879 @tab @code{MOR @var{a},@var{b},@var{c}}
10880 @item @code{uw1 __MPACKH (uh, uh)}
10881 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
10882 @tab @code{MPACKH @var{a},@var{b},@var{c}}
10883 @item @code{sw2 __MQADDHSS (sw2, sw2)}
10884 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
10885 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
10886 @item @code{uw2 __MQADDHUS (uw2, uw2)}
10887 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
10888 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
10889 @item @code{void __MQCPXIS (acc, sw2, sw2)}
10890 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
10891 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
10892 @item @code{void __MQCPXIU (acc, uw2, uw2)}
10893 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
10894 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
10895 @item @code{void __MQCPXRS (acc, sw2, sw2)}
10896 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
10897 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
10898 @item @code{void __MQCPXRU (acc, uw2, uw2)}
10899 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
10900 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
10901 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
10902 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
10903 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
10904 @item @code{sw2 __MQLMTHS (sw2, sw2)}
10905 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
10906 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
10907 @item @code{void __MQMACHS (acc, sw2, sw2)}
10908 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
10909 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
10910 @item @code{void __MQMACHU (acc, uw2, uw2)}
10911 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
10912 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
10913 @item @code{void __MQMACXHS (acc, sw2, sw2)}
10914 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
10915 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
10916 @item @code{void __MQMULHS (acc, sw2, sw2)}
10917 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
10918 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
10919 @item @code{void __MQMULHU (acc, uw2, uw2)}
10920 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
10921 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
10922 @item @code{void __MQMULXHS (acc, sw2, sw2)}
10923 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
10924 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
10925 @item @code{void __MQMULXHU (acc, uw2, uw2)}
10926 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
10927 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
10928 @item @code{sw2 __MQSATHS (sw2, sw2)}
10929 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
10930 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
10931 @item @code{uw2 __MQSLLHI (uw2, int)}
10932 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
10933 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
10934 @item @code{sw2 __MQSRAHI (sw2, int)}
10935 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
10936 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
10937 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
10938 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
10939 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
10940 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
10941 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
10942 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
10943 @item @code{void __MQXMACHS (acc, sw2, sw2)}
10944 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
10945 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
10946 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
10947 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
10948 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
10949 @item @code{uw1 __MRDACC (acc)}
10950 @tab @code{@var{b} = __MRDACC (@var{a})}
10951 @tab @code{MRDACC @var{a},@var{b}}
10952 @item @code{uw1 __MRDACCG (acc)}
10953 @tab @code{@var{b} = __MRDACCG (@var{a})}
10954 @tab @code{MRDACCG @var{a},@var{b}}
10955 @item @code{uw1 __MROTLI (uw1, const)}
10956 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
10957 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
10958 @item @code{uw1 __MROTRI (uw1, const)}
10959 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
10960 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
10961 @item @code{sw1 __MSATHS (sw1, sw1)}
10962 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
10963 @tab @code{MSATHS @var{a},@var{b},@var{c}}
10964 @item @code{uw1 __MSATHU (uw1, uw1)}
10965 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
10966 @tab @code{MSATHU @var{a},@var{b},@var{c}}
10967 @item @code{uw1 __MSLLHI (uw1, const)}
10968 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
10969 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
10970 @item @code{sw1 __MSRAHI (sw1, const)}
10971 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
10972 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
10973 @item @code{uw1 __MSRLHI (uw1, const)}
10974 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
10975 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
10976 @item @code{void __MSUBACCS (acc, acc)}
10977 @tab @code{__MSUBACCS (@var{b}, @var{a})}
10978 @tab @code{MSUBACCS @var{a},@var{b}}
10979 @item @code{sw1 __MSUBHSS (sw1, sw1)}
10980 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
10981 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
10982 @item @code{uw1 __MSUBHUS (uw1, uw1)}
10983 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
10984 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
10985 @item @code{void __MTRAP (void)}
10986 @tab @code{__MTRAP ()}
10987 @tab @code{MTRAP}
10988 @item @code{uw2 __MUNPACKH (uw1)}
10989 @tab @code{@var{b} = __MUNPACKH (@var{a})}
10990 @tab @code{MUNPACKH @var{a},@var{b}}
10991 @item @code{uw1 __MWCUT (uw2, uw1)}
10992 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
10993 @tab @code{MWCUT @var{a},@var{b},@var{c}}
10994 @item @code{void __MWTACC (acc, uw1)}
10995 @tab @code{__MWTACC (@var{b}, @var{a})}
10996 @tab @code{MWTACC @var{a},@var{b}}
10997 @item @code{void __MWTACCG (acc, uw1)}
10998 @tab @code{__MWTACCG (@var{b}, @var{a})}
10999 @tab @code{MWTACCG @var{a},@var{b}}
11000 @item @code{uw1 __MXOR (uw1, uw1)}
11001 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
11002 @tab @code{MXOR @var{a},@var{b},@var{c}}
11003 @end multitable
11004
11005 @node Raw read/write Functions
11006 @subsubsection Raw read/write Functions
11007
11008 This sections describes built-in functions related to read and write
11009 instructions to access memory. These functions generate
11010 @code{membar} instructions to flush the I/O load and stores where
11011 appropriate, as described in Fujitsu's manual described above.
11012
11013 @table @code
11014
11015 @item unsigned char __builtin_read8 (void *@var{data})
11016 @item unsigned short __builtin_read16 (void *@var{data})
11017 @item unsigned long __builtin_read32 (void *@var{data})
11018 @item unsigned long long __builtin_read64 (void *@var{data})
11019
11020 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
11021 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
11022 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
11023 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
11024 @end table
11025
11026 @node Other Built-in Functions
11027 @subsubsection Other Built-in Functions
11028
11029 This section describes built-in functions that are not named after
11030 a specific FR-V instruction.
11031
11032 @table @code
11033 @item sw2 __IACCreadll (iacc @var{reg})
11034 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
11035 for future expansion and must be 0.
11036
11037 @item sw1 __IACCreadl (iacc @var{reg})
11038 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
11039 Other values of @var{reg} are rejected as invalid.
11040
11041 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
11042 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
11043 is reserved for future expansion and must be 0.
11044
11045 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
11046 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
11047 is 1. Other values of @var{reg} are rejected as invalid.
11048
11049 @item void __data_prefetch0 (const void *@var{x})
11050 Use the @code{dcpl} instruction to load the contents of address @var{x}
11051 into the data cache.
11052
11053 @item void __data_prefetch (const void *@var{x})
11054 Use the @code{nldub} instruction to load the contents of address @var{x}
11055 into the data cache. The instruction is issued in slot I1@.
11056 @end table
11057
11058 @node X86 Built-in Functions
11059 @subsection X86 Built-in Functions
11060
11061 These built-in functions are available for the i386 and x86-64 family
11062 of computers, depending on the command-line switches used.
11063
11064 If you specify command-line switches such as @option{-msse},
11065 the compiler could use the extended instruction sets even if the built-ins
11066 are not used explicitly in the program. For this reason, applications
11067 that perform run-time CPU detection must compile separate files for each
11068 supported architecture, using the appropriate flags. In particular,
11069 the file containing the CPU detection code should be compiled without
11070 these options.
11071
11072 The following machine modes are available for use with MMX built-in functions
11073 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
11074 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
11075 vector of eight 8-bit integers. Some of the built-in functions operate on
11076 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
11077
11078 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
11079 of two 32-bit floating-point values.
11080
11081 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
11082 floating-point values. Some instructions use a vector of four 32-bit
11083 integers, these use @code{V4SI}. Finally, some instructions operate on an
11084 entire vector register, interpreting it as a 128-bit integer, these use mode
11085 @code{TI}.
11086
11087 In 64-bit mode, the x86-64 family of processors uses additional built-in
11088 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
11089 floating point and @code{TC} 128-bit complex floating-point values.
11090
11091 The following floating-point built-in functions are available in 64-bit
11092 mode. All of them implement the function that is part of the name.
11093
11094 @smallexample
11095 __float128 __builtin_fabsq (__float128)
11096 __float128 __builtin_copysignq (__float128, __float128)
11097 @end smallexample
11098
11099 The following built-in function is always available.
11100
11101 @table @code
11102 @item void __builtin_ia32_pause (void)
11103 Generates the @code{pause} machine instruction with a compiler memory
11104 barrier.
11105 @end table
11106
11107 The following floating-point built-in functions are made available in the
11108 64-bit mode.
11109
11110 @table @code
11111 @item __float128 __builtin_infq (void)
11112 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
11113 @findex __builtin_infq
11114
11115 @item __float128 __builtin_huge_valq (void)
11116 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
11117 @findex __builtin_huge_valq
11118 @end table
11119
11120 The following built-in functions are always available and can be used to
11121 check the target platform type.
11122
11123 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
11124 This function runs the CPU detection code to check the type of CPU and the
11125 features supported. This built-in function needs to be invoked along with the built-in functions
11126 to check CPU type and features, @code{__builtin_cpu_is} and
11127 @code{__builtin_cpu_supports}, only when used in a function that is
11128 executed before any constructors are called. The CPU detection code is
11129 automatically executed in a very high priority constructor.
11130
11131 For example, this function has to be used in @code{ifunc} resolvers that
11132 check for CPU type using the built-in functions @code{__builtin_cpu_is}
11133 and @code{__builtin_cpu_supports}, or in constructors on targets that
11134 don't support constructor priority.
11135 @smallexample
11136
11137 static void (*resolve_memcpy (void)) (void)
11138 @{
11139 // ifunc resolvers fire before constructors, explicitly call the init
11140 // function.
11141 __builtin_cpu_init ();
11142 if (__builtin_cpu_supports ("ssse3"))
11143 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
11144 else
11145 return default_memcpy;
11146 @}
11147
11148 void *memcpy (void *, const void *, size_t)
11149 __attribute__ ((ifunc ("resolve_memcpy")));
11150 @end smallexample
11151
11152 @end deftypefn
11153
11154 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
11155 This function returns a positive integer if the run-time CPU
11156 is of type @var{cpuname}
11157 and returns @code{0} otherwise. The following CPU names can be detected:
11158
11159 @table @samp
11160 @item intel
11161 Intel CPU.
11162
11163 @item atom
11164 Intel Atom CPU.
11165
11166 @item core2
11167 Intel Core 2 CPU.
11168
11169 @item corei7
11170 Intel Core i7 CPU.
11171
11172 @item nehalem
11173 Intel Core i7 Nehalem CPU.
11174
11175 @item westmere
11176 Intel Core i7 Westmere CPU.
11177
11178 @item sandybridge
11179 Intel Core i7 Sandy Bridge CPU.
11180
11181 @item amd
11182 AMD CPU.
11183
11184 @item amdfam10h
11185 AMD Family 10h CPU.
11186
11187 @item barcelona
11188 AMD Family 10h Barcelona CPU.
11189
11190 @item shanghai
11191 AMD Family 10h Shanghai CPU.
11192
11193 @item istanbul
11194 AMD Family 10h Istanbul CPU.
11195
11196 @item btver1
11197 AMD Family 14h CPU.
11198
11199 @item amdfam15h
11200 AMD Family 15h CPU.
11201
11202 @item bdver1
11203 AMD Family 15h Bulldozer version 1.
11204
11205 @item bdver2
11206 AMD Family 15h Bulldozer version 2.
11207
11208 @item bdver3
11209 AMD Family 15h Bulldozer version 3.
11210
11211 @item bdver4
11212 AMD Family 15h Bulldozer version 4.
11213
11214 @item btver2
11215 AMD Family 16h CPU.
11216 @end table
11217
11218 Here is an example:
11219 @smallexample
11220 if (__builtin_cpu_is ("corei7"))
11221 @{
11222 do_corei7 (); // Core i7 specific implementation.
11223 @}
11224 else
11225 @{
11226 do_generic (); // Generic implementation.
11227 @}
11228 @end smallexample
11229 @end deftypefn
11230
11231 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
11232 This function returns a positive integer if the run-time CPU
11233 supports @var{feature}
11234 and returns @code{0} otherwise. The following features can be detected:
11235
11236 @table @samp
11237 @item cmov
11238 CMOV instruction.
11239 @item mmx
11240 MMX instructions.
11241 @item popcnt
11242 POPCNT instruction.
11243 @item sse
11244 SSE instructions.
11245 @item sse2
11246 SSE2 instructions.
11247 @item sse3
11248 SSE3 instructions.
11249 @item ssse3
11250 SSSE3 instructions.
11251 @item sse4.1
11252 SSE4.1 instructions.
11253 @item sse4.2
11254 SSE4.2 instructions.
11255 @item avx
11256 AVX instructions.
11257 @item avx2
11258 AVX2 instructions.
11259 @end table
11260
11261 Here is an example:
11262 @smallexample
11263 if (__builtin_cpu_supports ("popcnt"))
11264 @{
11265 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
11266 @}
11267 else
11268 @{
11269 count = generic_countbits (n); //generic implementation.
11270 @}
11271 @end smallexample
11272 @end deftypefn
11273
11274
11275 The following built-in functions are made available by @option{-mmmx}.
11276 All of them generate the machine instruction that is part of the name.
11277
11278 @smallexample
11279 v8qi __builtin_ia32_paddb (v8qi, v8qi)
11280 v4hi __builtin_ia32_paddw (v4hi, v4hi)
11281 v2si __builtin_ia32_paddd (v2si, v2si)
11282 v8qi __builtin_ia32_psubb (v8qi, v8qi)
11283 v4hi __builtin_ia32_psubw (v4hi, v4hi)
11284 v2si __builtin_ia32_psubd (v2si, v2si)
11285 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
11286 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
11287 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
11288 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
11289 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
11290 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
11291 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
11292 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
11293 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
11294 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
11295 di __builtin_ia32_pand (di, di)
11296 di __builtin_ia32_pandn (di,di)
11297 di __builtin_ia32_por (di, di)
11298 di __builtin_ia32_pxor (di, di)
11299 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
11300 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
11301 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
11302 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
11303 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
11304 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
11305 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
11306 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
11307 v2si __builtin_ia32_punpckhdq (v2si, v2si)
11308 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
11309 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
11310 v2si __builtin_ia32_punpckldq (v2si, v2si)
11311 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
11312 v4hi __builtin_ia32_packssdw (v2si, v2si)
11313 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
11314
11315 v4hi __builtin_ia32_psllw (v4hi, v4hi)
11316 v2si __builtin_ia32_pslld (v2si, v2si)
11317 v1di __builtin_ia32_psllq (v1di, v1di)
11318 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
11319 v2si __builtin_ia32_psrld (v2si, v2si)
11320 v1di __builtin_ia32_psrlq (v1di, v1di)
11321 v4hi __builtin_ia32_psraw (v4hi, v4hi)
11322 v2si __builtin_ia32_psrad (v2si, v2si)
11323 v4hi __builtin_ia32_psllwi (v4hi, int)
11324 v2si __builtin_ia32_pslldi (v2si, int)
11325 v1di __builtin_ia32_psllqi (v1di, int)
11326 v4hi __builtin_ia32_psrlwi (v4hi, int)
11327 v2si __builtin_ia32_psrldi (v2si, int)
11328 v1di __builtin_ia32_psrlqi (v1di, int)
11329 v4hi __builtin_ia32_psrawi (v4hi, int)
11330 v2si __builtin_ia32_psradi (v2si, int)
11331
11332 @end smallexample
11333
11334 The following built-in functions are made available either with
11335 @option{-msse}, or with a combination of @option{-m3dnow} and
11336 @option{-march=athlon}. All of them generate the machine
11337 instruction that is part of the name.
11338
11339 @smallexample
11340 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
11341 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
11342 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
11343 v1di __builtin_ia32_psadbw (v8qi, v8qi)
11344 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
11345 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
11346 v8qi __builtin_ia32_pminub (v8qi, v8qi)
11347 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
11348 int __builtin_ia32_pmovmskb (v8qi)
11349 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
11350 void __builtin_ia32_movntq (di *, di)
11351 void __builtin_ia32_sfence (void)
11352 @end smallexample
11353
11354 The following built-in functions are available when @option{-msse} is used.
11355 All of them generate the machine instruction that is part of the name.
11356
11357 @smallexample
11358 int __builtin_ia32_comieq (v4sf, v4sf)
11359 int __builtin_ia32_comineq (v4sf, v4sf)
11360 int __builtin_ia32_comilt (v4sf, v4sf)
11361 int __builtin_ia32_comile (v4sf, v4sf)
11362 int __builtin_ia32_comigt (v4sf, v4sf)
11363 int __builtin_ia32_comige (v4sf, v4sf)
11364 int __builtin_ia32_ucomieq (v4sf, v4sf)
11365 int __builtin_ia32_ucomineq (v4sf, v4sf)
11366 int __builtin_ia32_ucomilt (v4sf, v4sf)
11367 int __builtin_ia32_ucomile (v4sf, v4sf)
11368 int __builtin_ia32_ucomigt (v4sf, v4sf)
11369 int __builtin_ia32_ucomige (v4sf, v4sf)
11370 v4sf __builtin_ia32_addps (v4sf, v4sf)
11371 v4sf __builtin_ia32_subps (v4sf, v4sf)
11372 v4sf __builtin_ia32_mulps (v4sf, v4sf)
11373 v4sf __builtin_ia32_divps (v4sf, v4sf)
11374 v4sf __builtin_ia32_addss (v4sf, v4sf)
11375 v4sf __builtin_ia32_subss (v4sf, v4sf)
11376 v4sf __builtin_ia32_mulss (v4sf, v4sf)
11377 v4sf __builtin_ia32_divss (v4sf, v4sf)
11378 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
11379 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
11380 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
11381 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
11382 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
11383 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
11384 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
11385 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
11386 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
11387 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
11388 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
11389 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
11390 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
11391 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
11392 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
11393 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
11394 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
11395 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
11396 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
11397 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
11398 v4sf __builtin_ia32_maxps (v4sf, v4sf)
11399 v4sf __builtin_ia32_maxss (v4sf, v4sf)
11400 v4sf __builtin_ia32_minps (v4sf, v4sf)
11401 v4sf __builtin_ia32_minss (v4sf, v4sf)
11402 v4sf __builtin_ia32_andps (v4sf, v4sf)
11403 v4sf __builtin_ia32_andnps (v4sf, v4sf)
11404 v4sf __builtin_ia32_orps (v4sf, v4sf)
11405 v4sf __builtin_ia32_xorps (v4sf, v4sf)
11406 v4sf __builtin_ia32_movss (v4sf, v4sf)
11407 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
11408 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
11409 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
11410 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
11411 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
11412 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
11413 v2si __builtin_ia32_cvtps2pi (v4sf)
11414 int __builtin_ia32_cvtss2si (v4sf)
11415 v2si __builtin_ia32_cvttps2pi (v4sf)
11416 int __builtin_ia32_cvttss2si (v4sf)
11417 v4sf __builtin_ia32_rcpps (v4sf)
11418 v4sf __builtin_ia32_rsqrtps (v4sf)
11419 v4sf __builtin_ia32_sqrtps (v4sf)
11420 v4sf __builtin_ia32_rcpss (v4sf)
11421 v4sf __builtin_ia32_rsqrtss (v4sf)
11422 v4sf __builtin_ia32_sqrtss (v4sf)
11423 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
11424 void __builtin_ia32_movntps (float *, v4sf)
11425 int __builtin_ia32_movmskps (v4sf)
11426 @end smallexample
11427
11428 The following built-in functions are available when @option{-msse} is used.
11429
11430 @table @code
11431 @item v4sf __builtin_ia32_loadups (float *)
11432 Generates the @code{movups} machine instruction as a load from memory.
11433 @item void __builtin_ia32_storeups (float *, v4sf)
11434 Generates the @code{movups} machine instruction as a store to memory.
11435 @item v4sf __builtin_ia32_loadss (float *)
11436 Generates the @code{movss} machine instruction as a load from memory.
11437 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
11438 Generates the @code{movhps} machine instruction as a load from memory.
11439 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
11440 Generates the @code{movlps} machine instruction as a load from memory
11441 @item void __builtin_ia32_storehps (v2sf *, v4sf)
11442 Generates the @code{movhps} machine instruction as a store to memory.
11443 @item void __builtin_ia32_storelps (v2sf *, v4sf)
11444 Generates the @code{movlps} machine instruction as a store to memory.
11445 @end table
11446
11447 The following built-in functions are available when @option{-msse2} is used.
11448 All of them generate the machine instruction that is part of the name.
11449
11450 @smallexample
11451 int __builtin_ia32_comisdeq (v2df, v2df)
11452 int __builtin_ia32_comisdlt (v2df, v2df)
11453 int __builtin_ia32_comisdle (v2df, v2df)
11454 int __builtin_ia32_comisdgt (v2df, v2df)
11455 int __builtin_ia32_comisdge (v2df, v2df)
11456 int __builtin_ia32_comisdneq (v2df, v2df)
11457 int __builtin_ia32_ucomisdeq (v2df, v2df)
11458 int __builtin_ia32_ucomisdlt (v2df, v2df)
11459 int __builtin_ia32_ucomisdle (v2df, v2df)
11460 int __builtin_ia32_ucomisdgt (v2df, v2df)
11461 int __builtin_ia32_ucomisdge (v2df, v2df)
11462 int __builtin_ia32_ucomisdneq (v2df, v2df)
11463 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
11464 v2df __builtin_ia32_cmpltpd (v2df, v2df)
11465 v2df __builtin_ia32_cmplepd (v2df, v2df)
11466 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
11467 v2df __builtin_ia32_cmpgepd (v2df, v2df)
11468 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
11469 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
11470 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
11471 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
11472 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
11473 v2df __builtin_ia32_cmpngepd (v2df, v2df)
11474 v2df __builtin_ia32_cmpordpd (v2df, v2df)
11475 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
11476 v2df __builtin_ia32_cmpltsd (v2df, v2df)
11477 v2df __builtin_ia32_cmplesd (v2df, v2df)
11478 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
11479 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
11480 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
11481 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
11482 v2df __builtin_ia32_cmpordsd (v2df, v2df)
11483 v2di __builtin_ia32_paddq (v2di, v2di)
11484 v2di __builtin_ia32_psubq (v2di, v2di)
11485 v2df __builtin_ia32_addpd (v2df, v2df)
11486 v2df __builtin_ia32_subpd (v2df, v2df)
11487 v2df __builtin_ia32_mulpd (v2df, v2df)
11488 v2df __builtin_ia32_divpd (v2df, v2df)
11489 v2df __builtin_ia32_addsd (v2df, v2df)
11490 v2df __builtin_ia32_subsd (v2df, v2df)
11491 v2df __builtin_ia32_mulsd (v2df, v2df)
11492 v2df __builtin_ia32_divsd (v2df, v2df)
11493 v2df __builtin_ia32_minpd (v2df, v2df)
11494 v2df __builtin_ia32_maxpd (v2df, v2df)
11495 v2df __builtin_ia32_minsd (v2df, v2df)
11496 v2df __builtin_ia32_maxsd (v2df, v2df)
11497 v2df __builtin_ia32_andpd (v2df, v2df)
11498 v2df __builtin_ia32_andnpd (v2df, v2df)
11499 v2df __builtin_ia32_orpd (v2df, v2df)
11500 v2df __builtin_ia32_xorpd (v2df, v2df)
11501 v2df __builtin_ia32_movsd (v2df, v2df)
11502 v2df __builtin_ia32_unpckhpd (v2df, v2df)
11503 v2df __builtin_ia32_unpcklpd (v2df, v2df)
11504 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
11505 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
11506 v4si __builtin_ia32_paddd128 (v4si, v4si)
11507 v2di __builtin_ia32_paddq128 (v2di, v2di)
11508 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
11509 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
11510 v4si __builtin_ia32_psubd128 (v4si, v4si)
11511 v2di __builtin_ia32_psubq128 (v2di, v2di)
11512 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
11513 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
11514 v2di __builtin_ia32_pand128 (v2di, v2di)
11515 v2di __builtin_ia32_pandn128 (v2di, v2di)
11516 v2di __builtin_ia32_por128 (v2di, v2di)
11517 v2di __builtin_ia32_pxor128 (v2di, v2di)
11518 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
11519 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
11520 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
11521 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
11522 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
11523 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
11524 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
11525 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
11526 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
11527 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
11528 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
11529 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
11530 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
11531 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
11532 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
11533 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
11534 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
11535 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
11536 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
11537 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
11538 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
11539 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
11540 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
11541 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
11542 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
11543 v2df __builtin_ia32_loadupd (double *)
11544 void __builtin_ia32_storeupd (double *, v2df)
11545 v2df __builtin_ia32_loadhpd (v2df, double const *)
11546 v2df __builtin_ia32_loadlpd (v2df, double const *)
11547 int __builtin_ia32_movmskpd (v2df)
11548 int __builtin_ia32_pmovmskb128 (v16qi)
11549 void __builtin_ia32_movnti (int *, int)
11550 void __builtin_ia32_movnti64 (long long int *, long long int)
11551 void __builtin_ia32_movntpd (double *, v2df)
11552 void __builtin_ia32_movntdq (v2df *, v2df)
11553 v4si __builtin_ia32_pshufd (v4si, int)
11554 v8hi __builtin_ia32_pshuflw (v8hi, int)
11555 v8hi __builtin_ia32_pshufhw (v8hi, int)
11556 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
11557 v2df __builtin_ia32_sqrtpd (v2df)
11558 v2df __builtin_ia32_sqrtsd (v2df)
11559 v2df __builtin_ia32_shufpd (v2df, v2df, int)
11560 v2df __builtin_ia32_cvtdq2pd (v4si)
11561 v4sf __builtin_ia32_cvtdq2ps (v4si)
11562 v4si __builtin_ia32_cvtpd2dq (v2df)
11563 v2si __builtin_ia32_cvtpd2pi (v2df)
11564 v4sf __builtin_ia32_cvtpd2ps (v2df)
11565 v4si __builtin_ia32_cvttpd2dq (v2df)
11566 v2si __builtin_ia32_cvttpd2pi (v2df)
11567 v2df __builtin_ia32_cvtpi2pd (v2si)
11568 int __builtin_ia32_cvtsd2si (v2df)
11569 int __builtin_ia32_cvttsd2si (v2df)
11570 long long __builtin_ia32_cvtsd2si64 (v2df)
11571 long long __builtin_ia32_cvttsd2si64 (v2df)
11572 v4si __builtin_ia32_cvtps2dq (v4sf)
11573 v2df __builtin_ia32_cvtps2pd (v4sf)
11574 v4si __builtin_ia32_cvttps2dq (v4sf)
11575 v2df __builtin_ia32_cvtsi2sd (v2df, int)
11576 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
11577 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
11578 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
11579 void __builtin_ia32_clflush (const void *)
11580 void __builtin_ia32_lfence (void)
11581 void __builtin_ia32_mfence (void)
11582 v16qi __builtin_ia32_loaddqu (const char *)
11583 void __builtin_ia32_storedqu (char *, v16qi)
11584 v1di __builtin_ia32_pmuludq (v2si, v2si)
11585 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
11586 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
11587 v4si __builtin_ia32_pslld128 (v4si, v4si)
11588 v2di __builtin_ia32_psllq128 (v2di, v2di)
11589 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
11590 v4si __builtin_ia32_psrld128 (v4si, v4si)
11591 v2di __builtin_ia32_psrlq128 (v2di, v2di)
11592 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
11593 v4si __builtin_ia32_psrad128 (v4si, v4si)
11594 v2di __builtin_ia32_pslldqi128 (v2di, int)
11595 v8hi __builtin_ia32_psllwi128 (v8hi, int)
11596 v4si __builtin_ia32_pslldi128 (v4si, int)
11597 v2di __builtin_ia32_psllqi128 (v2di, int)
11598 v2di __builtin_ia32_psrldqi128 (v2di, int)
11599 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
11600 v4si __builtin_ia32_psrldi128 (v4si, int)
11601 v2di __builtin_ia32_psrlqi128 (v2di, int)
11602 v8hi __builtin_ia32_psrawi128 (v8hi, int)
11603 v4si __builtin_ia32_psradi128 (v4si, int)
11604 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
11605 v2di __builtin_ia32_movq128 (v2di)
11606 @end smallexample
11607
11608 The following built-in functions are available when @option{-msse3} is used.
11609 All of them generate the machine instruction that is part of the name.
11610
11611 @smallexample
11612 v2df __builtin_ia32_addsubpd (v2df, v2df)
11613 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
11614 v2df __builtin_ia32_haddpd (v2df, v2df)
11615 v4sf __builtin_ia32_haddps (v4sf, v4sf)
11616 v2df __builtin_ia32_hsubpd (v2df, v2df)
11617 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
11618 v16qi __builtin_ia32_lddqu (char const *)
11619 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
11620 v4sf __builtin_ia32_movshdup (v4sf)
11621 v4sf __builtin_ia32_movsldup (v4sf)
11622 void __builtin_ia32_mwait (unsigned int, unsigned int)
11623 @end smallexample
11624
11625 The following built-in functions are available when @option{-mssse3} is used.
11626 All of them generate the machine instruction that is part of the name.
11627
11628 @smallexample
11629 v2si __builtin_ia32_phaddd (v2si, v2si)
11630 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
11631 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
11632 v2si __builtin_ia32_phsubd (v2si, v2si)
11633 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
11634 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
11635 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
11636 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
11637 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
11638 v8qi __builtin_ia32_psignb (v8qi, v8qi)
11639 v2si __builtin_ia32_psignd (v2si, v2si)
11640 v4hi __builtin_ia32_psignw (v4hi, v4hi)
11641 v1di __builtin_ia32_palignr (v1di, v1di, int)
11642 v8qi __builtin_ia32_pabsb (v8qi)
11643 v2si __builtin_ia32_pabsd (v2si)
11644 v4hi __builtin_ia32_pabsw (v4hi)
11645 @end smallexample
11646
11647 The following built-in functions are available when @option{-mssse3} is used.
11648 All of them generate the machine instruction that is part of the name.
11649
11650 @smallexample
11651 v4si __builtin_ia32_phaddd128 (v4si, v4si)
11652 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
11653 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
11654 v4si __builtin_ia32_phsubd128 (v4si, v4si)
11655 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
11656 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
11657 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
11658 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
11659 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
11660 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
11661 v4si __builtin_ia32_psignd128 (v4si, v4si)
11662 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
11663 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
11664 v16qi __builtin_ia32_pabsb128 (v16qi)
11665 v4si __builtin_ia32_pabsd128 (v4si)
11666 v8hi __builtin_ia32_pabsw128 (v8hi)
11667 @end smallexample
11668
11669 The following built-in functions are available when @option{-msse4.1} is
11670 used. All of them generate the machine instruction that is part of the
11671 name.
11672
11673 @smallexample
11674 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
11675 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
11676 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
11677 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
11678 v2df __builtin_ia32_dppd (v2df, v2df, const int)
11679 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
11680 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
11681 v2di __builtin_ia32_movntdqa (v2di *);
11682 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
11683 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
11684 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
11685 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
11686 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
11687 v8hi __builtin_ia32_phminposuw128 (v8hi)
11688 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
11689 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
11690 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
11691 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
11692 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
11693 v4si __builtin_ia32_pminsd128 (v4si, v4si)
11694 v4si __builtin_ia32_pminud128 (v4si, v4si)
11695 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
11696 v4si __builtin_ia32_pmovsxbd128 (v16qi)
11697 v2di __builtin_ia32_pmovsxbq128 (v16qi)
11698 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
11699 v2di __builtin_ia32_pmovsxdq128 (v4si)
11700 v4si __builtin_ia32_pmovsxwd128 (v8hi)
11701 v2di __builtin_ia32_pmovsxwq128 (v8hi)
11702 v4si __builtin_ia32_pmovzxbd128 (v16qi)
11703 v2di __builtin_ia32_pmovzxbq128 (v16qi)
11704 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
11705 v2di __builtin_ia32_pmovzxdq128 (v4si)
11706 v4si __builtin_ia32_pmovzxwd128 (v8hi)
11707 v2di __builtin_ia32_pmovzxwq128 (v8hi)
11708 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
11709 v4si __builtin_ia32_pmulld128 (v4si, v4si)
11710 int __builtin_ia32_ptestc128 (v2di, v2di)
11711 int __builtin_ia32_ptestnzc128 (v2di, v2di)
11712 int __builtin_ia32_ptestz128 (v2di, v2di)
11713 v2df __builtin_ia32_roundpd (v2df, const int)
11714 v4sf __builtin_ia32_roundps (v4sf, const int)
11715 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
11716 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
11717 @end smallexample
11718
11719 The following built-in functions are available when @option{-msse4.1} is
11720 used.
11721
11722 @table @code
11723 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
11724 Generates the @code{insertps} machine instruction.
11725 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
11726 Generates the @code{pextrb} machine instruction.
11727 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
11728 Generates the @code{pinsrb} machine instruction.
11729 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
11730 Generates the @code{pinsrd} machine instruction.
11731 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
11732 Generates the @code{pinsrq} machine instruction in 64bit mode.
11733 @end table
11734
11735 The following built-in functions are changed to generate new SSE4.1
11736 instructions when @option{-msse4.1} is used.
11737
11738 @table @code
11739 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
11740 Generates the @code{extractps} machine instruction.
11741 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
11742 Generates the @code{pextrd} machine instruction.
11743 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
11744 Generates the @code{pextrq} machine instruction in 64bit mode.
11745 @end table
11746
11747 The following built-in functions are available when @option{-msse4.2} is
11748 used. All of them generate the machine instruction that is part of the
11749 name.
11750
11751 @smallexample
11752 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
11753 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
11754 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
11755 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
11756 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
11757 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
11758 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
11759 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
11760 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
11761 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
11762 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
11763 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
11764 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
11765 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
11766 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
11767 @end smallexample
11768
11769 The following built-in functions are available when @option{-msse4.2} is
11770 used.
11771
11772 @table @code
11773 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
11774 Generates the @code{crc32b} machine instruction.
11775 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
11776 Generates the @code{crc32w} machine instruction.
11777 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
11778 Generates the @code{crc32l} machine instruction.
11779 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
11780 Generates the @code{crc32q} machine instruction.
11781 @end table
11782
11783 The following built-in functions are changed to generate new SSE4.2
11784 instructions when @option{-msse4.2} is used.
11785
11786 @table @code
11787 @item int __builtin_popcount (unsigned int)
11788 Generates the @code{popcntl} machine instruction.
11789 @item int __builtin_popcountl (unsigned long)
11790 Generates the @code{popcntl} or @code{popcntq} machine instruction,
11791 depending on the size of @code{unsigned long}.
11792 @item int __builtin_popcountll (unsigned long long)
11793 Generates the @code{popcntq} machine instruction.
11794 @end table
11795
11796 The following built-in functions are available when @option{-mavx} is
11797 used. All of them generate the machine instruction that is part of the
11798 name.
11799
11800 @smallexample
11801 v4df __builtin_ia32_addpd256 (v4df,v4df)
11802 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
11803 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
11804 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
11805 v4df __builtin_ia32_andnpd256 (v4df,v4df)
11806 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
11807 v4df __builtin_ia32_andpd256 (v4df,v4df)
11808 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
11809 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
11810 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
11811 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
11812 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
11813 v2df __builtin_ia32_cmppd (v2df,v2df,int)
11814 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
11815 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
11816 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
11817 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
11818 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
11819 v4df __builtin_ia32_cvtdq2pd256 (v4si)
11820 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
11821 v4si __builtin_ia32_cvtpd2dq256 (v4df)
11822 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
11823 v8si __builtin_ia32_cvtps2dq256 (v8sf)
11824 v4df __builtin_ia32_cvtps2pd256 (v4sf)
11825 v4si __builtin_ia32_cvttpd2dq256 (v4df)
11826 v8si __builtin_ia32_cvttps2dq256 (v8sf)
11827 v4df __builtin_ia32_divpd256 (v4df,v4df)
11828 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
11829 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
11830 v4df __builtin_ia32_haddpd256 (v4df,v4df)
11831 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
11832 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
11833 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
11834 v32qi __builtin_ia32_lddqu256 (pcchar)
11835 v32qi __builtin_ia32_loaddqu256 (pcchar)
11836 v4df __builtin_ia32_loadupd256 (pcdouble)
11837 v8sf __builtin_ia32_loadups256 (pcfloat)
11838 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
11839 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
11840 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
11841 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
11842 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
11843 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
11844 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
11845 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
11846 v4df __builtin_ia32_maxpd256 (v4df,v4df)
11847 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
11848 v4df __builtin_ia32_minpd256 (v4df,v4df)
11849 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
11850 v4df __builtin_ia32_movddup256 (v4df)
11851 int __builtin_ia32_movmskpd256 (v4df)
11852 int __builtin_ia32_movmskps256 (v8sf)
11853 v8sf __builtin_ia32_movshdup256 (v8sf)
11854 v8sf __builtin_ia32_movsldup256 (v8sf)
11855 v4df __builtin_ia32_mulpd256 (v4df,v4df)
11856 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
11857 v4df __builtin_ia32_orpd256 (v4df,v4df)
11858 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
11859 v2df __builtin_ia32_pd_pd256 (v4df)
11860 v4df __builtin_ia32_pd256_pd (v2df)
11861 v4sf __builtin_ia32_ps_ps256 (v8sf)
11862 v8sf __builtin_ia32_ps256_ps (v4sf)
11863 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
11864 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
11865 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
11866 v8sf __builtin_ia32_rcpps256 (v8sf)
11867 v4df __builtin_ia32_roundpd256 (v4df,int)
11868 v8sf __builtin_ia32_roundps256 (v8sf,int)
11869 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
11870 v8sf __builtin_ia32_rsqrtps256 (v8sf)
11871 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
11872 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
11873 v4si __builtin_ia32_si_si256 (v8si)
11874 v8si __builtin_ia32_si256_si (v4si)
11875 v4df __builtin_ia32_sqrtpd256 (v4df)
11876 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
11877 v8sf __builtin_ia32_sqrtps256 (v8sf)
11878 void __builtin_ia32_storedqu256 (pchar,v32qi)
11879 void __builtin_ia32_storeupd256 (pdouble,v4df)
11880 void __builtin_ia32_storeups256 (pfloat,v8sf)
11881 v4df __builtin_ia32_subpd256 (v4df,v4df)
11882 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
11883 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
11884 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
11885 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
11886 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
11887 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
11888 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
11889 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
11890 v4sf __builtin_ia32_vbroadcastss (pcfloat)
11891 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
11892 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
11893 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
11894 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
11895 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
11896 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
11897 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
11898 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
11899 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
11900 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
11901 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
11902 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
11903 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
11904 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
11905 v2df __builtin_ia32_vpermilpd (v2df,int)
11906 v4df __builtin_ia32_vpermilpd256 (v4df,int)
11907 v4sf __builtin_ia32_vpermilps (v4sf,int)
11908 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
11909 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
11910 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
11911 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
11912 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
11913 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
11914 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
11915 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
11916 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
11917 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
11918 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
11919 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
11920 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
11921 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
11922 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
11923 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
11924 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
11925 void __builtin_ia32_vzeroall (void)
11926 void __builtin_ia32_vzeroupper (void)
11927 v4df __builtin_ia32_xorpd256 (v4df,v4df)
11928 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
11929 @end smallexample
11930
11931 The following built-in functions are available when @option{-mavx2} is
11932 used. All of them generate the machine instruction that is part of the
11933 name.
11934
11935 @smallexample
11936 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
11937 v32qi __builtin_ia32_pabsb256 (v32qi)
11938 v16hi __builtin_ia32_pabsw256 (v16hi)
11939 v8si __builtin_ia32_pabsd256 (v8si)
11940 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
11941 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
11942 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
11943 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
11944 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
11945 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
11946 v8si __builtin_ia32_paddd256 (v8si,v8si)
11947 v4di __builtin_ia32_paddq256 (v4di,v4di)
11948 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
11949 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
11950 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
11951 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
11952 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
11953 v4di __builtin_ia32_andsi256 (v4di,v4di)
11954 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
11955 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
11956 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
11957 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
11958 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
11959 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
11960 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
11961 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
11962 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
11963 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
11964 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
11965 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
11966 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
11967 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
11968 v8si __builtin_ia32_phaddd256 (v8si,v8si)
11969 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
11970 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
11971 v8si __builtin_ia32_phsubd256 (v8si,v8si)
11972 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
11973 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
11974 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
11975 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
11976 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
11977 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
11978 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
11979 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
11980 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
11981 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
11982 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
11983 v8si __builtin_ia32_pminsd256 (v8si,v8si)
11984 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
11985 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
11986 v8si __builtin_ia32_pminud256 (v8si,v8si)
11987 int __builtin_ia32_pmovmskb256 (v32qi)
11988 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
11989 v8si __builtin_ia32_pmovsxbd256 (v16qi)
11990 v4di __builtin_ia32_pmovsxbq256 (v16qi)
11991 v8si __builtin_ia32_pmovsxwd256 (v8hi)
11992 v4di __builtin_ia32_pmovsxwq256 (v8hi)
11993 v4di __builtin_ia32_pmovsxdq256 (v4si)
11994 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
11995 v8si __builtin_ia32_pmovzxbd256 (v16qi)
11996 v4di __builtin_ia32_pmovzxbq256 (v16qi)
11997 v8si __builtin_ia32_pmovzxwd256 (v8hi)
11998 v4di __builtin_ia32_pmovzxwq256 (v8hi)
11999 v4di __builtin_ia32_pmovzxdq256 (v4si)
12000 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
12001 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
12002 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
12003 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
12004 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
12005 v8si __builtin_ia32_pmulld256 (v8si,v8si)
12006 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
12007 v4di __builtin_ia32_por256 (v4di,v4di)
12008 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
12009 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
12010 v8si __builtin_ia32_pshufd256 (v8si,int)
12011 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
12012 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
12013 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
12014 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
12015 v8si __builtin_ia32_psignd256 (v8si,v8si)
12016 v4di __builtin_ia32_pslldqi256 (v4di,int)
12017 v16hi __builtin_ia32_psllwi256 (16hi,int)
12018 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
12019 v8si __builtin_ia32_pslldi256 (v8si,int)
12020 v8si __builtin_ia32_pslld256(v8si,v4si)
12021 v4di __builtin_ia32_psllqi256 (v4di,int)
12022 v4di __builtin_ia32_psllq256(v4di,v2di)
12023 v16hi __builtin_ia32_psrawi256 (v16hi,int)
12024 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
12025 v8si __builtin_ia32_psradi256 (v8si,int)
12026 v8si __builtin_ia32_psrad256 (v8si,v4si)
12027 v4di __builtin_ia32_psrldqi256 (v4di, int)
12028 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
12029 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
12030 v8si __builtin_ia32_psrldi256 (v8si,int)
12031 v8si __builtin_ia32_psrld256 (v8si,v4si)
12032 v4di __builtin_ia32_psrlqi256 (v4di,int)
12033 v4di __builtin_ia32_psrlq256(v4di,v2di)
12034 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
12035 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
12036 v8si __builtin_ia32_psubd256 (v8si,v8si)
12037 v4di __builtin_ia32_psubq256 (v4di,v4di)
12038 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
12039 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
12040 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
12041 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
12042 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
12043 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
12044 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
12045 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
12046 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
12047 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
12048 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
12049 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
12050 v4di __builtin_ia32_pxor256 (v4di,v4di)
12051 v4di __builtin_ia32_movntdqa256 (pv4di)
12052 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
12053 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
12054 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
12055 v4di __builtin_ia32_vbroadcastsi256 (v2di)
12056 v4si __builtin_ia32_pblendd128 (v4si,v4si)
12057 v8si __builtin_ia32_pblendd256 (v8si,v8si)
12058 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
12059 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
12060 v8si __builtin_ia32_pbroadcastd256 (v4si)
12061 v4di __builtin_ia32_pbroadcastq256 (v2di)
12062 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
12063 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
12064 v4si __builtin_ia32_pbroadcastd128 (v4si)
12065 v2di __builtin_ia32_pbroadcastq128 (v2di)
12066 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
12067 v4df __builtin_ia32_permdf256 (v4df,int)
12068 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
12069 v4di __builtin_ia32_permdi256 (v4di,int)
12070 v4di __builtin_ia32_permti256 (v4di,v4di,int)
12071 v4di __builtin_ia32_extract128i256 (v4di,int)
12072 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
12073 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
12074 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
12075 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
12076 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
12077 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
12078 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
12079 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
12080 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
12081 v8si __builtin_ia32_psllv8si (v8si,v8si)
12082 v4si __builtin_ia32_psllv4si (v4si,v4si)
12083 v4di __builtin_ia32_psllv4di (v4di,v4di)
12084 v2di __builtin_ia32_psllv2di (v2di,v2di)
12085 v8si __builtin_ia32_psrav8si (v8si,v8si)
12086 v4si __builtin_ia32_psrav4si (v4si,v4si)
12087 v8si __builtin_ia32_psrlv8si (v8si,v8si)
12088 v4si __builtin_ia32_psrlv4si (v4si,v4si)
12089 v4di __builtin_ia32_psrlv4di (v4di,v4di)
12090 v2di __builtin_ia32_psrlv2di (v2di,v2di)
12091 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
12092 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
12093 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
12094 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
12095 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
12096 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
12097 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
12098 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
12099 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
12100 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
12101 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
12102 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
12103 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
12104 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
12105 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
12106 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
12107 @end smallexample
12108
12109 The following built-in functions are available when @option{-maes} is
12110 used. All of them generate the machine instruction that is part of the
12111 name.
12112
12113 @smallexample
12114 v2di __builtin_ia32_aesenc128 (v2di, v2di)
12115 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
12116 v2di __builtin_ia32_aesdec128 (v2di, v2di)
12117 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
12118 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
12119 v2di __builtin_ia32_aesimc128 (v2di)
12120 @end smallexample
12121
12122 The following built-in function is available when @option{-mpclmul} is
12123 used.
12124
12125 @table @code
12126 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
12127 Generates the @code{pclmulqdq} machine instruction.
12128 @end table
12129
12130 The following built-in function is available when @option{-mfsgsbase} is
12131 used. All of them generate the machine instruction that is part of the
12132 name.
12133
12134 @smallexample
12135 unsigned int __builtin_ia32_rdfsbase32 (void)
12136 unsigned long long __builtin_ia32_rdfsbase64 (void)
12137 unsigned int __builtin_ia32_rdgsbase32 (void)
12138 unsigned long long __builtin_ia32_rdgsbase64 (void)
12139 void _writefsbase_u32 (unsigned int)
12140 void _writefsbase_u64 (unsigned long long)
12141 void _writegsbase_u32 (unsigned int)
12142 void _writegsbase_u64 (unsigned long long)
12143 @end smallexample
12144
12145 The following built-in function is available when @option{-mrdrnd} is
12146 used. All of them generate the machine instruction that is part of the
12147 name.
12148
12149 @smallexample
12150 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
12151 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
12152 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
12153 @end smallexample
12154
12155 The following built-in functions are available when @option{-msse4a} is used.
12156 All of them generate the machine instruction that is part of the name.
12157
12158 @smallexample
12159 void __builtin_ia32_movntsd (double *, v2df)
12160 void __builtin_ia32_movntss (float *, v4sf)
12161 v2di __builtin_ia32_extrq (v2di, v16qi)
12162 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
12163 v2di __builtin_ia32_insertq (v2di, v2di)
12164 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
12165 @end smallexample
12166
12167 The following built-in functions are available when @option{-mxop} is used.
12168 @smallexample
12169 v2df __builtin_ia32_vfrczpd (v2df)
12170 v4sf __builtin_ia32_vfrczps (v4sf)
12171 v2df __builtin_ia32_vfrczsd (v2df)
12172 v4sf __builtin_ia32_vfrczss (v4sf)
12173 v4df __builtin_ia32_vfrczpd256 (v4df)
12174 v8sf __builtin_ia32_vfrczps256 (v8sf)
12175 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
12176 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
12177 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
12178 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
12179 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
12180 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
12181 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
12182 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
12183 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
12184 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
12185 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
12186 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
12187 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
12188 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
12189 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12190 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
12191 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
12192 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
12193 v4si __builtin_ia32_vpcomequd (v4si, v4si)
12194 v2di __builtin_ia32_vpcomequq (v2di, v2di)
12195 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
12196 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12197 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
12198 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
12199 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
12200 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
12201 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
12202 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
12203 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
12204 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
12205 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
12206 v4si __builtin_ia32_vpcomged (v4si, v4si)
12207 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
12208 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
12209 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
12210 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
12211 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
12212 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
12213 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
12214 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
12215 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
12216 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
12217 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
12218 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
12219 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
12220 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
12221 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
12222 v4si __builtin_ia32_vpcomled (v4si, v4si)
12223 v2di __builtin_ia32_vpcomleq (v2di, v2di)
12224 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
12225 v4si __builtin_ia32_vpcomleud (v4si, v4si)
12226 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
12227 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
12228 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
12229 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
12230 v4si __builtin_ia32_vpcomltd (v4si, v4si)
12231 v2di __builtin_ia32_vpcomltq (v2di, v2di)
12232 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
12233 v4si __builtin_ia32_vpcomltud (v4si, v4si)
12234 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
12235 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
12236 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
12237 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
12238 v4si __builtin_ia32_vpcomned (v4si, v4si)
12239 v2di __builtin_ia32_vpcomneq (v2di, v2di)
12240 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
12241 v4si __builtin_ia32_vpcomneud (v4si, v4si)
12242 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
12243 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
12244 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
12245 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
12246 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
12247 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
12248 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
12249 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
12250 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
12251 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
12252 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
12253 v4si __builtin_ia32_vphaddbd (v16qi)
12254 v2di __builtin_ia32_vphaddbq (v16qi)
12255 v8hi __builtin_ia32_vphaddbw (v16qi)
12256 v2di __builtin_ia32_vphadddq (v4si)
12257 v4si __builtin_ia32_vphaddubd (v16qi)
12258 v2di __builtin_ia32_vphaddubq (v16qi)
12259 v8hi __builtin_ia32_vphaddubw (v16qi)
12260 v2di __builtin_ia32_vphaddudq (v4si)
12261 v4si __builtin_ia32_vphadduwd (v8hi)
12262 v2di __builtin_ia32_vphadduwq (v8hi)
12263 v4si __builtin_ia32_vphaddwd (v8hi)
12264 v2di __builtin_ia32_vphaddwq (v8hi)
12265 v8hi __builtin_ia32_vphsubbw (v16qi)
12266 v2di __builtin_ia32_vphsubdq (v4si)
12267 v4si __builtin_ia32_vphsubwd (v8hi)
12268 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
12269 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
12270 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
12271 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
12272 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
12273 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
12274 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
12275 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
12276 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
12277 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
12278 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
12279 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
12280 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
12281 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
12282 v4si __builtin_ia32_vprotd (v4si, v4si)
12283 v2di __builtin_ia32_vprotq (v2di, v2di)
12284 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
12285 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
12286 v4si __builtin_ia32_vpshad (v4si, v4si)
12287 v2di __builtin_ia32_vpshaq (v2di, v2di)
12288 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
12289 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
12290 v4si __builtin_ia32_vpshld (v4si, v4si)
12291 v2di __builtin_ia32_vpshlq (v2di, v2di)
12292 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
12293 @end smallexample
12294
12295 The following built-in functions are available when @option{-mfma4} is used.
12296 All of them generate the machine instruction that is part of the name.
12297
12298 @smallexample
12299 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
12300 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
12301 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
12302 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
12303 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
12304 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
12305 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
12306 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
12307 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
12308 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
12309 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
12310 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
12311 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
12312 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
12313 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
12314 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
12315 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
12316 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
12317 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
12318 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
12319 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
12320 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
12321 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
12322 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
12323 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
12324 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
12325 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
12326 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
12327 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
12328 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
12329 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
12330 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
12331
12332 @end smallexample
12333
12334 The following built-in functions are available when @option{-mlwp} is used.
12335
12336 @smallexample
12337 void __builtin_ia32_llwpcb16 (void *);
12338 void __builtin_ia32_llwpcb32 (void *);
12339 void __builtin_ia32_llwpcb64 (void *);
12340 void * __builtin_ia32_llwpcb16 (void);
12341 void * __builtin_ia32_llwpcb32 (void);
12342 void * __builtin_ia32_llwpcb64 (void);
12343 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
12344 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
12345 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
12346 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
12347 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
12348 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
12349 @end smallexample
12350
12351 The following built-in functions are available when @option{-mbmi} is used.
12352 All of them generate the machine instruction that is part of the name.
12353 @smallexample
12354 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
12355 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
12356 @end smallexample
12357
12358 The following built-in functions are available when @option{-mbmi2} is used.
12359 All of them generate the machine instruction that is part of the name.
12360 @smallexample
12361 unsigned int _bzhi_u32 (unsigned int, unsigned int)
12362 unsigned int _pdep_u32 (unsigned int, unsigned int)
12363 unsigned int _pext_u32 (unsigned int, unsigned int)
12364 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
12365 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
12366 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
12367 @end smallexample
12368
12369 The following built-in functions are available when @option{-mlzcnt} is used.
12370 All of them generate the machine instruction that is part of the name.
12371 @smallexample
12372 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
12373 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
12374 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
12375 @end smallexample
12376
12377 The following built-in functions are available when @option{-mfxsr} is used.
12378 All of them generate the machine instruction that is part of the name.
12379 @smallexample
12380 void __builtin_ia32_fxsave (void *)
12381 void __builtin_ia32_fxrstor (void *)
12382 void __builtin_ia32_fxsave64 (void *)
12383 void __builtin_ia32_fxrstor64 (void *)
12384 @end smallexample
12385
12386 The following built-in functions are available when @option{-mxsave} is used.
12387 All of them generate the machine instruction that is part of the name.
12388 @smallexample
12389 void __builtin_ia32_xsave (void *, long long)
12390 void __builtin_ia32_xrstor (void *, long long)
12391 void __builtin_ia32_xsave64 (void *, long long)
12392 void __builtin_ia32_xrstor64 (void *, long long)
12393 @end smallexample
12394
12395 The following built-in functions are available when @option{-mxsaveopt} is used.
12396 All of them generate the machine instruction that is part of the name.
12397 @smallexample
12398 void __builtin_ia32_xsaveopt (void *, long long)
12399 void __builtin_ia32_xsaveopt64 (void *, long long)
12400 @end smallexample
12401
12402 The following built-in functions are available when @option{-mtbm} is used.
12403 Both of them generate the immediate form of the bextr machine instruction.
12404 @smallexample
12405 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
12406 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
12407 @end smallexample
12408
12409
12410 The following built-in functions are available when @option{-m3dnow} is used.
12411 All of them generate the machine instruction that is part of the name.
12412
12413 @smallexample
12414 void __builtin_ia32_femms (void)
12415 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
12416 v2si __builtin_ia32_pf2id (v2sf)
12417 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
12418 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
12419 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
12420 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
12421 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
12422 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
12423 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
12424 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
12425 v2sf __builtin_ia32_pfrcp (v2sf)
12426 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
12427 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
12428 v2sf __builtin_ia32_pfrsqrt (v2sf)
12429 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
12430 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
12431 v2sf __builtin_ia32_pi2fd (v2si)
12432 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
12433 @end smallexample
12434
12435 The following built-in functions are available when both @option{-m3dnow}
12436 and @option{-march=athlon} are used. All of them generate the machine
12437 instruction that is part of the name.
12438
12439 @smallexample
12440 v2si __builtin_ia32_pf2iw (v2sf)
12441 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
12442 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
12443 v2sf __builtin_ia32_pi2fw (v2si)
12444 v2sf __builtin_ia32_pswapdsf (v2sf)
12445 v2si __builtin_ia32_pswapdsi (v2si)
12446 @end smallexample
12447
12448 The following built-in functions are available when @option{-mrtm} is used
12449 They are used for restricted transactional memory. These are the internal
12450 low level functions. Normally the functions in
12451 @ref{X86 transactional memory intrinsics} should be used instead.
12452
12453 @smallexample
12454 int __builtin_ia32_xbegin ()
12455 void __builtin_ia32_xend ()
12456 void __builtin_ia32_xabort (status)
12457 int __builtin_ia32_xtest ()
12458 @end smallexample
12459
12460 @node X86 transactional memory intrinsics
12461 @subsection X86 transaction memory intrinsics
12462
12463 Hardware transactional memory intrinsics for i386. These allow to use
12464 memory transactions with RTM (Restricted Transactional Memory).
12465 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
12466 This support is enabled with the @option{-mrtm} option.
12467
12468 A memory transaction commits all changes to memory in an atomic way,
12469 as visible to other threads. If the transaction fails it is rolled back
12470 and all side effects discarded.
12471
12472 Generally there is no guarantee that a memory transaction ever succeeds
12473 and suitable fallback code always needs to be supplied.
12474
12475 @deftypefn {RTM Function} {unsigned} _xbegin ()
12476 Start a RTM (Restricted Transactional Memory) transaction.
12477 Returns _XBEGIN_STARTED when the transaction
12478 started successfully (note this is not 0, so the constant has to be
12479 explicitely tested). When the transaction aborts all side effects
12480 are undone and an abort code is returned. There is no guarantee
12481 any transaction ever succeeds, so there always needs to be a valid
12482 tested fallback path.
12483 @end deftypefn
12484
12485 @smallexample
12486 #include <immintrin.h>
12487
12488 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
12489 ... transaction code...
12490 _xend ();
12491 @} else @{
12492 ... non transactional fallback path...
12493 @}
12494 @end smallexample
12495
12496 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
12497
12498 @table @code
12499 @item _XABORT_EXPLICIT
12500 Transaction explicitely aborted with @code{_xabort}. The parameter passed
12501 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
12502 @item _XABORT_RETRY
12503 Transaction retry is possible.
12504 @item _XABORT_CONFLICT
12505 Transaction abort due to a memory conflict with another thread
12506 @item _XABORT_CAPACITY
12507 Transaction abort due to the transaction using too much memory
12508 @item _XABORT_DEBUG
12509 Transaction abort due to a debug trap
12510 @item _XABORT_NESTED
12511 Transaction abort in a inner nested transaction
12512 @end table
12513
12514 @deftypefn {RTM Function} {void} _xend ()
12515 Commit the current transaction. When no transaction is active this will
12516 fault. All memory side effects of the transactions will become visible
12517 to other threads in an atomic matter.
12518 @end deftypefn
12519
12520 @deftypefn {RTM Function} {int} _xtest ()
12521 Return a value not zero when a transaction is currently active, otherwise 0.
12522 @end deftypefn
12523
12524 @deftypefn {RTM Function} {void} _xabort (status)
12525 Abort the current transaction. When no transaction is active this is a no-op.
12526 status must be a 8bit constant, that is included in the status code returned
12527 by @code{_xbegin}
12528 @end deftypefn
12529
12530 @node MIPS DSP Built-in Functions
12531 @subsection MIPS DSP Built-in Functions
12532
12533 The MIPS DSP Application-Specific Extension (ASE) includes new
12534 instructions that are designed to improve the performance of DSP and
12535 media applications. It provides instructions that operate on packed
12536 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12537
12538 GCC supports MIPS DSP operations using both the generic
12539 vector extensions (@pxref{Vector Extensions}) and a collection of
12540 MIPS-specific built-in functions. Both kinds of support are
12541 enabled by the @option{-mdsp} command-line option.
12542
12543 Revision 2 of the ASE was introduced in the second half of 2006.
12544 This revision adds extra instructions to the original ASE, but is
12545 otherwise backwards-compatible with it. You can select revision 2
12546 using the command-line option @option{-mdspr2}; this option implies
12547 @option{-mdsp}.
12548
12549 The SCOUNT and POS bits of the DSP control register are global. The
12550 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12551 POS bits. During optimization, the compiler does not delete these
12552 instructions and it does not delete calls to functions containing
12553 these instructions.
12554
12555 At present, GCC only provides support for operations on 32-bit
12556 vectors. The vector type associated with 8-bit integer data is
12557 usually called @code{v4i8}, the vector type associated with Q7
12558 is usually called @code{v4q7}, the vector type associated with 16-bit
12559 integer data is usually called @code{v2i16}, and the vector type
12560 associated with Q15 is usually called @code{v2q15}. They can be
12561 defined in C as follows:
12562
12563 @smallexample
12564 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12565 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12566 typedef short v2i16 __attribute__ ((vector_size(4)));
12567 typedef short v2q15 __attribute__ ((vector_size(4)));
12568 @end smallexample
12569
12570 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12571 initialized in the same way as aggregates. For example:
12572
12573 @smallexample
12574 v4i8 a = @{1, 2, 3, 4@};
12575 v4i8 b;
12576 b = (v4i8) @{5, 6, 7, 8@};
12577
12578 v2q15 c = @{0x0fcb, 0x3a75@};
12579 v2q15 d;
12580 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12581 @end smallexample
12582
12583 @emph{Note:} The CPU's endianness determines the order in which values
12584 are packed. On little-endian targets, the first value is the least
12585 significant and the last value is the most significant. The opposite
12586 order applies to big-endian targets. For example, the code above
12587 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12588 and @code{4} on big-endian targets.
12589
12590 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12591 representation. As shown in this example, the integer representation
12592 of a Q7 value can be obtained by multiplying the fractional value by
12593 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
12594 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
12595 @code{0x1.0p31}.
12596
12597 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12598 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
12599 and @code{c} and @code{d} are @code{v2q15} values.
12600
12601 @multitable @columnfractions .50 .50
12602 @item C code @tab MIPS instruction
12603 @item @code{a + b} @tab @code{addu.qb}
12604 @item @code{c + d} @tab @code{addq.ph}
12605 @item @code{a - b} @tab @code{subu.qb}
12606 @item @code{c - d} @tab @code{subq.ph}
12607 @end multitable
12608
12609 The table below lists the @code{v2i16} operation for which
12610 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
12611 @code{v2i16} values.
12612
12613 @multitable @columnfractions .50 .50
12614 @item C code @tab MIPS instruction
12615 @item @code{e * f} @tab @code{mul.ph}
12616 @end multitable
12617
12618 It is easier to describe the DSP built-in functions if we first define
12619 the following types:
12620
12621 @smallexample
12622 typedef int q31;
12623 typedef int i32;
12624 typedef unsigned int ui32;
12625 typedef long long a64;
12626 @end smallexample
12627
12628 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12629 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12630 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
12631 @code{long long}, but we use @code{a64} to indicate values that are
12632 placed in one of the four DSP accumulators (@code{$ac0},
12633 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12634
12635 Also, some built-in functions prefer or require immediate numbers as
12636 parameters, because the corresponding DSP instructions accept both immediate
12637 numbers and register operands, or accept immediate numbers only. The
12638 immediate parameters are listed as follows.
12639
12640 @smallexample
12641 imm0_3: 0 to 3.
12642 imm0_7: 0 to 7.
12643 imm0_15: 0 to 15.
12644 imm0_31: 0 to 31.
12645 imm0_63: 0 to 63.
12646 imm0_255: 0 to 255.
12647 imm_n32_31: -32 to 31.
12648 imm_n512_511: -512 to 511.
12649 @end smallexample
12650
12651 The following built-in functions map directly to a particular MIPS DSP
12652 instruction. Please refer to the architecture specification
12653 for details on what each instruction does.
12654
12655 @smallexample
12656 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12657 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12658 q31 __builtin_mips_addq_s_w (q31, q31)
12659 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12660 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12661 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12662 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12663 q31 __builtin_mips_subq_s_w (q31, q31)
12664 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12665 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12666 i32 __builtin_mips_addsc (i32, i32)
12667 i32 __builtin_mips_addwc (i32, i32)
12668 i32 __builtin_mips_modsub (i32, i32)
12669 i32 __builtin_mips_raddu_w_qb (v4i8)
12670 v2q15 __builtin_mips_absq_s_ph (v2q15)
12671 q31 __builtin_mips_absq_s_w (q31)
12672 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12673 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12674 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12675 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12676 q31 __builtin_mips_preceq_w_phl (v2q15)
12677 q31 __builtin_mips_preceq_w_phr (v2q15)
12678 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12679 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12680 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12681 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12682 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12683 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12684 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12685 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12686 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12687 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12688 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12689 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12690 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12691 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12692 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12693 q31 __builtin_mips_shll_s_w (q31, i32)
12694 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12695 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12696 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12697 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12698 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12699 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12700 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12701 q31 __builtin_mips_shra_r_w (q31, i32)
12702 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12703 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12704 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12705 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12706 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12707 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12708 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12709 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12710 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12711 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12712 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12713 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12714 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12715 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12716 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12717 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12718 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12719 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12720 i32 __builtin_mips_bitrev (i32)
12721 i32 __builtin_mips_insv (i32, i32)
12722 v4i8 __builtin_mips_repl_qb (imm0_255)
12723 v4i8 __builtin_mips_repl_qb (i32)
12724 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12725 v2q15 __builtin_mips_repl_ph (i32)
12726 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12727 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12728 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12729 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
12730 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
12731 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
12732 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
12733 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
12734 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
12735 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
12736 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
12737 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
12738 i32 __builtin_mips_extr_w (a64, imm0_31)
12739 i32 __builtin_mips_extr_w (a64, i32)
12740 i32 __builtin_mips_extr_r_w (a64, imm0_31)
12741 i32 __builtin_mips_extr_s_h (a64, i32)
12742 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
12743 i32 __builtin_mips_extr_rs_w (a64, i32)
12744 i32 __builtin_mips_extr_s_h (a64, imm0_31)
12745 i32 __builtin_mips_extr_r_w (a64, i32)
12746 i32 __builtin_mips_extp (a64, imm0_31)
12747 i32 __builtin_mips_extp (a64, i32)
12748 i32 __builtin_mips_extpdp (a64, imm0_31)
12749 i32 __builtin_mips_extpdp (a64, i32)
12750 a64 __builtin_mips_shilo (a64, imm_n32_31)
12751 a64 __builtin_mips_shilo (a64, i32)
12752 a64 __builtin_mips_mthlip (a64, i32)
12753 void __builtin_mips_wrdsp (i32, imm0_63)
12754 i32 __builtin_mips_rddsp (imm0_63)
12755 i32 __builtin_mips_lbux (void *, i32)
12756 i32 __builtin_mips_lhx (void *, i32)
12757 i32 __builtin_mips_lwx (void *, i32)
12758 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
12759 i32 __builtin_mips_bposge32 (void)
12760 a64 __builtin_mips_madd (a64, i32, i32);
12761 a64 __builtin_mips_maddu (a64, ui32, ui32);
12762 a64 __builtin_mips_msub (a64, i32, i32);
12763 a64 __builtin_mips_msubu (a64, ui32, ui32);
12764 a64 __builtin_mips_mult (i32, i32);
12765 a64 __builtin_mips_multu (ui32, ui32);
12766 @end smallexample
12767
12768 The following built-in functions map directly to a particular MIPS DSP REV 2
12769 instruction. Please refer to the architecture specification
12770 for details on what each instruction does.
12771
12772 @smallexample
12773 v4q7 __builtin_mips_absq_s_qb (v4q7);
12774 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
12775 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
12776 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
12777 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
12778 i32 __builtin_mips_append (i32, i32, imm0_31);
12779 i32 __builtin_mips_balign (i32, i32, imm0_3);
12780 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
12781 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
12782 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
12783 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
12784 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
12785 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
12786 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
12787 q31 __builtin_mips_mulq_rs_w (q31, q31);
12788 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
12789 q31 __builtin_mips_mulq_s_w (q31, q31);
12790 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
12791 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
12792 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
12793 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
12794 i32 __builtin_mips_prepend (i32, i32, imm0_31);
12795 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
12796 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
12797 v4i8 __builtin_mips_shra_qb (v4i8, i32);
12798 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
12799 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
12800 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
12801 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
12802 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
12803 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
12804 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
12805 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
12806 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
12807 q31 __builtin_mips_addqh_w (q31, q31);
12808 q31 __builtin_mips_addqh_r_w (q31, q31);
12809 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
12810 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
12811 q31 __builtin_mips_subqh_w (q31, q31);
12812 q31 __builtin_mips_subqh_r_w (q31, q31);
12813 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
12814 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
12815 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
12816 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
12817 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
12818 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
12819 @end smallexample
12820
12821
12822 @node MIPS Paired-Single Support
12823 @subsection MIPS Paired-Single Support
12824
12825 The MIPS64 architecture includes a number of instructions that
12826 operate on pairs of single-precision floating-point values.
12827 Each pair is packed into a 64-bit floating-point register,
12828 with one element being designated the ``upper half'' and
12829 the other being designated the ``lower half''.
12830
12831 GCC supports paired-single operations using both the generic
12832 vector extensions (@pxref{Vector Extensions}) and a collection of
12833 MIPS-specific built-in functions. Both kinds of support are
12834 enabled by the @option{-mpaired-single} command-line option.
12835
12836 The vector type associated with paired-single values is usually
12837 called @code{v2sf}. It can be defined in C as follows:
12838
12839 @smallexample
12840 typedef float v2sf __attribute__ ((vector_size (8)));
12841 @end smallexample
12842
12843 @code{v2sf} values are initialized in the same way as aggregates.
12844 For example:
12845
12846 @smallexample
12847 v2sf a = @{1.5, 9.1@};
12848 v2sf b;
12849 float e, f;
12850 b = (v2sf) @{e, f@};
12851 @end smallexample
12852
12853 @emph{Note:} The CPU's endianness determines which value is stored in
12854 the upper half of a register and which value is stored in the lower half.
12855 On little-endian targets, the first value is the lower one and the second
12856 value is the upper one. The opposite order applies to big-endian targets.
12857 For example, the code above sets the lower half of @code{a} to
12858 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
12859
12860 @node MIPS Loongson Built-in Functions
12861 @subsection MIPS Loongson Built-in Functions
12862
12863 GCC provides intrinsics to access the SIMD instructions provided by the
12864 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
12865 available after inclusion of the @code{loongson.h} header file,
12866 operate on the following 64-bit vector types:
12867
12868 @itemize
12869 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
12870 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
12871 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
12872 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
12873 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
12874 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
12875 @end itemize
12876
12877 The intrinsics provided are listed below; each is named after the
12878 machine instruction to which it corresponds, with suffixes added as
12879 appropriate to distinguish intrinsics that expand to the same machine
12880 instruction yet have different argument types. Refer to the architecture
12881 documentation for a description of the functionality of each
12882 instruction.
12883
12884 @smallexample
12885 int16x4_t packsswh (int32x2_t s, int32x2_t t);
12886 int8x8_t packsshb (int16x4_t s, int16x4_t t);
12887 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
12888 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
12889 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
12890 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
12891 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
12892 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
12893 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
12894 uint64_t paddd_u (uint64_t s, uint64_t t);
12895 int64_t paddd_s (int64_t s, int64_t t);
12896 int16x4_t paddsh (int16x4_t s, int16x4_t t);
12897 int8x8_t paddsb (int8x8_t s, int8x8_t t);
12898 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
12899 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
12900 uint64_t pandn_ud (uint64_t s, uint64_t t);
12901 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
12902 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
12903 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
12904 int64_t pandn_sd (int64_t s, int64_t t);
12905 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
12906 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
12907 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
12908 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
12909 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
12910 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
12911 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
12912 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
12913 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
12914 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
12915 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
12916 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
12917 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
12918 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
12919 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
12920 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
12921 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
12922 uint16x4_t pextrh_u (uint16x4_t s, int field);
12923 int16x4_t pextrh_s (int16x4_t s, int field);
12924 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
12925 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
12926 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
12927 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
12928 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
12929 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
12930 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
12931 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
12932 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
12933 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
12934 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
12935 int16x4_t pminsh (int16x4_t s, int16x4_t t);
12936 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
12937 uint8x8_t pmovmskb_u (uint8x8_t s);
12938 int8x8_t pmovmskb_s (int8x8_t s);
12939 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
12940 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
12941 int16x4_t pmullh (int16x4_t s, int16x4_t t);
12942 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
12943 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
12944 uint16x4_t biadd (uint8x8_t s);
12945 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
12946 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
12947 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
12948 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
12949 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
12950 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
12951 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
12952 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
12953 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
12954 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
12955 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
12956 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
12957 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
12958 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
12959 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
12960 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
12961 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
12962 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
12963 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
12964 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
12965 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
12966 uint64_t psubd_u (uint64_t s, uint64_t t);
12967 int64_t psubd_s (int64_t s, int64_t t);
12968 int16x4_t psubsh (int16x4_t s, int16x4_t t);
12969 int8x8_t psubsb (int8x8_t s, int8x8_t t);
12970 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
12971 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
12972 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
12973 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
12974 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
12975 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
12976 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
12977 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
12978 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
12979 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
12980 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
12981 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
12982 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
12983 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
12984 @end smallexample
12985
12986 @menu
12987 * Paired-Single Arithmetic::
12988 * Paired-Single Built-in Functions::
12989 * MIPS-3D Built-in Functions::
12990 @end menu
12991
12992 @node Paired-Single Arithmetic
12993 @subsubsection Paired-Single Arithmetic
12994
12995 The table below lists the @code{v2sf} operations for which hardware
12996 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
12997 values and @code{x} is an integral value.
12998
12999 @multitable @columnfractions .50 .50
13000 @item C code @tab MIPS instruction
13001 @item @code{a + b} @tab @code{add.ps}
13002 @item @code{a - b} @tab @code{sub.ps}
13003 @item @code{-a} @tab @code{neg.ps}
13004 @item @code{a * b} @tab @code{mul.ps}
13005 @item @code{a * b + c} @tab @code{madd.ps}
13006 @item @code{a * b - c} @tab @code{msub.ps}
13007 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13008 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13009 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13010 @end multitable
13011
13012 Note that the multiply-accumulate instructions can be disabled
13013 using the command-line option @code{-mno-fused-madd}.
13014
13015 @node Paired-Single Built-in Functions
13016 @subsubsection Paired-Single Built-in Functions
13017
13018 The following paired-single functions map directly to a particular
13019 MIPS instruction. Please refer to the architecture specification
13020 for details on what each instruction does.
13021
13022 @table @code
13023 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13024 Pair lower lower (@code{pll.ps}).
13025
13026 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13027 Pair upper lower (@code{pul.ps}).
13028
13029 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13030 Pair lower upper (@code{plu.ps}).
13031
13032 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13033 Pair upper upper (@code{puu.ps}).
13034
13035 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13036 Convert pair to paired single (@code{cvt.ps.s}).
13037
13038 @item float __builtin_mips_cvt_s_pl (v2sf)
13039 Convert pair lower to single (@code{cvt.s.pl}).
13040
13041 @item float __builtin_mips_cvt_s_pu (v2sf)
13042 Convert pair upper to single (@code{cvt.s.pu}).
13043
13044 @item v2sf __builtin_mips_abs_ps (v2sf)
13045 Absolute value (@code{abs.ps}).
13046
13047 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13048 Align variable (@code{alnv.ps}).
13049
13050 @emph{Note:} The value of the third parameter must be 0 or 4
13051 modulo 8, otherwise the result is unpredictable. Please read the
13052 instruction description for details.
13053 @end table
13054
13055 The following multi-instruction functions are also available.
13056 In each case, @var{cond} can be any of the 16 floating-point conditions:
13057 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13058 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13059 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13060
13061 @table @code
13062 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13063 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13064 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13065 @code{movt.ps}/@code{movf.ps}).
13066
13067 The @code{movt} functions return the value @var{x} computed by:
13068
13069 @smallexample
13070 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13071 mov.ps @var{x},@var{c}
13072 movt.ps @var{x},@var{d},@var{cc}
13073 @end smallexample
13074
13075 The @code{movf} functions are similar but use @code{movf.ps} instead
13076 of @code{movt.ps}.
13077
13078 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13079 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13080 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13081 @code{bc1t}/@code{bc1f}).
13082
13083 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13084 and return either the upper or lower half of the result. For example:
13085
13086 @smallexample
13087 v2sf a, b;
13088 if (__builtin_mips_upper_c_eq_ps (a, b))
13089 upper_halves_are_equal ();
13090 else
13091 upper_halves_are_unequal ();
13092
13093 if (__builtin_mips_lower_c_eq_ps (a, b))
13094 lower_halves_are_equal ();
13095 else
13096 lower_halves_are_unequal ();
13097 @end smallexample
13098 @end table
13099
13100 @node MIPS-3D Built-in Functions
13101 @subsubsection MIPS-3D Built-in Functions
13102
13103 The MIPS-3D Application-Specific Extension (ASE) includes additional
13104 paired-single instructions that are designed to improve the performance
13105 of 3D graphics operations. Support for these instructions is controlled
13106 by the @option{-mips3d} command-line option.
13107
13108 The functions listed below map directly to a particular MIPS-3D
13109 instruction. Please refer to the architecture specification for
13110 more details on what each instruction does.
13111
13112 @table @code
13113 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13114 Reduction add (@code{addr.ps}).
13115
13116 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13117 Reduction multiply (@code{mulr.ps}).
13118
13119 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13120 Convert paired single to paired word (@code{cvt.pw.ps}).
13121
13122 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13123 Convert paired word to paired single (@code{cvt.ps.pw}).
13124
13125 @item float __builtin_mips_recip1_s (float)
13126 @itemx double __builtin_mips_recip1_d (double)
13127 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13128 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13129
13130 @item float __builtin_mips_recip2_s (float, float)
13131 @itemx double __builtin_mips_recip2_d (double, double)
13132 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13133 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13134
13135 @item float __builtin_mips_rsqrt1_s (float)
13136 @itemx double __builtin_mips_rsqrt1_d (double)
13137 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13138 Reduced-precision reciprocal square root (sequence step 1)
13139 (@code{rsqrt1.@var{fmt}}).
13140
13141 @item float __builtin_mips_rsqrt2_s (float, float)
13142 @itemx double __builtin_mips_rsqrt2_d (double, double)
13143 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13144 Reduced-precision reciprocal square root (sequence step 2)
13145 (@code{rsqrt2.@var{fmt}}).
13146 @end table
13147
13148 The following multi-instruction functions are also available.
13149 In each case, @var{cond} can be any of the 16 floating-point conditions:
13150 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13151 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13152 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13153
13154 @table @code
13155 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13156 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13157 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13158 @code{bc1t}/@code{bc1f}).
13159
13160 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13161 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13162 For example:
13163
13164 @smallexample
13165 float a, b;
13166 if (__builtin_mips_cabs_eq_s (a, b))
13167 true ();
13168 else
13169 false ();
13170 @end smallexample
13171
13172 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13173 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13174 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13175 @code{bc1t}/@code{bc1f}).
13176
13177 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13178 and return either the upper or lower half of the result. For example:
13179
13180 @smallexample
13181 v2sf a, b;
13182 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13183 upper_halves_are_equal ();
13184 else
13185 upper_halves_are_unequal ();
13186
13187 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13188 lower_halves_are_equal ();
13189 else
13190 lower_halves_are_unequal ();
13191 @end smallexample
13192
13193 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13194 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13195 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13196 @code{movt.ps}/@code{movf.ps}).
13197
13198 The @code{movt} functions return the value @var{x} computed by:
13199
13200 @smallexample
13201 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13202 mov.ps @var{x},@var{c}
13203 movt.ps @var{x},@var{d},@var{cc}
13204 @end smallexample
13205
13206 The @code{movf} functions are similar but use @code{movf.ps} instead
13207 of @code{movt.ps}.
13208
13209 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13210 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13211 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13212 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13213 Comparison of two paired-single values
13214 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13215 @code{bc1any2t}/@code{bc1any2f}).
13216
13217 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13218 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13219 result is true and the @code{all} forms return true if both results are true.
13220 For example:
13221
13222 @smallexample
13223 v2sf a, b;
13224 if (__builtin_mips_any_c_eq_ps (a, b))
13225 one_is_true ();
13226 else
13227 both_are_false ();
13228
13229 if (__builtin_mips_all_c_eq_ps (a, b))
13230 both_are_true ();
13231 else
13232 one_is_false ();
13233 @end smallexample
13234
13235 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13236 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13237 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13238 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13239 Comparison of four paired-single values
13240 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13241 @code{bc1any4t}/@code{bc1any4f}).
13242
13243 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13244 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13245 The @code{any} forms return true if any of the four results are true
13246 and the @code{all} forms return true if all four results are true.
13247 For example:
13248
13249 @smallexample
13250 v2sf a, b, c, d;
13251 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13252 some_are_true ();
13253 else
13254 all_are_false ();
13255
13256 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13257 all_are_true ();
13258 else
13259 some_are_false ();
13260 @end smallexample
13261 @end table
13262
13263 @node Other MIPS Built-in Functions
13264 @subsection Other MIPS Built-in Functions
13265
13266 GCC provides other MIPS-specific built-in functions:
13267
13268 @table @code
13269 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13270 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13271 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13272 when this function is available.
13273
13274 @item unsigned int __builtin_mips_get_fcsr (void)
13275 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13276 Get and set the contents of the floating-point control and status register
13277 (FPU control register 31). These functions are only available in hard-float
13278 code but can be called in both MIPS16 and non-MIPS16 contexts.
13279
13280 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13281 register except the condition codes, which GCC assumes are preserved.
13282 @end table
13283
13284 @node MSP430 Built-in Functions
13285 @subsection MSP430 Built-in Functions
13286
13287 GCC provides a couple of special builtin functions to aid in the
13288 writing of interrupt handlers in C.
13289
13290 @table @code
13291 @item __bic_SR_register_on_exit (int @var{mask})
13292 This clears the indicated bits in the saved copy of the status register
13293 currently residing on the stack. This only works inside interrupt
13294 handlers and the changes to the status register will only take affect
13295 once the handler returns.
13296
13297 @item __bis_SR_register_on_exit (int @var{mask})
13298 This sets the indicated bits in the saved copy of the status register
13299 currently residing on the stack. This only works inside interrupt
13300 handlers and the changes to the status register will only take affect
13301 once the handler returns.
13302
13303 @item __delay_cycles (long long @var{cycles})
13304 This inserts an instruction sequence that takes exactly @var{cycles}
13305 cycles (between 0 and about 17E9) to complete. The inserted sequence
13306 may use jumps, loops, or no-ops, and does not interfere with any other
13307 instructions. Note that @var{cycles} must be a compile-time constant
13308 integer - that is, you must pass a number, not a variable that may be
13309 optimized to a constant later. The number of cycles delayed by this
13310 builtin is exact.
13311 @end table
13312
13313 @node NDS32 Built-in Functions
13314 @subsection NDS32 Built-in Functions
13315
13316 These built-in functions are available for the NDS32 target:
13317
13318 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13319 Insert an ISYNC instruction into the instruction stream where
13320 @var{addr} is an instruction address for serialization.
13321 @end deftypefn
13322
13323 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13324 Insert an ISB instruction into the instruction stream.
13325 @end deftypefn
13326
13327 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13328 Return the content of a system register which is mapped by @var{sr}.
13329 @end deftypefn
13330
13331 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13332 Return the content of a user space register which is mapped by @var{usr}.
13333 @end deftypefn
13334
13335 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13336 Move the @var{value} to a system register which is mapped by @var{sr}.
13337 @end deftypefn
13338
13339 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13340 Move the @var{value} to a user space register which is mapped by @var{usr}.
13341 @end deftypefn
13342
13343 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13344 Enable global interrupt.
13345 @end deftypefn
13346
13347 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13348 Disable global interrupt.
13349 @end deftypefn
13350
13351 @node picoChip Built-in Functions
13352 @subsection picoChip Built-in Functions
13353
13354 GCC provides an interface to selected machine instructions from the
13355 picoChip instruction set.
13356
13357 @table @code
13358 @item int __builtin_sbc (int @var{value})
13359 Sign bit count. Return the number of consecutive bits in @var{value}
13360 that have the same value as the sign bit. The result is the number of
13361 leading sign bits minus one, giving the number of redundant sign bits in
13362 @var{value}.
13363
13364 @item int __builtin_byteswap (int @var{value})
13365 Byte swap. Return the result of swapping the upper and lower bytes of
13366 @var{value}.
13367
13368 @item int __builtin_brev (int @var{value})
13369 Bit reversal. Return the result of reversing the bits in
13370 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13371 and so on.
13372
13373 @item int __builtin_adds (int @var{x}, int @var{y})
13374 Saturating addition. Return the result of adding @var{x} and @var{y},
13375 storing the value 32767 if the result overflows.
13376
13377 @item int __builtin_subs (int @var{x}, int @var{y})
13378 Saturating subtraction. Return the result of subtracting @var{y} from
13379 @var{x}, storing the value @minus{}32768 if the result overflows.
13380
13381 @item void __builtin_halt (void)
13382 Halt. The processor stops execution. This built-in is useful for
13383 implementing assertions.
13384
13385 @end table
13386
13387 @node PowerPC Built-in Functions
13388 @subsection PowerPC Built-in Functions
13389
13390 These built-in functions are available for the PowerPC family of
13391 processors:
13392 @smallexample
13393 float __builtin_recipdivf (float, float);
13394 float __builtin_rsqrtf (float);
13395 double __builtin_recipdiv (double, double);
13396 double __builtin_rsqrt (double);
13397 uint64_t __builtin_ppc_get_timebase ();
13398 unsigned long __builtin_ppc_mftb ();
13399 double __builtin_unpack_longdouble (long double, int);
13400 double __builtin_longdouble_dw0 (long double);
13401 double __builtin_longdouble_dw1 (long double);
13402 long double __builtin_pack_longdouble (double, double);
13403 @end smallexample
13404
13405 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13406 @code{__builtin_rsqrtf} functions generate multiple instructions to
13407 implement the reciprocal sqrt functionality using reciprocal sqrt
13408 estimate instructions.
13409
13410 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13411 functions generate multiple instructions to implement division using
13412 the reciprocal estimate instructions.
13413
13414 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13415 functions generate instructions to read the Time Base Register. The
13416 @code{__builtin_ppc_get_timebase} function may generate multiple
13417 instructions and always returns the 64 bits of the Time Base Register.
13418 The @code{__builtin_ppc_mftb} function always generates one instruction and
13419 returns the Time Base Register value as an unsigned long, throwing away
13420 the most significant word on 32-bit environments.
13421
13422 The following built-in functions are available for the PowerPC family
13423 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13424 or @option{-mpopcntd}):
13425 @smallexample
13426 long __builtin_bpermd (long, long);
13427 int __builtin_divwe (int, int);
13428 int __builtin_divweo (int, int);
13429 unsigned int __builtin_divweu (unsigned int, unsigned int);
13430 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13431 long __builtin_divde (long, long);
13432 long __builtin_divdeo (long, long);
13433 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13434 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13435 unsigned int cdtbcd (unsigned int);
13436 unsigned int cbcdtd (unsigned int);
13437 unsigned int addg6s (unsigned int, unsigned int);
13438 @end smallexample
13439
13440 The @code{__builtin_divde}, @code{__builtin_divdeo},
13441 @code{__builitin_divdeu}, @code{__builtin_divdeou} functions require a
13442 64-bit environment support ISA 2.06 or later.
13443
13444 The following built-in functions are available for the PowerPC family
13445 of processors when hardware decimal floating point
13446 (@option{-mhard-dfp}) is available:
13447 @smallexample
13448 _Decimal64 __builtin_dxex (_Decimal64);
13449 _Decimal128 __builtin_dxexq (_Decimal128);
13450 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13451 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13452 _Decimal64 __builtin_denbcd (int, _Decimal64);
13453 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13454 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13455 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13456 _Decimal64 __builtin_dscli (_Decimal64, int);
13457 _Decimal128 __builitn_dscliq (_Decimal128, int);
13458 _Decimal64 __builtin_dscri (_Decimal64, int);
13459 _Decimal128 __builitn_dscriq (_Decimal128, int);
13460 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13461 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13462 @end smallexample
13463
13464 The following built-in functions are available for the PowerPC family
13465 of processors when the Vector Scalar (vsx) instruction set is
13466 available:
13467 @smallexample
13468 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13469 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13470 unsigned long long);
13471 @end smallexample
13472
13473 @node PowerPC AltiVec/VSX Built-in Functions
13474 @subsection PowerPC AltiVec Built-in Functions
13475
13476 GCC provides an interface for the PowerPC family of processors to access
13477 the AltiVec operations described in Motorola's AltiVec Programming
13478 Interface Manual. The interface is made available by including
13479 @code{<altivec.h>} and using @option{-maltivec} and
13480 @option{-mabi=altivec}. The interface supports the following vector
13481 types.
13482
13483 @smallexample
13484 vector unsigned char
13485 vector signed char
13486 vector bool char
13487
13488 vector unsigned short
13489 vector signed short
13490 vector bool short
13491 vector pixel
13492
13493 vector unsigned int
13494 vector signed int
13495 vector bool int
13496 vector float
13497 @end smallexample
13498
13499 If @option{-mvsx} is used the following additional vector types are
13500 implemented.
13501
13502 @smallexample
13503 vector unsigned long
13504 vector signed long
13505 vector double
13506 @end smallexample
13507
13508 The long types are only implemented for 64-bit code generation, and
13509 the long type is only used in the floating point/integer conversion
13510 instructions.
13511
13512 GCC's implementation of the high-level language interface available from
13513 C and C++ code differs from Motorola's documentation in several ways.
13514
13515 @itemize @bullet
13516
13517 @item
13518 A vector constant is a list of constant expressions within curly braces.
13519
13520 @item
13521 A vector initializer requires no cast if the vector constant is of the
13522 same type as the variable it is initializing.
13523
13524 @item
13525 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13526 vector type is the default signedness of the base type. The default
13527 varies depending on the operating system, so a portable program should
13528 always specify the signedness.
13529
13530 @item
13531 Compiling with @option{-maltivec} adds keywords @code{__vector},
13532 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13533 @code{bool}. When compiling ISO C, the context-sensitive substitution
13534 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13535 disabled. To use them, you must include @code{<altivec.h>} instead.
13536
13537 @item
13538 GCC allows using a @code{typedef} name as the type specifier for a
13539 vector type.
13540
13541 @item
13542 For C, overloaded functions are implemented with macros so the following
13543 does not work:
13544
13545 @smallexample
13546 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13547 @end smallexample
13548
13549 @noindent
13550 Since @code{vec_add} is a macro, the vector constant in the example
13551 is treated as four separate arguments. Wrap the entire argument in
13552 parentheses for this to work.
13553 @end itemize
13554
13555 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13556 Internally, GCC uses built-in functions to achieve the functionality in
13557 the aforementioned header file, but they are not supported and are
13558 subject to change without notice.
13559
13560 The following interfaces are supported for the generic and specific
13561 AltiVec operations and the AltiVec predicates. In cases where there
13562 is a direct mapping between generic and specific operations, only the
13563 generic names are shown here, although the specific operations can also
13564 be used.
13565
13566 Arguments that are documented as @code{const int} require literal
13567 integral values within the range required for that operation.
13568
13569 @smallexample
13570 vector signed char vec_abs (vector signed char);
13571 vector signed short vec_abs (vector signed short);
13572 vector signed int vec_abs (vector signed int);
13573 vector float vec_abs (vector float);
13574
13575 vector signed char vec_abss (vector signed char);
13576 vector signed short vec_abss (vector signed short);
13577 vector signed int vec_abss (vector signed int);
13578
13579 vector signed char vec_add (vector bool char, vector signed char);
13580 vector signed char vec_add (vector signed char, vector bool char);
13581 vector signed char vec_add (vector signed char, vector signed char);
13582 vector unsigned char vec_add (vector bool char, vector unsigned char);
13583 vector unsigned char vec_add (vector unsigned char, vector bool char);
13584 vector unsigned char vec_add (vector unsigned char,
13585 vector unsigned char);
13586 vector signed short vec_add (vector bool short, vector signed short);
13587 vector signed short vec_add (vector signed short, vector bool short);
13588 vector signed short vec_add (vector signed short, vector signed short);
13589 vector unsigned short vec_add (vector bool short,
13590 vector unsigned short);
13591 vector unsigned short vec_add (vector unsigned short,
13592 vector bool short);
13593 vector unsigned short vec_add (vector unsigned short,
13594 vector unsigned short);
13595 vector signed int vec_add (vector bool int, vector signed int);
13596 vector signed int vec_add (vector signed int, vector bool int);
13597 vector signed int vec_add (vector signed int, vector signed int);
13598 vector unsigned int vec_add (vector bool int, vector unsigned int);
13599 vector unsigned int vec_add (vector unsigned int, vector bool int);
13600 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13601 vector float vec_add (vector float, vector float);
13602
13603 vector float vec_vaddfp (vector float, vector float);
13604
13605 vector signed int vec_vadduwm (vector bool int, vector signed int);
13606 vector signed int vec_vadduwm (vector signed int, vector bool int);
13607 vector signed int vec_vadduwm (vector signed int, vector signed int);
13608 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13609 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
13610 vector unsigned int vec_vadduwm (vector unsigned int,
13611 vector unsigned int);
13612
13613 vector signed short vec_vadduhm (vector bool short,
13614 vector signed short);
13615 vector signed short vec_vadduhm (vector signed short,
13616 vector bool short);
13617 vector signed short vec_vadduhm (vector signed short,
13618 vector signed short);
13619 vector unsigned short vec_vadduhm (vector bool short,
13620 vector unsigned short);
13621 vector unsigned short vec_vadduhm (vector unsigned short,
13622 vector bool short);
13623 vector unsigned short vec_vadduhm (vector unsigned short,
13624 vector unsigned short);
13625
13626 vector signed char vec_vaddubm (vector bool char, vector signed char);
13627 vector signed char vec_vaddubm (vector signed char, vector bool char);
13628 vector signed char vec_vaddubm (vector signed char, vector signed char);
13629 vector unsigned char vec_vaddubm (vector bool char,
13630 vector unsigned char);
13631 vector unsigned char vec_vaddubm (vector unsigned char,
13632 vector bool char);
13633 vector unsigned char vec_vaddubm (vector unsigned char,
13634 vector unsigned char);
13635
13636 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
13637
13638 vector unsigned char vec_adds (vector bool char, vector unsigned char);
13639 vector unsigned char vec_adds (vector unsigned char, vector bool char);
13640 vector unsigned char vec_adds (vector unsigned char,
13641 vector unsigned char);
13642 vector signed char vec_adds (vector bool char, vector signed char);
13643 vector signed char vec_adds (vector signed char, vector bool char);
13644 vector signed char vec_adds (vector signed char, vector signed char);
13645 vector unsigned short vec_adds (vector bool short,
13646 vector unsigned short);
13647 vector unsigned short vec_adds (vector unsigned short,
13648 vector bool short);
13649 vector unsigned short vec_adds (vector unsigned short,
13650 vector unsigned short);
13651 vector signed short vec_adds (vector bool short, vector signed short);
13652 vector signed short vec_adds (vector signed short, vector bool short);
13653 vector signed short vec_adds (vector signed short, vector signed short);
13654 vector unsigned int vec_adds (vector bool int, vector unsigned int);
13655 vector unsigned int vec_adds (vector unsigned int, vector bool int);
13656 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
13657 vector signed int vec_adds (vector bool int, vector signed int);
13658 vector signed int vec_adds (vector signed int, vector bool int);
13659 vector signed int vec_adds (vector signed int, vector signed int);
13660
13661 vector signed int vec_vaddsws (vector bool int, vector signed int);
13662 vector signed int vec_vaddsws (vector signed int, vector bool int);
13663 vector signed int vec_vaddsws (vector signed int, vector signed int);
13664
13665 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
13666 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
13667 vector unsigned int vec_vadduws (vector unsigned int,
13668 vector unsigned int);
13669
13670 vector signed short vec_vaddshs (vector bool short,
13671 vector signed short);
13672 vector signed short vec_vaddshs (vector signed short,
13673 vector bool short);
13674 vector signed short vec_vaddshs (vector signed short,
13675 vector signed short);
13676
13677 vector unsigned short vec_vadduhs (vector bool short,
13678 vector unsigned short);
13679 vector unsigned short vec_vadduhs (vector unsigned short,
13680 vector bool short);
13681 vector unsigned short vec_vadduhs (vector unsigned short,
13682 vector unsigned short);
13683
13684 vector signed char vec_vaddsbs (vector bool char, vector signed char);
13685 vector signed char vec_vaddsbs (vector signed char, vector bool char);
13686 vector signed char vec_vaddsbs (vector signed char, vector signed char);
13687
13688 vector unsigned char vec_vaddubs (vector bool char,
13689 vector unsigned char);
13690 vector unsigned char vec_vaddubs (vector unsigned char,
13691 vector bool char);
13692 vector unsigned char vec_vaddubs (vector unsigned char,
13693 vector unsigned char);
13694
13695 vector float vec_and (vector float, vector float);
13696 vector float vec_and (vector float, vector bool int);
13697 vector float vec_and (vector bool int, vector float);
13698 vector bool int vec_and (vector bool int, vector bool int);
13699 vector signed int vec_and (vector bool int, vector signed int);
13700 vector signed int vec_and (vector signed int, vector bool int);
13701 vector signed int vec_and (vector signed int, vector signed int);
13702 vector unsigned int vec_and (vector bool int, vector unsigned int);
13703 vector unsigned int vec_and (vector unsigned int, vector bool int);
13704 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
13705 vector bool short vec_and (vector bool short, vector bool short);
13706 vector signed short vec_and (vector bool short, vector signed short);
13707 vector signed short vec_and (vector signed short, vector bool short);
13708 vector signed short vec_and (vector signed short, vector signed short);
13709 vector unsigned short vec_and (vector bool short,
13710 vector unsigned short);
13711 vector unsigned short vec_and (vector unsigned short,
13712 vector bool short);
13713 vector unsigned short vec_and (vector unsigned short,
13714 vector unsigned short);
13715 vector signed char vec_and (vector bool char, vector signed char);
13716 vector bool char vec_and (vector bool char, vector bool char);
13717 vector signed char vec_and (vector signed char, vector bool char);
13718 vector signed char vec_and (vector signed char, vector signed char);
13719 vector unsigned char vec_and (vector bool char, vector unsigned char);
13720 vector unsigned char vec_and (vector unsigned char, vector bool char);
13721 vector unsigned char vec_and (vector unsigned char,
13722 vector unsigned char);
13723
13724 vector float vec_andc (vector float, vector float);
13725 vector float vec_andc (vector float, vector bool int);
13726 vector float vec_andc (vector bool int, vector float);
13727 vector bool int vec_andc (vector bool int, vector bool int);
13728 vector signed int vec_andc (vector bool int, vector signed int);
13729 vector signed int vec_andc (vector signed int, vector bool int);
13730 vector signed int vec_andc (vector signed int, vector signed int);
13731 vector unsigned int vec_andc (vector bool int, vector unsigned int);
13732 vector unsigned int vec_andc (vector unsigned int, vector bool int);
13733 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
13734 vector bool short vec_andc (vector bool short, vector bool short);
13735 vector signed short vec_andc (vector bool short, vector signed short);
13736 vector signed short vec_andc (vector signed short, vector bool short);
13737 vector signed short vec_andc (vector signed short, vector signed short);
13738 vector unsigned short vec_andc (vector bool short,
13739 vector unsigned short);
13740 vector unsigned short vec_andc (vector unsigned short,
13741 vector bool short);
13742 vector unsigned short vec_andc (vector unsigned short,
13743 vector unsigned short);
13744 vector signed char vec_andc (vector bool char, vector signed char);
13745 vector bool char vec_andc (vector bool char, vector bool char);
13746 vector signed char vec_andc (vector signed char, vector bool char);
13747 vector signed char vec_andc (vector signed char, vector signed char);
13748 vector unsigned char vec_andc (vector bool char, vector unsigned char);
13749 vector unsigned char vec_andc (vector unsigned char, vector bool char);
13750 vector unsigned char vec_andc (vector unsigned char,
13751 vector unsigned char);
13752
13753 vector unsigned char vec_avg (vector unsigned char,
13754 vector unsigned char);
13755 vector signed char vec_avg (vector signed char, vector signed char);
13756 vector unsigned short vec_avg (vector unsigned short,
13757 vector unsigned short);
13758 vector signed short vec_avg (vector signed short, vector signed short);
13759 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
13760 vector signed int vec_avg (vector signed int, vector signed int);
13761
13762 vector signed int vec_vavgsw (vector signed int, vector signed int);
13763
13764 vector unsigned int vec_vavguw (vector unsigned int,
13765 vector unsigned int);
13766
13767 vector signed short vec_vavgsh (vector signed short,
13768 vector signed short);
13769
13770 vector unsigned short vec_vavguh (vector unsigned short,
13771 vector unsigned short);
13772
13773 vector signed char vec_vavgsb (vector signed char, vector signed char);
13774
13775 vector unsigned char vec_vavgub (vector unsigned char,
13776 vector unsigned char);
13777
13778 vector float vec_copysign (vector float);
13779
13780 vector float vec_ceil (vector float);
13781
13782 vector signed int vec_cmpb (vector float, vector float);
13783
13784 vector bool char vec_cmpeq (vector signed char, vector signed char);
13785 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
13786 vector bool short vec_cmpeq (vector signed short, vector signed short);
13787 vector bool short vec_cmpeq (vector unsigned short,
13788 vector unsigned short);
13789 vector bool int vec_cmpeq (vector signed int, vector signed int);
13790 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
13791 vector bool int vec_cmpeq (vector float, vector float);
13792
13793 vector bool int vec_vcmpeqfp (vector float, vector float);
13794
13795 vector bool int vec_vcmpequw (vector signed int, vector signed int);
13796 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
13797
13798 vector bool short vec_vcmpequh (vector signed short,
13799 vector signed short);
13800 vector bool short vec_vcmpequh (vector unsigned short,
13801 vector unsigned short);
13802
13803 vector bool char vec_vcmpequb (vector signed char, vector signed char);
13804 vector bool char vec_vcmpequb (vector unsigned char,
13805 vector unsigned char);
13806
13807 vector bool int vec_cmpge (vector float, vector float);
13808
13809 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
13810 vector bool char vec_cmpgt (vector signed char, vector signed char);
13811 vector bool short vec_cmpgt (vector unsigned short,
13812 vector unsigned short);
13813 vector bool short vec_cmpgt (vector signed short, vector signed short);
13814 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
13815 vector bool int vec_cmpgt (vector signed int, vector signed int);
13816 vector bool int vec_cmpgt (vector float, vector float);
13817
13818 vector bool int vec_vcmpgtfp (vector float, vector float);
13819
13820 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
13821
13822 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
13823
13824 vector bool short vec_vcmpgtsh (vector signed short,
13825 vector signed short);
13826
13827 vector bool short vec_vcmpgtuh (vector unsigned short,
13828 vector unsigned short);
13829
13830 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
13831
13832 vector bool char vec_vcmpgtub (vector unsigned char,
13833 vector unsigned char);
13834
13835 vector bool int vec_cmple (vector float, vector float);
13836
13837 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
13838 vector bool char vec_cmplt (vector signed char, vector signed char);
13839 vector bool short vec_cmplt (vector unsigned short,
13840 vector unsigned short);
13841 vector bool short vec_cmplt (vector signed short, vector signed short);
13842 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
13843 vector bool int vec_cmplt (vector signed int, vector signed int);
13844 vector bool int vec_cmplt (vector float, vector float);
13845
13846 vector float vec_ctf (vector unsigned int, const int);
13847 vector float vec_ctf (vector signed int, const int);
13848
13849 vector float vec_vcfsx (vector signed int, const int);
13850
13851 vector float vec_vcfux (vector unsigned int, const int);
13852
13853 vector signed int vec_cts (vector float, const int);
13854
13855 vector unsigned int vec_ctu (vector float, const int);
13856
13857 void vec_dss (const int);
13858
13859 void vec_dssall (void);
13860
13861 void vec_dst (const vector unsigned char *, int, const int);
13862 void vec_dst (const vector signed char *, int, const int);
13863 void vec_dst (const vector bool char *, int, const int);
13864 void vec_dst (const vector unsigned short *, int, const int);
13865 void vec_dst (const vector signed short *, int, const int);
13866 void vec_dst (const vector bool short *, int, const int);
13867 void vec_dst (const vector pixel *, int, const int);
13868 void vec_dst (const vector unsigned int *, int, const int);
13869 void vec_dst (const vector signed int *, int, const int);
13870 void vec_dst (const vector bool int *, int, const int);
13871 void vec_dst (const vector float *, int, const int);
13872 void vec_dst (const unsigned char *, int, const int);
13873 void vec_dst (const signed char *, int, const int);
13874 void vec_dst (const unsigned short *, int, const int);
13875 void vec_dst (const short *, int, const int);
13876 void vec_dst (const unsigned int *, int, const int);
13877 void vec_dst (const int *, int, const int);
13878 void vec_dst (const unsigned long *, int, const int);
13879 void vec_dst (const long *, int, const int);
13880 void vec_dst (const float *, int, const int);
13881
13882 void vec_dstst (const vector unsigned char *, int, const int);
13883 void vec_dstst (const vector signed char *, int, const int);
13884 void vec_dstst (const vector bool char *, int, const int);
13885 void vec_dstst (const vector unsigned short *, int, const int);
13886 void vec_dstst (const vector signed short *, int, const int);
13887 void vec_dstst (const vector bool short *, int, const int);
13888 void vec_dstst (const vector pixel *, int, const int);
13889 void vec_dstst (const vector unsigned int *, int, const int);
13890 void vec_dstst (const vector signed int *, int, const int);
13891 void vec_dstst (const vector bool int *, int, const int);
13892 void vec_dstst (const vector float *, int, const int);
13893 void vec_dstst (const unsigned char *, int, const int);
13894 void vec_dstst (const signed char *, int, const int);
13895 void vec_dstst (const unsigned short *, int, const int);
13896 void vec_dstst (const short *, int, const int);
13897 void vec_dstst (const unsigned int *, int, const int);
13898 void vec_dstst (const int *, int, const int);
13899 void vec_dstst (const unsigned long *, int, const int);
13900 void vec_dstst (const long *, int, const int);
13901 void vec_dstst (const float *, int, const int);
13902
13903 void vec_dststt (const vector unsigned char *, int, const int);
13904 void vec_dststt (const vector signed char *, int, const int);
13905 void vec_dststt (const vector bool char *, int, const int);
13906 void vec_dststt (const vector unsigned short *, int, const int);
13907 void vec_dststt (const vector signed short *, int, const int);
13908 void vec_dststt (const vector bool short *, int, const int);
13909 void vec_dststt (const vector pixel *, int, const int);
13910 void vec_dststt (const vector unsigned int *, int, const int);
13911 void vec_dststt (const vector signed int *, int, const int);
13912 void vec_dststt (const vector bool int *, int, const int);
13913 void vec_dststt (const vector float *, int, const int);
13914 void vec_dststt (const unsigned char *, int, const int);
13915 void vec_dststt (const signed char *, int, const int);
13916 void vec_dststt (const unsigned short *, int, const int);
13917 void vec_dststt (const short *, int, const int);
13918 void vec_dststt (const unsigned int *, int, const int);
13919 void vec_dststt (const int *, int, const int);
13920 void vec_dststt (const unsigned long *, int, const int);
13921 void vec_dststt (const long *, int, const int);
13922 void vec_dststt (const float *, int, const int);
13923
13924 void vec_dstt (const vector unsigned char *, int, const int);
13925 void vec_dstt (const vector signed char *, int, const int);
13926 void vec_dstt (const vector bool char *, int, const int);
13927 void vec_dstt (const vector unsigned short *, int, const int);
13928 void vec_dstt (const vector signed short *, int, const int);
13929 void vec_dstt (const vector bool short *, int, const int);
13930 void vec_dstt (const vector pixel *, int, const int);
13931 void vec_dstt (const vector unsigned int *, int, const int);
13932 void vec_dstt (const vector signed int *, int, const int);
13933 void vec_dstt (const vector bool int *, int, const int);
13934 void vec_dstt (const vector float *, int, const int);
13935 void vec_dstt (const unsigned char *, int, const int);
13936 void vec_dstt (const signed char *, int, const int);
13937 void vec_dstt (const unsigned short *, int, const int);
13938 void vec_dstt (const short *, int, const int);
13939 void vec_dstt (const unsigned int *, int, const int);
13940 void vec_dstt (const int *, int, const int);
13941 void vec_dstt (const unsigned long *, int, const int);
13942 void vec_dstt (const long *, int, const int);
13943 void vec_dstt (const float *, int, const int);
13944
13945 vector float vec_expte (vector float);
13946
13947 vector float vec_floor (vector float);
13948
13949 vector float vec_ld (int, const vector float *);
13950 vector float vec_ld (int, const float *);
13951 vector bool int vec_ld (int, const vector bool int *);
13952 vector signed int vec_ld (int, const vector signed int *);
13953 vector signed int vec_ld (int, const int *);
13954 vector signed int vec_ld (int, const long *);
13955 vector unsigned int vec_ld (int, const vector unsigned int *);
13956 vector unsigned int vec_ld (int, const unsigned int *);
13957 vector unsigned int vec_ld (int, const unsigned long *);
13958 vector bool short vec_ld (int, const vector bool short *);
13959 vector pixel vec_ld (int, const vector pixel *);
13960 vector signed short vec_ld (int, const vector signed short *);
13961 vector signed short vec_ld (int, const short *);
13962 vector unsigned short vec_ld (int, const vector unsigned short *);
13963 vector unsigned short vec_ld (int, const unsigned short *);
13964 vector bool char vec_ld (int, const vector bool char *);
13965 vector signed char vec_ld (int, const vector signed char *);
13966 vector signed char vec_ld (int, const signed char *);
13967 vector unsigned char vec_ld (int, const vector unsigned char *);
13968 vector unsigned char vec_ld (int, const unsigned char *);
13969
13970 vector signed char vec_lde (int, const signed char *);
13971 vector unsigned char vec_lde (int, const unsigned char *);
13972 vector signed short vec_lde (int, const short *);
13973 vector unsigned short vec_lde (int, const unsigned short *);
13974 vector float vec_lde (int, const float *);
13975 vector signed int vec_lde (int, const int *);
13976 vector unsigned int vec_lde (int, const unsigned int *);
13977 vector signed int vec_lde (int, const long *);
13978 vector unsigned int vec_lde (int, const unsigned long *);
13979
13980 vector float vec_lvewx (int, float *);
13981 vector signed int vec_lvewx (int, int *);
13982 vector unsigned int vec_lvewx (int, unsigned int *);
13983 vector signed int vec_lvewx (int, long *);
13984 vector unsigned int vec_lvewx (int, unsigned long *);
13985
13986 vector signed short vec_lvehx (int, short *);
13987 vector unsigned short vec_lvehx (int, unsigned short *);
13988
13989 vector signed char vec_lvebx (int, char *);
13990 vector unsigned char vec_lvebx (int, unsigned char *);
13991
13992 vector float vec_ldl (int, const vector float *);
13993 vector float vec_ldl (int, const float *);
13994 vector bool int vec_ldl (int, const vector bool int *);
13995 vector signed int vec_ldl (int, const vector signed int *);
13996 vector signed int vec_ldl (int, const int *);
13997 vector signed int vec_ldl (int, const long *);
13998 vector unsigned int vec_ldl (int, const vector unsigned int *);
13999 vector unsigned int vec_ldl (int, const unsigned int *);
14000 vector unsigned int vec_ldl (int, const unsigned long *);
14001 vector bool short vec_ldl (int, const vector bool short *);
14002 vector pixel vec_ldl (int, const vector pixel *);
14003 vector signed short vec_ldl (int, const vector signed short *);
14004 vector signed short vec_ldl (int, const short *);
14005 vector unsigned short vec_ldl (int, const vector unsigned short *);
14006 vector unsigned short vec_ldl (int, const unsigned short *);
14007 vector bool char vec_ldl (int, const vector bool char *);
14008 vector signed char vec_ldl (int, const vector signed char *);
14009 vector signed char vec_ldl (int, const signed char *);
14010 vector unsigned char vec_ldl (int, const vector unsigned char *);
14011 vector unsigned char vec_ldl (int, const unsigned char *);
14012
14013 vector float vec_loge (vector float);
14014
14015 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14016 vector unsigned char vec_lvsl (int, const volatile signed char *);
14017 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14018 vector unsigned char vec_lvsl (int, const volatile short *);
14019 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14020 vector unsigned char vec_lvsl (int, const volatile int *);
14021 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14022 vector unsigned char vec_lvsl (int, const volatile long *);
14023 vector unsigned char vec_lvsl (int, const volatile float *);
14024
14025 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14026 vector unsigned char vec_lvsr (int, const volatile signed char *);
14027 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14028 vector unsigned char vec_lvsr (int, const volatile short *);
14029 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14030 vector unsigned char vec_lvsr (int, const volatile int *);
14031 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14032 vector unsigned char vec_lvsr (int, const volatile long *);
14033 vector unsigned char vec_lvsr (int, const volatile float *);
14034
14035 vector float vec_madd (vector float, vector float, vector float);
14036
14037 vector signed short vec_madds (vector signed short,
14038 vector signed short,
14039 vector signed short);
14040
14041 vector unsigned char vec_max (vector bool char, vector unsigned char);
14042 vector unsigned char vec_max (vector unsigned char, vector bool char);
14043 vector unsigned char vec_max (vector unsigned char,
14044 vector unsigned char);
14045 vector signed char vec_max (vector bool char, vector signed char);
14046 vector signed char vec_max (vector signed char, vector bool char);
14047 vector signed char vec_max (vector signed char, vector signed char);
14048 vector unsigned short vec_max (vector bool short,
14049 vector unsigned short);
14050 vector unsigned short vec_max (vector unsigned short,
14051 vector bool short);
14052 vector unsigned short vec_max (vector unsigned short,
14053 vector unsigned short);
14054 vector signed short vec_max (vector bool short, vector signed short);
14055 vector signed short vec_max (vector signed short, vector bool short);
14056 vector signed short vec_max (vector signed short, vector signed short);
14057 vector unsigned int vec_max (vector bool int, vector unsigned int);
14058 vector unsigned int vec_max (vector unsigned int, vector bool int);
14059 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14060 vector signed int vec_max (vector bool int, vector signed int);
14061 vector signed int vec_max (vector signed int, vector bool int);
14062 vector signed int vec_max (vector signed int, vector signed int);
14063 vector float vec_max (vector float, vector float);
14064
14065 vector float vec_vmaxfp (vector float, vector float);
14066
14067 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14068 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14069 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14070
14071 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14072 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14073 vector unsigned int vec_vmaxuw (vector unsigned int,
14074 vector unsigned int);
14075
14076 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14077 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14078 vector signed short vec_vmaxsh (vector signed short,
14079 vector signed short);
14080
14081 vector unsigned short vec_vmaxuh (vector bool short,
14082 vector unsigned short);
14083 vector unsigned short vec_vmaxuh (vector unsigned short,
14084 vector bool short);
14085 vector unsigned short vec_vmaxuh (vector unsigned short,
14086 vector unsigned short);
14087
14088 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14089 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14090 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14091
14092 vector unsigned char vec_vmaxub (vector bool char,
14093 vector unsigned char);
14094 vector unsigned char vec_vmaxub (vector unsigned char,
14095 vector bool char);
14096 vector unsigned char vec_vmaxub (vector unsigned char,
14097 vector unsigned char);
14098
14099 vector bool char vec_mergeh (vector bool char, vector bool char);
14100 vector signed char vec_mergeh (vector signed char, vector signed char);
14101 vector unsigned char vec_mergeh (vector unsigned char,
14102 vector unsigned char);
14103 vector bool short vec_mergeh (vector bool short, vector bool short);
14104 vector pixel vec_mergeh (vector pixel, vector pixel);
14105 vector signed short vec_mergeh (vector signed short,
14106 vector signed short);
14107 vector unsigned short vec_mergeh (vector unsigned short,
14108 vector unsigned short);
14109 vector float vec_mergeh (vector float, vector float);
14110 vector bool int vec_mergeh (vector bool int, vector bool int);
14111 vector signed int vec_mergeh (vector signed int, vector signed int);
14112 vector unsigned int vec_mergeh (vector unsigned int,
14113 vector unsigned int);
14114
14115 vector float vec_vmrghw (vector float, vector float);
14116 vector bool int vec_vmrghw (vector bool int, vector bool int);
14117 vector signed int vec_vmrghw (vector signed int, vector signed int);
14118 vector unsigned int vec_vmrghw (vector unsigned int,
14119 vector unsigned int);
14120
14121 vector bool short vec_vmrghh (vector bool short, vector bool short);
14122 vector signed short vec_vmrghh (vector signed short,
14123 vector signed short);
14124 vector unsigned short vec_vmrghh (vector unsigned short,
14125 vector unsigned short);
14126 vector pixel vec_vmrghh (vector pixel, vector pixel);
14127
14128 vector bool char vec_vmrghb (vector bool char, vector bool char);
14129 vector signed char vec_vmrghb (vector signed char, vector signed char);
14130 vector unsigned char vec_vmrghb (vector unsigned char,
14131 vector unsigned char);
14132
14133 vector bool char vec_mergel (vector bool char, vector bool char);
14134 vector signed char vec_mergel (vector signed char, vector signed char);
14135 vector unsigned char vec_mergel (vector unsigned char,
14136 vector unsigned char);
14137 vector bool short vec_mergel (vector bool short, vector bool short);
14138 vector pixel vec_mergel (vector pixel, vector pixel);
14139 vector signed short vec_mergel (vector signed short,
14140 vector signed short);
14141 vector unsigned short vec_mergel (vector unsigned short,
14142 vector unsigned short);
14143 vector float vec_mergel (vector float, vector float);
14144 vector bool int vec_mergel (vector bool int, vector bool int);
14145 vector signed int vec_mergel (vector signed int, vector signed int);
14146 vector unsigned int vec_mergel (vector unsigned int,
14147 vector unsigned int);
14148
14149 vector float vec_vmrglw (vector float, vector float);
14150 vector signed int vec_vmrglw (vector signed int, vector signed int);
14151 vector unsigned int vec_vmrglw (vector unsigned int,
14152 vector unsigned int);
14153 vector bool int vec_vmrglw (vector bool int, vector bool int);
14154
14155 vector bool short vec_vmrglh (vector bool short, vector bool short);
14156 vector signed short vec_vmrglh (vector signed short,
14157 vector signed short);
14158 vector unsigned short vec_vmrglh (vector unsigned short,
14159 vector unsigned short);
14160 vector pixel vec_vmrglh (vector pixel, vector pixel);
14161
14162 vector bool char vec_vmrglb (vector bool char, vector bool char);
14163 vector signed char vec_vmrglb (vector signed char, vector signed char);
14164 vector unsigned char vec_vmrglb (vector unsigned char,
14165 vector unsigned char);
14166
14167 vector unsigned short vec_mfvscr (void);
14168
14169 vector unsigned char vec_min (vector bool char, vector unsigned char);
14170 vector unsigned char vec_min (vector unsigned char, vector bool char);
14171 vector unsigned char vec_min (vector unsigned char,
14172 vector unsigned char);
14173 vector signed char vec_min (vector bool char, vector signed char);
14174 vector signed char vec_min (vector signed char, vector bool char);
14175 vector signed char vec_min (vector signed char, vector signed char);
14176 vector unsigned short vec_min (vector bool short,
14177 vector unsigned short);
14178 vector unsigned short vec_min (vector unsigned short,
14179 vector bool short);
14180 vector unsigned short vec_min (vector unsigned short,
14181 vector unsigned short);
14182 vector signed short vec_min (vector bool short, vector signed short);
14183 vector signed short vec_min (vector signed short, vector bool short);
14184 vector signed short vec_min (vector signed short, vector signed short);
14185 vector unsigned int vec_min (vector bool int, vector unsigned int);
14186 vector unsigned int vec_min (vector unsigned int, vector bool int);
14187 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14188 vector signed int vec_min (vector bool int, vector signed int);
14189 vector signed int vec_min (vector signed int, vector bool int);
14190 vector signed int vec_min (vector signed int, vector signed int);
14191 vector float vec_min (vector float, vector float);
14192
14193 vector float vec_vminfp (vector float, vector float);
14194
14195 vector signed int vec_vminsw (vector bool int, vector signed int);
14196 vector signed int vec_vminsw (vector signed int, vector bool int);
14197 vector signed int vec_vminsw (vector signed int, vector signed int);
14198
14199 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14200 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14201 vector unsigned int vec_vminuw (vector unsigned int,
14202 vector unsigned int);
14203
14204 vector signed short vec_vminsh (vector bool short, vector signed short);
14205 vector signed short vec_vminsh (vector signed short, vector bool short);
14206 vector signed short vec_vminsh (vector signed short,
14207 vector signed short);
14208
14209 vector unsigned short vec_vminuh (vector bool short,
14210 vector unsigned short);
14211 vector unsigned short vec_vminuh (vector unsigned short,
14212 vector bool short);
14213 vector unsigned short vec_vminuh (vector unsigned short,
14214 vector unsigned short);
14215
14216 vector signed char vec_vminsb (vector bool char, vector signed char);
14217 vector signed char vec_vminsb (vector signed char, vector bool char);
14218 vector signed char vec_vminsb (vector signed char, vector signed char);
14219
14220 vector unsigned char vec_vminub (vector bool char,
14221 vector unsigned char);
14222 vector unsigned char vec_vminub (vector unsigned char,
14223 vector bool char);
14224 vector unsigned char vec_vminub (vector unsigned char,
14225 vector unsigned char);
14226
14227 vector signed short vec_mladd (vector signed short,
14228 vector signed short,
14229 vector signed short);
14230 vector signed short vec_mladd (vector signed short,
14231 vector unsigned short,
14232 vector unsigned short);
14233 vector signed short vec_mladd (vector unsigned short,
14234 vector signed short,
14235 vector signed short);
14236 vector unsigned short vec_mladd (vector unsigned short,
14237 vector unsigned short,
14238 vector unsigned short);
14239
14240 vector signed short vec_mradds (vector signed short,
14241 vector signed short,
14242 vector signed short);
14243
14244 vector unsigned int vec_msum (vector unsigned char,
14245 vector unsigned char,
14246 vector unsigned int);
14247 vector signed int vec_msum (vector signed char,
14248 vector unsigned char,
14249 vector signed int);
14250 vector unsigned int vec_msum (vector unsigned short,
14251 vector unsigned short,
14252 vector unsigned int);
14253 vector signed int vec_msum (vector signed short,
14254 vector signed short,
14255 vector signed int);
14256
14257 vector signed int vec_vmsumshm (vector signed short,
14258 vector signed short,
14259 vector signed int);
14260
14261 vector unsigned int vec_vmsumuhm (vector unsigned short,
14262 vector unsigned short,
14263 vector unsigned int);
14264
14265 vector signed int vec_vmsummbm (vector signed char,
14266 vector unsigned char,
14267 vector signed int);
14268
14269 vector unsigned int vec_vmsumubm (vector unsigned char,
14270 vector unsigned char,
14271 vector unsigned int);
14272
14273 vector unsigned int vec_msums (vector unsigned short,
14274 vector unsigned short,
14275 vector unsigned int);
14276 vector signed int vec_msums (vector signed short,
14277 vector signed short,
14278 vector signed int);
14279
14280 vector signed int vec_vmsumshs (vector signed short,
14281 vector signed short,
14282 vector signed int);
14283
14284 vector unsigned int vec_vmsumuhs (vector unsigned short,
14285 vector unsigned short,
14286 vector unsigned int);
14287
14288 void vec_mtvscr (vector signed int);
14289 void vec_mtvscr (vector unsigned int);
14290 void vec_mtvscr (vector bool int);
14291 void vec_mtvscr (vector signed short);
14292 void vec_mtvscr (vector unsigned short);
14293 void vec_mtvscr (vector bool short);
14294 void vec_mtvscr (vector pixel);
14295 void vec_mtvscr (vector signed char);
14296 void vec_mtvscr (vector unsigned char);
14297 void vec_mtvscr (vector bool char);
14298
14299 vector unsigned short vec_mule (vector unsigned char,
14300 vector unsigned char);
14301 vector signed short vec_mule (vector signed char,
14302 vector signed char);
14303 vector unsigned int vec_mule (vector unsigned short,
14304 vector unsigned short);
14305 vector signed int vec_mule (vector signed short, vector signed short);
14306
14307 vector signed int vec_vmulesh (vector signed short,
14308 vector signed short);
14309
14310 vector unsigned int vec_vmuleuh (vector unsigned short,
14311 vector unsigned short);
14312
14313 vector signed short vec_vmulesb (vector signed char,
14314 vector signed char);
14315
14316 vector unsigned short vec_vmuleub (vector unsigned char,
14317 vector unsigned char);
14318
14319 vector unsigned short vec_mulo (vector unsigned char,
14320 vector unsigned char);
14321 vector signed short vec_mulo (vector signed char, vector signed char);
14322 vector unsigned int vec_mulo (vector unsigned short,
14323 vector unsigned short);
14324 vector signed int vec_mulo (vector signed short, vector signed short);
14325
14326 vector signed int vec_vmulosh (vector signed short,
14327 vector signed short);
14328
14329 vector unsigned int vec_vmulouh (vector unsigned short,
14330 vector unsigned short);
14331
14332 vector signed short vec_vmulosb (vector signed char,
14333 vector signed char);
14334
14335 vector unsigned short vec_vmuloub (vector unsigned char,
14336 vector unsigned char);
14337
14338 vector float vec_nmsub (vector float, vector float, vector float);
14339
14340 vector float vec_nor (vector float, vector float);
14341 vector signed int vec_nor (vector signed int, vector signed int);
14342 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14343 vector bool int vec_nor (vector bool int, vector bool int);
14344 vector signed short vec_nor (vector signed short, vector signed short);
14345 vector unsigned short vec_nor (vector unsigned short,
14346 vector unsigned short);
14347 vector bool short vec_nor (vector bool short, vector bool short);
14348 vector signed char vec_nor (vector signed char, vector signed char);
14349 vector unsigned char vec_nor (vector unsigned char,
14350 vector unsigned char);
14351 vector bool char vec_nor (vector bool char, vector bool char);
14352
14353 vector float vec_or (vector float, vector float);
14354 vector float vec_or (vector float, vector bool int);
14355 vector float vec_or (vector bool int, vector float);
14356 vector bool int vec_or (vector bool int, vector bool int);
14357 vector signed int vec_or (vector bool int, vector signed int);
14358 vector signed int vec_or (vector signed int, vector bool int);
14359 vector signed int vec_or (vector signed int, vector signed int);
14360 vector unsigned int vec_or (vector bool int, vector unsigned int);
14361 vector unsigned int vec_or (vector unsigned int, vector bool int);
14362 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14363 vector bool short vec_or (vector bool short, vector bool short);
14364 vector signed short vec_or (vector bool short, vector signed short);
14365 vector signed short vec_or (vector signed short, vector bool short);
14366 vector signed short vec_or (vector signed short, vector signed short);
14367 vector unsigned short vec_or (vector bool short, vector unsigned short);
14368 vector unsigned short vec_or (vector unsigned short, vector bool short);
14369 vector unsigned short vec_or (vector unsigned short,
14370 vector unsigned short);
14371 vector signed char vec_or (vector bool char, vector signed char);
14372 vector bool char vec_or (vector bool char, vector bool char);
14373 vector signed char vec_or (vector signed char, vector bool char);
14374 vector signed char vec_or (vector signed char, vector signed char);
14375 vector unsigned char vec_or (vector bool char, vector unsigned char);
14376 vector unsigned char vec_or (vector unsigned char, vector bool char);
14377 vector unsigned char vec_or (vector unsigned char,
14378 vector unsigned char);
14379
14380 vector signed char vec_pack (vector signed short, vector signed short);
14381 vector unsigned char vec_pack (vector unsigned short,
14382 vector unsigned short);
14383 vector bool char vec_pack (vector bool short, vector bool short);
14384 vector signed short vec_pack (vector signed int, vector signed int);
14385 vector unsigned short vec_pack (vector unsigned int,
14386 vector unsigned int);
14387 vector bool short vec_pack (vector bool int, vector bool int);
14388
14389 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14390 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14391 vector unsigned short vec_vpkuwum (vector unsigned int,
14392 vector unsigned int);
14393
14394 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14395 vector signed char vec_vpkuhum (vector signed short,
14396 vector signed short);
14397 vector unsigned char vec_vpkuhum (vector unsigned short,
14398 vector unsigned short);
14399
14400 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14401
14402 vector unsigned char vec_packs (vector unsigned short,
14403 vector unsigned short);
14404 vector signed char vec_packs (vector signed short, vector signed short);
14405 vector unsigned short vec_packs (vector unsigned int,
14406 vector unsigned int);
14407 vector signed short vec_packs (vector signed int, vector signed int);
14408
14409 vector signed short vec_vpkswss (vector signed int, vector signed int);
14410
14411 vector unsigned short vec_vpkuwus (vector unsigned int,
14412 vector unsigned int);
14413
14414 vector signed char vec_vpkshss (vector signed short,
14415 vector signed short);
14416
14417 vector unsigned char vec_vpkuhus (vector unsigned short,
14418 vector unsigned short);
14419
14420 vector unsigned char vec_packsu (vector unsigned short,
14421 vector unsigned short);
14422 vector unsigned char vec_packsu (vector signed short,
14423 vector signed short);
14424 vector unsigned short vec_packsu (vector unsigned int,
14425 vector unsigned int);
14426 vector unsigned short vec_packsu (vector signed int, vector signed int);
14427
14428 vector unsigned short vec_vpkswus (vector signed int,
14429 vector signed int);
14430
14431 vector unsigned char vec_vpkshus (vector signed short,
14432 vector signed short);
14433
14434 vector float vec_perm (vector float,
14435 vector float,
14436 vector unsigned char);
14437 vector signed int vec_perm (vector signed int,
14438 vector signed int,
14439 vector unsigned char);
14440 vector unsigned int vec_perm (vector unsigned int,
14441 vector unsigned int,
14442 vector unsigned char);
14443 vector bool int vec_perm (vector bool int,
14444 vector bool int,
14445 vector unsigned char);
14446 vector signed short vec_perm (vector signed short,
14447 vector signed short,
14448 vector unsigned char);
14449 vector unsigned short vec_perm (vector unsigned short,
14450 vector unsigned short,
14451 vector unsigned char);
14452 vector bool short vec_perm (vector bool short,
14453 vector bool short,
14454 vector unsigned char);
14455 vector pixel vec_perm (vector pixel,
14456 vector pixel,
14457 vector unsigned char);
14458 vector signed char vec_perm (vector signed char,
14459 vector signed char,
14460 vector unsigned char);
14461 vector unsigned char vec_perm (vector unsigned char,
14462 vector unsigned char,
14463 vector unsigned char);
14464 vector bool char vec_perm (vector bool char,
14465 vector bool char,
14466 vector unsigned char);
14467
14468 vector float vec_re (vector float);
14469
14470 vector signed char vec_rl (vector signed char,
14471 vector unsigned char);
14472 vector unsigned char vec_rl (vector unsigned char,
14473 vector unsigned char);
14474 vector signed short vec_rl (vector signed short, vector unsigned short);
14475 vector unsigned short vec_rl (vector unsigned short,
14476 vector unsigned short);
14477 vector signed int vec_rl (vector signed int, vector unsigned int);
14478 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14479
14480 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14481 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14482
14483 vector signed short vec_vrlh (vector signed short,
14484 vector unsigned short);
14485 vector unsigned short vec_vrlh (vector unsigned short,
14486 vector unsigned short);
14487
14488 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14489 vector unsigned char vec_vrlb (vector unsigned char,
14490 vector unsigned char);
14491
14492 vector float vec_round (vector float);
14493
14494 vector float vec_recip (vector float, vector float);
14495
14496 vector float vec_rsqrt (vector float);
14497
14498 vector float vec_rsqrte (vector float);
14499
14500 vector float vec_sel (vector float, vector float, vector bool int);
14501 vector float vec_sel (vector float, vector float, vector unsigned int);
14502 vector signed int vec_sel (vector signed int,
14503 vector signed int,
14504 vector bool int);
14505 vector signed int vec_sel (vector signed int,
14506 vector signed int,
14507 vector unsigned int);
14508 vector unsigned int vec_sel (vector unsigned int,
14509 vector unsigned int,
14510 vector bool int);
14511 vector unsigned int vec_sel (vector unsigned int,
14512 vector unsigned int,
14513 vector unsigned int);
14514 vector bool int vec_sel (vector bool int,
14515 vector bool int,
14516 vector bool int);
14517 vector bool int vec_sel (vector bool int,
14518 vector bool int,
14519 vector unsigned int);
14520 vector signed short vec_sel (vector signed short,
14521 vector signed short,
14522 vector bool short);
14523 vector signed short vec_sel (vector signed short,
14524 vector signed short,
14525 vector unsigned short);
14526 vector unsigned short vec_sel (vector unsigned short,
14527 vector unsigned short,
14528 vector bool short);
14529 vector unsigned short vec_sel (vector unsigned short,
14530 vector unsigned short,
14531 vector unsigned short);
14532 vector bool short vec_sel (vector bool short,
14533 vector bool short,
14534 vector bool short);
14535 vector bool short vec_sel (vector bool short,
14536 vector bool short,
14537 vector unsigned short);
14538 vector signed char vec_sel (vector signed char,
14539 vector signed char,
14540 vector bool char);
14541 vector signed char vec_sel (vector signed char,
14542 vector signed char,
14543 vector unsigned char);
14544 vector unsigned char vec_sel (vector unsigned char,
14545 vector unsigned char,
14546 vector bool char);
14547 vector unsigned char vec_sel (vector unsigned char,
14548 vector unsigned char,
14549 vector unsigned char);
14550 vector bool char vec_sel (vector bool char,
14551 vector bool char,
14552 vector bool char);
14553 vector bool char vec_sel (vector bool char,
14554 vector bool char,
14555 vector unsigned char);
14556
14557 vector signed char vec_sl (vector signed char,
14558 vector unsigned char);
14559 vector unsigned char vec_sl (vector unsigned char,
14560 vector unsigned char);
14561 vector signed short vec_sl (vector signed short, vector unsigned short);
14562 vector unsigned short vec_sl (vector unsigned short,
14563 vector unsigned short);
14564 vector signed int vec_sl (vector signed int, vector unsigned int);
14565 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14566
14567 vector signed int vec_vslw (vector signed int, vector unsigned int);
14568 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14569
14570 vector signed short vec_vslh (vector signed short,
14571 vector unsigned short);
14572 vector unsigned short vec_vslh (vector unsigned short,
14573 vector unsigned short);
14574
14575 vector signed char vec_vslb (vector signed char, vector unsigned char);
14576 vector unsigned char vec_vslb (vector unsigned char,
14577 vector unsigned char);
14578
14579 vector float vec_sld (vector float, vector float, const int);
14580 vector signed int vec_sld (vector signed int,
14581 vector signed int,
14582 const int);
14583 vector unsigned int vec_sld (vector unsigned int,
14584 vector unsigned int,
14585 const int);
14586 vector bool int vec_sld (vector bool int,
14587 vector bool int,
14588 const int);
14589 vector signed short vec_sld (vector signed short,
14590 vector signed short,
14591 const int);
14592 vector unsigned short vec_sld (vector unsigned short,
14593 vector unsigned short,
14594 const int);
14595 vector bool short vec_sld (vector bool short,
14596 vector bool short,
14597 const int);
14598 vector pixel vec_sld (vector pixel,
14599 vector pixel,
14600 const int);
14601 vector signed char vec_sld (vector signed char,
14602 vector signed char,
14603 const int);
14604 vector unsigned char vec_sld (vector unsigned char,
14605 vector unsigned char,
14606 const int);
14607 vector bool char vec_sld (vector bool char,
14608 vector bool char,
14609 const int);
14610
14611 vector signed int vec_sll (vector signed int,
14612 vector unsigned int);
14613 vector signed int vec_sll (vector signed int,
14614 vector unsigned short);
14615 vector signed int vec_sll (vector signed int,
14616 vector unsigned char);
14617 vector unsigned int vec_sll (vector unsigned int,
14618 vector unsigned int);
14619 vector unsigned int vec_sll (vector unsigned int,
14620 vector unsigned short);
14621 vector unsigned int vec_sll (vector unsigned int,
14622 vector unsigned char);
14623 vector bool int vec_sll (vector bool int,
14624 vector unsigned int);
14625 vector bool int vec_sll (vector bool int,
14626 vector unsigned short);
14627 vector bool int vec_sll (vector bool int,
14628 vector unsigned char);
14629 vector signed short vec_sll (vector signed short,
14630 vector unsigned int);
14631 vector signed short vec_sll (vector signed short,
14632 vector unsigned short);
14633 vector signed short vec_sll (vector signed short,
14634 vector unsigned char);
14635 vector unsigned short vec_sll (vector unsigned short,
14636 vector unsigned int);
14637 vector unsigned short vec_sll (vector unsigned short,
14638 vector unsigned short);
14639 vector unsigned short vec_sll (vector unsigned short,
14640 vector unsigned char);
14641 vector bool short vec_sll (vector bool short, vector unsigned int);
14642 vector bool short vec_sll (vector bool short, vector unsigned short);
14643 vector bool short vec_sll (vector bool short, vector unsigned char);
14644 vector pixel vec_sll (vector pixel, vector unsigned int);
14645 vector pixel vec_sll (vector pixel, vector unsigned short);
14646 vector pixel vec_sll (vector pixel, vector unsigned char);
14647 vector signed char vec_sll (vector signed char, vector unsigned int);
14648 vector signed char vec_sll (vector signed char, vector unsigned short);
14649 vector signed char vec_sll (vector signed char, vector unsigned char);
14650 vector unsigned char vec_sll (vector unsigned char,
14651 vector unsigned int);
14652 vector unsigned char vec_sll (vector unsigned char,
14653 vector unsigned short);
14654 vector unsigned char vec_sll (vector unsigned char,
14655 vector unsigned char);
14656 vector bool char vec_sll (vector bool char, vector unsigned int);
14657 vector bool char vec_sll (vector bool char, vector unsigned short);
14658 vector bool char vec_sll (vector bool char, vector unsigned char);
14659
14660 vector float vec_slo (vector float, vector signed char);
14661 vector float vec_slo (vector float, vector unsigned char);
14662 vector signed int vec_slo (vector signed int, vector signed char);
14663 vector signed int vec_slo (vector signed int, vector unsigned char);
14664 vector unsigned int vec_slo (vector unsigned int, vector signed char);
14665 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
14666 vector signed short vec_slo (vector signed short, vector signed char);
14667 vector signed short vec_slo (vector signed short, vector unsigned char);
14668 vector unsigned short vec_slo (vector unsigned short,
14669 vector signed char);
14670 vector unsigned short vec_slo (vector unsigned short,
14671 vector unsigned char);
14672 vector pixel vec_slo (vector pixel, vector signed char);
14673 vector pixel vec_slo (vector pixel, vector unsigned char);
14674 vector signed char vec_slo (vector signed char, vector signed char);
14675 vector signed char vec_slo (vector signed char, vector unsigned char);
14676 vector unsigned char vec_slo (vector unsigned char, vector signed char);
14677 vector unsigned char vec_slo (vector unsigned char,
14678 vector unsigned char);
14679
14680 vector signed char vec_splat (vector signed char, const int);
14681 vector unsigned char vec_splat (vector unsigned char, const int);
14682 vector bool char vec_splat (vector bool char, const int);
14683 vector signed short vec_splat (vector signed short, const int);
14684 vector unsigned short vec_splat (vector unsigned short, const int);
14685 vector bool short vec_splat (vector bool short, const int);
14686 vector pixel vec_splat (vector pixel, const int);
14687 vector float vec_splat (vector float, const int);
14688 vector signed int vec_splat (vector signed int, const int);
14689 vector unsigned int vec_splat (vector unsigned int, const int);
14690 vector bool int vec_splat (vector bool int, const int);
14691
14692 vector float vec_vspltw (vector float, const int);
14693 vector signed int vec_vspltw (vector signed int, const int);
14694 vector unsigned int vec_vspltw (vector unsigned int, const int);
14695 vector bool int vec_vspltw (vector bool int, const int);
14696
14697 vector bool short vec_vsplth (vector bool short, const int);
14698 vector signed short vec_vsplth (vector signed short, const int);
14699 vector unsigned short vec_vsplth (vector unsigned short, const int);
14700 vector pixel vec_vsplth (vector pixel, const int);
14701
14702 vector signed char vec_vspltb (vector signed char, const int);
14703 vector unsigned char vec_vspltb (vector unsigned char, const int);
14704 vector bool char vec_vspltb (vector bool char, const int);
14705
14706 vector signed char vec_splat_s8 (const int);
14707
14708 vector signed short vec_splat_s16 (const int);
14709
14710 vector signed int vec_splat_s32 (const int);
14711
14712 vector unsigned char vec_splat_u8 (const int);
14713
14714 vector unsigned short vec_splat_u16 (const int);
14715
14716 vector unsigned int vec_splat_u32 (const int);
14717
14718 vector signed char vec_sr (vector signed char, vector unsigned char);
14719 vector unsigned char vec_sr (vector unsigned char,
14720 vector unsigned char);
14721 vector signed short vec_sr (vector signed short,
14722 vector unsigned short);
14723 vector unsigned short vec_sr (vector unsigned short,
14724 vector unsigned short);
14725 vector signed int vec_sr (vector signed int, vector unsigned int);
14726 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
14727
14728 vector signed int vec_vsrw (vector signed int, vector unsigned int);
14729 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
14730
14731 vector signed short vec_vsrh (vector signed short,
14732 vector unsigned short);
14733 vector unsigned short vec_vsrh (vector unsigned short,
14734 vector unsigned short);
14735
14736 vector signed char vec_vsrb (vector signed char, vector unsigned char);
14737 vector unsigned char vec_vsrb (vector unsigned char,
14738 vector unsigned char);
14739
14740 vector signed char vec_sra (vector signed char, vector unsigned char);
14741 vector unsigned char vec_sra (vector unsigned char,
14742 vector unsigned char);
14743 vector signed short vec_sra (vector signed short,
14744 vector unsigned short);
14745 vector unsigned short vec_sra (vector unsigned short,
14746 vector unsigned short);
14747 vector signed int vec_sra (vector signed int, vector unsigned int);
14748 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
14749
14750 vector signed int vec_vsraw (vector signed int, vector unsigned int);
14751 vector unsigned int vec_vsraw (vector unsigned int,
14752 vector unsigned int);
14753
14754 vector signed short vec_vsrah (vector signed short,
14755 vector unsigned short);
14756 vector unsigned short vec_vsrah (vector unsigned short,
14757 vector unsigned short);
14758
14759 vector signed char vec_vsrab (vector signed char, vector unsigned char);
14760 vector unsigned char vec_vsrab (vector unsigned char,
14761 vector unsigned char);
14762
14763 vector signed int vec_srl (vector signed int, vector unsigned int);
14764 vector signed int vec_srl (vector signed int, vector unsigned short);
14765 vector signed int vec_srl (vector signed int, vector unsigned char);
14766 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
14767 vector unsigned int vec_srl (vector unsigned int,
14768 vector unsigned short);
14769 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
14770 vector bool int vec_srl (vector bool int, vector unsigned int);
14771 vector bool int vec_srl (vector bool int, vector unsigned short);
14772 vector bool int vec_srl (vector bool int, vector unsigned char);
14773 vector signed short vec_srl (vector signed short, vector unsigned int);
14774 vector signed short vec_srl (vector signed short,
14775 vector unsigned short);
14776 vector signed short vec_srl (vector signed short, vector unsigned char);
14777 vector unsigned short vec_srl (vector unsigned short,
14778 vector unsigned int);
14779 vector unsigned short vec_srl (vector unsigned short,
14780 vector unsigned short);
14781 vector unsigned short vec_srl (vector unsigned short,
14782 vector unsigned char);
14783 vector bool short vec_srl (vector bool short, vector unsigned int);
14784 vector bool short vec_srl (vector bool short, vector unsigned short);
14785 vector bool short vec_srl (vector bool short, vector unsigned char);
14786 vector pixel vec_srl (vector pixel, vector unsigned int);
14787 vector pixel vec_srl (vector pixel, vector unsigned short);
14788 vector pixel vec_srl (vector pixel, vector unsigned char);
14789 vector signed char vec_srl (vector signed char, vector unsigned int);
14790 vector signed char vec_srl (vector signed char, vector unsigned short);
14791 vector signed char vec_srl (vector signed char, vector unsigned char);
14792 vector unsigned char vec_srl (vector unsigned char,
14793 vector unsigned int);
14794 vector unsigned char vec_srl (vector unsigned char,
14795 vector unsigned short);
14796 vector unsigned char vec_srl (vector unsigned char,
14797 vector unsigned char);
14798 vector bool char vec_srl (vector bool char, vector unsigned int);
14799 vector bool char vec_srl (vector bool char, vector unsigned short);
14800 vector bool char vec_srl (vector bool char, vector unsigned char);
14801
14802 vector float vec_sro (vector float, vector signed char);
14803 vector float vec_sro (vector float, vector unsigned char);
14804 vector signed int vec_sro (vector signed int, vector signed char);
14805 vector signed int vec_sro (vector signed int, vector unsigned char);
14806 vector unsigned int vec_sro (vector unsigned int, vector signed char);
14807 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
14808 vector signed short vec_sro (vector signed short, vector signed char);
14809 vector signed short vec_sro (vector signed short, vector unsigned char);
14810 vector unsigned short vec_sro (vector unsigned short,
14811 vector signed char);
14812 vector unsigned short vec_sro (vector unsigned short,
14813 vector unsigned char);
14814 vector pixel vec_sro (vector pixel, vector signed char);
14815 vector pixel vec_sro (vector pixel, vector unsigned char);
14816 vector signed char vec_sro (vector signed char, vector signed char);
14817 vector signed char vec_sro (vector signed char, vector unsigned char);
14818 vector unsigned char vec_sro (vector unsigned char, vector signed char);
14819 vector unsigned char vec_sro (vector unsigned char,
14820 vector unsigned char);
14821
14822 void vec_st (vector float, int, vector float *);
14823 void vec_st (vector float, int, float *);
14824 void vec_st (vector signed int, int, vector signed int *);
14825 void vec_st (vector signed int, int, int *);
14826 void vec_st (vector unsigned int, int, vector unsigned int *);
14827 void vec_st (vector unsigned int, int, unsigned int *);
14828 void vec_st (vector bool int, int, vector bool int *);
14829 void vec_st (vector bool int, int, unsigned int *);
14830 void vec_st (vector bool int, int, int *);
14831 void vec_st (vector signed short, int, vector signed short *);
14832 void vec_st (vector signed short, int, short *);
14833 void vec_st (vector unsigned short, int, vector unsigned short *);
14834 void vec_st (vector unsigned short, int, unsigned short *);
14835 void vec_st (vector bool short, int, vector bool short *);
14836 void vec_st (vector bool short, int, unsigned short *);
14837 void vec_st (vector pixel, int, vector pixel *);
14838 void vec_st (vector pixel, int, unsigned short *);
14839 void vec_st (vector pixel, int, short *);
14840 void vec_st (vector bool short, int, short *);
14841 void vec_st (vector signed char, int, vector signed char *);
14842 void vec_st (vector signed char, int, signed char *);
14843 void vec_st (vector unsigned char, int, vector unsigned char *);
14844 void vec_st (vector unsigned char, int, unsigned char *);
14845 void vec_st (vector bool char, int, vector bool char *);
14846 void vec_st (vector bool char, int, unsigned char *);
14847 void vec_st (vector bool char, int, signed char *);
14848
14849 void vec_ste (vector signed char, int, signed char *);
14850 void vec_ste (vector unsigned char, int, unsigned char *);
14851 void vec_ste (vector bool char, int, signed char *);
14852 void vec_ste (vector bool char, int, unsigned char *);
14853 void vec_ste (vector signed short, int, short *);
14854 void vec_ste (vector unsigned short, int, unsigned short *);
14855 void vec_ste (vector bool short, int, short *);
14856 void vec_ste (vector bool short, int, unsigned short *);
14857 void vec_ste (vector pixel, int, short *);
14858 void vec_ste (vector pixel, int, unsigned short *);
14859 void vec_ste (vector float, int, float *);
14860 void vec_ste (vector signed int, int, int *);
14861 void vec_ste (vector unsigned int, int, unsigned int *);
14862 void vec_ste (vector bool int, int, int *);
14863 void vec_ste (vector bool int, int, unsigned int *);
14864
14865 void vec_stvewx (vector float, int, float *);
14866 void vec_stvewx (vector signed int, int, int *);
14867 void vec_stvewx (vector unsigned int, int, unsigned int *);
14868 void vec_stvewx (vector bool int, int, int *);
14869 void vec_stvewx (vector bool int, int, unsigned int *);
14870
14871 void vec_stvehx (vector signed short, int, short *);
14872 void vec_stvehx (vector unsigned short, int, unsigned short *);
14873 void vec_stvehx (vector bool short, int, short *);
14874 void vec_stvehx (vector bool short, int, unsigned short *);
14875 void vec_stvehx (vector pixel, int, short *);
14876 void vec_stvehx (vector pixel, int, unsigned short *);
14877
14878 void vec_stvebx (vector signed char, int, signed char *);
14879 void vec_stvebx (vector unsigned char, int, unsigned char *);
14880 void vec_stvebx (vector bool char, int, signed char *);
14881 void vec_stvebx (vector bool char, int, unsigned char *);
14882
14883 void vec_stl (vector float, int, vector float *);
14884 void vec_stl (vector float, int, float *);
14885 void vec_stl (vector signed int, int, vector signed int *);
14886 void vec_stl (vector signed int, int, int *);
14887 void vec_stl (vector unsigned int, int, vector unsigned int *);
14888 void vec_stl (vector unsigned int, int, unsigned int *);
14889 void vec_stl (vector bool int, int, vector bool int *);
14890 void vec_stl (vector bool int, int, unsigned int *);
14891 void vec_stl (vector bool int, int, int *);
14892 void vec_stl (vector signed short, int, vector signed short *);
14893 void vec_stl (vector signed short, int, short *);
14894 void vec_stl (vector unsigned short, int, vector unsigned short *);
14895 void vec_stl (vector unsigned short, int, unsigned short *);
14896 void vec_stl (vector bool short, int, vector bool short *);
14897 void vec_stl (vector bool short, int, unsigned short *);
14898 void vec_stl (vector bool short, int, short *);
14899 void vec_stl (vector pixel, int, vector pixel *);
14900 void vec_stl (vector pixel, int, unsigned short *);
14901 void vec_stl (vector pixel, int, short *);
14902 void vec_stl (vector signed char, int, vector signed char *);
14903 void vec_stl (vector signed char, int, signed char *);
14904 void vec_stl (vector unsigned char, int, vector unsigned char *);
14905 void vec_stl (vector unsigned char, int, unsigned char *);
14906 void vec_stl (vector bool char, int, vector bool char *);
14907 void vec_stl (vector bool char, int, unsigned char *);
14908 void vec_stl (vector bool char, int, signed char *);
14909
14910 vector signed char vec_sub (vector bool char, vector signed char);
14911 vector signed char vec_sub (vector signed char, vector bool char);
14912 vector signed char vec_sub (vector signed char, vector signed char);
14913 vector unsigned char vec_sub (vector bool char, vector unsigned char);
14914 vector unsigned char vec_sub (vector unsigned char, vector bool char);
14915 vector unsigned char vec_sub (vector unsigned char,
14916 vector unsigned char);
14917 vector signed short vec_sub (vector bool short, vector signed short);
14918 vector signed short vec_sub (vector signed short, vector bool short);
14919 vector signed short vec_sub (vector signed short, vector signed short);
14920 vector unsigned short vec_sub (vector bool short,
14921 vector unsigned short);
14922 vector unsigned short vec_sub (vector unsigned short,
14923 vector bool short);
14924 vector unsigned short vec_sub (vector unsigned short,
14925 vector unsigned short);
14926 vector signed int vec_sub (vector bool int, vector signed int);
14927 vector signed int vec_sub (vector signed int, vector bool int);
14928 vector signed int vec_sub (vector signed int, vector signed int);
14929 vector unsigned int vec_sub (vector bool int, vector unsigned int);
14930 vector unsigned int vec_sub (vector unsigned int, vector bool int);
14931 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
14932 vector float vec_sub (vector float, vector float);
14933
14934 vector float vec_vsubfp (vector float, vector float);
14935
14936 vector signed int vec_vsubuwm (vector bool int, vector signed int);
14937 vector signed int vec_vsubuwm (vector signed int, vector bool int);
14938 vector signed int vec_vsubuwm (vector signed int, vector signed int);
14939 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
14940 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
14941 vector unsigned int vec_vsubuwm (vector unsigned int,
14942 vector unsigned int);
14943
14944 vector signed short vec_vsubuhm (vector bool short,
14945 vector signed short);
14946 vector signed short vec_vsubuhm (vector signed short,
14947 vector bool short);
14948 vector signed short vec_vsubuhm (vector signed short,
14949 vector signed short);
14950 vector unsigned short vec_vsubuhm (vector bool short,
14951 vector unsigned short);
14952 vector unsigned short vec_vsubuhm (vector unsigned short,
14953 vector bool short);
14954 vector unsigned short vec_vsubuhm (vector unsigned short,
14955 vector unsigned short);
14956
14957 vector signed char vec_vsububm (vector bool char, vector signed char);
14958 vector signed char vec_vsububm (vector signed char, vector bool char);
14959 vector signed char vec_vsububm (vector signed char, vector signed char);
14960 vector unsigned char vec_vsububm (vector bool char,
14961 vector unsigned char);
14962 vector unsigned char vec_vsububm (vector unsigned char,
14963 vector bool char);
14964 vector unsigned char vec_vsububm (vector unsigned char,
14965 vector unsigned char);
14966
14967 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
14968
14969 vector unsigned char vec_subs (vector bool char, vector unsigned char);
14970 vector unsigned char vec_subs (vector unsigned char, vector bool char);
14971 vector unsigned char vec_subs (vector unsigned char,
14972 vector unsigned char);
14973 vector signed char vec_subs (vector bool char, vector signed char);
14974 vector signed char vec_subs (vector signed char, vector bool char);
14975 vector signed char vec_subs (vector signed char, vector signed char);
14976 vector unsigned short vec_subs (vector bool short,
14977 vector unsigned short);
14978 vector unsigned short vec_subs (vector unsigned short,
14979 vector bool short);
14980 vector unsigned short vec_subs (vector unsigned short,
14981 vector unsigned short);
14982 vector signed short vec_subs (vector bool short, vector signed short);
14983 vector signed short vec_subs (vector signed short, vector bool short);
14984 vector signed short vec_subs (vector signed short, vector signed short);
14985 vector unsigned int vec_subs (vector bool int, vector unsigned int);
14986 vector unsigned int vec_subs (vector unsigned int, vector bool int);
14987 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
14988 vector signed int vec_subs (vector bool int, vector signed int);
14989 vector signed int vec_subs (vector signed int, vector bool int);
14990 vector signed int vec_subs (vector signed int, vector signed int);
14991
14992 vector signed int vec_vsubsws (vector bool int, vector signed int);
14993 vector signed int vec_vsubsws (vector signed int, vector bool int);
14994 vector signed int vec_vsubsws (vector signed int, vector signed int);
14995
14996 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
14997 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
14998 vector unsigned int vec_vsubuws (vector unsigned int,
14999 vector unsigned int);
15000
15001 vector signed short vec_vsubshs (vector bool short,
15002 vector signed short);
15003 vector signed short vec_vsubshs (vector signed short,
15004 vector bool short);
15005 vector signed short vec_vsubshs (vector signed short,
15006 vector signed short);
15007
15008 vector unsigned short vec_vsubuhs (vector bool short,
15009 vector unsigned short);
15010 vector unsigned short vec_vsubuhs (vector unsigned short,
15011 vector bool short);
15012 vector unsigned short vec_vsubuhs (vector unsigned short,
15013 vector unsigned short);
15014
15015 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15016 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15017 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15018
15019 vector unsigned char vec_vsububs (vector bool char,
15020 vector unsigned char);
15021 vector unsigned char vec_vsububs (vector unsigned char,
15022 vector bool char);
15023 vector unsigned char vec_vsububs (vector unsigned char,
15024 vector unsigned char);
15025
15026 vector unsigned int vec_sum4s (vector unsigned char,
15027 vector unsigned int);
15028 vector signed int vec_sum4s (vector signed char, vector signed int);
15029 vector signed int vec_sum4s (vector signed short, vector signed int);
15030
15031 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15032
15033 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15034
15035 vector unsigned int vec_vsum4ubs (vector unsigned char,
15036 vector unsigned int);
15037
15038 vector signed int vec_sum2s (vector signed int, vector signed int);
15039
15040 vector signed int vec_sums (vector signed int, vector signed int);
15041
15042 vector float vec_trunc (vector float);
15043
15044 vector signed short vec_unpackh (vector signed char);
15045 vector bool short vec_unpackh (vector bool char);
15046 vector signed int vec_unpackh (vector signed short);
15047 vector bool int vec_unpackh (vector bool short);
15048 vector unsigned int vec_unpackh (vector pixel);
15049
15050 vector bool int vec_vupkhsh (vector bool short);
15051 vector signed int vec_vupkhsh (vector signed short);
15052
15053 vector unsigned int vec_vupkhpx (vector pixel);
15054
15055 vector bool short vec_vupkhsb (vector bool char);
15056 vector signed short vec_vupkhsb (vector signed char);
15057
15058 vector signed short vec_unpackl (vector signed char);
15059 vector bool short vec_unpackl (vector bool char);
15060 vector unsigned int vec_unpackl (vector pixel);
15061 vector signed int vec_unpackl (vector signed short);
15062 vector bool int vec_unpackl (vector bool short);
15063
15064 vector unsigned int vec_vupklpx (vector pixel);
15065
15066 vector bool int vec_vupklsh (vector bool short);
15067 vector signed int vec_vupklsh (vector signed short);
15068
15069 vector bool short vec_vupklsb (vector bool char);
15070 vector signed short vec_vupklsb (vector signed char);
15071
15072 vector float vec_xor (vector float, vector float);
15073 vector float vec_xor (vector float, vector bool int);
15074 vector float vec_xor (vector bool int, vector float);
15075 vector bool int vec_xor (vector bool int, vector bool int);
15076 vector signed int vec_xor (vector bool int, vector signed int);
15077 vector signed int vec_xor (vector signed int, vector bool int);
15078 vector signed int vec_xor (vector signed int, vector signed int);
15079 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15080 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15081 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15082 vector bool short vec_xor (vector bool short, vector bool short);
15083 vector signed short vec_xor (vector bool short, vector signed short);
15084 vector signed short vec_xor (vector signed short, vector bool short);
15085 vector signed short vec_xor (vector signed short, vector signed short);
15086 vector unsigned short vec_xor (vector bool short,
15087 vector unsigned short);
15088 vector unsigned short vec_xor (vector unsigned short,
15089 vector bool short);
15090 vector unsigned short vec_xor (vector unsigned short,
15091 vector unsigned short);
15092 vector signed char vec_xor (vector bool char, vector signed char);
15093 vector bool char vec_xor (vector bool char, vector bool char);
15094 vector signed char vec_xor (vector signed char, vector bool char);
15095 vector signed char vec_xor (vector signed char, vector signed char);
15096 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15097 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15098 vector unsigned char vec_xor (vector unsigned char,
15099 vector unsigned char);
15100
15101 int vec_all_eq (vector signed char, vector bool char);
15102 int vec_all_eq (vector signed char, vector signed char);
15103 int vec_all_eq (vector unsigned char, vector bool char);
15104 int vec_all_eq (vector unsigned char, vector unsigned char);
15105 int vec_all_eq (vector bool char, vector bool char);
15106 int vec_all_eq (vector bool char, vector unsigned char);
15107 int vec_all_eq (vector bool char, vector signed char);
15108 int vec_all_eq (vector signed short, vector bool short);
15109 int vec_all_eq (vector signed short, vector signed short);
15110 int vec_all_eq (vector unsigned short, vector bool short);
15111 int vec_all_eq (vector unsigned short, vector unsigned short);
15112 int vec_all_eq (vector bool short, vector bool short);
15113 int vec_all_eq (vector bool short, vector unsigned short);
15114 int vec_all_eq (vector bool short, vector signed short);
15115 int vec_all_eq (vector pixel, vector pixel);
15116 int vec_all_eq (vector signed int, vector bool int);
15117 int vec_all_eq (vector signed int, vector signed int);
15118 int vec_all_eq (vector unsigned int, vector bool int);
15119 int vec_all_eq (vector unsigned int, vector unsigned int);
15120 int vec_all_eq (vector bool int, vector bool int);
15121 int vec_all_eq (vector bool int, vector unsigned int);
15122 int vec_all_eq (vector bool int, vector signed int);
15123 int vec_all_eq (vector float, vector float);
15124
15125 int vec_all_ge (vector bool char, vector unsigned char);
15126 int vec_all_ge (vector unsigned char, vector bool char);
15127 int vec_all_ge (vector unsigned char, vector unsigned char);
15128 int vec_all_ge (vector bool char, vector signed char);
15129 int vec_all_ge (vector signed char, vector bool char);
15130 int vec_all_ge (vector signed char, vector signed char);
15131 int vec_all_ge (vector bool short, vector unsigned short);
15132 int vec_all_ge (vector unsigned short, vector bool short);
15133 int vec_all_ge (vector unsigned short, vector unsigned short);
15134 int vec_all_ge (vector signed short, vector signed short);
15135 int vec_all_ge (vector bool short, vector signed short);
15136 int vec_all_ge (vector signed short, vector bool short);
15137 int vec_all_ge (vector bool int, vector unsigned int);
15138 int vec_all_ge (vector unsigned int, vector bool int);
15139 int vec_all_ge (vector unsigned int, vector unsigned int);
15140 int vec_all_ge (vector bool int, vector signed int);
15141 int vec_all_ge (vector signed int, vector bool int);
15142 int vec_all_ge (vector signed int, vector signed int);
15143 int vec_all_ge (vector float, vector float);
15144
15145 int vec_all_gt (vector bool char, vector unsigned char);
15146 int vec_all_gt (vector unsigned char, vector bool char);
15147 int vec_all_gt (vector unsigned char, vector unsigned char);
15148 int vec_all_gt (vector bool char, vector signed char);
15149 int vec_all_gt (vector signed char, vector bool char);
15150 int vec_all_gt (vector signed char, vector signed char);
15151 int vec_all_gt (vector bool short, vector unsigned short);
15152 int vec_all_gt (vector unsigned short, vector bool short);
15153 int vec_all_gt (vector unsigned short, vector unsigned short);
15154 int vec_all_gt (vector bool short, vector signed short);
15155 int vec_all_gt (vector signed short, vector bool short);
15156 int vec_all_gt (vector signed short, vector signed short);
15157 int vec_all_gt (vector bool int, vector unsigned int);
15158 int vec_all_gt (vector unsigned int, vector bool int);
15159 int vec_all_gt (vector unsigned int, vector unsigned int);
15160 int vec_all_gt (vector bool int, vector signed int);
15161 int vec_all_gt (vector signed int, vector bool int);
15162 int vec_all_gt (vector signed int, vector signed int);
15163 int vec_all_gt (vector float, vector float);
15164
15165 int vec_all_in (vector float, vector float);
15166
15167 int vec_all_le (vector bool char, vector unsigned char);
15168 int vec_all_le (vector unsigned char, vector bool char);
15169 int vec_all_le (vector unsigned char, vector unsigned char);
15170 int vec_all_le (vector bool char, vector signed char);
15171 int vec_all_le (vector signed char, vector bool char);
15172 int vec_all_le (vector signed char, vector signed char);
15173 int vec_all_le (vector bool short, vector unsigned short);
15174 int vec_all_le (vector unsigned short, vector bool short);
15175 int vec_all_le (vector unsigned short, vector unsigned short);
15176 int vec_all_le (vector bool short, vector signed short);
15177 int vec_all_le (vector signed short, vector bool short);
15178 int vec_all_le (vector signed short, vector signed short);
15179 int vec_all_le (vector bool int, vector unsigned int);
15180 int vec_all_le (vector unsigned int, vector bool int);
15181 int vec_all_le (vector unsigned int, vector unsigned int);
15182 int vec_all_le (vector bool int, vector signed int);
15183 int vec_all_le (vector signed int, vector bool int);
15184 int vec_all_le (vector signed int, vector signed int);
15185 int vec_all_le (vector float, vector float);
15186
15187 int vec_all_lt (vector bool char, vector unsigned char);
15188 int vec_all_lt (vector unsigned char, vector bool char);
15189 int vec_all_lt (vector unsigned char, vector unsigned char);
15190 int vec_all_lt (vector bool char, vector signed char);
15191 int vec_all_lt (vector signed char, vector bool char);
15192 int vec_all_lt (vector signed char, vector signed char);
15193 int vec_all_lt (vector bool short, vector unsigned short);
15194 int vec_all_lt (vector unsigned short, vector bool short);
15195 int vec_all_lt (vector unsigned short, vector unsigned short);
15196 int vec_all_lt (vector bool short, vector signed short);
15197 int vec_all_lt (vector signed short, vector bool short);
15198 int vec_all_lt (vector signed short, vector signed short);
15199 int vec_all_lt (vector bool int, vector unsigned int);
15200 int vec_all_lt (vector unsigned int, vector bool int);
15201 int vec_all_lt (vector unsigned int, vector unsigned int);
15202 int vec_all_lt (vector bool int, vector signed int);
15203 int vec_all_lt (vector signed int, vector bool int);
15204 int vec_all_lt (vector signed int, vector signed int);
15205 int vec_all_lt (vector float, vector float);
15206
15207 int vec_all_nan (vector float);
15208
15209 int vec_all_ne (vector signed char, vector bool char);
15210 int vec_all_ne (vector signed char, vector signed char);
15211 int vec_all_ne (vector unsigned char, vector bool char);
15212 int vec_all_ne (vector unsigned char, vector unsigned char);
15213 int vec_all_ne (vector bool char, vector bool char);
15214 int vec_all_ne (vector bool char, vector unsigned char);
15215 int vec_all_ne (vector bool char, vector signed char);
15216 int vec_all_ne (vector signed short, vector bool short);
15217 int vec_all_ne (vector signed short, vector signed short);
15218 int vec_all_ne (vector unsigned short, vector bool short);
15219 int vec_all_ne (vector unsigned short, vector unsigned short);
15220 int vec_all_ne (vector bool short, vector bool short);
15221 int vec_all_ne (vector bool short, vector unsigned short);
15222 int vec_all_ne (vector bool short, vector signed short);
15223 int vec_all_ne (vector pixel, vector pixel);
15224 int vec_all_ne (vector signed int, vector bool int);
15225 int vec_all_ne (vector signed int, vector signed int);
15226 int vec_all_ne (vector unsigned int, vector bool int);
15227 int vec_all_ne (vector unsigned int, vector unsigned int);
15228 int vec_all_ne (vector bool int, vector bool int);
15229 int vec_all_ne (vector bool int, vector unsigned int);
15230 int vec_all_ne (vector bool int, vector signed int);
15231 int vec_all_ne (vector float, vector float);
15232
15233 int vec_all_nge (vector float, vector float);
15234
15235 int vec_all_ngt (vector float, vector float);
15236
15237 int vec_all_nle (vector float, vector float);
15238
15239 int vec_all_nlt (vector float, vector float);
15240
15241 int vec_all_numeric (vector float);
15242
15243 int vec_any_eq (vector signed char, vector bool char);
15244 int vec_any_eq (vector signed char, vector signed char);
15245 int vec_any_eq (vector unsigned char, vector bool char);
15246 int vec_any_eq (vector unsigned char, vector unsigned char);
15247 int vec_any_eq (vector bool char, vector bool char);
15248 int vec_any_eq (vector bool char, vector unsigned char);
15249 int vec_any_eq (vector bool char, vector signed char);
15250 int vec_any_eq (vector signed short, vector bool short);
15251 int vec_any_eq (vector signed short, vector signed short);
15252 int vec_any_eq (vector unsigned short, vector bool short);
15253 int vec_any_eq (vector unsigned short, vector unsigned short);
15254 int vec_any_eq (vector bool short, vector bool short);
15255 int vec_any_eq (vector bool short, vector unsigned short);
15256 int vec_any_eq (vector bool short, vector signed short);
15257 int vec_any_eq (vector pixel, vector pixel);
15258 int vec_any_eq (vector signed int, vector bool int);
15259 int vec_any_eq (vector signed int, vector signed int);
15260 int vec_any_eq (vector unsigned int, vector bool int);
15261 int vec_any_eq (vector unsigned int, vector unsigned int);
15262 int vec_any_eq (vector bool int, vector bool int);
15263 int vec_any_eq (vector bool int, vector unsigned int);
15264 int vec_any_eq (vector bool int, vector signed int);
15265 int vec_any_eq (vector float, vector float);
15266
15267 int vec_any_ge (vector signed char, vector bool char);
15268 int vec_any_ge (vector unsigned char, vector bool char);
15269 int vec_any_ge (vector unsigned char, vector unsigned char);
15270 int vec_any_ge (vector signed char, vector signed char);
15271 int vec_any_ge (vector bool char, vector unsigned char);
15272 int vec_any_ge (vector bool char, vector signed char);
15273 int vec_any_ge (vector unsigned short, vector bool short);
15274 int vec_any_ge (vector unsigned short, vector unsigned short);
15275 int vec_any_ge (vector signed short, vector signed short);
15276 int vec_any_ge (vector signed short, vector bool short);
15277 int vec_any_ge (vector bool short, vector unsigned short);
15278 int vec_any_ge (vector bool short, vector signed short);
15279 int vec_any_ge (vector signed int, vector bool int);
15280 int vec_any_ge (vector unsigned int, vector bool int);
15281 int vec_any_ge (vector unsigned int, vector unsigned int);
15282 int vec_any_ge (vector signed int, vector signed int);
15283 int vec_any_ge (vector bool int, vector unsigned int);
15284 int vec_any_ge (vector bool int, vector signed int);
15285 int vec_any_ge (vector float, vector float);
15286
15287 int vec_any_gt (vector bool char, vector unsigned char);
15288 int vec_any_gt (vector unsigned char, vector bool char);
15289 int vec_any_gt (vector unsigned char, vector unsigned char);
15290 int vec_any_gt (vector bool char, vector signed char);
15291 int vec_any_gt (vector signed char, vector bool char);
15292 int vec_any_gt (vector signed char, vector signed char);
15293 int vec_any_gt (vector bool short, vector unsigned short);
15294 int vec_any_gt (vector unsigned short, vector bool short);
15295 int vec_any_gt (vector unsigned short, vector unsigned short);
15296 int vec_any_gt (vector bool short, vector signed short);
15297 int vec_any_gt (vector signed short, vector bool short);
15298 int vec_any_gt (vector signed short, vector signed short);
15299 int vec_any_gt (vector bool int, vector unsigned int);
15300 int vec_any_gt (vector unsigned int, vector bool int);
15301 int vec_any_gt (vector unsigned int, vector unsigned int);
15302 int vec_any_gt (vector bool int, vector signed int);
15303 int vec_any_gt (vector signed int, vector bool int);
15304 int vec_any_gt (vector signed int, vector signed int);
15305 int vec_any_gt (vector float, vector float);
15306
15307 int vec_any_le (vector bool char, vector unsigned char);
15308 int vec_any_le (vector unsigned char, vector bool char);
15309 int vec_any_le (vector unsigned char, vector unsigned char);
15310 int vec_any_le (vector bool char, vector signed char);
15311 int vec_any_le (vector signed char, vector bool char);
15312 int vec_any_le (vector signed char, vector signed char);
15313 int vec_any_le (vector bool short, vector unsigned short);
15314 int vec_any_le (vector unsigned short, vector bool short);
15315 int vec_any_le (vector unsigned short, vector unsigned short);
15316 int vec_any_le (vector bool short, vector signed short);
15317 int vec_any_le (vector signed short, vector bool short);
15318 int vec_any_le (vector signed short, vector signed short);
15319 int vec_any_le (vector bool int, vector unsigned int);
15320 int vec_any_le (vector unsigned int, vector bool int);
15321 int vec_any_le (vector unsigned int, vector unsigned int);
15322 int vec_any_le (vector bool int, vector signed int);
15323 int vec_any_le (vector signed int, vector bool int);
15324 int vec_any_le (vector signed int, vector signed int);
15325 int vec_any_le (vector float, vector float);
15326
15327 int vec_any_lt (vector bool char, vector unsigned char);
15328 int vec_any_lt (vector unsigned char, vector bool char);
15329 int vec_any_lt (vector unsigned char, vector unsigned char);
15330 int vec_any_lt (vector bool char, vector signed char);
15331 int vec_any_lt (vector signed char, vector bool char);
15332 int vec_any_lt (vector signed char, vector signed char);
15333 int vec_any_lt (vector bool short, vector unsigned short);
15334 int vec_any_lt (vector unsigned short, vector bool short);
15335 int vec_any_lt (vector unsigned short, vector unsigned short);
15336 int vec_any_lt (vector bool short, vector signed short);
15337 int vec_any_lt (vector signed short, vector bool short);
15338 int vec_any_lt (vector signed short, vector signed short);
15339 int vec_any_lt (vector bool int, vector unsigned int);
15340 int vec_any_lt (vector unsigned int, vector bool int);
15341 int vec_any_lt (vector unsigned int, vector unsigned int);
15342 int vec_any_lt (vector bool int, vector signed int);
15343 int vec_any_lt (vector signed int, vector bool int);
15344 int vec_any_lt (vector signed int, vector signed int);
15345 int vec_any_lt (vector float, vector float);
15346
15347 int vec_any_nan (vector float);
15348
15349 int vec_any_ne (vector signed char, vector bool char);
15350 int vec_any_ne (vector signed char, vector signed char);
15351 int vec_any_ne (vector unsigned char, vector bool char);
15352 int vec_any_ne (vector unsigned char, vector unsigned char);
15353 int vec_any_ne (vector bool char, vector bool char);
15354 int vec_any_ne (vector bool char, vector unsigned char);
15355 int vec_any_ne (vector bool char, vector signed char);
15356 int vec_any_ne (vector signed short, vector bool short);
15357 int vec_any_ne (vector signed short, vector signed short);
15358 int vec_any_ne (vector unsigned short, vector bool short);
15359 int vec_any_ne (vector unsigned short, vector unsigned short);
15360 int vec_any_ne (vector bool short, vector bool short);
15361 int vec_any_ne (vector bool short, vector unsigned short);
15362 int vec_any_ne (vector bool short, vector signed short);
15363 int vec_any_ne (vector pixel, vector pixel);
15364 int vec_any_ne (vector signed int, vector bool int);
15365 int vec_any_ne (vector signed int, vector signed int);
15366 int vec_any_ne (vector unsigned int, vector bool int);
15367 int vec_any_ne (vector unsigned int, vector unsigned int);
15368 int vec_any_ne (vector bool int, vector bool int);
15369 int vec_any_ne (vector bool int, vector unsigned int);
15370 int vec_any_ne (vector bool int, vector signed int);
15371 int vec_any_ne (vector float, vector float);
15372
15373 int vec_any_nge (vector float, vector float);
15374
15375 int vec_any_ngt (vector float, vector float);
15376
15377 int vec_any_nle (vector float, vector float);
15378
15379 int vec_any_nlt (vector float, vector float);
15380
15381 int vec_any_numeric (vector float);
15382
15383 int vec_any_out (vector float, vector float);
15384 @end smallexample
15385
15386 If the vector/scalar (VSX) instruction set is available, the following
15387 additional functions are available:
15388
15389 @smallexample
15390 vector double vec_abs (vector double);
15391 vector double vec_add (vector double, vector double);
15392 vector double vec_and (vector double, vector double);
15393 vector double vec_and (vector double, vector bool long);
15394 vector double vec_and (vector bool long, vector double);
15395 vector double vec_andc (vector double, vector double);
15396 vector double vec_andc (vector double, vector bool long);
15397 vector double vec_andc (vector bool long, vector double);
15398 vector double vec_ceil (vector double);
15399 vector bool long vec_cmpeq (vector double, vector double);
15400 vector bool long vec_cmpge (vector double, vector double);
15401 vector bool long vec_cmpgt (vector double, vector double);
15402 vector bool long vec_cmple (vector double, vector double);
15403 vector bool long vec_cmplt (vector double, vector double);
15404 vector float vec_div (vector float, vector float);
15405 vector double vec_div (vector double, vector double);
15406 vector double vec_floor (vector double);
15407 vector double vec_ld (int, const vector double *);
15408 vector double vec_ld (int, const double *);
15409 vector double vec_ldl (int, const vector double *);
15410 vector double vec_ldl (int, const double *);
15411 vector unsigned char vec_lvsl (int, const volatile double *);
15412 vector unsigned char vec_lvsr (int, const volatile double *);
15413 vector double vec_madd (vector double, vector double, vector double);
15414 vector double vec_max (vector double, vector double);
15415 vector double vec_min (vector double, vector double);
15416 vector float vec_msub (vector float, vector float, vector float);
15417 vector double vec_msub (vector double, vector double, vector double);
15418 vector float vec_mul (vector float, vector float);
15419 vector double vec_mul (vector double, vector double);
15420 vector float vec_nearbyint (vector float);
15421 vector double vec_nearbyint (vector double);
15422 vector float vec_nmadd (vector float, vector float, vector float);
15423 vector double vec_nmadd (vector double, vector double, vector double);
15424 vector double vec_nmsub (vector double, vector double, vector double);
15425 vector double vec_nor (vector double, vector double);
15426 vector double vec_or (vector double, vector double);
15427 vector double vec_or (vector double, vector bool long);
15428 vector double vec_or (vector bool long, vector double);
15429 vector double vec_perm (vector double,
15430 vector double,
15431 vector unsigned char);
15432 vector double vec_rint (vector double);
15433 vector double vec_recip (vector double, vector double);
15434 vector double vec_rsqrt (vector double);
15435 vector double vec_rsqrte (vector double);
15436 vector double vec_sel (vector double, vector double, vector bool long);
15437 vector double vec_sel (vector double, vector double, vector unsigned long);
15438 vector double vec_sub (vector double, vector double);
15439 vector float vec_sqrt (vector float);
15440 vector double vec_sqrt (vector double);
15441 void vec_st (vector double, int, vector double *);
15442 void vec_st (vector double, int, double *);
15443 vector double vec_trunc (vector double);
15444 vector double vec_xor (vector double, vector double);
15445 vector double vec_xor (vector double, vector bool long);
15446 vector double vec_xor (vector bool long, vector double);
15447 int vec_all_eq (vector double, vector double);
15448 int vec_all_ge (vector double, vector double);
15449 int vec_all_gt (vector double, vector double);
15450 int vec_all_le (vector double, vector double);
15451 int vec_all_lt (vector double, vector double);
15452 int vec_all_nan (vector double);
15453 int vec_all_ne (vector double, vector double);
15454 int vec_all_nge (vector double, vector double);
15455 int vec_all_ngt (vector double, vector double);
15456 int vec_all_nle (vector double, vector double);
15457 int vec_all_nlt (vector double, vector double);
15458 int vec_all_numeric (vector double);
15459 int vec_any_eq (vector double, vector double);
15460 int vec_any_ge (vector double, vector double);
15461 int vec_any_gt (vector double, vector double);
15462 int vec_any_le (vector double, vector double);
15463 int vec_any_lt (vector double, vector double);
15464 int vec_any_nan (vector double);
15465 int vec_any_ne (vector double, vector double);
15466 int vec_any_nge (vector double, vector double);
15467 int vec_any_ngt (vector double, vector double);
15468 int vec_any_nle (vector double, vector double);
15469 int vec_any_nlt (vector double, vector double);
15470 int vec_any_numeric (vector double);
15471
15472 vector double vec_vsx_ld (int, const vector double *);
15473 vector double vec_vsx_ld (int, const double *);
15474 vector float vec_vsx_ld (int, const vector float *);
15475 vector float vec_vsx_ld (int, const float *);
15476 vector bool int vec_vsx_ld (int, const vector bool int *);
15477 vector signed int vec_vsx_ld (int, const vector signed int *);
15478 vector signed int vec_vsx_ld (int, const int *);
15479 vector signed int vec_vsx_ld (int, const long *);
15480 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15481 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15482 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15483 vector bool short vec_vsx_ld (int, const vector bool short *);
15484 vector pixel vec_vsx_ld (int, const vector pixel *);
15485 vector signed short vec_vsx_ld (int, const vector signed short *);
15486 vector signed short vec_vsx_ld (int, const short *);
15487 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15488 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15489 vector bool char vec_vsx_ld (int, const vector bool char *);
15490 vector signed char vec_vsx_ld (int, const vector signed char *);
15491 vector signed char vec_vsx_ld (int, const signed char *);
15492 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15493 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15494
15495 void vec_vsx_st (vector double, int, vector double *);
15496 void vec_vsx_st (vector double, int, double *);
15497 void vec_vsx_st (vector float, int, vector float *);
15498 void vec_vsx_st (vector float, int, float *);
15499 void vec_vsx_st (vector signed int, int, vector signed int *);
15500 void vec_vsx_st (vector signed int, int, int *);
15501 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15502 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15503 void vec_vsx_st (vector bool int, int, vector bool int *);
15504 void vec_vsx_st (vector bool int, int, unsigned int *);
15505 void vec_vsx_st (vector bool int, int, int *);
15506 void vec_vsx_st (vector signed short, int, vector signed short *);
15507 void vec_vsx_st (vector signed short, int, short *);
15508 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15509 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15510 void vec_vsx_st (vector bool short, int, vector bool short *);
15511 void vec_vsx_st (vector bool short, int, unsigned short *);
15512 void vec_vsx_st (vector pixel, int, vector pixel *);
15513 void vec_vsx_st (vector pixel, int, unsigned short *);
15514 void vec_vsx_st (vector pixel, int, short *);
15515 void vec_vsx_st (vector bool short, int, short *);
15516 void vec_vsx_st (vector signed char, int, vector signed char *);
15517 void vec_vsx_st (vector signed char, int, signed char *);
15518 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15519 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15520 void vec_vsx_st (vector bool char, int, vector bool char *);
15521 void vec_vsx_st (vector bool char, int, unsigned char *);
15522 void vec_vsx_st (vector bool char, int, signed char *);
15523
15524 vector double vec_xxpermdi (vector double, vector double, int);
15525 vector float vec_xxpermdi (vector float, vector float, int);
15526 vector long long vec_xxpermdi (vector long long, vector long long, int);
15527 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15528 vector unsigned long long, int);
15529 vector int vec_xxpermdi (vector int, vector int, int);
15530 vector unsigned int vec_xxpermdi (vector unsigned int,
15531 vector unsigned int, int);
15532 vector short vec_xxpermdi (vector short, vector short, int);
15533 vector unsigned short vec_xxpermdi (vector unsigned short,
15534 vector unsigned short, int);
15535 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
15536 vector unsigned char vec_xxpermdi (vector unsigned char,
15537 vector unsigned char, int);
15538
15539 vector double vec_xxsldi (vector double, vector double, int);
15540 vector float vec_xxsldi (vector float, vector float, int);
15541 vector long long vec_xxsldi (vector long long, vector long long, int);
15542 vector unsigned long long vec_xxsldi (vector unsigned long long,
15543 vector unsigned long long, int);
15544 vector int vec_xxsldi (vector int, vector int, int);
15545 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
15546 vector short vec_xxsldi (vector short, vector short, int);
15547 vector unsigned short vec_xxsldi (vector unsigned short,
15548 vector unsigned short, int);
15549 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
15550 vector unsigned char vec_xxsldi (vector unsigned char,
15551 vector unsigned char, int);
15552 @end smallexample
15553
15554 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
15555 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
15556 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
15557 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
15558 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
15559
15560 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15561 instruction set is available, the following additional functions are
15562 available for both 32-bit and 64-bit targets. For 64-bit targets, you
15563 can use @var{vector long} instead of @var{vector long long},
15564 @var{vector bool long} instead of @var{vector bool long long}, and
15565 @var{vector unsigned long} instead of @var{vector unsigned long long}.
15566
15567 @smallexample
15568 vector long long vec_abs (vector long long);
15569
15570 vector long long vec_add (vector long long, vector long long);
15571 vector unsigned long long vec_add (vector unsigned long long,
15572 vector unsigned long long);
15573
15574 int vec_all_eq (vector long long, vector long long);
15575 int vec_all_ge (vector long long, vector long long);
15576 int vec_all_gt (vector long long, vector long long);
15577 int vec_all_le (vector long long, vector long long);
15578 int vec_all_lt (vector long long, vector long long);
15579 int vec_all_ne (vector long long, vector long long);
15580 int vec_any_eq (vector long long, vector long long);
15581 int vec_any_ge (vector long long, vector long long);
15582 int vec_any_gt (vector long long, vector long long);
15583 int vec_any_le (vector long long, vector long long);
15584 int vec_any_lt (vector long long, vector long long);
15585 int vec_any_ne (vector long long, vector long long);
15586
15587 vector long long vec_eqv (vector long long, vector long long);
15588 vector long long vec_eqv (vector bool long long, vector long long);
15589 vector long long vec_eqv (vector long long, vector bool long long);
15590 vector unsigned long long vec_eqv (vector unsigned long long,
15591 vector unsigned long long);
15592 vector unsigned long long vec_eqv (vector bool long long,
15593 vector unsigned long long);
15594 vector unsigned long long vec_eqv (vector unsigned long long,
15595 vector bool long long);
15596 vector int vec_eqv (vector int, vector int);
15597 vector int vec_eqv (vector bool int, vector int);
15598 vector int vec_eqv (vector int, vector bool int);
15599 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
15600 vector unsigned int vec_eqv (vector bool unsigned int,
15601 vector unsigned int);
15602 vector unsigned int vec_eqv (vector unsigned int,
15603 vector bool unsigned int);
15604 vector short vec_eqv (vector short, vector short);
15605 vector short vec_eqv (vector bool short, vector short);
15606 vector short vec_eqv (vector short, vector bool short);
15607 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
15608 vector unsigned short vec_eqv (vector bool unsigned short,
15609 vector unsigned short);
15610 vector unsigned short vec_eqv (vector unsigned short,
15611 vector bool unsigned short);
15612 vector signed char vec_eqv (vector signed char, vector signed char);
15613 vector signed char vec_eqv (vector bool signed char, vector signed char);
15614 vector signed char vec_eqv (vector signed char, vector bool signed char);
15615 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
15616 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
15617 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
15618
15619 vector long long vec_max (vector long long, vector long long);
15620 vector unsigned long long vec_max (vector unsigned long long,
15621 vector unsigned long long);
15622
15623 vector long long vec_min (vector long long, vector long long);
15624 vector unsigned long long vec_min (vector unsigned long long,
15625 vector unsigned long long);
15626
15627 vector long long vec_nand (vector long long, vector long long);
15628 vector long long vec_nand (vector bool long long, vector long long);
15629 vector long long vec_nand (vector long long, vector bool long long);
15630 vector unsigned long long vec_nand (vector unsigned long long,
15631 vector unsigned long long);
15632 vector unsigned long long vec_nand (vector bool long long,
15633 vector unsigned long long);
15634 vector unsigned long long vec_nand (vector unsigned long long,
15635 vector bool long long);
15636 vector int vec_nand (vector int, vector int);
15637 vector int vec_nand (vector bool int, vector int);
15638 vector int vec_nand (vector int, vector bool int);
15639 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
15640 vector unsigned int vec_nand (vector bool unsigned int,
15641 vector unsigned int);
15642 vector unsigned int vec_nand (vector unsigned int,
15643 vector bool unsigned int);
15644 vector short vec_nand (vector short, vector short);
15645 vector short vec_nand (vector bool short, vector short);
15646 vector short vec_nand (vector short, vector bool short);
15647 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
15648 vector unsigned short vec_nand (vector bool unsigned short,
15649 vector unsigned short);
15650 vector unsigned short vec_nand (vector unsigned short,
15651 vector bool unsigned short);
15652 vector signed char vec_nand (vector signed char, vector signed char);
15653 vector signed char vec_nand (vector bool signed char, vector signed char);
15654 vector signed char vec_nand (vector signed char, vector bool signed char);
15655 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
15656 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
15657 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
15658
15659 vector long long vec_orc (vector long long, vector long long);
15660 vector long long vec_orc (vector bool long long, vector long long);
15661 vector long long vec_orc (vector long long, vector bool long long);
15662 vector unsigned long long vec_orc (vector unsigned long long,
15663 vector unsigned long long);
15664 vector unsigned long long vec_orc (vector bool long long,
15665 vector unsigned long long);
15666 vector unsigned long long vec_orc (vector unsigned long long,
15667 vector bool long long);
15668 vector int vec_orc (vector int, vector int);
15669 vector int vec_orc (vector bool int, vector int);
15670 vector int vec_orc (vector int, vector bool int);
15671 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
15672 vector unsigned int vec_orc (vector bool unsigned int,
15673 vector unsigned int);
15674 vector unsigned int vec_orc (vector unsigned int,
15675 vector bool unsigned int);
15676 vector short vec_orc (vector short, vector short);
15677 vector short vec_orc (vector bool short, vector short);
15678 vector short vec_orc (vector short, vector bool short);
15679 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
15680 vector unsigned short vec_orc (vector bool unsigned short,
15681 vector unsigned short);
15682 vector unsigned short vec_orc (vector unsigned short,
15683 vector bool unsigned short);
15684 vector signed char vec_orc (vector signed char, vector signed char);
15685 vector signed char vec_orc (vector bool signed char, vector signed char);
15686 vector signed char vec_orc (vector signed char, vector bool signed char);
15687 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
15688 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
15689 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
15690
15691 vector int vec_pack (vector long long, vector long long);
15692 vector unsigned int vec_pack (vector unsigned long long,
15693 vector unsigned long long);
15694 vector bool int vec_pack (vector bool long long, vector bool long long);
15695
15696 vector int vec_packs (vector long long, vector long long);
15697 vector unsigned int vec_packs (vector unsigned long long,
15698 vector unsigned long long);
15699
15700 vector unsigned int vec_packsu (vector long long, vector long long);
15701
15702 vector long long vec_rl (vector long long,
15703 vector unsigned long long);
15704 vector long long vec_rl (vector unsigned long long,
15705 vector unsigned long long);
15706
15707 vector long long vec_sl (vector long long, vector unsigned long long);
15708 vector long long vec_sl (vector unsigned long long,
15709 vector unsigned long long);
15710
15711 vector long long vec_sr (vector long long, vector unsigned long long);
15712 vector unsigned long long char vec_sr (vector unsigned long long,
15713 vector unsigned long long);
15714
15715 vector long long vec_sra (vector long long, vector unsigned long long);
15716 vector unsigned long long vec_sra (vector unsigned long long,
15717 vector unsigned long long);
15718
15719 vector long long vec_sub (vector long long, vector long long);
15720 vector unsigned long long vec_sub (vector unsigned long long,
15721 vector unsigned long long);
15722
15723 vector long long vec_unpackh (vector int);
15724 vector unsigned long long vec_unpackh (vector unsigned int);
15725
15726 vector long long vec_unpackl (vector int);
15727 vector unsigned long long vec_unpackl (vector unsigned int);
15728
15729 vector long long vec_vaddudm (vector long long, vector long long);
15730 vector long long vec_vaddudm (vector bool long long, vector long long);
15731 vector long long vec_vaddudm (vector long long, vector bool long long);
15732 vector unsigned long long vec_vaddudm (vector unsigned long long,
15733 vector unsigned long long);
15734 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
15735 vector unsigned long long);
15736 vector unsigned long long vec_vaddudm (vector unsigned long long,
15737 vector bool unsigned long long);
15738
15739 vector long long vec_vbpermq (vector signed char, vector signed char);
15740 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
15741
15742 vector long long vec_vclz (vector long long);
15743 vector unsigned long long vec_vclz (vector unsigned long long);
15744 vector int vec_vclz (vector int);
15745 vector unsigned int vec_vclz (vector int);
15746 vector short vec_vclz (vector short);
15747 vector unsigned short vec_vclz (vector unsigned short);
15748 vector signed char vec_vclz (vector signed char);
15749 vector unsigned char vec_vclz (vector unsigned char);
15750
15751 vector signed char vec_vclzb (vector signed char);
15752 vector unsigned char vec_vclzb (vector unsigned char);
15753
15754 vector long long vec_vclzd (vector long long);
15755 vector unsigned long long vec_vclzd (vector unsigned long long);
15756
15757 vector short vec_vclzh (vector short);
15758 vector unsigned short vec_vclzh (vector unsigned short);
15759
15760 vector int vec_vclzw (vector int);
15761 vector unsigned int vec_vclzw (vector int);
15762
15763 vector signed char vec_vgbbd (vector signed char);
15764 vector unsigned char vec_vgbbd (vector unsigned char);
15765
15766 vector long long vec_vmaxsd (vector long long, vector long long);
15767
15768 vector unsigned long long vec_vmaxud (vector unsigned long long,
15769 unsigned vector long long);
15770
15771 vector long long vec_vminsd (vector long long, vector long long);
15772
15773 vector unsigned long long vec_vminud (vector long long,
15774 vector long long);
15775
15776 vector int vec_vpksdss (vector long long, vector long long);
15777 vector unsigned int vec_vpksdss (vector long long, vector long long);
15778
15779 vector unsigned int vec_vpkudus (vector unsigned long long,
15780 vector unsigned long long);
15781
15782 vector int vec_vpkudum (vector long long, vector long long);
15783 vector unsigned int vec_vpkudum (vector unsigned long long,
15784 vector unsigned long long);
15785 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
15786
15787 vector long long vec_vpopcnt (vector long long);
15788 vector unsigned long long vec_vpopcnt (vector unsigned long long);
15789 vector int vec_vpopcnt (vector int);
15790 vector unsigned int vec_vpopcnt (vector int);
15791 vector short vec_vpopcnt (vector short);
15792 vector unsigned short vec_vpopcnt (vector unsigned short);
15793 vector signed char vec_vpopcnt (vector signed char);
15794 vector unsigned char vec_vpopcnt (vector unsigned char);
15795
15796 vector signed char vec_vpopcntb (vector signed char);
15797 vector unsigned char vec_vpopcntb (vector unsigned char);
15798
15799 vector long long vec_vpopcntd (vector long long);
15800 vector unsigned long long vec_vpopcntd (vector unsigned long long);
15801
15802 vector short vec_vpopcnth (vector short);
15803 vector unsigned short vec_vpopcnth (vector unsigned short);
15804
15805 vector int vec_vpopcntw (vector int);
15806 vector unsigned int vec_vpopcntw (vector int);
15807
15808 vector long long vec_vrld (vector long long, vector unsigned long long);
15809 vector unsigned long long vec_vrld (vector unsigned long long,
15810 vector unsigned long long);
15811
15812 vector long long vec_vsld (vector long long, vector unsigned long long);
15813 vector long long vec_vsld (vector unsigned long long,
15814 vector unsigned long long);
15815
15816 vector long long vec_vsrad (vector long long, vector unsigned long long);
15817 vector unsigned long long vec_vsrad (vector unsigned long long,
15818 vector unsigned long long);
15819
15820 vector long long vec_vsrd (vector long long, vector unsigned long long);
15821 vector unsigned long long char vec_vsrd (vector unsigned long long,
15822 vector unsigned long long);
15823
15824 vector long long vec_vsubudm (vector long long, vector long long);
15825 vector long long vec_vsubudm (vector bool long long, vector long long);
15826 vector long long vec_vsubudm (vector long long, vector bool long long);
15827 vector unsigned long long vec_vsubudm (vector unsigned long long,
15828 vector unsigned long long);
15829 vector unsigned long long vec_vsubudm (vector bool long long,
15830 vector unsigned long long);
15831 vector unsigned long long vec_vsubudm (vector unsigned long long,
15832 vector bool long long);
15833
15834 vector long long vec_vupkhsw (vector int);
15835 vector unsigned long long vec_vupkhsw (vector unsigned int);
15836
15837 vector long long vec_vupklsw (vector int);
15838 vector unsigned long long vec_vupklsw (vector int);
15839 @end smallexample
15840
15841 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15842 instruction set is available, the following additional functions are
15843 available for 64-bit targets. New vector types
15844 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
15845 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
15846 builtins.
15847
15848 The normal vector extract, and set operations work on
15849 @var{vector __int128_t} and @var{vector __uint128_t} types,
15850 but the index value must be 0.
15851
15852 @smallexample
15853 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
15854 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
15855
15856 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
15857 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
15858
15859 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
15860 vector __int128_t);
15861 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
15862 vector __uint128_t);
15863
15864 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
15865 vector __int128_t);
15866 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
15867 vector __uint128_t);
15868
15869 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
15870 vector __int128_t);
15871 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
15872 vector __uint128_t);
15873
15874 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
15875 vector __int128_t);
15876 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
15877 vector __uint128_t);
15878
15879 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
15880 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
15881
15882 __int128_t vec_vsubuqm (__int128_t, __int128_t);
15883 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
15884
15885 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
15886 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
15887 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
15888 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
15889 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
15890 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
15891 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
15892 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
15893 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
15894 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
15895 @end smallexample
15896
15897 If the cryptographic instructions are enabled (@option{-mcrypto} or
15898 @option{-mcpu=power8}), the following builtins are enabled.
15899
15900 @smallexample
15901 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
15902
15903 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
15904 vector unsigned long long);
15905
15906 vector unsigned long long __builtin_crypto_vcipherlast
15907 (vector unsigned long long,
15908 vector unsigned long long);
15909
15910 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
15911 vector unsigned long long);
15912
15913 vector unsigned long long __builtin_crypto_vncipherlast
15914 (vector unsigned long long,
15915 vector unsigned long long);
15916
15917 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
15918 vector unsigned char,
15919 vector unsigned char);
15920
15921 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
15922 vector unsigned short,
15923 vector unsigned short);
15924
15925 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
15926 vector unsigned int,
15927 vector unsigned int);
15928
15929 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
15930 vector unsigned long long,
15931 vector unsigned long long);
15932
15933 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
15934 vector unsigned char);
15935
15936 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
15937 vector unsigned short);
15938
15939 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
15940 vector unsigned int);
15941
15942 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
15943 vector unsigned long long);
15944
15945 vector unsigned long long __builtin_crypto_vshasigmad
15946 (vector unsigned long long, int, int);
15947
15948 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
15949 int, int);
15950 @end smallexample
15951
15952 The second argument to the @var{__builtin_crypto_vshasigmad} and
15953 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
15954 integer that is 0 or 1. The third argument to these builtin functions
15955 must be a constant integer in the range of 0 to 15.
15956
15957 @node PowerPC Hardware Transactional Memory Built-in Functions
15958 @subsection PowerPC Hardware Transactional Memory Built-in Functions
15959 GCC provides two interfaces for accessing the Hardware Transactional
15960 Memory (HTM) instructions available on some of the PowerPC family
15961 of prcoessors (eg, POWER8). The two interfaces come in a low level
15962 interface, consisting of built-in functions specific to PowerPC and a
15963 higher level interface consisting of inline functions that are common
15964 between PowerPC and S/390.
15965
15966 @subsubsection PowerPC HTM Low Level Built-in Functions
15967
15968 The following low level built-in functions are available with
15969 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
15970 They all generate the machine instruction that is part of the name.
15971
15972 The HTM built-ins return true or false depending on their success and
15973 their arguments match exactly the type and order of the associated
15974 hardware instruction's operands. Refer to the ISA manual for a
15975 description of each instruction's operands.
15976
15977 @smallexample
15978 unsigned int __builtin_tbegin (unsigned int)
15979 unsigned int __builtin_tend (unsigned int)
15980
15981 unsigned int __builtin_tabort (unsigned int)
15982 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
15983 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
15984 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
15985 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
15986
15987 unsigned int __builtin_tcheck (unsigned int)
15988 unsigned int __builtin_treclaim (unsigned int)
15989 unsigned int __builtin_trechkpt (void)
15990 unsigned int __builtin_tsr (unsigned int)
15991 @end smallexample
15992
15993 In addition to the above HTM built-ins, we have added built-ins for
15994 some common extended mnemonics of the HTM instructions:
15995
15996 @smallexample
15997 unsigned int __builtin_tendall (void)
15998 unsigned int __builtin_tresume (void)
15999 unsigned int __builtin_tsuspend (void)
16000 @end smallexample
16001
16002 The following set of built-in functions are available to gain access
16003 to the HTM specific special purpose registers.
16004
16005 @smallexample
16006 unsigned long __builtin_get_texasr (void)
16007 unsigned long __builtin_get_texasru (void)
16008 unsigned long __builtin_get_tfhar (void)
16009 unsigned long __builtin_get_tfiar (void)
16010
16011 void __builtin_set_texasr (unsigned long);
16012 void __builtin_set_texasru (unsigned long);
16013 void __builtin_set_tfhar (unsigned long);
16014 void __builtin_set_tfiar (unsigned long);
16015 @end smallexample
16016
16017 Example usage of these low level built-in functions may look like:
16018
16019 @smallexample
16020 #include <htmintrin.h>
16021
16022 int num_retries = 10;
16023
16024 while (1)
16025 @{
16026 if (__builtin_tbegin (0))
16027 @{
16028 /* Transaction State Initiated. */
16029 if (is_locked (lock))
16030 __builtin_tabort (0);
16031 ... transaction code...
16032 __builtin_tend (0);
16033 break;
16034 @}
16035 else
16036 @{
16037 /* Transaction State Failed. Use locks if the transaction
16038 failure is "persistent" or we've tried too many times. */
16039 if (num_retries-- <= 0
16040 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16041 @{
16042 acquire_lock (lock);
16043 ... non transactional fallback path...
16044 release_lock (lock);
16045 break;
16046 @}
16047 @}
16048 @}
16049 @end smallexample
16050
16051 One final built-in function has been added that returns the value of
16052 the 2-bit Transaction State field of the Machine Status Register (MSR)
16053 as stored in @code{CR0}.
16054
16055 @smallexample
16056 unsigned long __builtin_ttest (void)
16057 @end smallexample
16058
16059 This built-in can be used to determine the current transaction state
16060 using the following code example:
16061
16062 @smallexample
16063 #include <htmintrin.h>
16064
16065 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16066
16067 if (tx_state == _HTM_TRANSACTIONAL)
16068 @{
16069 /* Code to use in transactional state. */
16070 @}
16071 else if (tx_state == _HTM_NONTRANSACTIONAL)
16072 @{
16073 /* Code to use in non-transactional state. */
16074 @}
16075 else if (tx_state == _HTM_SUSPENDED)
16076 @{
16077 /* Code to use in transaction suspended state. */
16078 @}
16079 @end smallexample
16080
16081 @subsubsection PowerPC HTM High Level Inline Functions
16082
16083 The following high level HTM interface is made available by including
16084 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16085 where CPU is `power8' or later. This interface is common between PowerPC
16086 and S/390, allowing users to write one HTM source implementation that
16087 can be compiled and executed on either system.
16088
16089 @smallexample
16090 long __TM_simple_begin (void)
16091 long __TM_begin (void* const TM_buff)
16092 long __TM_end (void)
16093 void __TM_abort (void)
16094 void __TM_named_abort (unsigned char const code)
16095 void __TM_resume (void)
16096 void __TM_suspend (void)
16097
16098 long __TM_is_user_abort (void* const TM_buff)
16099 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16100 long __TM_is_illegal (void* const TM_buff)
16101 long __TM_is_footprint_exceeded (void* const TM_buff)
16102 long __TM_nesting_depth (void* const TM_buff)
16103 long __TM_is_nested_too_deep(void* const TM_buff)
16104 long __TM_is_conflict(void* const TM_buff)
16105 long __TM_is_failure_persistent(void* const TM_buff)
16106 long __TM_failure_address(void* const TM_buff)
16107 long long __TM_failure_code(void* const TM_buff)
16108 @end smallexample
16109
16110 Using these common set of HTM inline functions, we can create
16111 a more portable version of the HTM example in the previous
16112 section that will work on either PowerPC or S/390:
16113
16114 @smallexample
16115 #include <htmxlintrin.h>
16116
16117 int num_retries = 10;
16118 TM_buff_type TM_buff;
16119
16120 while (1)
16121 @{
16122 if (__TM_begin (TM_buff))
16123 @{
16124 /* Transaction State Initiated. */
16125 if (is_locked (lock))
16126 __TM_abort ();
16127 ... transaction code...
16128 __TM_end ();
16129 break;
16130 @}
16131 else
16132 @{
16133 /* Transaction State Failed. Use locks if the transaction
16134 failure is "persistent" or we've tried too many times. */
16135 if (num_retries-- <= 0
16136 || __TM_is_failure_persistent (TM_buff))
16137 @{
16138 acquire_lock (lock);
16139 ... non transactional fallback path...
16140 release_lock (lock);
16141 break;
16142 @}
16143 @}
16144 @}
16145 @end smallexample
16146
16147 @node RX Built-in Functions
16148 @subsection RX Built-in Functions
16149 GCC supports some of the RX instructions which cannot be expressed in
16150 the C programming language via the use of built-in functions. The
16151 following functions are supported:
16152
16153 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
16154 Generates the @code{brk} machine instruction.
16155 @end deftypefn
16156
16157 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
16158 Generates the @code{clrpsw} machine instruction to clear the specified
16159 bit in the processor status word.
16160 @end deftypefn
16161
16162 @deftypefn {Built-in Function} void __builtin_rx_int (int)
16163 Generates the @code{int} machine instruction to generate an interrupt
16164 with the specified value.
16165 @end deftypefn
16166
16167 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
16168 Generates the @code{machi} machine instruction to add the result of
16169 multiplying the top 16 bits of the two arguments into the
16170 accumulator.
16171 @end deftypefn
16172
16173 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
16174 Generates the @code{maclo} machine instruction to add the result of
16175 multiplying the bottom 16 bits of the two arguments into the
16176 accumulator.
16177 @end deftypefn
16178
16179 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
16180 Generates the @code{mulhi} machine instruction to place the result of
16181 multiplying the top 16 bits of the two arguments into the
16182 accumulator.
16183 @end deftypefn
16184
16185 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
16186 Generates the @code{mullo} machine instruction to place the result of
16187 multiplying the bottom 16 bits of the two arguments into the
16188 accumulator.
16189 @end deftypefn
16190
16191 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
16192 Generates the @code{mvfachi} machine instruction to read the top
16193 32 bits of the accumulator.
16194 @end deftypefn
16195
16196 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
16197 Generates the @code{mvfacmi} machine instruction to read the middle
16198 32 bits of the accumulator.
16199 @end deftypefn
16200
16201 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
16202 Generates the @code{mvfc} machine instruction which reads the control
16203 register specified in its argument and returns its value.
16204 @end deftypefn
16205
16206 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
16207 Generates the @code{mvtachi} machine instruction to set the top
16208 32 bits of the accumulator.
16209 @end deftypefn
16210
16211 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
16212 Generates the @code{mvtaclo} machine instruction to set the bottom
16213 32 bits of the accumulator.
16214 @end deftypefn
16215
16216 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
16217 Generates the @code{mvtc} machine instruction which sets control
16218 register number @code{reg} to @code{val}.
16219 @end deftypefn
16220
16221 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
16222 Generates the @code{mvtipl} machine instruction set the interrupt
16223 priority level.
16224 @end deftypefn
16225
16226 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
16227 Generates the @code{racw} machine instruction to round the accumulator
16228 according to the specified mode.
16229 @end deftypefn
16230
16231 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
16232 Generates the @code{revw} machine instruction which swaps the bytes in
16233 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16234 and also bits 16--23 occupy bits 24--31 and vice versa.
16235 @end deftypefn
16236
16237 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
16238 Generates the @code{rmpa} machine instruction which initiates a
16239 repeated multiply and accumulate sequence.
16240 @end deftypefn
16241
16242 @deftypefn {Built-in Function} void __builtin_rx_round (float)
16243 Generates the @code{round} machine instruction which returns the
16244 floating-point argument rounded according to the current rounding mode
16245 set in the floating-point status word register.
16246 @end deftypefn
16247
16248 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
16249 Generates the @code{sat} machine instruction which returns the
16250 saturated value of the argument.
16251 @end deftypefn
16252
16253 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
16254 Generates the @code{setpsw} machine instruction to set the specified
16255 bit in the processor status word.
16256 @end deftypefn
16257
16258 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
16259 Generates the @code{wait} machine instruction.
16260 @end deftypefn
16261
16262 @node S/390 System z Built-in Functions
16263 @subsection S/390 System z Built-in Functions
16264 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16265 Generates the @code{tbegin} machine instruction starting a
16266 non-constraint hardware transaction. If the parameter is non-NULL the
16267 memory area is used to store the transaction diagnostic buffer and
16268 will be passed as first operand to @code{tbegin}. This buffer can be
16269 defined using the @code{struct __htm_tdb} C struct defined in
16270 @code{htmintrin.h} and must reside on a double-word boundary. The
16271 second tbegin operand is set to @code{0xff0c}. This enables
16272 save/restore of all GPRs and disables aborts for FPR and AR
16273 manipulations inside the transaction body. The condition code set by
16274 the tbegin instruction is returned as integer value. The tbegin
16275 instruction by definition overwrites the content of all FPRs. The
16276 compiler will generate code which saves and restores the FPRs. For
16277 soft-float code it is recommended to used the @code{*_nofloat}
16278 variant. In order to prevent a TDB from being written it is required
16279 to pass an constant zero value as parameter. Passing the zero value
16280 through a variable is not sufficient. Although modifications of
16281 access registers inside the transaction will not trigger an
16282 transaction abort it is not supported to actually modify them. Access
16283 registers do not get saved when entering a transaction. They will have
16284 undefined state when reaching the abort code.
16285 @end deftypefn
16286
16287 Macros for the possible return codes of tbegin are defined in the
16288 @code{htmintrin.h} header file:
16289
16290 @table @code
16291 @item _HTM_TBEGIN_STARTED
16292 @code{tbegin} has been executed as part of normal processing. The
16293 transaction body is supposed to be executed.
16294 @item _HTM_TBEGIN_INDETERMINATE
16295 The transaction was aborted due to an indeterminate condition which
16296 might be persistent.
16297 @item _HTM_TBEGIN_TRANSIENT
16298 The transaction aborted due to a transient failure. The transaction
16299 should be re-executed in that case.
16300 @item _HTM_TBEGIN_PERSISTENT
16301 The transaction aborted due to a persistent failure. Re-execution
16302 under same circumstances will not be productive.
16303 @end table
16304
16305 @defmac _HTM_FIRST_USER_ABORT_CODE
16306 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16307 specifies the first abort code which can be used for
16308 @code{__builtin_tabort}. Values below this threshold are reserved for
16309 machine use.
16310 @end defmac
16311
16312 @deftp {Data type} {struct __htm_tdb}
16313 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16314 the structure of the transaction diagnostic block as specified in the
16315 Principles of Operation manual chapter 5-91.
16316 @end deftp
16317
16318 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16319 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16320 Using this variant in code making use of FPRs will leave the FPRs in
16321 undefined state when entering the transaction abort handler code.
16322 @end deftypefn
16323
16324 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16325 In addition to @code{__builtin_tbegin} a loop for transient failures
16326 is generated. If tbegin returns a condition code of 2 the transaction
16327 will be retried as often as specified in the second argument. The
16328 perform processor assist instruction is used to tell the CPU about the
16329 number of fails so far.
16330 @end deftypefn
16331
16332 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16333 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16334 restores. Using this variant in code making use of FPRs will leave
16335 the FPRs in undefined state when entering the transaction abort
16336 handler code.
16337 @end deftypefn
16338
16339 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16340 Generates the @code{tbeginc} machine instruction starting a constraint
16341 hardware transaction. The second operand is set to @code{0xff08}.
16342 @end deftypefn
16343
16344 @deftypefn {Built-in Function} int __builtin_tend (void)
16345 Generates the @code{tend} machine instruction finishing a transaction
16346 and making the changes visible to other threads. The condition code
16347 generated by tend is returned as integer value.
16348 @end deftypefn
16349
16350 @deftypefn {Built-in Function} void __builtin_tabort (int)
16351 Generates the @code{tabort} machine instruction with the specified
16352 abort code. Abort codes from 0 through 255 are reserved and will
16353 result in an error message.
16354 @end deftypefn
16355
16356 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16357 Generates the @code{ppa rX,rY,1} machine instruction. Where the
16358 integer parameter is loaded into rX and a value of zero is loaded into
16359 rY. The integer parameter specifies the number of times the
16360 transaction repeatedly aborted.
16361 @end deftypefn
16362
16363 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16364 Generates the @code{etnd} machine instruction. The current nesting
16365 depth is returned as integer value. For a nesting depth of 0 the code
16366 is not executed as part of an transaction.
16367 @end deftypefn
16368
16369 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16370
16371 Generates the @code{ntstg} machine instruction. The second argument
16372 is written to the first arguments location. The store operation will
16373 not be rolled-back in case of an transaction abort.
16374 @end deftypefn
16375
16376 @node SH Built-in Functions
16377 @subsection SH Built-in Functions
16378 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16379 families of processors:
16380
16381 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16382 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
16383 used by system code that manages threads and execution contexts. The compiler
16384 normally does not generate code that modifies the contents of @samp{GBR} and
16385 thus the value is preserved across function calls. Changing the @samp{GBR}
16386 value in user code must be done with caution, since the compiler might use
16387 @samp{GBR} in order to access thread local variables.
16388
16389 @end deftypefn
16390
16391 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16392 Returns the value that is currently set in the @samp{GBR} register.
16393 Memory loads and stores that use the thread pointer as a base address are
16394 turned into @samp{GBR} based displacement loads and stores, if possible.
16395 For example:
16396 @smallexample
16397 struct my_tcb
16398 @{
16399 int a, b, c, d, e;
16400 @};
16401
16402 int get_tcb_value (void)
16403 @{
16404 // Generate @samp{mov.l @@(8,gbr),r0} instruction
16405 return ((my_tcb*)__builtin_thread_pointer ())->c;
16406 @}
16407
16408 @end smallexample
16409 @end deftypefn
16410
16411 @node SPARC VIS Built-in Functions
16412 @subsection SPARC VIS Built-in Functions
16413
16414 GCC supports SIMD operations on the SPARC using both the generic vector
16415 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16416 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
16417 switch, the VIS extension is exposed as the following built-in functions:
16418
16419 @smallexample
16420 typedef int v1si __attribute__ ((vector_size (4)));
16421 typedef int v2si __attribute__ ((vector_size (8)));
16422 typedef short v4hi __attribute__ ((vector_size (8)));
16423 typedef short v2hi __attribute__ ((vector_size (4)));
16424 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16425 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16426
16427 void __builtin_vis_write_gsr (int64_t);
16428 int64_t __builtin_vis_read_gsr (void);
16429
16430 void * __builtin_vis_alignaddr (void *, long);
16431 void * __builtin_vis_alignaddrl (void *, long);
16432 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16433 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16434 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16435 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16436
16437 v4hi __builtin_vis_fexpand (v4qi);
16438
16439 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16440 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16441 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16442 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16443 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16444 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16445 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16446
16447 v4qi __builtin_vis_fpack16 (v4hi);
16448 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16449 v2hi __builtin_vis_fpackfix (v2si);
16450 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16451
16452 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16453
16454 long __builtin_vis_edge8 (void *, void *);
16455 long __builtin_vis_edge8l (void *, void *);
16456 long __builtin_vis_edge16 (void *, void *);
16457 long __builtin_vis_edge16l (void *, void *);
16458 long __builtin_vis_edge32 (void *, void *);
16459 long __builtin_vis_edge32l (void *, void *);
16460
16461 long __builtin_vis_fcmple16 (v4hi, v4hi);
16462 long __builtin_vis_fcmple32 (v2si, v2si);
16463 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16464 long __builtin_vis_fcmpne32 (v2si, v2si);
16465 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16466 long __builtin_vis_fcmpgt32 (v2si, v2si);
16467 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16468 long __builtin_vis_fcmpeq32 (v2si, v2si);
16469
16470 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16471 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16472 v2si __builtin_vis_fpadd32 (v2si, v2si);
16473 v1si __builtin_vis_fpadd32s (v1si, v1si);
16474 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
16475 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
16476 v2si __builtin_vis_fpsub32 (v2si, v2si);
16477 v1si __builtin_vis_fpsub32s (v1si, v1si);
16478
16479 long __builtin_vis_array8 (long, long);
16480 long __builtin_vis_array16 (long, long);
16481 long __builtin_vis_array32 (long, long);
16482 @end smallexample
16483
16484 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
16485 functions also become available:
16486
16487 @smallexample
16488 long __builtin_vis_bmask (long, long);
16489 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
16490 v2si __builtin_vis_bshufflev2si (v2si, v2si);
16491 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
16492 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
16493
16494 long __builtin_vis_edge8n (void *, void *);
16495 long __builtin_vis_edge8ln (void *, void *);
16496 long __builtin_vis_edge16n (void *, void *);
16497 long __builtin_vis_edge16ln (void *, void *);
16498 long __builtin_vis_edge32n (void *, void *);
16499 long __builtin_vis_edge32ln (void *, void *);
16500 @end smallexample
16501
16502 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
16503 functions also become available:
16504
16505 @smallexample
16506 void __builtin_vis_cmask8 (long);
16507 void __builtin_vis_cmask16 (long);
16508 void __builtin_vis_cmask32 (long);
16509
16510 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
16511
16512 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
16513 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
16514 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
16515 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
16516 v2si __builtin_vis_fsll16 (v2si, v2si);
16517 v2si __builtin_vis_fslas16 (v2si, v2si);
16518 v2si __builtin_vis_fsrl16 (v2si, v2si);
16519 v2si __builtin_vis_fsra16 (v2si, v2si);
16520
16521 long __builtin_vis_pdistn (v8qi, v8qi);
16522
16523 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
16524
16525 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
16526 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
16527
16528 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
16529 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
16530 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
16531 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
16532 v2si __builtin_vis_fpadds32 (v2si, v2si);
16533 v1si __builtin_vis_fpadds32s (v1si, v1si);
16534 v2si __builtin_vis_fpsubs32 (v2si, v2si);
16535 v1si __builtin_vis_fpsubs32s (v1si, v1si);
16536
16537 long __builtin_vis_fucmple8 (v8qi, v8qi);
16538 long __builtin_vis_fucmpne8 (v8qi, v8qi);
16539 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
16540 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
16541
16542 float __builtin_vis_fhadds (float, float);
16543 double __builtin_vis_fhaddd (double, double);
16544 float __builtin_vis_fhsubs (float, float);
16545 double __builtin_vis_fhsubd (double, double);
16546 float __builtin_vis_fnhadds (float, float);
16547 double __builtin_vis_fnhaddd (double, double);
16548
16549 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
16550 int64_t __builtin_vis_xmulx (int64_t, int64_t);
16551 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
16552 @end smallexample
16553
16554 @node SPU Built-in Functions
16555 @subsection SPU Built-in Functions
16556
16557 GCC provides extensions for the SPU processor as described in the
16558 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
16559 found at @uref{http://cell.scei.co.jp/} or
16560 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
16561 implementation differs in several ways.
16562
16563 @itemize @bullet
16564
16565 @item
16566 The optional extension of specifying vector constants in parentheses is
16567 not supported.
16568
16569 @item
16570 A vector initializer requires no cast if the vector constant is of the
16571 same type as the variable it is initializing.
16572
16573 @item
16574 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16575 vector type is the default signedness of the base type. The default
16576 varies depending on the operating system, so a portable program should
16577 always specify the signedness.
16578
16579 @item
16580 By default, the keyword @code{__vector} is added. The macro
16581 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
16582 undefined.
16583
16584 @item
16585 GCC allows using a @code{typedef} name as the type specifier for a
16586 vector type.
16587
16588 @item
16589 For C, overloaded functions are implemented with macros so the following
16590 does not work:
16591
16592 @smallexample
16593 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16594 @end smallexample
16595
16596 @noindent
16597 Since @code{spu_add} is a macro, the vector constant in the example
16598 is treated as four separate arguments. Wrap the entire argument in
16599 parentheses for this to work.
16600
16601 @item
16602 The extended version of @code{__builtin_expect} is not supported.
16603
16604 @end itemize
16605
16606 @emph{Note:} Only the interface described in the aforementioned
16607 specification is supported. Internally, GCC uses built-in functions to
16608 implement the required functionality, but these are not supported and
16609 are subject to change without notice.
16610
16611 @node TI C6X Built-in Functions
16612 @subsection TI C6X Built-in Functions
16613
16614 GCC provides intrinsics to access certain instructions of the TI C6X
16615 processors. These intrinsics, listed below, are available after
16616 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
16617 to C6X instructions.
16618
16619 @smallexample
16620
16621 int _sadd (int, int)
16622 int _ssub (int, int)
16623 int _sadd2 (int, int)
16624 int _ssub2 (int, int)
16625 long long _mpy2 (int, int)
16626 long long _smpy2 (int, int)
16627 int _add4 (int, int)
16628 int _sub4 (int, int)
16629 int _saddu4 (int, int)
16630
16631 int _smpy (int, int)
16632 int _smpyh (int, int)
16633 int _smpyhl (int, int)
16634 int _smpylh (int, int)
16635
16636 int _sshl (int, int)
16637 int _subc (int, int)
16638
16639 int _avg2 (int, int)
16640 int _avgu4 (int, int)
16641
16642 int _clrr (int, int)
16643 int _extr (int, int)
16644 int _extru (int, int)
16645 int _abs (int)
16646 int _abs2 (int)
16647
16648 @end smallexample
16649
16650 @node TILE-Gx Built-in Functions
16651 @subsection TILE-Gx Built-in Functions
16652
16653 GCC provides intrinsics to access every instruction of the TILE-Gx
16654 processor. The intrinsics are of the form:
16655
16656 @smallexample
16657
16658 unsigned long long __insn_@var{op} (...)
16659
16660 @end smallexample
16661
16662 Where @var{op} is the name of the instruction. Refer to the ISA manual
16663 for the complete list of instructions.
16664
16665 GCC also provides intrinsics to directly access the network registers.
16666 The intrinsics are:
16667
16668 @smallexample
16669
16670 unsigned long long __tile_idn0_receive (void)
16671 unsigned long long __tile_idn1_receive (void)
16672 unsigned long long __tile_udn0_receive (void)
16673 unsigned long long __tile_udn1_receive (void)
16674 unsigned long long __tile_udn2_receive (void)
16675 unsigned long long __tile_udn3_receive (void)
16676 void __tile_idn_send (unsigned long long)
16677 void __tile_udn_send (unsigned long long)
16678
16679 @end smallexample
16680
16681 The intrinsic @code{void __tile_network_barrier (void)} is used to
16682 guarantee that no network operations before it are reordered with
16683 those after it.
16684
16685 @node TILEPro Built-in Functions
16686 @subsection TILEPro Built-in Functions
16687
16688 GCC provides intrinsics to access every instruction of the TILEPro
16689 processor. The intrinsics are of the form:
16690
16691 @smallexample
16692
16693 unsigned __insn_@var{op} (...)
16694
16695 @end smallexample
16696
16697 @noindent
16698 where @var{op} is the name of the instruction. Refer to the ISA manual
16699 for the complete list of instructions.
16700
16701 GCC also provides intrinsics to directly access the network registers.
16702 The intrinsics are:
16703
16704 @smallexample
16705
16706 unsigned __tile_idn0_receive (void)
16707 unsigned __tile_idn1_receive (void)
16708 unsigned __tile_sn_receive (void)
16709 unsigned __tile_udn0_receive (void)
16710 unsigned __tile_udn1_receive (void)
16711 unsigned __tile_udn2_receive (void)
16712 unsigned __tile_udn3_receive (void)
16713 void __tile_idn_send (unsigned)
16714 void __tile_sn_send (unsigned)
16715 void __tile_udn_send (unsigned)
16716
16717 @end smallexample
16718
16719 The intrinsic @code{void __tile_network_barrier (void)} is used to
16720 guarantee that no network operations before it are reordered with
16721 those after it.
16722
16723 @node Target Format Checks
16724 @section Format Checks Specific to Particular Target Machines
16725
16726 For some target machines, GCC supports additional options to the
16727 format attribute
16728 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
16729
16730 @menu
16731 * Solaris Format Checks::
16732 * Darwin Format Checks::
16733 @end menu
16734
16735 @node Solaris Format Checks
16736 @subsection Solaris Format Checks
16737
16738 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
16739 check. @code{cmn_err} accepts a subset of the standard @code{printf}
16740 conversions, and the two-argument @code{%b} conversion for displaying
16741 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
16742
16743 @node Darwin Format Checks
16744 @subsection Darwin Format Checks
16745
16746 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
16747 attribute context. Declarations made with such attribution are parsed for correct syntax
16748 and format argument types. However, parsing of the format string itself is currently undefined
16749 and is not carried out by this version of the compiler.
16750
16751 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
16752 also be used as format arguments. Note that the relevant headers are only likely to be
16753 available on Darwin (OSX) installations. On such installations, the XCode and system
16754 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
16755 associated functions.
16756
16757 @node Pragmas
16758 @section Pragmas Accepted by GCC
16759 @cindex pragmas
16760 @cindex @code{#pragma}
16761
16762 GCC supports several types of pragmas, primarily in order to compile
16763 code originally written for other compilers. Note that in general
16764 we do not recommend the use of pragmas; @xref{Function Attributes},
16765 for further explanation.
16766
16767 @menu
16768 * ARM Pragmas::
16769 * M32C Pragmas::
16770 * MeP Pragmas::
16771 * RS/6000 and PowerPC Pragmas::
16772 * Darwin Pragmas::
16773 * Solaris Pragmas::
16774 * Symbol-Renaming Pragmas::
16775 * Structure-Packing Pragmas::
16776 * Weak Pragmas::
16777 * Diagnostic Pragmas::
16778 * Visibility Pragmas::
16779 * Push/Pop Macro Pragmas::
16780 * Function Specific Option Pragmas::
16781 * Loop-Specific Pragmas::
16782 @end menu
16783
16784 @node ARM Pragmas
16785 @subsection ARM Pragmas
16786
16787 The ARM target defines pragmas for controlling the default addition of
16788 @code{long_call} and @code{short_call} attributes to functions.
16789 @xref{Function Attributes}, for information about the effects of these
16790 attributes.
16791
16792 @table @code
16793 @item long_calls
16794 @cindex pragma, long_calls
16795 Set all subsequent functions to have the @code{long_call} attribute.
16796
16797 @item no_long_calls
16798 @cindex pragma, no_long_calls
16799 Set all subsequent functions to have the @code{short_call} attribute.
16800
16801 @item long_calls_off
16802 @cindex pragma, long_calls_off
16803 Do not affect the @code{long_call} or @code{short_call} attributes of
16804 subsequent functions.
16805 @end table
16806
16807 @node M32C Pragmas
16808 @subsection M32C Pragmas
16809
16810 @table @code
16811 @item GCC memregs @var{number}
16812 @cindex pragma, memregs
16813 Overrides the command-line option @code{-memregs=} for the current
16814 file. Use with care! This pragma must be before any function in the
16815 file, and mixing different memregs values in different objects may
16816 make them incompatible. This pragma is useful when a
16817 performance-critical function uses a memreg for temporary values,
16818 as it may allow you to reduce the number of memregs used.
16819
16820 @item ADDRESS @var{name} @var{address}
16821 @cindex pragma, address
16822 For any declared symbols matching @var{name}, this does three things
16823 to that symbol: it forces the symbol to be located at the given
16824 address (a number), it forces the symbol to be volatile, and it
16825 changes the symbol's scope to be static. This pragma exists for
16826 compatibility with other compilers, but note that the common
16827 @code{1234H} numeric syntax is not supported (use @code{0x1234}
16828 instead). Example:
16829
16830 @smallexample
16831 #pragma ADDRESS port3 0x103
16832 char port3;
16833 @end smallexample
16834
16835 @end table
16836
16837 @node MeP Pragmas
16838 @subsection MeP Pragmas
16839
16840 @table @code
16841
16842 @item custom io_volatile (on|off)
16843 @cindex pragma, custom io_volatile
16844 Overrides the command-line option @code{-mio-volatile} for the current
16845 file. Note that for compatibility with future GCC releases, this
16846 option should only be used once before any @code{io} variables in each
16847 file.
16848
16849 @item GCC coprocessor available @var{registers}
16850 @cindex pragma, coprocessor available
16851 Specifies which coprocessor registers are available to the register
16852 allocator. @var{registers} may be a single register, register range
16853 separated by ellipses, or comma-separated list of those. Example:
16854
16855 @smallexample
16856 #pragma GCC coprocessor available $c0...$c10, $c28
16857 @end smallexample
16858
16859 @item GCC coprocessor call_saved @var{registers}
16860 @cindex pragma, coprocessor call_saved
16861 Specifies which coprocessor registers are to be saved and restored by
16862 any function using them. @var{registers} may be a single register,
16863 register range separated by ellipses, or comma-separated list of
16864 those. Example:
16865
16866 @smallexample
16867 #pragma GCC coprocessor call_saved $c4...$c6, $c31
16868 @end smallexample
16869
16870 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
16871 @cindex pragma, coprocessor subclass
16872 Creates and defines a register class. These register classes can be
16873 used by inline @code{asm} constructs. @var{registers} may be a single
16874 register, register range separated by ellipses, or comma-separated
16875 list of those. Example:
16876
16877 @smallexample
16878 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
16879
16880 asm ("cpfoo %0" : "=B" (x));
16881 @end smallexample
16882
16883 @item GCC disinterrupt @var{name} , @var{name} @dots{}
16884 @cindex pragma, disinterrupt
16885 For the named functions, the compiler adds code to disable interrupts
16886 for the duration of those functions. If any functions so named
16887 are not encountered in the source, a warning is emitted that the pragma is
16888 not used. Examples:
16889
16890 @smallexample
16891 #pragma disinterrupt foo
16892 #pragma disinterrupt bar, grill
16893 int foo () @{ @dots{} @}
16894 @end smallexample
16895
16896 @item GCC call @var{name} , @var{name} @dots{}
16897 @cindex pragma, call
16898 For the named functions, the compiler always uses a register-indirect
16899 call model when calling the named functions. Examples:
16900
16901 @smallexample
16902 extern int foo ();
16903 #pragma call foo
16904 @end smallexample
16905
16906 @end table
16907
16908 @node RS/6000 and PowerPC Pragmas
16909 @subsection RS/6000 and PowerPC Pragmas
16910
16911 The RS/6000 and PowerPC targets define one pragma for controlling
16912 whether or not the @code{longcall} attribute is added to function
16913 declarations by default. This pragma overrides the @option{-mlongcall}
16914 option, but not the @code{longcall} and @code{shortcall} attributes.
16915 @xref{RS/6000 and PowerPC Options}, for more information about when long
16916 calls are and are not necessary.
16917
16918 @table @code
16919 @item longcall (1)
16920 @cindex pragma, longcall
16921 Apply the @code{longcall} attribute to all subsequent function
16922 declarations.
16923
16924 @item longcall (0)
16925 Do not apply the @code{longcall} attribute to subsequent function
16926 declarations.
16927 @end table
16928
16929 @c Describe h8300 pragmas here.
16930 @c Describe sh pragmas here.
16931 @c Describe v850 pragmas here.
16932
16933 @node Darwin Pragmas
16934 @subsection Darwin Pragmas
16935
16936 The following pragmas are available for all architectures running the
16937 Darwin operating system. These are useful for compatibility with other
16938 Mac OS compilers.
16939
16940 @table @code
16941 @item mark @var{tokens}@dots{}
16942 @cindex pragma, mark
16943 This pragma is accepted, but has no effect.
16944
16945 @item options align=@var{alignment}
16946 @cindex pragma, options align
16947 This pragma sets the alignment of fields in structures. The values of
16948 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
16949 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
16950 properly; to restore the previous setting, use @code{reset} for the
16951 @var{alignment}.
16952
16953 @item segment @var{tokens}@dots{}
16954 @cindex pragma, segment
16955 This pragma is accepted, but has no effect.
16956
16957 @item unused (@var{var} [, @var{var}]@dots{})
16958 @cindex pragma, unused
16959 This pragma declares variables to be possibly unused. GCC does not
16960 produce warnings for the listed variables. The effect is similar to
16961 that of the @code{unused} attribute, except that this pragma may appear
16962 anywhere within the variables' scopes.
16963 @end table
16964
16965 @node Solaris Pragmas
16966 @subsection Solaris Pragmas
16967
16968 The Solaris target supports @code{#pragma redefine_extname}
16969 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
16970 @code{#pragma} directives for compatibility with the system compiler.
16971
16972 @table @code
16973 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
16974 @cindex pragma, align
16975
16976 Increase the minimum alignment of each @var{variable} to @var{alignment}.
16977 This is the same as GCC's @code{aligned} attribute @pxref{Variable
16978 Attributes}). Macro expansion occurs on the arguments to this pragma
16979 when compiling C and Objective-C@. It does not currently occur when
16980 compiling C++, but this is a bug which may be fixed in a future
16981 release.
16982
16983 @item fini (@var{function} [, @var{function}]...)
16984 @cindex pragma, fini
16985
16986 This pragma causes each listed @var{function} to be called after
16987 main, or during shared module unloading, by adding a call to the
16988 @code{.fini} section.
16989
16990 @item init (@var{function} [, @var{function}]...)
16991 @cindex pragma, init
16992
16993 This pragma causes each listed @var{function} to be called during
16994 initialization (before @code{main}) or during shared module loading, by
16995 adding a call to the @code{.init} section.
16996
16997 @end table
16998
16999 @node Symbol-Renaming Pragmas
17000 @subsection Symbol-Renaming Pragmas
17001
17002 GCC supports a @code{#pragma} directive that changes the name used in
17003 assembly for a given declaration. This effect can also be achieved
17004 using the asm labels extension (@pxref{Asm Labels}).
17005
17006 @table @code
17007 @item redefine_extname @var{oldname} @var{newname}
17008 @cindex pragma, redefine_extname
17009
17010 This pragma gives the C function @var{oldname} the assembly symbol
17011 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
17012 is defined if this pragma is available (currently on all platforms).
17013 @end table
17014
17015 This pragma and the asm labels extension interact in a complicated
17016 manner. Here are some corner cases you may want to be aware of:
17017
17018 @enumerate
17019 @item This pragma silently applies only to declarations with external
17020 linkage. Asm labels do not have this restriction.
17021
17022 @item In C++, this pragma silently applies only to declarations with
17023 ``C'' linkage. Again, asm labels do not have this restriction.
17024
17025 @item If either of the ways of changing the assembly name of a
17026 declaration are applied to a declaration whose assembly name has
17027 already been determined (either by a previous use of one of these
17028 features, or because the compiler needed the assembly name in order to
17029 generate code), and the new name is different, a warning issues and
17030 the name does not change.
17031
17032 @item The @var{oldname} used by @code{#pragma redefine_extname} is
17033 always the C-language name.
17034 @end enumerate
17035
17036 @node Structure-Packing Pragmas
17037 @subsection Structure-Packing Pragmas
17038
17039 For compatibility with Microsoft Windows compilers, GCC supports a
17040 set of @code{#pragma} directives that change the maximum alignment of
17041 members of structures (other than zero-width bit-fields), unions, and
17042 classes subsequently defined. The @var{n} value below always is required
17043 to be a small power of two and specifies the new alignment in bytes.
17044
17045 @enumerate
17046 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
17047 @item @code{#pragma pack()} sets the alignment to the one that was in
17048 effect when compilation started (see also command-line option
17049 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
17050 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
17051 setting on an internal stack and then optionally sets the new alignment.
17052 @item @code{#pragma pack(pop)} restores the alignment setting to the one
17053 saved at the top of the internal stack (and removes that stack entry).
17054 Note that @code{#pragma pack([@var{n}])} does not influence this internal
17055 stack; thus it is possible to have @code{#pragma pack(push)} followed by
17056 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
17057 @code{#pragma pack(pop)}.
17058 @end enumerate
17059
17060 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
17061 @code{#pragma} which lays out a structure as the documented
17062 @code{__attribute__ ((ms_struct))}.
17063 @enumerate
17064 @item @code{#pragma ms_struct on} turns on the layout for structures
17065 declared.
17066 @item @code{#pragma ms_struct off} turns off the layout for structures
17067 declared.
17068 @item @code{#pragma ms_struct reset} goes back to the default layout.
17069 @end enumerate
17070
17071 @node Weak Pragmas
17072 @subsection Weak Pragmas
17073
17074 For compatibility with SVR4, GCC supports a set of @code{#pragma}
17075 directives for declaring symbols to be weak, and defining weak
17076 aliases.
17077
17078 @table @code
17079 @item #pragma weak @var{symbol}
17080 @cindex pragma, weak
17081 This pragma declares @var{symbol} to be weak, as if the declaration
17082 had the attribute of the same name. The pragma may appear before
17083 or after the declaration of @var{symbol}. It is not an error for
17084 @var{symbol} to never be defined at all.
17085
17086 @item #pragma weak @var{symbol1} = @var{symbol2}
17087 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
17088 It is an error if @var{symbol2} is not defined in the current
17089 translation unit.
17090 @end table
17091
17092 @node Diagnostic Pragmas
17093 @subsection Diagnostic Pragmas
17094
17095 GCC allows the user to selectively enable or disable certain types of
17096 diagnostics, and change the kind of the diagnostic. For example, a
17097 project's policy might require that all sources compile with
17098 @option{-Werror} but certain files might have exceptions allowing
17099 specific types of warnings. Or, a project might selectively enable
17100 diagnostics and treat them as errors depending on which preprocessor
17101 macros are defined.
17102
17103 @table @code
17104 @item #pragma GCC diagnostic @var{kind} @var{option}
17105 @cindex pragma, diagnostic
17106
17107 Modifies the disposition of a diagnostic. Note that not all
17108 diagnostics are modifiable; at the moment only warnings (normally
17109 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
17110 Use @option{-fdiagnostics-show-option} to determine which diagnostics
17111 are controllable and which option controls them.
17112
17113 @var{kind} is @samp{error} to treat this diagnostic as an error,
17114 @samp{warning} to treat it like a warning (even if @option{-Werror} is
17115 in effect), or @samp{ignored} if the diagnostic is to be ignored.
17116 @var{option} is a double quoted string that matches the command-line
17117 option.
17118
17119 @smallexample
17120 #pragma GCC diagnostic warning "-Wformat"
17121 #pragma GCC diagnostic error "-Wformat"
17122 #pragma GCC diagnostic ignored "-Wformat"
17123 @end smallexample
17124
17125 Note that these pragmas override any command-line options. GCC keeps
17126 track of the location of each pragma, and issues diagnostics according
17127 to the state as of that point in the source file. Thus, pragmas occurring
17128 after a line do not affect diagnostics caused by that line.
17129
17130 @item #pragma GCC diagnostic push
17131 @itemx #pragma GCC diagnostic pop
17132
17133 Causes GCC to remember the state of the diagnostics as of each
17134 @code{push}, and restore to that point at each @code{pop}. If a
17135 @code{pop} has no matching @code{push}, the command-line options are
17136 restored.
17137
17138 @smallexample
17139 #pragma GCC diagnostic error "-Wuninitialized"
17140 foo(a); /* error is given for this one */
17141 #pragma GCC diagnostic push
17142 #pragma GCC diagnostic ignored "-Wuninitialized"
17143 foo(b); /* no diagnostic for this one */
17144 #pragma GCC diagnostic pop
17145 foo(c); /* error is given for this one */
17146 #pragma GCC diagnostic pop
17147 foo(d); /* depends on command-line options */
17148 @end smallexample
17149
17150 @end table
17151
17152 GCC also offers a simple mechanism for printing messages during
17153 compilation.
17154
17155 @table @code
17156 @item #pragma message @var{string}
17157 @cindex pragma, diagnostic
17158
17159 Prints @var{string} as a compiler message on compilation. The message
17160 is informational only, and is neither a compilation warning nor an error.
17161
17162 @smallexample
17163 #pragma message "Compiling " __FILE__ "..."
17164 @end smallexample
17165
17166 @var{string} may be parenthesized, and is printed with location
17167 information. For example,
17168
17169 @smallexample
17170 #define DO_PRAGMA(x) _Pragma (#x)
17171 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
17172
17173 TODO(Remember to fix this)
17174 @end smallexample
17175
17176 @noindent
17177 prints @samp{/tmp/file.c:4: note: #pragma message:
17178 TODO - Remember to fix this}.
17179
17180 @end table
17181
17182 @node Visibility Pragmas
17183 @subsection Visibility Pragmas
17184
17185 @table @code
17186 @item #pragma GCC visibility push(@var{visibility})
17187 @itemx #pragma GCC visibility pop
17188 @cindex pragma, visibility
17189
17190 This pragma allows the user to set the visibility for multiple
17191 declarations without having to give each a visibility attribute
17192 (@pxref{Function Attributes}).
17193
17194 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
17195 declarations. Class members and template specializations are not
17196 affected; if you want to override the visibility for a particular
17197 member or instantiation, you must use an attribute.
17198
17199 @end table
17200
17201
17202 @node Push/Pop Macro Pragmas
17203 @subsection Push/Pop Macro Pragmas
17204
17205 For compatibility with Microsoft Windows compilers, GCC supports
17206 @samp{#pragma push_macro(@var{"macro_name"})}
17207 and @samp{#pragma pop_macro(@var{"macro_name"})}.
17208
17209 @table @code
17210 @item #pragma push_macro(@var{"macro_name"})
17211 @cindex pragma, push_macro
17212 This pragma saves the value of the macro named as @var{macro_name} to
17213 the top of the stack for this macro.
17214
17215 @item #pragma pop_macro(@var{"macro_name"})
17216 @cindex pragma, pop_macro
17217 This pragma sets the value of the macro named as @var{macro_name} to
17218 the value on top of the stack for this macro. If the stack for
17219 @var{macro_name} is empty, the value of the macro remains unchanged.
17220 @end table
17221
17222 For example:
17223
17224 @smallexample
17225 #define X 1
17226 #pragma push_macro("X")
17227 #undef X
17228 #define X -1
17229 #pragma pop_macro("X")
17230 int x [X];
17231 @end smallexample
17232
17233 @noindent
17234 In this example, the definition of X as 1 is saved by @code{#pragma
17235 push_macro} and restored by @code{#pragma pop_macro}.
17236
17237 @node Function Specific Option Pragmas
17238 @subsection Function Specific Option Pragmas
17239
17240 @table @code
17241 @item #pragma GCC target (@var{"string"}...)
17242 @cindex pragma GCC target
17243
17244 This pragma allows you to set target specific options for functions
17245 defined later in the source file. One or more strings can be
17246 specified. Each function that is defined after this point is as
17247 if @code{attribute((target("STRING")))} was specified for that
17248 function. The parenthesis around the options is optional.
17249 @xref{Function Attributes}, for more information about the
17250 @code{target} attribute and the attribute syntax.
17251
17252 The @code{#pragma GCC target} pragma is presently implemented for
17253 i386/x86_64, PowerPC, and Nios II targets only.
17254 @end table
17255
17256 @table @code
17257 @item #pragma GCC optimize (@var{"string"}...)
17258 @cindex pragma GCC optimize
17259
17260 This pragma allows you to set global optimization options for functions
17261 defined later in the source file. One or more strings can be
17262 specified. Each function that is defined after this point is as
17263 if @code{attribute((optimize("STRING")))} was specified for that
17264 function. The parenthesis around the options is optional.
17265 @xref{Function Attributes}, for more information about the
17266 @code{optimize} attribute and the attribute syntax.
17267
17268 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
17269 versions earlier than 4.4.
17270 @end table
17271
17272 @table @code
17273 @item #pragma GCC push_options
17274 @itemx #pragma GCC pop_options
17275 @cindex pragma GCC push_options
17276 @cindex pragma GCC pop_options
17277
17278 These pragmas maintain a stack of the current target and optimization
17279 options. It is intended for include files where you temporarily want
17280 to switch to using a different @samp{#pragma GCC target} or
17281 @samp{#pragma GCC optimize} and then to pop back to the previous
17282 options.
17283
17284 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
17285 pragmas are not implemented in GCC versions earlier than 4.4.
17286 @end table
17287
17288 @table @code
17289 @item #pragma GCC reset_options
17290 @cindex pragma GCC reset_options
17291
17292 This pragma clears the current @code{#pragma GCC target} and
17293 @code{#pragma GCC optimize} to use the default switches as specified
17294 on the command line.
17295
17296 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
17297 versions earlier than 4.4.
17298 @end table
17299
17300 @node Loop-Specific Pragmas
17301 @subsection Loop-Specific Pragmas
17302
17303 @table @code
17304 @item #pragma GCC ivdep
17305 @cindex pragma GCC ivdep
17306 @end table
17307
17308 With this pragma, the programmer asserts that there are no loop-carried
17309 dependencies which would prevent that consecutive iterations of
17310 the following loop can be executed concurrently with SIMD
17311 (single instruction multiple data) instructions.
17312
17313 For example, the compiler can only unconditionally vectorize the following
17314 loop with the pragma:
17315
17316 @smallexample
17317 void foo (int n, int *a, int *b, int *c)
17318 @{
17319 int i, j;
17320 #pragma GCC ivdep
17321 for (i = 0; i < n; ++i)
17322 a[i] = b[i] + c[i];
17323 @}
17324 @end smallexample
17325
17326 @noindent
17327 In this example, using the @code{restrict} qualifier had the same
17328 effect. In the following example, that would not be possible. Assume
17329 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
17330 that it can unconditionally vectorize the following loop:
17331
17332 @smallexample
17333 void ignore_vec_dep (int *a, int k, int c, int m)
17334 @{
17335 #pragma GCC ivdep
17336 for (int i = 0; i < m; i++)
17337 a[i] = a[i + k] * c;
17338 @}
17339 @end smallexample
17340
17341
17342 @node Unnamed Fields
17343 @section Unnamed struct/union fields within structs/unions
17344 @cindex @code{struct}
17345 @cindex @code{union}
17346
17347 As permitted by ISO C11 and for compatibility with other compilers,
17348 GCC allows you to define
17349 a structure or union that contains, as fields, structures and unions
17350 without names. For example:
17351
17352 @smallexample
17353 struct @{
17354 int a;
17355 union @{
17356 int b;
17357 float c;
17358 @};
17359 int d;
17360 @} foo;
17361 @end smallexample
17362
17363 @noindent
17364 In this example, you are able to access members of the unnamed
17365 union with code like @samp{foo.b}. Note that only unnamed structs and
17366 unions are allowed, you may not have, for example, an unnamed
17367 @code{int}.
17368
17369 You must never create such structures that cause ambiguous field definitions.
17370 For example, in this structure:
17371
17372 @smallexample
17373 struct @{
17374 int a;
17375 struct @{
17376 int a;
17377 @};
17378 @} foo;
17379 @end smallexample
17380
17381 @noindent
17382 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
17383 The compiler gives errors for such constructs.
17384
17385 @opindex fms-extensions
17386 Unless @option{-fms-extensions} is used, the unnamed field must be a
17387 structure or union definition without a tag (for example, @samp{struct
17388 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
17389 also be a definition with a tag such as @samp{struct foo @{ int a;
17390 @};}, a reference to a previously defined structure or union such as
17391 @samp{struct foo;}, or a reference to a @code{typedef} name for a
17392 previously defined structure or union type.
17393
17394 @opindex fplan9-extensions
17395 The option @option{-fplan9-extensions} enables
17396 @option{-fms-extensions} as well as two other extensions. First, a
17397 pointer to a structure is automatically converted to a pointer to an
17398 anonymous field for assignments and function calls. For example:
17399
17400 @smallexample
17401 struct s1 @{ int a; @};
17402 struct s2 @{ struct s1; @};
17403 extern void f1 (struct s1 *);
17404 void f2 (struct s2 *p) @{ f1 (p); @}
17405 @end smallexample
17406
17407 @noindent
17408 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
17409 converted into a pointer to the anonymous field.
17410
17411 Second, when the type of an anonymous field is a @code{typedef} for a
17412 @code{struct} or @code{union}, code may refer to the field using the
17413 name of the @code{typedef}.
17414
17415 @smallexample
17416 typedef struct @{ int a; @} s1;
17417 struct s2 @{ s1; @};
17418 s1 f1 (struct s2 *p) @{ return p->s1; @}
17419 @end smallexample
17420
17421 These usages are only permitted when they are not ambiguous.
17422
17423 @node Thread-Local
17424 @section Thread-Local Storage
17425 @cindex Thread-Local Storage
17426 @cindex @acronym{TLS}
17427 @cindex @code{__thread}
17428
17429 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
17430 are allocated such that there is one instance of the variable per extant
17431 thread. The runtime model GCC uses to implement this originates
17432 in the IA-64 processor-specific ABI, but has since been migrated
17433 to other processors as well. It requires significant support from
17434 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
17435 system libraries (@file{libc.so} and @file{libpthread.so}), so it
17436 is not available everywhere.
17437
17438 At the user level, the extension is visible with a new storage
17439 class keyword: @code{__thread}. For example:
17440
17441 @smallexample
17442 __thread int i;
17443 extern __thread struct state s;
17444 static __thread char *p;
17445 @end smallexample
17446
17447 The @code{__thread} specifier may be used alone, with the @code{extern}
17448 or @code{static} specifiers, but with no other storage class specifier.
17449 When used with @code{extern} or @code{static}, @code{__thread} must appear
17450 immediately after the other storage class specifier.
17451
17452 The @code{__thread} specifier may be applied to any global, file-scoped
17453 static, function-scoped static, or static data member of a class. It may
17454 not be applied to block-scoped automatic or non-static data member.
17455
17456 When the address-of operator is applied to a thread-local variable, it is
17457 evaluated at run time and returns the address of the current thread's
17458 instance of that variable. An address so obtained may be used by any
17459 thread. When a thread terminates, any pointers to thread-local variables
17460 in that thread become invalid.
17461
17462 No static initialization may refer to the address of a thread-local variable.
17463
17464 In C++, if an initializer is present for a thread-local variable, it must
17465 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
17466 standard.
17467
17468 See @uref{http://www.akkadia.org/drepper/tls.pdf,
17469 ELF Handling For Thread-Local Storage} for a detailed explanation of
17470 the four thread-local storage addressing models, and how the runtime
17471 is expected to function.
17472
17473 @menu
17474 * C99 Thread-Local Edits::
17475 * C++98 Thread-Local Edits::
17476 @end menu
17477
17478 @node C99 Thread-Local Edits
17479 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
17480
17481 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
17482 that document the exact semantics of the language extension.
17483
17484 @itemize @bullet
17485 @item
17486 @cite{5.1.2 Execution environments}
17487
17488 Add new text after paragraph 1
17489
17490 @quotation
17491 Within either execution environment, a @dfn{thread} is a flow of
17492 control within a program. It is implementation defined whether
17493 or not there may be more than one thread associated with a program.
17494 It is implementation defined how threads beyond the first are
17495 created, the name and type of the function called at thread
17496 startup, and how threads may be terminated. However, objects
17497 with thread storage duration shall be initialized before thread
17498 startup.
17499 @end quotation
17500
17501 @item
17502 @cite{6.2.4 Storage durations of objects}
17503
17504 Add new text before paragraph 3
17505
17506 @quotation
17507 An object whose identifier is declared with the storage-class
17508 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
17509 Its lifetime is the entire execution of the thread, and its
17510 stored value is initialized only once, prior to thread startup.
17511 @end quotation
17512
17513 @item
17514 @cite{6.4.1 Keywords}
17515
17516 Add @code{__thread}.
17517
17518 @item
17519 @cite{6.7.1 Storage-class specifiers}
17520
17521 Add @code{__thread} to the list of storage class specifiers in
17522 paragraph 1.
17523
17524 Change paragraph 2 to
17525
17526 @quotation
17527 With the exception of @code{__thread}, at most one storage-class
17528 specifier may be given [@dots{}]. The @code{__thread} specifier may
17529 be used alone, or immediately following @code{extern} or
17530 @code{static}.
17531 @end quotation
17532
17533 Add new text after paragraph 6
17534
17535 @quotation
17536 The declaration of an identifier for a variable that has
17537 block scope that specifies @code{__thread} shall also
17538 specify either @code{extern} or @code{static}.
17539
17540 The @code{__thread} specifier shall be used only with
17541 variables.
17542 @end quotation
17543 @end itemize
17544
17545 @node C++98 Thread-Local Edits
17546 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
17547
17548 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
17549 that document the exact semantics of the language extension.
17550
17551 @itemize @bullet
17552 @item
17553 @b{[intro.execution]}
17554
17555 New text after paragraph 4
17556
17557 @quotation
17558 A @dfn{thread} is a flow of control within the abstract machine.
17559 It is implementation defined whether or not there may be more than
17560 one thread.
17561 @end quotation
17562
17563 New text after paragraph 7
17564
17565 @quotation
17566 It is unspecified whether additional action must be taken to
17567 ensure when and whether side effects are visible to other threads.
17568 @end quotation
17569
17570 @item
17571 @b{[lex.key]}
17572
17573 Add @code{__thread}.
17574
17575 @item
17576 @b{[basic.start.main]}
17577
17578 Add after paragraph 5
17579
17580 @quotation
17581 The thread that begins execution at the @code{main} function is called
17582 the @dfn{main thread}. It is implementation defined how functions
17583 beginning threads other than the main thread are designated or typed.
17584 A function so designated, as well as the @code{main} function, is called
17585 a @dfn{thread startup function}. It is implementation defined what
17586 happens if a thread startup function returns. It is implementation
17587 defined what happens to other threads when any thread calls @code{exit}.
17588 @end quotation
17589
17590 @item
17591 @b{[basic.start.init]}
17592
17593 Add after paragraph 4
17594
17595 @quotation
17596 The storage for an object of thread storage duration shall be
17597 statically initialized before the first statement of the thread startup
17598 function. An object of thread storage duration shall not require
17599 dynamic initialization.
17600 @end quotation
17601
17602 @item
17603 @b{[basic.start.term]}
17604
17605 Add after paragraph 3
17606
17607 @quotation
17608 The type of an object with thread storage duration shall not have a
17609 non-trivial destructor, nor shall it be an array type whose elements
17610 (directly or indirectly) have non-trivial destructors.
17611 @end quotation
17612
17613 @item
17614 @b{[basic.stc]}
17615
17616 Add ``thread storage duration'' to the list in paragraph 1.
17617
17618 Change paragraph 2
17619
17620 @quotation
17621 Thread, static, and automatic storage durations are associated with
17622 objects introduced by declarations [@dots{}].
17623 @end quotation
17624
17625 Add @code{__thread} to the list of specifiers in paragraph 3.
17626
17627 @item
17628 @b{[basic.stc.thread]}
17629
17630 New section before @b{[basic.stc.static]}
17631
17632 @quotation
17633 The keyword @code{__thread} applied to a non-local object gives the
17634 object thread storage duration.
17635
17636 A local variable or class data member declared both @code{static}
17637 and @code{__thread} gives the variable or member thread storage
17638 duration.
17639 @end quotation
17640
17641 @item
17642 @b{[basic.stc.static]}
17643
17644 Change paragraph 1
17645
17646 @quotation
17647 All objects that have neither thread storage duration, dynamic
17648 storage duration nor are local [@dots{}].
17649 @end quotation
17650
17651 @item
17652 @b{[dcl.stc]}
17653
17654 Add @code{__thread} to the list in paragraph 1.
17655
17656 Change paragraph 1
17657
17658 @quotation
17659 With the exception of @code{__thread}, at most one
17660 @var{storage-class-specifier} shall appear in a given
17661 @var{decl-specifier-seq}. The @code{__thread} specifier may
17662 be used alone, or immediately following the @code{extern} or
17663 @code{static} specifiers. [@dots{}]
17664 @end quotation
17665
17666 Add after paragraph 5
17667
17668 @quotation
17669 The @code{__thread} specifier can be applied only to the names of objects
17670 and to anonymous unions.
17671 @end quotation
17672
17673 @item
17674 @b{[class.mem]}
17675
17676 Add after paragraph 6
17677
17678 @quotation
17679 Non-@code{static} members shall not be @code{__thread}.
17680 @end quotation
17681 @end itemize
17682
17683 @node Binary constants
17684 @section Binary constants using the @samp{0b} prefix
17685 @cindex Binary constants using the @samp{0b} prefix
17686
17687 Integer constants can be written as binary constants, consisting of a
17688 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
17689 @samp{0B}. This is particularly useful in environments that operate a
17690 lot on the bit level (like microcontrollers).
17691
17692 The following statements are identical:
17693
17694 @smallexample
17695 i = 42;
17696 i = 0x2a;
17697 i = 052;
17698 i = 0b101010;
17699 @end smallexample
17700
17701 The type of these constants follows the same rules as for octal or
17702 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
17703 can be applied.
17704
17705 @node C++ Extensions
17706 @chapter Extensions to the C++ Language
17707 @cindex extensions, C++ language
17708 @cindex C++ language extensions
17709
17710 The GNU compiler provides these extensions to the C++ language (and you
17711 can also use most of the C language extensions in your C++ programs). If you
17712 want to write code that checks whether these features are available, you can
17713 test for the GNU compiler the same way as for C programs: check for a
17714 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
17715 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
17716 Predefined Macros,cpp,The GNU C Preprocessor}).
17717
17718 @menu
17719 * C++ Volatiles:: What constitutes an access to a volatile object.
17720 * Restricted Pointers:: C99 restricted pointers and references.
17721 * Vague Linkage:: Where G++ puts inlines, vtables and such.
17722 * C++ Interface:: You can use a single C++ header file for both
17723 declarations and definitions.
17724 * Template Instantiation:: Methods for ensuring that exactly one copy of
17725 each needed template instantiation is emitted.
17726 * Bound member functions:: You can extract a function pointer to the
17727 method denoted by a @samp{->*} or @samp{.*} expression.
17728 * C++ Attributes:: Variable, function, and type attributes for C++ only.
17729 * Function Multiversioning:: Declaring multiple function versions.
17730 * Namespace Association:: Strong using-directives for namespace association.
17731 * Type Traits:: Compiler support for type traits
17732 * Java Exceptions:: Tweaking exception handling to work with Java.
17733 * Deprecated Features:: Things will disappear from G++.
17734 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
17735 @end menu
17736
17737 @node C++ Volatiles
17738 @section When is a Volatile C++ Object Accessed?
17739 @cindex accessing volatiles
17740 @cindex volatile read
17741 @cindex volatile write
17742 @cindex volatile access
17743
17744 The C++ standard differs from the C standard in its treatment of
17745 volatile objects. It fails to specify what constitutes a volatile
17746 access, except to say that C++ should behave in a similar manner to C
17747 with respect to volatiles, where possible. However, the different
17748 lvalueness of expressions between C and C++ complicate the behavior.
17749 G++ behaves the same as GCC for volatile access, @xref{C
17750 Extensions,,Volatiles}, for a description of GCC's behavior.
17751
17752 The C and C++ language specifications differ when an object is
17753 accessed in a void context:
17754
17755 @smallexample
17756 volatile int *src = @var{somevalue};
17757 *src;
17758 @end smallexample
17759
17760 The C++ standard specifies that such expressions do not undergo lvalue
17761 to rvalue conversion, and that the type of the dereferenced object may
17762 be incomplete. The C++ standard does not specify explicitly that it
17763 is lvalue to rvalue conversion that is responsible for causing an
17764 access. There is reason to believe that it is, because otherwise
17765 certain simple expressions become undefined. However, because it
17766 would surprise most programmers, G++ treats dereferencing a pointer to
17767 volatile object of complete type as GCC would do for an equivalent
17768 type in C@. When the object has incomplete type, G++ issues a
17769 warning; if you wish to force an error, you must force a conversion to
17770 rvalue with, for instance, a static cast.
17771
17772 When using a reference to volatile, G++ does not treat equivalent
17773 expressions as accesses to volatiles, but instead issues a warning that
17774 no volatile is accessed. The rationale for this is that otherwise it
17775 becomes difficult to determine where volatile access occur, and not
17776 possible to ignore the return value from functions returning volatile
17777 references. Again, if you wish to force a read, cast the reference to
17778 an rvalue.
17779
17780 G++ implements the same behavior as GCC does when assigning to a
17781 volatile object---there is no reread of the assigned-to object, the
17782 assigned rvalue is reused. Note that in C++ assignment expressions
17783 are lvalues, and if used as an lvalue, the volatile object is
17784 referred to. For instance, @var{vref} refers to @var{vobj}, as
17785 expected, in the following example:
17786
17787 @smallexample
17788 volatile int vobj;
17789 volatile int &vref = vobj = @var{something};
17790 @end smallexample
17791
17792 @node Restricted Pointers
17793 @section Restricting Pointer Aliasing
17794 @cindex restricted pointers
17795 @cindex restricted references
17796 @cindex restricted this pointer
17797
17798 As with the C front end, G++ understands the C99 feature of restricted pointers,
17799 specified with the @code{__restrict__}, or @code{__restrict} type
17800 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
17801 language flag, @code{restrict} is not a keyword in C++.
17802
17803 In addition to allowing restricted pointers, you can specify restricted
17804 references, which indicate that the reference is not aliased in the local
17805 context.
17806
17807 @smallexample
17808 void fn (int *__restrict__ rptr, int &__restrict__ rref)
17809 @{
17810 /* @r{@dots{}} */
17811 @}
17812 @end smallexample
17813
17814 @noindent
17815 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
17816 @var{rref} refers to a (different) unaliased integer.
17817
17818 You may also specify whether a member function's @var{this} pointer is
17819 unaliased by using @code{__restrict__} as a member function qualifier.
17820
17821 @smallexample
17822 void T::fn () __restrict__
17823 @{
17824 /* @r{@dots{}} */
17825 @}
17826 @end smallexample
17827
17828 @noindent
17829 Within the body of @code{T::fn}, @var{this} has the effective
17830 definition @code{T *__restrict__ const this}. Notice that the
17831 interpretation of a @code{__restrict__} member function qualifier is
17832 different to that of @code{const} or @code{volatile} qualifier, in that it
17833 is applied to the pointer rather than the object. This is consistent with
17834 other compilers that implement restricted pointers.
17835
17836 As with all outermost parameter qualifiers, @code{__restrict__} is
17837 ignored in function definition matching. This means you only need to
17838 specify @code{__restrict__} in a function definition, rather than
17839 in a function prototype as well.
17840
17841 @node Vague Linkage
17842 @section Vague Linkage
17843 @cindex vague linkage
17844
17845 There are several constructs in C++ that require space in the object
17846 file but are not clearly tied to a single translation unit. We say that
17847 these constructs have ``vague linkage''. Typically such constructs are
17848 emitted wherever they are needed, though sometimes we can be more
17849 clever.
17850
17851 @table @asis
17852 @item Inline Functions
17853 Inline functions are typically defined in a header file which can be
17854 included in many different compilations. Hopefully they can usually be
17855 inlined, but sometimes an out-of-line copy is necessary, if the address
17856 of the function is taken or if inlining fails. In general, we emit an
17857 out-of-line copy in all translation units where one is needed. As an
17858 exception, we only emit inline virtual functions with the vtable, since
17859 it always requires a copy.
17860
17861 Local static variables and string constants used in an inline function
17862 are also considered to have vague linkage, since they must be shared
17863 between all inlined and out-of-line instances of the function.
17864
17865 @item VTables
17866 @cindex vtable
17867 C++ virtual functions are implemented in most compilers using a lookup
17868 table, known as a vtable. The vtable contains pointers to the virtual
17869 functions provided by a class, and each object of the class contains a
17870 pointer to its vtable (or vtables, in some multiple-inheritance
17871 situations). If the class declares any non-inline, non-pure virtual
17872 functions, the first one is chosen as the ``key method'' for the class,
17873 and the vtable is only emitted in the translation unit where the key
17874 method is defined.
17875
17876 @emph{Note:} If the chosen key method is later defined as inline, the
17877 vtable is still emitted in every translation unit that defines it.
17878 Make sure that any inline virtuals are declared inline in the class
17879 body, even if they are not defined there.
17880
17881 @item @code{type_info} objects
17882 @cindex @code{type_info}
17883 @cindex RTTI
17884 C++ requires information about types to be written out in order to
17885 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
17886 For polymorphic classes (classes with virtual functions), the @samp{type_info}
17887 object is written out along with the vtable so that @samp{dynamic_cast}
17888 can determine the dynamic type of a class object at run time. For all
17889 other types, we write out the @samp{type_info} object when it is used: when
17890 applying @samp{typeid} to an expression, throwing an object, or
17891 referring to a type in a catch clause or exception specification.
17892
17893 @item Template Instantiations
17894 Most everything in this section also applies to template instantiations,
17895 but there are other options as well.
17896 @xref{Template Instantiation,,Where's the Template?}.
17897
17898 @end table
17899
17900 When used with GNU ld version 2.8 or later on an ELF system such as
17901 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
17902 these constructs will be discarded at link time. This is known as
17903 COMDAT support.
17904
17905 On targets that don't support COMDAT, but do support weak symbols, GCC
17906 uses them. This way one copy overrides all the others, but
17907 the unused copies still take up space in the executable.
17908
17909 For targets that do not support either COMDAT or weak symbols,
17910 most entities with vague linkage are emitted as local symbols to
17911 avoid duplicate definition errors from the linker. This does not happen
17912 for local statics in inlines, however, as having multiple copies
17913 almost certainly breaks things.
17914
17915 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
17916 another way to control placement of these constructs.
17917
17918 @node C++ Interface
17919 @section #pragma interface and implementation
17920
17921 @cindex interface and implementation headers, C++
17922 @cindex C++ interface and implementation headers
17923 @cindex pragmas, interface and implementation
17924
17925 @code{#pragma interface} and @code{#pragma implementation} provide the
17926 user with a way of explicitly directing the compiler to emit entities
17927 with vague linkage (and debugging information) in a particular
17928 translation unit.
17929
17930 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
17931 most cases, because of COMDAT support and the ``key method'' heuristic
17932 mentioned in @ref{Vague Linkage}. Using them can actually cause your
17933 program to grow due to unnecessary out-of-line copies of inline
17934 functions. Currently (3.4) the only benefit of these
17935 @code{#pragma}s is reduced duplication of debugging information, and
17936 that should be addressed soon on DWARF 2 targets with the use of
17937 COMDAT groups.
17938
17939 @table @code
17940 @item #pragma interface
17941 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
17942 @kindex #pragma interface
17943 Use this directive in @emph{header files} that define object classes, to save
17944 space in most of the object files that use those classes. Normally,
17945 local copies of certain information (backup copies of inline member
17946 functions, debugging information, and the internal tables that implement
17947 virtual functions) must be kept in each object file that includes class
17948 definitions. You can use this pragma to avoid such duplication. When a
17949 header file containing @samp{#pragma interface} is included in a
17950 compilation, this auxiliary information is not generated (unless
17951 the main input source file itself uses @samp{#pragma implementation}).
17952 Instead, the object files contain references to be resolved at link
17953 time.
17954
17955 The second form of this directive is useful for the case where you have
17956 multiple headers with the same name in different directories. If you
17957 use this form, you must specify the same string to @samp{#pragma
17958 implementation}.
17959
17960 @item #pragma implementation
17961 @itemx #pragma implementation "@var{objects}.h"
17962 @kindex #pragma implementation
17963 Use this pragma in a @emph{main input file}, when you want full output from
17964 included header files to be generated (and made globally visible). The
17965 included header file, in turn, should use @samp{#pragma interface}.
17966 Backup copies of inline member functions, debugging information, and the
17967 internal tables used to implement virtual functions are all generated in
17968 implementation files.
17969
17970 @cindex implied @code{#pragma implementation}
17971 @cindex @code{#pragma implementation}, implied
17972 @cindex naming convention, implementation headers
17973 If you use @samp{#pragma implementation} with no argument, it applies to
17974 an include file with the same basename@footnote{A file's @dfn{basename}
17975 is the name stripped of all leading path information and of trailing
17976 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
17977 file. For example, in @file{allclass.cc}, giving just
17978 @samp{#pragma implementation}
17979 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
17980
17981 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
17982 an implementation file whenever you would include it from
17983 @file{allclass.cc} even if you never specified @samp{#pragma
17984 implementation}. This was deemed to be more trouble than it was worth,
17985 however, and disabled.
17986
17987 Use the string argument if you want a single implementation file to
17988 include code from multiple header files. (You must also use
17989 @samp{#include} to include the header file; @samp{#pragma
17990 implementation} only specifies how to use the file---it doesn't actually
17991 include it.)
17992
17993 There is no way to split up the contents of a single header file into
17994 multiple implementation files.
17995 @end table
17996
17997 @cindex inlining and C++ pragmas
17998 @cindex C++ pragmas, effect on inlining
17999 @cindex pragmas in C++, effect on inlining
18000 @samp{#pragma implementation} and @samp{#pragma interface} also have an
18001 effect on function inlining.
18002
18003 If you define a class in a header file marked with @samp{#pragma
18004 interface}, the effect on an inline function defined in that class is
18005 similar to an explicit @code{extern} declaration---the compiler emits
18006 no code at all to define an independent version of the function. Its
18007 definition is used only for inlining with its callers.
18008
18009 @opindex fno-implement-inlines
18010 Conversely, when you include the same header file in a main source file
18011 that declares it as @samp{#pragma implementation}, the compiler emits
18012 code for the function itself; this defines a version of the function
18013 that can be found via pointers (or by callers compiled without
18014 inlining). If all calls to the function can be inlined, you can avoid
18015 emitting the function by compiling with @option{-fno-implement-inlines}.
18016 If any calls are not inlined, you will get linker errors.
18017
18018 @node Template Instantiation
18019 @section Where's the Template?
18020 @cindex template instantiation
18021
18022 C++ templates are the first language feature to require more
18023 intelligence from the environment than one usually finds on a UNIX
18024 system. Somehow the compiler and linker have to make sure that each
18025 template instance occurs exactly once in the executable if it is needed,
18026 and not at all otherwise. There are two basic approaches to this
18027 problem, which are referred to as the Borland model and the Cfront model.
18028
18029 @table @asis
18030 @item Borland model
18031 Borland C++ solved the template instantiation problem by adding the code
18032 equivalent of common blocks to their linker; the compiler emits template
18033 instances in each translation unit that uses them, and the linker
18034 collapses them together. The advantage of this model is that the linker
18035 only has to consider the object files themselves; there is no external
18036 complexity to worry about. This disadvantage is that compilation time
18037 is increased because the template code is being compiled repeatedly.
18038 Code written for this model tends to include definitions of all
18039 templates in the header file, since they must be seen to be
18040 instantiated.
18041
18042 @item Cfront model
18043 The AT&T C++ translator, Cfront, solved the template instantiation
18044 problem by creating the notion of a template repository, an
18045 automatically maintained place where template instances are stored. A
18046 more modern version of the repository works as follows: As individual
18047 object files are built, the compiler places any template definitions and
18048 instantiations encountered in the repository. At link time, the link
18049 wrapper adds in the objects in the repository and compiles any needed
18050 instances that were not previously emitted. The advantages of this
18051 model are more optimal compilation speed and the ability to use the
18052 system linker; to implement the Borland model a compiler vendor also
18053 needs to replace the linker. The disadvantages are vastly increased
18054 complexity, and thus potential for error; for some code this can be
18055 just as transparent, but in practice it can been very difficult to build
18056 multiple programs in one directory and one program in multiple
18057 directories. Code written for this model tends to separate definitions
18058 of non-inline member templates into a separate file, which should be
18059 compiled separately.
18060 @end table
18061
18062 When used with GNU ld version 2.8 or later on an ELF system such as
18063 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
18064 Borland model. On other systems, G++ implements neither automatic
18065 model.
18066
18067 You have the following options for dealing with template instantiations:
18068
18069 @enumerate
18070 @item
18071 @opindex frepo
18072 Compile your template-using code with @option{-frepo}. The compiler
18073 generates files with the extension @samp{.rpo} listing all of the
18074 template instantiations used in the corresponding object files that
18075 could be instantiated there; the link wrapper, @samp{collect2},
18076 then updates the @samp{.rpo} files to tell the compiler where to place
18077 those instantiations and rebuild any affected object files. The
18078 link-time overhead is negligible after the first pass, as the compiler
18079 continues to place the instantiations in the same files.
18080
18081 This is your best option for application code written for the Borland
18082 model, as it just works. Code written for the Cfront model
18083 needs to be modified so that the template definitions are available at
18084 one or more points of instantiation; usually this is as simple as adding
18085 @code{#include <tmethods.cc>} to the end of each template header.
18086
18087 For library code, if you want the library to provide all of the template
18088 instantiations it needs, just try to link all of its object files
18089 together; the link will fail, but cause the instantiations to be
18090 generated as a side effect. Be warned, however, that this may cause
18091 conflicts if multiple libraries try to provide the same instantiations.
18092 For greater control, use explicit instantiation as described in the next
18093 option.
18094
18095 @item
18096 @opindex fno-implicit-templates
18097 Compile your code with @option{-fno-implicit-templates} to disable the
18098 implicit generation of template instances, and explicitly instantiate
18099 all the ones you use. This approach requires more knowledge of exactly
18100 which instances you need than do the others, but it's less
18101 mysterious and allows greater control. You can scatter the explicit
18102 instantiations throughout your program, perhaps putting them in the
18103 translation units where the instances are used or the translation units
18104 that define the templates themselves; you can put all of the explicit
18105 instantiations you need into one big file; or you can create small files
18106 like
18107
18108 @smallexample
18109 #include "Foo.h"
18110 #include "Foo.cc"
18111
18112 template class Foo<int>;
18113 template ostream& operator <<
18114 (ostream&, const Foo<int>&);
18115 @end smallexample
18116
18117 @noindent
18118 for each of the instances you need, and create a template instantiation
18119 library from those.
18120
18121 If you are using Cfront-model code, you can probably get away with not
18122 using @option{-fno-implicit-templates} when compiling files that don't
18123 @samp{#include} the member template definitions.
18124
18125 If you use one big file to do the instantiations, you may want to
18126 compile it without @option{-fno-implicit-templates} so you get all of the
18127 instances required by your explicit instantiations (but not by any
18128 other files) without having to specify them as well.
18129
18130 The ISO C++ 2011 standard allows forward declaration of explicit
18131 instantiations (with @code{extern}). G++ supports explicit instantiation
18132 declarations in C++98 mode and has extended the template instantiation
18133 syntax to support instantiation of the compiler support data for a
18134 template class (i.e.@: the vtable) without instantiating any of its
18135 members (with @code{inline}), and instantiation of only the static data
18136 members of a template class, without the support data or member
18137 functions (with (@code{static}):
18138
18139 @smallexample
18140 extern template int max (int, int);
18141 inline template class Foo<int>;
18142 static template class Foo<int>;
18143 @end smallexample
18144
18145 @item
18146 Do nothing. Pretend G++ does implement automatic instantiation
18147 management. Code written for the Borland model works fine, but
18148 each translation unit contains instances of each of the templates it
18149 uses. In a large program, this can lead to an unacceptable amount of code
18150 duplication.
18151 @end enumerate
18152
18153 @node Bound member functions
18154 @section Extracting the function pointer from a bound pointer to member function
18155 @cindex pmf
18156 @cindex pointer to member function
18157 @cindex bound pointer to member function
18158
18159 In C++, pointer to member functions (PMFs) are implemented using a wide
18160 pointer of sorts to handle all the possible call mechanisms; the PMF
18161 needs to store information about how to adjust the @samp{this} pointer,
18162 and if the function pointed to is virtual, where to find the vtable, and
18163 where in the vtable to look for the member function. If you are using
18164 PMFs in an inner loop, you should really reconsider that decision. If
18165 that is not an option, you can extract the pointer to the function that
18166 would be called for a given object/PMF pair and call it directly inside
18167 the inner loop, to save a bit of time.
18168
18169 Note that you still pay the penalty for the call through a
18170 function pointer; on most modern architectures, such a call defeats the
18171 branch prediction features of the CPU@. This is also true of normal
18172 virtual function calls.
18173
18174 The syntax for this extension is
18175
18176 @smallexample
18177 extern A a;
18178 extern int (A::*fp)();
18179 typedef int (*fptr)(A *);
18180
18181 fptr p = (fptr)(a.*fp);
18182 @end smallexample
18183
18184 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
18185 no object is needed to obtain the address of the function. They can be
18186 converted to function pointers directly:
18187
18188 @smallexample
18189 fptr p1 = (fptr)(&A::foo);
18190 @end smallexample
18191
18192 @opindex Wno-pmf-conversions
18193 You must specify @option{-Wno-pmf-conversions} to use this extension.
18194
18195 @node C++ Attributes
18196 @section C++-Specific Variable, Function, and Type Attributes
18197
18198 Some attributes only make sense for C++ programs.
18199
18200 @table @code
18201 @item abi_tag ("@var{tag}", ...)
18202 @cindex @code{abi_tag} attribute
18203 The @code{abi_tag} attribute can be applied to a function or class
18204 declaration. It modifies the mangled name of the function or class to
18205 incorporate the tag name, in order to distinguish the function or
18206 class from an earlier version with a different ABI; perhaps the class
18207 has changed size, or the function has a different return type that is
18208 not encoded in the mangled name.
18209
18210 The argument can be a list of strings of arbitrary length. The
18211 strings are sorted on output, so the order of the list is
18212 unimportant.
18213
18214 A redeclaration of a function or class must not add new ABI tags,
18215 since doing so would change the mangled name.
18216
18217 The ABI tags apply to a name, so all instantiations and
18218 specializations of a template have the same tags. The attribute will
18219 be ignored if applied to an explicit specialization or instantiation.
18220
18221 The @option{-Wabi-tag} flag enables a warning about a class which does
18222 not have all the ABI tags used by its subobjects and virtual functions; for users with code
18223 that needs to coexist with an earlier ABI, using this option can help
18224 to find all affected types that need to be tagged.
18225
18226 @item init_priority (@var{priority})
18227 @cindex @code{init_priority} attribute
18228
18229
18230 In Standard C++, objects defined at namespace scope are guaranteed to be
18231 initialized in an order in strict accordance with that of their definitions
18232 @emph{in a given translation unit}. No guarantee is made for initializations
18233 across translation units. However, GNU C++ allows users to control the
18234 order of initialization of objects defined at namespace scope with the
18235 @code{init_priority} attribute by specifying a relative @var{priority},
18236 a constant integral expression currently bounded between 101 and 65535
18237 inclusive. Lower numbers indicate a higher priority.
18238
18239 In the following example, @code{A} would normally be created before
18240 @code{B}, but the @code{init_priority} attribute reverses that order:
18241
18242 @smallexample
18243 Some_Class A __attribute__ ((init_priority (2000)));
18244 Some_Class B __attribute__ ((init_priority (543)));
18245 @end smallexample
18246
18247 @noindent
18248 Note that the particular values of @var{priority} do not matter; only their
18249 relative ordering.
18250
18251 @item java_interface
18252 @cindex @code{java_interface} attribute
18253
18254 This type attribute informs C++ that the class is a Java interface. It may
18255 only be applied to classes declared within an @code{extern "Java"} block.
18256 Calls to methods declared in this interface are dispatched using GCJ's
18257 interface table mechanism, instead of regular virtual table dispatch.
18258
18259 @item warn_unused
18260 @cindex @code{warn_unused} attribute
18261
18262 For C++ types with non-trivial constructors and/or destructors it is
18263 impossible for the compiler to determine whether a variable of this
18264 type is truly unused if it is not referenced. This type attribute
18265 informs the compiler that variables of this type should be warned
18266 about if they appear to be unused, just like variables of fundamental
18267 types.
18268
18269 This attribute is appropriate for types which just represent a value,
18270 such as @code{std::string}; it is not appropriate for types which
18271 control a resource, such as @code{std::mutex}.
18272
18273 This attribute is also accepted in C, but it is unnecessary because C
18274 does not have constructors or destructors.
18275
18276 @end table
18277
18278 See also @ref{Namespace Association}.
18279
18280 @node Function Multiversioning
18281 @section Function Multiversioning
18282 @cindex function versions
18283
18284 With the GNU C++ front end, for target i386, you may specify multiple
18285 versions of a function, where each function is specialized for a
18286 specific target feature. At runtime, the appropriate version of the
18287 function is automatically executed depending on the characteristics of
18288 the execution platform. Here is an example.
18289
18290 @smallexample
18291 __attribute__ ((target ("default")))
18292 int foo ()
18293 @{
18294 // The default version of foo.
18295 return 0;
18296 @}
18297
18298 __attribute__ ((target ("sse4.2")))
18299 int foo ()
18300 @{
18301 // foo version for SSE4.2
18302 return 1;
18303 @}
18304
18305 __attribute__ ((target ("arch=atom")))
18306 int foo ()
18307 @{
18308 // foo version for the Intel ATOM processor
18309 return 2;
18310 @}
18311
18312 __attribute__ ((target ("arch=amdfam10")))
18313 int foo ()
18314 @{
18315 // foo version for the AMD Family 0x10 processors.
18316 return 3;
18317 @}
18318
18319 int main ()
18320 @{
18321 int (*p)() = &foo;
18322 assert ((*p) () == foo ());
18323 return 0;
18324 @}
18325 @end smallexample
18326
18327 In the above example, four versions of function foo are created. The
18328 first version of foo with the target attribute "default" is the default
18329 version. This version gets executed when no other target specific
18330 version qualifies for execution on a particular platform. A new version
18331 of foo is created by using the same function signature but with a
18332 different target string. Function foo is called or a pointer to it is
18333 taken just like a regular function. GCC takes care of doing the
18334 dispatching to call the right version at runtime. Refer to the
18335 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
18336 Function Multiversioning} for more details.
18337
18338 @node Namespace Association
18339 @section Namespace Association
18340
18341 @strong{Caution:} The semantics of this extension are equivalent
18342 to C++ 2011 inline namespaces. Users should use inline namespaces
18343 instead as this extension will be removed in future versions of G++.
18344
18345 A using-directive with @code{__attribute ((strong))} is stronger
18346 than a normal using-directive in two ways:
18347
18348 @itemize @bullet
18349 @item
18350 Templates from the used namespace can be specialized and explicitly
18351 instantiated as though they were members of the using namespace.
18352
18353 @item
18354 The using namespace is considered an associated namespace of all
18355 templates in the used namespace for purposes of argument-dependent
18356 name lookup.
18357 @end itemize
18358
18359 The used namespace must be nested within the using namespace so that
18360 normal unqualified lookup works properly.
18361
18362 This is useful for composing a namespace transparently from
18363 implementation namespaces. For example:
18364
18365 @smallexample
18366 namespace std @{
18367 namespace debug @{
18368 template <class T> struct A @{ @};
18369 @}
18370 using namespace debug __attribute ((__strong__));
18371 template <> struct A<int> @{ @}; // @r{OK to specialize}
18372
18373 template <class T> void f (A<T>);
18374 @}
18375
18376 int main()
18377 @{
18378 f (std::A<float>()); // @r{lookup finds} std::f
18379 f (std::A<int>());
18380 @}
18381 @end smallexample
18382
18383 @node Type Traits
18384 @section Type Traits
18385
18386 The C++ front end implements syntactic extensions that allow
18387 compile-time determination of
18388 various characteristics of a type (or of a
18389 pair of types).
18390
18391 @table @code
18392 @item __has_nothrow_assign (type)
18393 If @code{type} is const qualified or is a reference type then the trait is
18394 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
18395 is true, else if @code{type} is a cv class or union type with copy assignment
18396 operators that are known not to throw an exception then the trait is true,
18397 else it is false. Requires: @code{type} shall be a complete type,
18398 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18399
18400 @item __has_nothrow_copy (type)
18401 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
18402 @code{type} is a cv class or union type with copy constructors that
18403 are known not to throw an exception then the trait is true, else it is false.
18404 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
18405 @code{void}, or an array of unknown bound.
18406
18407 @item __has_nothrow_constructor (type)
18408 If @code{__has_trivial_constructor (type)} is true then the trait is
18409 true, else if @code{type} is a cv class or union type (or array
18410 thereof) with a default constructor that is known not to throw an
18411 exception then the trait is true, else it is false. Requires:
18412 @code{type} shall be a complete type, (possibly cv-qualified)
18413 @code{void}, or an array of unknown bound.
18414
18415 @item __has_trivial_assign (type)
18416 If @code{type} is const qualified or is a reference type then the trait is
18417 false. Otherwise if @code{__is_pod (type)} is true then the trait is
18418 true, else if @code{type} is a cv class or union type with a trivial
18419 copy assignment ([class.copy]) then the trait is true, else it is
18420 false. Requires: @code{type} shall be a complete type, (possibly
18421 cv-qualified) @code{void}, or an array of unknown bound.
18422
18423 @item __has_trivial_copy (type)
18424 If @code{__is_pod (type)} is true or @code{type} is a reference type
18425 then the trait is true, else if @code{type} is a cv class or union type
18426 with a trivial copy constructor ([class.copy]) then the trait
18427 is true, else it is false. Requires: @code{type} shall be a complete
18428 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18429
18430 @item __has_trivial_constructor (type)
18431 If @code{__is_pod (type)} is true then the trait is true, else if
18432 @code{type} is a cv class or union type (or array thereof) with a
18433 trivial default constructor ([class.ctor]) then the trait is true,
18434 else it is false. Requires: @code{type} shall be a complete
18435 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18436
18437 @item __has_trivial_destructor (type)
18438 If @code{__is_pod (type)} is true or @code{type} is a reference type then
18439 the trait is true, else if @code{type} is a cv class or union type (or
18440 array thereof) with a trivial destructor ([class.dtor]) then the trait
18441 is true, else it is false. Requires: @code{type} shall be a complete
18442 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18443
18444 @item __has_virtual_destructor (type)
18445 If @code{type} is a class type with a virtual destructor
18446 ([class.dtor]) then the trait is true, else it is false. Requires:
18447 @code{type} shall be a complete type, (possibly cv-qualified)
18448 @code{void}, or an array of unknown bound.
18449
18450 @item __is_abstract (type)
18451 If @code{type} is an abstract class ([class.abstract]) then the trait
18452 is true, else it is false. Requires: @code{type} shall be a complete
18453 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18454
18455 @item __is_base_of (base_type, derived_type)
18456 If @code{base_type} is a base class of @code{derived_type}
18457 ([class.derived]) then the trait is true, otherwise it is false.
18458 Top-level cv qualifications of @code{base_type} and
18459 @code{derived_type} are ignored. For the purposes of this trait, a
18460 class type is considered is own base. Requires: if @code{__is_class
18461 (base_type)} and @code{__is_class (derived_type)} are true and
18462 @code{base_type} and @code{derived_type} are not the same type
18463 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
18464 type. Diagnostic is produced if this requirement is not met.
18465
18466 @item __is_class (type)
18467 If @code{type} is a cv class type, and not a union type
18468 ([basic.compound]) the trait is true, else it is false.
18469
18470 @item __is_empty (type)
18471 If @code{__is_class (type)} is false then the trait is false.
18472 Otherwise @code{type} is considered empty if and only if: @code{type}
18473 has no non-static data members, or all non-static data members, if
18474 any, are bit-fields of length 0, and @code{type} has no virtual
18475 members, and @code{type} has no virtual base classes, and @code{type}
18476 has no base classes @code{base_type} for which
18477 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
18478 be a complete type, (possibly cv-qualified) @code{void}, or an array
18479 of unknown bound.
18480
18481 @item __is_enum (type)
18482 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
18483 true, else it is false.
18484
18485 @item __is_literal_type (type)
18486 If @code{type} is a literal type ([basic.types]) the trait is
18487 true, else it is false. Requires: @code{type} shall be a complete type,
18488 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18489
18490 @item __is_pod (type)
18491 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
18492 else it is false. Requires: @code{type} shall be a complete type,
18493 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18494
18495 @item __is_polymorphic (type)
18496 If @code{type} is a polymorphic class ([class.virtual]) then the trait
18497 is true, else it is false. Requires: @code{type} shall be a complete
18498 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18499
18500 @item __is_standard_layout (type)
18501 If @code{type} is a standard-layout type ([basic.types]) the trait is
18502 true, else it is false. Requires: @code{type} shall be a complete
18503 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18504
18505 @item __is_trivial (type)
18506 If @code{type} is a trivial type ([basic.types]) the trait is
18507 true, else it is false. Requires: @code{type} shall be a complete
18508 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18509
18510 @item __is_union (type)
18511 If @code{type} is a cv union type ([basic.compound]) the trait is
18512 true, else it is false.
18513
18514 @item __underlying_type (type)
18515 The underlying type of @code{type}. Requires: @code{type} shall be
18516 an enumeration type ([dcl.enum]).
18517
18518 @end table
18519
18520 @node Java Exceptions
18521 @section Java Exceptions
18522
18523 The Java language uses a slightly different exception handling model
18524 from C++. Normally, GNU C++ automatically detects when you are
18525 writing C++ code that uses Java exceptions, and handle them
18526 appropriately. However, if C++ code only needs to execute destructors
18527 when Java exceptions are thrown through it, GCC guesses incorrectly.
18528 Sample problematic code is:
18529
18530 @smallexample
18531 struct S @{ ~S(); @};
18532 extern void bar(); // @r{is written in Java, and may throw exceptions}
18533 void foo()
18534 @{
18535 S s;
18536 bar();
18537 @}
18538 @end smallexample
18539
18540 @noindent
18541 The usual effect of an incorrect guess is a link failure, complaining of
18542 a missing routine called @samp{__gxx_personality_v0}.
18543
18544 You can inform the compiler that Java exceptions are to be used in a
18545 translation unit, irrespective of what it might think, by writing
18546 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
18547 @samp{#pragma} must appear before any functions that throw or catch
18548 exceptions, or run destructors when exceptions are thrown through them.
18549
18550 You cannot mix Java and C++ exceptions in the same translation unit. It
18551 is believed to be safe to throw a C++ exception from one file through
18552 another file compiled for the Java exception model, or vice versa, but
18553 there may be bugs in this area.
18554
18555 @node Deprecated Features
18556 @section Deprecated Features
18557
18558 In the past, the GNU C++ compiler was extended to experiment with new
18559 features, at a time when the C++ language was still evolving. Now that
18560 the C++ standard is complete, some of those features are superseded by
18561 superior alternatives. Using the old features might cause a warning in
18562 some cases that the feature will be dropped in the future. In other
18563 cases, the feature might be gone already.
18564
18565 While the list below is not exhaustive, it documents some of the options
18566 that are now deprecated:
18567
18568 @table @code
18569 @item -fexternal-templates
18570 @itemx -falt-external-templates
18571 These are two of the many ways for G++ to implement template
18572 instantiation. @xref{Template Instantiation}. The C++ standard clearly
18573 defines how template definitions have to be organized across
18574 implementation units. G++ has an implicit instantiation mechanism that
18575 should work just fine for standard-conforming code.
18576
18577 @item -fstrict-prototype
18578 @itemx -fno-strict-prototype
18579 Previously it was possible to use an empty prototype parameter list to
18580 indicate an unspecified number of parameters (like C), rather than no
18581 parameters, as C++ demands. This feature has been removed, except where
18582 it is required for backwards compatibility. @xref{Backwards Compatibility}.
18583 @end table
18584
18585 G++ allows a virtual function returning @samp{void *} to be overridden
18586 by one returning a different pointer type. This extension to the
18587 covariant return type rules is now deprecated and will be removed from a
18588 future version.
18589
18590 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
18591 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
18592 and are now removed from G++. Code using these operators should be
18593 modified to use @code{std::min} and @code{std::max} instead.
18594
18595 The named return value extension has been deprecated, and is now
18596 removed from G++.
18597
18598 The use of initializer lists with new expressions has been deprecated,
18599 and is now removed from G++.
18600
18601 Floating and complex non-type template parameters have been deprecated,
18602 and are now removed from G++.
18603
18604 The implicit typename extension has been deprecated and is now
18605 removed from G++.
18606
18607 The use of default arguments in function pointers, function typedefs
18608 and other places where they are not permitted by the standard is
18609 deprecated and will be removed from a future version of G++.
18610
18611 G++ allows floating-point literals to appear in integral constant expressions,
18612 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
18613 This extension is deprecated and will be removed from a future version.
18614
18615 G++ allows static data members of const floating-point type to be declared
18616 with an initializer in a class definition. The standard only allows
18617 initializers for static members of const integral types and const
18618 enumeration types so this extension has been deprecated and will be removed
18619 from a future version.
18620
18621 @node Backwards Compatibility
18622 @section Backwards Compatibility
18623 @cindex Backwards Compatibility
18624 @cindex ARM [Annotated C++ Reference Manual]
18625
18626 Now that there is a definitive ISO standard C++, G++ has a specification
18627 to adhere to. The C++ language evolved over time, and features that
18628 used to be acceptable in previous drafts of the standard, such as the ARM
18629 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
18630 compilation of C++ written to such drafts, G++ contains some backwards
18631 compatibilities. @emph{All such backwards compatibility features are
18632 liable to disappear in future versions of G++.} They should be considered
18633 deprecated. @xref{Deprecated Features}.
18634
18635 @table @code
18636 @item For scope
18637 If a variable is declared at for scope, it used to remain in scope until
18638 the end of the scope that contained the for statement (rather than just
18639 within the for scope). G++ retains this, but issues a warning, if such a
18640 variable is accessed outside the for scope.
18641
18642 @item Implicit C language
18643 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
18644 scope to set the language. On such systems, all header files are
18645 implicitly scoped inside a C language scope. Also, an empty prototype
18646 @code{()} is treated as an unspecified number of arguments, rather
18647 than no arguments, as C++ demands.
18648 @end table
18649
18650 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
18651 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr followign