1@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1996, 1998, 1999, 2000, 2001, 2@c 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 3@c Free Software Foundation, Inc. 4 5@c This is part of the GCC manual. 6@c For copying conditions, see the file gcc.texi. 7 8@node C Extensions 9@chapter Extensions to the C Language Family 10@cindex extensions, C language 11@cindex C language extensions 12 13@opindex pedantic 14GNU C provides several language features not found in ISO standard C@. 15(The @option{-pedantic} option directs GCC to print a warning message if 16any of these features is used.) To test for the availability of these 17features in conditional compilation, check for a predefined macro 18@code{__GNUC__}, which is always defined under GCC@. 19 20These extensions are available in C and Objective-C@. Most of them are 21also available in C++. @xref{C++ Extensions,,Extensions to the 22C++ Language}, for extensions that apply @emph{only} to C++. 23 24Some features that are in ISO C99 but not C90 or C++ are also, as 25extensions, accepted by GCC in C90 mode and in C++. 26 27@menu 28* Statement Exprs:: Putting statements and declarations inside expressions. 29* Local Labels:: Labels local to a block. 30* Labels as Values:: Getting pointers to labels, and computed gotos. 31* Nested Functions:: As in Algol and Pascal, lexical scoping of functions. 32* Constructing Calls:: Dispatching a call to another function. 33* Typeof:: @code{typeof}: referring to the type of an expression. 34* Conditionals:: Omitting the middle operand of a @samp{?:} expression. 35* Long Long:: Double-word integers---@code{long long int}. 36* __int128:: 128-bit integers---@code{__int128}. 37* Complex:: Data types for complex numbers. 38* Floating Types:: Additional Floating Types. 39* Half-Precision:: Half-Precision Floating Point. 40* Decimal Float:: Decimal Floating Types. 41* Hex Floats:: Hexadecimal floating-point constants. 42* Fixed-Point:: Fixed-Point Types. 43* Named Address Spaces::Named address spaces. 44* Zero Length:: Zero-length arrays. 45* Variable Length:: Arrays whose length is computed at run time. 46* Empty Structures:: Structures with no members. 47* Variadic Macros:: Macros with a variable number of arguments. 48* Escaped Newlines:: Slightly looser rules for escaped newlines. 49* Subscripting:: Any array can be subscripted, even if not an lvalue. 50* Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers. 51* Initializers:: Non-constant initializers. 52* Compound Literals:: Compound literals give structures, unions 53 or arrays as values. 54* Designated Inits:: Labeling elements of initializers. 55* Cast to Union:: Casting to union type from any member of the union. 56* Case Ranges:: `case 1 ... 9' and such. 57* Mixed Declarations:: Mixing declarations and code. 58* Function Attributes:: Declaring that functions have no side effects, 59 or that they can never return. 60* Attribute Syntax:: Formal syntax for attributes. 61* Function Prototypes:: Prototype declarations and old-style definitions. 62* C++ Comments:: C++ comments are recognized. 63* Dollar Signs:: Dollar sign is allowed in identifiers. 64* Character Escapes:: @samp{\e} stands for the character @key{ESC}. 65* Variable Attributes:: Specifying attributes of variables. 66* Type Attributes:: Specifying attributes of types. 67* Alignment:: Inquiring about the alignment of a type or variable. 68* Inline:: Defining inline functions (as fast as macros). 69* Volatiles:: What constitutes an access to a volatile object. 70* Extended Asm:: Assembler instructions with C expressions as operands. 71 (With them you can define ``built-in'' functions.) 72* Constraints:: Constraints for asm operands 73* Asm Labels:: Specifying the assembler name to use for a C symbol. 74* Explicit Reg Vars:: Defining variables residing in specified registers. 75* Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files. 76* Incomplete Enums:: @code{enum foo;}, with details to follow. 77* Function Names:: Printable strings which are the name of the current 78 function. 79* Return Address:: Getting the return or frame address of a function. 80* Vector Extensions:: Using vector instructions through built-in functions. 81* Offsetof:: Special syntax for implementing @code{offsetof}. 82* __sync Builtins:: Legacy built-in functions for atomic memory access. 83* __atomic Builtins:: Atomic built-in functions with memory model. 84* Object Size Checking:: Built-in functions for limited buffer overflow 85 checking. 86* Other Builtins:: Other built-in functions. 87* Target Builtins:: Built-in functions specific to particular targets. 88* Target Format Checks:: Format checks specific to particular targets. 89* Pragmas:: Pragmas accepted by GCC. 90* Unnamed Fields:: Unnamed struct/union fields within structs/unions. 91* Thread-Local:: Per-thread variables. 92* Binary constants:: Binary constants using the @samp{0b} prefix. 93@end menu 94 95@node Statement Exprs 96@section Statements and Declarations in Expressions 97@cindex statements inside expressions 98@cindex declarations inside expressions 99@cindex expressions containing statements 100@cindex macros, statements in expressions 101 102@c the above section title wrapped and causes an underfull hbox.. i 103@c changed it from "within" to "in". --mew 4feb93 104A compound statement enclosed in parentheses may appear as an expression 105in GNU C@. This allows you to use loops, switches, and local variables 106within an expression. 107 108Recall that a compound statement is a sequence of statements surrounded 109by braces; in this construct, parentheses go around the braces. For 110example: 111 112@smallexample 113(@{ int y = foo (); int z; 114 if (y > 0) z = y; 115 else z = - y; 116 z; @}) 117@end smallexample 118 119@noindent 120is a valid (though slightly more complex than necessary) expression 121for the absolute value of @code{foo ()}. 122 123The last thing in the compound statement should be an expression 124followed by a semicolon; the value of this subexpression serves as the 125value of the entire construct. (If you use some other kind of statement 126last within the braces, the construct has type @code{void}, and thus 127effectively no value.) 128 129This feature is especially useful in making macro definitions ``safe'' (so 130that they evaluate each operand exactly once). For example, the 131``maximum'' function is commonly defined as a macro in standard C as 132follows: 133 134@smallexample 135#define max(a,b) ((a) > (b) ? (a) : (b)) 136@end smallexample 137 138@noindent 139@cindex side effects, macro argument 140But this definition computes either @var{a} or @var{b} twice, with bad 141results if the operand has side effects. In GNU C, if you know the 142type of the operands (here taken as @code{int}), you can define 143the macro safely as follows: 144 145@smallexample 146#define maxint(a,b) \ 147 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @}) 148@end smallexample 149 150Embedded statements are not allowed in constant expressions, such as 151the value of an enumeration constant, the width of a bit-field, or 152the initial value of a static variable. 153 154If you don't know the type of the operand, you can still do this, but you 155must use @code{typeof} (@pxref{Typeof}). 156 157In G++, the result value of a statement expression undergoes array and 158function pointer decay, and is returned by value to the enclosing 159expression. For instance, if @code{A} is a class, then 160 161@smallexample 162 A a; 163 164 (@{a;@}).Foo () 165@end smallexample 166 167@noindent 168will construct a temporary @code{A} object to hold the result of the 169statement expression, and that will be used to invoke @code{Foo}. 170Therefore the @code{this} pointer observed by @code{Foo} will not be the 171address of @code{a}. 172 173Any temporaries created within a statement within a statement expression 174will be destroyed at the statement's end. This makes statement 175expressions inside macros slightly different from function calls. In 176the latter case temporaries introduced during argument evaluation will 177be destroyed at the end of the statement that includes the function 178call. In the statement expression case they will be destroyed during 179the statement expression. For instance, 180 181@smallexample 182#define macro(a) (@{__typeof__(a) b = (a); b + 3; @}) 183template<typename T> T function(T a) @{ T b = a; return b + 3; @} 184 185void foo () 186@{ 187 macro (X ()); 188 function (X ()); 189@} 190@end smallexample 191 192@noindent 193will have different places where temporaries are destroyed. For the 194@code{macro} case, the temporary @code{X} will be destroyed just after 195the initialization of @code{b}. In the @code{function} case that 196temporary will be destroyed when the function returns. 197 198These considerations mean that it is probably a bad idea to use 199statement-expressions of this form in header files that are designed to 200work with C++. (Note that some versions of the GNU C Library contained 201header files using statement-expression that lead to precisely this 202bug.) 203 204Jumping into a statement expression with @code{goto} or using a 205@code{switch} statement outside the statement expression with a 206@code{case} or @code{default} label inside the statement expression is 207not permitted. Jumping into a statement expression with a computed 208@code{goto} (@pxref{Labels as Values}) yields undefined behavior. 209Jumping out of a statement expression is permitted, but if the 210statement expression is part of a larger expression then it is 211unspecified which other subexpressions of that expression have been 212evaluated except where the language definition requires certain 213subexpressions to be evaluated before or after the statement 214expression. In any case, as with a function call the evaluation of a 215statement expression is not interleaved with the evaluation of other 216parts of the containing expression. For example, 217 218@smallexample 219 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz(); 220@end smallexample 221 222@noindent 223will call @code{foo} and @code{bar1} and will not call @code{baz} but 224may or may not call @code{bar2}. If @code{bar2} is called, it will be 225called after @code{foo} and before @code{bar1} 226 227@node Local Labels 228@section Locally Declared Labels 229@cindex local labels 230@cindex macros, local labels 231 232GCC allows you to declare @dfn{local labels} in any nested block 233scope. A local label is just like an ordinary label, but you can 234only reference it (with a @code{goto} statement, or by taking its 235address) within the block in which it was declared. 236 237A local label declaration looks like this: 238 239@smallexample 240__label__ @var{label}; 241@end smallexample 242 243@noindent 244or 245 246@smallexample 247__label__ @var{label1}, @var{label2}, /* @r{@dots{}} */; 248@end smallexample 249 250Local label declarations must come at the beginning of the block, 251before any ordinary declarations or statements. 252 253The label declaration defines the label @emph{name}, but does not define 254the label itself. You must do this in the usual way, with 255@code{@var{label}:}, within the statements of the statement expression. 256 257The local label feature is useful for complex macros. If a macro 258contains nested loops, a @code{goto} can be useful for breaking out of 259them. However, an ordinary label whose scope is the whole function 260cannot be used: if the macro can be expanded several times in one 261function, the label will be multiply defined in that function. A 262local label avoids this problem. For example: 263 264@smallexample 265#define SEARCH(value, array, target) \ 266do @{ \ 267 __label__ found; \ 268 typeof (target) _SEARCH_target = (target); \ 269 typeof (*(array)) *_SEARCH_array = (array); \ 270 int i, j; \ 271 int value; \ 272 for (i = 0; i < max; i++) \ 273 for (j = 0; j < max; j++) \ 274 if (_SEARCH_array[i][j] == _SEARCH_target) \ 275 @{ (value) = i; goto found; @} \ 276 (value) = -1; \ 277 found:; \ 278@} while (0) 279@end smallexample 280 281This could also be written using a statement-expression: 282 283@smallexample 284#define SEARCH(array, target) \ 285(@{ \ 286 __label__ found; \ 287 typeof (target) _SEARCH_target = (target); \ 288 typeof (*(array)) *_SEARCH_array = (array); \ 289 int i, j; \ 290 int value; \ 291 for (i = 0; i < max; i++) \ 292 for (j = 0; j < max; j++) \ 293 if (_SEARCH_array[i][j] == _SEARCH_target) \ 294 @{ value = i; goto found; @} \ 295 value = -1; \ 296 found: \ 297 value; \ 298@}) 299@end smallexample 300 301Local label declarations also make the labels they declare visible to 302nested functions, if there are any. @xref{Nested Functions}, for details. 303 304@node Labels as Values 305@section Labels as Values 306@cindex labels as values 307@cindex computed gotos 308@cindex goto with computed label 309@cindex address of a label 310 311You can get the address of a label defined in the current function 312(or a containing function) with the unary operator @samp{&&}. The 313value has type @code{void *}. This value is a constant and can be used 314wherever a constant of that type is valid. For example: 315 316@smallexample 317void *ptr; 318/* @r{@dots{}} */ 319ptr = &&foo; 320@end smallexample 321 322To use these values, you need to be able to jump to one. This is done 323with the computed goto statement@footnote{The analogous feature in 324Fortran is called an assigned goto, but that name seems inappropriate in 325C, where one can do more than simply store label addresses in label 326variables.}, @code{goto *@var{exp};}. For example, 327 328@smallexample 329goto *ptr; 330@end smallexample 331 332@noindent 333Any expression of type @code{void *} is allowed. 334 335One way of using these constants is in initializing a static array that 336will serve as a jump table: 337 338@smallexample 339static void *array[] = @{ &&foo, &&bar, &&hack @}; 340@end smallexample 341 342Then you can select a label with indexing, like this: 343 344@smallexample 345goto *array[i]; 346@end smallexample 347 348@noindent 349Note that this does not check whether the subscript is in bounds---array 350indexing in C never does that. 351 352Such an array of label values serves a purpose much like that of the 353@code{switch} statement. The @code{switch} statement is cleaner, so 354use that rather than an array unless the problem does not fit a 355@code{switch} statement very well. 356 357Another use of label values is in an interpreter for threaded code. 358The labels within the interpreter function can be stored in the 359threaded code for super-fast dispatching. 360 361You may not use this mechanism to jump to code in a different function. 362If you do that, totally unpredictable things will happen. The best way to 363avoid this is to store the label address only in automatic variables and 364never pass it as an argument. 365 366An alternate way to write the above example is 367 368@smallexample 369static const int array[] = @{ &&foo - &&foo, &&bar - &&foo, 370 &&hack - &&foo @}; 371goto *(&&foo + array[i]); 372@end smallexample 373 374@noindent 375This is more friendly to code living in shared libraries, as it reduces 376the number of dynamic relocations that are needed, and by consequence, 377allows the data to be read-only. 378This alternative with label differences is not supported for the AVR target, 379please use the first approach for AVR programs. 380 381The @code{&&foo} expressions for the same label might have different 382values if the containing function is inlined or cloned. If a program 383relies on them being always the same, 384@code{__attribute__((__noinline__,__noclone__))} should be used to 385prevent inlining and cloning. If @code{&&foo} is used in a static 386variable initializer, inlining and cloning is forbidden. 387 388@node Nested Functions 389@section Nested Functions 390@cindex nested functions 391@cindex downward funargs 392@cindex thunks 393 394A @dfn{nested function} is a function defined inside another function. 395(Nested functions are not supported for GNU C++.) The nested function's 396name is local to the block where it is defined. For example, here we 397define a nested function named @code{square}, and call it twice: 398 399@smallexample 400@group 401foo (double a, double b) 402@{ 403 double square (double z) @{ return z * z; @} 404 405 return square (a) + square (b); 406@} 407@end group 408@end smallexample 409 410The nested function can access all the variables of the containing 411function that are visible at the point of its definition. This is 412called @dfn{lexical scoping}. For example, here we show a nested 413function which uses an inherited variable named @code{offset}: 414 415@smallexample 416@group 417bar (int *array, int offset, int size) 418@{ 419 int access (int *array, int index) 420 @{ return array[index + offset]; @} 421 int i; 422 /* @r{@dots{}} */ 423 for (i = 0; i < size; i++) 424 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */ 425@} 426@end group 427@end smallexample 428 429Nested function definitions are permitted within functions in the places 430where variable definitions are allowed; that is, in any block, mixed 431with the other declarations and statements in the block. 432 433It is possible to call the nested function from outside the scope of its 434name by storing its address or passing the address to another function: 435 436@smallexample 437hack (int *array, int size) 438@{ 439 void store (int index, int value) 440 @{ array[index] = value; @} 441 442 intermediate (store, size); 443@} 444@end smallexample 445 446Here, the function @code{intermediate} receives the address of 447@code{store} as an argument. If @code{intermediate} calls @code{store}, 448the arguments given to @code{store} are used to store into @code{array}. 449But this technique works only so long as the containing function 450(@code{hack}, in this example) does not exit. 451 452If you try to call the nested function through its address after the 453containing function has exited, all hell will break loose. If you try 454to call it after a containing scope level has exited, and if it refers 455to some of the variables that are no longer in scope, you may be lucky, 456but it's not wise to take the risk. If, however, the nested function 457does not refer to anything that has gone out of scope, you should be 458safe. 459 460GCC implements taking the address of a nested function using a technique 461called @dfn{trampolines}. This technique was described in 462@cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX 463C++ Conference Proceedings, October 17-21, 1988). 464 465A nested function can jump to a label inherited from a containing 466function, provided the label was explicitly declared in the containing 467function (@pxref{Local Labels}). Such a jump returns instantly to the 468containing function, exiting the nested function which did the 469@code{goto} and any intermediate functions as well. Here is an example: 470 471@smallexample 472@group 473bar (int *array, int offset, int size) 474@{ 475 __label__ failure; 476 int access (int *array, int index) 477 @{ 478 if (index > size) 479 goto failure; 480 return array[index + offset]; 481 @} 482 int i; 483 /* @r{@dots{}} */ 484 for (i = 0; i < size; i++) 485 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */ 486 /* @r{@dots{}} */ 487 return 0; 488 489 /* @r{Control comes here from @code{access} 490 if it detects an error.} */ 491 failure: 492 return -1; 493@} 494@end group 495@end smallexample 496 497A nested function always has no linkage. Declaring one with 498@code{extern} or @code{static} is erroneous. If you need to declare the nested function 499before its definition, use @code{auto} (which is otherwise meaningless 500for function declarations). 501 502@smallexample 503bar (int *array, int offset, int size) 504@{ 505 __label__ failure; 506 auto int access (int *, int); 507 /* @r{@dots{}} */ 508 int access (int *array, int index) 509 @{ 510 if (index > size) 511 goto failure; 512 return array[index + offset]; 513 @} 514 /* @r{@dots{}} */ 515@} 516@end smallexample 517 518@node Constructing Calls 519@section Constructing Function Calls 520@cindex constructing calls 521@cindex forwarding calls 522 523Using the built-in functions described below, you can record 524the arguments a function received, and call another function 525with the same arguments, without knowing the number or types 526of the arguments. 527 528You can also record the return value of that function call, 529and later return that value, without knowing what data type 530the function tried to return (as long as your caller expects 531that data type). 532 533However, these built-in functions may interact badly with some 534sophisticated features or other extensions of the language. It 535is, therefore, not recommended to use them outside very simple 536functions acting as mere forwarders for their arguments. 537 538@deftypefn {Built-in Function} {void *} __builtin_apply_args () 539This built-in function returns a pointer to data 540describing how to perform a call with the same arguments as were passed 541to the current function. 542 543The function saves the arg pointer register, structure value address, 544and all registers that might be used to pass arguments to a function 545into a block of memory allocated on the stack. Then it returns the 546address of that block. 547@end deftypefn 548 549@deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size}) 550This built-in function invokes @var{function} 551with a copy of the parameters described by @var{arguments} 552and @var{size}. 553 554The value of @var{arguments} should be the value returned by 555@code{__builtin_apply_args}. The argument @var{size} specifies the size 556of the stack argument data, in bytes. 557 558This function returns a pointer to data describing 559how to return whatever value was returned by @var{function}. The data 560is saved in a block of memory allocated on the stack. 561 562It is not always simple to compute the proper value for @var{size}. The 563value is used by @code{__builtin_apply} to compute the amount of data 564that should be pushed on the stack and copied from the incoming argument 565area. 566@end deftypefn 567 568@deftypefn {Built-in Function} {void} __builtin_return (void *@var{result}) 569This built-in function returns the value described by @var{result} from 570the containing function. You should specify, for @var{result}, a value 571returned by @code{__builtin_apply}. 572@end deftypefn 573 574@deftypefn {Built-in Function} {} __builtin_va_arg_pack () 575This built-in function represents all anonymous arguments of an inline 576function. It can be used only in inline functions which will be always 577inlined, never compiled as a separate function, such as those using 578@code{__attribute__ ((__always_inline__))} or 579@code{__attribute__ ((__gnu_inline__))} extern inline functions. 580It must be only passed as last argument to some other function 581with variable arguments. This is useful for writing small wrapper 582inlines for variable argument functions, when using preprocessor 583macros is undesirable. For example: 584@smallexample 585extern int myprintf (FILE *f, const char *format, ...); 586extern inline __attribute__ ((__gnu_inline__)) int 587myprintf (FILE *f, const char *format, ...) 588@{ 589 int r = fprintf (f, "myprintf: "); 590 if (r < 0) 591 return r; 592 int s = fprintf (f, format, __builtin_va_arg_pack ()); 593 if (s < 0) 594 return s; 595 return r + s; 596@} 597@end smallexample 598@end deftypefn 599 600@deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len () 601This built-in function returns the number of anonymous arguments of 602an inline function. It can be used only in inline functions which 603will be always inlined, never compiled as a separate function, such 604as those using @code{__attribute__ ((__always_inline__))} or 605@code{__attribute__ ((__gnu_inline__))} extern inline functions. 606For example following will do link or runtime checking of open 607arguments for optimized code: 608@smallexample 609#ifdef __OPTIMIZE__ 610extern inline __attribute__((__gnu_inline__)) int 611myopen (const char *path, int oflag, ...) 612@{ 613 if (__builtin_va_arg_pack_len () > 1) 614 warn_open_too_many_arguments (); 615 616 if (__builtin_constant_p (oflag)) 617 @{ 618 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1) 619 @{ 620 warn_open_missing_mode (); 621 return __open_2 (path, oflag); 622 @} 623 return open (path, oflag, __builtin_va_arg_pack ()); 624 @} 625 626 if (__builtin_va_arg_pack_len () < 1) 627 return __open_2 (path, oflag); 628 629 return open (path, oflag, __builtin_va_arg_pack ()); 630@} 631#endif 632@end smallexample 633@end deftypefn 634 635@node Typeof 636@section Referring to a Type with @code{typeof} 637@findex typeof 638@findex sizeof 639@cindex macros, types of arguments 640 641Another way to refer to the type of an expression is with @code{typeof}. 642The syntax of using of this keyword looks like @code{sizeof}, but the 643construct acts semantically like a type name defined with @code{typedef}. 644 645There are two ways of writing the argument to @code{typeof}: with an 646expression or with a type. Here is an example with an expression: 647 648@smallexample 649typeof (x[0](1)) 650@end smallexample 651 652@noindent 653This assumes that @code{x} is an array of pointers to functions; 654the type described is that of the values of the functions. 655 656Here is an example with a typename as the argument: 657 658@smallexample 659typeof (int *) 660@end smallexample 661 662@noindent 663Here the type described is that of pointers to @code{int}. 664 665If you are writing a header file that must work when included in ISO C 666programs, write @code{__typeof__} instead of @code{typeof}. 667@xref{Alternate Keywords}. 668 669A @code{typeof}-construct can be used anywhere a typedef name could be 670used. For example, you can use it in a declaration, in a cast, or inside 671of @code{sizeof} or @code{typeof}. 672 673The operand of @code{typeof} is evaluated for its side effects if and 674only if it is an expression of variably modified type or the name of 675such a type. 676 677@code{typeof} is often useful in conjunction with the 678statements-within-expressions feature. Here is how the two together can 679be used to define a safe ``maximum'' macro that operates on any 680arithmetic 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 695The reason for using names that start with underscores for the local 696variables is to avoid conflicts with variable names that occur within the 697expressions that are substituted for @code{a} and @code{b}. Eventually we 698hope to design a new form of declaration syntax that allows you to declare 699variables whose scopes start only after their initializers; this will be a 700more reliable way to prevent such conflicts. 701 702@noindent 703Some more examples of the use of @code{typeof}: 704 705@itemize @bullet 706@item 707This declares @code{y} with the type of what @code{x} points to. 708 709@smallexample 710typeof (*x) y; 711@end smallexample 712 713@item 714This declares @code{y} as an array of such values. 715 716@smallexample 717typeof (*x) y[4]; 718@end smallexample 719 720@item 721This declares @code{y} as an array of pointers to characters: 722 723@smallexample 724typeof (typeof (char *)[4]) y; 725@end smallexample 726 727@noindent 728It is equivalent to the following traditional C declaration: 729 730@smallexample 731char *y[4]; 732@end smallexample 733 734To see the meaning of the declaration using @code{typeof}, and why it 735might 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 743Now the declaration can be rewritten this way: 744 745@smallexample 746array (pointer (char), 4) y; 747@end smallexample 748 749@noindent 750Thus, @code{array (pointer (char), 4)} is the type of arrays of 4 751pointers to @code{char}. 752@end itemize 753 754@emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported 755a more limited extension which permitted one to write 756 757@smallexample 758typedef @var{T} = @var{expr}; 759@end smallexample 760 761@noindent 762with the effect of declaring @var{T} to have the type of the expression 763@var{expr}. This extension does not work with GCC 3 (versions between 7643.0 and 3.2 will crash; 3.2.1 and later give an error). Code which 765relies on it should be rewritten to use @code{typeof}: 766 767@smallexample 768typedef typeof(@var{expr}) @var{T}; 769@end smallexample 770 771@noindent 772This will work with all versions of GCC@. 773 774@node Conditionals 775@section Conditionals with Omitted Operands 776@cindex conditional expressions, extensions 777@cindex omitted middle-operands 778@cindex middle-operands, omitted 779@cindex extensions, @code{?:} 780@cindex @code{?:} extensions 781 782The middle operand in a conditional expression may be omitted. Then 783if the first operand is nonzero, its value is the value of the conditional 784expression. 785 786Therefore, the expression 787 788@smallexample 789x ? : y 790@end smallexample 791 792@noindent 793has the value of @code{x} if that is nonzero; otherwise, the value of 794@code{y}. 795 796This example is perfectly equivalent to 797 798@smallexample 799x ? x : y 800@end smallexample 801 802@cindex side effect in @code{?:} 803@cindex @code{?:} side effect 804@noindent 805In this simple case, the ability to omit the middle operand is not 806especially useful. When it becomes useful is when the first operand does, 807or may (if it is a macro argument), contain a side effect. Then repeating 808the operand in the middle would perform the side effect twice. Omitting 809the middle operand uses the value already computed without the undesirable 810effects of recomputing it. 811 812@node __int128 813@section 128-bits integers 814@cindex @code{__int128} data types 815 816As an extension the integer scalar type @code{__int128} is supported for 817targets having an integer mode wide enough to hold 128-bit. 818Simply write @code{__int128} for a signed 128-bit integer, or 819@code{unsigned __int128} for an unsigned 128-bit integer. There is no 820support in GCC to express an integer constant of type @code{__int128} 821for targets having @code{long long} integer with less then 128 bit width. 822 823@node Long Long 824@section Double-Word Integers 825@cindex @code{long long} data types 826@cindex double-word arithmetic 827@cindex multiprecision arithmetic 828@cindex @code{LL} integer suffix 829@cindex @code{ULL} integer suffix 830 831ISO C99 supports data types for integers that are at least 64 bits wide, 832and as an extension GCC supports them in C90 mode and in C++. 833Simply write @code{long long int} for a signed integer, or 834@code{unsigned long long int} for an unsigned integer. To make an 835integer constant of type @code{long long int}, add the suffix @samp{LL} 836to the integer. To make an integer constant of type @code{unsigned long 837long int}, add the suffix @samp{ULL} to the integer. 838 839You can use these types in arithmetic like any other integer types. 840Addition, subtraction, and bitwise boolean operations on these types 841are open-coded on all types of machines. Multiplication is open-coded 842if the machine supports fullword-to-doubleword a widening multiply 843instruction. Division and shifts are open-coded only on machines that 844provide special support. The operations that are not open-coded use 845special library routines that come with GCC@. 846 847There may be pitfalls when you use @code{long long} types for function 848arguments, unless you declare function prototypes. If a function 849expects type @code{int} for its argument, and you pass a value of type 850@code{long long int}, confusion will result because the caller and the 851subroutine will disagree about the number of bytes for the argument. 852Likewise, if the function expects @code{long long int} and you pass 853@code{int}. The best way to avoid such problems is to use prototypes. 854 855@node Complex 856@section Complex Numbers 857@cindex complex numbers 858@cindex @code{_Complex} keyword 859@cindex @code{__complex__} keyword 860 861ISO C99 supports complex floating data types, and as an extension GCC 862supports them in C90 mode and in C++, and supports complex integer data 863types which are not part of ISO C99. You can declare complex types 864using the keyword @code{_Complex}. As an extension, the older GNU 865keyword @code{__complex__} is also supported. 866 867For example, @samp{_Complex double x;} declares @code{x} as a 868variable whose real part and imaginary part are both of type 869@code{double}. @samp{_Complex short int y;} declares @code{y} to 870have real and imaginary parts of type @code{short int}; this is not 871likely to be useful, but it shows that the set of complex types is 872complete. 873 874To write a constant with a complex data type, use the suffix @samp{i} or 875@samp{j} (either one; they are equivalent). For example, @code{2.5fi} 876has type @code{_Complex float} and @code{3i} has type 877@code{_Complex int}. Such a constant always has a pure imaginary 878value, but you can form any complex value you like by adding one to a 879real constant. This is a GNU extension; if you have an ISO C99 880conforming C library (such as GNU libc), and want to construct complex 881constants of floating type, you should include @code{<complex.h>} and 882use the macros @code{I} or @code{_Complex_I} instead. 883 884@cindex @code{__real__} keyword 885@cindex @code{__imag__} keyword 886To extract the real part of a complex-valued expression @var{exp}, write 887@code{__real__ @var{exp}}. Likewise, use @code{__imag__} to 888extract the imaginary part. This is a GNU extension; for values of 889floating type, you should use the ISO C99 functions @code{crealf}, 890@code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and 891@code{cimagl}, declared in @code{<complex.h>} and also provided as 892built-in functions by GCC@. 893 894@cindex complex conjugation 895The operator @samp{~} performs complex conjugation when used on a value 896with a complex type. This is a GNU extension; for values of 897floating type, you should use the ISO C99 functions @code{conjf}, 898@code{conj} and @code{conjl}, declared in @code{<complex.h>} and also 899provided as built-in functions by GCC@. 900 901GCC can allocate complex automatic variables in a noncontiguous 902fashion; it's even possible for the real part to be in a register while 903the imaginary part is on the stack (or vice-versa). Only the DWARF2 904debug info format can represent this, so use of DWARF2 is recommended. 905If you are using the stabs debug info format, GCC describes a noncontiguous 906complex variable as if it were two separate variables of noncomplex type. 907If the variable's actual name is @code{foo}, the two fictitious 908variables are named @code{foo$real} and @code{foo$imag}. You can 909examine and set these two fictitious variables with your debugger. 910 911@node Floating Types 912@section Additional Floating Types 913@cindex additional floating types 914@cindex @code{__float80} data type 915@cindex @code{__float128} data type 916@cindex @code{w} floating point suffix 917@cindex @code{q} floating point suffix 918@cindex @code{W} floating point suffix 919@cindex @code{Q} floating point suffix 920 921As an extension, the GNU C compiler supports additional floating 922types, @code{__float80} and @code{__float128} to support 80bit 923(@code{XFmode}) and 128 bit (@code{TFmode}) floating types. 924Support for additional types includes the arithmetic operators: 925add, subtract, multiply, divide; unary arithmetic operators; 926relational operators; equality operators; and conversions to and from 927integer and other floating types. Use a suffix @samp{w} or @samp{W} 928in a literal constant of type @code{__float80} and @samp{q} or @samp{Q} 929for @code{_float128}. You can declare complex types using the 930corresponding internal complex type, @code{XCmode} for @code{__float80} 931type and @code{TCmode} for @code{__float128} type: 932 933@smallexample 934typedef _Complex float __attribute__((mode(TC))) _Complex128; 935typedef _Complex float __attribute__((mode(XC))) _Complex80; 936@end smallexample 937 938Not all targets support additional floating point types. @code{__float80} 939and @code{__float128} types are supported on i386, x86_64 and ia64 targets. 940The @code{__float128} type is supported on hppa HP-UX targets. 941 942@node Half-Precision 943@section Half-Precision Floating Point 944@cindex half-precision floating point 945@cindex @code{__fp16} data type 946 947On ARM targets, GCC supports half-precision (16-bit) floating point via 948the @code{__fp16} type. You must enable this type explicitly 949with the @option{-mfp16-format} command-line option in order to use it. 950 951ARM supports two incompatible representations for half-precision 952floating-point values. You must choose one of the representations and 953use it consistently in your program. 954 955Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format. 956This format can represent normalized values in the range of @math{2^{-14}} to 65504. 957There are 11 bits of significand precision, approximately 3 958decimal digits. 959 960Specifying @option{-mfp16-format=alternative} selects the ARM 961alternative format. This representation is similar to the IEEE 962format, but does not support infinities or NaNs. Instead, the range 963of exponents is extended, so that this format can represent normalized 964values in the range of @math{2^{-14}} to 131008. 965 966The @code{__fp16} type is a storage format only. For purposes 967of arithmetic and other operations, @code{__fp16} values in C or C++ 968expressions are automatically promoted to @code{float}. In addition, 969you cannot declare a function with a return value or parameters 970of type @code{__fp16}. 971 972Note that conversions from @code{double} to @code{__fp16} 973involve an intermediate conversion to @code{float}. Because 974of rounding, this can sometimes produce a different result than a 975direct conversion. 976 977ARM provides hardware support for conversions between 978@code{__fp16} and @code{float} values 979as an extension to VFP and NEON (Advanced SIMD). GCC generates 980code using these hardware instructions if you compile with 981options to select an FPU that provides them; 982for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp}, 983in addition to the @option{-mfp16-format} option to select 984a half-precision format. 985 986Language-level support for the @code{__fp16} data type is 987independent of whether GCC generates code using hardware floating-point 988instructions. In cases where hardware support is not specified, GCC 989implements conversions between @code{__fp16} and @code{float} values 990as library calls. 991 992@node Decimal Float 993@section Decimal Floating Types 994@cindex decimal floating types 995@cindex @code{_Decimal32} data type 996@cindex @code{_Decimal64} data type 997@cindex @code{_Decimal128} data type 998@cindex @code{df} integer suffix 999@cindex @code{dd} integer suffix 1000@cindex @code{dl} integer suffix 1001@cindex @code{DF} integer suffix 1002@cindex @code{DD} integer suffix 1003@cindex @code{DL} integer suffix 1004 1005As an extension, the GNU C compiler supports decimal floating types as 1006defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal 1007floating types in GCC will evolve as the draft technical report changes. 1008Calling conventions for any target might also change. Not all targets 1009support decimal floating types. 1010 1011The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and 1012@code{_Decimal128}. They use a radix of ten, unlike the floating types 1013@code{float}, @code{double}, and @code{long double} whose radix is not 1014specified by the C standard but is usually two. 1015 1016Support for decimal floating types includes the arithmetic operators 1017add, subtract, multiply, divide; unary arithmetic operators; 1018relational operators; equality operators; and conversions to and from 1019integer and other floating types. Use a suffix @samp{df} or 1020@samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd} 1021or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for 1022@code{_Decimal128}. 1023 1024GCC support of decimal float as specified by the draft technical report 1025is incomplete: 1026 1027@itemize @bullet 1028@item 1029When the value of a decimal floating type cannot be represented in the 1030integer type to which it is being converted, the result is undefined 1031rather than the result value specified by the draft technical report. 1032 1033@item 1034GCC does not provide the C library functionality associated with 1035@file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and 1036@file{wchar.h}, which must come from a separate C library implementation. 1037Because of this the GNU C compiler does not define macro 1038@code{__STDC_DEC_FP__} to indicate that the implementation conforms to 1039the technical report. 1040@end itemize 1041 1042Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128} 1043are supported by the DWARF2 debug information format. 1044 1045@node Hex Floats 1046@section Hex Floats 1047@cindex hex floats 1048 1049ISO C99 supports floating-point numbers written not only in the usual 1050decimal notation, such as @code{1.55e1}, but also numbers such as 1051@code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC 1052supports this in C90 mode (except in some cases when strictly 1053conforming) and in C++. In that format the 1054@samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are 1055mandatory. The exponent is a decimal number that indicates the power of 10562 by which the significant part will be multiplied. Thus @samp{0x1.f} is 1057@tex 1058$1 {15\over16}$, 1059@end tex 1060@ifnottex 10611 15/16, 1062@end ifnottex 1063@samp{p3} multiplies it by 8, and the value of @code{0x1.fp3} 1064is the same as @code{1.55e1}. 1065 1066Unlike for floating-point numbers in the decimal notation the exponent 1067is always required in the hexadecimal notation. Otherwise the compiler 1068would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This 1069could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the 1070extension for floating-point constants of type @code{float}. 1071 1072@node Fixed-Point 1073@section Fixed-Point Types 1074@cindex fixed-point types 1075@cindex @code{_Fract} data type 1076@cindex @code{_Accum} data type 1077@cindex @code{_Sat} data type 1078@cindex @code{hr} fixed-suffix 1079@cindex @code{r} fixed-suffix 1080@cindex @code{lr} fixed-suffix 1081@cindex @code{llr} fixed-suffix 1082@cindex @code{uhr} fixed-suffix 1083@cindex @code{ur} fixed-suffix 1084@cindex @code{ulr} fixed-suffix 1085@cindex @code{ullr} fixed-suffix 1086@cindex @code{hk} fixed-suffix 1087@cindex @code{k} fixed-suffix 1088@cindex @code{lk} fixed-suffix 1089@cindex @code{llk} fixed-suffix 1090@cindex @code{uhk} fixed-suffix 1091@cindex @code{uk} fixed-suffix 1092@cindex @code{ulk} fixed-suffix 1093@cindex @code{ullk} fixed-suffix 1094@cindex @code{HR} fixed-suffix 1095@cindex @code{R} fixed-suffix 1096@cindex @code{LR} fixed-suffix 1097@cindex @code{LLR} fixed-suffix 1098@cindex @code{UHR} fixed-suffix 1099@cindex @code{UR} fixed-suffix 1100@cindex @code{ULR} fixed-suffix 1101@cindex @code{ULLR} fixed-suffix 1102@cindex @code{HK} fixed-suffix 1103@cindex @code{K} fixed-suffix 1104@cindex @code{LK} fixed-suffix 1105@cindex @code{LLK} fixed-suffix 1106@cindex @code{UHK} fixed-suffix 1107@cindex @code{UK} fixed-suffix 1108@cindex @code{ULK} fixed-suffix 1109@cindex @code{ULLK} fixed-suffix 1110 1111As an extension, the GNU C compiler supports fixed-point types as 1112defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point 1113types in GCC will evolve as the draft technical report changes. 1114Calling conventions for any target might also change. Not all targets 1115support fixed-point types. 1116 1117The fixed-point types are 1118@code{short _Fract}, 1119@code{_Fract}, 1120@code{long _Fract}, 1121@code{long long _Fract}, 1122@code{unsigned short _Fract}, 1123@code{unsigned _Fract}, 1124@code{unsigned long _Fract}, 1125@code{unsigned long long _Fract}, 1126@code{_Sat short _Fract}, 1127@code{_Sat _Fract}, 1128@code{_Sat long _Fract}, 1129@code{_Sat long long _Fract}, 1130@code{_Sat unsigned short _Fract}, 1131@code{_Sat unsigned _Fract}, 1132@code{_Sat unsigned long _Fract}, 1133@code{_Sat unsigned long long _Fract}, 1134@code{short _Accum}, 1135@code{_Accum}, 1136@code{long _Accum}, 1137@code{long long _Accum}, 1138@code{unsigned short _Accum}, 1139@code{unsigned _Accum}, 1140@code{unsigned long _Accum}, 1141@code{unsigned long long _Accum}, 1142@code{_Sat short _Accum}, 1143@code{_Sat _Accum}, 1144@code{_Sat long _Accum}, 1145@code{_Sat long long _Accum}, 1146@code{_Sat unsigned short _Accum}, 1147@code{_Sat unsigned _Accum}, 1148@code{_Sat unsigned long _Accum}, 1149@code{_Sat unsigned long long _Accum}. 1150 1151Fixed-point data values contain fractional and optional integral parts. 1152The format of fixed-point data varies and depends on the target machine. 1153 1154Support for fixed-point types includes: 1155@itemize @bullet 1156@item 1157prefix and postfix increment and decrement operators (@code{++}, @code{--}) 1158@item 1159unary arithmetic operators (@code{+}, @code{-}, @code{!}) 1160@item 1161binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/}) 1162@item 1163binary shift operators (@code{<<}, @code{>>}) 1164@item 1165relational operators (@code{<}, @code{<=}, @code{>=}, @code{>}) 1166@item 1167equality operators (@code{==}, @code{!=}) 1168@item 1169assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=}, 1170@code{<<=}, @code{>>=}) 1171@item 1172conversions to and from integer, floating-point, or fixed-point types 1173@end itemize 1174 1175Use a suffix in a fixed-point literal constant: 1176@itemize 1177@item @samp{hr} or @samp{HR} for @code{short _Fract} and 1178@code{_Sat short _Fract} 1179@item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract} 1180@item @samp{lr} or @samp{LR} for @code{long _Fract} and 1181@code{_Sat long _Fract} 1182@item @samp{llr} or @samp{LLR} for @code{long long _Fract} and 1183@code{_Sat long long _Fract} 1184@item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and 1185@code{_Sat unsigned short _Fract} 1186@item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and 1187@code{_Sat unsigned _Fract} 1188@item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and 1189@code{_Sat unsigned long _Fract} 1190@item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract} 1191and @code{_Sat unsigned long long _Fract} 1192@item @samp{hk} or @samp{HK} for @code{short _Accum} and 1193@code{_Sat short _Accum} 1194@item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum} 1195@item @samp{lk} or @samp{LK} for @code{long _Accum} and 1196@code{_Sat long _Accum} 1197@item @samp{llk} or @samp{LLK} for @code{long long _Accum} and 1198@code{_Sat long long _Accum} 1199@item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and 1200@code{_Sat unsigned short _Accum} 1201@item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and 1202@code{_Sat unsigned _Accum} 1203@item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and 1204@code{_Sat unsigned long _Accum} 1205@item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum} 1206and @code{_Sat unsigned long long _Accum} 1207@end itemize 1208 1209GCC support of fixed-point types as specified by the draft technical report 1210is incomplete: 1211 1212@itemize @bullet 1213@item 1214Pragmas to control overflow and rounding behaviors are not implemented. 1215@end itemize 1216 1217Fixed-point types are supported by the DWARF2 debug information format. 1218 1219@node Named Address Spaces 1220@section Named Address Spaces 1221@cindex Named Address Spaces 1222 1223As an extension, the GNU C compiler supports named address spaces as 1224defined in the N1275 draft of ISO/IEC DTR 18037. Support for named 1225address spaces in GCC will evolve as the draft technical report 1226changes. Calling conventions for any target might also change. At 1227present, only the AVR, SPU, M32C, and RL78 targets support address 1228spaces other than the generic address space. 1229 1230Address space identifiers may be used exactly like any other C type 1231qualifier (e.g., @code{const} or @code{volatile}). See the N1275 1232document for more details. 1233 1234@anchor{AVR Named Address Spaces} 1235@subsection AVR Named Address Spaces 1236 1237On the AVR target, there are several address spaces that can be used 1238in order to put read-only data into the flash memory and access that 1239data by means of the special instructions @code{LPM} or @code{ELPM} 1240needed to read from flash. 1241 1242Per default, any data including read-only data is located in RAM 1243(the generic address space) so that non-generic address spaces are 1244needed to locate read-only data in flash memory 1245@emph{and} to generate the right instructions to access this data 1246without using (inline) assembler code. 1247 1248@table @code 1249@item __flash 1250@cindex @code{__flash} AVR Named Address Spaces 1251The @code{__flash} qualifier will locate data in the 1252@code{.progmem.data} section. Data will be read using the @code{LPM} 1253instruction. Pointers to this address space are 16 bits wide. 1254 1255@item __flash1 1256@item __flash2 1257@item __flash3 1258@item __flash4 1259@item __flash5 1260@cindex @code{__flash1} AVR Named Address Spaces 1261@cindex @code{__flash2} AVR Named Address Spaces 1262@cindex @code{__flash3} AVR Named Address Spaces 1263@cindex @code{__flash4} AVR Named Address Spaces 1264@cindex @code{__flash5} AVR Named Address Spaces 1265These are 16-bit address spaces locating data in section 1266@code{.progmem@var{N}.data} where @var{N} refers to 1267address space @code{__flash@var{N}}. 1268The compiler will set the @code{RAMPZ} segment register approptiately 1269before reading data by means of the @code{ELPM} instruction. 1270 1271@item __memx 1272@cindex @code{__memx} AVR Named Address Spaces 1273This is a 24-bit address space that linearizes flash and RAM: 1274If the high bit of the address is set, data is read from 1275RAM using the lower two bytes as RAM address. 1276If the high bit of the address is clear, data is read from flash 1277with @code{RAMPZ} set according to the high byte of the address. 1278 1279Objects in this address space will be located in @code{.progmemx.data}. 1280@end table 1281 1282@b{Example} 1283 1284@example 1285char my_read (const __flash char ** p) 1286@{ 1287 /* p is a pointer to RAM that points to a pointer to flash. 1288 The first indirection of p will read that flash pointer 1289 from RAM and the second indirection reads a char from this 1290 flash address. */ 1291 1292 return **p; 1293@} 1294 1295/* Locate array[] in flash memory */ 1296const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @}; 1297 1298int i = 1; 1299 1300int main (void) 1301@{ 1302 /* Return 17 by reading from flash memory */ 1303 return array[array[i]]; 1304@} 1305@end example 1306 1307For each named address space supported by avr-gcc there is an equally 1308named but uppercase built-in macro defined. 1309The purpose is to facilitate testing if respective address space 1310support is available or not: 1311 1312@example 1313#ifdef __FLASH 1314const __flash int var = 1; 1315 1316int read_var (void) 1317@{ 1318 return var; 1319@} 1320#else 1321#include <avr/pgmspace.h> /* From AVR-LibC */ 1322 1323const int var PROGMEM = 1; 1324 1325int read_var (void) 1326@{ 1327 return (int) pgm_read_word (&var); 1328@} 1329#endif /* __FLASH */ 1330@end example 1331 1332Notice that attribute @ref{AVR Variable Attributes,@code{progmem}} 1333locates data in flash but 1334accesses to these data will read from generic address space, i.e.@: 1335from RAM, 1336so that you need special accessors like @code{pgm_read_byte} 1337from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} 1338together with attribute @code{progmem}. 1339 1340@b{Limitations and caveats} 1341 1342@itemize 1343@item 1344Reading across the 64@tie{}KiB section boundary of 1345the @code{__flash} or @code{__flash@var{N}} address spaces 1346will show undefined behaviour. The only address space that 1347supports reading across the 64@tie{}KiB flash segment boundaries is 1348@code{__memx}. 1349 1350@item 1351If you use one of the @code{__flash@var{N}} address spaces 1352you will have to arrange your linker skript to locate the 1353@code{.progmem@var{N}.data} sections according to your needs. 1354 1355@item 1356Any data or pointers to the non-generic address spaces must 1357be qualified as @code{const}, i.e.@: as read-only data. 1358This still applies if the data in one of these address 1359spaces like software version number or calibration lookup table are intended to 1360be changed after load time by, say, a boot loader. In this case 1361the right qualification is @code{const} @code{volatile} so that the compiler 1362must not optimize away known values or insert them 1363as immediates into operands of instructions. 1364 1365@item 1366Code like the following is not yet supported because of missing 1367support in avr-binutils, 1368see @w{@uref{http://sourceware.org/PR13503,PR13503}}. 1369@example 1370extern const __memx char foo; 1371const __memx void *pfoo = &foo; 1372@end example 1373The code will throw an assembler warning and the high byte of 1374@code{pfoo} will be initialized with@tie{}@code{0}, i.e.@: the 1375initialization will be as if @code{foo} was located in the first 137664@tie{}KiB chunk of flash. 1377 1378@end itemize 1379 1380@subsection M32C Named Address Spaces 1381@cindex @code{__far} M32C Named Address Spaces 1382 1383On the M32C target, with the R8C and M16C cpu variants, variables 1384qualified with @code{__far} are accessed using 32-bit addresses in 1385order to access memory beyond the first 64@tie{}Ki bytes. If 1386@code{__far} is used with the M32CM or M32C cpu variants, it has no 1387effect. 1388 1389@subsection RL78 Named Address Spaces 1390@cindex @code{__far} RL78 Named Address Spaces 1391 1392On the RL78 target, variables qualified with @code{__far} are accessed 1393with 32-bit pointers (20-bit addresses) rather than the default 16-bit 1394addresses. Non-far variables are assumed to appear in the topmost 139564@tie{}KiB of the address space. 1396 1397@subsection SPU Named Address Spaces 1398@cindex @code{__ea} SPU Named Address Spaces 1399 1400On the SPU target variables may be declared as 1401belonging to another address space by qualifying the type with the 1402@code{__ea} address space identifier: 1403 1404@smallexample 1405extern int __ea i; 1406@end smallexample 1407 1408When the variable @code{i} is accessed, the compiler will generate 1409special code to access this variable. It may use runtime library 1410support, or generate special machine instructions to access that address 1411space. 1412 1413@node Zero Length 1414@section Arrays of Length Zero 1415@cindex arrays of length zero 1416@cindex zero-length arrays 1417@cindex length-zero arrays 1418@cindex flexible array members 1419 1420Zero-length arrays are allowed in GNU C@. They are very useful as the 1421last element of a structure which is really a header for a variable-length 1422object: 1423 1424@smallexample 1425struct line @{ 1426 int length; 1427 char contents[0]; 1428@}; 1429 1430struct line *thisline = (struct line *) 1431 malloc (sizeof (struct line) + this_length); 1432thisline->length = this_length; 1433@end smallexample 1434 1435In ISO C90, you would have to give @code{contents} a length of 1, which 1436means either you waste space or complicate the argument to @code{malloc}. 1437 1438In ISO C99, you would use a @dfn{flexible array member}, which is 1439slightly different in syntax and semantics: 1440 1441@itemize @bullet 1442@item 1443Flexible array members are written as @code{contents[]} without 1444the @code{0}. 1445 1446@item 1447Flexible array members have incomplete type, and so the @code{sizeof} 1448operator may not be applied. As a quirk of the original implementation 1449of zero-length arrays, @code{sizeof} evaluates to zero. 1450 1451@item 1452Flexible array members may only appear as the last member of a 1453@code{struct} that is otherwise non-empty. 1454 1455@item 1456A structure containing a flexible array member, or a union containing 1457such a structure (possibly recursively), may not be a member of a 1458structure or an element of an array. (However, these uses are 1459permitted by GCC as extensions.) 1460@end itemize 1461 1462GCC versions before 3.0 allowed zero-length arrays to be statically 1463initialized, as if they were flexible arrays. In addition to those 1464cases that were useful, it also allowed initializations in situations 1465that would corrupt later data. Non-empty initialization of zero-length 1466arrays is now treated like any case where there are more initializer 1467elements than the array holds, in that a suitable warning about "excess 1468elements in array" is given, and the excess elements (all of them, in 1469this case) are ignored. 1470 1471Instead GCC allows static initialization of flexible array members. 1472This is equivalent to defining a new structure containing the original 1473structure followed by an array of sufficient size to contain the data. 1474I.e.@: in the following, @code{f1} is constructed as if it were declared 1475like @code{f2}. 1476 1477@smallexample 1478struct f1 @{ 1479 int x; int y[]; 1480@} f1 = @{ 1, @{ 2, 3, 4 @} @}; 1481 1482struct f2 @{ 1483 struct f1 f1; int data[3]; 1484@} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @}; 1485@end smallexample 1486 1487@noindent 1488The convenience of this extension is that @code{f1} has the desired 1489type, eliminating the need to consistently refer to @code{f2.f1}. 1490 1491This has symmetry with normal static arrays, in that an array of 1492unknown size is also written with @code{[]}. 1493 1494Of course, this extension only makes sense if the extra data comes at 1495the end of a top-level object, as otherwise we would be overwriting 1496data at subsequent offsets. To avoid undue complication and confusion 1497with initialization of deeply nested arrays, we simply disallow any 1498non-empty initialization except when the structure is the top-level 1499object. For example: 1500 1501@smallexample 1502struct foo @{ int x; int y[]; @}; 1503struct bar @{ struct foo z; @}; 1504 1505struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.} 1506struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.} 1507struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.} 1508struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @}; // @r{Invalid.} 1509@end smallexample 1510 1511@node Empty Structures 1512@section Structures With No Members 1513@cindex empty structures 1514@cindex zero-size structures 1515 1516GCC permits a C structure to have no members: 1517 1518@smallexample 1519struct empty @{ 1520@}; 1521@end smallexample 1522 1523The structure will have size zero. In C++, empty structures are part 1524of the language. G++ treats empty structures as if they had a single 1525member of type @code{char}. 1526 1527@node Variable Length 1528@section Arrays of Variable Length 1529@cindex variable-length arrays 1530@cindex arrays of variable length 1531@cindex VLAs 1532 1533Variable-length automatic arrays are allowed in ISO C99, and as an 1534extension GCC accepts them in C90 mode and in C++. These arrays are 1535declared like any other automatic arrays, but with a length that is not 1536a constant expression. The storage is allocated at the point of 1537declaration and deallocated when the brace-level is exited. For 1538example: 1539 1540@smallexample 1541FILE * 1542concat_fopen (char *s1, char *s2, char *mode) 1543@{ 1544 char str[strlen (s1) + strlen (s2) + 1]; 1545 strcpy (str, s1); 1546 strcat (str, s2); 1547 return fopen (str, mode); 1548@} 1549@end smallexample 1550 1551@cindex scope of a variable length array 1552@cindex variable-length array scope 1553@cindex deallocating variable length arrays 1554Jumping or breaking out of the scope of the array name deallocates the 1555storage. Jumping into the scope is not allowed; you get an error 1556message for it. 1557 1558@cindex @code{alloca} vs variable-length arrays 1559You can use the function @code{alloca} to get an effect much like 1560variable-length arrays. The function @code{alloca} is available in 1561many other C implementations (but not in all). On the other hand, 1562variable-length arrays are more elegant. 1563 1564There are other differences between these two methods. Space allocated 1565with @code{alloca} exists until the containing @emph{function} returns. 1566The space for a variable-length array is deallocated as soon as the array 1567name's scope ends. (If you use both variable-length arrays and 1568@code{alloca} in the same function, deallocation of a variable-length array 1569will also deallocate anything more recently allocated with @code{alloca}.) 1570 1571You can also use variable-length arrays as arguments to functions: 1572 1573@smallexample 1574struct entry 1575tester (int len, char data[len][len]) 1576@{ 1577 /* @r{@dots{}} */ 1578@} 1579@end smallexample 1580 1581The length of an array is computed once when the storage is allocated 1582and is remembered for the scope of the array in case you access it with 1583@code{sizeof}. 1584 1585If you want to pass the array first and the length afterward, you can 1586use a forward declaration in the parameter list---another GNU extension. 1587 1588@smallexample 1589struct entry 1590tester (int len; char data[len][len], int len) 1591@{ 1592 /* @r{@dots{}} */ 1593@} 1594@end smallexample 1595 1596@cindex parameter forward declaration 1597The @samp{int len} before the semicolon is a @dfn{parameter forward 1598declaration}, and it serves the purpose of making the name @code{len} 1599known when the declaration of @code{data} is parsed. 1600 1601You can write any number of such parameter forward declarations in the 1602parameter list. They can be separated by commas or semicolons, but the 1603last one must end with a semicolon, which is followed by the ``real'' 1604parameter declarations. Each forward declaration must match a ``real'' 1605declaration in parameter name and data type. ISO C99 does not support 1606parameter forward declarations. 1607 1608@node Variadic Macros 1609@section Macros with a Variable Number of Arguments. 1610@cindex variable number of arguments 1611@cindex macro with variable arguments 1612@cindex rest argument (in macro) 1613@cindex variadic macros 1614 1615In the ISO C standard of 1999, a macro can be declared to accept a 1616variable number of arguments much as a function can. The syntax for 1617defining the macro is similar to that of a function. Here is an 1618example: 1619 1620@smallexample 1621#define debug(format, ...) fprintf (stderr, format, __VA_ARGS__) 1622@end smallexample 1623 1624Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of 1625such a macro, it represents the zero or more tokens until the closing 1626parenthesis that ends the invocation, including any commas. This set of 1627tokens replaces the identifier @code{__VA_ARGS__} in the macro body 1628wherever it appears. See the CPP manual for more information. 1629 1630GCC has long supported variadic macros, and used a different syntax that 1631allowed you to give a name to the variable arguments just like any other 1632argument. Here is an example: 1633 1634@smallexample 1635#define debug(format, args...) fprintf (stderr, format, args) 1636@end smallexample 1637 1638This is in all ways equivalent to the ISO C example above, but arguably 1639more readable and descriptive. 1640 1641GNU CPP has two further variadic macro extensions, and permits them to 1642be used with either of the above forms of macro definition. 1643 1644In standard C, you are not allowed to leave the variable argument out 1645entirely; but you are allowed to pass an empty argument. For example, 1646this invocation is invalid in ISO C, because there is no comma after 1647the string: 1648 1649@smallexample 1650debug ("A message") 1651@end smallexample 1652 1653GNU CPP permits you to completely omit the variable arguments in this 1654way. In the above examples, the compiler would complain, though since 1655the expansion of the macro still has the extra comma after the format 1656string. 1657 1658To help solve this problem, CPP behaves specially for variable arguments 1659used with the token paste operator, @samp{##}. If instead you write 1660 1661@smallexample 1662#define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__) 1663@end smallexample 1664 1665and if the variable arguments are omitted or empty, the @samp{##} 1666operator causes the preprocessor to remove the comma before it. If you 1667do provide some variable arguments in your macro invocation, GNU CPP 1668does not complain about the paste operation and instead places the 1669variable arguments after the comma. Just like any other pasted macro 1670argument, these arguments are not macro expanded. 1671 1672@node Escaped Newlines 1673@section Slightly Looser Rules for Escaped Newlines 1674@cindex escaped newlines 1675@cindex newlines (escaped) 1676 1677Recently, the preprocessor has relaxed its treatment of escaped 1678newlines. Previously, the newline had to immediately follow a 1679backslash. The current implementation allows whitespace in the form 1680of spaces, horizontal and vertical tabs, and form feeds between the 1681backslash and the subsequent newline. The preprocessor issues a 1682warning, but treats it as a valid escaped newline and combines the two 1683lines to form a single logical line. This works within comments and 1684tokens, as well as between tokens. Comments are @emph{not} treated as 1685whitespace for the purposes of this relaxation, since they have not 1686yet been replaced with spaces. 1687 1688@node Subscripting 1689@section Non-Lvalue Arrays May Have Subscripts 1690@cindex subscripting 1691@cindex arrays, non-lvalue 1692 1693@cindex subscripting and function values 1694In ISO C99, arrays that are not lvalues still decay to pointers, and 1695may be subscripted, although they may not be modified or used after 1696the next sequence point and the unary @samp{&} operator may not be 1697applied to them. As an extension, GCC allows such arrays to be 1698subscripted in C90 mode, though otherwise they do not decay to 1699pointers outside C99 mode. For example, 1700this is valid in GNU C though not valid in C90: 1701 1702@smallexample 1703@group 1704struct foo @{int a[4];@}; 1705 1706struct foo f(); 1707 1708bar (int index) 1709@{ 1710 return f().a[index]; 1711@} 1712@end group 1713@end smallexample 1714 1715@node Pointer Arith 1716@section Arithmetic on @code{void}- and Function-Pointers 1717@cindex void pointers, arithmetic 1718@cindex void, size of pointer to 1719@cindex function pointers, arithmetic 1720@cindex function, size of pointer to 1721 1722In GNU C, addition and subtraction operations are supported on pointers to 1723@code{void} and on pointers to functions. This is done by treating the 1724size of a @code{void} or of a function as 1. 1725 1726A consequence of this is that @code{sizeof} is also allowed on @code{void} 1727and on function types, and returns 1. 1728 1729@opindex Wpointer-arith 1730The option @option{-Wpointer-arith} requests a warning if these extensions 1731are used. 1732 1733@node Initializers 1734@section Non-Constant Initializers 1735@cindex initializers, non-constant 1736@cindex non-constant initializers 1737 1738As in standard C++ and ISO C99, the elements of an aggregate initializer for an 1739automatic variable are not required to be constant expressions in GNU C@. 1740Here is an example of an initializer with run-time varying elements: 1741 1742@smallexample 1743foo (float f, float g) 1744@{ 1745 float beat_freqs[2] = @{ f-g, f+g @}; 1746 /* @r{@dots{}} */ 1747@} 1748@end smallexample 1749 1750@node Compound Literals 1751@section Compound Literals 1752@cindex constructor expressions 1753@cindex initializations in expressions 1754@cindex structures, constructor expression 1755@cindex expressions, constructor 1756@cindex compound literals 1757@c The GNU C name for what C99 calls compound literals was "constructor expressions". 1758 1759ISO C99 supports compound literals. A compound literal looks like 1760a cast containing an initializer. Its value is an object of the 1761type specified in the cast, containing the elements specified in 1762the initializer; it is an lvalue. As an extension, GCC supports 1763compound literals in C90 mode and in C++, though the semantics are 1764somewhat different in C++. 1765 1766Usually, the specified type is a structure. Assume that 1767@code{struct foo} and @code{structure} are declared as shown: 1768 1769@smallexample 1770struct foo @{int a; char b[2];@} structure; 1771@end smallexample 1772 1773@noindent 1774Here is an example of constructing a @code{struct foo} with a compound literal: 1775 1776@smallexample 1777structure = ((struct foo) @{x + y, 'a', 0@}); 1778@end smallexample 1779 1780@noindent 1781This is equivalent to writing the following: 1782 1783@smallexample 1784@{ 1785 struct foo temp = @{x + y, 'a', 0@}; 1786 structure = temp; 1787@} 1788@end smallexample 1789 1790You can also construct an array, though this is dangerous in C++, as 1791explained below. If all the elements of the compound literal are 1792(made up of) simple constant expressions, suitable for use in 1793initializers of objects of static storage duration, then the compound 1794literal can be coerced to a pointer to its first element and used in 1795such an initializer, as shown here: 1796 1797@smallexample 1798char **foo = (char *[]) @{ "x", "y", "z" @}; 1799@end smallexample 1800 1801Compound literals for scalar types and union types are 1802also allowed, but then the compound literal is equivalent 1803to a cast. 1804 1805As a GNU extension, GCC allows initialization of objects with static storage 1806duration by compound literals (which is not possible in ISO C99, because 1807the initializer is not a constant). 1808It is handled as if the object was initialized only with the bracket 1809enclosed list if the types of the compound literal and the object match. 1810The initializer list of the compound literal must be constant. 1811If the object being initialized has array type of unknown size, the size is 1812determined by compound literal size. 1813 1814@smallexample 1815static struct foo x = (struct foo) @{1, 'a', 'b'@}; 1816static int y[] = (int []) @{1, 2, 3@}; 1817static int z[] = (int [3]) @{1@}; 1818@end smallexample 1819 1820@noindent 1821The above lines are equivalent to the following: 1822@smallexample 1823static struct foo x = @{1, 'a', 'b'@}; 1824static int y[] = @{1, 2, 3@}; 1825static int z[] = @{1, 0, 0@}; 1826@end smallexample 1827 1828In C, a compound literal designates an unnamed object with static or 1829automatic storage duration. In C++, a compound literal designates a 1830temporary object, which only lives until the end of its 1831full-expression. As a result, well-defined C code that takes the 1832address of a subobject of a compound literal can be undefined in C++. 1833For instance, if the array compound literal example above appeared 1834inside a function, any subsequent use of @samp{foo} in C++ has 1835undefined behavior because the lifetime of the array ends after the 1836declaration of @samp{foo}. As a result, the C++ compiler now rejects 1837the conversion of a temporary array to a pointer. 1838 1839As an optimization, the C++ compiler sometimes gives array compound 1840literals longer lifetimes: when the array either appears outside a 1841function or has const-qualified type. If @samp{foo} and its 1842initializer had elements of @samp{char *const} type rather than 1843@samp{char *}, or if @samp{foo} were a global variable, the array 1844would have static storage duration. But it is probably safest just to 1845avoid the use of array compound literals in code compiled as C++. 1846 1847@node Designated Inits 1848@section Designated Initializers 1849@cindex initializers with labeled elements 1850@cindex labeled elements in initializers 1851@cindex case labels in initializers 1852@cindex designated initializers 1853 1854Standard C90 requires the elements of an initializer to appear in a fixed 1855order, the same as the order of the elements in the array or structure 1856being initialized. 1857 1858In ISO C99 you can give the elements in any order, specifying the array 1859indices or structure field names they apply to, and GNU C allows this as 1860an extension in C90 mode as well. This extension is not 1861implemented in GNU C++. 1862 1863To specify an array index, write 1864@samp{[@var{index}] =} before the element value. For example, 1865 1866@smallexample 1867int a[6] = @{ [4] = 29, [2] = 15 @}; 1868@end smallexample 1869 1870@noindent 1871is equivalent to 1872 1873@smallexample 1874int a[6] = @{ 0, 0, 15, 0, 29, 0 @}; 1875@end smallexample 1876 1877@noindent 1878The index values must be constant expressions, even if the array being 1879initialized is automatic. 1880 1881An alternative syntax for this which has been obsolete since GCC 2.5 but 1882GCC still accepts is to write @samp{[@var{index}]} before the element 1883value, with no @samp{=}. 1884 1885To initialize a range of elements to the same value, write 1886@samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU 1887extension. For example, 1888 1889@smallexample 1890int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @}; 1891@end smallexample 1892 1893@noindent 1894If the value in it has side-effects, the side-effects will happen only once, 1895not for each initialized field by the range initializer. 1896 1897@noindent 1898Note that the length of the array is the highest value specified 1899plus one. 1900 1901In a structure initializer, specify the name of a field to initialize 1902with @samp{.@var{fieldname} =} before the element value. For example, 1903given the following structure, 1904 1905@smallexample 1906struct point @{ int x, y; @}; 1907@end smallexample 1908 1909@noindent 1910the following initialization 1911 1912@smallexample 1913struct point p = @{ .y = yvalue, .x = xvalue @}; 1914@end smallexample 1915 1916@noindent 1917is equivalent to 1918 1919@smallexample 1920struct point p = @{ xvalue, yvalue @}; 1921@end smallexample 1922 1923Another syntax which has the same meaning, obsolete since GCC 2.5, is 1924@samp{@var{fieldname}:}, as shown here: 1925 1926@smallexample 1927struct point p = @{ y: yvalue, x: xvalue @}; 1928@end smallexample 1929 1930@cindex designators 1931The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a 1932@dfn{designator}. You can also use a designator (or the obsolete colon 1933syntax) when initializing a union, to specify which element of the union 1934should be used. For example, 1935 1936@smallexample 1937union foo @{ int i; double d; @}; 1938 1939union foo f = @{ .d = 4 @}; 1940@end smallexample 1941 1942@noindent 1943will convert 4 to a @code{double} to store it in the union using 1944the second element. By contrast, casting 4 to type @code{union foo} 1945would store it into the union as the integer @code{i}, since it is 1946an integer. (@xref{Cast to Union}.) 1947 1948You can combine this technique of naming elements with ordinary C 1949initialization of successive elements. Each initializer element that 1950does not have a designator applies to the next consecutive element of the 1951array or structure. For example, 1952 1953@smallexample 1954int a[6] = @{ [1] = v1, v2, [4] = v4 @}; 1955@end smallexample 1956 1957@noindent 1958is equivalent to 1959 1960@smallexample 1961int a[6] = @{ 0, v1, v2, 0, v4, 0 @}; 1962@end smallexample 1963 1964Labeling the elements of an array initializer is especially useful 1965when the indices are characters or belong to an @code{enum} type. 1966For example: 1967 1968@smallexample 1969int whitespace[256] 1970 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1, 1971 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @}; 1972@end smallexample 1973 1974@cindex designator lists 1975You can also write a series of @samp{.@var{fieldname}} and 1976@samp{[@var{index}]} designators before an @samp{=} to specify a 1977nested subobject to initialize; the list is taken relative to the 1978subobject corresponding to the closest surrounding brace pair. For 1979example, with the @samp{struct point} declaration above: 1980 1981@smallexample 1982struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @}; 1983@end smallexample 1984 1985@noindent 1986If the same field is initialized multiple times, it will have value from 1987the last initialization. If any such overridden initialization has 1988side-effect, it is unspecified whether the side-effect happens or not. 1989Currently, GCC will discard them and issue a warning. 1990 1991@node Case Ranges 1992@section Case Ranges 1993@cindex case ranges 1994@cindex ranges in case statements 1995 1996You can specify a range of consecutive values in a single @code{case} label, 1997like this: 1998 1999@smallexample 2000case @var{low} ... @var{high}: 2001@end smallexample 2002 2003@noindent 2004This has the same effect as the proper number of individual @code{case} 2005labels, one for each integer value from @var{low} to @var{high}, inclusive. 2006 2007This feature is especially useful for ranges of ASCII character codes: 2008 2009@smallexample 2010case 'A' ... 'Z': 2011@end smallexample 2012 2013@strong{Be careful:} Write spaces around the @code{...}, for otherwise 2014it may be parsed wrong when you use it with integer values. For example, 2015write this: 2016 2017@smallexample 2018case 1 ... 5: 2019@end smallexample 2020 2021@noindent 2022rather than this: 2023 2024@smallexample 2025case 1...5: 2026@end smallexample 2027 2028@node Cast to Union 2029@section Cast to a Union Type 2030@cindex cast to a union 2031@cindex union, casting to a 2032 2033A cast to union type is similar to other casts, except that the type 2034specified is a union type. You can specify the type either with 2035@code{union @var{tag}} or with a typedef name. A cast to union is actually 2036a constructor though, not a cast, and hence does not yield an lvalue like 2037normal casts. (@xref{Compound Literals}.) 2038 2039The types that may be cast to the union type are those of the members 2040of the union. Thus, given the following union and variables: 2041 2042@smallexample 2043union foo @{ int i; double d; @}; 2044int x; 2045double y; 2046@end smallexample 2047 2048@noindent 2049both @code{x} and @code{y} can be cast to type @code{union foo}. 2050 2051Using the cast as the right-hand side of an assignment to a variable of 2052union type is equivalent to storing in a member of the union: 2053 2054@smallexample 2055union foo u; 2056/* @r{@dots{}} */ 2057u = (union foo) x @equiv{} u.i = x 2058u = (union foo) y @equiv{} u.d = y 2059@end smallexample 2060 2061You can also use the union cast as a function argument: 2062 2063@smallexample 2064void hack (union foo); 2065/* @r{@dots{}} */ 2066hack ((union foo) x); 2067@end smallexample 2068 2069@node Mixed Declarations 2070@section Mixed Declarations and Code 2071@cindex mixed declarations and code 2072@cindex declarations, mixed with code 2073@cindex code, mixed with declarations 2074 2075ISO C99 and ISO C++ allow declarations and code to be freely mixed 2076within compound statements. As an extension, GCC also allows this in 2077C90 mode. For example, you could do: 2078 2079@smallexample 2080int i; 2081/* @r{@dots{}} */ 2082i++; 2083int j = i + 2; 2084@end smallexample 2085 2086Each identifier is visible from where it is declared until the end of 2087the enclosing block. 2088 2089@node Function Attributes 2090@section Declaring Attributes of Functions 2091@cindex function attributes 2092@cindex declaring attributes of functions 2093@cindex functions that never return 2094@cindex functions that return more than once 2095@cindex functions that have no side effects 2096@cindex functions in arbitrary sections 2097@cindex functions that behave like malloc 2098@cindex @code{volatile} applied to function 2099@cindex @code{const} applied to function 2100@cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments 2101@cindex functions with non-null pointer arguments 2102@cindex functions that are passed arguments in registers on the 386 2103@cindex functions that pop the argument stack on the 386 2104@cindex functions that do not pop the argument stack on the 386 2105@cindex functions that have different compilation options on the 386 2106@cindex functions that have different optimization options 2107@cindex functions that are dynamically resolved 2108 2109In GNU C, you declare certain things about functions called in your program 2110which help the compiler optimize function calls and check your code more 2111carefully. 2112 2113The keyword @code{__attribute__} allows you to specify special 2114attributes when making a declaration. This keyword is followed by an 2115attribute specification inside double parentheses. The following 2116attributes are currently defined for functions on all targets: 2117@code{aligned}, @code{alloc_size}, @code{noreturn}, 2118@code{returns_twice}, @code{noinline}, @code{noclone}, 2119@code{always_inline}, @code{flatten}, @code{pure}, @code{const}, 2120@code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg}, 2121@code{no_instrument_function}, @code{no_split_stack}, 2122@code{section}, @code{constructor}, 2123@code{destructor}, @code{used}, @code{unused}, @code{deprecated}, 2124@code{weak}, @code{malloc}, @code{alias}, @code{ifunc}, 2125@code{warn_unused_result}, @code{nonnull}, @code{gnu_inline}, 2126@code{externally_visible}, @code{hot}, @code{cold}, @code{artificial}, 2127@code{error} and @code{warning}. Several other attributes are defined 2128for functions on particular target systems. Other attributes, 2129including @code{section} are supported for variables declarations 2130(@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}). 2131 2132GCC plugins may provide their own attributes. 2133 2134You may also specify attributes with @samp{__} preceding and following 2135each keyword. This allows you to use them in header files without 2136being concerned about a possible macro of the same name. For example, 2137you may use @code{__noreturn__} instead of @code{noreturn}. 2138 2139@xref{Attribute Syntax}, for details of the exact syntax for using 2140attributes. 2141 2142@table @code 2143@c Keep this table alphabetized by attribute name. Treat _ as space. 2144 2145@item alias ("@var{target}") 2146@cindex @code{alias} attribute 2147The @code{alias} attribute causes the declaration to be emitted as an 2148alias for another symbol, which must be specified. For instance, 2149 2150@smallexample 2151void __f () @{ /* @r{Do something.} */; @} 2152void f () __attribute__ ((weak, alias ("__f"))); 2153@end smallexample 2154 2155defines @samp{f} to be a weak alias for @samp{__f}. In C++, the 2156mangled name for the target must be used. It is an error if @samp{__f} 2157is not defined in the same translation unit. 2158 2159Not all target machines support this attribute. 2160 2161@item aligned (@var{alignment}) 2162@cindex @code{aligned} attribute 2163This attribute specifies a minimum alignment for the function, 2164measured in bytes. 2165 2166You cannot use this attribute to decrease the alignment of a function, 2167only to increase it. However, when you explicitly specify a function 2168alignment this will override the effect of the 2169@option{-falign-functions} (@pxref{Optimize Options}) option for this 2170function. 2171 2172Note that the effectiveness of @code{aligned} attributes may be 2173limited by inherent limitations in your linker. On many systems, the 2174linker is only able to arrange for functions to be aligned up to a 2175certain maximum alignment. (For some linkers, the maximum supported 2176alignment may be very very small.) See your linker documentation for 2177further information. 2178 2179The @code{aligned} attribute can also be used for variables and fields 2180(@pxref{Variable Attributes}.) 2181 2182@item alloc_size 2183@cindex @code{alloc_size} attribute 2184The @code{alloc_size} attribute is used to tell the compiler that the 2185function return value points to memory, where the size is given by 2186one or two of the functions parameters. GCC uses this 2187information to improve the correctness of @code{__builtin_object_size}. 2188 2189The function parameter(s) denoting the allocated size are specified by 2190one or two integer arguments supplied to the attribute. The allocated size 2191is either the value of the single function argument specified or the product 2192of the two function arguments specified. Argument numbering starts at 2193one. 2194 2195For instance, 2196 2197@smallexample 2198void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2))) 2199void my_realloc(void*, size_t) __attribute__((alloc_size(2))) 2200@end smallexample 2201 2202declares that my_calloc will return memory of the size given by 2203the product of parameter 1 and 2 and that my_realloc will return memory 2204of the size given by parameter 2. 2205 2206@item always_inline 2207@cindex @code{always_inline} function attribute 2208Generally, functions are not inlined unless optimization is specified. 2209For functions declared inline, this attribute inlines the function even 2210if no optimization level was specified. 2211 2212@item gnu_inline 2213@cindex @code{gnu_inline} function attribute 2214This attribute should be used with a function which is also declared 2215with the @code{inline} keyword. It directs GCC to treat the function 2216as if it were defined in gnu90 mode even when compiling in C99 or 2217gnu99 mode. 2218 2219If the function is declared @code{extern}, then this definition of the 2220function is used only for inlining. In no case is the function 2221compiled as a standalone function, not even if you take its address 2222explicitly. Such an address becomes an external reference, as if you 2223had only declared the function, and had not defined it. This has 2224almost the effect of a macro. The way to use this is to put a 2225function definition in a header file with this attribute, and put 2226another copy of the function, without @code{extern}, in a library 2227file. The definition in the header file will cause most calls to the 2228function to be inlined. If any uses of the function remain, they will 2229refer to the single copy in the library. Note that the two 2230definitions of the functions need not be precisely the same, although 2231if they do not have the same effect your program may behave oddly. 2232 2233In C, if the function is neither @code{extern} nor @code{static}, then 2234the function is compiled as a standalone function, as well as being 2235inlined where possible. 2236 2237This is how GCC traditionally handled functions declared 2238@code{inline}. Since ISO C99 specifies a different semantics for 2239@code{inline}, this function attribute is provided as a transition 2240measure and as a useful feature in its own right. This attribute is 2241available in GCC 4.1.3 and later. It is available if either of the 2242preprocessor macros @code{__GNUC_GNU_INLINE__} or 2243@code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline 2244Function is As Fast As a Macro}. 2245 2246In C++, this attribute does not depend on @code{extern} in any way, 2247but it still requires the @code{inline} keyword to enable its special 2248behavior. 2249 2250@item artificial 2251@cindex @code{artificial} function attribute 2252This attribute is useful for small inline wrappers which if possible 2253should appear during debugging as a unit, depending on the debug 2254info format it will either mean marking the function as artificial 2255or using the caller location for all instructions within the inlined 2256body. 2257 2258@item bank_switch 2259@cindex interrupt handler functions 2260When added to an interrupt handler with the M32C port, causes the 2261prologue and epilogue to use bank switching to preserve the registers 2262rather than saving them on the stack. 2263 2264@item flatten 2265@cindex @code{flatten} function attribute 2266Generally, inlining into a function is limited. For a function marked with 2267this attribute, every call inside this function will be inlined, if possible. 2268Whether the function itself is considered for inlining depends on its size and 2269the current inlining parameters. 2270 2271@item error ("@var{message}") 2272@cindex @code{error} function attribute 2273If this attribute is used on a function declaration and a call to such a function 2274is not eliminated through dead code elimination or other optimizations, an error 2275which will include @var{message} will be diagnosed. This is useful 2276for compile time checking, especially together with @code{__builtin_constant_p} 2277and inline functions where checking the inline function arguments is not 2278possible through @code{extern char [(condition) ? 1 : -1];} tricks. 2279While it is possible to leave the function undefined and thus invoke 2280a link failure, when using this attribute the problem will be diagnosed 2281earlier and with exact location of the call even in presence of inline 2282functions or when not emitting debugging information. 2283 2284@item warning ("@var{message}") 2285@cindex @code{warning} function attribute 2286If this attribute is used on a function declaration and a call to such a function 2287is not eliminated through dead code elimination or other optimizations, a warning 2288which will include @var{message} will be diagnosed. This is useful 2289for compile time checking, especially together with @code{__builtin_constant_p} 2290and inline functions. While it is possible to define the function with 2291a message in @code{.gnu.warning*} section, when using this attribute the problem 2292will be diagnosed earlier and with exact location of the call even in presence 2293of inline functions or when not emitting debugging information. 2294 2295@item cdecl 2296@cindex functions that do pop the argument stack on the 386 2297@opindex mrtd 2298On the Intel 386, the @code{cdecl} attribute causes the compiler to 2299assume that the calling function will pop off the stack space used to 2300pass arguments. This is 2301useful to override the effects of the @option{-mrtd} switch. 2302 2303@item const 2304@cindex @code{const} function attribute 2305Many functions do not examine any values except their arguments, and 2306have no effects except the return value. Basically this is just slightly 2307more strict class than the @code{pure} attribute below, since function is not 2308allowed to read global memory. 2309 2310@cindex pointer arguments 2311Note that a function that has pointer arguments and examines the data 2312pointed to must @emph{not} be declared @code{const}. Likewise, a 2313function that calls a non-@code{const} function usually must not be 2314@code{const}. It does not make sense for a @code{const} function to 2315return @code{void}. 2316 2317The attribute @code{const} is not implemented in GCC versions earlier 2318than 2.5. An alternative way to declare that a function has no side 2319effects, which works in the current version and in some older versions, 2320is as follows: 2321 2322@smallexample 2323typedef int intfn (); 2324 2325extern const intfn square; 2326@end smallexample 2327 2328This approach does not work in GNU C++ from 2.6.0 on, since the language 2329specifies that the @samp{const} must be attached to the return value. 2330 2331@item constructor 2332@itemx destructor 2333@itemx constructor (@var{priority}) 2334@itemx destructor (@var{priority}) 2335@cindex @code{constructor} function attribute 2336@cindex @code{destructor} function attribute 2337The @code{constructor} attribute causes the function to be called 2338automatically before execution enters @code{main ()}. Similarly, the 2339@code{destructor} attribute causes the function to be called 2340automatically after @code{main ()} has completed or @code{exit ()} has 2341been called. Functions with these attributes are useful for 2342initializing data that will be used implicitly during the execution of 2343the program. 2344 2345You may provide an optional integer priority to control the order in 2346which constructor and destructor functions are run. A constructor 2347with a smaller priority number runs before a constructor with a larger 2348priority number; the opposite relationship holds for destructors. So, 2349if you have a constructor that allocates a resource and a destructor 2350that deallocates the same resource, both functions typically have the 2351same priority. The priorities for constructor and destructor 2352functions are the same as those specified for namespace-scope C++ 2353objects (@pxref{C++ Attributes}). 2354 2355These attributes are not currently implemented for Objective-C@. 2356 2357@item deprecated 2358@itemx deprecated (@var{msg}) 2359@cindex @code{deprecated} attribute. 2360The @code{deprecated} attribute results in a warning if the function 2361is used anywhere in the source file. This is useful when identifying 2362functions that are expected to be removed in a future version of a 2363program. The warning also includes the location of the declaration 2364of the deprecated function, to enable users to easily find further 2365information about why the function is deprecated, or what they should 2366do instead. Note that the warnings only occurs for uses: 2367 2368@smallexample 2369int old_fn () __attribute__ ((deprecated)); 2370int old_fn (); 2371int (*fn_ptr)() = old_fn; 2372@end smallexample 2373 2374results in a warning on line 3 but not line 2. The optional msg 2375argument, which must be a string, will be printed in the warning if 2376present. 2377 2378The @code{deprecated} attribute can also be used for variables and 2379types (@pxref{Variable Attributes}, @pxref{Type Attributes}.) 2380 2381@item disinterrupt 2382@cindex @code{disinterrupt} attribute 2383On Epiphany and MeP targets, this attribute causes the compiler to emit 2384instructions to disable interrupts for the duration of the given 2385function. 2386 2387@item dllexport 2388@cindex @code{__declspec(dllexport)} 2389On Microsoft Windows targets and Symbian OS targets the 2390@code{dllexport} attribute causes the compiler to provide a global 2391pointer to a pointer in a DLL, so that it can be referenced with the 2392@code{dllimport} attribute. On Microsoft Windows targets, the pointer 2393name is formed by combining @code{_imp__} and the function or variable 2394name. 2395 2396You can use @code{__declspec(dllexport)} as a synonym for 2397@code{__attribute__ ((dllexport))} for compatibility with other 2398compilers. 2399 2400On systems that support the @code{visibility} attribute, this 2401attribute also implies ``default'' visibility. It is an error to 2402explicitly specify any other visibility. 2403 2404In previous versions of GCC, the @code{dllexport} attribute was ignored 2405for inlined functions, unless the @option{-fkeep-inline-functions} flag 2406had been used. The default behaviour now is to emit all dllexported 2407inline functions; however, this can cause object file-size bloat, in 2408which case the old behaviour can be restored by using 2409@option{-fno-keep-inline-dllexport}. 2410 2411The attribute is also ignored for undefined symbols. 2412 2413When applied to C++ classes, the attribute marks defined non-inlined 2414member functions and static data members as exports. Static consts 2415initialized in-class are not marked unless they are also defined 2416out-of-class. 2417 2418For Microsoft Windows targets there are alternative methods for 2419including the symbol in the DLL's export table such as using a 2420@file{.def} file with an @code{EXPORTS} section or, with GNU ld, using 2421the @option{--export-all} linker flag. 2422 2423@item dllimport 2424@cindex @code{__declspec(dllimport)} 2425On Microsoft Windows and Symbian OS targets, the @code{dllimport} 2426attribute causes the compiler to reference a function or variable via 2427a global pointer to a pointer that is set up by the DLL exporting the 2428symbol. The attribute implies @code{extern}. On Microsoft Windows 2429targets, the pointer name is formed by combining @code{_imp__} and the 2430function or variable name. 2431 2432You can use @code{__declspec(dllimport)} as a synonym for 2433@code{__attribute__ ((dllimport))} for compatibility with other 2434compilers. 2435 2436On systems that support the @code{visibility} attribute, this 2437attribute also implies ``default'' visibility. It is an error to 2438explicitly specify any other visibility. 2439 2440Currently, the attribute is ignored for inlined functions. If the 2441attribute is applied to a symbol @emph{definition}, an error is reported. 2442If a symbol previously declared @code{dllimport} is later defined, the 2443attribute is ignored in subsequent references, and a warning is emitted. 2444The attribute is also overridden by a subsequent declaration as 2445@code{dllexport}. 2446 2447When applied to C++ classes, the attribute marks non-inlined 2448member functions and static data members as imports. However, the 2449attribute is ignored for virtual methods to allow creation of vtables 2450using thunks. 2451 2452On the SH Symbian OS target the @code{dllimport} attribute also has 2453another affect---it can cause the vtable and run-time type information 2454for a class to be exported. This happens when the class has a 2455dllimport'ed constructor or a non-inline, non-pure virtual function 2456and, for either of those two conditions, the class also has an inline 2457constructor or destructor and has a key function that is defined in 2458the current translation unit. 2459 2460For Microsoft Windows based targets the use of the @code{dllimport} 2461attribute on functions is not necessary, but provides a small 2462performance benefit by eliminating a thunk in the DLL@. The use of the 2463@code{dllimport} attribute on imported variables was required on older 2464versions of the GNU linker, but can now be avoided by passing the 2465@option{--enable-auto-import} switch to the GNU linker. As with 2466functions, using the attribute for a variable eliminates a thunk in 2467the DLL@. 2468 2469One drawback to using this attribute is that a pointer to a 2470@emph{variable} marked as @code{dllimport} cannot be used as a constant 2471address. However, a pointer to a @emph{function} with the 2472@code{dllimport} attribute can be used as a constant initializer; in 2473this case, the address of a stub function in the import lib is 2474referenced. On Microsoft Windows targets, the attribute can be disabled 2475for functions by setting the @option{-mnop-fun-dllimport} flag. 2476 2477@item eightbit_data 2478@cindex eight bit data on the H8/300, H8/300H, and H8S 2479Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified 2480variable should be placed into the eight bit data section. 2481The compiler will generate more efficient code for certain operations 2482on data in the eight bit data area. Note the eight bit data area is limited to 2483256 bytes of data. 2484 2485You must use GAS and GLD from GNU binutils version 2.7 or later for 2486this attribute to work correctly. 2487 2488@item exception_handler 2489@cindex exception handler functions on the Blackfin processor 2490Use this attribute on the Blackfin to indicate that the specified function 2491is an exception handler. The compiler will generate function entry and 2492exit sequences suitable for use in an exception handler when this 2493attribute is present. 2494 2495@item externally_visible 2496@cindex @code{externally_visible} attribute. 2497This attribute, attached to a global variable or function, nullifies 2498the effect of the @option{-fwhole-program} command-line option, so the 2499object remains visible outside the current compilation unit. If @option{-fwhole-program} is used together with @option{-flto} and @command{gold} is used as the linker plugin, @code{externally_visible} attributes are automatically added to functions (not variable yet due to a current @command{gold} issue) that are accessed outside of LTO objects according to resolution file produced by @command{gold}. For other linkers that cannot generate resolution file, explicit @code{externally_visible} attributes are still necessary. 2500 2501@item far 2502@cindex functions which handle memory bank switching 2503On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to 2504use a calling convention that takes care of switching memory banks when 2505entering and leaving a function. This calling convention is also the 2506default when using the @option{-mlong-calls} option. 2507 2508On 68HC12 the compiler will use the @code{call} and @code{rtc} instructions 2509to call and return from a function. 2510 2511On 68HC11 the compiler will generate a sequence of instructions 2512to invoke a board-specific routine to switch the memory bank and call the 2513real function. The board-specific routine simulates a @code{call}. 2514At the end of a function, it will jump to a board-specific routine 2515instead of using @code{rts}. The board-specific return routine simulates 2516the @code{rtc}. 2517 2518On MeP targets this causes the compiler to use a calling convention 2519which assumes the called function is too far away for the built-in 2520addressing modes. 2521 2522@item fast_interrupt 2523@cindex interrupt handler functions 2524Use this attribute on the M32C and RX ports to indicate that the specified 2525function is a fast interrupt handler. This is just like the 2526@code{interrupt} attribute, except that @code{freit} is used to return 2527instead of @code{reit}. 2528 2529@item fastcall 2530@cindex functions that pop the argument stack on the 386 2531On the Intel 386, the @code{fastcall} attribute causes the compiler to 2532pass the first argument (if of integral type) in the register ECX and 2533the second argument (if of integral type) in the register EDX@. Subsequent 2534and other typed arguments are passed on the stack. The called function will 2535pop the arguments off the stack. If the number of arguments is variable all 2536arguments are pushed on the stack. 2537 2538@item thiscall 2539@cindex functions that pop the argument stack on the 386 2540On the Intel 386, the @code{thiscall} attribute causes the compiler to 2541pass the first argument (if of integral type) in the register ECX. 2542Subsequent and other typed arguments are passed on the stack. The called 2543function will pop the arguments off the stack. 2544If the number of arguments is variable all arguments are pushed on the 2545stack. 2546The @code{thiscall} attribute is intended for C++ non-static member functions. 2547As gcc extension this calling convention can be used for C-functions 2548and for static member methods. 2549 2550@item format (@var{archetype}, @var{string-index}, @var{first-to-check}) 2551@cindex @code{format} function attribute 2552@opindex Wformat 2553The @code{format} attribute specifies that a function takes @code{printf}, 2554@code{scanf}, @code{strftime} or @code{strfmon} style arguments which 2555should be type-checked against a format string. For example, the 2556declaration: 2557 2558@smallexample 2559extern int 2560my_printf (void *my_object, const char *my_format, ...) 2561 __attribute__ ((format (printf, 2, 3))); 2562@end smallexample 2563 2564@noindent 2565causes the compiler to check the arguments in calls to @code{my_printf} 2566for consistency with the @code{printf} style format string argument 2567@code{my_format}. 2568 2569The parameter @var{archetype} determines how the format string is 2570interpreted, and should be @code{printf}, @code{scanf}, @code{strftime}, 2571@code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or 2572@code{strfmon}. (You can also use @code{__printf__}, 2573@code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On 2574MinGW targets, @code{ms_printf}, @code{ms_scanf}, and 2575@code{ms_strftime} are also present. 2576@var{archtype} values such as @code{printf} refer to the formats accepted 2577by the system's C run-time library, while @code{gnu_} values always refer 2578to the formats accepted by the GNU C Library. On Microsoft Windows 2579targets, @code{ms_} values refer to the formats accepted by the 2580@file{msvcrt.dll} library. 2581The parameter @var{string-index} 2582specifies which argument is the format string argument (starting 2583from 1), while @var{first-to-check} is the number of the first 2584argument to check against the format string. For functions 2585where the arguments are not available to be checked (such as 2586@code{vprintf}), specify the third parameter as zero. In this case the 2587compiler only checks the format string for consistency. For 2588@code{strftime} formats, the third parameter is required to be zero. 2589Since non-static C++ methods have an implicit @code{this} argument, the 2590arguments of such methods should be counted from two, not one, when 2591giving values for @var{string-index} and @var{first-to-check}. 2592 2593In the example above, the format string (@code{my_format}) is the second 2594argument of the function @code{my_print}, and the arguments to check 2595start with the third argument, so the correct parameters for the format 2596attribute are 2 and 3. 2597 2598@opindex ffreestanding 2599@opindex fno-builtin 2600The @code{format} attribute allows you to identify your own functions 2601which take format strings as arguments, so that GCC can check the 2602calls to these functions for errors. The compiler always (unless 2603@option{-ffreestanding} or @option{-fno-builtin} is used) checks formats 2604for the standard library functions @code{printf}, @code{fprintf}, 2605@code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime}, 2606@code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such 2607warnings are requested (using @option{-Wformat}), so there is no need to 2608modify the header file @file{stdio.h}. In C99 mode, the functions 2609@code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and 2610@code{vsscanf} are also checked. Except in strictly conforming C 2611standard modes, the X/Open function @code{strfmon} is also checked as 2612are @code{printf_unlocked} and @code{fprintf_unlocked}. 2613@xref{C Dialect Options,,Options Controlling C Dialect}. 2614 2615For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is 2616recognized in the same context. Declarations including these format attributes 2617will be parsed for correct syntax, however the result of checking of such format 2618strings is not yet defined, and will not be carried out by this version of the 2619compiler. 2620 2621The target may also provide additional types of format checks. 2622@xref{Target Format Checks,,Format Checks Specific to Particular 2623Target Machines}. 2624 2625@item format_arg (@var{string-index}) 2626@cindex @code{format_arg} function attribute 2627@opindex Wformat-nonliteral 2628The @code{format_arg} attribute specifies that a function takes a format 2629string for a @code{printf}, @code{scanf}, @code{strftime} or 2630@code{strfmon} style function and modifies it (for example, to translate 2631it into another language), so the result can be passed to a 2632@code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style 2633function (with the remaining arguments to the format function the same 2634as they would have been for the unmodified string). For example, the 2635declaration: 2636 2637@smallexample 2638extern char * 2639my_dgettext (char *my_domain, const char *my_format) 2640 __attribute__ ((format_arg (2))); 2641@end smallexample 2642 2643@noindent 2644causes the compiler to check the arguments in calls to a @code{printf}, 2645@code{scanf}, @code{strftime} or @code{strfmon} type function, whose 2646format string argument is a call to the @code{my_dgettext} function, for 2647consistency with the format string argument @code{my_format}. If the 2648@code{format_arg} attribute had not been specified, all the compiler 2649could tell in such calls to format functions would be that the format 2650string argument is not constant; this would generate a warning when 2651@option{-Wformat-nonliteral} is used, but the calls could not be checked 2652without the attribute. 2653 2654The parameter @var{string-index} specifies which argument is the format 2655string argument (starting from one). Since non-static C++ methods have 2656an implicit @code{this} argument, the arguments of such methods should 2657be counted from two. 2658 2659The @code{format-arg} attribute allows you to identify your own 2660functions which modify format strings, so that GCC can check the 2661calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} 2662type function whose operands are a call to one of your own function. 2663The compiler always treats @code{gettext}, @code{dgettext}, and 2664@code{dcgettext} in this manner except when strict ISO C support is 2665requested by @option{-ansi} or an appropriate @option{-std} option, or 2666@option{-ffreestanding} or @option{-fno-builtin} 2667is used. @xref{C Dialect Options,,Options 2668Controlling C Dialect}. 2669 2670For Objective-C dialects, the @code{format-arg} attribute may refer to an 2671@code{NSString} reference for compatibility with the @code{format} attribute 2672above. 2673 2674The target may also allow additional types in @code{format-arg} attributes. 2675@xref{Target Format Checks,,Format Checks Specific to Particular 2676Target Machines}. 2677 2678@item function_vector 2679@cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors 2680Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified 2681function should be called through the function vector. Calling a 2682function through the function vector will reduce code size, however; 2683the function vector has a limited size (maximum 128 entries on the H8/300 2684and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector. 2685 2686In SH2A target, this attribute declares a function to be called using the 2687TBR relative addressing mode. The argument to this attribute is the entry 2688number of the same function in a vector table containing all the TBR 2689relative addressable functions. For the successful jump, register TBR 2690should contain the start address of this TBR relative vector table. 2691In the startup routine of the user application, user needs to care of this 2692TBR register initialization. The TBR relative vector table can have at 2693max 256 function entries. The jumps to these functions will be generated 2694using a SH2A specific, non delayed branch instruction JSR/N @@(disp8,TBR). 2695You must use GAS and GLD from GNU binutils version 2.7 or later for 2696this attribute to work correctly. 2697 2698Please refer the example of M16C target, to see the use of this 2699attribute while declaring a function, 2700 2701In an application, for a function being called once, this attribute will 2702save at least 8 bytes of code; and if other successive calls are being 2703made to the same function, it will save 2 bytes of code per each of these 2704calls. 2705 2706On M16C/M32C targets, the @code{function_vector} attribute declares a 2707special page subroutine call function. Use of this attribute reduces 2708the code size by 2 bytes for each call generated to the 2709subroutine. The argument to the attribute is the vector number entry 2710from the special page vector table which contains the 16 low-order 2711bits of the subroutine's entry address. Each vector table has special 2712page number (18 to 255) which are used in @code{jsrs} instruction. 2713Jump addresses of the routines are generated by adding 0x0F0000 (in 2714case of M16C targets) or 0xFF0000 (in case of M32C targets), to the 2 2715byte addresses set in the vector table. Therefore you need to ensure 2716that all the special page vector routines should get mapped within the 2717address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF 2718(for M32C). 2719 2720In the following example 2 bytes will be saved for each call to 2721function @code{foo}. 2722 2723@smallexample 2724void foo (void) __attribute__((function_vector(0x18))); 2725void foo (void) 2726@{ 2727@} 2728 2729void bar (void) 2730@{ 2731 foo(); 2732@} 2733@end smallexample 2734 2735If functions are defined in one file and are called in another file, 2736then be sure to write this declaration in both files. 2737 2738This attribute is ignored for R8C target. 2739 2740@item ifunc ("@var{resolver}") 2741@cindex @code{ifunc} attribute 2742The @code{ifunc} attribute is used to mark a function as an indirect 2743function using the STT_GNU_IFUNC symbol type extension to the ELF 2744standard. This allows the resolution of the symbol value to be 2745determined dynamically at load time, and an optimized version of the 2746routine can be selected for the particular processor or other system 2747characteristics determined then. To use this attribute, first define 2748the implementation functions available, and a resolver function that 2749returns a pointer to the selected implementation function. The 2750implementation functions' declarations must match the API of the 2751function being implemented, the resolver's declaration is be a 2752function returning pointer to void function returning void: 2753 2754@smallexample 2755void *my_memcpy (void *dst, const void *src, size_t len) 2756@{ 2757 @dots{} 2758@} 2759 2760static void (*resolve_memcpy (void)) (void) 2761@{ 2762 return my_memcpy; // we'll just always select this routine 2763@} 2764@end smallexample 2765 2766The exported header file declaring the function the user calls would 2767contain: 2768 2769@smallexample 2770extern void *memcpy (void *, const void *, size_t); 2771@end smallexample 2772 2773allowing the user to call this as a regular function, unaware of the 2774implementation. Finally, the indirect function needs to be defined in 2775the same translation unit as the resolver function: 2776 2777@smallexample 2778void *memcpy (void *, const void *, size_t) 2779 __attribute__ ((ifunc ("resolve_memcpy"))); 2780@end smallexample 2781 2782Indirect functions cannot be weak, and require a recent binutils (at 2783least version 2.20.1), and GNU C library (at least version 2.11.1). 2784 2785@item interrupt 2786@cindex interrupt handler functions 2787Use this attribute on the ARM, AVR, CR16, Epiphany, M32C, M32R/D, m68k, MeP, MIPS, 2788RL78, RX and Xstormy16 ports to indicate that the specified function is an 2789interrupt handler. The compiler will generate function entry and exit 2790sequences suitable for use in an interrupt handler when this attribute 2791is present. With Epiphany targets it may also generate a special section with 2792code to initialize the interrupt vector table. 2793 2794Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze, 2795and SH processors can be specified via the @code{interrupt_handler} attribute. 2796 2797Note, on the AVR, the hardware globally disables interrupts when an 2798interrupt is executed. The first instruction of an interrupt handler 2799declared with this attribute will be a @code{SEI} instruction to 2800re-enable interrupts. See also the @code{signal} function attribute 2801that does not insert a @code{SEI} instuction. If both @code{signal} and 2802@code{interrupt} are specified for the same function, @code{signal} 2803will be silently ignored. 2804 2805Note, for the ARM, you can specify the kind of interrupt to be handled by 2806adding an optional parameter to the interrupt attribute like this: 2807 2808@smallexample 2809void f () __attribute__ ((interrupt ("IRQ"))); 2810@end smallexample 2811 2812Permissible values for this parameter are: IRQ, FIQ, SWI, ABORT and UNDEF@. 2813 2814On ARMv7-M the interrupt type is ignored, and the attribute means the function 2815may be called with a word aligned stack pointer. 2816 2817On Epiphany targets one or more optional parameters can be added like this: 2818 2819@smallexample 2820void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler (); 2821@end smallexample 2822 2823Permissible values for these parameters are: @w{@code{reset}}, 2824@w{@code{software_exception}}, @w{@code{page_miss}}, 2825@w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}}, 2826@w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}. 2827Multiple parameters indicate that multiple entries in the interrupt 2828vector table should be initialized for this function, i.e. for each 2829parameter @w{@var{name}}, a jump to the function will be emitted in 2830the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted 2831entirely, in which case no interrupt vector table entry will be provided. 2832 2833Note, on Epiphany targets, interrupts are enabled inside the function 2834unless the @code{disinterrupt} attribute is also specified. 2835 2836On Epiphany targets, you can also use the following attribute to 2837modify the behavior of an interrupt handler: 2838@table @code 2839@item forwarder_section 2840@cindex @code{forwarder_section} attribute 2841The interrupt handler may be in external memory which cannot be 2842reached by a branch instruction, so generate a local memory trampoline 2843to transfer control. The single parameter identifies the section where 2844the trampoline will be placed. 2845@end table 2846 2847The following examples are all valid uses of these attributes on 2848Epiphany targets: 2849@smallexample 2850void __attribute__ ((interrupt)) universal_handler (); 2851void __attribute__ ((interrupt ("dma1"))) dma1_handler (); 2852void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler (); 2853void __attribute__ ((interrupt ("timer0"), disinterrupt)) 2854 fast_timer_handler (); 2855void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp"))) 2856 external_dma_handler (); 2857@end smallexample 2858 2859On MIPS targets, you can use the following attributes to modify the behavior 2860of an interrupt handler: 2861@table @code 2862@item use_shadow_register_set 2863@cindex @code{use_shadow_register_set} attribute 2864Assume that the handler uses a shadow register set, instead of 2865the main general-purpose registers. 2866 2867@item keep_interrupts_masked 2868@cindex @code{keep_interrupts_masked} attribute 2869Keep interrupts masked for the whole function. Without this attribute, 2870GCC tries to reenable interrupts for as much of the function as it can. 2871 2872@item use_debug_exception_return 2873@cindex @code{use_debug_exception_return} attribute 2874Return using the @code{deret} instruction. Interrupt handlers that don't 2875have this attribute return using @code{eret} instead. 2876@end table 2877 2878You can use any combination of these attributes, as shown below: 2879@smallexample 2880void __attribute__ ((interrupt)) v0 (); 2881void __attribute__ ((interrupt, use_shadow_register_set)) v1 (); 2882void __attribute__ ((interrupt, keep_interrupts_masked)) v2 (); 2883void __attribute__ ((interrupt, use_debug_exception_return)) v3 (); 2884void __attribute__ ((interrupt, use_shadow_register_set, 2885 keep_interrupts_masked)) v4 (); 2886void __attribute__ ((interrupt, use_shadow_register_set, 2887 use_debug_exception_return)) v5 (); 2888void __attribute__ ((interrupt, keep_interrupts_masked, 2889 use_debug_exception_return)) v6 (); 2890void __attribute__ ((interrupt, use_shadow_register_set, 2891 keep_interrupts_masked, 2892 use_debug_exception_return)) v7 (); 2893@end smallexample 2894 2895On RL78, use @code{brk_interrupt} instead of @code{interrupt} for 2896handlers intended to be used with the @code{BRK} opcode (i.e. those 2897that must end with @code{RETB} instead of @code{RETI}). 2898 2899@item interrupt_handler 2900@cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors 2901Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to 2902indicate that the specified function is an interrupt handler. The compiler 2903will generate function entry and exit sequences suitable for use in an 2904interrupt handler when this attribute is present. 2905 2906@item interrupt_thread 2907@cindex interrupt thread functions on fido 2908Use this attribute on fido, a subarchitecture of the m68k, to indicate 2909that the specified function is an interrupt handler that is designed 2910to run as a thread. The compiler omits generate prologue/epilogue 2911sequences and replaces the return instruction with a @code{sleep} 2912instruction. This attribute is available only on fido. 2913 2914@item isr 2915@cindex interrupt service routines on ARM 2916Use this attribute on ARM to write Interrupt Service Routines. This is an 2917alias to the @code{interrupt} attribute above. 2918 2919@item kspisusp 2920@cindex User stack pointer in interrupts on the Blackfin 2921When used together with @code{interrupt_handler}, @code{exception_handler} 2922or @code{nmi_handler}, code will be generated to load the stack pointer 2923from the USP register in the function prologue. 2924 2925@item l1_text 2926@cindex @code{l1_text} function attribute 2927This attribute specifies a function to be placed into L1 Instruction 2928SRAM@. The function will be put into a specific section named @code{.l1.text}. 2929With @option{-mfdpic}, function calls with a such function as the callee 2930or caller will use inlined PLT. 2931 2932@item l2 2933@cindex @code{l2} function attribute 2934On the Blackfin, this attribute specifies a function to be placed into L2 2935SRAM. The function will be put into a specific section named 2936@code{.l1.text}. With @option{-mfdpic}, callers of such functions will use 2937an inlined PLT. 2938 2939@item leaf 2940@cindex @code{leaf} function attribute 2941Calls to external functions with this attribute must return to the current 2942compilation unit only by return or by exception handling. In particular, leaf 2943functions are not allowed to call callback function passed to it from the current 2944compilation unit or directly call functions exported by the unit or longjmp 2945into the unit. Leaf function might still call functions from other compilation 2946units and thus they are not necessarily leaf in the sense that they contain no 2947function calls at all. 2948 2949The attribute is intended for library functions to improve dataflow analysis. 2950The compiler takes the hint that any data not escaping the current compilation unit can 2951not be used or modified by the leaf function. For example, the @code{sin} function 2952is a leaf function, but @code{qsort} is not. 2953 2954Note that leaf functions might invoke signals and signal handlers might be 2955defined in the current compilation unit and use static variables. The only 2956compliant way to write such a signal handler is to declare such variables 2957@code{volatile}. 2958 2959The attribute has no effect on functions defined within the current compilation 2960unit. This is to allow easy merging of multiple compilation units into one, 2961for example, by using the link time optimization. For this reason the 2962attribute is not allowed on types to annotate indirect calls. 2963 2964@item long_call/short_call 2965@cindex indirect calls on ARM 2966This attribute specifies how a particular function is called on 2967ARM and Epiphany. Both attributes override the 2968@option{-mlong-calls} (@pxref{ARM Options}) 2969command-line switch and @code{#pragma long_calls} settings. The 2970@code{long_call} attribute indicates that the function might be far 2971away from the call site and require a different (more expensive) 2972calling sequence. The @code{short_call} attribute always places 2973the offset to the function from the call site into the @samp{BL} 2974instruction directly. 2975 2976@item longcall/shortcall 2977@cindex functions called via pointer on the RS/6000 and PowerPC 2978On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute 2979indicates that the function might be far away from the call site and 2980require a different (more expensive) calling sequence. The 2981@code{shortcall} attribute indicates that the function is always close 2982enough for the shorter calling sequence to be used. These attributes 2983override both the @option{-mlongcall} switch and, on the RS/6000 and 2984PowerPC, the @code{#pragma longcall} setting. 2985 2986@xref{RS/6000 and PowerPC Options}, for more information on whether long 2987calls are necessary. 2988 2989@item long_call/near/far 2990@cindex indirect calls on MIPS 2991These attributes specify how a particular function is called on MIPS@. 2992The attributes override the @option{-mlong-calls} (@pxref{MIPS Options}) 2993command-line switch. The @code{long_call} and @code{far} attributes are 2994synonyms, and cause the compiler to always call 2995the function by first loading its address into a register, and then using 2996the contents of that register. The @code{near} attribute has the opposite 2997effect; it specifies that non-PIC calls should be made using the more 2998efficient @code{jal} instruction. 2999 3000@item malloc 3001@cindex @code{malloc} attribute 3002The @code{malloc} attribute is used to tell the compiler that a function 3003may be treated as if any non-@code{NULL} pointer it returns cannot 3004alias any other pointer valid when the function returns and that the memory 3005has undefined content. 3006This will often improve optimization. 3007Standard functions with this property include @code{malloc} and 3008@code{calloc}. @code{realloc}-like functions do not have this 3009property as the memory pointed to does not have undefined content. 3010 3011@item mips16/nomips16 3012@cindex @code{mips16} attribute 3013@cindex @code{nomips16} attribute 3014 3015On MIPS targets, you can use the @code{mips16} and @code{nomips16} 3016function attributes to locally select or turn off MIPS16 code generation. 3017A function with the @code{mips16} attribute is emitted as MIPS16 code, 3018while MIPS16 code generation is disabled for functions with the 3019@code{nomips16} attribute. These attributes override the 3020@option{-mips16} and @option{-mno-mips16} options on the command line 3021(@pxref{MIPS Options}). 3022 3023When compiling files containing mixed MIPS16 and non-MIPS16 code, the 3024preprocessor symbol @code{__mips16} reflects the setting on the command line, 3025not that within individual functions. Mixed MIPS16 and non-MIPS16 code 3026may interact badly with some GCC extensions such as @code{__builtin_apply} 3027(@pxref{Constructing Calls}). 3028 3029@item model (@var{model-name}) 3030@cindex function addressability on the M32R/D 3031@cindex variable addressability on the IA-64 3032 3033On the M32R/D, use this attribute to set the addressability of an 3034object, and of the code generated for a function. The identifier 3035@var{model-name} is one of @code{small}, @code{medium}, or 3036@code{large}, representing each of the code models. 3037 3038Small model objects live in the lower 16MB of memory (so that their 3039addresses can be loaded with the @code{ld24} instruction), and are 3040callable with the @code{bl} instruction. 3041 3042Medium model objects may live anywhere in the 32-bit address space (the 3043compiler will generate @code{seth/add3} instructions to load their addresses), 3044and are callable with the @code{bl} instruction. 3045 3046Large model objects may live anywhere in the 32-bit address space (the 3047compiler will generate @code{seth/add3} instructions to load their addresses), 3048and may not be reachable with the @code{bl} instruction (the compiler will 3049generate the much slower @code{seth/add3/jl} instruction sequence). 3050 3051On IA-64, use this attribute to set the addressability of an object. 3052At present, the only supported identifier for @var{model-name} is 3053@code{small}, indicating addressability via ``small'' (22-bit) 3054addresses (so that their addresses can be loaded with the @code{addl} 3055instruction). Caveat: such addressing is by definition not position 3056independent and hence this attribute must not be used for objects 3057defined by shared libraries. 3058 3059@item ms_abi/sysv_abi 3060@cindex @code{ms_abi} attribute 3061@cindex @code{sysv_abi} attribute 3062 3063On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute 3064to indicate which calling convention should be used for a function. The 3065@code{ms_abi} attribute tells the compiler to use the Microsoft ABI, 3066while the @code{sysv_abi} attribute tells the compiler to use the ABI 3067used on GNU/Linux and other systems. The default is to use the Microsoft ABI 3068when targeting Windows. On all other systems, the default is the x86/AMD ABI. 3069 3070Note, the @code{ms_abi} attribute for Windows 64-bit targets currently 3071requires the @option{-maccumulate-outgoing-args} option. 3072 3073@item callee_pop_aggregate_return (@var{number}) 3074@cindex @code{callee_pop_aggregate_return} attribute 3075 3076On 32-bit i?86-*-* targets, you can control by those attribute for 3077aggregate return in memory, if the caller is responsible to pop the hidden 3078pointer together with the rest of the arguments - @var{number} equal to 3079zero -, or if the callee is responsible to pop hidden pointer - @var{number} 3080equal to one. The default i386 ABI assumes that the callee pops the 3081stack for hidden pointer. 3082 3083Note, that on 32-bit i386 Windows targets the compiler assumes that the 3084caller pops the stack for hidden pointer. 3085 3086@item ms_hook_prologue 3087@cindex @code{ms_hook_prologue} attribute 3088 3089On 32 bit i[34567]86-*-* targets and 64 bit x86_64-*-* targets, you can use 3090this function attribute to make gcc generate the "hot-patching" function 3091prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2 3092and newer. 3093 3094@item naked 3095@cindex function without a prologue/epilogue code 3096Use this attribute on the ARM, AVR, MCORE, RX and SPU ports to indicate that 3097the specified function does not need prologue/epilogue sequences generated by 3098the compiler. It is up to the programmer to provide these sequences. The 3099only statements that can be safely included in naked functions are 3100@code{asm} statements that do not have operands. All other statements, 3101including declarations of local variables, @code{if} statements, and so 3102forth, should be avoided. Naked functions should be used to implement the 3103body of an assembly function, while allowing the compiler to construct 3104the requisite function declaration for the assembler. 3105 3106@item near 3107@cindex functions which do not handle memory bank switching on 68HC11/68HC12 3108On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to 3109use the normal calling convention based on @code{jsr} and @code{rts}. 3110This attribute can be used to cancel the effect of the @option{-mlong-calls} 3111option. 3112 3113On MeP targets this attribute causes the compiler to assume the called 3114function is close enough to use the normal calling convention, 3115overriding the @code{-mtf} command line option. 3116 3117@item nesting 3118@cindex Allow nesting in an interrupt handler on the Blackfin processor. 3119Use this attribute together with @code{interrupt_handler}, 3120@code{exception_handler} or @code{nmi_handler} to indicate that the function 3121entry code should enable nested interrupts or exceptions. 3122 3123@item nmi_handler 3124@cindex NMI handler functions on the Blackfin processor 3125Use this attribute on the Blackfin to indicate that the specified function 3126is an NMI handler. The compiler will generate function entry and 3127exit sequences suitable for use in an NMI handler when this 3128attribute is present. 3129 3130@item no_instrument_function 3131@cindex @code{no_instrument_function} function attribute 3132@opindex finstrument-functions 3133If @option{-finstrument-functions} is given, profiling function calls will 3134be generated at entry and exit of most user-compiled functions. 3135Functions with this attribute will not be so instrumented. 3136 3137@item no_split_stack 3138@cindex @code{no_split_stack} function attribute 3139@opindex fsplit-stack 3140If @option{-fsplit-stack} is given, functions will have a small 3141prologue which decides whether to split the stack. Functions with the 3142@code{no_split_stack} attribute will not have that prologue, and thus 3143may run with only a small amount of stack space available. 3144 3145@item noinline 3146@cindex @code{noinline} function attribute 3147This function attribute prevents a function from being considered for 3148inlining. 3149@c Don't enumerate the optimizations by name here; we try to be 3150@c future-compatible with this mechanism. 3151If the function does not have side-effects, there are optimizations 3152other than inlining that causes function calls to be optimized away, 3153although the function call is live. To keep such calls from being 3154optimized away, put 3155@smallexample 3156asm (""); 3157@end smallexample 3158(@pxref{Extended Asm}) in the called function, to serve as a special 3159side-effect. 3160 3161@item noclone 3162@cindex @code{noclone} function attribute 3163This function attribute prevents a function from being considered for 3164cloning - a mechanism which produces specialized copies of functions 3165and which is (currently) performed by interprocedural constant 3166propagation. 3167 3168@item nonnull (@var{arg-index}, @dots{}) 3169@cindex @code{nonnull} function attribute 3170The @code{nonnull} attribute specifies that some function parameters should 3171be non-null pointers. For instance, the declaration: 3172 3173@smallexample 3174extern void * 3175my_memcpy (void *dest, const void *src, size_t len) 3176 __attribute__((nonnull (1, 2))); 3177@end smallexample 3178 3179@noindent 3180causes the compiler to check that, in calls to @code{my_memcpy}, 3181arguments @var{dest} and @var{src} are non-null. If the compiler 3182determines that a null pointer is passed in an argument slot marked 3183as non-null, and the @option{-Wnonnull} option is enabled, a warning 3184is issued. The compiler may also choose to make optimizations based 3185on the knowledge that certain function arguments will not be null. 3186 3187If no argument index list is given to the @code{nonnull} attribute, 3188all pointer arguments are marked as non-null. To illustrate, the 3189following declaration is equivalent to the previous example: 3190 3191@smallexample 3192extern void * 3193my_memcpy (void *dest, const void *src, size_t len) 3194 __attribute__((nonnull)); 3195@end smallexample 3196 3197@item noreturn 3198@cindex @code{noreturn} function attribute 3199A few standard library functions, such as @code{abort} and @code{exit}, 3200cannot return. GCC knows this automatically. Some programs define 3201their own functions that never return. You can declare them 3202@code{noreturn} to tell the compiler this fact. For example, 3203 3204@smallexample 3205@group 3206void fatal () __attribute__ ((noreturn)); 3207 3208void 3209fatal (/* @r{@dots{}} */) 3210@{ 3211 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */ 3212 exit (1); 3213@} 3214@end group 3215@end smallexample 3216 3217The @code{noreturn} keyword tells the compiler to assume that 3218@code{fatal} cannot return. It can then optimize without regard to what 3219would happen if @code{fatal} ever did return. This makes slightly 3220better code. More importantly, it helps avoid spurious warnings of 3221uninitialized variables. 3222 3223The @code{noreturn} keyword does not affect the exceptional path when that 3224applies: a @code{noreturn}-marked function may still return to the caller 3225by throwing an exception or calling @code{longjmp}. 3226 3227Do not assume that registers saved by the calling function are 3228restored before calling the @code{noreturn} function. 3229 3230It does not make sense for a @code{noreturn} function to have a return 3231type other than @code{void}. 3232 3233The attribute @code{noreturn} is not implemented in GCC versions 3234earlier than 2.5. An alternative way to declare that a function does 3235not return, which works in the current version and in some older 3236versions, is as follows: 3237 3238@smallexample 3239typedef void voidfn (); 3240 3241volatile voidfn fatal; 3242@end smallexample 3243 3244This approach does not work in GNU C++. 3245 3246@item nothrow 3247@cindex @code{nothrow} function attribute 3248The @code{nothrow} attribute is used to inform the compiler that a 3249function cannot throw an exception. For example, most functions in 3250the standard C library can be guaranteed not to throw an exception 3251with the notable exceptions of @code{qsort} and @code{bsearch} that 3252take function pointer arguments. The @code{nothrow} attribute is not 3253implemented in GCC versions earlier than 3.3. 3254 3255@item optimize 3256@cindex @code{optimize} function attribute 3257The @code{optimize} attribute is used to specify that a function is to 3258be compiled with different optimization options than specified on the 3259command line. Arguments can either be numbers or strings. Numbers 3260are assumed to be an optimization level. Strings that begin with 3261@code{O} are assumed to be an optimization option, while other options 3262are assumed to be used with a @code{-f} prefix. You can also use the 3263@samp{#pragma GCC optimize} pragma to set the optimization options 3264that affect more than one function. 3265@xref{Function Specific Option Pragmas}, for details about the 3266@samp{#pragma GCC optimize} pragma. 3267 3268This can be used for instance to have frequently executed functions 3269compiled with more aggressive optimization options that produce faster 3270and larger code, while other functions can be called with less 3271aggressive options. 3272 3273@item OS_main/OS_task 3274@cindex @code{OS_main} AVR function attribute 3275@cindex @code{OS_task} AVR function attribute 3276On AVR, functions with the @code{OS_main} or @code{OS_task} attribute 3277do not save/restore any call-saved register in their prologue/epilogue. 3278 3279The @code{OS_main} attribute can be used when there @emph{is 3280guarantee} that interrupts are disabled at the time when the function 3281is entered. This will save resources when the stack pointer has to be 3282changed to set up a frame for local variables. 3283 3284The @code{OS_task} attribute can be used when there is @emph{no 3285guarantee} that interrupts are disabled at that time when the function 3286is entered like for, e@.g@. task functions in a multi-threading operating 3287system. In that case, changing the stack pointer register will be 3288guarded by save/clear/restore of the global interrupt enable flag. 3289 3290The differences to the @code{naked} function attribute are: 3291@itemize @bullet 3292@item @code{naked} functions do not have a return instruction whereas 3293@code{OS_main} and @code{OS_task} functions will have a @code{RET} or 3294@code{RETI} return instruction. 3295@item @code{naked} functions do not set up a frame for local variables 3296or a frame pointer whereas @code{OS_main} and @code{OS_task} do this 3297as needed. 3298@end itemize 3299 3300@item pcs 3301@cindex @code{pcs} function attribute 3302 3303The @code{pcs} attribute can be used to control the calling convention 3304used for a function on ARM. The attribute takes an argument that specifies 3305the calling convention to use. 3306 3307When compiling using the AAPCS ABI (or a variant of that) then valid 3308values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In 3309order to use a variant other than @code{"aapcs"} then the compiler must 3310be permitted to use the appropriate co-processor registers (i.e., the 3311VFP registers must be available in order to use @code{"aapcs-vfp"}). 3312For example, 3313 3314@smallexample 3315/* Argument passed in r0, and result returned in r0+r1. */ 3316double f2d (float) __attribute__((pcs("aapcs"))); 3317@end smallexample 3318 3319Variadic functions always use the @code{"aapcs"} calling convention and 3320the compiler will reject attempts to specify an alternative. 3321 3322@item pure 3323@cindex @code{pure} function attribute 3324Many functions have no effects except the return value and their 3325return value depends only on the parameters and/or global variables. 3326Such a function can be subject 3327to common subexpression elimination and loop optimization just as an 3328arithmetic operator would be. These functions should be declared 3329with the attribute @code{pure}. For example, 3330 3331@smallexample 3332int square (int) __attribute__ ((pure)); 3333@end smallexample 3334 3335@noindent 3336says that the hypothetical function @code{square} is safe to call 3337fewer times than the program says. 3338 3339Some of common examples of pure functions are @code{strlen} or @code{memcmp}. 3340Interesting non-pure functions are functions with infinite loops or those 3341depending on volatile memory or other system resource, that may change between 3342two consecutive calls (such as @code{feof} in a multithreading environment). 3343 3344The attribute @code{pure} is not implemented in GCC versions earlier 3345than 2.96. 3346 3347@item hot 3348@cindex @code{hot} function attribute 3349The @code{hot} attribute is used to inform the compiler that a function is a 3350hot spot of the compiled program. The function is optimized more aggressively 3351and on many target it is placed into special subsection of the text section so 3352all hot functions appears close together improving locality. 3353 3354When profile feedback is available, via @option{-fprofile-use}, hot functions 3355are automatically detected and this attribute is ignored. 3356 3357The @code{hot} attribute is not implemented in GCC versions earlier 3358than 4.3. 3359 3360@item cold 3361@cindex @code{cold} function attribute 3362The @code{cold} attribute is used to inform the compiler that a function is 3363unlikely executed. The function is optimized for size rather than speed and on 3364many targets it is placed into special subsection of the text section so all 3365cold functions appears close together improving code locality of non-cold parts 3366of program. The paths leading to call of cold functions within code are marked 3367as unlikely by the branch prediction mechanism. It is thus useful to mark 3368functions used to handle unlikely conditions, such as @code{perror}, as cold to 3369improve optimization of hot functions that do call marked functions in rare 3370occasions. 3371 3372When profile feedback is available, via @option{-fprofile-use}, hot functions 3373are automatically detected and this attribute is ignored. 3374 3375The @code{cold} attribute is not implemented in GCC versions earlier than 4.3. 3376 3377@item regparm (@var{number}) 3378@cindex @code{regparm} attribute 3379@cindex functions that are passed arguments in registers on the 386 3380On the Intel 386, the @code{regparm} attribute causes the compiler to 3381pass arguments number one to @var{number} if they are of integral type 3382in registers EAX, EDX, and ECX instead of on the stack. Functions that 3383take a variable number of arguments will continue to be passed all of their 3384arguments on the stack. 3385 3386Beware that on some ELF systems this attribute is unsuitable for 3387global functions in shared libraries with lazy binding (which is the 3388default). Lazy binding will send the first call via resolving code in 3389the loader, which might assume EAX, EDX and ECX can be clobbered, as 3390per the standard calling conventions. Solaris 8 is affected by this. 3391GNU systems with GLIBC 2.1 or higher, and FreeBSD, are believed to be 3392safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be 3393disabled with the linker or the loader if desired, to avoid the 3394problem.) 3395 3396@item sseregparm 3397@cindex @code{sseregparm} attribute 3398On the Intel 386 with SSE support, the @code{sseregparm} attribute 3399causes the compiler to pass up to 3 floating point arguments in 3400SSE registers instead of on the stack. Functions that take a 3401variable number of arguments will continue to pass all of their 3402floating point arguments on the stack. 3403 3404@item force_align_arg_pointer 3405@cindex @code{force_align_arg_pointer} attribute 3406On the Intel x86, the @code{force_align_arg_pointer} attribute may be 3407applied to individual function definitions, generating an alternate 3408prologue and epilogue that realigns the runtime stack if necessary. 3409This supports mixing legacy codes that run with a 4-byte aligned stack 3410with modern codes that keep a 16-byte stack for SSE compatibility. 3411 3412@item resbank 3413@cindex @code{resbank} attribute 3414On the SH2A target, this attribute enables the high-speed register 3415saving and restoration using a register bank for @code{interrupt_handler} 3416routines. Saving to the bank is performed automatically after the CPU 3417accepts an interrupt that uses a register bank. 3418 3419The nineteen 32-bit registers comprising general register R0 to R14, 3420control register GBR, and system registers MACH, MACL, and PR and the 3421vector table address offset are saved into a register bank. Register 3422banks are stacked in first-in last-out (FILO) sequence. Restoration 3423from the bank is executed by issuing a RESBANK instruction. 3424 3425@item returns_twice 3426@cindex @code{returns_twice} attribute 3427The @code{returns_twice} attribute tells the compiler that a function may 3428return more than one time. The compiler will ensure that all registers 3429are dead before calling such a function and will emit a warning about 3430the variables that may be clobbered after the second return from the 3431function. Examples of such functions are @code{setjmp} and @code{vfork}. 3432The @code{longjmp}-like counterpart of such function, if any, might need 3433to be marked with the @code{noreturn} attribute. 3434 3435@item saveall 3436@cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S 3437Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that 3438all registers except the stack pointer should be saved in the prologue 3439regardless of whether they are used or not. 3440 3441@item save_volatiles 3442@cindex save volatile registers on the MicroBlaze 3443Use this attribute on the MicroBlaze to indicate that the function is 3444an interrupt handler. All volatile registers (in addition to non-volatile 3445registers) will be saved in the function prologue. If the function is a leaf 3446function, only volatiles used by the function are saved. A normal function 3447return is generated instead of a return from interrupt. 3448 3449@item section ("@var{section-name}") 3450@cindex @code{section} function attribute 3451Normally, the compiler places the code it generates in the @code{text} section. 3452Sometimes, however, you need additional sections, or you need certain 3453particular functions to appear in special sections. The @code{section} 3454attribute specifies that a function lives in a particular section. 3455For example, the declaration: 3456 3457@smallexample 3458extern void foobar (void) __attribute__ ((section ("bar"))); 3459@end smallexample 3460 3461@noindent 3462puts the function @code{foobar} in the @code{bar} section. 3463 3464Some file formats do not support arbitrary sections so the @code{section} 3465attribute is not available on all platforms. 3466If you need to map the entire contents of a module to a particular 3467section, consider using the facilities of the linker instead. 3468 3469@item sentinel 3470@cindex @code{sentinel} function attribute 3471This function attribute ensures that a parameter in a function call is 3472an explicit @code{NULL}. The attribute is only valid on variadic 3473functions. By default, the sentinel is located at position zero, the 3474last parameter of the function call. If an optional integer position 3475argument P is supplied to the attribute, the sentinel must be located at 3476position P counting backwards from the end of the argument list. 3477 3478@smallexample 3479__attribute__ ((sentinel)) 3480is equivalent to 3481__attribute__ ((sentinel(0))) 3482@end smallexample 3483 3484The attribute is automatically set with a position of 0 for the built-in 3485functions @code{execl} and @code{execlp}. The built-in function 3486@code{execle} has the attribute set with a position of 1. 3487 3488A valid @code{NULL} in this context is defined as zero with any pointer 3489type. If your system defines the @code{NULL} macro with an integer type 3490then you need to add an explicit cast. GCC replaces @code{stddef.h} 3491with a copy that redefines NULL appropriately. 3492 3493The warnings for missing or incorrect sentinels are enabled with 3494@option{-Wformat}. 3495 3496@item short_call 3497See long_call/short_call. 3498 3499@item shortcall 3500See longcall/shortcall. 3501 3502@item signal 3503@cindex interrupt handler functions on the AVR processors 3504Use this attribute on the AVR to indicate that the specified 3505function is an interrupt handler. The compiler will generate function 3506entry and exit sequences suitable for use in an interrupt handler when this 3507attribute is present. 3508 3509See also the @code{interrupt} function attribute. 3510 3511The AVR hardware globally disables interrupts when an interrupt is executed. 3512Interrupt handler functions defined with the @code{signal} attribute 3513do not re-enable interrupts. It is save to enable interrupts in a 3514@code{signal} handler. This ``save'' only applies to the code 3515generated by the compiler and not to the IRQ-layout of the 3516application which is responsibility of the application. 3517 3518If both @code{signal} and @code{interrupt} are specified for the same 3519function, @code{signal} will be silently ignored. 3520 3521@item sp_switch 3522Use this attribute on the SH to indicate an @code{interrupt_handler} 3523function should switch to an alternate stack. It expects a string 3524argument that names a global variable holding the address of the 3525alternate stack. 3526 3527@smallexample 3528void *alt_stack; 3529void f () __attribute__ ((interrupt_handler, 3530 sp_switch ("alt_stack"))); 3531@end smallexample 3532 3533@item stdcall 3534@cindex functions that pop the argument stack on the 386 3535On the Intel 386, the @code{stdcall} attribute causes the compiler to 3536assume that the called function will pop off the stack space used to 3537pass arguments, unless it takes a variable number of arguments. 3538 3539@item syscall_linkage 3540@cindex @code{syscall_linkage} attribute 3541This attribute is used to modify the IA64 calling convention by marking 3542all input registers as live at all function exits. This makes it possible 3543to restart a system call after an interrupt without having to save/restore 3544the input registers. This also prevents kernel data from leaking into 3545application code. 3546 3547@item target 3548@cindex @code{target} function attribute 3549The @code{target} attribute is used to specify that a function is to 3550be compiled with different target options than specified on the 3551command line. This can be used for instance to have functions 3552compiled with a different ISA (instruction set architecture) than the 3553default. You can also use the @samp{#pragma GCC target} pragma to set 3554more than one function to be compiled with specific target options. 3555@xref{Function Specific Option Pragmas}, for details about the 3556@samp{#pragma GCC target} pragma. 3557 3558For instance on a 386, you could compile one function with 3559@code{target("sse4.1,arch=core2")} and another with 3560@code{target("sse4a,arch=amdfam10")} that would be equivalent to 3561compiling the first function with @option{-msse4.1} and 3562@option{-march=core2} options, and the second function with 3563@option{-msse4a} and @option{-march=amdfam10} options. It is up to the 3564user to make sure that a function is only invoked on a machine that 3565supports the particular ISA it was compiled for (for example by using 3566@code{cpuid} on 386 to determine what feature bits and architecture 3567family are used). 3568 3569@smallexample 3570int core2_func (void) __attribute__ ((__target__ ("arch=core2"))); 3571int sse3_func (void) __attribute__ ((__target__ ("sse3"))); 3572@end smallexample 3573 3574On the 386, the following options are allowed: 3575 3576@table @samp 3577@item abm 3578@itemx no-abm 3579@cindex @code{target("abm")} attribute 3580Enable/disable the generation of the advanced bit instructions. 3581 3582@item aes 3583@itemx no-aes 3584@cindex @code{target("aes")} attribute 3585Enable/disable the generation of the AES instructions. 3586 3587@item mmx 3588@itemx no-mmx 3589@cindex @code{target("mmx")} attribute 3590Enable/disable the generation of the MMX instructions. 3591 3592@item pclmul 3593@itemx no-pclmul 3594@cindex @code{target("pclmul")} attribute 3595Enable/disable the generation of the PCLMUL instructions. 3596 3597@item popcnt 3598@itemx no-popcnt 3599@cindex @code{target("popcnt")} attribute 3600Enable/disable the generation of the POPCNT instruction. 3601 3602@item sse 3603@itemx no-sse 3604@cindex @code{target("sse")} attribute 3605Enable/disable the generation of the SSE instructions. 3606 3607@item sse2 3608@itemx no-sse2 3609@cindex @code{target("sse2")} attribute 3610Enable/disable the generation of the SSE2 instructions. 3611 3612@item sse3 3613@itemx no-sse3 3614@cindex @code{target("sse3")} attribute 3615Enable/disable the generation of the SSE3 instructions. 3616 3617@item sse4 3618@itemx no-sse4 3619@cindex @code{target("sse4")} attribute 3620Enable/disable the generation of the SSE4 instructions (both SSE4.1 3621and SSE4.2). 3622 3623@item sse4.1 3624@itemx no-sse4.1 3625@cindex @code{target("sse4.1")} attribute 3626Enable/disable the generation of the sse4.1 instructions. 3627 3628@item sse4.2 3629@itemx no-sse4.2 3630@cindex @code{target("sse4.2")} attribute 3631Enable/disable the generation of the sse4.2 instructions. 3632 3633@item sse4a 3634@itemx no-sse4a 3635@cindex @code{target("sse4a")} attribute 3636Enable/disable the generation of the SSE4A instructions. 3637 3638@item fma4 3639@itemx no-fma4 3640@cindex @code{target("fma4")} attribute 3641Enable/disable the generation of the FMA4 instructions. 3642 3643@item xop 3644@itemx no-xop 3645@cindex @code{target("xop")} attribute 3646Enable/disable the generation of the XOP instructions. 3647 3648@item lwp 3649@itemx no-lwp 3650@cindex @code{target("lwp")} attribute 3651Enable/disable the generation of the LWP instructions. 3652 3653@item ssse3 3654@itemx no-ssse3 3655@cindex @code{target("ssse3")} attribute 3656Enable/disable the generation of the SSSE3 instructions. 3657 3658@item cld 3659@itemx no-cld 3660@cindex @code{target("cld")} attribute 3661Enable/disable the generation of the CLD before string moves. 3662 3663@item fancy-math-387 3664@itemx no-fancy-math-387 3665@cindex @code{target("fancy-math-387")} attribute 3666Enable/disable the generation of the @code{sin}, @code{cos}, and 3667@code{sqrt} instructions on the 387 floating point unit. 3668 3669@item fused-madd 3670@itemx no-fused-madd 3671@cindex @code{target("fused-madd")} attribute 3672Enable/disable the generation of the fused multiply/add instructions. 3673 3674@item ieee-fp 3675@itemx no-ieee-fp 3676@cindex @code{target("ieee-fp")} attribute 3677Enable/disable the generation of floating point that depends on IEEE arithmetic. 3678 3679@item inline-all-stringops 3680@itemx no-inline-all-stringops 3681@cindex @code{target("inline-all-stringops")} attribute 3682Enable/disable inlining of string operations. 3683 3684@item inline-stringops-dynamically 3685@itemx no-inline-stringops-dynamically 3686@cindex @code{target("inline-stringops-dynamically")} attribute 3687Enable/disable the generation of the inline code to do small string 3688operations and calling the library routines for large operations. 3689 3690@item align-stringops 3691@itemx no-align-stringops 3692@cindex @code{target("align-stringops")} attribute 3693Do/do not align destination of inlined string operations. 3694 3695@item recip 3696@itemx no-recip 3697@cindex @code{target("recip")} attribute 3698Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS 3699instructions followed an additional Newton-Raphson step instead of 3700doing a floating point division. 3701 3702@item arch=@var{ARCH} 3703@cindex @code{target("arch=@var{ARCH}")} attribute 3704Specify the architecture to generate code for in compiling the function. 3705 3706@item tune=@var{TUNE} 3707@cindex @code{target("tune=@var{TUNE}")} attribute 3708Specify the architecture to tune for in compiling the function. 3709 3710@item fpmath=@var{FPMATH} 3711@cindex @code{target("fpmath=@var{FPMATH}")} attribute 3712Specify which floating point unit to use. The 3713@code{target("fpmath=sse,387")} option must be specified as 3714@code{target("fpmath=sse+387")} because the comma would separate 3715different options. 3716@end table 3717 3718On the PowerPC, the following options are allowed: 3719 3720@table @samp 3721@item altivec 3722@itemx no-altivec 3723@cindex @code{target("altivec")} attribute 3724Generate code that uses (does not use) AltiVec instructions. In 372532-bit code, you cannot enable Altivec instructions unless 3726@option{-mabi=altivec} was used on the command line. 3727 3728@item cmpb 3729@itemx no-cmpb 3730@cindex @code{target("cmpb")} attribute 3731Generate code that uses (does not use) the compare bytes instruction 3732implemented on the POWER6 processor and other processors that support 3733the PowerPC V2.05 architecture. 3734 3735@item dlmzb 3736@itemx no-dlmzb 3737@cindex @code{target("dlmzb")} attribute 3738Generate code that uses (does not use) the string-search @samp{dlmzb} 3739instruction on the IBM 405, 440, 464 and 476 processors. This instruction is 3740generated by default when targetting those processors. 3741 3742@item fprnd 3743@itemx no-fprnd 3744@cindex @code{target("fprnd")} attribute 3745Generate code that uses (does not use) the FP round to integer 3746instructions implemented on the POWER5+ processor and other processors 3747that support the PowerPC V2.03 architecture. 3748 3749@item hard-dfp 3750@itemx no-hard-dfp 3751@cindex @code{target("hard-dfp")} attribute 3752Generate code that uses (does not use) the decimal floating point 3753instructions implemented on some POWER processors. 3754 3755@item isel 3756@itemx no-isel 3757@cindex @code{target("isel")} attribute 3758Generate code that uses (does not use) ISEL instruction. 3759 3760@item mfcrf 3761@itemx no-mfcrf 3762@cindex @code{target("mfcrf")} attribute 3763Generate code that uses (does not use) the move from condition 3764register field instruction implemented on the POWER4 processor and 3765other processors that support the PowerPC V2.01 architecture. 3766 3767@item mfpgpr 3768@itemx no-mfpgpr 3769@cindex @code{target("mfpgpr")} attribute 3770Generate code that uses (does not use) the FP move to/from general 3771purpose register instructions implemented on the POWER6X processor and 3772other processors that support the extended PowerPC V2.05 architecture. 3773 3774@item mulhw 3775@itemx no-mulhw 3776@cindex @code{target("mulhw")} attribute 3777Generate code that uses (does not use) the half-word multiply and 3778multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors. 3779These instructions are generated by default when targetting those 3780processors. 3781 3782@item multiple 3783@itemx no-multiple 3784@cindex @code{target("multiple")} attribute 3785Generate code that uses (does not use) the load multiple word 3786instructions and the store multiple word instructions. 3787 3788@item update 3789@itemx no-update 3790@cindex @code{target("update")} attribute 3791Generate code that uses (does not use) the load or store instructions 3792that update the base register to the address of the calculated memory 3793location. 3794 3795@item popcntb 3796@itemx no-popcntb 3797@cindex @code{target("popcntb")} attribute 3798Generate code that uses (does not use) the popcount and double 3799precision FP reciprocal estimate instruction implemented on the POWER5 3800processor and other processors that support the PowerPC V2.02 3801architecture. 3802 3803@item popcntd 3804@itemx no-popcntd 3805@cindex @code{target("popcntd")} attribute 3806Generate code that uses (does not use) the popcount instruction 3807implemented on the POWER7 processor and other processors that support 3808the PowerPC V2.06 architecture. 3809 3810@item powerpc-gfxopt 3811@itemx no-powerpc-gfxopt 3812@cindex @code{target("powerpc-gfxopt")} attribute 3813Generate code that uses (does not use) the optional PowerPC 3814architecture instructions in the Graphics group, including 3815floating-point select. 3816 3817@item powerpc-gpopt 3818@itemx no-powerpc-gpopt 3819@cindex @code{target("powerpc-gpopt")} attribute 3820Generate code that uses (does not use) the optional PowerPC 3821architecture instructions in the General Purpose group, including 3822floating-point square root. 3823 3824@item recip-precision 3825@itemx no-recip-precision 3826@cindex @code{target("recip-precision")} attribute 3827Assume (do not assume) that the reciprocal estimate instructions 3828provide higher precision estimates than is mandated by the powerpc 3829ABI. 3830 3831@item string 3832@itemx no-string 3833@cindex @code{target("string")} attribute 3834Generate code that uses (does not use) the load string instructions 3835and the store string word instructions to save multiple registers and 3836do small block moves. 3837 3838@item vsx 3839@itemx no-vsx 3840@cindex @code{target("vsx")} attribute 3841Generate code that uses (does not use) vector/scalar (VSX) 3842instructions, and also enable the use of built-in functions that allow 3843more direct access to the VSX instruction set. In 32-bit code, you 3844cannot enable VSX or Altivec instructions unless 3845@option{-mabi=altivec} was used on the command line. 3846 3847@item friz 3848@itemx no-friz 3849@cindex @code{target("friz")} attribute 3850Generate (do not generate) the @code{friz} instruction when the 3851@option{-funsafe-math-optimizations} option is used to optimize 3852rounding a floating point value to 64-bit integer and back to floating 3853point. The @code{friz} instruction does not return the same value if 3854the floating point number is too large to fit in an integer. 3855 3856@item avoid-indexed-addresses 3857@itemx no-avoid-indexed-addresses 3858@cindex @code{target("avoid-indexed-addresses")} attribute 3859Generate code that tries to avoid (not avoid) the use of indexed load 3860or store instructions. 3861 3862@item paired 3863@itemx no-paired 3864@cindex @code{target("paired")} attribute 3865Generate code that uses (does not use) the generation of PAIRED simd 3866instructions. 3867 3868@item longcall 3869@itemx no-longcall 3870@cindex @code{target("longcall")} attribute 3871Generate code that assumes (does not assume) that all calls are far 3872away so that a longer more expensive calling sequence is required. 3873 3874@item cpu=@var{CPU} 3875@cindex @code{target("cpu=@var{CPU}")} attribute 3876Specify the architecture to generate code for when compiling the 3877function. If you select the @code{target("cpu=power7")} attribute when 3878generating 32-bit code, VSX and Altivec instructions are not generated 3879unless you use the @option{-mabi=altivec} option on the command line. 3880 3881@item tune=@var{TUNE} 3882@cindex @code{target("tune=@var{TUNE}")} attribute 3883Specify the architecture to tune for when compiling the function. If 3884you do not specify the @code{target("tune=@var{TUNE}")} attribute and 3885you do specify the @code{target("cpu=@var{CPU}")} attribute, 3886compilation will tune for the @var{CPU} architecture, and not the 3887default tuning specified on the command line. 3888@end table 3889 3890On the 386/x86_64 and PowerPC backends, you can use either multiple 3891strings to specify multiple options, or you can separate the option 3892with a comma (@code{,}). 3893 3894On the 386/x86_64 and PowerPC backends, the inliner will not inline a 3895function that has different target options than the caller, unless the 3896callee has a subset of the target options of the caller. For example 3897a function declared with @code{target("sse3")} can inline a function 3898with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}. 3899 3900The @code{target} attribute is not implemented in GCC versions earlier 3901than 4.4 for the i386/x86_64 and 4.6 for the PowerPC backends. It is 3902not currently implemented for other backends. 3903 3904@item tiny_data 3905@cindex tiny data section on the H8/300H and H8S 3906Use this attribute on the H8/300H and H8S to indicate that the specified 3907variable should be placed into the tiny data section. 3908The compiler will generate more efficient code for loads and stores 3909on data in the tiny data section. Note the tiny data area is limited to 3910slightly under 32kbytes of data. 3911 3912@item trap_exit 3913Use this attribute on the SH for an @code{interrupt_handler} to return using 3914@code{trapa} instead of @code{rte}. This attribute expects an integer 3915argument specifying the trap number to be used. 3916 3917@item unused 3918@cindex @code{unused} attribute. 3919This attribute, attached to a function, means that the function is meant 3920to be possibly unused. GCC will not produce a warning for this 3921function. 3922 3923@item used 3924@cindex @code{used} attribute. 3925This attribute, attached to a function, means that code must be emitted 3926for the function even if it appears that the function is not referenced. 3927This is useful, for example, when the function is referenced only in 3928inline assembly. 3929 3930When applied to a member function of a C++ class template, the 3931attribute also means that the function will be instantiated if the 3932class itself is instantiated. 3933 3934@item version_id 3935@cindex @code{version_id} attribute 3936This IA64 HP-UX attribute, attached to a global variable or function, renames a 3937symbol to contain a version string, thus allowing for function level 3938versioning. HP-UX system header files may use version level functioning 3939for some system calls. 3940 3941@smallexample 3942extern int foo () __attribute__((version_id ("20040821"))); 3943@end smallexample 3944 3945Calls to @var{foo} will be mapped to calls to @var{foo@{20040821@}}. 3946 3947@item visibility ("@var{visibility_type}") 3948@cindex @code{visibility} attribute 3949This attribute affects the linkage of the declaration to which it is attached. 3950There are four supported @var{visibility_type} values: default, 3951hidden, protected or internal visibility. 3952 3953@smallexample 3954void __attribute__ ((visibility ("protected"))) 3955f () @{ /* @r{Do something.} */; @} 3956int i __attribute__ ((visibility ("hidden"))); 3957@end smallexample 3958 3959The possible values of @var{visibility_type} correspond to the 3960visibility settings in the ELF gABI. 3961 3962@table @dfn 3963@c keep this list of visibilities in alphabetical order. 3964 3965@item default 3966Default visibility is the normal case for the object file format. 3967This value is available for the visibility attribute to override other 3968options that may change the assumed visibility of entities. 3969 3970On ELF, default visibility means that the declaration is visible to other 3971modules and, in shared libraries, means that the declared entity may be 3972overridden. 3973 3974On Darwin, default visibility means that the declaration is visible to 3975other modules. 3976 3977Default visibility corresponds to ``external linkage'' in the language. 3978 3979@item hidden 3980Hidden visibility indicates that the entity declared will have a new 3981form of linkage, which we'll call ``hidden linkage''. Two 3982declarations of an object with hidden linkage refer to the same object 3983if they are in the same shared object. 3984 3985@item internal 3986Internal visibility is like hidden visibility, but with additional 3987processor specific semantics. Unless otherwise specified by the 3988psABI, GCC defines internal visibility to mean that a function is 3989@emph{never} called from another module. Compare this with hidden 3990functions which, while they cannot be referenced directly by other 3991modules, can be referenced indirectly via function pointers. By 3992indicating that a function cannot be called from outside the module, 3993GCC may for instance omit the load of a PIC register since it is known 3994that the calling function loaded the correct value. 3995 3996@item protected 3997Protected visibility is like default visibility except that it 3998indicates that references within the defining module will bind to the 3999definition in that module. That is, the declared entity cannot be 4000overridden by another module. 4001 4002@end table 4003 4004All visibilities are supported on many, but not all, ELF targets 4005(supported when the assembler supports the @samp{.visibility} 4006pseudo-op). Default visibility is supported everywhere. Hidden 4007visibility is supported on Darwin targets. 4008 4009The visibility attribute should be applied only to declarations which 4010would otherwise have external linkage. The attribute should be applied 4011consistently, so that the same entity should not be declared with 4012different settings of the attribute. 4013 4014In C++, the visibility attribute applies to types as well as functions 4015and objects, because in C++ types have linkage. A class must not have 4016greater visibility than its non-static data member types and bases, 4017and class members default to the visibility of their class. Also, a 4018declaration without explicit visibility is limited to the visibility 4019of its type. 4020 4021In C++, you can mark member functions and static member variables of a 4022class with the visibility attribute. This is useful if you know a 4023particular method or static member variable should only be used from 4024one shared object; then you can mark it hidden while the rest of the 4025class has default visibility. Care must be taken to avoid breaking 4026the One Definition Rule; for example, it is usually not useful to mark 4027an inline method as hidden without marking the whole class as hidden. 4028 4029A C++ namespace declaration can also have the visibility attribute. 4030This attribute applies only to the particular namespace body, not to 4031other definitions of the same namespace; it is equivalent to using 4032@samp{#pragma GCC visibility} before and after the namespace 4033definition (@pxref{Visibility Pragmas}). 4034 4035In C++, if a template argument has limited visibility, this 4036restriction is implicitly propagated to the template instantiation. 4037Otherwise, template instantiations and specializations default to the 4038visibility of their template. 4039 4040If both the template and enclosing class have explicit visibility, the 4041visibility from the template is used. 4042 4043@item vliw 4044@cindex @code{vliw} attribute 4045On MeP, the @code{vliw} attribute tells the compiler to emit 4046instructions in VLIW mode instead of core mode. Note that this 4047attribute is not allowed unless a VLIW coprocessor has been configured 4048and enabled through command line options. 4049 4050@item warn_unused_result 4051@cindex @code{warn_unused_result} attribute 4052The @code{warn_unused_result} attribute causes a warning to be emitted 4053if a caller of the function with this attribute does not use its 4054return value. This is useful for functions where not checking 4055the result is either a security problem or always a bug, such as 4056@code{realloc}. 4057 4058@smallexample 4059int fn () __attribute__ ((warn_unused_result)); 4060int foo () 4061@{ 4062 if (fn () < 0) return -1; 4063 fn (); 4064 return 0; 4065@} 4066@end smallexample 4067 4068results in warning on line 5. 4069 4070@item weak 4071@cindex @code{weak} attribute 4072The @code{weak} attribute causes the declaration to be emitted as a weak 4073symbol rather than a global. This is primarily useful in defining 4074library functions which can be overridden in user code, though it can 4075also be used with non-function declarations. Weak symbols are supported 4076for ELF targets, and also for a.out targets when using the GNU assembler 4077and linker. 4078 4079@item weakref 4080@itemx weakref ("@var{target}") 4081@cindex @code{weakref} attribute 4082The @code{weakref} attribute marks a declaration as a weak reference. 4083Without arguments, it should be accompanied by an @code{alias} attribute 4084naming the target symbol. Optionally, the @var{target} may be given as 4085an argument to @code{weakref} itself. In either case, @code{weakref} 4086implicitly marks the declaration as @code{weak}. Without a 4087@var{target}, given as an argument to @code{weakref} or to @code{alias}, 4088@code{weakref} is equivalent to @code{weak}. 4089 4090@smallexample 4091static int x() __attribute__ ((weakref ("y"))); 4092/* is equivalent to... */ 4093static int x() __attribute__ ((weak, weakref, alias ("y"))); 4094/* and to... */ 4095static int x() __attribute__ ((weakref)); 4096static int x() __attribute__ ((alias ("y"))); 4097@end smallexample 4098 4099A weak reference is an alias that does not by itself require a 4100definition to be given for the target symbol. If the target symbol is 4101only referenced through weak references, then it becomes a @code{weak} 4102undefined symbol. If it is directly referenced, however, then such 4103strong references prevail, and a definition will be required for the 4104symbol, not necessarily in the same translation unit. 4105 4106The effect is equivalent to moving all references to the alias to a 4107separate translation unit, renaming the alias to the aliased symbol, 4108declaring it as weak, compiling the two separate translation units and 4109performing a reloadable link on them. 4110 4111At present, a declaration to which @code{weakref} is attached can 4112only be @code{static}. 4113 4114@end table 4115 4116You can specify multiple attributes in a declaration by separating them 4117by commas within the double parentheses or by immediately following an 4118attribute declaration with another attribute declaration. 4119 4120@cindex @code{#pragma}, reason for not using 4121@cindex pragma, reason for not using 4122Some people object to the @code{__attribute__} feature, suggesting that 4123ISO C's @code{#pragma} should be used instead. At the time 4124@code{__attribute__} was designed, there were two reasons for not doing 4125this. 4126 4127@enumerate 4128@item 4129It is impossible to generate @code{#pragma} commands from a macro. 4130 4131@item 4132There is no telling what the same @code{#pragma} might mean in another 4133compiler. 4134@end enumerate 4135 4136These two reasons applied to almost any application that might have been 4137proposed for @code{#pragma}. It was basically a mistake to use 4138@code{#pragma} for @emph{anything}. 4139 4140The ISO C99 standard includes @code{_Pragma}, which now allows pragmas 4141to be generated from macros. In addition, a @code{#pragma GCC} 4142namespace is now in use for GCC-specific pragmas. However, it has been 4143found convenient to use @code{__attribute__} to achieve a natural 4144attachment of attributes to their corresponding declarations, whereas 4145@code{#pragma GCC} is of use for constructs that do not naturally form 4146part of the grammar. @xref{Other Directives,,Miscellaneous 4147Preprocessing Directives, cpp, The GNU C Preprocessor}. 4148 4149@node Attribute Syntax 4150@section Attribute Syntax 4151@cindex attribute syntax 4152 4153This section describes the syntax with which @code{__attribute__} may be 4154used, and the constructs to which attribute specifiers bind, for the C 4155language. Some details may vary for C++ and Objective-C@. Because of 4156infelicities in the grammar for attributes, some forms described here 4157may not be successfully parsed in all cases. 4158 4159There are some problems with the semantics of attributes in C++. For 4160example, there are no manglings for attributes, although they may affect 4161code generation, so problems may arise when attributed types are used in 4162conjunction with templates or overloading. Similarly, @code{typeid} 4163does not distinguish between types with different attributes. Support 4164for attributes in C++ may be restricted in future to attributes on 4165declarations only, but not on nested declarators. 4166 4167@xref{Function Attributes}, for details of the semantics of attributes 4168applying to functions. @xref{Variable Attributes}, for details of the 4169semantics of attributes applying to variables. @xref{Type Attributes}, 4170for details of the semantics of attributes applying to structure, union 4171and enumerated types. 4172 4173An @dfn{attribute specifier} is of the form 4174@code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list} 4175is a possibly empty comma-separated sequence of @dfn{attributes}, where 4176each attribute is one of the following: 4177 4178@itemize @bullet 4179@item 4180Empty. Empty attributes are ignored. 4181 4182@item 4183A word (which may be an identifier such as @code{unused}, or a reserved 4184word such as @code{const}). 4185 4186@item 4187A word, followed by, in parentheses, parameters for the attribute. 4188These parameters take one of the following forms: 4189 4190@itemize @bullet 4191@item 4192An identifier. For example, @code{mode} attributes use this form. 4193 4194@item 4195An identifier followed by a comma and a non-empty comma-separated list 4196of expressions. For example, @code{format} attributes use this form. 4197 4198@item 4199A possibly empty comma-separated list of expressions. For example, 4200@code{format_arg} attributes use this form with the list being a single 4201integer constant expression, and @code{alias} attributes use this form 4202with the list being a single string constant. 4203@end itemize 4204@end itemize 4205 4206An @dfn{attribute specifier list} is a sequence of one or more attribute 4207specifiers, not separated by any other tokens. 4208 4209In GNU C, an attribute specifier list may appear after the colon following a 4210label, other than a @code{case} or @code{default} label. The only 4211attribute it makes sense to use after a label is @code{unused}. This 4212feature is intended for code generated by programs which contains labels 4213that may be unused but which is compiled with @option{-Wall}. It would 4214not normally be appropriate to use in it human-written code, though it 4215could be useful in cases where the code that jumps to the label is 4216contained within an @code{#ifdef} conditional. GNU C++ only permits 4217attributes on labels if the attribute specifier is immediately 4218followed by a semicolon (i.e., the label applies to an empty 4219statement). If the semicolon is missing, C++ label attributes are 4220ambiguous, as it is permissible for a declaration, which could begin 4221with an attribute list, to be labelled in C++. Declarations cannot be 4222labelled in C90 or C99, so the ambiguity does not arise there. 4223 4224An attribute specifier list may appear as part of a @code{struct}, 4225@code{union} or @code{enum} specifier. It may go either immediately 4226after the @code{struct}, @code{union} or @code{enum} keyword, or after 4227the closing brace. The former syntax is preferred. 4228Where attribute specifiers follow the closing brace, they are considered 4229to relate to the structure, union or enumerated type defined, not to any 4230enclosing declaration the type specifier appears in, and the type 4231defined is not complete until after the attribute specifiers. 4232@c Otherwise, there would be the following problems: a shift/reduce 4233@c conflict between attributes binding the struct/union/enum and 4234@c binding to the list of specifiers/qualifiers; and "aligned" 4235@c attributes could use sizeof for the structure, but the size could be 4236@c changed later by "packed" attributes. 4237 4238Otherwise, an attribute specifier appears as part of a declaration, 4239counting declarations of unnamed parameters and type names, and relates 4240to that declaration (which may be nested in another declaration, for 4241example in the case of a parameter declaration), or to a particular declarator 4242within a declaration. Where an 4243attribute specifier is applied to a parameter declared as a function or 4244an array, it should apply to the function or array rather than the 4245pointer to which the parameter is implicitly converted, but this is not 4246yet correctly implemented. 4247 4248Any list of specifiers and qualifiers at the start of a declaration may 4249contain attribute specifiers, whether or not such a list may in that 4250context contain storage class specifiers. (Some attributes, however, 4251are essentially in the nature of storage class specifiers, and only make 4252sense where storage class specifiers may be used; for example, 4253@code{section}.) There is one necessary limitation to this syntax: the 4254first old-style parameter declaration in a function definition cannot 4255begin with an attribute specifier, because such an attribute applies to 4256the function instead by syntax described below (which, however, is not 4257yet implemented in this case). In some other cases, attribute 4258specifiers are permitted by this grammar but not yet supported by the 4259compiler. All attribute specifiers in this place relate to the 4260declaration as a whole. In the obsolescent usage where a type of 4261@code{int} is implied by the absence of type specifiers, such a list of 4262specifiers and qualifiers may be an attribute specifier list with no 4263other specifiers or qualifiers. 4264 4265At present, the first parameter in a function prototype must have some 4266type specifier which is not an attribute specifier; this resolves an 4267ambiguity in the interpretation of @code{void f(int 4268(__attribute__((foo)) x))}, but is subject to change. At present, if 4269the parentheses of a function declarator contain only attributes then 4270those attributes are ignored, rather than yielding an error or warning 4271or implying a single parameter of type int, but this is subject to 4272change. 4273 4274An attribute specifier list may appear immediately before a declarator 4275(other than the first) in a comma-separated list of declarators in a 4276declaration of more than one identifier using a single list of 4277specifiers and qualifiers. Such attribute specifiers apply 4278only to the identifier before whose declarator they appear. For 4279example, in 4280 4281@smallexample 4282__attribute__((noreturn)) void d0 (void), 4283 __attribute__((format(printf, 1, 2))) d1 (const char *, ...), 4284 d2 (void) 4285@end smallexample 4286 4287@noindent 4288the @code{noreturn} attribute applies to all the functions 4289declared; the @code{format} attribute only applies to @code{d1}. 4290 4291An attribute specifier list may appear immediately before the comma, 4292@code{=} or semicolon terminating the declaration of an identifier other 4293than a function definition. Such attribute specifiers apply 4294to the declared object or function. Where an 4295assembler name for an object or function is specified (@pxref{Asm 4296Labels}), the attribute must follow the @code{asm} 4297specification. 4298 4299An attribute specifier list may, in future, be permitted to appear after 4300the declarator in a function definition (before any old-style parameter 4301declarations or the function body). 4302 4303Attribute specifiers may be mixed with type qualifiers appearing inside 4304the @code{[]} of a parameter array declarator, in the C99 construct by 4305which such qualifiers are applied to the pointer to which the array is 4306implicitly converted. Such attribute specifiers apply to the pointer, 4307not to the array, but at present this is not implemented and they are 4308ignored. 4309 4310An attribute specifier list may appear at the start of a nested 4311declarator. At present, there are some limitations in this usage: the 4312attributes correctly apply to the declarator, but for most individual 4313attributes the semantics this implies are not implemented. 4314When attribute specifiers follow the @code{*} of a pointer 4315declarator, they may be mixed with any type qualifiers present. 4316The following describes the formal semantics of this syntax. It will make the 4317most sense if you are familiar with the formal specification of 4318declarators in the ISO C standard. 4319 4320Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T 4321D1}, where @code{T} contains declaration specifiers that specify a type 4322@var{Type} (such as @code{int}) and @code{D1} is a declarator that 4323contains an identifier @var{ident}. The type specified for @var{ident} 4324for derived declarators whose type does not include an attribute 4325specifier is as in the ISO C standard. 4326 4327If @code{D1} has the form @code{( @var{attribute-specifier-list} D )}, 4328and the declaration @code{T D} specifies the type 4329``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then 4330@code{T D1} specifies the type ``@var{derived-declarator-type-list} 4331@var{attribute-specifier-list} @var{Type}'' for @var{ident}. 4332 4333If @code{D1} has the form @code{* 4334@var{type-qualifier-and-attribute-specifier-list} D}, and the 4335declaration @code{T D} specifies the type 4336``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then 4337@code{T D1} specifies the type ``@var{derived-declarator-type-list} 4338@var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for 4339@var{ident}. 4340 4341For example, 4342 4343@smallexample 4344void (__attribute__((noreturn)) ****f) (void); 4345@end smallexample 4346 4347@noindent 4348specifies the type ``pointer to pointer to pointer to pointer to 4349non-returning function returning @code{void}''. As another example, 4350 4351@smallexample 4352char *__attribute__((aligned(8))) *f; 4353@end smallexample 4354 4355@noindent 4356specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''. 4357Note again that this does not work with most attributes; for example, 4358the usage of @samp{aligned} and @samp{noreturn} attributes given above 4359is not yet supported. 4360 4361For compatibility with existing code written for compiler versions that 4362did not implement attributes on nested declarators, some laxity is 4363allowed in the placing of attributes. If an attribute that only applies 4364to types is applied to a declaration, it will be treated as applying to 4365the type of that declaration. If an attribute that only applies to 4366declarations is applied to the type of a declaration, it will be treated 4367as applying to that declaration; and, for compatibility with code 4368placing the attributes immediately before the identifier declared, such 4369an attribute applied to a function return type will be treated as 4370applying to the function type, and such an attribute applied to an array 4371element type will be treated as applying to the array type. If an 4372attribute that only applies to function types is applied to a 4373pointer-to-function type, it will be treated as applying to the pointer 4374target type; if such an attribute is applied to a function return type 4375that is not a pointer-to-function type, it will be treated as applying 4376to the function type. 4377 4378@node Function Prototypes 4379@section Prototypes and Old-Style Function Definitions 4380@cindex function prototype declarations 4381@cindex old-style function definitions 4382@cindex promotion of formal parameters 4383 4384GNU C extends ISO C to allow a function prototype to override a later 4385old-style non-prototype definition. Consider the following example: 4386 4387@smallexample 4388/* @r{Use prototypes unless the compiler is old-fashioned.} */ 4389#ifdef __STDC__ 4390#define P(x) x 4391#else 4392#define P(x) () 4393#endif 4394 4395/* @r{Prototype function declaration.} */ 4396int isroot P((uid_t)); 4397 4398/* @r{Old-style function definition.} */ 4399int 4400isroot (x) /* @r{??? lossage here ???} */ 4401 uid_t x; 4402@{ 4403 return x == 0; 4404@} 4405@end smallexample 4406 4407Suppose the type @code{uid_t} happens to be @code{short}. ISO C does 4408not allow this example, because subword arguments in old-style 4409non-prototype definitions are promoted. Therefore in this example the 4410function definition's argument is really an @code{int}, which does not 4411match the prototype argument type of @code{short}. 4412 4413This restriction of ISO C makes it hard to write code that is portable 4414to traditional C compilers, because the programmer does not know 4415whether the @code{uid_t} type is @code{short}, @code{int}, or 4416@code{long}. Therefore, in cases like these GNU C allows a prototype 4417to override a later old-style definition. More precisely, in GNU C, a 4418function prototype argument type overrides the argument type specified 4419by a later old-style definition if the former type is the same as the 4420latter type before promotion. Thus in GNU C the above example is 4421equivalent to the following: 4422 4423@smallexample 4424int isroot (uid_t); 4425 4426int 4427isroot (uid_t x) 4428@{ 4429 return x == 0; 4430@} 4431@end smallexample 4432 4433@noindent 4434GNU C++ does not support old-style function definitions, so this 4435extension is irrelevant. 4436 4437@node C++ Comments 4438@section C++ Style Comments 4439@cindex @code{//} 4440@cindex C++ comments 4441@cindex comments, C++ style 4442 4443In GNU C, you may use C++ style comments, which start with @samp{//} and 4444continue until the end of the line. Many other C implementations allow 4445such comments, and they are included in the 1999 C standard. However, 4446C++ style comments are not recognized if you specify an @option{-std} 4447option specifying a version of ISO C before C99, or @option{-ansi} 4448(equivalent to @option{-std=c90}). 4449 4450@node Dollar Signs 4451@section Dollar Signs in Identifier Names 4452@cindex $ 4453@cindex dollar signs in identifier names 4454@cindex identifier names, dollar signs in 4455 4456In GNU C, you may normally use dollar signs in identifier names. 4457This is because many traditional C implementations allow such identifiers. 4458However, dollar signs in identifiers are not supported on a few target 4459machines, typically because the target assembler does not allow them. 4460 4461@node Character Escapes 4462@section The Character @key{ESC} in Constants 4463 4464You can use the sequence @samp{\e} in a string or character constant to 4465stand for the ASCII character @key{ESC}. 4466 4467@node Variable Attributes 4468@section Specifying Attributes of Variables 4469@cindex attribute of variables 4470@cindex variable attributes 4471 4472The keyword @code{__attribute__} allows you to specify special 4473attributes of variables or structure fields. This keyword is followed 4474by an attribute specification inside double parentheses. Some 4475attributes are currently defined generically for variables. 4476Other attributes are defined for variables on particular target 4477systems. Other attributes are available for functions 4478(@pxref{Function Attributes}) and for types (@pxref{Type Attributes}). 4479Other front ends might define more attributes 4480(@pxref{C++ Extensions,,Extensions to the C++ Language}). 4481 4482You may also specify attributes with @samp{__} preceding and following 4483each keyword. This allows you to use them in header files without 4484being concerned about a possible macro of the same name. For example, 4485you may use @code{__aligned__} instead of @code{aligned}. 4486 4487@xref{Attribute Syntax}, for details of the exact syntax for using 4488attributes. 4489 4490@table @code 4491@cindex @code{aligned} attribute 4492@item aligned (@var{alignment}) 4493This attribute specifies a minimum alignment for the variable or 4494structure field, measured in bytes. For example, the declaration: 4495 4496@smallexample 4497int x __attribute__ ((aligned (16))) = 0; 4498@end smallexample 4499 4500@noindent 4501causes the compiler to allocate the global variable @code{x} on a 450216-byte boundary. On a 68040, this could be used in conjunction with 4503an @code{asm} expression to access the @code{move16} instruction which 4504requires 16-byte aligned operands. 4505 4506You can also specify the alignment of structure fields. For example, to 4507create a double-word aligned @code{int} pair, you could write: 4508 4509@smallexample 4510struct foo @{ int x[2] __attribute__ ((aligned (8))); @}; 4511@end smallexample 4512 4513@noindent 4514This is an alternative to creating a union with a @code{double} member 4515that forces the union to be double-word aligned. 4516 4517As in the preceding examples, you can explicitly specify the alignment 4518(in bytes) that you wish the compiler to use for a given variable or 4519structure field. Alternatively, you can leave out the alignment factor 4520and just ask the compiler to align a variable or field to the 4521default alignment for the target architecture you are compiling for. 4522The default alignment is sufficient for all scalar types, but may not be 4523enough for all vector types on a target which supports vector operations. 4524The default alignment is fixed for a particular target ABI. 4525 4526Gcc also provides a target specific macro @code{__BIGGEST_ALIGNMENT__}, 4527which is the largest alignment ever used for any data type on the 4528target machine you are compiling for. For example, you could write: 4529 4530@smallexample 4531short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__))); 4532@end smallexample 4533 4534The compiler automatically sets the alignment for the declared 4535variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can 4536often make copy operations more efficient, because the compiler can 4537use whatever instructions copy the biggest chunks of memory when 4538performing copies to or from the variables or fields that you have 4539aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__} 4540may change depending on command line options. 4541 4542When used on a struct, or struct member, the @code{aligned} attribute can 4543only increase the alignment; in order to decrease it, the @code{packed} 4544attribute must be specified as well. When used as part of a typedef, the 4545@code{aligned} attribute can both increase and decrease alignment, and 4546specifying the @code{packed} attribute will generate a warning. 4547 4548Note that the effectiveness of @code{aligned} attributes may be limited 4549by inherent limitations in your linker. On many systems, the linker is 4550only able to arrange for variables to be aligned up to a certain maximum 4551alignment. (For some linkers, the maximum supported alignment may 4552be very very small.) If your linker is only able to align variables 4553up to a maximum of 8 byte alignment, then specifying @code{aligned(16)} 4554in an @code{__attribute__} will still only provide you with 8 byte 4555alignment. See your linker documentation for further information. 4556 4557The @code{aligned} attribute can also be used for functions 4558(@pxref{Function Attributes}.) 4559 4560@item cleanup (@var{cleanup_function}) 4561@cindex @code{cleanup} attribute 4562The @code{cleanup} attribute runs a function when the variable goes 4563out of scope. This attribute can only be applied to auto function 4564scope variables; it may not be applied to parameters or variables 4565with static storage duration. The function must take one parameter, 4566a pointer to a type compatible with the variable. The return value 4567of the function (if any) is ignored. 4568 4569If @option{-fexceptions} is enabled, then @var{cleanup_function} 4570will be run during the stack unwinding that happens during the 4571processing of the exception. Note that the @code{cleanup} attribute 4572does not allow the exception to be caught, only to perform an action. 4573It is undefined what happens if @var{cleanup_function} does not 4574return normally. 4575 4576@item common 4577@itemx nocommon 4578@cindex @code{common} attribute 4579@cindex @code{nocommon} attribute 4580@opindex fcommon 4581@opindex fno-common 4582The @code{common} attribute requests GCC to place a variable in 4583``common'' storage. The @code{nocommon} attribute requests the 4584opposite---to allocate space for it directly. 4585 4586These attributes override the default chosen by the 4587@option{-fno-common} and @option{-fcommon} flags respectively. 4588 4589@item deprecated 4590@itemx deprecated (@var{msg}) 4591@cindex @code{deprecated} attribute 4592The @code{deprecated} attribute results in a warning if the variable 4593is used anywhere in the source file. This is useful when identifying 4594variables that are expected to be removed in a future version of a 4595program. The warning also includes the location of the declaration 4596of the deprecated variable, to enable users to easily find further 4597information about why the variable is deprecated, or what they should 4598do instead. Note that the warning only occurs for uses: 4599 4600@smallexample 4601extern int old_var __attribute__ ((deprecated)); 4602extern int old_var; 4603int new_fn () @{ return old_var; @} 4604@end smallexample 4605 4606results in a warning on line 3 but not line 2. The optional msg 4607argument, which must be a string, will be printed in the warning if 4608present. 4609 4610The @code{deprecated} attribute can also be used for functions and 4611types (@pxref{Function Attributes}, @pxref{Type Attributes}.) 4612 4613@item mode (@var{mode}) 4614@cindex @code{mode} attribute 4615This attribute specifies the data type for the declaration---whichever 4616type corresponds to the mode @var{mode}. This in effect lets you 4617request an integer or floating point type according to its width. 4618 4619You may also specify a mode of @samp{byte} or @samp{__byte__} to 4620indicate the mode corresponding to a one-byte integer, @samp{word} or 4621@samp{__word__} for the mode of a one-word integer, and @samp{pointer} 4622or @samp{__pointer__} for the mode used to represent pointers. 4623 4624@item packed 4625@cindex @code{packed} attribute 4626The @code{packed} attribute specifies that a variable or structure field 4627should have the smallest possible alignment---one byte for a variable, 4628and one bit for a field, unless you specify a larger value with the 4629@code{aligned} attribute. 4630 4631Here is a structure in which the field @code{x} is packed, so that it 4632immediately follows @code{a}: 4633 4634@smallexample 4635struct foo 4636@{ 4637 char a; 4638 int x[2] __attribute__ ((packed)); 4639@}; 4640@end smallexample 4641 4642@emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the 4643@code{packed} attribute on bit-fields of type @code{char}. This has 4644been fixed in GCC 4.4 but the change can lead to differences in the 4645structure layout. See the documentation of 4646@option{-Wpacked-bitfield-compat} for more information. 4647 4648@item section ("@var{section-name}") 4649@cindex @code{section} variable attribute 4650Normally, the compiler places the objects it generates in sections like 4651@code{data} and @code{bss}. Sometimes, however, you need additional sections, 4652or you need certain particular variables to appear in special sections, 4653for example to map to special hardware. The @code{section} 4654attribute specifies that a variable (or function) lives in a particular 4655section. For example, this small program uses several specific section names: 4656 4657@smallexample 4658struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @}; 4659struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @}; 4660char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @}; 4661int init_data __attribute__ ((section ("INITDATA"))); 4662 4663main() 4664@{ 4665 /* @r{Initialize stack pointer} */ 4666 init_sp (stack + sizeof (stack)); 4667 4668 /* @r{Initialize initialized data} */ 4669 memcpy (&init_data, &data, &edata - &data); 4670 4671 /* @r{Turn on the serial ports} */ 4672 init_duart (&a); 4673 init_duart (&b); 4674@} 4675@end smallexample 4676 4677@noindent 4678Use the @code{section} attribute with 4679@emph{global} variables and not @emph{local} variables, 4680as shown in the example. 4681 4682You may use the @code{section} attribute with initialized or 4683uninitialized global variables but the linker requires 4684each object be defined once, with the exception that uninitialized 4685variables tentatively go in the @code{common} (or @code{bss}) section 4686and can be multiply ``defined''. Using the @code{section} attribute 4687will change what section the variable goes into and may cause the 4688linker to issue an error if an uninitialized variable has multiple 4689definitions. You can force a variable to be initialized with the 4690@option{-fno-common} flag or the @code{nocommon} attribute. 4691 4692Some file formats do not support arbitrary sections so the @code{section} 4693attribute is not available on all platforms. 4694If you need to map the entire contents of a module to a particular 4695section, consider using the facilities of the linker instead. 4696 4697@item shared 4698@cindex @code{shared} variable attribute 4699On Microsoft Windows, in addition to putting variable definitions in a named 4700section, the section can also be shared among all running copies of an 4701executable or DLL@. For example, this small program defines shared data 4702by putting it in a named section @code{shared} and marking the section 4703shareable: 4704 4705@smallexample 4706int foo __attribute__((section ("shared"), shared)) = 0; 4707 4708int 4709main() 4710@{ 4711 /* @r{Read and write foo. All running 4712 copies see the same value.} */ 4713 return 0; 4714@} 4715@end smallexample 4716 4717@noindent 4718You may only use the @code{shared} attribute along with @code{section} 4719attribute with a fully initialized global definition because of the way 4720linkers work. See @code{section} attribute for more information. 4721 4722The @code{shared} attribute is only available on Microsoft Windows@. 4723 4724@item tls_model ("@var{tls_model}") 4725@cindex @code{tls_model} attribute 4726The @code{tls_model} attribute sets thread-local storage model 4727(@pxref{Thread-Local}) of a particular @code{__thread} variable, 4728overriding @option{-ftls-model=} command-line switch on a per-variable 4729basis. 4730The @var{tls_model} argument should be one of @code{global-dynamic}, 4731@code{local-dynamic}, @code{initial-exec} or @code{local-exec}. 4732 4733Not all targets support this attribute. 4734 4735@item unused 4736This attribute, attached to a variable, means that the variable is meant 4737to be possibly unused. GCC will not produce a warning for this 4738variable. 4739 4740@item used 4741This attribute, attached to a variable, means that the variable must be 4742emitted even if it appears that the variable is not referenced. 4743 4744When applied to a static data member of a C++ class template, the 4745attribute also means that the member will be instantiated if the 4746class itself is instantiated. 4747 4748@item vector_size (@var{bytes}) 4749This attribute specifies the vector size for the variable, measured in 4750bytes. For example, the declaration: 4751 4752@smallexample 4753int foo __attribute__ ((vector_size (16))); 4754@end smallexample 4755 4756@noindent 4757causes the compiler to set the mode for @code{foo}, to be 16 bytes, 4758divided into @code{int} sized units. Assuming a 32-bit int (a vector of 47594 units of 4 bytes), the corresponding mode of @code{foo} will be V4SI@. 4760 4761This attribute is only applicable to integral and float scalars, 4762although arrays, pointers, and function return values are allowed in 4763conjunction with this construct. 4764 4765Aggregates with this attribute are invalid, even if they are of the same 4766size as a corresponding scalar. For example, the declaration: 4767 4768@smallexample 4769struct S @{ int a; @}; 4770struct S __attribute__ ((vector_size (16))) foo; 4771@end smallexample 4772 4773@noindent 4774is invalid even if the size of the structure is the same as the size of 4775the @code{int}. 4776 4777@item selectany 4778The @code{selectany} attribute causes an initialized global variable to 4779have link-once semantics. When multiple definitions of the variable are 4780encountered by the linker, the first is selected and the remainder are 4781discarded. Following usage by the Microsoft compiler, the linker is told 4782@emph{not} to warn about size or content differences of the multiple 4783definitions. 4784 4785Although the primary usage of this attribute is for POD types, the 4786attribute can also be applied to global C++ objects that are initialized 4787by a constructor. In this case, the static initialization and destruction 4788code for the object is emitted in each translation defining the object, 4789but the calls to the constructor and destructor are protected by a 4790link-once guard variable. 4791 4792The @code{selectany} attribute is only available on Microsoft Windows 4793targets. You can use @code{__declspec (selectany)} as a synonym for 4794@code{__attribute__ ((selectany))} for compatibility with other 4795compilers. 4796 4797@item weak 4798The @code{weak} attribute is described in @ref{Function Attributes}. 4799 4800@item dllimport 4801The @code{dllimport} attribute is described in @ref{Function Attributes}. 4802 4803@item dllexport 4804The @code{dllexport} attribute is described in @ref{Function Attributes}. 4805 4806@end table 4807 4808@anchor{AVR Variable Attributes} 4809@subsection AVR Variable Attributes 4810 4811@table @code 4812@item progmem 4813@cindex @code{progmem} AVR variable attribute 4814The @code{progmem} attribute is used on the AVR to place read-only 4815data in the non-volatile program memory (flash). The @code{progmem} 4816attribute accomplishes this by putting respective variables into a 4817section whose name starts with @code{.progmem}. 4818 4819This attribute works similar to the @code{section} attribute 4820but adds additional checking. Notice that just like the 4821@code{section} attribute, @code{progmem} affects the location 4822of the data but not how this data is accessed. 4823 4824In order to read data located with the @code{progmem} attribute 4825(inline) assembler must be used. 4826@example 4827/* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */ 4828#include <avr/pgmspace.h> 4829 4830/* Locate var in flash memory */ 4831const int var[2] PROGMEM = @{ 1, 2 @}; 4832 4833int read_var (int i) 4834@{ 4835 /* Access var[] by accessor macro from avr/pgmspace.h */ 4836 return (int) pgm_read_word (& var[i]); 4837@} 4838@end example 4839 4840AVR is a Harvard architecture processor and data and read-only data 4841normally resides in the data memory (RAM). 4842 4843See also the @ref{AVR Named Address Spaces} section for 4844an alternate way to locate and access data in flash memory. 4845@end table 4846 4847@subsection Blackfin Variable Attributes 4848 4849Three attributes are currently defined for the Blackfin. 4850 4851@table @code 4852@item l1_data 4853@itemx l1_data_A 4854@itemx l1_data_B 4855@cindex @code{l1_data} variable attribute 4856@cindex @code{l1_data_A} variable attribute 4857@cindex @code{l1_data_B} variable attribute 4858Use these attributes on the Blackfin to place the variable into L1 Data SRAM. 4859Variables with @code{l1_data} attribute will be put into the specific section 4860named @code{.l1.data}. Those with @code{l1_data_A} attribute will be put into 4861the specific section named @code{.l1.data.A}. Those with @code{l1_data_B} 4862attribute will be put into the specific section named @code{.l1.data.B}. 4863 4864@item l2 4865@cindex @code{l2} variable attribute 4866Use this attribute on the Blackfin to place the variable into L2 SRAM. 4867Variables with @code{l2} attribute will be put into the specific section 4868named @code{.l2.data}. 4869@end table 4870 4871@subsection M32R/D Variable Attributes 4872 4873One attribute is currently defined for the M32R/D@. 4874 4875@table @code 4876@item model (@var{model-name}) 4877@cindex variable addressability on the M32R/D 4878Use this attribute on the M32R/D to set the addressability of an object. 4879The identifier @var{model-name} is one of @code{small}, @code{medium}, 4880or @code{large}, representing each of the code models. 4881 4882Small model objects live in the lower 16MB of memory (so that their 4883addresses can be loaded with the @code{ld24} instruction). 4884 4885Medium and large model objects may live anywhere in the 32-bit address space 4886(the compiler will generate @code{seth/add3} instructions to load their 4887addresses). 4888@end table 4889 4890@anchor{MeP Variable Attributes} 4891@subsection MeP Variable Attributes 4892 4893The MeP target has a number of addressing modes and busses. The 4894@code{near} space spans the standard memory space's first 16 megabytes 4895(24 bits). The @code{far} space spans the entire 32-bit memory space. 4896The @code{based} space is a 128 byte region in the memory space which 4897is addressed relative to the @code{$tp} register. The @code{tiny} 4898space is a 65536 byte region relative to the @code{$gp} register. In 4899addition to these memory regions, the MeP target has a separate 16-bit 4900control bus which is specified with @code{cb} attributes. 4901 4902@table @code 4903 4904@item based 4905Any variable with the @code{based} attribute will be assigned to the 4906@code{.based} section, and will be accessed with relative to the 4907@code{$tp} register. 4908 4909@item tiny 4910Likewise, the @code{tiny} attribute assigned variables to the 4911@code{.tiny} section, relative to the @code{$gp} register. 4912 4913@item near 4914Variables with the @code{near} attribute are assumed to have addresses 4915that fit in a 24-bit addressing mode. This is the default for large 4916variables (@code{-mtiny=4} is the default) but this attribute can 4917override @code{-mtiny=} for small variables, or override @code{-ml}. 4918 4919@item far 4920Variables with the @code{far} attribute are addressed using a full 492132-bit address. Since this covers the entire memory space, this 4922allows modules to make no assumptions about where variables might be 4923stored. 4924 4925@item io 4926@itemx io (@var{addr}) 4927Variables with the @code{io} attribute are used to address 4928memory-mapped peripherals. If an address is specified, the variable 4929is assigned that address, else it is not assigned an address (it is 4930assumed some other module will assign an address). Example: 4931 4932@example 4933int timer_count __attribute__((io(0x123))); 4934@end example 4935 4936@item cb 4937@itemx cb (@var{addr}) 4938Variables with the @code{cb} attribute are used to access the control 4939bus, using special instructions. @code{addr} indicates the control bus 4940address. Example: 4941 4942@example 4943int cpu_clock __attribute__((cb(0x123))); 4944@end example 4945 4946@end table 4947 4948@anchor{i386 Variable Attributes} 4949@subsection i386 Variable Attributes 4950 4951Two attributes are currently defined for i386 configurations: 4952@code{ms_struct} and @code{gcc_struct} 4953 4954@table @code 4955@item ms_struct 4956@itemx gcc_struct 4957@cindex @code{ms_struct} attribute 4958@cindex @code{gcc_struct} attribute 4959 4960If @code{packed} is used on a structure, or if bit-fields are used 4961it may be that the Microsoft ABI packs them differently 4962than GCC would normally pack them. Particularly when moving packed 4963data between functions compiled with GCC and the native Microsoft compiler 4964(either via function call or as data in a file), it may be necessary to access 4965either format. 4966 4967Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86 4968compilers to match the native Microsoft compiler. 4969 4970The Microsoft structure layout algorithm is fairly simple with the exception 4971of the bitfield packing: 4972 4973The padding and alignment of members of structures and whether a bit field 4974can straddle a storage-unit boundary 4975 4976@enumerate 4977@item Structure members are stored sequentially in the order in which they are 4978declared: the first member has the lowest memory address and the last member 4979the highest. 4980 4981@item Every data object has an alignment-requirement. The alignment-requirement 4982for all data except structures, unions, and arrays is either the size of the 4983object or the current packing size (specified with either the aligned attribute 4984or the pack pragma), whichever is less. For structures, unions, and arrays, 4985the alignment-requirement is the largest alignment-requirement of its members. 4986Every object is allocated an offset so that: 4987 4988offset % alignment-requirement == 0 4989 4990@item Adjacent bit fields are packed into the same 1-, 2-, or 4-byte allocation 4991unit if the integral types are the same size and if the next bit field fits 4992into the current allocation unit without crossing the boundary imposed by the 4993common alignment requirements of the bit fields. 4994@end enumerate 4995 4996Handling of zero-length bitfields: 4997 4998MSVC interprets zero-length bitfields in the following ways: 4999 5000@enumerate 5001@item If a zero-length bitfield is inserted between two bitfields that would 5002normally be coalesced, the bitfields will not be coalesced. 5003 5004For example: 5005 5006@smallexample 5007struct 5008 @{ 5009 unsigned long bf_1 : 12; 5010 unsigned long : 0; 5011 unsigned long bf_2 : 12; 5012 @} t1; 5013@end smallexample 5014 5015The size of @code{t1} would be 8 bytes with the zero-length bitfield. If the 5016zero-length bitfield were removed, @code{t1}'s size would be 4 bytes. 5017 5018@item If a zero-length bitfield is inserted after a bitfield, @code{foo}, and the 5019alignment of the zero-length bitfield is greater than the member that follows it, 5020@code{bar}, @code{bar} will be aligned as the type of the zero-length bitfield. 5021 5022For example: 5023 5024@smallexample 5025struct 5026 @{ 5027 char foo : 4; 5028 short : 0; 5029 char bar; 5030 @} t2; 5031 5032struct 5033 @{ 5034 char foo : 4; 5035 short : 0; 5036 double bar; 5037 @} t3; 5038@end smallexample 5039 5040For @code{t2}, @code{bar} will be placed at offset 2, rather than offset 1. 5041Accordingly, the size of @code{t2} will be 4. For @code{t3}, the zero-length 5042bitfield will not affect the alignment of @code{bar} or, as a result, the size 5043of the structure. 5044 5045Taking this into account, it is important to note the following: 5046 5047@enumerate 5048@item If a zero-length bitfield follows a normal bitfield, the type of the 5049zero-length bitfield may affect the alignment of the structure as whole. For 5050example, @code{t2} has a size of 4 bytes, since the zero-length bitfield follows a 5051normal bitfield, and is of type short. 5052 5053@item Even if a zero-length bitfield is not followed by a normal bitfield, it may 5054still affect the alignment of the structure: 5055 5056@smallexample 5057struct 5058 @{ 5059 char foo : 6; 5060 long : 0; 5061 @} t4; 5062@end smallexample 5063 5064Here, @code{t4} will take up 4 bytes. 5065@end enumerate 5066 5067@item Zero-length bitfields following non-bitfield members are ignored: 5068 5069@smallexample 5070struct 5071 @{ 5072 char foo; 5073 long : 0; 5074 char bar; 5075 @} t5; 5076@end smallexample 5077 5078Here, @code{t5} will take up 2 bytes. 5079@end enumerate 5080@end table 5081 5082@subsection PowerPC Variable Attributes 5083 5084Three attributes currently are defined for PowerPC configurations: 5085@code{altivec}, @code{ms_struct} and @code{gcc_struct}. 5086 5087For full documentation of the struct attributes please see the 5088documentation in @ref{i386 Variable Attributes}. 5089 5090For documentation of @code{altivec} attribute please see the 5091documentation in @ref{PowerPC Type Attributes}. 5092 5093@subsection SPU Variable Attributes 5094 5095The SPU supports the @code{spu_vector} attribute for variables. For 5096documentation of this attribute please see the documentation in 5097@ref{SPU Type Attributes}. 5098 5099@subsection Xstormy16 Variable Attributes 5100 5101One attribute is currently defined for xstormy16 configurations: 5102@code{below100}. 5103 5104@table @code 5105@item below100 5106@cindex @code{below100} attribute 5107 5108If a variable has the @code{below100} attribute (@code{BELOW100} is 5109allowed also), GCC will place the variable in the first 0x100 bytes of 5110memory and use special opcodes to access it. Such variables will be 5111placed in either the @code{.bss_below100} section or the 5112@code{.data_below100} section. 5113 5114@end table 5115 5116@node Type Attributes 5117@section Specifying Attributes of Types 5118@cindex attribute of types 5119@cindex type attributes 5120 5121The keyword @code{__attribute__} allows you to specify special 5122attributes of @code{struct} and @code{union} types when you define 5123such types. This keyword is followed by an attribute specification 5124inside double parentheses. Seven attributes are currently defined for 5125types: @code{aligned}, @code{packed}, @code{transparent_union}, 5126@code{unused}, @code{deprecated}, @code{visibility}, and 5127@code{may_alias}. Other attributes are defined for functions 5128(@pxref{Function Attributes}) and for variables (@pxref{Variable 5129Attributes}). 5130 5131You may also specify any one of these attributes with @samp{__} 5132preceding and following its keyword. This allows you to use these 5133attributes in header files without being concerned about a possible 5134macro of the same name. For example, you may use @code{__aligned__} 5135instead of @code{aligned}. 5136 5137You may specify type attributes in an enum, struct or union type 5138declaration or definition, or for other types in a @code{typedef} 5139declaration. 5140 5141For an enum, struct or union type, you may specify attributes either 5142between the enum, struct or union tag and the name of the type, or 5143just past the closing curly brace of the @emph{definition}. The 5144former syntax is preferred. 5145 5146@xref{Attribute Syntax}, for details of the exact syntax for using 5147attributes. 5148 5149@table @code 5150@cindex @code{aligned} attribute 5151@item aligned (@var{alignment}) 5152This attribute specifies a minimum alignment (in bytes) for variables 5153of the specified type. For example, the declarations: 5154 5155@smallexample 5156struct S @{ short f[3]; @} __attribute__ ((aligned (8))); 5157typedef int more_aligned_int __attribute__ ((aligned (8))); 5158@end smallexample 5159 5160@noindent 5161force the compiler to insure (as far as it can) that each variable whose 5162type is @code{struct S} or @code{more_aligned_int} will be allocated and 5163aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all 5164variables of type @code{struct S} aligned to 8-byte boundaries allows 5165the compiler to use the @code{ldd} and @code{std} (doubleword load and 5166store) instructions when copying one variable of type @code{struct S} to 5167another, thus improving run-time efficiency. 5168 5169Note that the alignment of any given @code{struct} or @code{union} type 5170is required by the ISO C standard to be at least a perfect multiple of 5171the lowest common multiple of the alignments of all of the members of 5172the @code{struct} or @code{union} in question. This means that you @emph{can} 5173effectively adjust the alignment of a @code{struct} or @code{union} 5174type by attaching an @code{aligned} attribute to any one of the members 5175of such a type, but the notation illustrated in the example above is a 5176more obvious, intuitive, and readable way to request the compiler to 5177adjust the alignment of an entire @code{struct} or @code{union} type. 5178 5179As in the preceding example, you can explicitly specify the alignment 5180(in bytes) that you wish the compiler to use for a given @code{struct} 5181or @code{union} type. Alternatively, you can leave out the alignment factor 5182and just ask the compiler to align a type to the maximum 5183useful alignment for the target machine you are compiling for. For 5184example, you could write: 5185 5186@smallexample 5187struct S @{ short f[3]; @} __attribute__ ((aligned)); 5188@end smallexample 5189 5190Whenever you leave out the alignment factor in an @code{aligned} 5191attribute specification, the compiler automatically sets the alignment 5192for the type to the largest alignment which is ever used for any data 5193type on the target machine you are compiling for. Doing this can often 5194make copy operations more efficient, because the compiler can use 5195whatever instructions copy the biggest chunks of memory when performing 5196copies to or from the variables which have types that you have aligned 5197this way. 5198 5199In the example above, if the size of each @code{short} is 2 bytes, then 5200the size of the entire @code{struct S} type is 6 bytes. The smallest 5201power of two which is greater than or equal to that is 8, so the 5202compiler sets the alignment for the entire @code{struct S} type to 8 5203bytes. 5204 5205Note that although you can ask the compiler to select a time-efficient 5206alignment for a given type and then declare only individual stand-alone 5207objects of that type, the compiler's ability to select a time-efficient 5208alignment is primarily useful only when you plan to create arrays of 5209variables having the relevant (efficiently aligned) type. If you 5210declare or use arrays of variables of an efficiently-aligned type, then 5211it is likely that your program will also be doing pointer arithmetic (or 5212subscripting, which amounts to the same thing) on pointers to the 5213relevant type, and the code that the compiler generates for these 5214pointer arithmetic operations will often be more efficient for 5215efficiently-aligned types than for other types. 5216 5217The @code{aligned} attribute can only increase the alignment; but you 5218can decrease it by specifying @code{packed} as well. See below. 5219 5220Note that the effectiveness of @code{aligned} attributes may be limited 5221by inherent limitations in your linker. On many systems, the linker is 5222only able to arrange for variables to be aligned up to a certain maximum 5223alignment. (For some linkers, the maximum supported alignment may 5224be very very small.) If your linker is only able to align variables 5225up to a maximum of 8 byte alignment, then specifying @code{aligned(16)} 5226in an @code{__attribute__} will still only provide you with 8 byte 5227alignment. See your linker documentation for further information. 5228 5229@item packed 5230This attribute, attached to @code{struct} or @code{union} type 5231definition, specifies that each member (other than zero-width bitfields) 5232of the structure or union is placed to minimize the memory required. When 5233attached to an @code{enum} definition, it indicates that the smallest 5234integral type should be used. 5235 5236@opindex fshort-enums 5237Specifying this attribute for @code{struct} and @code{union} types is 5238equivalent to specifying the @code{packed} attribute on each of the 5239structure or union members. Specifying the @option{-fshort-enums} 5240flag on the line is equivalent to specifying the @code{packed} 5241attribute on all @code{enum} definitions. 5242 5243In the following example @code{struct my_packed_struct}'s members are 5244packed closely together, but the internal layout of its @code{s} member 5245is not packed---to do that, @code{struct my_unpacked_struct} would need to 5246be packed too. 5247 5248@smallexample 5249struct my_unpacked_struct 5250 @{ 5251 char c; 5252 int i; 5253 @}; 5254 5255struct __attribute__ ((__packed__)) my_packed_struct 5256 @{ 5257 char c; 5258 int i; 5259 struct my_unpacked_struct s; 5260 @}; 5261@end smallexample 5262 5263You may only specify this attribute on the definition of an @code{enum}, 5264@code{struct} or @code{union}, not on a @code{typedef} which does not 5265also define the enumerated type, structure or union. 5266 5267@item transparent_union 5268This attribute, attached to a @code{union} type definition, indicates 5269that any function parameter having that union type causes calls to that 5270function to be treated in a special way. 5271 5272First, the argument corresponding to a transparent union type can be of 5273any type in the union; no cast is required. Also, if the union contains 5274a pointer type, the corresponding argument can be a null pointer 5275constant or a void pointer expression; and if the union contains a void 5276pointer type, the corresponding argument can be any pointer expression. 5277If the union member type is a pointer, qualifiers like @code{const} on 5278the referenced type must be respected, just as with normal pointer 5279conversions. 5280 5281Second, the argument is passed to the function using the calling 5282conventions of the first member of the transparent union, not the calling 5283conventions of the union itself. All members of the union must have the 5284same machine representation; this is necessary for this argument passing 5285to work properly. 5286 5287Transparent unions are designed for library functions that have multiple 5288interfaces for compatibility reasons. For example, suppose the 5289@code{wait} function must accept either a value of type @code{int *} to 5290comply with Posix, or a value of type @code{union wait *} to comply with 5291the 4.1BSD interface. If @code{wait}'s parameter were @code{void *}, 5292@code{wait} would accept both kinds of arguments, but it would also 5293accept any other pointer type and this would make argument type checking 5294less useful. Instead, @code{<sys/wait.h>} might define the interface 5295as follows: 5296 5297@smallexample 5298typedef union __attribute__ ((__transparent_union__)) 5299 @{ 5300 int *__ip; 5301 union wait *__up; 5302 @} wait_status_ptr_t; 5303 5304pid_t wait (wait_status_ptr_t); 5305@end smallexample 5306 5307This interface allows either @code{int *} or @code{union wait *} 5308arguments to be passed, using the @code{int *} calling convention. 5309The program can call @code{wait} with arguments of either type: 5310 5311@smallexample 5312int w1 () @{ int w; return wait (&w); @} 5313int w2 () @{ union wait w; return wait (&w); @} 5314@end smallexample 5315 5316With this interface, @code{wait}'s implementation might look like this: 5317 5318@smallexample 5319pid_t wait (wait_status_ptr_t p) 5320@{ 5321 return waitpid (-1, p.__ip, 0); 5322@} 5323@end smallexample 5324 5325@item unused 5326When attached to a type (including a @code{union} or a @code{struct}), 5327this attribute means that variables of that type are meant to appear 5328possibly unused. GCC will not produce a warning for any variables of 5329that type, even if the variable appears to do nothing. This is often 5330the case with lock or thread classes, which are usually defined and then 5331not referenced, but contain constructors and destructors that have 5332nontrivial bookkeeping functions. 5333 5334@item deprecated 5335@itemx deprecated (@var{msg}) 5336The @code{deprecated} attribute results in a warning if the type 5337is used anywhere in the source file. This is useful when identifying 5338types that are expected to be removed in a future version of a program. 5339If possible, the warning also includes the location of the declaration 5340of the deprecated type, to enable users to easily find further 5341information about why the type is deprecated, or what they should do 5342instead. Note that the warnings only occur for uses and then only 5343if the type is being applied to an identifier that itself is not being 5344declared as deprecated. 5345 5346@smallexample 5347typedef int T1 __attribute__ ((deprecated)); 5348T1 x; 5349typedef T1 T2; 5350T2 y; 5351typedef T1 T3 __attribute__ ((deprecated)); 5352T3 z __attribute__ ((deprecated)); 5353@end smallexample 5354 5355results in a warning on line 2 and 3 but not lines 4, 5, or 6. No 5356warning is issued for line 4 because T2 is not explicitly 5357deprecated. Line 5 has no warning because T3 is explicitly 5358deprecated. Similarly for line 6. The optional msg 5359argument, which must be a string, will be printed in the warning if 5360present. 5361 5362The @code{deprecated} attribute can also be used for functions and 5363variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.) 5364 5365@item may_alias 5366Accesses through pointers to types with this attribute are not subject 5367to type-based alias analysis, but are instead assumed to be able to alias 5368any other type of objects. In the context of 6.5/7 an lvalue expression 5369dereferencing such a pointer is treated like having a character type. 5370See @option{-fstrict-aliasing} for more information on aliasing issues. 5371This extension exists to support some vector APIs, in which pointers to 5372one vector type are permitted to alias pointers to a different vector type. 5373 5374Note that an object of a type with this attribute does not have any 5375special semantics. 5376 5377Example of use: 5378 5379@smallexample 5380typedef short __attribute__((__may_alias__)) short_a; 5381 5382int 5383main (void) 5384@{ 5385 int a = 0x12345678; 5386 short_a *b = (short_a *) &a; 5387 5388 b[1] = 0; 5389 5390 if (a == 0x12345678) 5391 abort(); 5392 5393 exit(0); 5394@} 5395@end smallexample 5396 5397If you replaced @code{short_a} with @code{short} in the variable 5398declaration, the above program would abort when compiled with 5399@option{-fstrict-aliasing}, which is on by default at @option{-O2} or 5400above in recent GCC versions. 5401 5402@item visibility 5403In C++, attribute visibility (@pxref{Function Attributes}) can also be 5404applied to class, struct, union and enum types. Unlike other type 5405attributes, the attribute must appear between the initial keyword and 5406the name of the type; it cannot appear after the body of the type. 5407 5408Note that the type visibility is applied to vague linkage entities 5409associated with the class (vtable, typeinfo node, etc.). In 5410particular, if a class is thrown as an exception in one shared object 5411and caught in another, the class must have default visibility. 5412Otherwise the two shared objects will be unable to use the same 5413typeinfo node and exception handling will break. 5414 5415@end table 5416 5417@subsection ARM Type Attributes 5418 5419On those ARM targets that support @code{dllimport} (such as Symbian 5420OS), you can use the @code{notshared} attribute to indicate that the 5421virtual table and other similar data for a class should not be 5422exported from a DLL@. For example: 5423 5424@smallexample 5425class __declspec(notshared) C @{ 5426public: 5427 __declspec(dllimport) C(); 5428 virtual void f(); 5429@} 5430 5431__declspec(dllexport) 5432C::C() @{@} 5433@end smallexample 5434 5435In this code, @code{C::C} is exported from the current DLL, but the 5436virtual table for @code{C} is not exported. (You can use 5437@code{__attribute__} instead of @code{__declspec} if you prefer, but 5438most Symbian OS code uses @code{__declspec}.) 5439 5440@anchor{MeP Type Attributes} 5441@subsection MeP Type Attributes 5442 5443Many of the MeP variable attributes may be applied to types as well. 5444Specifically, the @code{based}, @code{tiny}, @code{near}, and 5445@code{far} attributes may be applied to either. The @code{io} and 5446@code{cb} attributes may not be applied to types. 5447 5448@anchor{i386 Type Attributes} 5449@subsection i386 Type Attributes 5450 5451Two attributes are currently defined for i386 configurations: 5452@code{ms_struct} and @code{gcc_struct}. 5453 5454@table @code 5455 5456@item ms_struct 5457@itemx gcc_struct 5458@cindex @code{ms_struct} 5459@cindex @code{gcc_struct} 5460 5461If @code{packed} is used on a structure, or if bit-fields are used 5462it may be that the Microsoft ABI packs them differently 5463than GCC would normally pack them. Particularly when moving packed 5464data between functions compiled with GCC and the native Microsoft compiler 5465(either via function call or as data in a file), it may be necessary to access 5466either format. 5467 5468Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86 5469compilers to match the native Microsoft compiler. 5470@end table 5471 5472To specify multiple attributes, separate them by commas within the 5473double parentheses: for example, @samp{__attribute__ ((aligned (16), 5474packed))}. 5475 5476@anchor{PowerPC Type Attributes} 5477@subsection PowerPC Type Attributes 5478 5479Three attributes currently are defined for PowerPC configurations: 5480@code{altivec}, @code{ms_struct} and @code{gcc_struct}. 5481 5482For full documentation of the @code{ms_struct} and @code{gcc_struct} 5483attributes please see the documentation in @ref{i386 Type Attributes}. 5484 5485The @code{altivec} attribute allows one to declare AltiVec vector data 5486types supported by the AltiVec Programming Interface Manual. The 5487attribute requires an argument to specify one of three vector types: 5488@code{vector__}, @code{pixel__} (always followed by unsigned short), 5489and @code{bool__} (always followed by unsigned). 5490 5491@smallexample 5492__attribute__((altivec(vector__))) 5493__attribute__((altivec(pixel__))) unsigned short 5494__attribute__((altivec(bool__))) unsigned 5495@end smallexample 5496 5497These attributes mainly are intended to support the @code{__vector}, 5498@code{__pixel}, and @code{__bool} AltiVec keywords. 5499 5500@anchor{SPU Type Attributes} 5501@subsection SPU Type Attributes 5502 5503The SPU supports the @code{spu_vector} attribute for types. This attribute 5504allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU 5505Language Extensions Specification. It is intended to support the 5506@code{__vector} keyword. 5507 5508@node Alignment 5509@section Inquiring on Alignment of Types or Variables 5510@cindex alignment 5511@cindex type alignment 5512@cindex variable alignment 5513 5514The keyword @code{__alignof__} allows you to inquire about how an object 5515is aligned, or the minimum alignment usually required by a type. Its 5516syntax is just like @code{sizeof}. 5517 5518For example, if the target machine requires a @code{double} value to be 5519aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8. 5520This is true on many RISC machines. On more traditional machine 5521designs, @code{__alignof__ (double)} is 4 or even 2. 5522 5523Some machines never actually require alignment; they allow reference to any 5524data type even at an odd address. For these machines, @code{__alignof__} 5525reports the smallest alignment that GCC will give the data type, usually as 5526mandated by the target ABI. 5527 5528If the operand of @code{__alignof__} is an lvalue rather than a type, 5529its value is the required alignment for its type, taking into account 5530any minimum alignment specified with GCC's @code{__attribute__} 5531extension (@pxref{Variable Attributes}). For example, after this 5532declaration: 5533 5534@smallexample 5535struct foo @{ int x; char y; @} foo1; 5536@end smallexample 5537 5538@noindent 5539the value of @code{__alignof__ (foo1.y)} is 1, even though its actual 5540alignment is probably 2 or 4, the same as @code{__alignof__ (int)}. 5541 5542It is an error to ask for the alignment of an incomplete type. 5543 5544 5545@node Inline 5546@section An Inline Function is As Fast As a Macro 5547@cindex inline functions 5548@cindex integrating function code 5549@cindex open coding 5550@cindex macros, inline alternative 5551 5552By declaring a function inline, you can direct GCC to make 5553calls to that function faster. One way GCC can achieve this is to 5554integrate that function's code into the code for its callers. This 5555makes execution faster by eliminating the function-call overhead; in 5556addition, if any of the actual argument values are constant, their 5557known values may permit simplifications at compile time so that not 5558all of the inline function's code needs to be included. The effect on 5559code size is less predictable; object code may be larger or smaller 5560with function inlining, depending on the particular case. You can 5561also direct GCC to try to integrate all ``simple enough'' functions 5562into their callers with the option @option{-finline-functions}. 5563 5564GCC implements three different semantics of declaring a function 5565inline. One is available with @option{-std=gnu89} or 5566@option{-fgnu89-inline} or when @code{gnu_inline} attribute is present 5567on all inline declarations, another when 5568@option{-std=c99}, @option{-std=c11}, 5569@option{-std=gnu99} or @option{-std=gnu11} 5570(without @option{-fgnu89-inline}), and the third 5571is used when compiling C++. 5572 5573To declare a function inline, use the @code{inline} keyword in its 5574declaration, like this: 5575 5576@smallexample 5577static inline int 5578inc (int *a) 5579@{ 5580 return (*a)++; 5581@} 5582@end smallexample 5583 5584If you are writing a header file to be included in ISO C90 programs, write 5585@code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}. 5586 5587The three types of inlining behave similarly in two important cases: 5588when the @code{inline} keyword is used on a @code{static} function, 5589like the example above, and when a function is first declared without 5590using the @code{inline} keyword and then is defined with 5591@code{inline}, like this: 5592 5593@smallexample 5594extern int inc (int *a); 5595inline int 5596inc (int *a) 5597@{ 5598 return (*a)++; 5599@} 5600@end smallexample 5601 5602In both of these common cases, the program behaves the same as if you 5603had not used the @code{inline} keyword, except for its speed. 5604 5605@cindex inline functions, omission of 5606@opindex fkeep-inline-functions 5607When a function is both inline and @code{static}, if all calls to the 5608function are integrated into the caller, and the function's address is 5609never used, then the function's own assembler code is never referenced. 5610In this case, GCC does not actually output assembler code for the 5611function, unless you specify the option @option{-fkeep-inline-functions}. 5612Some calls cannot be integrated for various reasons (in particular, 5613calls that precede the function's definition cannot be integrated, and 5614neither can recursive calls within the definition). If there is a 5615nonintegrated call, then the function is compiled to assembler code as 5616usual. The function must also be compiled as usual if the program 5617refers to its address, because that can't be inlined. 5618 5619@opindex Winline 5620Note that certain usages in a function definition can make it unsuitable 5621for inline substitution. Among these usages are: use of varargs, use of 5622alloca, use of variable sized data types (@pxref{Variable Length}), 5623use of computed goto (@pxref{Labels as Values}), use of nonlocal goto, 5624and nested functions (@pxref{Nested Functions}). Using @option{-Winline} 5625will warn when a function marked @code{inline} could not be substituted, 5626and will give the reason for the failure. 5627 5628@cindex automatic @code{inline} for C++ member fns 5629@cindex @code{inline} automatic for C++ member fns 5630@cindex member fns, automatically @code{inline} 5631@cindex C++ member fns, automatically @code{inline} 5632@opindex fno-default-inline 5633As required by ISO C++, GCC considers member functions defined within 5634the body of a class to be marked inline even if they are 5635not explicitly declared with the @code{inline} keyword. You can 5636override this with @option{-fno-default-inline}; @pxref{C++ Dialect 5637Options,,Options Controlling C++ Dialect}. 5638 5639GCC does not inline any functions when not optimizing unless you specify 5640the @samp{always_inline} attribute for the function, like this: 5641 5642@smallexample 5643/* @r{Prototype.} */ 5644inline void foo (const char) __attribute__((always_inline)); 5645@end smallexample 5646 5647The remainder of this section is specific to GNU C90 inlining. 5648 5649@cindex non-static inline function 5650When an inline function is not @code{static}, then the compiler must assume 5651that there may be calls from other source files; since a global symbol can 5652be defined only once in any program, the function must not be defined in 5653the other source files, so the calls therein cannot be integrated. 5654Therefore, a non-@code{static} inline function is always compiled on its 5655own in the usual fashion. 5656 5657If you specify both @code{inline} and @code{extern} in the function 5658definition, then the definition is used only for inlining. In no case 5659is the function compiled on its own, not even if you refer to its 5660address explicitly. Such an address becomes an external reference, as 5661if you had only declared the function, and had not defined it. 5662 5663This combination of @code{inline} and @code{extern} has almost the 5664effect of a macro. The way to use it is to put a function definition in 5665a header file with these keywords, and put another copy of the 5666definition (lacking @code{inline} and @code{extern}) in a library file. 5667The definition in the header file will cause most calls to the function 5668to be inlined. If any uses of the function remain, they will refer to 5669the single copy in the library. 5670 5671@node Volatiles 5672@section When is a Volatile Object Accessed? 5673@cindex accessing volatiles 5674@cindex volatile read 5675@cindex volatile write 5676@cindex volatile access 5677 5678C has the concept of volatile objects. These are normally accessed by 5679pointers and used for accessing hardware or inter-thread 5680communication. The standard encourages compilers to refrain from 5681optimizations concerning accesses to volatile objects, but leaves it 5682implementation defined as to what constitutes a volatile access. The 5683minimum requirement is that at a sequence point all previous accesses 5684to volatile objects have stabilized and no subsequent accesses have 5685occurred. Thus an implementation is free to reorder and combine 5686volatile accesses which occur between sequence points, but cannot do 5687so for accesses across a sequence point. The use of volatile does 5688not allow you to violate the restriction on updating objects multiple 5689times between two sequence points. 5690 5691Accesses to non-volatile objects are not ordered with respect to 5692volatile accesses. You cannot use a volatile object as a memory 5693barrier to order a sequence of writes to non-volatile memory. For 5694instance: 5695 5696@smallexample 5697int *ptr = @var{something}; 5698volatile int vobj; 5699*ptr = @var{something}; 5700vobj = 1; 5701@end smallexample 5702 5703Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed 5704that the write to @var{*ptr} will have occurred by the time the update 5705of @var{vobj} has happened. If you need this guarantee, you must use 5706a stronger memory barrier such as: 5707 5708@smallexample 5709int *ptr = @var{something}; 5710volatile int vobj; 5711*ptr = @var{something}; 5712asm volatile ("" : : : "memory"); 5713vobj = 1; 5714@end smallexample 5715 5716A scalar volatile object is read when it is accessed in a void context: 5717 5718@smallexample 5719volatile int *src = @var{somevalue}; 5720*src; 5721@end smallexample 5722 5723Such expressions are rvalues, and GCC implements this as a 5724read of the volatile object being pointed to. 5725 5726Assignments are also expressions and have an rvalue. However when 5727assigning to a scalar volatile, the volatile object is not reread, 5728regardless of whether the assignment expression's rvalue is used or 5729not. If the assignment's rvalue is used, the value is that assigned 5730to the volatile object. For instance, there is no read of @var{vobj} 5731in all the following cases: 5732 5733@smallexample 5734int obj; 5735volatile int vobj; 5736vobj = @var{something}; 5737obj = vobj = @var{something}; 5738obj ? vobj = @var{onething} : vobj = @var{anotherthing}; 5739obj = (@var{something}, vobj = @var{anotherthing}); 5740@end smallexample 5741 5742If you need to read the volatile object after an assignment has 5743occurred, you must use a separate expression with an intervening 5744sequence point. 5745 5746As bitfields are not individually addressable, volatile bitfields may 5747be implicitly read when written to, or when adjacent bitfields are 5748accessed. Bitfield operations may be optimized such that adjacent 5749bitfields are only partially accessed, if they straddle a storage unit 5750boundary. For these reasons it is unwise to use volatile bitfields to 5751access hardware. 5752 5753@node Extended Asm 5754@section Assembler Instructions with C Expression Operands 5755@cindex extended @code{asm} 5756@cindex @code{asm} expressions 5757@cindex assembler instructions 5758@cindex registers 5759 5760In an assembler instruction using @code{asm}, you can specify the 5761operands of the instruction using C expressions. This means you need not 5762guess which registers or memory locations will contain the data you want 5763to use. 5764 5765You must specify an assembler instruction template much like what 5766appears in a machine description, plus an operand constraint string for 5767each operand. 5768 5769For example, here is how to use the 68881's @code{fsinx} instruction: 5770 5771@smallexample 5772asm ("fsinx %1,%0" : "=f" (result) : "f" (angle)); 5773@end smallexample 5774 5775@noindent 5776Here @code{angle} is the C expression for the input operand while 5777@code{result} is that of the output operand. Each has @samp{"f"} as its 5778operand constraint, saying that a floating point register is required. 5779The @samp{=} in @samp{=f} indicates that the operand is an output; all 5780output operands' constraints must use @samp{=}. The constraints use the 5781same language used in the machine description (@pxref{Constraints}). 5782 5783Each operand is described by an operand-constraint string followed by 5784the C expression in parentheses. A colon separates the assembler 5785template from the first output operand and another separates the last 5786output operand from the first input, if any. Commas separate the 5787operands within each group. The total number of operands is currently 5788limited to 30; this limitation may be lifted in some future version of 5789GCC@. 5790 5791If there are no output operands but there are input operands, you must 5792place two consecutive colons surrounding the place where the output 5793operands would go. 5794 5795As of GCC version 3.1, it is also possible to specify input and output 5796operands using symbolic names which can be referenced within the 5797assembler code. These names are specified inside square brackets 5798preceding the constraint string, and can be referenced inside the 5799assembler code using @code{%[@var{name}]} instead of a percentage sign 5800followed by the operand number. Using named operands the above example 5801could look like: 5802 5803@smallexample 5804asm ("fsinx %[angle],%[output]" 5805 : [output] "=f" (result) 5806 : [angle] "f" (angle)); 5807@end smallexample 5808 5809@noindent 5810Note that the symbolic operand names have no relation whatsoever to 5811other C identifiers. You may use any name you like, even those of 5812existing C symbols, but you must ensure that no two operands within the same 5813assembler construct use the same symbolic name. 5814 5815Output operand expressions must be lvalues; the compiler can check this. 5816The input operands need not be lvalues. The compiler cannot check 5817whether the operands have data types that are reasonable for the 5818instruction being executed. It does not parse the assembler instruction 5819template and does not know what it means or even whether it is valid 5820assembler input. The extended @code{asm} feature is most often used for 5821machine instructions the compiler itself does not know exist. If 5822the output expression cannot be directly addressed (for example, it is a 5823bit-field), your constraint must allow a register. In that case, GCC 5824will use the register as the output of the @code{asm}, and then store 5825that register into the output. 5826 5827The ordinary output operands must be write-only; GCC will assume that 5828the values in these operands before the instruction are dead and need 5829not be generated. Extended asm supports input-output or read-write 5830operands. Use the constraint character @samp{+} to indicate such an 5831operand and list it with the output operands. You should only use 5832read-write operands when the constraints for the operand (or the 5833operand in which only some of the bits are to be changed) allow a 5834register. 5835 5836You may, as an alternative, logically split its function into two 5837separate operands, one input operand and one write-only output 5838operand. The connection between them is expressed by constraints 5839which say they need to be in the same location when the instruction 5840executes. You can use the same C expression for both operands, or 5841different expressions. For example, here we write the (fictitious) 5842@samp{combine} instruction with @code{bar} as its read-only source 5843operand and @code{foo} as its read-write destination: 5844 5845@smallexample 5846asm ("combine %2,%0" : "=r" (foo) : "0" (foo), "g" (bar)); 5847@end smallexample 5848 5849@noindent 5850The constraint @samp{"0"} for operand 1 says that it must occupy the 5851same location as operand 0. A number in constraint is allowed only in 5852an input operand and it must refer to an output operand. 5853 5854Only a number in the constraint can guarantee that one operand will be in 5855the same place as another. The mere fact that @code{foo} is the value 5856of both operands is not enough to guarantee that they will be in the 5857same place in the generated assembler code. The following would not 5858work reliably: 5859 5860@smallexample 5861asm ("combine %2,%0" : "=r" (foo) : "r" (foo), "g" (bar)); 5862@end smallexample 5863 5864Various optimizations or reloading could cause operands 0 and 1 to be in 5865different registers; GCC knows no reason not to do so. For example, the 5866compiler might find a copy of the value of @code{foo} in one register and 5867use it for operand 1, but generate the output operand 0 in a different 5868register (copying it afterward to @code{foo}'s own address). Of course, 5869since the register for operand 1 is not even mentioned in the assembler 5870code, the result will not work, but GCC can't tell that. 5871 5872As of GCC version 3.1, one may write @code{[@var{name}]} instead of 5873the operand number for a matching constraint. For example: 5874 5875@smallexample 5876asm ("cmoveq %1,%2,%[result]" 5877 : [result] "=r"(result) 5878 : "r" (test), "r"(new), "[result]"(old)); 5879@end smallexample 5880 5881Sometimes you need to make an @code{asm} operand be a specific register, 5882but there's no matching constraint letter for that register @emph{by 5883itself}. To force the operand into that register, use a local variable 5884for the operand and specify the register in the variable declaration. 5885@xref{Explicit Reg Vars}. Then for the @code{asm} operand, use any 5886register constraint letter that matches the register: 5887 5888@smallexample 5889register int *p1 asm ("r0") = @dots{}; 5890register int *p2 asm ("r1") = @dots{}; 5891register int *result asm ("r0"); 5892asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2)); 5893@end smallexample 5894 5895@anchor{Example of asm with clobbered asm reg} 5896In the above example, beware that a register that is call-clobbered by 5897the target ABI will be overwritten by any function call in the 5898assignment, including library calls for arithmetic operators. 5899Also a register may be clobbered when generating some operations, 5900like variable shift, memory copy or memory move on x86. 5901Assuming it is a call-clobbered register, this may happen to @code{r0} 5902above by the assignment to @code{p2}. If you have to use such a 5903register, use temporary variables for expressions between the register 5904assignment and use: 5905 5906@smallexample 5907int t1 = @dots{}; 5908register int *p1 asm ("r0") = @dots{}; 5909register int *p2 asm ("r1") = t1; 5910register int *result asm ("r0"); 5911asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2)); 5912@end smallexample 5913 5914Some instructions clobber specific hard registers. To describe this, 5915write a third colon after the input operands, followed by the names of 5916the clobbered hard registers (given as strings). Here is a realistic 5917example for the VAX: 5918 5919@smallexample 5920asm volatile ("movc3 %0,%1,%2" 5921 : /* @r{no outputs} */ 5922 : "g" (from), "g" (to), "g" (count) 5923 : "r0", "r1", "r2", "r3", "r4", "r5"); 5924@end smallexample 5925 5926You may not write a clobber description in a way that overlaps with an 5927input or output operand. For example, you may not have an operand 5928describing a register class with one member if you mention that register 5929in the clobber list. Variables declared to live in specific registers 5930(@pxref{Explicit Reg Vars}), and used as asm input or output operands must 5931have no part mentioned in the clobber description. 5932There is no way for you to specify that an input 5933operand is modified without also specifying it as an output 5934operand. Note that if all the output operands you specify are for this 5935purpose (and hence unused), you will then also need to specify 5936@code{volatile} for the @code{asm} construct, as described below, to 5937prevent GCC from deleting the @code{asm} statement as unused. 5938 5939If you refer to a particular hardware register from the assembler code, 5940you will probably have to list the register after the third colon to 5941tell the compiler the register's value is modified. In some assemblers, 5942the register names begin with @samp{%}; to produce one @samp{%} in the 5943assembler code, you must write @samp{%%} in the input. 5944 5945If your assembler instruction can alter the condition code register, add 5946@samp{cc} to the list of clobbered registers. GCC on some machines 5947represents the condition codes as a specific hardware register; 5948@samp{cc} serves to name this register. On other machines, the 5949condition code is handled differently, and specifying @samp{cc} has no 5950effect. But it is valid no matter what the machine. 5951 5952If your assembler instructions access memory in an unpredictable 5953fashion, add @samp{memory} to the list of clobbered registers. This 5954will cause GCC to not keep memory values cached in registers across the 5955assembler instruction and not optimize stores or loads to that memory. 5956You will also want to add the @code{volatile} keyword if the memory 5957affected is not listed in the inputs or outputs of the @code{asm}, as 5958the @samp{memory} clobber does not count as a side-effect of the 5959@code{asm}. If you know how large the accessed memory is, you can add 5960it as input or output but if this is not known, you should add 5961@samp{memory}. As an example, if you access ten bytes of a string, you 5962can use a memory input like: 5963 5964@smallexample 5965@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}. 5966@end smallexample 5967 5968Note that in the following example the memory input is necessary, 5969otherwise GCC might optimize the store to @code{x} away: 5970@smallexample 5971int foo () 5972@{ 5973 int x = 42; 5974 int *y = &x; 5975 int result; 5976 asm ("magic stuff accessing an 'int' pointed to by '%1'" 5977 "=&d" (r) : "a" (y), "m" (*y)); 5978 return result; 5979@} 5980@end smallexample 5981 5982You can put multiple assembler instructions together in a single 5983@code{asm} template, separated by the characters normally used in assembly 5984code for the system. A combination that works in most places is a newline 5985to break the line, plus a tab character to move to the instruction field 5986(written as @samp{\n\t}). Sometimes semicolons can be used, if the 5987assembler allows semicolons as a line-breaking character. Note that some 5988assembler dialects use semicolons to start a comment. 5989The input operands are guaranteed not to use any of the clobbered 5990registers, and neither will the output operands' addresses, so you can 5991read and write the clobbered registers as many times as you like. Here 5992is an example of multiple instructions in a template; it assumes the 5993subroutine @code{_foo} accepts arguments in registers 9 and 10: 5994 5995@smallexample 5996asm ("movl %0,r9\n\tmovl %1,r10\n\tcall _foo" 5997 : /* no outputs */ 5998 : "g" (from), "g" (to) 5999 : "r9", "r10"); 6000@end smallexample 6001 6002Unless an output operand has the @samp{&} constraint modifier, GCC 6003may allocate it in the same register as an unrelated input operand, on 6004the assumption the inputs are consumed before the outputs are produced. 6005This assumption may be false if the assembler code actually consists of 6006more than one instruction. In such a case, use @samp{&} for each output 6007operand that may not overlap an input. @xref{Modifiers}. 6008 6009If you want to test the condition code produced by an assembler 6010instruction, you must include a branch and a label in the @code{asm} 6011construct, as follows: 6012 6013@smallexample 6014asm ("clr %0\n\tfrob %1\n\tbeq 0f\n\tmov #1,%0\n0:" 6015 : "g" (result) 6016 : "g" (input)); 6017@end smallexample 6018 6019@noindent 6020This assumes your assembler supports local labels, as the GNU assembler 6021and most Unix assemblers do. 6022 6023Speaking of labels, jumps from one @code{asm} to another are not 6024supported. The compiler's optimizers do not know about these jumps, and 6025therefore they cannot take account of them when deciding how to 6026optimize. @xref{Extended asm with goto}. 6027 6028@cindex macros containing @code{asm} 6029Usually the most convenient way to use these @code{asm} instructions is to 6030encapsulate them in macros that look like functions. For example, 6031 6032@smallexample 6033#define sin(x) \ 6034(@{ double __value, __arg = (x); \ 6035 asm ("fsinx %1,%0": "=f" (__value): "f" (__arg)); \ 6036 __value; @}) 6037@end smallexample 6038 6039@noindent 6040Here the variable @code{__arg} is used to make sure that the instruction 6041operates on a proper @code{double} value, and to accept only those 6042arguments @code{x} which can convert automatically to a @code{double}. 6043 6044Another way to make sure the instruction operates on the correct data 6045type is to use a cast in the @code{asm}. This is different from using a 6046variable @code{__arg} in that it converts more different types. For 6047example, if the desired type were @code{int}, casting the argument to 6048@code{int} would accept a pointer with no complaint, while assigning the 6049argument to an @code{int} variable named @code{__arg} would warn about 6050using a pointer unless the caller explicitly casts it. 6051 6052If an @code{asm} has output operands, GCC assumes for optimization 6053purposes the instruction has no side effects except to change the output 6054operands. This does not mean instructions with a side effect cannot be 6055used, but you must be careful, because the compiler may eliminate them 6056if the output operands aren't used, or move them out of loops, or 6057replace two with one if they constitute a common subexpression. Also, 6058if your instruction does have a side effect on a variable that otherwise 6059appears not to change, the old value of the variable may be reused later 6060if it happens to be found in a register. 6061 6062You can prevent an @code{asm} instruction from being deleted 6063by writing the keyword @code{volatile} after 6064the @code{asm}. For example: 6065 6066@smallexample 6067#define get_and_set_priority(new) \ 6068(@{ int __old; \ 6069 asm volatile ("get_and_set_priority %0, %1" \ 6070 : "=g" (__old) : "g" (new)); \ 6071 __old; @}) 6072@end smallexample 6073 6074@noindent 6075The @code{volatile} keyword indicates that the instruction has 6076important side-effects. GCC will not delete a volatile @code{asm} if 6077it is reachable. (The instruction can still be deleted if GCC can 6078prove that control-flow will never reach the location of the 6079instruction.) Note that even a volatile @code{asm} instruction 6080can be moved relative to other code, including across jump 6081instructions. For example, on many targets there is a system 6082register which can be set to control the rounding mode of 6083floating point operations. You might try 6084setting it with a volatile @code{asm}, like this PowerPC example: 6085 6086@smallexample 6087 asm volatile("mtfsf 255,%0" : : "f" (fpenv)); 6088 sum = x + y; 6089@end smallexample 6090 6091@noindent 6092This will not work reliably, as the compiler may move the addition back 6093before the volatile @code{asm}. To make it work you need to add an 6094artificial dependency to the @code{asm} referencing a variable in the code 6095you don't want moved, for example: 6096 6097@smallexample 6098 asm volatile ("mtfsf 255,%1" : "=X"(sum): "f"(fpenv)); 6099 sum = x + y; 6100@end smallexample 6101 6102Similarly, you can't expect a 6103sequence of volatile @code{asm} instructions to remain perfectly 6104consecutive. If you want consecutive output, use a single @code{asm}. 6105Also, GCC will perform some optimizations across a volatile @code{asm} 6106instruction; GCC does not ``forget everything'' when it encounters 6107a volatile @code{asm} instruction the way some other compilers do. 6108 6109An @code{asm} instruction without any output operands will be treated 6110identically to a volatile @code{asm} instruction. 6111 6112It is a natural idea to look for a way to give access to the condition 6113code left by the assembler instruction. However, when we attempted to 6114implement this, we found no way to make it work reliably. The problem 6115is that output operands might need reloading, which would result in 6116additional following ``store'' instructions. On most machines, these 6117instructions would alter the condition code before there was time to 6118test it. This problem doesn't arise for ordinary ``test'' and 6119``compare'' instructions because they don't have any output operands. 6120 6121For reasons similar to those described above, it is not possible to give 6122an assembler instruction access to the condition code left by previous 6123instructions. 6124 6125@anchor{Extended asm with goto} 6126As of GCC version 4.5, @code{asm goto} may be used to have the assembly 6127jump to one or more C labels. In this form, a fifth section after the 6128clobber list contains a list of all C labels to which the assembly may jump. 6129Each label operand is implicitly self-named. The @code{asm} is also assumed 6130to fall through to the next statement. 6131 6132This form of @code{asm} is restricted to not have outputs. This is due 6133to a internal restriction in the compiler that control transfer instructions 6134cannot have outputs. This restriction on @code{asm goto} may be lifted 6135in some future version of the compiler. In the mean time, @code{asm goto} 6136may include a memory clobber, and so leave outputs in memory. 6137 6138@smallexample 6139int frob(int x) 6140@{ 6141 int y; 6142 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5" 6143 : : "r"(x), "r"(&y) : "r5", "memory" : error); 6144 return y; 6145 error: 6146 return -1; 6147@} 6148@end smallexample 6149 6150In this (inefficient) example, the @code{frob} instruction sets the 6151carry bit to indicate an error. The @code{jc} instruction detects 6152this and branches to the @code{error} label. Finally, the output 6153of the @code{frob} instruction (@code{%r5}) is stored into the memory 6154for variable @code{y}, which is later read by the @code{return} statement. 6155 6156@smallexample 6157void doit(void) 6158@{ 6159 int i = 0; 6160 asm goto ("mfsr %%r1, 123; jmp %%r1;" 6161 ".pushsection doit_table;" 6162 ".long %l0, %l1, %l2, %l3;" 6163 ".popsection" 6164 : : : "r1" : label1, label2, label3, label4); 6165 __builtin_unreachable (); 6166 6167 label1: 6168 f1(); 6169 return; 6170 label2: 6171 f2(); 6172 return; 6173 label3: 6174 i = 1; 6175 label4: 6176 f3(i); 6177@} 6178@end smallexample 6179 6180In this (also inefficient) example, the @code{mfsr} instruction reads 6181an address from some out-of-band machine register, and the following 6182@code{jmp} instruction branches to that address. The address read by 6183the @code{mfsr} instruction is assumed to have been previously set via 6184some application-specific mechanism to be one of the four values stored 6185in the @code{doit_table} section. Finally, the @code{asm} is followed 6186by a call to @code{__builtin_unreachable} to indicate that the @code{asm} 6187does not in fact fall through. 6188 6189@smallexample 6190#define TRACE1(NUM) \ 6191 do @{ \ 6192 asm goto ("0: nop;" \ 6193 ".pushsection trace_table;" \ 6194 ".long 0b, %l0;" \ 6195 ".popsection" \ 6196 : : : : trace#NUM); \ 6197 if (0) @{ trace#NUM: trace(); @} \ 6198 @} while (0) 6199#define TRACE TRACE1(__COUNTER__) 6200@end smallexample 6201 6202In this example (which in fact inspired the @code{asm goto} feature) 6203we want on rare occasions to call the @code{trace} function; on other 6204occasions we'd like to keep the overhead to the absolute minimum. 6205The normal code path consists of a single @code{nop} instruction. 6206However, we record the address of this @code{nop} together with the 6207address of a label that calls the @code{trace} function. This allows 6208the @code{nop} instruction to be patched at runtime to be an 6209unconditional branch to the stored label. It is assumed that an 6210optimizing compiler will move the labeled block out of line, to 6211optimize the fall through path from the @code{asm}. 6212 6213If you are writing a header file that should be includable in ISO C 6214programs, write @code{__asm__} instead of @code{asm}. @xref{Alternate 6215Keywords}. 6216 6217@subsection Size of an @code{asm} 6218 6219Some targets require that GCC track the size of each instruction used in 6220order to generate correct code. Because the final length of an 6221@code{asm} is only known by the assembler, GCC must make an estimate as 6222to how big it will be. The estimate is formed by counting the number of 6223statements in the pattern of the @code{asm} and multiplying that by the 6224length of the longest instruction on that processor. Statements in the 6225@code{asm} are identified by newline characters and whatever statement 6226separator characters are supported by the assembler; on most processors 6227this is the `@code{;}' character. 6228 6229Normally, GCC's estimate is perfectly adequate to ensure that correct 6230code is generated, but it is possible to confuse the compiler if you use 6231pseudo instructions or assembler macros that expand into multiple real 6232instructions or if you use assembler directives that expand to more 6233space in the object file than would be needed for a single instruction. 6234If this happens then the assembler will produce a diagnostic saying that 6235a label is unreachable. 6236 6237@subsection i386 floating point asm operands 6238 6239There are several rules on the usage of stack-like regs in 6240asm_operands insns. These rules apply only to the operands that are 6241stack-like regs: 6242 6243@enumerate 6244@item 6245Given a set of input regs that die in an asm_operands, it is 6246necessary to know which are implicitly popped by the asm, and 6247which must be explicitly popped by gcc. 6248 6249An input reg that is implicitly popped by the asm must be 6250explicitly clobbered, unless it is constrained to match an 6251output operand. 6252 6253@item 6254For any input reg that is implicitly popped by an asm, it is 6255necessary to know how to adjust the stack to compensate for the pop. 6256If any non-popped input is closer to the top of the reg-stack than 6257the implicitly popped reg, it would not be possible to know what the 6258stack looked like---it's not clear how the rest of the stack ``slides 6259up''. 6260 6261All implicitly popped input regs must be closer to the top of 6262the reg-stack than any input that is not implicitly popped. 6263 6264It is possible that if an input dies in an insn, reload might 6265use the input reg for an output reload. Consider this example: 6266 6267@smallexample 6268asm ("foo" : "=t" (a) : "f" (b)); 6269@end smallexample 6270 6271This asm says that input B is not popped by the asm, and that 6272the asm pushes a result onto the reg-stack, i.e., the stack is one 6273deeper after the asm than it was before. But, it is possible that 6274reload will think that it can use the same reg for both the input and 6275the output, if input B dies in this insn. 6276 6277If any input operand uses the @code{f} constraint, all output reg 6278constraints must use the @code{&} earlyclobber. 6279 6280The asm above would be written as 6281 6282@smallexample 6283asm ("foo" : "=&t" (a) : "f" (b)); 6284@end smallexample 6285 6286@item 6287Some operands need to be in particular places on the stack. All 6288output operands fall in this category---there is no other way to 6289know which regs the outputs appear in unless the user indicates 6290this in the constraints. 6291 6292Output operands must specifically indicate which reg an output 6293appears in after an asm. @code{=f} is not allowed: the operand 6294constraints must select a class with a single reg. 6295 6296@item 6297Output operands may not be ``inserted'' between existing stack regs. 6298Since no 387 opcode uses a read/write operand, all output operands 6299are dead before the asm_operands, and are pushed by the asm_operands. 6300It makes no sense to push anywhere but the top of the reg-stack. 6301 6302Output operands must start at the top of the reg-stack: output 6303operands may not ``skip'' a reg. 6304 6305@item 6306Some asm statements may need extra stack space for internal 6307calculations. This can be guaranteed by clobbering stack registers 6308unrelated to the inputs and outputs. 6309 6310@end enumerate 6311 6312Here are a couple of reasonable asms to want to write. This asm 6313takes one input, which is internally popped, and produces two outputs. 6314 6315@smallexample 6316asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp)); 6317@end smallexample 6318 6319This asm takes two inputs, which are popped by the @code{fyl2xp1} opcode, 6320and replaces them with one output. The user must code the @code{st(1)} 6321clobber for reg-stack.c to know that @code{fyl2xp1} pops both inputs. 6322 6323@smallexample 6324asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)"); 6325@end smallexample 6326 6327@include md.texi 6328 6329@node Asm Labels 6330@section Controlling Names Used in Assembler Code 6331@cindex assembler names for identifiers 6332@cindex names used in assembler code 6333@cindex identifiers, names in assembler code 6334 6335You can specify the name to be used in the assembler code for a C 6336function or variable by writing the @code{asm} (or @code{__asm__}) 6337keyword after the declarator as follows: 6338 6339@smallexample 6340int foo asm ("myfoo") = 2; 6341@end smallexample 6342 6343@noindent 6344This specifies that the name to be used for the variable @code{foo} in 6345the assembler code should be @samp{myfoo} rather than the usual 6346@samp{_foo}. 6347 6348On systems where an underscore is normally prepended to the name of a C 6349function or variable, this feature allows you to define names for the 6350linker that do not start with an underscore. 6351 6352It does not make sense to use this feature with a non-static local 6353variable since such variables do not have assembler names. If you are 6354trying to put the variable in a particular register, see @ref{Explicit 6355Reg Vars}. GCC presently accepts such code with a warning, but will 6356probably be changed to issue an error, rather than a warning, in the 6357future. 6358 6359You cannot use @code{asm} in this way in a function @emph{definition}; but 6360you can get the same effect by writing a declaration for the function 6361before its definition and putting @code{asm} there, like this: 6362 6363@smallexample 6364extern func () asm ("FUNC"); 6365 6366func (x, y) 6367 int x, y; 6368/* @r{@dots{}} */ 6369@end smallexample 6370 6371It is up to you to make sure that the assembler names you choose do not 6372conflict with any other assembler symbols. Also, you must not use a 6373register name; that would produce completely invalid assembler code. GCC 6374does not as yet have the ability to store static variables in registers. 6375Perhaps that will be added. 6376 6377@node Explicit Reg Vars 6378@section Variables in Specified Registers 6379@cindex explicit register variables 6380@cindex variables in specified registers 6381@cindex specified registers 6382@cindex registers, global allocation 6383 6384GNU C allows you to put a few global variables into specified hardware 6385registers. You can also specify the register in which an ordinary 6386register variable should be allocated. 6387 6388@itemize @bullet 6389@item 6390Global register variables reserve registers throughout the program. 6391This may be useful in programs such as programming language 6392interpreters which have a couple of global variables that are accessed 6393very often. 6394 6395@item 6396Local register variables in specific registers do not reserve the 6397registers, except at the point where they are used as input or output 6398operands in an @code{asm} statement and the @code{asm} statement itself is 6399not deleted. The compiler's data flow analysis is capable of determining 6400where the specified registers contain live values, and where they are 6401available for other uses. Stores into local register variables may be deleted 6402when they appear to be dead according to dataflow analysis. References 6403to local register variables may be deleted or moved or simplified. 6404 6405These local variables are sometimes convenient for use with the extended 6406@code{asm} feature (@pxref{Extended Asm}), if you want to write one 6407output of the assembler instruction directly into a particular register. 6408(This will work provided the register you specify fits the constraints 6409specified for that operand in the @code{asm}.) 6410@end itemize 6411 6412@menu 6413* Global Reg Vars:: 6414* Local Reg Vars:: 6415@end menu 6416 6417@node Global Reg Vars 6418@subsection Defining Global Register Variables 6419@cindex global register variables 6420@cindex registers, global variables in 6421 6422You can define a global register variable in GNU C like this: 6423 6424@smallexample 6425register int *foo asm ("a5"); 6426@end smallexample 6427 6428@noindent 6429Here @code{a5} is the name of the register which should be used. Choose a 6430register which is normally saved and restored by function calls on your 6431machine, so that library routines will not clobber it. 6432 6433Naturally the register name is cpu-dependent, so you would need to 6434conditionalize your program according to cpu type. The register 6435@code{a5} would be a good choice on a 68000 for a variable of pointer 6436type. On machines with register windows, be sure to choose a ``global'' 6437register that is not affected magically by the function call mechanism. 6438 6439In addition, operating systems on one type of cpu may differ in how they 6440name the registers; then you would need additional conditionals. For 6441example, some 68000 operating systems call this register @code{%a5}. 6442 6443Eventually there may be a way of asking the compiler to choose a register 6444automatically, but first we need to figure out how it should choose and 6445how to enable you to guide the choice. No solution is evident. 6446 6447Defining a global register variable in a certain register reserves that 6448register entirely for this use, at least within the current compilation. 6449The register will not be allocated for any other purpose in the functions 6450in the current compilation. The register will not be saved and restored by 6451these functions. Stores into this register are never deleted even if they 6452would appear to be dead, but references may be deleted or moved or 6453simplified. 6454 6455It is not safe to access the global register variables from signal 6456handlers, or from more than one thread of control, because the system 6457library routines may temporarily use the register for other things (unless 6458you recompile them specially for the task at hand). 6459 6460@cindex @code{qsort}, and global register variables 6461It is not safe for one function that uses a global register variable to 6462call another such function @code{foo} by way of a third function 6463@code{lose} that was compiled without knowledge of this variable (i.e.@: in a 6464different source file in which the variable wasn't declared). This is 6465because @code{lose} might save the register and put some other value there. 6466For example, you can't expect a global register variable to be available in 6467the comparison-function that you pass to @code{qsort}, since @code{qsort} 6468might have put something else in that register. (If you are prepared to 6469recompile @code{qsort} with the same global register variable, you can 6470solve this problem.) 6471 6472If you want to recompile @code{qsort} or other source files which do not 6473actually use your global register variable, so that they will not use that 6474register for any other purpose, then it suffices to specify the compiler 6475option @option{-ffixed-@var{reg}}. You need not actually add a global 6476register declaration to their source code. 6477 6478A function which can alter the value of a global register variable cannot 6479safely be called from a function compiled without this variable, because it 6480could clobber the value the caller expects to find there on return. 6481Therefore, the function which is the entry point into the part of the 6482program that uses the global register variable must explicitly save and 6483restore the value which belongs to its caller. 6484 6485@cindex register variable after @code{longjmp} 6486@cindex global register after @code{longjmp} 6487@cindex value after @code{longjmp} 6488@findex longjmp 6489@findex setjmp 6490On most machines, @code{longjmp} will restore to each global register 6491variable the value it had at the time of the @code{setjmp}. On some 6492machines, however, @code{longjmp} will not change the value of global 6493register variables. To be portable, the function that called @code{setjmp} 6494should make other arrangements to save the values of the global register 6495variables, and to restore them in a @code{longjmp}. This way, the same 6496thing will happen regardless of what @code{longjmp} does. 6497 6498All global register variable declarations must precede all function 6499definitions. If such a declaration could appear after function 6500definitions, the declaration would be too late to prevent the register from 6501being used for other purposes in the preceding functions. 6502 6503Global register variables may not have initial values, because an 6504executable file has no means to supply initial contents for a register. 6505 6506On the SPARC, there are reports that g3 @dots{} g7 are suitable 6507registers, but certain library functions, such as @code{getwd}, as well 6508as the subroutines for division and remainder, modify g3 and g4. g1 and 6509g2 are local temporaries. 6510 6511On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7. 6512Of course, it will not do to use more than a few of those. 6513 6514@node Local Reg Vars 6515@subsection Specifying Registers for Local Variables 6516@cindex local variables, specifying registers 6517@cindex specifying registers for local variables 6518@cindex registers for local variables 6519 6520You can define a local register variable with a specified register 6521like this: 6522 6523@smallexample 6524register int *foo asm ("a5"); 6525@end smallexample 6526 6527@noindent 6528Here @code{a5} is the name of the register which should be used. Note 6529that this is the same syntax used for defining global register 6530variables, but for a local variable it would appear within a function. 6531 6532Naturally the register name is cpu-dependent, but this is not a 6533problem, since specific registers are most often useful with explicit 6534assembler instructions (@pxref{Extended Asm}). Both of these things 6535generally require that you conditionalize your program according to 6536cpu type. 6537 6538In addition, operating systems on one type of cpu may differ in how they 6539name the registers; then you would need additional conditionals. For 6540example, some 68000 operating systems call this register @code{%a5}. 6541 6542Defining such a register variable does not reserve the register; it 6543remains available for other uses in places where flow control determines 6544the variable's value is not live. 6545 6546This option does not guarantee that GCC will generate code that has 6547this variable in the register you specify at all times. You may not 6548code an explicit reference to this register in the @emph{assembler 6549instruction template} part of an @code{asm} statement and assume it will 6550always refer to this variable. However, using the variable as an 6551@code{asm} @emph{operand} guarantees that the specified register is used 6552for the operand. 6553 6554Stores into local register variables may be deleted when they appear to be dead 6555according to dataflow analysis. References to local register variables may 6556be deleted or moved or simplified. 6557 6558As for global register variables, it's recommended that you choose a 6559register which is normally saved and restored by function calls on 6560your machine, so that library routines will not clobber it. A common 6561pitfall is to initialize multiple call-clobbered registers with 6562arbitrary expressions, where a function call or library call for an 6563arithmetic operator will overwrite a register value from a previous 6564assignment, for example @code{r0} below: 6565@smallexample 6566register int *p1 asm ("r0") = @dots{}; 6567register int *p2 asm ("r1") = @dots{}; 6568@end smallexample 6569In those cases, a solution is to use a temporary variable for 6570each arbitrary expression. @xref{Example of asm with clobbered asm reg}. 6571 6572@node Alternate Keywords 6573@section Alternate Keywords 6574@cindex alternate keywords 6575@cindex keywords, alternate 6576 6577@option{-ansi} and the various @option{-std} options disable certain 6578keywords. This causes trouble when you want to use GNU C extensions, or 6579a general-purpose header file that should be usable by all programs, 6580including ISO C programs. The keywords @code{asm}, @code{typeof} and 6581@code{inline} are not available in programs compiled with 6582@option{-ansi} or @option{-std} (although @code{inline} can be used in a 6583program compiled with @option{-std=c99} or @option{-std=c11}). The 6584ISO C99 keyword 6585@code{restrict} is only available when @option{-std=gnu99} (which will 6586eventually be the default) or @option{-std=c99} (or the equivalent 6587@option{-std=iso9899:1999}), or an option for a later standard 6588version, is used. 6589 6590The way to solve these problems is to put @samp{__} at the beginning and 6591end of each problematical keyword. For example, use @code{__asm__} 6592instead of @code{asm}, and @code{__inline__} instead of @code{inline}. 6593 6594Other C compilers won't accept these alternative keywords; if you want to 6595compile with another compiler, you can define the alternate keywords as 6596macros to replace them with the customary keywords. It looks like this: 6597 6598@smallexample 6599#ifndef __GNUC__ 6600#define __asm__ asm 6601#endif 6602@end smallexample 6603 6604@findex __extension__ 6605@opindex pedantic 6606@option{-pedantic} and other options cause warnings for many GNU C extensions. 6607You can 6608prevent such warnings within one expression by writing 6609@code{__extension__} before the expression. @code{__extension__} has no 6610effect aside from this. 6611 6612@node Incomplete Enums 6613@section Incomplete @code{enum} Types 6614 6615You can define an @code{enum} tag without specifying its possible values. 6616This results in an incomplete type, much like what you get if you write 6617@code{struct foo} without describing the elements. A later declaration 6618which does specify the possible values completes the type. 6619 6620You can't allocate variables or storage using the type while it is 6621incomplete. However, you can work with pointers to that type. 6622 6623This extension may not be very useful, but it makes the handling of 6624@code{enum} more consistent with the way @code{struct} and @code{union} 6625are handled. 6626 6627This extension is not supported by GNU C++. 6628 6629@node Function Names 6630@section Function Names as Strings 6631@cindex @code{__func__} identifier 6632@cindex @code{__FUNCTION__} identifier 6633@cindex @code{__PRETTY_FUNCTION__} identifier 6634 6635GCC provides three magic variables which hold the name of the current 6636function, as a string. The first of these is @code{__func__}, which 6637is part of the C99 standard: 6638 6639The identifier @code{__func__} is implicitly declared by the translator 6640as if, immediately following the opening brace of each function 6641definition, the declaration 6642 6643@smallexample 6644static const char __func__[] = "function-name"; 6645@end smallexample 6646 6647@noindent 6648appeared, where function-name is the name of the lexically-enclosing 6649function. This name is the unadorned name of the function. 6650 6651@code{__FUNCTION__} is another name for @code{__func__}. Older 6652versions of GCC recognize only this name. However, it is not 6653standardized. For maximum portability, we recommend you use 6654@code{__func__}, but provide a fallback definition with the 6655preprocessor: 6656 6657@smallexample 6658#if __STDC_VERSION__ < 199901L 6659# if __GNUC__ >= 2 6660# define __func__ __FUNCTION__ 6661# else 6662# define __func__ "<unknown>" 6663# endif 6664#endif 6665@end smallexample 6666 6667In C, @code{__PRETTY_FUNCTION__} is yet another name for 6668@code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains 6669the type signature of the function as well as its bare name. For 6670example, this program: 6671 6672@smallexample 6673extern "C" @{ 6674extern int printf (char *, ...); 6675@} 6676 6677class a @{ 6678 public: 6679 void sub (int i) 6680 @{ 6681 printf ("__FUNCTION__ = %s\n", __FUNCTION__); 6682 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__); 6683 @} 6684@}; 6685 6686int 6687main (void) 6688@{ 6689 a ax; 6690 ax.sub (0); 6691 return 0; 6692@} 6693@end smallexample 6694 6695@noindent 6696gives this output: 6697 6698@smallexample 6699__FUNCTION__ = sub 6700__PRETTY_FUNCTION__ = void a::sub(int) 6701@end smallexample 6702 6703These identifiers are not preprocessor macros. In GCC 3.3 and 6704earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__} 6705were treated as string literals; they could be used to initialize 6706@code{char} arrays, and they could be concatenated with other string 6707literals. GCC 3.4 and later treat them as variables, like 6708@code{__func__}. In C++, @code{__FUNCTION__} and 6709@code{__PRETTY_FUNCTION__} have always been variables. 6710 6711@node Return Address 6712@section Getting the Return or Frame Address of a Function 6713 6714These functions may be used to get information about the callers of a 6715function. 6716 6717@deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level}) 6718This function returns the return address of the current function, or of 6719one of its callers. The @var{level} argument is number of frames to 6720scan up the call stack. A value of @code{0} yields the return address 6721of the current function, a value of @code{1} yields the return address 6722of the caller of the current function, and so forth. When inlining 6723the expected behavior is that the function will return the address of 6724the function that will be returned to. To work around this behavior use 6725the @code{noinline} function attribute. 6726 6727The @var{level} argument must be a constant integer. 6728 6729On some machines it may be impossible to determine the return address of 6730any function other than the current one; in such cases, or when the top 6731of the stack has been reached, this function will return @code{0} or a 6732random value. In addition, @code{__builtin_frame_address} may be used 6733to determine if the top of the stack has been reached. 6734 6735Additional post-processing of the returned value may be needed, see 6736@code{__builtin_extract_return_address}. 6737 6738This function should only be used with a nonzero argument for debugging 6739purposes. 6740@end deftypefn 6741 6742@deftypefn {Built-in Function} {void *} __builtin_extract_return_address (void *@var{addr}) 6743The address as returned by @code{__builtin_return_address} may have to be fed 6744through this function to get the actual encoded address. For example, on the 674531-bit S/390 platform the highest bit has to be masked out, or on SPARC 6746platforms an offset has to be added for the true next instruction to be 6747executed. 6748 6749If no fixup is needed, this function simply passes through @var{addr}. 6750@end deftypefn 6751 6752@deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr}) 6753This function does the reverse of @code{__builtin_extract_return_address}. 6754@end deftypefn 6755 6756@deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level}) 6757This function is similar to @code{__builtin_return_address}, but it 6758returns the address of the function frame rather than the return address 6759of the function. Calling @code{__builtin_frame_address} with a value of 6760@code{0} yields the frame address of the current function, a value of 6761@code{1} yields the frame address of the caller of the current function, 6762and so forth. 6763 6764The frame is the area on the stack which holds local variables and saved 6765registers. The frame address is normally the address of the first word 6766pushed on to the stack by the function. However, the exact definition 6767depends upon the processor and the calling convention. If the processor 6768has a dedicated frame pointer register, and the function has a frame, 6769then @code{__builtin_frame_address} will return the value of the frame 6770pointer register. 6771 6772On some machines it may be impossible to determine the frame address of 6773any function other than the current one; in such cases, or when the top 6774of the stack has been reached, this function will return @code{0} if 6775the first frame pointer is properly initialized by the startup code. 6776 6777This function should only be used with a nonzero argument for debugging 6778purposes. 6779@end deftypefn 6780 6781@node Vector Extensions 6782@section Using vector instructions through built-in functions 6783 6784On some targets, the instruction set contains SIMD vector instructions that 6785operate on multiple values contained in one large register at the same time. 6786For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used 6787this way. 6788 6789The first step in using these extensions is to provide the necessary data 6790types. This should be done using an appropriate @code{typedef}: 6791 6792@smallexample 6793typedef int v4si __attribute__ ((vector_size (16))); 6794@end smallexample 6795 6796The @code{int} type specifies the base type, while the attribute specifies 6797the vector size for the variable, measured in bytes. For example, the 6798declaration above causes the compiler to set the mode for the @code{v4si} 6799type to be 16 bytes wide and divided into @code{int} sized units. For 6800a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the 6801corresponding mode of @code{foo} will be @acronym{V4SI}. 6802 6803The @code{vector_size} attribute is only applicable to integral and 6804float scalars, although arrays, pointers, and function return values 6805are allowed in conjunction with this construct. 6806 6807All the basic integer types can be used as base types, both as signed 6808and as unsigned: @code{char}, @code{short}, @code{int}, @code{long}, 6809@code{long long}. In addition, @code{float} and @code{double} can be 6810used to build floating-point vector types. 6811 6812Specifying a combination that is not valid for the current architecture 6813will cause GCC to synthesize the instructions using a narrower mode. 6814For example, if you specify a variable of type @code{V4SI} and your 6815architecture does not allow for this specific SIMD type, GCC will 6816produce code that uses 4 @code{SIs}. 6817 6818The types defined in this manner can be used with a subset of normal C 6819operations. Currently, GCC will allow using the following operators 6820on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@. 6821 6822The operations behave like C++ @code{valarrays}. Addition is defined as 6823the addition of the corresponding elements of the operands. For 6824example, in the code below, each of the 4 elements in @var{a} will be 6825added to the corresponding 4 elements in @var{b} and the resulting 6826vector will be stored in @var{c}. 6827 6828@smallexample 6829typedef int v4si __attribute__ ((vector_size (16))); 6830 6831v4si a, b, c; 6832 6833c = a + b; 6834@end smallexample 6835 6836Subtraction, multiplication, division, and the logical operations 6837operate in a similar manner. Likewise, the result of using the unary 6838minus or complement operators on a vector type is a vector whose 6839elements are the negative or complemented values of the corresponding 6840elements in the operand. 6841 6842In C it is possible to use shifting operators @code{<<}, @code{>>} on 6843integer-type vectors. The operation is defined as following: @code{@{a0, 6844a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1, 6845@dots{}, an >> bn@}}@. Vector operands must have the same number of 6846elements. 6847 6848For the convenience in C it is allowed to use a binary vector operation 6849where one operand is a scalar. In that case the compiler will transform 6850the scalar operand into a vector where each element is the scalar from 6851the operation. The transformation will happen only if the scalar could be 6852safely converted to the vector-element type. 6853Consider the following code. 6854 6855@smallexample 6856typedef int v4si __attribute__ ((vector_size (16))); 6857 6858v4si a, b, c; 6859long l; 6860 6861a = b + 1; /* a = b + @{1,1,1,1@}; */ 6862a = 2 * b; /* a = @{2,2,2,2@} * b; */ 6863 6864a = l + a; /* Error, cannot convert long to int. */ 6865@end smallexample 6866 6867In C vectors can be subscripted as if the vector were an array with 6868the same number of elements and base type. Out of bound accesses 6869invoke undefined behavior at runtime. Warnings for out of bound 6870accesses for vector subscription can be enabled with 6871@option{-Warray-bounds}. 6872 6873In GNU C vector comparison is supported within standard comparison 6874operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be 6875vector expressions of integer-type or real-type. Comparison between 6876integer-type vectors and real-type vectors are not supported. The 6877result of the comparison is a vector of the same width and number of 6878elements as the comparison operands with a signed integral element 6879type. 6880 6881Vectors are compared element-wise producing 0 when comparison is false 6882and -1 (constant of the appropriate type where all bits are set) 6883otherwise. Consider the following example. 6884 6885@smallexample 6886typedef int v4si __attribute__ ((vector_size (16))); 6887 6888v4si a = @{1,2,3,4@}; 6889v4si b = @{3,2,1,4@}; 6890v4si c; 6891 6892c = a > b; /* The result would be @{0, 0,-1, 0@} */ 6893c = a == b; /* The result would be @{0,-1, 0,-1@} */ 6894@end smallexample 6895 6896Vector shuffling is available using functions 6897@code{__builtin_shuffle (vec, mask)} and 6898@code{__builtin_shuffle (vec0, vec1, mask)}. 6899Both functions construct a permutation of elements from one or two 6900vectors and return a vector of the same type as the input vector(s). 6901The @var{mask} is an integral vector with the same width (@var{W}) 6902and element count (@var{N}) as the output vector. 6903 6904The elements of the input vectors are numbered in memory ordering of 6905@var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The 6906elements of @var{mask} are considered modulo @var{N} in the single-operand 6907case and modulo @math{2*@var{N}} in the two-operand case. 6908 6909Consider the following example, 6910 6911@smallexample 6912typedef int v4si __attribute__ ((vector_size (16))); 6913 6914v4si a = @{1,2,3,4@}; 6915v4si b = @{5,6,7,8@}; 6916v4si mask1 = @{0,1,1,3@}; 6917v4si mask2 = @{0,4,2,5@}; 6918v4si res; 6919 6920res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */ 6921res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */ 6922@end smallexample 6923 6924Note that @code{__builtin_shuffle} is intentionally semantically 6925compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions. 6926 6927You can declare variables and use them in function calls and returns, as 6928well as in assignments and some casts. You can specify a vector type as 6929a return type for a function. Vector types can also be used as function 6930arguments. It is possible to cast from one vector type to another, 6931provided they are of the same size (in fact, you can also cast vectors 6932to and from other datatypes of the same size). 6933 6934You cannot operate between vectors of different lengths or different 6935signedness without a cast. 6936 6937@node Offsetof 6938@section Offsetof 6939@findex __builtin_offsetof 6940 6941GCC implements for both C and C++ a syntactic extension to implement 6942the @code{offsetof} macro. 6943 6944@smallexample 6945primary: 6946 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")" 6947 6948offsetof_member_designator: 6949 @code{identifier} 6950 | offsetof_member_designator "." @code{identifier} 6951 | offsetof_member_designator "[" @code{expr} "]" 6952@end smallexample 6953 6954This extension is sufficient such that 6955 6956@smallexample 6957#define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member}) 6958@end smallexample 6959 6960is a suitable definition of the @code{offsetof} macro. In C++, @var{type} 6961may be dependent. In either case, @var{member} may consist of a single 6962identifier, or a sequence of member accesses and array references. 6963 6964@node __sync Builtins 6965@section Legacy __sync built-in functions for atomic memory access 6966 6967The following builtins are intended to be compatible with those described 6968in the @cite{Intel Itanium Processor-specific Application Binary Interface}, 6969section 7.4. As such, they depart from the normal GCC practice of using 6970the ``__builtin_'' prefix, and further that they are overloaded such that 6971they work on multiple types. 6972 6973The definition given in the Intel documentation allows only for the use of 6974the types @code{int}, @code{long}, @code{long long} as well as their unsigned 6975counterparts. GCC will allow any integral scalar or pointer type that is 69761, 2, 4 or 8 bytes in length. 6977 6978Not all operations are supported by all target processors. If a particular 6979operation cannot be implemented on the target processor, a warning will be 6980generated and a call an external function will be generated. The external 6981function will carry the same name as the builtin, with an additional suffix 6982@samp{_@var{n}} where @var{n} is the size of the data type. 6983 6984@c ??? Should we have a mechanism to suppress this warning? This is almost 6985@c useful for implementing the operation under the control of an external 6986@c mutex. 6987 6988In most cases, these builtins are considered a @dfn{full barrier}. That is, 6989no memory operand will be moved across the operation, either forward or 6990backward. Further, instructions will be issued as necessary to prevent the 6991processor from speculating loads across the operation and from queuing stores 6992after the operation. 6993 6994All of the routines are described in the Intel documentation to take 6995``an optional list of variables protected by the memory barrier''. It's 6996not clear what is meant by that; it could mean that @emph{only} the 6997following variables are protected, or it could mean that these variables 6998should in addition be protected. At present GCC ignores this list and 6999protects all variables which are globally accessible. If in the future 7000we make some use of this list, an empty list will continue to mean all 7001globally accessible variables. 7002 7003@table @code 7004@item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...) 7005@itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...) 7006@itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...) 7007@itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...) 7008@itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...) 7009@itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...) 7010@findex __sync_fetch_and_add 7011@findex __sync_fetch_and_sub 7012@findex __sync_fetch_and_or 7013@findex __sync_fetch_and_and 7014@findex __sync_fetch_and_xor 7015@findex __sync_fetch_and_nand 7016These builtins perform the operation suggested by the name, and 7017returns the value that had previously been in memory. That is, 7018 7019@smallexample 7020@{ tmp = *ptr; *ptr @var{op}= value; return tmp; @} 7021@{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand 7022@end smallexample 7023 7024@emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand} 7025builtin as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}. 7026 7027@item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...) 7028@itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...) 7029@itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...) 7030@itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...) 7031@itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...) 7032@itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...) 7033@findex __sync_add_and_fetch 7034@findex __sync_sub_and_fetch 7035@findex __sync_or_and_fetch 7036@findex __sync_and_and_fetch 7037@findex __sync_xor_and_fetch 7038@findex __sync_nand_and_fetch 7039These builtins perform the operation suggested by the name, and 7040return the new value. That is, 7041 7042@smallexample 7043@{ *ptr @var{op}= value; return *ptr; @} 7044@{ *ptr = ~(*ptr & value); return *ptr; @} // nand 7045@end smallexample 7046 7047@emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch} 7048builtin as @code{*ptr = ~(*ptr & value)} instead of 7049@code{*ptr = ~*ptr & value}. 7050 7051@item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...) 7052@itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...) 7053@findex __sync_bool_compare_and_swap 7054@findex __sync_val_compare_and_swap 7055These builtins perform an atomic compare and swap. That is, if the current 7056value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into 7057@code{*@var{ptr}}. 7058 7059The ``bool'' version returns true if the comparison is successful and 7060@var{newval} was written. The ``val'' version returns the contents 7061of @code{*@var{ptr}} before the operation. 7062 7063@item __sync_synchronize (...) 7064@findex __sync_synchronize 7065This builtin issues a full memory barrier. 7066 7067@item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...) 7068@findex __sync_lock_test_and_set 7069This builtin, as described by Intel, is not a traditional test-and-set 7070operation, but rather an atomic exchange operation. It writes @var{value} 7071into @code{*@var{ptr}}, and returns the previous contents of 7072@code{*@var{ptr}}. 7073 7074Many targets have only minimal support for such locks, and do not support 7075a full exchange operation. In this case, a target may support reduced 7076functionality here by which the @emph{only} valid value to store is the 7077immediate constant 1. The exact value actually stored in @code{*@var{ptr}} 7078is implementation defined. 7079 7080This builtin is not a full barrier, but rather an @dfn{acquire barrier}. 7081This means that references after the builtin cannot move to (or be 7082speculated to) before the builtin, but previous memory stores may not 7083be globally visible yet, and previous memory loads may not yet be 7084satisfied. 7085 7086@item void __sync_lock_release (@var{type} *ptr, ...) 7087@findex __sync_lock_release 7088This builtin releases the lock acquired by @code{__sync_lock_test_and_set}. 7089Normally this means writing the constant 0 to @code{*@var{ptr}}. 7090 7091This builtin is not a full barrier, but rather a @dfn{release barrier}. 7092This means that all previous memory stores are globally visible, and all 7093previous memory loads have been satisfied, but following memory reads 7094are not prevented from being speculated to before the barrier. 7095@end table 7096 7097@node __atomic Builtins 7098@section Built-in functions for memory model aware atomic operations 7099 7100The following built-in functions approximately match the requirements for 7101C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in 7102functions, but all also have a memory model parameter. These are all 7103identified by being prefixed with @samp{__atomic}, and most are overloaded 7104such that they work with multiple types. 7105 7106GCC will allow any integral scalar or pointer type that is 1, 2, 4, or 8 7107bytes in length. 16-byte integral types are also allowed if 7108@samp{__int128} (@pxref{__int128}) is supported by the architecture. 7109 7110Target architectures are encouraged to provide their own patterns for 7111each of these built-in functions. If no target is provided, the original 7112non-memory model set of @samp{__sync} atomic built-in functions will be 7113utilized, along with any required synchronization fences surrounding it in 7114order to achieve the proper behaviour. Execution in this case is subject 7115to the same restrictions as those built-in functions. 7116 7117If there is no pattern or mechanism to provide a lock free instruction 7118sequence, a call is made to an external routine with the same parameters 7119to be resolved at runtime. 7120 7121The four non-arithmetic functions (load, store, exchange, and 7122compare_exchange) all have a generic version as well. This generic 7123version will work on any data type. If the data type size maps to one 7124of the integral sizes which may have lock free support, the generic 7125version will utilize the lock free built-in function. Otherwise an 7126external call is left to be resolved at runtime. This external call will 7127be the same format with the addition of a @samp{size_t} parameter inserted 7128as the first parameter indicating the size of the object being pointed to. 7129All objects must be the same size. 7130 7131There are 6 different memory models which can be specified. These map 7132to the same names in the C++11 standard. Refer there or to the 7133@uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on 7134atomic synchronization} for more detailed definitions. These memory 7135models integrate both barriers to code motion as well as synchronization 7136requirements with other threads. These are listed in approximately 7137ascending order of strength. 7138 7139@table @code 7140@item __ATOMIC_RELAXED 7141No barriers or synchronization. 7142@item __ATOMIC_CONSUME 7143Data dependency only for both barrier and synchronization with another 7144thread. 7145@item __ATOMIC_ACQUIRE 7146Barrier to hoisting of code and synchronizes with release (or stronger) 7147semantic stores from another thread. 7148@item __ATOMIC_RELEASE 7149Barrier to sinking of code and synchronizes with acquire (or stronger) 7150semantic loads from another thread. 7151@item __ATOMIC_ACQ_REL 7152Full barrier in both directions and synchronizes with acquire loads and 7153release stores in another thread. 7154@item __ATOMIC_SEQ_CST 7155Full barrier in both directions and synchronizes with acquire loads and 7156release stores in all threads. 7157@end table 7158 7159When implementing patterns for these built-in functions , the memory model 7160parameter can be ignored as long as the pattern implements the most 7161restrictive @code{__ATOMIC_SEQ_CST} model. Any of the other memory models 7162will execute correctly with this memory model but they may not execute as 7163efficiently as they could with a more appropriate implemention of the 7164relaxed requirements. 7165 7166Note that the C++11 standard allows for the memory model parameter to be 7167determined at runtime rather than at compile time. These built-in 7168functions will map any runtime value to @code{__ATOMIC_SEQ_CST} rather 7169than invoke a runtime library call or inline a switch statement. This is 7170standard compliant, safe, and the simplest approach for now. 7171 7172The memory model parameter is a signed int, but only the lower 8 bits are 7173reserved for the memory model. The remainder of the signed int is reserved 7174for future use and should be 0. Use of the predefined atomic values will 7175ensure proper usage. 7176 7177@deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel) 7178This built-in function implements an atomic load operation. It returns the 7179contents of @code{*@var{ptr}}. 7180 7181The valid memory model variants are 7182@code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE}, 7183and @code{__ATOMIC_CONSUME}. 7184 7185@end deftypefn 7186 7187@deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel) 7188This is the generic version of an atomic load. It will return the 7189contents of @code{*@var{ptr}} in @code{*@var{ret}}. 7190 7191@end deftypefn 7192 7193@deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel) 7194This built-in function implements an atomic store operation. It writes 7195@code{@var{val}} into @code{*@var{ptr}}. 7196 7197The valid memory model variants are 7198@code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}. 7199 7200@end deftypefn 7201 7202@deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel) 7203This is the generic version of an atomic store. It will store the value 7204of @code{*@var{val}} into @code{*@var{ptr}}. 7205 7206@end deftypefn 7207 7208@deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel) 7209This built-in function implements an atomic exchange operation. It writes 7210@var{val} into @code{*@var{ptr}}, and returns the previous contents of 7211@code{*@var{ptr}}. 7212 7213The valid memory model variants are 7214@code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE}, 7215@code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}. 7216 7217@end deftypefn 7218 7219@deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel) 7220This is the generic version of an atomic exchange. It will store the 7221contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value 7222of @code{*@var{ptr}} will be copied into @code{*@var{ret}}. 7223 7224@end deftypefn 7225 7226@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) 7227This built-in function implements an atomic compare and exchange operation. 7228This compares the contents of @code{*@var{ptr}} with the contents of 7229@code{*@var{expected}} and if equal, writes @var{desired} into 7230@code{*@var{ptr}}. If they are not equal, the current contents of 7231@code{*@var{ptr}} is written into @code{*@var{expected}}. @var{weak} is true 7232for weak compare_exchange, and false for the strong variation. Many targets 7233only offer the strong variation and ignore the parameter. When in doubt, use 7234the strong variation. 7235 7236True is returned if @var{desired} is written into 7237@code{*@var{ptr}} and the execution is considered to conform to the 7238memory model specified by @var{success_memmodel}. There are no 7239restrictions on what memory model can be used here. 7240 7241False is returned otherwise, and the execution is considered to conform 7242to @var{failure_memmodel}. This memory model cannot be 7243@code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a 7244stronger model than that specified by @var{success_memmodel}. 7245 7246@end deftypefn 7247 7248@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) 7249This built-in function implements the generic version of 7250@code{__atomic_compare_exchange}. The function is virtually identical to 7251@code{__atomic_compare_exchange_n}, except the desired value is also a 7252pointer. 7253 7254@end deftypefn 7255 7256@deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel) 7257@deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel) 7258@deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel) 7259@deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel) 7260@deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel) 7261@deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel) 7262These built-in functions perform the operation suggested by the name, and 7263return the result of the operation. That is, 7264 7265@smallexample 7266@{ *ptr @var{op}= val; return *ptr; @} 7267@end smallexample 7268 7269All memory models are valid. 7270 7271@end deftypefn 7272 7273@deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel) 7274@deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel) 7275@deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel) 7276@deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel) 7277@deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel) 7278@deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel) 7279These built-in functions perform the operation suggested by the name, and 7280return the value that had previously been in @code{*@var{ptr}}. That is, 7281 7282@smallexample 7283@{ tmp = *ptr; *ptr @var{op}= val; return tmp; @} 7284@end smallexample 7285 7286All memory models are valid. 7287 7288@end deftypefn 7289 7290@deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel) 7291 7292This built-in function performs an atomic test-and-set operation on 7293the byte at @code{*@var{ptr}}. The byte is set to some implementation 7294defined non-zero "set" value and the return value is @code{true} if and only 7295if the previous contents were "set". 7296 7297All memory models are valid. 7298 7299@end deftypefn 7300 7301@deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel) 7302 7303This built-in function performs an atomic clear operation on 7304@code{*@var{ptr}}. After the operation, @code{*@var{ptr}} will contain 0. 7305 7306The valid memory model variants are 7307@code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and 7308@code{__ATOMIC_RELEASE}. 7309 7310@end deftypefn 7311 7312@deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel) 7313 7314This built-in function acts as a synchronization fence between threads 7315based on the specified memory model. 7316 7317All memory orders are valid. 7318 7319@end deftypefn 7320 7321@deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel) 7322 7323This built-in function acts as a synchronization fence between a thread 7324and signal handlers based in the same thread. 7325 7326All memory orders are valid. 7327 7328@end deftypefn 7329 7330@deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr) 7331 7332This built-in function returns true if objects of @var{size} bytes will always 7333generate lock free atomic instructions for the target architecture. 7334@var{size} must resolve to a compile time constant and the result also resolves to compile time constant. 7335 7336@var{ptr} is an optional pointer to the object which may be used to determine 7337alignment. A value of 0 indicates typical alignment should be used. The 7338compiler may also ignore this parameter. 7339 7340@smallexample 7341if (_atomic_always_lock_free (sizeof (long long), 0)) 7342@end smallexample 7343 7344@end deftypefn 7345 7346@deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr) 7347 7348This built-in function returns true if objects of @var{size} bytes will always 7349generate lock free atomic instructions for the target architecture. If 7350it is not known to be lock free a call is made to a runtime routine named 7351@code{__atomic_is_lock_free}. 7352 7353@var{ptr} is an optional pointer to the object which may be used to determine 7354alignment. A value of 0 indicates typical alignment should be used. The 7355compiler may also ignore this parameter. 7356@end deftypefn 7357 7358@node Object Size Checking 7359@section Object Size Checking Builtins 7360@findex __builtin_object_size 7361@findex __builtin___memcpy_chk 7362@findex __builtin___mempcpy_chk 7363@findex __builtin___memmove_chk 7364@findex __builtin___memset_chk 7365@findex __builtin___strcpy_chk 7366@findex __builtin___stpcpy_chk 7367@findex __builtin___strncpy_chk 7368@findex __builtin___strcat_chk 7369@findex __builtin___strncat_chk 7370@findex __builtin___sprintf_chk 7371@findex __builtin___snprintf_chk 7372@findex __builtin___vsprintf_chk 7373@findex __builtin___vsnprintf_chk 7374@findex __builtin___printf_chk 7375@findex __builtin___vprintf_chk 7376@findex __builtin___fprintf_chk 7377@findex __builtin___vfprintf_chk 7378 7379GCC implements a limited buffer overflow protection mechanism 7380that can prevent some buffer overflow attacks. 7381 7382@deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type}) 7383is a built-in construct that returns a constant number of bytes from 7384@var{ptr} to the end of the object @var{ptr} pointer points to 7385(if known at compile time). @code{__builtin_object_size} never evaluates 7386its arguments for side-effects. If there are any side-effects in them, it 7387returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0} 7388for @var{type} 2 or 3. If there are multiple objects @var{ptr} can 7389point to and all of them are known at compile time, the returned number 7390is the maximum of remaining byte counts in those objects if @var{type} & 2 is 73910 and minimum if nonzero. If it is not possible to determine which objects 7392@var{ptr} points to at compile time, @code{__builtin_object_size} should 7393return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0} 7394for @var{type} 2 or 3. 7395 7396@var{type} is an integer constant from 0 to 3. If the least significant 7397bit is clear, objects are whole variables, if it is set, a closest 7398surrounding subobject is considered the object a pointer points to. 7399The second bit determines if maximum or minimum of remaining bytes 7400is computed. 7401 7402@smallexample 7403struct V @{ char buf1[10]; int b; char buf2[10]; @} var; 7404char *p = &var.buf1[1], *q = &var.b; 7405 7406/* Here the object p points to is var. */ 7407assert (__builtin_object_size (p, 0) == sizeof (var) - 1); 7408/* The subobject p points to is var.buf1. */ 7409assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1); 7410/* The object q points to is var. */ 7411assert (__builtin_object_size (q, 0) 7412 == (char *) (&var + 1) - (char *) &var.b); 7413/* The subobject q points to is var.b. */ 7414assert (__builtin_object_size (q, 1) == sizeof (var.b)); 7415@end smallexample 7416@end deftypefn 7417 7418There are built-in functions added for many common string operation 7419functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk} 7420built-in is provided. This built-in has an additional last argument, 7421which is the number of bytes remaining in object the @var{dest} 7422argument points to or @code{(size_t) -1} if the size is not known. 7423 7424The built-in functions are optimized into the normal string functions 7425like @code{memcpy} if the last argument is @code{(size_t) -1} or if 7426it is known at compile time that the destination object will not 7427be overflown. If the compiler can determine at compile time the 7428object will be always overflown, it issues a warning. 7429 7430The intended use can be e.g. 7431 7432@smallexample 7433#undef memcpy 7434#define bos0(dest) __builtin_object_size (dest, 0) 7435#define memcpy(dest, src, n) \ 7436 __builtin___memcpy_chk (dest, src, n, bos0 (dest)) 7437 7438char *volatile p; 7439char buf[10]; 7440/* It is unknown what object p points to, so this is optimized 7441 into plain memcpy - no checking is possible. */ 7442memcpy (p, "abcde", n); 7443/* Destination is known and length too. It is known at compile 7444 time there will be no overflow. */ 7445memcpy (&buf[5], "abcde", 5); 7446/* Destination is known, but the length is not known at compile time. 7447 This will result in __memcpy_chk call that can check for overflow 7448 at runtime. */ 7449memcpy (&buf[5], "abcde", n); 7450/* Destination is known and it is known at compile time there will 7451 be overflow. There will be a warning and __memcpy_chk call that 7452 will abort the program at runtime. */ 7453memcpy (&buf[6], "abcde", 5); 7454@end smallexample 7455 7456Such built-in functions are provided for @code{memcpy}, @code{mempcpy}, 7457@code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy}, 7458@code{strcat} and @code{strncat}. 7459 7460There are also checking built-in functions for formatted output functions. 7461@smallexample 7462int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...); 7463int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os, 7464 const char *fmt, ...); 7465int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt, 7466 va_list ap); 7467int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os, 7468 const char *fmt, va_list ap); 7469@end smallexample 7470 7471The added @var{flag} argument is passed unchanged to @code{__sprintf_chk} 7472etc.@: functions and can contain implementation specific flags on what 7473additional security measures the checking function might take, such as 7474handling @code{%n} differently. 7475 7476The @var{os} argument is the object size @var{s} points to, like in the 7477other built-in functions. There is a small difference in the behavior 7478though, if @var{os} is @code{(size_t) -1}, the built-in functions are 7479optimized into the non-checking functions only if @var{flag} is 0, otherwise 7480the checking function is called with @var{os} argument set to 7481@code{(size_t) -1}. 7482 7483In addition to this, there are checking built-in functions 7484@code{__builtin___printf_chk}, @code{__builtin___vprintf_chk}, 7485@code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}. 7486These have just one additional argument, @var{flag}, right before 7487format string @var{fmt}. If the compiler is able to optimize them to 7488@code{fputc} etc.@: functions, it will, otherwise the checking function 7489should be called and the @var{flag} argument passed to it. 7490 7491@node Other Builtins 7492@section Other built-in functions provided by GCC 7493@cindex built-in functions 7494@findex __builtin_fpclassify 7495@findex __builtin_isfinite 7496@findex __builtin_isnormal 7497@findex __builtin_isgreater 7498@findex __builtin_isgreaterequal 7499@findex __builtin_isinf_sign 7500@findex __builtin_isless 7501@findex __builtin_islessequal 7502@findex __builtin_islessgreater 7503@findex __builtin_isunordered 7504@findex __builtin_powi 7505@findex __builtin_powif 7506@findex __builtin_powil 7507@findex _Exit 7508@findex _exit 7509@findex abort 7510@findex abs 7511@findex acos 7512@findex acosf 7513@findex acosh 7514@findex acoshf 7515@findex acoshl 7516@findex acosl 7517@findex alloca 7518@findex asin 7519@findex asinf 7520@findex asinh 7521@findex asinhf 7522@findex asinhl 7523@findex asinl 7524@findex atan 7525@findex atan2 7526@findex atan2f 7527@findex atan2l 7528@findex atanf 7529@findex atanh 7530@findex atanhf 7531@findex atanhl 7532@findex atanl 7533@findex bcmp 7534@findex bzero 7535@findex cabs 7536@findex cabsf 7537@findex cabsl 7538@findex cacos 7539@findex cacosf 7540@findex cacosh 7541@findex cacoshf 7542@findex cacoshl 7543@findex cacosl 7544@findex calloc 7545@findex carg 7546@findex cargf 7547@findex cargl 7548@findex casin 7549@findex casinf 7550@findex casinh 7551@findex casinhf 7552@findex casinhl 7553@findex casinl 7554@findex catan 7555@findex catanf 7556@findex catanh 7557@findex catanhf 7558@findex catanhl 7559@findex catanl 7560@findex cbrt 7561@findex cbrtf 7562@findex cbrtl 7563@findex ccos 7564@findex ccosf 7565@findex ccosh 7566@findex ccoshf 7567@findex ccoshl 7568@findex ccosl 7569@findex ceil 7570@findex ceilf 7571@findex ceill 7572@findex cexp 7573@findex cexpf 7574@findex cexpl 7575@findex cimag 7576@findex cimagf 7577@findex cimagl 7578@findex clog 7579@findex clogf 7580@findex clogl 7581@findex conj 7582@findex conjf 7583@findex conjl 7584@findex copysign 7585@findex copysignf 7586@findex copysignl 7587@findex cos 7588@findex cosf 7589@findex cosh 7590@findex coshf 7591@findex coshl 7592@findex cosl 7593@findex cpow 7594@findex cpowf 7595@findex cpowl 7596@findex cproj 7597@findex cprojf 7598@findex cprojl 7599@findex creal 7600@findex crealf 7601@findex creall 7602@findex csin 7603@findex csinf 7604@findex csinh 7605@findex csinhf 7606@findex csinhl 7607@findex csinl 7608@findex csqrt 7609@findex csqrtf 7610@findex csqrtl 7611@findex ctan 7612@findex ctanf 7613@findex ctanh 7614@findex ctanhf 7615@findex ctanhl 7616@findex ctanl 7617@findex dcgettext 7618@findex dgettext 7619@findex drem 7620@findex dremf 7621@findex dreml 7622@findex erf 7623@findex erfc 7624@findex erfcf 7625@findex erfcl 7626@findex erff 7627@findex erfl 7628@findex exit 7629@findex exp 7630@findex exp10 7631@findex exp10f 7632@findex exp10l 7633@findex exp2 7634@findex exp2f 7635@findex exp2l 7636@findex expf 7637@findex expl 7638@findex expm1 7639@findex expm1f 7640@findex expm1l 7641@findex fabs 7642@findex fabsf 7643@findex fabsl 7644@findex fdim 7645@findex fdimf 7646@findex fdiml 7647@findex ffs 7648@findex floor 7649@findex floorf 7650@findex floorl 7651@findex fma 7652@findex fmaf 7653@findex fmal 7654@findex fmax 7655@findex fmaxf 7656@findex fmaxl 7657@findex fmin 7658@findex fminf 7659@findex fminl 7660@findex fmod 7661@findex fmodf 7662@findex fmodl 7663@findex fprintf 7664@findex fprintf_unlocked 7665@findex fputs 7666@findex fputs_unlocked 7667@findex frexp 7668@findex frexpf 7669@findex frexpl 7670@findex fscanf 7671@findex gamma 7672@findex gammaf 7673@findex gammal 7674@findex gamma_r 7675@findex gammaf_r 7676@findex gammal_r 7677@findex gettext 7678@findex hypot 7679@findex hypotf 7680@findex hypotl 7681@findex ilogb 7682@findex ilogbf 7683@findex ilogbl 7684@findex imaxabs 7685@findex index 7686@findex isalnum 7687@findex isalpha 7688@findex isascii 7689@findex isblank 7690@findex iscntrl 7691@findex isdigit 7692@findex isgraph 7693@findex islower 7694@findex isprint 7695@findex ispunct 7696@findex isspace 7697@findex isupper 7698@findex iswalnum 7699@findex iswalpha 7700@findex iswblank 7701@findex iswcntrl 7702@findex iswdigit 7703@findex iswgraph 7704@findex iswlower 7705@findex iswprint 7706@findex iswpunct 7707@findex iswspace 7708@findex iswupper 7709@findex iswxdigit 7710@findex isxdigit 7711@findex j0 7712@findex j0f 7713@findex j0l 7714@findex j1 7715@findex j1f 7716@findex j1l 7717@findex jn 7718@findex jnf 7719@findex jnl 7720@findex labs 7721@findex ldexp 7722@findex ldexpf 7723@findex ldexpl 7724@findex lgamma 7725@findex lgammaf 7726@findex lgammal 7727@findex lgamma_r 7728@findex lgammaf_r 7729@findex lgammal_r 7730@findex llabs 7731@findex llrint 7732@findex llrintf 7733@findex llrintl 7734@findex llround 7735@findex llroundf 7736@findex llroundl 7737@findex log 7738@findex log10 7739@findex log10f 7740@findex log10l 7741@findex log1p 7742@findex log1pf 7743@findex log1pl 7744@findex log2 7745@findex log2f 7746@findex log2l 7747@findex logb 7748@findex logbf 7749@findex logbl 7750@findex logf 7751@findex logl 7752@findex lrint 7753@findex lrintf 7754@findex lrintl 7755@findex lround 7756@findex lroundf 7757@findex lroundl 7758@findex malloc 7759@findex memchr 7760@findex memcmp 7761@findex memcpy 7762@findex mempcpy 7763@findex memset 7764@findex modf 7765@findex modff 7766@findex modfl 7767@findex nearbyint 7768@findex nearbyintf 7769@findex nearbyintl 7770@findex nextafter 7771@findex nextafterf 7772@findex nextafterl 7773@findex nexttoward 7774@findex nexttowardf 7775@findex nexttowardl 7776@findex pow 7777@findex pow10 7778@findex pow10f 7779@findex pow10l 7780@findex powf 7781@findex powl 7782@findex printf 7783@findex printf_unlocked 7784@findex putchar 7785@findex puts 7786@findex remainder 7787@findex remainderf 7788@findex remainderl 7789@findex remquo 7790@findex remquof 7791@findex remquol 7792@findex rindex 7793@findex rint 7794@findex rintf 7795@findex rintl 7796@findex round 7797@findex roundf 7798@findex roundl 7799@findex scalb 7800@findex scalbf 7801@findex scalbl 7802@findex scalbln 7803@findex scalblnf 7804@findex scalblnf 7805@findex scalbn 7806@findex scalbnf 7807@findex scanfnl 7808@findex signbit 7809@findex signbitf 7810@findex signbitl 7811@findex signbitd32 7812@findex signbitd64 7813@findex signbitd128 7814@findex significand 7815@findex significandf 7816@findex significandl 7817@findex sin 7818@findex sincos 7819@findex sincosf 7820@findex sincosl 7821@findex sinf 7822@findex sinh 7823@findex sinhf 7824@findex sinhl 7825@findex sinl 7826@findex snprintf 7827@findex sprintf 7828@findex sqrt 7829@findex sqrtf 7830@findex sqrtl 7831@findex sscanf 7832@findex stpcpy 7833@findex stpncpy 7834@findex strcasecmp 7835@findex strcat 7836@findex strchr 7837@findex strcmp 7838@findex strcpy 7839@findex strcspn 7840@findex strdup 7841@findex strfmon 7842@findex strftime 7843@findex strlen 7844@findex strncasecmp 7845@findex strncat 7846@findex strncmp 7847@findex strncpy 7848@findex strndup 7849@findex strpbrk 7850@findex strrchr 7851@findex strspn 7852@findex strstr 7853@findex tan 7854@findex tanf 7855@findex tanh 7856@findex tanhf 7857@findex tanhl 7858@findex tanl 7859@findex tgamma 7860@findex tgammaf 7861@findex tgammal 7862@findex toascii 7863@findex tolower 7864@findex toupper 7865@findex towlower 7866@findex towupper 7867@findex trunc 7868@findex truncf 7869@findex truncl 7870@findex vfprintf 7871@findex vfscanf 7872@findex vprintf 7873@findex vscanf 7874@findex vsnprintf 7875@findex vsprintf 7876@findex vsscanf 7877@findex y0 7878@findex y0f 7879@findex y0l 7880@findex y1 7881@findex y1f 7882@findex y1l 7883@findex yn 7884@findex ynf 7885@findex ynl 7886 7887GCC provides a large number of built-in functions other than the ones 7888mentioned above. Some of these are for internal use in the processing 7889of exceptions or variable-length argument lists and will not be 7890documented here because they may change from time to time; we do not 7891recommend general use of these functions. 7892 7893The remaining functions are provided for optimization purposes. 7894 7895@opindex fno-builtin 7896GCC includes built-in versions of many of the functions in the standard 7897C library. The versions prefixed with @code{__builtin_} will always be 7898treated as having the same meaning as the C library function even if you 7899specify the @option{-fno-builtin} option. (@pxref{C Dialect Options}) 7900Many of these functions are only optimized in certain cases; if they are 7901not optimized in a particular case, a call to the library function will 7902be emitted. 7903 7904@opindex ansi 7905@opindex std 7906Outside strict ISO C mode (@option{-ansi}, @option{-std=c90}, 7907@option{-std=c99} or @option{-std=c11}), the functions 7908@code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero}, 7909@code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml}, 7910@code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll}, 7911@code{ffsl}, @code{ffs}, @code{fprintf_unlocked}, 7912@code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma}, 7913@code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext}, 7914@code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0}, 7915@code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn}, 7916@code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy}, 7917@code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked}, 7918@code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb}, 7919@code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32}, 7920@code{signbitd64}, @code{signbitd128}, @code{significandf}, 7921@code{significandl}, @code{significand}, @code{sincosf}, 7922@code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy}, 7923@code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp}, 7924@code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0}, 7925@code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and 7926@code{yn} 7927may be handled as built-in functions. 7928All these functions have corresponding versions 7929prefixed with @code{__builtin_}, which may be used even in strict C90 7930mode. 7931 7932The ISO C99 functions 7933@code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf}, 7934@code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh}, 7935@code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf}, 7936@code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos}, 7937@code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf}, 7938@code{casinhl}, @code{casinh}, @code{casinl}, @code{casin}, 7939@code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh}, 7940@code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt}, 7941@code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl}, 7942@code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf}, 7943@code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog}, 7944@code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl}, 7945@code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf}, 7946@code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal}, 7947@code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl}, 7948@code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf}, 7949@code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan}, 7950@code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl}, 7951@code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f}, 7952@code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim}, 7953@code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax}, 7954@code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf}, 7955@code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb}, 7956@code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf}, 7957@code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl}, 7958@code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround}, 7959@code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l}, 7960@code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf}, 7961@code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl}, 7962@code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint}, 7963@code{nextafterf}, @code{nextafterl}, @code{nextafter}, 7964@code{nexttowardf}, @code{nexttowardl}, @code{nexttoward}, 7965@code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof}, 7966@code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint}, 7967@code{roundf}, @code{roundl}, @code{round}, @code{scalblnf}, 7968@code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl}, 7969@code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal}, 7970@code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc}, 7971@code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf} 7972are handled as built-in functions 7973except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}). 7974 7975There are also built-in versions of the ISO C99 functions 7976@code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f}, 7977@code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill}, 7978@code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf}, 7979@code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl}, 7980@code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf}, 7981@code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl}, 7982@code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf}, 7983@code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl}, 7984@code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl} 7985that are recognized in any mode since ISO C90 reserves these names for 7986the purpose to which ISO C99 puts them. All these functions have 7987corresponding versions prefixed with @code{__builtin_}. 7988 7989The ISO C94 functions 7990@code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit}, 7991@code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct}, 7992@code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and 7993@code{towupper} 7994are handled as built-in functions 7995except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}). 7996 7997The ISO C90 functions 7998@code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2}, 7999@code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos}, 8000@code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod}, 8001@code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf}, 8002@code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit}, 8003@code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct}, 8004@code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower}, 8005@code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log}, 8006@code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy}, 8007@code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar}, 8008@code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf}, 8009@code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat}, 8010@code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn}, 8011@code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy}, 8012@code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr}, 8013@code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf} 8014are all recognized as built-in functions unless 8015@option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}} 8016is specified for an individual function). All of these functions have 8017corresponding versions prefixed with @code{__builtin_}. 8018 8019GCC provides built-in versions of the ISO C99 floating point comparison 8020macros that avoid raising exceptions for unordered operands. They have 8021the same names as the standard macros ( @code{isgreater}, 8022@code{isgreaterequal}, @code{isless}, @code{islessequal}, 8023@code{islessgreater}, and @code{isunordered}) , with @code{__builtin_} 8024prefixed. We intend for a library implementor to be able to simply 8025@code{#define} each standard macro to its built-in equivalent. 8026In the same fashion, GCC provides @code{fpclassify}, @code{isfinite}, 8027@code{isinf_sign} and @code{isnormal} built-ins used with 8028@code{__builtin_} prefixed. The @code{isinf} and @code{isnan} 8029builtins appear both with and without the @code{__builtin_} prefix. 8030 8031@deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2}) 8032 8033You can use the built-in function @code{__builtin_types_compatible_p} to 8034determine whether two types are the same. 8035 8036This built-in function returns 1 if the unqualified versions of the 8037types @var{type1} and @var{type2} (which are types, not expressions) are 8038compatible, 0 otherwise. The result of this built-in function can be 8039used in integer constant expressions. 8040 8041This built-in function ignores top level qualifiers (e.g., @code{const}, 8042@code{volatile}). For example, @code{int} is equivalent to @code{const 8043int}. 8044 8045The type @code{int[]} and @code{int[5]} are compatible. On the other 8046hand, @code{int} and @code{char *} are not compatible, even if the size 8047of their types, on the particular architecture are the same. Also, the 8048amount of pointer indirection is taken into account when determining 8049similarity. Consequently, @code{short *} is not similar to 8050@code{short **}. Furthermore, two types that are typedefed are 8051considered compatible if their underlying types are compatible. 8052 8053An @code{enum} type is not considered to be compatible with another 8054@code{enum} type even if both are compatible with the same integer 8055type; this is what the C standard specifies. 8056For example, @code{enum @{foo, bar@}} is not similar to 8057@code{enum @{hot, dog@}}. 8058 8059You would typically use this function in code whose execution varies 8060depending on the arguments' types. For example: 8061 8062@smallexample 8063#define foo(x) \ 8064 (@{ \ 8065 typeof (x) tmp = (x); \ 8066 if (__builtin_types_compatible_p (typeof (x), long double)) \ 8067 tmp = foo_long_double (tmp); \ 8068 else if (__builtin_types_compatible_p (typeof (x), double)) \ 8069 tmp = foo_double (tmp); \ 8070 else if (__builtin_types_compatible_p (typeof (x), float)) \ 8071 tmp = foo_float (tmp); \ 8072 else \ 8073 abort (); \ 8074 tmp; \ 8075 @}) 8076@end smallexample 8077 8078@emph{Note:} This construct is only available for C@. 8079 8080@end deftypefn 8081 8082@deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2}) 8083 8084You can use the built-in function @code{__builtin_choose_expr} to 8085evaluate code depending on the value of a constant expression. This 8086built-in function returns @var{exp1} if @var{const_exp}, which is an 8087integer constant expression, is nonzero. Otherwise it returns @var{exp2}. 8088 8089This built-in function is analogous to the @samp{? :} operator in C, 8090except that the expression returned has its type unaltered by promotion 8091rules. Also, the built-in function does not evaluate the expression 8092that was not chosen. For example, if @var{const_exp} evaluates to true, 8093@var{exp2} is not evaluated even if it has side-effects. 8094 8095This built-in function can return an lvalue if the chosen argument is an 8096lvalue. 8097 8098If @var{exp1} is returned, the return type is the same as @var{exp1}'s 8099type. Similarly, if @var{exp2} is returned, its return type is the same 8100as @var{exp2}. 8101 8102Example: 8103 8104@smallexample 8105#define foo(x) \ 8106 __builtin_choose_expr ( \ 8107 __builtin_types_compatible_p (typeof (x), double), \ 8108 foo_double (x), \ 8109 __builtin_choose_expr ( \ 8110 __builtin_types_compatible_p (typeof (x), float), \ 8111 foo_float (x), \ 8112 /* @r{The void expression results in a compile-time error} \ 8113 @r{when assigning the result to something.} */ \ 8114 (void)0)) 8115@end smallexample 8116 8117@emph{Note:} This construct is only available for C@. Furthermore, the 8118unused expression (@var{exp1} or @var{exp2} depending on the value of 8119@var{const_exp}) may still generate syntax errors. This may change in 8120future revisions. 8121 8122@end deftypefn 8123 8124@deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag}) 8125 8126The built-in function @code{__builtin_complex} is provided for use in 8127implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and 8128@code{CMPLXL}. @var{real} and @var{imag} must have the same type, a 8129real binary floating-point type, and the result has the corresponding 8130complex type with real and imaginary parts @var{real} and @var{imag}. 8131Unlike @samp{@var{real} + I * @var{imag}}, this works even when 8132infinities, NaNs and negative zeros are involved. 8133 8134@end deftypefn 8135 8136@deftypefn {Built-in Function} int __builtin_constant_p (@var{exp}) 8137You can use the built-in function @code{__builtin_constant_p} to 8138determine if a value is known to be constant at compile-time and hence 8139that GCC can perform constant-folding on expressions involving that 8140value. The argument of the function is the value to test. The function 8141returns the integer 1 if the argument is known to be a compile-time 8142constant and 0 if it is not known to be a compile-time constant. A 8143return of 0 does not indicate that the value is @emph{not} a constant, 8144but merely that GCC cannot prove it is a constant with the specified 8145value of the @option{-O} option. 8146 8147You would typically use this function in an embedded application where 8148memory was a critical resource. If you have some complex calculation, 8149you may want it to be folded if it involves constants, but need to call 8150a function if it does not. For example: 8151 8152@smallexample 8153#define Scale_Value(X) \ 8154 (__builtin_constant_p (X) \ 8155 ? ((X) * SCALE + OFFSET) : Scale (X)) 8156@end smallexample 8157 8158You may use this built-in function in either a macro or an inline 8159function. However, if you use it in an inlined function and pass an 8160argument of the function as the argument to the built-in, GCC will 8161never return 1 when you call the inline function with a string constant 8162or compound literal (@pxref{Compound Literals}) and will not return 1 8163when you pass a constant numeric value to the inline function unless you 8164specify the @option{-O} option. 8165 8166You may also use @code{__builtin_constant_p} in initializers for static 8167data. For instance, you can write 8168 8169@smallexample 8170static const int table[] = @{ 8171 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1, 8172 /* @r{@dots{}} */ 8173@}; 8174@end smallexample 8175 8176@noindent 8177This is an acceptable initializer even if @var{EXPRESSION} is not a 8178constant expression, including the case where 8179@code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be 8180folded to a constant but @var{EXPRESSION} contains operands that would 8181not otherwise be permitted in a static initializer (for example, 8182@code{0 && foo ()}). GCC must be more conservative about evaluating the 8183built-in in this case, because it has no opportunity to perform 8184optimization. 8185 8186Previous versions of GCC did not accept this built-in in data 8187initializers. The earliest version where it is completely safe is 81883.0.1. 8189@end deftypefn 8190 8191@deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c}) 8192@opindex fprofile-arcs 8193You may use @code{__builtin_expect} to provide the compiler with 8194branch prediction information. In general, you should prefer to 8195use actual profile feedback for this (@option{-fprofile-arcs}), as 8196programmers are notoriously bad at predicting how their programs 8197actually perform. However, there are applications in which this 8198data is hard to collect. 8199 8200The return value is the value of @var{exp}, which should be an integral 8201expression. The semantics of the built-in are that it is expected that 8202@var{exp} == @var{c}. For example: 8203 8204@smallexample 8205if (__builtin_expect (x, 0)) 8206 foo (); 8207@end smallexample 8208 8209@noindent 8210would indicate that we do not expect to call @code{foo}, since 8211we expect @code{x} to be zero. Since you are limited to integral 8212expressions for @var{exp}, you should use constructions such as 8213 8214@smallexample 8215if (__builtin_expect (ptr != NULL, 1)) 8216 foo (*ptr); 8217@end smallexample 8218 8219@noindent 8220when testing pointer or floating-point values. 8221@end deftypefn 8222 8223@deftypefn {Built-in Function} void __builtin_trap (void) 8224This function causes the program to exit abnormally. GCC implements 8225this function by using a target-dependent mechanism (such as 8226intentionally executing an illegal instruction) or by calling 8227@code{abort}. The mechanism used may vary from release to release so 8228you should not rely on any particular implementation. 8229@end deftypefn 8230 8231@deftypefn {Built-in Function} void __builtin_unreachable (void) 8232If control flow reaches the point of the @code{__builtin_unreachable}, 8233the program is undefined. It is useful in situations where the 8234compiler cannot deduce the unreachability of the code. 8235 8236One such case is immediately following an @code{asm} statement that 8237will either never terminate, or one that transfers control elsewhere 8238and never returns. In this example, without the 8239@code{__builtin_unreachable}, GCC would issue a warning that control 8240reaches the end of a non-void function. It would also generate code 8241to return after the @code{asm}. 8242 8243@smallexample 8244int f (int c, int v) 8245@{ 8246 if (c) 8247 @{ 8248 return v; 8249 @} 8250 else 8251 @{ 8252 asm("jmp error_handler"); 8253 __builtin_unreachable (); 8254 @} 8255@} 8256@end smallexample 8257 8258Because the @code{asm} statement unconditionally transfers control out 8259of the function, control will never reach the end of the function 8260body. The @code{__builtin_unreachable} is in fact unreachable and 8261communicates this fact to the compiler. 8262 8263Another use for @code{__builtin_unreachable} is following a call a 8264function that never returns but that is not declared 8265@code{__attribute__((noreturn))}, as in this example: 8266 8267@smallexample 8268void function_that_never_returns (void); 8269 8270int g (int c) 8271@{ 8272 if (c) 8273 @{ 8274 return 1; 8275 @} 8276 else 8277 @{ 8278 function_that_never_returns (); 8279 __builtin_unreachable (); 8280 @} 8281@} 8282@end smallexample 8283 8284@end deftypefn 8285 8286@deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...) 8287This function returns its first argument, and allows the compiler 8288to assume that the returned pointer is at least @var{align} bytes 8289aligned. This built-in can have either two or three arguments, 8290if it has three, the third argument should have integer type, and 8291if it is non-zero means misalignment offset. For example: 8292 8293@smallexample 8294void *x = __builtin_assume_aligned (arg, 16); 8295@end smallexample 8296 8297means that the compiler can assume x, set to arg, is at least 829816 byte aligned, while: 8299 8300@smallexample 8301void *x = __builtin_assume_aligned (arg, 32, 8); 8302@end smallexample 8303 8304means that the compiler can assume for x, set to arg, that 8305(char *) x - 8 is 32 byte aligned. 8306@end deftypefn 8307 8308@deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end}) 8309This function is used to flush the processor's instruction cache for 8310the region of memory between @var{begin} inclusive and @var{end} 8311exclusive. Some targets require that the instruction cache be 8312flushed, after modifying memory containing code, in order to obtain 8313deterministic behavior. 8314 8315If the target does not require instruction cache flushes, 8316@code{__builtin___clear_cache} has no effect. Otherwise either 8317instructions are emitted in-line to clear the instruction cache or a 8318call to the @code{__clear_cache} function in libgcc is made. 8319@end deftypefn 8320 8321@deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...) 8322This function is used to minimize cache-miss latency by moving data into 8323a cache before it is accessed. 8324You can insert calls to @code{__builtin_prefetch} into code for which 8325you know addresses of data in memory that is likely to be accessed soon. 8326If the target supports them, data prefetch instructions will be generated. 8327If the prefetch is done early enough before the access then the data will 8328be in the cache by the time it is accessed. 8329 8330The value of @var{addr} is the address of the memory to prefetch. 8331There are two optional arguments, @var{rw} and @var{locality}. 8332The value of @var{rw} is a compile-time constant one or zero; one 8333means that the prefetch is preparing for a write to the memory address 8334and zero, the default, means that the prefetch is preparing for a read. 8335The value @var{locality} must be a compile-time constant integer between 8336zero and three. A value of zero means that the data has no temporal 8337locality, so it need not be left in the cache after the access. A value 8338of three means that the data has a high degree of temporal locality and 8339should be left in all levels of cache possible. Values of one and two 8340mean, respectively, a low or moderate degree of temporal locality. The 8341default is three. 8342 8343@smallexample 8344for (i = 0; i < n; i++) 8345 @{ 8346 a[i] = a[i] + b[i]; 8347 __builtin_prefetch (&a[i+j], 1, 1); 8348 __builtin_prefetch (&b[i+j], 0, 1); 8349 /* @r{@dots{}} */ 8350 @} 8351@end smallexample 8352 8353Data prefetch does not generate faults if @var{addr} is invalid, but 8354the address expression itself must be valid. For example, a prefetch 8355of @code{p->next} will not fault if @code{p->next} is not a valid 8356address, but evaluation will fault if @code{p} is not a valid address. 8357 8358If the target does not support data prefetch, the address expression 8359is evaluated if it includes side effects but no other code is generated 8360and GCC does not issue a warning. 8361@end deftypefn 8362 8363@deftypefn {Built-in Function} double __builtin_huge_val (void) 8364Returns a positive infinity, if supported by the floating-point format, 8365else @code{DBL_MAX}. This function is suitable for implementing the 8366ISO C macro @code{HUGE_VAL}. 8367@end deftypefn 8368 8369@deftypefn {Built-in Function} float __builtin_huge_valf (void) 8370Similar to @code{__builtin_huge_val}, except the return type is @code{float}. 8371@end deftypefn 8372 8373@deftypefn {Built-in Function} {long double} __builtin_huge_vall (void) 8374Similar to @code{__builtin_huge_val}, except the return 8375type is @code{long double}. 8376@end deftypefn 8377 8378@deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...) 8379This built-in implements the C99 fpclassify functionality. The first 8380five int arguments should be the target library's notion of the 8381possible FP classes and are used for return values. They must be 8382constant values and they must appear in this order: @code{FP_NAN}, 8383@code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and 8384@code{FP_ZERO}. The ellipsis is for exactly one floating point value 8385to classify. GCC treats the last argument as type-generic, which 8386means it does not do default promotion from float to double. 8387@end deftypefn 8388 8389@deftypefn {Built-in Function} double __builtin_inf (void) 8390Similar to @code{__builtin_huge_val}, except a warning is generated 8391if the target floating-point format does not support infinities. 8392@end deftypefn 8393 8394@deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void) 8395Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}. 8396@end deftypefn 8397 8398@deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void) 8399Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}. 8400@end deftypefn 8401 8402@deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void) 8403Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}. 8404@end deftypefn 8405 8406@deftypefn {Built-in Function} float __builtin_inff (void) 8407Similar to @code{__builtin_inf}, except the return type is @code{float}. 8408This function is suitable for implementing the ISO C99 macro @code{INFINITY}. 8409@end deftypefn 8410 8411@deftypefn {Built-in Function} {long double} __builtin_infl (void) 8412Similar to @code{__builtin_inf}, except the return 8413type is @code{long double}. 8414@end deftypefn 8415 8416@deftypefn {Built-in Function} int __builtin_isinf_sign (...) 8417Similar to @code{isinf}, except the return value will be negative for 8418an argument of @code{-Inf}. Note while the parameter list is an 8419ellipsis, this function only accepts exactly one floating point 8420argument. GCC treats this parameter as type-generic, which means it 8421does not do default promotion from float to double. 8422@end deftypefn 8423 8424@deftypefn {Built-in Function} double __builtin_nan (const char *str) 8425This is an implementation of the ISO C99 function @code{nan}. 8426 8427Since ISO C99 defines this function in terms of @code{strtod}, which we 8428do not implement, a description of the parsing is in order. The string 8429is parsed as by @code{strtol}; that is, the base is recognized by 8430leading @samp{0} or @samp{0x} prefixes. The number parsed is placed 8431in the significand such that the least significant bit of the number 8432is at the least significant bit of the significand. The number is 8433truncated to fit the significand field provided. The significand is 8434forced to be a quiet NaN@. 8435 8436This function, if given a string literal all of which would have been 8437consumed by strtol, is evaluated early enough that it is considered a 8438compile-time constant. 8439@end deftypefn 8440 8441@deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str) 8442Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}. 8443@end deftypefn 8444 8445@deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str) 8446Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}. 8447@end deftypefn 8448 8449@deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str) 8450Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}. 8451@end deftypefn 8452 8453@deftypefn {Built-in Function} float __builtin_nanf (const char *str) 8454Similar to @code{__builtin_nan}, except the return type is @code{float}. 8455@end deftypefn 8456 8457@deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str) 8458Similar to @code{__builtin_nan}, except the return type is @code{long double}. 8459@end deftypefn 8460 8461@deftypefn {Built-in Function} double __builtin_nans (const char *str) 8462Similar to @code{__builtin_nan}, except the significand is forced 8463to be a signaling NaN@. The @code{nans} function is proposed by 8464@uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}. 8465@end deftypefn 8466 8467@deftypefn {Built-in Function} float __builtin_nansf (const char *str) 8468Similar to @code{__builtin_nans}, except the return type is @code{float}. 8469@end deftypefn 8470 8471@deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str) 8472Similar to @code{__builtin_nans}, except the return type is @code{long double}. 8473@end deftypefn 8474 8475@deftypefn {Built-in Function} int __builtin_ffs (unsigned int x) 8476Returns one plus the index of the least significant 1-bit of @var{x}, or 8477if @var{x} is zero, returns zero. 8478@end deftypefn 8479 8480@deftypefn {Built-in Function} int __builtin_clz (unsigned int x) 8481Returns the number of leading 0-bits in @var{x}, starting at the most 8482significant bit position. If @var{x} is 0, the result is undefined. 8483@end deftypefn 8484 8485@deftypefn {Built-in Function} int __builtin_ctz (unsigned int x) 8486Returns the number of trailing 0-bits in @var{x}, starting at the least 8487significant bit position. If @var{x} is 0, the result is undefined. 8488@end deftypefn 8489 8490@deftypefn {Built-in Function} int __builtin_clrsb (int x) 8491Returns the number of leading redundant sign bits in @var{x}, i.e. the 8492number of bits following the most significant bit which are identical 8493to it. There are no special cases for 0 or other values. 8494@end deftypefn 8495 8496@deftypefn {Built-in Function} int __builtin_popcount (unsigned int x) 8497Returns the number of 1-bits in @var{x}. 8498@end deftypefn 8499 8500@deftypefn {Built-in Function} int __builtin_parity (unsigned int x) 8501Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x} 8502modulo 2. 8503@end deftypefn 8504 8505@deftypefn {Built-in Function} int __builtin_ffsl (unsigned long) 8506Similar to @code{__builtin_ffs}, except the argument type is 8507@code{unsigned long}. 8508@end deftypefn 8509 8510@deftypefn {Built-in Function} int __builtin_clzl (unsigned long) 8511Similar to @code{__builtin_clz}, except the argument type is 8512@code{unsigned long}. 8513@end deftypefn 8514 8515@deftypefn {Built-in Function} int __builtin_ctzl (unsigned long) 8516Similar to @code{__builtin_ctz}, except the argument type is 8517@code{unsigned long}. 8518@end deftypefn 8519 8520@deftypefn {Built-in Function} int __builtin_clrsbl (long) 8521Similar to @code{__builtin_clrsb}, except the argument type is 8522@code{long}. 8523@end deftypefn 8524 8525@deftypefn {Built-in Function} int __builtin_popcountl (unsigned long) 8526Similar to @code{__builtin_popcount}, except the argument type is 8527@code{unsigned long}. 8528@end deftypefn 8529 8530@deftypefn {Built-in Function} int __builtin_parityl (unsigned long) 8531Similar to @code{__builtin_parity}, except the argument type is 8532@code{unsigned long}. 8533@end deftypefn 8534 8535@deftypefn {Built-in Function} int __builtin_ffsll (unsigned long long) 8536Similar to @code{__builtin_ffs}, except the argument type is 8537@code{unsigned long long}. 8538@end deftypefn 8539 8540@deftypefn {Built-in Function} int __builtin_clzll (unsigned long long) 8541Similar to @code{__builtin_clz}, except the argument type is 8542@code{unsigned long long}. 8543@end deftypefn 8544 8545@deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long) 8546Similar to @code{__builtin_ctz}, except the argument type is 8547@code{unsigned long long}. 8548@end deftypefn 8549 8550@deftypefn {Built-in Function} int __builtin_clrsbll (long long) 8551Similar to @code{__builtin_clrsb}, except the argument type is 8552@code{long long}. 8553@end deftypefn 8554 8555@deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long) 8556Similar to @code{__builtin_popcount}, except the argument type is 8557@code{unsigned long long}. 8558@end deftypefn 8559 8560@deftypefn {Built-in Function} int __builtin_parityll (unsigned long long) 8561Similar to @code{__builtin_parity}, except the argument type is 8562@code{unsigned long long}. 8563@end deftypefn 8564 8565@deftypefn {Built-in Function} double __builtin_powi (double, int) 8566Returns the first argument raised to the power of the second. Unlike the 8567@code{pow} function no guarantees about precision and rounding are made. 8568@end deftypefn 8569 8570@deftypefn {Built-in Function} float __builtin_powif (float, int) 8571Similar to @code{__builtin_powi}, except the argument and return types 8572are @code{float}. 8573@end deftypefn 8574 8575@deftypefn {Built-in Function} {long double} __builtin_powil (long double, int) 8576Similar to @code{__builtin_powi}, except the argument and return types 8577are @code{long double}. 8578@end deftypefn 8579 8580@deftypefn {Built-in Function} int32_t __builtin_bswap32 (int32_t x) 8581Returns @var{x} with the order of the bytes reversed; for example, 8582@code{0xaabbccdd} becomes @code{0xddccbbaa}. Byte here always means 8583exactly 8 bits. 8584@end deftypefn 8585 8586@deftypefn {Built-in Function} int64_t __builtin_bswap64 (int64_t x) 8587Similar to @code{__builtin_bswap32}, except the argument and return types 8588are 64-bit. 8589@end deftypefn 8590 8591@node Target Builtins 8592@section Built-in Functions Specific to Particular Target Machines 8593 8594On some target machines, GCC supports many built-in functions specific 8595to those machines. Generally these generate calls to specific machine 8596instructions, but allow the compiler to schedule those calls. 8597 8598@menu 8599* Alpha Built-in Functions:: 8600* ARM iWMMXt Built-in Functions:: 8601* ARM NEON Intrinsics:: 8602* AVR Built-in Functions:: 8603* Blackfin Built-in Functions:: 8604* FR-V Built-in Functions:: 8605* X86 Built-in Functions:: 8606* MIPS DSP Built-in Functions:: 8607* MIPS Paired-Single Support:: 8608* MIPS Loongson Built-in Functions:: 8609* Other MIPS Built-in Functions:: 8610* picoChip Built-in Functions:: 8611* PowerPC AltiVec/VSX Built-in Functions:: 8612* RX Built-in Functions:: 8613* SPARC VIS Built-in Functions:: 8614* SPU Built-in Functions:: 8615* TI C6X Built-in Functions:: 8616* TILE-Gx Built-in Functions:: 8617* TILEPro Built-in Functions:: 8618@end menu 8619 8620@node Alpha Built-in Functions 8621@subsection Alpha Built-in Functions 8622 8623These built-in functions are available for the Alpha family of 8624processors, depending on the command-line switches used. 8625 8626The following built-in functions are always available. They 8627all generate the machine instruction that is part of the name. 8628 8629@smallexample 8630long __builtin_alpha_implver (void) 8631long __builtin_alpha_rpcc (void) 8632long __builtin_alpha_amask (long) 8633long __builtin_alpha_cmpbge (long, long) 8634long __builtin_alpha_extbl (long, long) 8635long __builtin_alpha_extwl (long, long) 8636long __builtin_alpha_extll (long, long) 8637long __builtin_alpha_extql (long, long) 8638long __builtin_alpha_extwh (long, long) 8639long __builtin_alpha_extlh (long, long) 8640long __builtin_alpha_extqh (long, long) 8641long __builtin_alpha_insbl (long, long) 8642long __builtin_alpha_inswl (long, long) 8643long __builtin_alpha_insll (long, long) 8644long __builtin_alpha_insql (long, long) 8645long __builtin_alpha_inswh (long, long) 8646long __builtin_alpha_inslh (long, long) 8647long __builtin_alpha_insqh (long, long) 8648long __builtin_alpha_mskbl (long, long) 8649long __builtin_alpha_mskwl (long, long) 8650long __builtin_alpha_mskll (long, long) 8651long __builtin_alpha_mskql (long, long) 8652long __builtin_alpha_mskwh (long, long) 8653long __builtin_alpha_msklh (long, long) 8654long __builtin_alpha_mskqh (long, long) 8655long __builtin_alpha_umulh (long, long) 8656long __builtin_alpha_zap (long, long) 8657long __builtin_alpha_zapnot (long, long) 8658@end smallexample 8659 8660The following built-in functions are always with @option{-mmax} 8661or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or 8662later. They all generate the machine instruction that is part 8663of the name. 8664 8665@smallexample 8666long __builtin_alpha_pklb (long) 8667long __builtin_alpha_pkwb (long) 8668long __builtin_alpha_unpkbl (long) 8669long __builtin_alpha_unpkbw (long) 8670long __builtin_alpha_minub8 (long, long) 8671long __builtin_alpha_minsb8 (long, long) 8672long __builtin_alpha_minuw4 (long, long) 8673long __builtin_alpha_minsw4 (long, long) 8674long __builtin_alpha_maxub8 (long, long) 8675long __builtin_alpha_maxsb8 (long, long) 8676long __builtin_alpha_maxuw4 (long, long) 8677long __builtin_alpha_maxsw4 (long, long) 8678long __builtin_alpha_perr (long, long) 8679@end smallexample 8680 8681The following built-in functions are always with @option{-mcix} 8682or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or 8683later. They all generate the machine instruction that is part 8684of the name. 8685 8686@smallexample 8687long __builtin_alpha_cttz (long) 8688long __builtin_alpha_ctlz (long) 8689long __builtin_alpha_ctpop (long) 8690@end smallexample 8691 8692The following builtins are available on systems that use the OSF/1 8693PALcode. Normally they invoke the @code{rduniq} and @code{wruniq} 8694PAL calls, but when invoked with @option{-mtls-kernel}, they invoke 8695@code{rdval} and @code{wrval}. 8696 8697@smallexample 8698void *__builtin_thread_pointer (void) 8699void __builtin_set_thread_pointer (void *) 8700@end smallexample 8701 8702@node ARM iWMMXt Built-in Functions 8703@subsection ARM iWMMXt Built-in Functions 8704 8705These built-in functions are available for the ARM family of 8706processors when the @option{-mcpu=iwmmxt} switch is used: 8707 8708@smallexample 8709typedef int v2si __attribute__ ((vector_size (8))); 8710typedef short v4hi __attribute__ ((vector_size (8))); 8711typedef char v8qi __attribute__ ((vector_size (8))); 8712 8713int __builtin_arm_getwcx (int) 8714void __builtin_arm_setwcx (int, int) 8715int __builtin_arm_textrmsb (v8qi, int) 8716int __builtin_arm_textrmsh (v4hi, int) 8717int __builtin_arm_textrmsw (v2si, int) 8718int __builtin_arm_textrmub (v8qi, int) 8719int __builtin_arm_textrmuh (v4hi, int) 8720int __builtin_arm_textrmuw (v2si, int) 8721v8qi __builtin_arm_tinsrb (v8qi, int) 8722v4hi __builtin_arm_tinsrh (v4hi, int) 8723v2si __builtin_arm_tinsrw (v2si, int) 8724long long __builtin_arm_tmia (long long, int, int) 8725long long __builtin_arm_tmiabb (long long, int, int) 8726long long __builtin_arm_tmiabt (long long, int, int) 8727long long __builtin_arm_tmiaph (long long, int, int) 8728long long __builtin_arm_tmiatb (long long, int, int) 8729long long __builtin_arm_tmiatt (long long, int, int) 8730int __builtin_arm_tmovmskb (v8qi) 8731int __builtin_arm_tmovmskh (v4hi) 8732int __builtin_arm_tmovmskw (v2si) 8733long long __builtin_arm_waccb (v8qi) 8734long long __builtin_arm_wacch (v4hi) 8735long long __builtin_arm_waccw (v2si) 8736v8qi __builtin_arm_waddb (v8qi, v8qi) 8737v8qi __builtin_arm_waddbss (v8qi, v8qi) 8738v8qi __builtin_arm_waddbus (v8qi, v8qi) 8739v4hi __builtin_arm_waddh (v4hi, v4hi) 8740v4hi __builtin_arm_waddhss (v4hi, v4hi) 8741v4hi __builtin_arm_waddhus (v4hi, v4hi) 8742v2si __builtin_arm_waddw (v2si, v2si) 8743v2si __builtin_arm_waddwss (v2si, v2si) 8744v2si __builtin_arm_waddwus (v2si, v2si) 8745v8qi __builtin_arm_walign (v8qi, v8qi, int) 8746long long __builtin_arm_wand(long long, long long) 8747long long __builtin_arm_wandn (long long, long long) 8748v8qi __builtin_arm_wavg2b (v8qi, v8qi) 8749v8qi __builtin_arm_wavg2br (v8qi, v8qi) 8750v4hi __builtin_arm_wavg2h (v4hi, v4hi) 8751v4hi __builtin_arm_wavg2hr (v4hi, v4hi) 8752v8qi __builtin_arm_wcmpeqb (v8qi, v8qi) 8753v4hi __builtin_arm_wcmpeqh (v4hi, v4hi) 8754v2si __builtin_arm_wcmpeqw (v2si, v2si) 8755v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi) 8756v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi) 8757v2si __builtin_arm_wcmpgtsw (v2si, v2si) 8758v8qi __builtin_arm_wcmpgtub (v8qi, v8qi) 8759v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi) 8760v2si __builtin_arm_wcmpgtuw (v2si, v2si) 8761long long __builtin_arm_wmacs (long long, v4hi, v4hi) 8762long long __builtin_arm_wmacsz (v4hi, v4hi) 8763long long __builtin_arm_wmacu (long long, v4hi, v4hi) 8764long long __builtin_arm_wmacuz (v4hi, v4hi) 8765v4hi __builtin_arm_wmadds (v4hi, v4hi) 8766v4hi __builtin_arm_wmaddu (v4hi, v4hi) 8767v8qi __builtin_arm_wmaxsb (v8qi, v8qi) 8768v4hi __builtin_arm_wmaxsh (v4hi, v4hi) 8769v2si __builtin_arm_wmaxsw (v2si, v2si) 8770v8qi __builtin_arm_wmaxub (v8qi, v8qi) 8771v4hi __builtin_arm_wmaxuh (v4hi, v4hi) 8772v2si __builtin_arm_wmaxuw (v2si, v2si) 8773v8qi __builtin_arm_wminsb (v8qi, v8qi) 8774v4hi __builtin_arm_wminsh (v4hi, v4hi) 8775v2si __builtin_arm_wminsw (v2si, v2si) 8776v8qi __builtin_arm_wminub (v8qi, v8qi) 8777v4hi __builtin_arm_wminuh (v4hi, v4hi) 8778v2si __builtin_arm_wminuw (v2si, v2si) 8779v4hi __builtin_arm_wmulsm (v4hi, v4hi) 8780v4hi __builtin_arm_wmulul (v4hi, v4hi) 8781v4hi __builtin_arm_wmulum (v4hi, v4hi) 8782long long __builtin_arm_wor (long long, long long) 8783v2si __builtin_arm_wpackdss (long long, long long) 8784v2si __builtin_arm_wpackdus (long long, long long) 8785v8qi __builtin_arm_wpackhss (v4hi, v4hi) 8786v8qi __builtin_arm_wpackhus (v4hi, v4hi) 8787v4hi __builtin_arm_wpackwss (v2si, v2si) 8788v4hi __builtin_arm_wpackwus (v2si, v2si) 8789long long __builtin_arm_wrord (long long, long long) 8790long long __builtin_arm_wrordi (long long, int) 8791v4hi __builtin_arm_wrorh (v4hi, long long) 8792v4hi __builtin_arm_wrorhi (v4hi, int) 8793v2si __builtin_arm_wrorw (v2si, long long) 8794v2si __builtin_arm_wrorwi (v2si, int) 8795v2si __builtin_arm_wsadb (v8qi, v8qi) 8796v2si __builtin_arm_wsadbz (v8qi, v8qi) 8797v2si __builtin_arm_wsadh (v4hi, v4hi) 8798v2si __builtin_arm_wsadhz (v4hi, v4hi) 8799v4hi __builtin_arm_wshufh (v4hi, int) 8800long long __builtin_arm_wslld (long long, long long) 8801long long __builtin_arm_wslldi (long long, int) 8802v4hi __builtin_arm_wsllh (v4hi, long long) 8803v4hi __builtin_arm_wsllhi (v4hi, int) 8804v2si __builtin_arm_wsllw (v2si, long long) 8805v2si __builtin_arm_wsllwi (v2si, int) 8806long long __builtin_arm_wsrad (long long, long long) 8807long long __builtin_arm_wsradi (long long, int) 8808v4hi __builtin_arm_wsrah (v4hi, long long) 8809v4hi __builtin_arm_wsrahi (v4hi, int) 8810v2si __builtin_arm_wsraw (v2si, long long) 8811v2si __builtin_arm_wsrawi (v2si, int) 8812long long __builtin_arm_wsrld (long long, long long) 8813long long __builtin_arm_wsrldi (long long, int) 8814v4hi __builtin_arm_wsrlh (v4hi, long long) 8815v4hi __builtin_arm_wsrlhi (v4hi, int) 8816v2si __builtin_arm_wsrlw (v2si, long long) 8817v2si __builtin_arm_wsrlwi (v2si, int) 8818v8qi __builtin_arm_wsubb (v8qi, v8qi) 8819v8qi __builtin_arm_wsubbss (v8qi, v8qi) 8820v8qi __builtin_arm_wsubbus (v8qi, v8qi) 8821v4hi __builtin_arm_wsubh (v4hi, v4hi) 8822v4hi __builtin_arm_wsubhss (v4hi, v4hi) 8823v4hi __builtin_arm_wsubhus (v4hi, v4hi) 8824v2si __builtin_arm_wsubw (v2si, v2si) 8825v2si __builtin_arm_wsubwss (v2si, v2si) 8826v2si __builtin_arm_wsubwus (v2si, v2si) 8827v4hi __builtin_arm_wunpckehsb (v8qi) 8828v2si __builtin_arm_wunpckehsh (v4hi) 8829long long __builtin_arm_wunpckehsw (v2si) 8830v4hi __builtin_arm_wunpckehub (v8qi) 8831v2si __builtin_arm_wunpckehuh (v4hi) 8832long long __builtin_arm_wunpckehuw (v2si) 8833v4hi __builtin_arm_wunpckelsb (v8qi) 8834v2si __builtin_arm_wunpckelsh (v4hi) 8835long long __builtin_arm_wunpckelsw (v2si) 8836v4hi __builtin_arm_wunpckelub (v8qi) 8837v2si __builtin_arm_wunpckeluh (v4hi) 8838long long __builtin_arm_wunpckeluw (v2si) 8839v8qi __builtin_arm_wunpckihb (v8qi, v8qi) 8840v4hi __builtin_arm_wunpckihh (v4hi, v4hi) 8841v2si __builtin_arm_wunpckihw (v2si, v2si) 8842v8qi __builtin_arm_wunpckilb (v8qi, v8qi) 8843v4hi __builtin_arm_wunpckilh (v4hi, v4hi) 8844v2si __builtin_arm_wunpckilw (v2si, v2si) 8845long long __builtin_arm_wxor (long long, long long) 8846long long __builtin_arm_wzero () 8847@end smallexample 8848 8849@node ARM NEON Intrinsics 8850@subsection ARM NEON Intrinsics 8851 8852These built-in intrinsics for the ARM Advanced SIMD extension are available 8853when the @option{-mfpu=neon} switch is used: 8854 8855@include arm-neon-intrinsics.texi 8856 8857@node AVR Built-in Functions 8858@subsection AVR Built-in Functions 8859 8860For each built-in function for AVR, there is an equally named, 8861uppercase built-in macro defined. That way users can easily query if 8862or if not a specific built-in is implemented or not. For example, if 8863@code{__builtin_avr_nop} is available the macro 8864@code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise. 8865 8866The following built-in functions map to the respective machine 8867instruction, i.e. @code{nop}, @code{sei}, @code{cli}, @code{sleep}, 8868@code{wdr}, @code{swap}, @code{fmul}, @code{fmuls} 8869resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented 8870as library call if no hardware multiplier is available. 8871 8872@smallexample 8873void __builtin_avr_nop (void) 8874void __builtin_avr_sei (void) 8875void __builtin_avr_cli (void) 8876void __builtin_avr_sleep (void) 8877void __builtin_avr_wdr (void) 8878unsigned char __builtin_avr_swap (unsigned char) 8879unsigned int __builtin_avr_fmul (unsigned char, unsigned char) 8880int __builtin_avr_fmuls (char, char) 8881int __builtin_avr_fmulsu (char, unsigned char) 8882@end smallexample 8883 8884In order to delay execution for a specific number of cycles, GCC 8885implements 8886@smallexample 8887void __builtin_avr_delay_cycles (unsigned long ticks) 8888@end smallexample 8889 8890@noindent 8891@code{ticks} is the number of ticks to delay execution. Note that this 8892built-in does not take into account the effect of interrupts which 8893might increase delay time. @code{ticks} must be a compile time 8894integer constant; delays with a variable number of cycles are not supported. 8895 8896@smallexample 8897char __builtin_avr_flash_segment (const __memx void*) 8898@end smallexample 8899 8900@noindent 8901This built-in takes a byte address to the 24-bit 8902@ref{AVR Named Address Spaces,address space} @code{__memx} and returns 8903the number of the flash segment (the 64 KiB chunk) where the address 8904points to. Counting starts at @code{0}. 8905If the address does not point to flash memory, return @code{-1}. 8906 8907@smallexample 8908unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val) 8909@end smallexample 8910 8911@noindent 8912Insert bits from @var{bits} into @var{val} and return the resulting 8913value. The nibbles of @var{map} determine how the insertion is 8914performed: Let @var{X} be the @var{n}-th nibble of @var{map} 8915@enumerate 8916@item If @var{X} is @code{0xf}, 8917then the @var{n}-th bit of @var{val} is returned unaltered. 8918 8919@item If X is in the range 0@dots{}7, 8920then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits} 8921 8922@item If X is in the range 8@dots{}@code{0xe}, 8923then the @var{n}-th result bit is undefined. 8924@end enumerate 8925 8926@noindent 8927One typical use case for this built-in is adjusting input and 8928output values to non-contiguous port layouts. Some examples: 8929 8930@smallexample 8931// same as val, bits is unused 8932__builtin_avr_insert_bits (0xffffffff, bits, val) 8933@end smallexample 8934 8935@smallexample 8936// same as bits, val is unused 8937__builtin_avr_insert_bits (0x76543210, bits, val) 8938@end smallexample 8939 8940@smallexample 8941// same as rotating bits by 4 8942__builtin_avr_insert_bits (0x32107654, bits, 0) 8943@end smallexample 8944 8945@smallexample 8946// high-nibble of result is the high-nibble of val 8947// low-nibble of result is the low-nibble of bits 8948__builtin_avr_insert_bits (0xffff3210, bits, val) 8949@end smallexample 8950 8951@smallexample 8952// reverse the bit order of bits 8953__builtin_avr_insert_bits (0x01234567, bits, 0) 8954@end smallexample 8955 8956@node Blackfin Built-in Functions 8957@subsection Blackfin Built-in Functions 8958 8959Currently, there are two Blackfin-specific built-in functions. These are 8960used for generating @code{CSYNC} and @code{SSYNC} machine insns without 8961using inline assembly; by using these built-in functions the compiler can 8962automatically add workarounds for hardware errata involving these 8963instructions. These functions are named as follows: 8964 8965@smallexample 8966void __builtin_bfin_csync (void) 8967void __builtin_bfin_ssync (void) 8968@end smallexample 8969 8970@node FR-V Built-in Functions 8971@subsection FR-V Built-in Functions 8972 8973GCC provides many FR-V-specific built-in functions. In general, 8974these functions are intended to be compatible with those described 8975by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu 8976Semiconductor}. The two exceptions are @code{__MDUNPACKH} and 8977@code{__MBTOHE}, the gcc forms of which pass 128-bit values by 8978pointer rather than by value. 8979 8980Most of the functions are named after specific FR-V instructions. 8981Such functions are said to be ``directly mapped'' and are summarized 8982here in tabular form. 8983 8984@menu 8985* Argument Types:: 8986* Directly-mapped Integer Functions:: 8987* Directly-mapped Media Functions:: 8988* Raw read/write Functions:: 8989* Other Built-in Functions:: 8990@end menu 8991 8992@node Argument Types 8993@subsubsection Argument Types 8994 8995The arguments to the built-in functions can be divided into three groups: 8996register numbers, compile-time constants and run-time values. In order 8997to make this classification clear at a glance, the arguments and return 8998values are given the following pseudo types: 8999 9000@multitable @columnfractions .20 .30 .15 .35 9001@item Pseudo type @tab Real C type @tab Constant? @tab Description 9002@item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword 9003@item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word 9004@item @code{sw1} @tab @code{int} @tab No @tab a signed word 9005@item @code{uw2} @tab @code{unsigned long long} @tab No 9006@tab an unsigned doubleword 9007@item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword 9008@item @code{const} @tab @code{int} @tab Yes @tab an integer constant 9009@item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number 9010@item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number 9011@end multitable 9012 9013These pseudo types are not defined by GCC, they are simply a notational 9014convenience used in this manual. 9015 9016Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2} 9017and @code{sw2} are evaluated at run time. They correspond to 9018register operands in the underlying FR-V instructions. 9019 9020@code{const} arguments represent immediate operands in the underlying 9021FR-V instructions. They must be compile-time constants. 9022 9023@code{acc} arguments are evaluated at compile time and specify the number 9024of an accumulator register. For example, an @code{acc} argument of 2 9025will select the ACC2 register. 9026 9027@code{iacc} arguments are similar to @code{acc} arguments but specify the 9028number of an IACC register. See @pxref{Other Built-in Functions} 9029for more details. 9030 9031@node Directly-mapped Integer Functions 9032@subsubsection Directly-mapped Integer Functions 9033 9034The functions listed below map directly to FR-V I-type instructions. 9035 9036@multitable @columnfractions .45 .32 .23 9037@item Function prototype @tab Example usage @tab Assembly output 9038@item @code{sw1 __ADDSS (sw1, sw1)} 9039@tab @code{@var{c} = __ADDSS (@var{a}, @var{b})} 9040@tab @code{ADDSS @var{a},@var{b},@var{c}} 9041@item @code{sw1 __SCAN (sw1, sw1)} 9042@tab @code{@var{c} = __SCAN (@var{a}, @var{b})} 9043@tab @code{SCAN @var{a},@var{b},@var{c}} 9044@item @code{sw1 __SCUTSS (sw1)} 9045@tab @code{@var{b} = __SCUTSS (@var{a})} 9046@tab @code{SCUTSS @var{a},@var{b}} 9047@item @code{sw1 __SLASS (sw1, sw1)} 9048@tab @code{@var{c} = __SLASS (@var{a}, @var{b})} 9049@tab @code{SLASS @var{a},@var{b},@var{c}} 9050@item @code{void __SMASS (sw1, sw1)} 9051@tab @code{__SMASS (@var{a}, @var{b})} 9052@tab @code{SMASS @var{a},@var{b}} 9053@item @code{void __SMSSS (sw1, sw1)} 9054@tab @code{__SMSSS (@var{a}, @var{b})} 9055@tab @code{SMSSS @var{a},@var{b}} 9056@item @code{void __SMU (sw1, sw1)} 9057@tab @code{__SMU (@var{a}, @var{b})} 9058@tab @code{SMU @var{a},@var{b}} 9059@item @code{sw2 __SMUL (sw1, sw1)} 9060@tab @code{@var{c} = __SMUL (@var{a}, @var{b})} 9061@tab @code{SMUL @var{a},@var{b},@var{c}} 9062@item @code{sw1 __SUBSS (sw1, sw1)} 9063@tab @code{@var{c} = __SUBSS (@var{a}, @var{b})} 9064@tab @code{SUBSS @var{a},@var{b},@var{c}} 9065@item @code{uw2 __UMUL (uw1, uw1)} 9066@tab @code{@var{c} = __UMUL (@var{a}, @var{b})} 9067@tab @code{UMUL @var{a},@var{b},@var{c}} 9068@end multitable 9069 9070@node Directly-mapped Media Functions 9071@subsubsection Directly-mapped Media Functions 9072 9073The functions listed below map directly to FR-V M-type instructions. 9074 9075@multitable @columnfractions .45 .32 .23 9076@item Function prototype @tab Example usage @tab Assembly output 9077@item @code{uw1 __MABSHS (sw1)} 9078@tab @code{@var{b} = __MABSHS (@var{a})} 9079@tab @code{MABSHS @var{a},@var{b}} 9080@item @code{void __MADDACCS (acc, acc)} 9081@tab @code{__MADDACCS (@var{b}, @var{a})} 9082@tab @code{MADDACCS @var{a},@var{b}} 9083@item @code{sw1 __MADDHSS (sw1, sw1)} 9084@tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})} 9085@tab @code{MADDHSS @var{a},@var{b},@var{c}} 9086@item @code{uw1 __MADDHUS (uw1, uw1)} 9087@tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})} 9088@tab @code{MADDHUS @var{a},@var{b},@var{c}} 9089@item @code{uw1 __MAND (uw1, uw1)} 9090@tab @code{@var{c} = __MAND (@var{a}, @var{b})} 9091@tab @code{MAND @var{a},@var{b},@var{c}} 9092@item @code{void __MASACCS (acc, acc)} 9093@tab @code{__MASACCS (@var{b}, @var{a})} 9094@tab @code{MASACCS @var{a},@var{b}} 9095@item @code{uw1 __MAVEH (uw1, uw1)} 9096@tab @code{@var{c} = __MAVEH (@var{a}, @var{b})} 9097@tab @code{MAVEH @var{a},@var{b},@var{c}} 9098@item @code{uw2 __MBTOH (uw1)} 9099@tab @code{@var{b} = __MBTOH (@var{a})} 9100@tab @code{MBTOH @var{a},@var{b}} 9101@item @code{void __MBTOHE (uw1 *, uw1)} 9102@tab @code{__MBTOHE (&@var{b}, @var{a})} 9103@tab @code{MBTOHE @var{a},@var{b}} 9104@item @code{void __MCLRACC (acc)} 9105@tab @code{__MCLRACC (@var{a})} 9106@tab @code{MCLRACC @var{a}} 9107@item @code{void __MCLRACCA (void)} 9108@tab @code{__MCLRACCA ()} 9109@tab @code{MCLRACCA} 9110@item @code{uw1 __Mcop1 (uw1, uw1)} 9111@tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})} 9112@tab @code{Mcop1 @var{a},@var{b},@var{c}} 9113@item @code{uw1 __Mcop2 (uw1, uw1)} 9114@tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})} 9115@tab @code{Mcop2 @var{a},@var{b},@var{c}} 9116@item @code{uw1 __MCPLHI (uw2, const)} 9117@tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})} 9118@tab @code{MCPLHI @var{a},#@var{b},@var{c}} 9119@item @code{uw1 __MCPLI (uw2, const)} 9120@tab @code{@var{c} = __MCPLI (@var{a}, @var{b})} 9121@tab @code{MCPLI @var{a},#@var{b},@var{c}} 9122@item @code{void __MCPXIS (acc, sw1, sw1)} 9123@tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})} 9124@tab @code{MCPXIS @var{a},@var{b},@var{c}} 9125@item @code{void __MCPXIU (acc, uw1, uw1)} 9126@tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})} 9127@tab @code{MCPXIU @var{a},@var{b},@var{c}} 9128@item @code{void __MCPXRS (acc, sw1, sw1)} 9129@tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})} 9130@tab @code{MCPXRS @var{a},@var{b},@var{c}} 9131@item @code{void __MCPXRU (acc, uw1, uw1)} 9132@tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})} 9133@tab @code{MCPXRU @var{a},@var{b},@var{c}} 9134@item @code{uw1 __MCUT (acc, uw1)} 9135@tab @code{@var{c} = __MCUT (@var{a}, @var{b})} 9136@tab @code{MCUT @var{a},@var{b},@var{c}} 9137@item @code{uw1 __MCUTSS (acc, sw1)} 9138@tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})} 9139@tab @code{MCUTSS @var{a},@var{b},@var{c}} 9140@item @code{void __MDADDACCS (acc, acc)} 9141@tab @code{__MDADDACCS (@var{b}, @var{a})} 9142@tab @code{MDADDACCS @var{a},@var{b}} 9143@item @code{void __MDASACCS (acc, acc)} 9144@tab @code{__MDASACCS (@var{b}, @var{a})} 9145@tab @code{MDASACCS @var{a},@var{b}} 9146@item @code{uw2 __MDCUTSSI (acc, const)} 9147@tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})} 9148@tab @code{MDCUTSSI @var{a},#@var{b},@var{c}} 9149@item @code{uw2 __MDPACKH (uw2, uw2)} 9150@tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})} 9151@tab @code{MDPACKH @var{a},@var{b},@var{c}} 9152@item @code{uw2 __MDROTLI (uw2, const)} 9153@tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})} 9154@tab @code{MDROTLI @var{a},#@var{b},@var{c}} 9155@item @code{void __MDSUBACCS (acc, acc)} 9156@tab @code{__MDSUBACCS (@var{b}, @var{a})} 9157@tab @code{MDSUBACCS @var{a},@var{b}} 9158@item @code{void __MDUNPACKH (uw1 *, uw2)} 9159@tab @code{__MDUNPACKH (&@var{b}, @var{a})} 9160@tab @code{MDUNPACKH @var{a},@var{b}} 9161@item @code{uw2 __MEXPDHD (uw1, const)} 9162@tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})} 9163@tab @code{MEXPDHD @var{a},#@var{b},@var{c}} 9164@item @code{uw1 __MEXPDHW (uw1, const)} 9165@tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})} 9166@tab @code{MEXPDHW @var{a},#@var{b},@var{c}} 9167@item @code{uw1 __MHDSETH (uw1, const)} 9168@tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})} 9169@tab @code{MHDSETH @var{a},#@var{b},@var{c}} 9170@item @code{sw1 __MHDSETS (const)} 9171@tab @code{@var{b} = __MHDSETS (@var{a})} 9172@tab @code{MHDSETS #@var{a},@var{b}} 9173@item @code{uw1 __MHSETHIH (uw1, const)} 9174@tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})} 9175@tab @code{MHSETHIH #@var{a},@var{b}} 9176@item @code{sw1 __MHSETHIS (sw1, const)} 9177@tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})} 9178@tab @code{MHSETHIS #@var{a},@var{b}} 9179@item @code{uw1 __MHSETLOH (uw1, const)} 9180@tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})} 9181@tab @code{MHSETLOH #@var{a},@var{b}} 9182@item @code{sw1 __MHSETLOS (sw1, const)} 9183@tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})} 9184@tab @code{MHSETLOS #@var{a},@var{b}} 9185@item @code{uw1 __MHTOB (uw2)} 9186@tab @code{@var{b} = __MHTOB (@var{a})} 9187@tab @code{MHTOB @var{a},@var{b}} 9188@item @code{void __MMACHS (acc, sw1, sw1)} 9189@tab @code{__MMACHS (@var{c}, @var{a}, @var{b})} 9190@tab @code{MMACHS @var{a},@var{b},@var{c}} 9191@item @code{void __MMACHU (acc, uw1, uw1)} 9192@tab @code{__MMACHU (@var{c}, @var{a}, @var{b})} 9193@tab @code{MMACHU @var{a},@var{b},@var{c}} 9194@item @code{void __MMRDHS (acc, sw1, sw1)} 9195@tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})} 9196@tab @code{MMRDHS @var{a},@var{b},@var{c}} 9197@item @code{void __MMRDHU (acc, uw1, uw1)} 9198@tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})} 9199@tab @code{MMRDHU @var{a},@var{b},@var{c}} 9200@item @code{void __MMULHS (acc, sw1, sw1)} 9201@tab @code{__MMULHS (@var{c}, @var{a}, @var{b})} 9202@tab @code{MMULHS @var{a},@var{b},@var{c}} 9203@item @code{void __MMULHU (acc, uw1, uw1)} 9204@tab @code{__MMULHU (@var{c}, @var{a}, @var{b})} 9205@tab @code{MMULHU @var{a},@var{b},@var{c}} 9206@item @code{void __MMULXHS (acc, sw1, sw1)} 9207@tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})} 9208@tab @code{MMULXHS @var{a},@var{b},@var{c}} 9209@item @code{void __MMULXHU (acc, uw1, uw1)} 9210@tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})} 9211@tab @code{MMULXHU @var{a},@var{b},@var{c}} 9212@item @code{uw1 __MNOT (uw1)} 9213@tab @code{@var{b} = __MNOT (@var{a})} 9214@tab @code{MNOT @var{a},@var{b}} 9215@item @code{uw1 __MOR (uw1, uw1)} 9216@tab @code{@var{c} = __MOR (@var{a}, @var{b})} 9217@tab @code{MOR @var{a},@var{b},@var{c}} 9218@item @code{uw1 __MPACKH (uh, uh)} 9219@tab @code{@var{c} = __MPACKH (@var{a}, @var{b})} 9220@tab @code{MPACKH @var{a},@var{b},@var{c}} 9221@item @code{sw2 __MQADDHSS (sw2, sw2)} 9222@tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})} 9223@tab @code{MQADDHSS @var{a},@var{b},@var{c}} 9224@item @code{uw2 __MQADDHUS (uw2, uw2)} 9225@tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})} 9226@tab @code{MQADDHUS @var{a},@var{b},@var{c}} 9227@item @code{void __MQCPXIS (acc, sw2, sw2)} 9228@tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})} 9229@tab @code{MQCPXIS @var{a},@var{b},@var{c}} 9230@item @code{void __MQCPXIU (acc, uw2, uw2)} 9231@tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})} 9232@tab @code{MQCPXIU @var{a},@var{b},@var{c}} 9233@item @code{void __MQCPXRS (acc, sw2, sw2)} 9234@tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})} 9235@tab @code{MQCPXRS @var{a},@var{b},@var{c}} 9236@item @code{void __MQCPXRU (acc, uw2, uw2)} 9237@tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})} 9238@tab @code{MQCPXRU @var{a},@var{b},@var{c}} 9239@item @code{sw2 __MQLCLRHS (sw2, sw2)} 9240@tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})} 9241@tab @code{MQLCLRHS @var{a},@var{b},@var{c}} 9242@item @code{sw2 __MQLMTHS (sw2, sw2)} 9243@tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})} 9244@tab @code{MQLMTHS @var{a},@var{b},@var{c}} 9245@item @code{void __MQMACHS (acc, sw2, sw2)} 9246@tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})} 9247@tab @code{MQMACHS @var{a},@var{b},@var{c}} 9248@item @code{void __MQMACHU (acc, uw2, uw2)} 9249@tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})} 9250@tab @code{MQMACHU @var{a},@var{b},@var{c}} 9251@item @code{void __MQMACXHS (acc, sw2, sw2)} 9252@tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})} 9253@tab @code{MQMACXHS @var{a},@var{b},@var{c}} 9254@item @code{void __MQMULHS (acc, sw2, sw2)} 9255@tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})} 9256@tab @code{MQMULHS @var{a},@var{b},@var{c}} 9257@item @code{void __MQMULHU (acc, uw2, uw2)} 9258@tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})} 9259@tab @code{MQMULHU @var{a},@var{b},@var{c}} 9260@item @code{void __MQMULXHS (acc, sw2, sw2)} 9261@tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})} 9262@tab @code{MQMULXHS @var{a},@var{b},@var{c}} 9263@item @code{void __MQMULXHU (acc, uw2, uw2)} 9264@tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})} 9265@tab @code{MQMULXHU @var{a},@var{b},@var{c}} 9266@item @code{sw2 __MQSATHS (sw2, sw2)} 9267@tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})} 9268@tab @code{MQSATHS @var{a},@var{b},@var{c}} 9269@item @code{uw2 __MQSLLHI (uw2, int)} 9270@tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})} 9271@tab @code{MQSLLHI @var{a},@var{b},@var{c}} 9272@item @code{sw2 __MQSRAHI (sw2, int)} 9273@tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})} 9274@tab @code{MQSRAHI @var{a},@var{b},@var{c}} 9275@item @code{sw2 __MQSUBHSS (sw2, sw2)} 9276@tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})} 9277@tab @code{MQSUBHSS @var{a},@var{b},@var{c}} 9278@item @code{uw2 __MQSUBHUS (uw2, uw2)} 9279@tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})} 9280@tab @code{MQSUBHUS @var{a},@var{b},@var{c}} 9281@item @code{void __MQXMACHS (acc, sw2, sw2)} 9282@tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})} 9283@tab @code{MQXMACHS @var{a},@var{b},@var{c}} 9284@item @code{void __MQXMACXHS (acc, sw2, sw2)} 9285@tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})} 9286@tab @code{MQXMACXHS @var{a},@var{b},@var{c}} 9287@item @code{uw1 __MRDACC (acc)} 9288@tab @code{@var{b} = __MRDACC (@var{a})} 9289@tab @code{MRDACC @var{a},@var{b}} 9290@item @code{uw1 __MRDACCG (acc)} 9291@tab @code{@var{b} = __MRDACCG (@var{a})} 9292@tab @code{MRDACCG @var{a},@var{b}} 9293@item @code{uw1 __MROTLI (uw1, const)} 9294@tab @code{@var{c} = __MROTLI (@var{a}, @var{b})} 9295@tab @code{MROTLI @var{a},#@var{b},@var{c}} 9296@item @code{uw1 __MROTRI (uw1, const)} 9297@tab @code{@var{c} = __MROTRI (@var{a}, @var{b})} 9298@tab @code{MROTRI @var{a},#@var{b},@var{c}} 9299@item @code{sw1 __MSATHS (sw1, sw1)} 9300@tab @code{@var{c} = __MSATHS (@var{a}, @var{b})} 9301@tab @code{MSATHS @var{a},@var{b},@var{c}} 9302@item @code{uw1 __MSATHU (uw1, uw1)} 9303@tab @code{@var{c} = __MSATHU (@var{a}, @var{b})} 9304@tab @code{MSATHU @var{a},@var{b},@var{c}} 9305@item @code{uw1 __MSLLHI (uw1, const)} 9306@tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})} 9307@tab @code{MSLLHI @var{a},#@var{b},@var{c}} 9308@item @code{sw1 __MSRAHI (sw1, const)} 9309@tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})} 9310@tab @code{MSRAHI @var{a},#@var{b},@var{c}} 9311@item @code{uw1 __MSRLHI (uw1, const)} 9312@tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})} 9313@tab @code{MSRLHI @var{a},#@var{b},@var{c}} 9314@item @code{void __MSUBACCS (acc, acc)} 9315@tab @code{__MSUBACCS (@var{b}, @var{a})} 9316@tab @code{MSUBACCS @var{a},@var{b}} 9317@item @code{sw1 __MSUBHSS (sw1, sw1)} 9318@tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})} 9319@tab @code{MSUBHSS @var{a},@var{b},@var{c}} 9320@item @code{uw1 __MSUBHUS (uw1, uw1)} 9321@tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})} 9322@tab @code{MSUBHUS @var{a},@var{b},@var{c}} 9323@item @code{void __MTRAP (void)} 9324@tab @code{__MTRAP ()} 9325@tab @code{MTRAP} 9326@item @code{uw2 __MUNPACKH (uw1)} 9327@tab @code{@var{b} = __MUNPACKH (@var{a})} 9328@tab @code{MUNPACKH @var{a},@var{b}} 9329@item @code{uw1 __MWCUT (uw2, uw1)} 9330@tab @code{@var{c} = __MWCUT (@var{a}, @var{b})} 9331@tab @code{MWCUT @var{a},@var{b},@var{c}} 9332@item @code{void __MWTACC (acc, uw1)} 9333@tab @code{__MWTACC (@var{b}, @var{a})} 9334@tab @code{MWTACC @var{a},@var{b}} 9335@item @code{void __MWTACCG (acc, uw1)} 9336@tab @code{__MWTACCG (@var{b}, @var{a})} 9337@tab @code{MWTACCG @var{a},@var{b}} 9338@item @code{uw1 __MXOR (uw1, uw1)} 9339@tab @code{@var{c} = __MXOR (@var{a}, @var{b})} 9340@tab @code{MXOR @var{a},@var{b},@var{c}} 9341@end multitable 9342 9343@node Raw read/write Functions 9344@subsubsection Raw read/write Functions 9345 9346This sections describes built-in functions related to read and write 9347instructions to access memory. These functions generate 9348@code{membar} instructions to flush the I/O load and stores where 9349appropriate, as described in Fujitsu's manual described above. 9350 9351@table @code 9352 9353@item unsigned char __builtin_read8 (void *@var{data}) 9354@item unsigned short __builtin_read16 (void *@var{data}) 9355@item unsigned long __builtin_read32 (void *@var{data}) 9356@item unsigned long long __builtin_read64 (void *@var{data}) 9357 9358@item void __builtin_write8 (void *@var{data}, unsigned char @var{datum}) 9359@item void __builtin_write16 (void *@var{data}, unsigned short @var{datum}) 9360@item void __builtin_write32 (void *@var{data}, unsigned long @var{datum}) 9361@item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum}) 9362@end table 9363 9364@node Other Built-in Functions 9365@subsubsection Other Built-in Functions 9366 9367This section describes built-in functions that are not named after 9368a specific FR-V instruction. 9369 9370@table @code 9371@item sw2 __IACCreadll (iacc @var{reg}) 9372Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved 9373for future expansion and must be 0. 9374 9375@item sw1 __IACCreadl (iacc @var{reg}) 9376Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1. 9377Other values of @var{reg} are rejected as invalid. 9378 9379@item void __IACCsetll (iacc @var{reg}, sw2 @var{x}) 9380Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument 9381is reserved for future expansion and must be 0. 9382 9383@item void __IACCsetl (iacc @var{reg}, sw1 @var{x}) 9384Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg} 9385is 1. Other values of @var{reg} are rejected as invalid. 9386 9387@item void __data_prefetch0 (const void *@var{x}) 9388Use the @code{dcpl} instruction to load the contents of address @var{x} 9389into the data cache. 9390 9391@item void __data_prefetch (const void *@var{x}) 9392Use the @code{nldub} instruction to load the contents of address @var{x} 9393into the data cache. The instruction will be issued in slot I1@. 9394@end table 9395 9396@node X86 Built-in Functions 9397@subsection X86 Built-in Functions 9398 9399These built-in functions are available for the i386 and x86-64 family 9400of computers, depending on the command-line switches used. 9401 9402Note that, if you specify command-line switches such as @option{-msse}, 9403the compiler could use the extended instruction sets even if the built-ins 9404are not used explicitly in the program. For this reason, applications 9405which perform runtime CPU detection must compile separate files for each 9406supported architecture, using the appropriate flags. In particular, 9407the file containing the CPU detection code should be compiled without 9408these options. 9409 9410The following machine modes are available for use with MMX built-in functions 9411(@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers, 9412@code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a 9413vector of eight 8-bit integers. Some of the built-in functions operate on 9414MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode. 9415 9416If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector 9417of two 32-bit floating point values. 9418 9419If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit 9420floating point values. Some instructions use a vector of four 32-bit 9421integers, these use @code{V4SI}. Finally, some instructions operate on an 9422entire vector register, interpreting it as a 128-bit integer, these use mode 9423@code{TI}. 9424 9425In 64-bit mode, the x86-64 family of processors uses additional built-in 9426functions for efficient use of @code{TF} (@code{__float128}) 128-bit 9427floating point and @code{TC} 128-bit complex floating point values. 9428 9429The following floating point built-in functions are available in 64-bit 9430mode. All of them implement the function that is part of the name. 9431 9432@smallexample 9433__float128 __builtin_fabsq (__float128) 9434__float128 __builtin_copysignq (__float128, __float128) 9435@end smallexample 9436 9437The following built-in function is always available. 9438 9439@table @code 9440@item void __builtin_ia32_pause (void) 9441Generates the @code{pause} machine instruction with a compiler memory 9442barrier. 9443@end table 9444 9445The following floating point built-in functions are made available in the 944664-bit mode. 9447 9448@table @code 9449@item __float128 __builtin_infq (void) 9450Similar to @code{__builtin_inf}, except the return type is @code{__float128}. 9451@findex __builtin_infq 9452 9453@item __float128 __builtin_huge_valq (void) 9454Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}. 9455@findex __builtin_huge_valq 9456@end table 9457 9458The following built-in functions are made available by @option{-mmmx}. 9459All of them generate the machine instruction that is part of the name. 9460 9461@smallexample 9462v8qi __builtin_ia32_paddb (v8qi, v8qi) 9463v4hi __builtin_ia32_paddw (v4hi, v4hi) 9464v2si __builtin_ia32_paddd (v2si, v2si) 9465v8qi __builtin_ia32_psubb (v8qi, v8qi) 9466v4hi __builtin_ia32_psubw (v4hi, v4hi) 9467v2si __builtin_ia32_psubd (v2si, v2si) 9468v8qi __builtin_ia32_paddsb (v8qi, v8qi) 9469v4hi __builtin_ia32_paddsw (v4hi, v4hi) 9470v8qi __builtin_ia32_psubsb (v8qi, v8qi) 9471v4hi __builtin_ia32_psubsw (v4hi, v4hi) 9472v8qi __builtin_ia32_paddusb (v8qi, v8qi) 9473v4hi __builtin_ia32_paddusw (v4hi, v4hi) 9474v8qi __builtin_ia32_psubusb (v8qi, v8qi) 9475v4hi __builtin_ia32_psubusw (v4hi, v4hi) 9476v4hi __builtin_ia32_pmullw (v4hi, v4hi) 9477v4hi __builtin_ia32_pmulhw (v4hi, v4hi) 9478di __builtin_ia32_pand (di, di) 9479di __builtin_ia32_pandn (di,di) 9480di __builtin_ia32_por (di, di) 9481di __builtin_ia32_pxor (di, di) 9482v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi) 9483v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi) 9484v2si __builtin_ia32_pcmpeqd (v2si, v2si) 9485v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi) 9486v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi) 9487v2si __builtin_ia32_pcmpgtd (v2si, v2si) 9488v8qi __builtin_ia32_punpckhbw (v8qi, v8qi) 9489v4hi __builtin_ia32_punpckhwd (v4hi, v4hi) 9490v2si __builtin_ia32_punpckhdq (v2si, v2si) 9491v8qi __builtin_ia32_punpcklbw (v8qi, v8qi) 9492v4hi __builtin_ia32_punpcklwd (v4hi, v4hi) 9493v2si __builtin_ia32_punpckldq (v2si, v2si) 9494v8qi __builtin_ia32_packsswb (v4hi, v4hi) 9495v4hi __builtin_ia32_packssdw (v2si, v2si) 9496v8qi __builtin_ia32_packuswb (v4hi, v4hi) 9497 9498v4hi __builtin_ia32_psllw (v4hi, v4hi) 9499v2si __builtin_ia32_pslld (v2si, v2si) 9500v1di __builtin_ia32_psllq (v1di, v1di) 9501v4hi __builtin_ia32_psrlw (v4hi, v4hi) 9502v2si __builtin_ia32_psrld (v2si, v2si) 9503v1di __builtin_ia32_psrlq (v1di, v1di) 9504v4hi __builtin_ia32_psraw (v4hi, v4hi) 9505v2si __builtin_ia32_psrad (v2si, v2si) 9506v4hi __builtin_ia32_psllwi (v4hi, int) 9507v2si __builtin_ia32_pslldi (v2si, int) 9508v1di __builtin_ia32_psllqi (v1di, int) 9509v4hi __builtin_ia32_psrlwi (v4hi, int) 9510v2si __builtin_ia32_psrldi (v2si, int) 9511v1di __builtin_ia32_psrlqi (v1di, int) 9512v4hi __builtin_ia32_psrawi (v4hi, int) 9513v2si __builtin_ia32_psradi (v2si, int) 9514 9515@end smallexample 9516 9517The following built-in functions are made available either with 9518@option{-msse}, or with a combination of @option{-m3dnow} and 9519@option{-march=athlon}. All of them generate the machine 9520instruction that is part of the name. 9521 9522@smallexample 9523v4hi __builtin_ia32_pmulhuw (v4hi, v4hi) 9524v8qi __builtin_ia32_pavgb (v8qi, v8qi) 9525v4hi __builtin_ia32_pavgw (v4hi, v4hi) 9526v1di __builtin_ia32_psadbw (v8qi, v8qi) 9527v8qi __builtin_ia32_pmaxub (v8qi, v8qi) 9528v4hi __builtin_ia32_pmaxsw (v4hi, v4hi) 9529v8qi __builtin_ia32_pminub (v8qi, v8qi) 9530v4hi __builtin_ia32_pminsw (v4hi, v4hi) 9531int __builtin_ia32_pextrw (v4hi, int) 9532v4hi __builtin_ia32_pinsrw (v4hi, int, int) 9533int __builtin_ia32_pmovmskb (v8qi) 9534void __builtin_ia32_maskmovq (v8qi, v8qi, char *) 9535void __builtin_ia32_movntq (di *, di) 9536void __builtin_ia32_sfence (void) 9537@end smallexample 9538 9539The following built-in functions are available when @option{-msse} is used. 9540All of them generate the machine instruction that is part of the name. 9541 9542@smallexample 9543int __builtin_ia32_comieq (v4sf, v4sf) 9544int __builtin_ia32_comineq (v4sf, v4sf) 9545int __builtin_ia32_comilt (v4sf, v4sf) 9546int __builtin_ia32_comile (v4sf, v4sf) 9547int __builtin_ia32_comigt (v4sf, v4sf) 9548int __builtin_ia32_comige (v4sf, v4sf) 9549int __builtin_ia32_ucomieq (v4sf, v4sf) 9550int __builtin_ia32_ucomineq (v4sf, v4sf) 9551int __builtin_ia32_ucomilt (v4sf, v4sf) 9552int __builtin_ia32_ucomile (v4sf, v4sf) 9553int __builtin_ia32_ucomigt (v4sf, v4sf) 9554int __builtin_ia32_ucomige (v4sf, v4sf) 9555v4sf __builtin_ia32_addps (v4sf, v4sf) 9556v4sf __builtin_ia32_subps (v4sf, v4sf) 9557v4sf __builtin_ia32_mulps (v4sf, v4sf) 9558v4sf __builtin_ia32_divps (v4sf, v4sf) 9559v4sf __builtin_ia32_addss (v4sf, v4sf) 9560v4sf __builtin_ia32_subss (v4sf, v4sf) 9561v4sf __builtin_ia32_mulss (v4sf, v4sf) 9562v4sf __builtin_ia32_divss (v4sf, v4sf) 9563v4si __builtin_ia32_cmpeqps (v4sf, v4sf) 9564v4si __builtin_ia32_cmpltps (v4sf, v4sf) 9565v4si __builtin_ia32_cmpleps (v4sf, v4sf) 9566v4si __builtin_ia32_cmpgtps (v4sf, v4sf) 9567v4si __builtin_ia32_cmpgeps (v4sf, v4sf) 9568v4si __builtin_ia32_cmpunordps (v4sf, v4sf) 9569v4si __builtin_ia32_cmpneqps (v4sf, v4sf) 9570v4si __builtin_ia32_cmpnltps (v4sf, v4sf) 9571v4si __builtin_ia32_cmpnleps (v4sf, v4sf) 9572v4si __builtin_ia32_cmpngtps (v4sf, v4sf) 9573v4si __builtin_ia32_cmpngeps (v4sf, v4sf) 9574v4si __builtin_ia32_cmpordps (v4sf, v4sf) 9575v4si __builtin_ia32_cmpeqss (v4sf, v4sf) 9576v4si __builtin_ia32_cmpltss (v4sf, v4sf) 9577v4si __builtin_ia32_cmpless (v4sf, v4sf) 9578v4si __builtin_ia32_cmpunordss (v4sf, v4sf) 9579v4si __builtin_ia32_cmpneqss (v4sf, v4sf) 9580v4si __builtin_ia32_cmpnlts (v4sf, v4sf) 9581v4si __builtin_ia32_cmpnless (v4sf, v4sf) 9582v4si __builtin_ia32_cmpordss (v4sf, v4sf) 9583v4sf __builtin_ia32_maxps (v4sf, v4sf) 9584v4sf __builtin_ia32_maxss (v4sf, v4sf) 9585v4sf __builtin_ia32_minps (v4sf, v4sf) 9586v4sf __builtin_ia32_minss (v4sf, v4sf) 9587v4sf __builtin_ia32_andps (v4sf, v4sf) 9588v4sf __builtin_ia32_andnps (v4sf, v4sf) 9589v4sf __builtin_ia32_orps (v4sf, v4sf) 9590v4sf __builtin_ia32_xorps (v4sf, v4sf) 9591v4sf __builtin_ia32_movss (v4sf, v4sf) 9592v4sf __builtin_ia32_movhlps (v4sf, v4sf) 9593v4sf __builtin_ia32_movlhps (v4sf, v4sf) 9594v4sf __builtin_ia32_unpckhps (v4sf, v4sf) 9595v4sf __builtin_ia32_unpcklps (v4sf, v4sf) 9596v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si) 9597v4sf __builtin_ia32_cvtsi2ss (v4sf, int) 9598v2si __builtin_ia32_cvtps2pi (v4sf) 9599int __builtin_ia32_cvtss2si (v4sf) 9600v2si __builtin_ia32_cvttps2pi (v4sf) 9601int __builtin_ia32_cvttss2si (v4sf) 9602v4sf __builtin_ia32_rcpps (v4sf) 9603v4sf __builtin_ia32_rsqrtps (v4sf) 9604v4sf __builtin_ia32_sqrtps (v4sf) 9605v4sf __builtin_ia32_rcpss (v4sf) 9606v4sf __builtin_ia32_rsqrtss (v4sf) 9607v4sf __builtin_ia32_sqrtss (v4sf) 9608v4sf __builtin_ia32_shufps (v4sf, v4sf, int) 9609void __builtin_ia32_movntps (float *, v4sf) 9610int __builtin_ia32_movmskps (v4sf) 9611@end smallexample 9612 9613The following built-in functions are available when @option{-msse} is used. 9614 9615@table @code 9616@item v4sf __builtin_ia32_loadaps (float *) 9617Generates the @code{movaps} machine instruction as a load from memory. 9618@item void __builtin_ia32_storeaps (float *, v4sf) 9619Generates the @code{movaps} machine instruction as a store to memory. 9620@item v4sf __builtin_ia32_loadups (float *) 9621Generates the @code{movups} machine instruction as a load from memory. 9622@item void __builtin_ia32_storeups (float *, v4sf) 9623Generates the @code{movups} machine instruction as a store to memory. 9624@item v4sf __builtin_ia32_loadsss (float *) 9625Generates the @code{movss} machine instruction as a load from memory. 9626@item void __builtin_ia32_storess (float *, v4sf) 9627Generates the @code{movss} machine instruction as a store to memory. 9628@item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *) 9629Generates the @code{movhps} machine instruction as a load from memory. 9630@item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *) 9631Generates the @code{movlps} machine instruction as a load from memory 9632@item void __builtin_ia32_storehps (v2sf *, v4sf) 9633Generates the @code{movhps} machine instruction as a store to memory. 9634@item void __builtin_ia32_storelps (v2sf *, v4sf) 9635Generates the @code{movlps} machine instruction as a store to memory. 9636@end table 9637 9638The following built-in functions are available when @option{-msse2} is used. 9639All of them generate the machine instruction that is part of the name. 9640 9641@smallexample 9642int __builtin_ia32_comisdeq (v2df, v2df) 9643int __builtin_ia32_comisdlt (v2df, v2df) 9644int __builtin_ia32_comisdle (v2df, v2df) 9645int __builtin_ia32_comisdgt (v2df, v2df) 9646int __builtin_ia32_comisdge (v2df, v2df) 9647int __builtin_ia32_comisdneq (v2df, v2df) 9648int __builtin_ia32_ucomisdeq (v2df, v2df) 9649int __builtin_ia32_ucomisdlt (v2df, v2df) 9650int __builtin_ia32_ucomisdle (v2df, v2df) 9651int __builtin_ia32_ucomisdgt (v2df, v2df) 9652int __builtin_ia32_ucomisdge (v2df, v2df) 9653int __builtin_ia32_ucomisdneq (v2df, v2df) 9654v2df __builtin_ia32_cmpeqpd (v2df, v2df) 9655v2df __builtin_ia32_cmpltpd (v2df, v2df) 9656v2df __builtin_ia32_cmplepd (v2df, v2df) 9657v2df __builtin_ia32_cmpgtpd (v2df, v2df) 9658v2df __builtin_ia32_cmpgepd (v2df, v2df) 9659v2df __builtin_ia32_cmpunordpd (v2df, v2df) 9660v2df __builtin_ia32_cmpneqpd (v2df, v2df) 9661v2df __builtin_ia32_cmpnltpd (v2df, v2df) 9662v2df __builtin_ia32_cmpnlepd (v2df, v2df) 9663v2df __builtin_ia32_cmpngtpd (v2df, v2df) 9664v2df __builtin_ia32_cmpngepd (v2df, v2df) 9665v2df __builtin_ia32_cmpordpd (v2df, v2df) 9666v2df __builtin_ia32_cmpeqsd (v2df, v2df) 9667v2df __builtin_ia32_cmpltsd (v2df, v2df) 9668v2df __builtin_ia32_cmplesd (v2df, v2df) 9669v2df __builtin_ia32_cmpunordsd (v2df, v2df) 9670v2df __builtin_ia32_cmpneqsd (v2df, v2df) 9671v2df __builtin_ia32_cmpnltsd (v2df, v2df) 9672v2df __builtin_ia32_cmpnlesd (v2df, v2df) 9673v2df __builtin_ia32_cmpordsd (v2df, v2df) 9674v2di __builtin_ia32_paddq (v2di, v2di) 9675v2di __builtin_ia32_psubq (v2di, v2di) 9676v2df __builtin_ia32_addpd (v2df, v2df) 9677v2df __builtin_ia32_subpd (v2df, v2df) 9678v2df __builtin_ia32_mulpd (v2df, v2df) 9679v2df __builtin_ia32_divpd (v2df, v2df) 9680v2df __builtin_ia32_addsd (v2df, v2df) 9681v2df __builtin_ia32_subsd (v2df, v2df) 9682v2df __builtin_ia32_mulsd (v2df, v2df) 9683v2df __builtin_ia32_divsd (v2df, v2df) 9684v2df __builtin_ia32_minpd (v2df, v2df) 9685v2df __builtin_ia32_maxpd (v2df, v2df) 9686v2df __builtin_ia32_minsd (v2df, v2df) 9687v2df __builtin_ia32_maxsd (v2df, v2df) 9688v2df __builtin_ia32_andpd (v2df, v2df) 9689v2df __builtin_ia32_andnpd (v2df, v2df) 9690v2df __builtin_ia32_orpd (v2df, v2df) 9691v2df __builtin_ia32_xorpd (v2df, v2df) 9692v2df __builtin_ia32_movsd (v2df, v2df) 9693v2df __builtin_ia32_unpckhpd (v2df, v2df) 9694v2df __builtin_ia32_unpcklpd (v2df, v2df) 9695v16qi __builtin_ia32_paddb128 (v16qi, v16qi) 9696v8hi __builtin_ia32_paddw128 (v8hi, v8hi) 9697v4si __builtin_ia32_paddd128 (v4si, v4si) 9698v2di __builtin_ia32_paddq128 (v2di, v2di) 9699v16qi __builtin_ia32_psubb128 (v16qi, v16qi) 9700v8hi __builtin_ia32_psubw128 (v8hi, v8hi) 9701v4si __builtin_ia32_psubd128 (v4si, v4si) 9702v2di __builtin_ia32_psubq128 (v2di, v2di) 9703v8hi __builtin_ia32_pmullw128 (v8hi, v8hi) 9704v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi) 9705v2di __builtin_ia32_pand128 (v2di, v2di) 9706v2di __builtin_ia32_pandn128 (v2di, v2di) 9707v2di __builtin_ia32_por128 (v2di, v2di) 9708v2di __builtin_ia32_pxor128 (v2di, v2di) 9709v16qi __builtin_ia32_pavgb128 (v16qi, v16qi) 9710v8hi __builtin_ia32_pavgw128 (v8hi, v8hi) 9711v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi) 9712v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi) 9713v4si __builtin_ia32_pcmpeqd128 (v4si, v4si) 9714v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi) 9715v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi) 9716v4si __builtin_ia32_pcmpgtd128 (v4si, v4si) 9717v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi) 9718v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi) 9719v16qi __builtin_ia32_pminub128 (v16qi, v16qi) 9720v8hi __builtin_ia32_pminsw128 (v8hi, v8hi) 9721v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi) 9722v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi) 9723v4si __builtin_ia32_punpckhdq128 (v4si, v4si) 9724v2di __builtin_ia32_punpckhqdq128 (v2di, v2di) 9725v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi) 9726v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi) 9727v4si __builtin_ia32_punpckldq128 (v4si, v4si) 9728v2di __builtin_ia32_punpcklqdq128 (v2di, v2di) 9729v16qi __builtin_ia32_packsswb128 (v8hi, v8hi) 9730v8hi __builtin_ia32_packssdw128 (v4si, v4si) 9731v16qi __builtin_ia32_packuswb128 (v8hi, v8hi) 9732v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi) 9733void __builtin_ia32_maskmovdqu (v16qi, v16qi) 9734v2df __builtin_ia32_loadupd (double *) 9735void __builtin_ia32_storeupd (double *, v2df) 9736v2df __builtin_ia32_loadhpd (v2df, double const *) 9737v2df __builtin_ia32_loadlpd (v2df, double const *) 9738int __builtin_ia32_movmskpd (v2df) 9739int __builtin_ia32_pmovmskb128 (v16qi) 9740void __builtin_ia32_movnti (int *, int) 9741void __builtin_ia32_movnti64 (long long int *, long long int) 9742void __builtin_ia32_movntpd (double *, v2df) 9743void __builtin_ia32_movntdq (v2df *, v2df) 9744v4si __builtin_ia32_pshufd (v4si, int) 9745v8hi __builtin_ia32_pshuflw (v8hi, int) 9746v8hi __builtin_ia32_pshufhw (v8hi, int) 9747v2di __builtin_ia32_psadbw128 (v16qi, v16qi) 9748v2df __builtin_ia32_sqrtpd (v2df) 9749v2df __builtin_ia32_sqrtsd (v2df) 9750v2df __builtin_ia32_shufpd (v2df, v2df, int) 9751v2df __builtin_ia32_cvtdq2pd (v4si) 9752v4sf __builtin_ia32_cvtdq2ps (v4si) 9753v4si __builtin_ia32_cvtpd2dq (v2df) 9754v2si __builtin_ia32_cvtpd2pi (v2df) 9755v4sf __builtin_ia32_cvtpd2ps (v2df) 9756v4si __builtin_ia32_cvttpd2dq (v2df) 9757v2si __builtin_ia32_cvttpd2pi (v2df) 9758v2df __builtin_ia32_cvtpi2pd (v2si) 9759int __builtin_ia32_cvtsd2si (v2df) 9760int __builtin_ia32_cvttsd2si (v2df) 9761long long __builtin_ia32_cvtsd2si64 (v2df) 9762long long __builtin_ia32_cvttsd2si64 (v2df) 9763v4si __builtin_ia32_cvtps2dq (v4sf) 9764v2df __builtin_ia32_cvtps2pd (v4sf) 9765v4si __builtin_ia32_cvttps2dq (v4sf) 9766v2df __builtin_ia32_cvtsi2sd (v2df, int) 9767v2df __builtin_ia32_cvtsi642sd (v2df, long long) 9768v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df) 9769v2df __builtin_ia32_cvtss2sd (v2df, v4sf) 9770void __builtin_ia32_clflush (const void *) 9771void __builtin_ia32_lfence (void) 9772void __builtin_ia32_mfence (void) 9773v16qi __builtin_ia32_loaddqu (const char *) 9774void __builtin_ia32_storedqu (char *, v16qi) 9775v1di __builtin_ia32_pmuludq (v2si, v2si) 9776v2di __builtin_ia32_pmuludq128 (v4si, v4si) 9777v8hi __builtin_ia32_psllw128 (v8hi, v8hi) 9778v4si __builtin_ia32_pslld128 (v4si, v4si) 9779v2di __builtin_ia32_psllq128 (v2di, v2di) 9780v8hi __builtin_ia32_psrlw128 (v8hi, v8hi) 9781v4si __builtin_ia32_psrld128 (v4si, v4si) 9782v2di __builtin_ia32_psrlq128 (v2di, v2di) 9783v8hi __builtin_ia32_psraw128 (v8hi, v8hi) 9784v4si __builtin_ia32_psrad128 (v4si, v4si) 9785v2di __builtin_ia32_pslldqi128 (v2di, int) 9786v8hi __builtin_ia32_psllwi128 (v8hi, int) 9787v4si __builtin_ia32_pslldi128 (v4si, int) 9788v2di __builtin_ia32_psllqi128 (v2di, int) 9789v2di __builtin_ia32_psrldqi128 (v2di, int) 9790v8hi __builtin_ia32_psrlwi128 (v8hi, int) 9791v4si __builtin_ia32_psrldi128 (v4si, int) 9792v2di __builtin_ia32_psrlqi128 (v2di, int) 9793v8hi __builtin_ia32_psrawi128 (v8hi, int) 9794v4si __builtin_ia32_psradi128 (v4si, int) 9795v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi) 9796v2di __builtin_ia32_movq128 (v2di) 9797@end smallexample 9798 9799The following built-in functions are available when @option{-msse3} is used. 9800All of them generate the machine instruction that is part of the name. 9801 9802@smallexample 9803v2df __builtin_ia32_addsubpd (v2df, v2df) 9804v4sf __builtin_ia32_addsubps (v4sf, v4sf) 9805v2df __builtin_ia32_haddpd (v2df, v2df) 9806v4sf __builtin_ia32_haddps (v4sf, v4sf) 9807v2df __builtin_ia32_hsubpd (v2df, v2df) 9808v4sf __builtin_ia32_hsubps (v4sf, v4sf) 9809v16qi __builtin_ia32_lddqu (char const *) 9810void __builtin_ia32_monitor (void *, unsigned int, unsigned int) 9811v2df __builtin_ia32_movddup (v2df) 9812v4sf __builtin_ia32_movshdup (v4sf) 9813v4sf __builtin_ia32_movsldup (v4sf) 9814void __builtin_ia32_mwait (unsigned int, unsigned int) 9815@end smallexample 9816 9817The following built-in functions are available when @option{-msse3} is used. 9818 9819@table @code 9820@item v2df __builtin_ia32_loadddup (double const *) 9821Generates the @code{movddup} machine instruction as a load from memory. 9822@end table 9823 9824The following built-in functions are available when @option{-mssse3} is used. 9825All of them generate the machine instruction that is part of the name 9826with MMX registers. 9827 9828@smallexample 9829v2si __builtin_ia32_phaddd (v2si, v2si) 9830v4hi __builtin_ia32_phaddw (v4hi, v4hi) 9831v4hi __builtin_ia32_phaddsw (v4hi, v4hi) 9832v2si __builtin_ia32_phsubd (v2si, v2si) 9833v4hi __builtin_ia32_phsubw (v4hi, v4hi) 9834v4hi __builtin_ia32_phsubsw (v4hi, v4hi) 9835v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi) 9836v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi) 9837v8qi __builtin_ia32_pshufb (v8qi, v8qi) 9838v8qi __builtin_ia32_psignb (v8qi, v8qi) 9839v2si __builtin_ia32_psignd (v2si, v2si) 9840v4hi __builtin_ia32_psignw (v4hi, v4hi) 9841v1di __builtin_ia32_palignr (v1di, v1di, int) 9842v8qi __builtin_ia32_pabsb (v8qi) 9843v2si __builtin_ia32_pabsd (v2si) 9844v4hi __builtin_ia32_pabsw (v4hi) 9845@end smallexample 9846 9847The following built-in functions are available when @option{-mssse3} is used. 9848All of them generate the machine instruction that is part of the name 9849with SSE registers. 9850 9851@smallexample 9852v4si __builtin_ia32_phaddd128 (v4si, v4si) 9853v8hi __builtin_ia32_phaddw128 (v8hi, v8hi) 9854v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi) 9855v4si __builtin_ia32_phsubd128 (v4si, v4si) 9856v8hi __builtin_ia32_phsubw128 (v8hi, v8hi) 9857v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi) 9858v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi) 9859v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi) 9860v16qi __builtin_ia32_pshufb128 (v16qi, v16qi) 9861v16qi __builtin_ia32_psignb128 (v16qi, v16qi) 9862v4si __builtin_ia32_psignd128 (v4si, v4si) 9863v8hi __builtin_ia32_psignw128 (v8hi, v8hi) 9864v2di __builtin_ia32_palignr128 (v2di, v2di, int) 9865v16qi __builtin_ia32_pabsb128 (v16qi) 9866v4si __builtin_ia32_pabsd128 (v4si) 9867v8hi __builtin_ia32_pabsw128 (v8hi) 9868@end smallexample 9869 9870The following built-in functions are available when @option{-msse4.1} is 9871used. All of them generate the machine instruction that is part of the 9872name. 9873 9874@smallexample 9875v2df __builtin_ia32_blendpd (v2df, v2df, const int) 9876v4sf __builtin_ia32_blendps (v4sf, v4sf, const int) 9877v2df __builtin_ia32_blendvpd (v2df, v2df, v2df) 9878v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf) 9879v2df __builtin_ia32_dppd (v2df, v2df, const int) 9880v4sf __builtin_ia32_dpps (v4sf, v4sf, const int) 9881v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int) 9882v2di __builtin_ia32_movntdqa (v2di *); 9883v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int) 9884v8hi __builtin_ia32_packusdw128 (v4si, v4si) 9885v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi) 9886v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int) 9887v2di __builtin_ia32_pcmpeqq (v2di, v2di) 9888v8hi __builtin_ia32_phminposuw128 (v8hi) 9889v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi) 9890v4si __builtin_ia32_pmaxsd128 (v4si, v4si) 9891v4si __builtin_ia32_pmaxud128 (v4si, v4si) 9892v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi) 9893v16qi __builtin_ia32_pminsb128 (v16qi, v16qi) 9894v4si __builtin_ia32_pminsd128 (v4si, v4si) 9895v4si __builtin_ia32_pminud128 (v4si, v4si) 9896v8hi __builtin_ia32_pminuw128 (v8hi, v8hi) 9897v4si __builtin_ia32_pmovsxbd128 (v16qi) 9898v2di __builtin_ia32_pmovsxbq128 (v16qi) 9899v8hi __builtin_ia32_pmovsxbw128 (v16qi) 9900v2di __builtin_ia32_pmovsxdq128 (v4si) 9901v4si __builtin_ia32_pmovsxwd128 (v8hi) 9902v2di __builtin_ia32_pmovsxwq128 (v8hi) 9903v4si __builtin_ia32_pmovzxbd128 (v16qi) 9904v2di __builtin_ia32_pmovzxbq128 (v16qi) 9905v8hi __builtin_ia32_pmovzxbw128 (v16qi) 9906v2di __builtin_ia32_pmovzxdq128 (v4si) 9907v4si __builtin_ia32_pmovzxwd128 (v8hi) 9908v2di __builtin_ia32_pmovzxwq128 (v8hi) 9909v2di __builtin_ia32_pmuldq128 (v4si, v4si) 9910v4si __builtin_ia32_pmulld128 (v4si, v4si) 9911int __builtin_ia32_ptestc128 (v2di, v2di) 9912int __builtin_ia32_ptestnzc128 (v2di, v2di) 9913int __builtin_ia32_ptestz128 (v2di, v2di) 9914v2df __builtin_ia32_roundpd (v2df, const int) 9915v4sf __builtin_ia32_roundps (v4sf, const int) 9916v2df __builtin_ia32_roundsd (v2df, v2df, const int) 9917v4sf __builtin_ia32_roundss (v4sf, v4sf, const int) 9918@end smallexample 9919 9920The following built-in functions are available when @option{-msse4.1} is 9921used. 9922 9923@table @code 9924@item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int) 9925Generates the @code{insertps} machine instruction. 9926@item int __builtin_ia32_vec_ext_v16qi (v16qi, const int) 9927Generates the @code{pextrb} machine instruction. 9928@item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int) 9929Generates the @code{pinsrb} machine instruction. 9930@item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int) 9931Generates the @code{pinsrd} machine instruction. 9932@item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int) 9933Generates the @code{pinsrq} machine instruction in 64bit mode. 9934@end table 9935 9936The following built-in functions are changed to generate new SSE4.1 9937instructions when @option{-msse4.1} is used. 9938 9939@table @code 9940@item float __builtin_ia32_vec_ext_v4sf (v4sf, const int) 9941Generates the @code{extractps} machine instruction. 9942@item int __builtin_ia32_vec_ext_v4si (v4si, const int) 9943Generates the @code{pextrd} machine instruction. 9944@item long long __builtin_ia32_vec_ext_v2di (v2di, const int) 9945Generates the @code{pextrq} machine instruction in 64bit mode. 9946@end table 9947 9948The following built-in functions are available when @option{-msse4.2} is 9949used. All of them generate the machine instruction that is part of the 9950name. 9951 9952@smallexample 9953v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int) 9954int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int) 9955int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int) 9956int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int) 9957int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int) 9958int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int) 9959int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int) 9960v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int) 9961int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int) 9962int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int) 9963int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int) 9964int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int) 9965int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int) 9966int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int) 9967v2di __builtin_ia32_pcmpgtq (v2di, v2di) 9968@end smallexample 9969 9970The following built-in functions are available when @option{-msse4.2} is 9971used. 9972 9973@table @code 9974@item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char) 9975Generates the @code{crc32b} machine instruction. 9976@item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short) 9977Generates the @code{crc32w} machine instruction. 9978@item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int) 9979Generates the @code{crc32l} machine instruction. 9980@item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long) 9981Generates the @code{crc32q} machine instruction. 9982@end table 9983 9984The following built-in functions are changed to generate new SSE4.2 9985instructions when @option{-msse4.2} is used. 9986 9987@table @code 9988@item int __builtin_popcount (unsigned int) 9989Generates the @code{popcntl} machine instruction. 9990@item int __builtin_popcountl (unsigned long) 9991Generates the @code{popcntl} or @code{popcntq} machine instruction, 9992depending on the size of @code{unsigned long}. 9993@item int __builtin_popcountll (unsigned long long) 9994Generates the @code{popcntq} machine instruction. 9995@end table 9996 9997The following built-in functions are available when @option{-mavx} is 9998used. All of them generate the machine instruction that is part of the 9999name. 10000 10001@smallexample 10002v4df __builtin_ia32_addpd256 (v4df,v4df) 10003v8sf __builtin_ia32_addps256 (v8sf,v8sf) 10004v4df __builtin_ia32_addsubpd256 (v4df,v4df) 10005v8sf __builtin_ia32_addsubps256 (v8sf,v8sf) 10006v4df __builtin_ia32_andnpd256 (v4df,v4df) 10007v8sf __builtin_ia32_andnps256 (v8sf,v8sf) 10008v4df __builtin_ia32_andpd256 (v4df,v4df) 10009v8sf __builtin_ia32_andps256 (v8sf,v8sf) 10010v4df __builtin_ia32_blendpd256 (v4df,v4df,int) 10011v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int) 10012v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df) 10013v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf) 10014v2df __builtin_ia32_cmppd (v2df,v2df,int) 10015v4df __builtin_ia32_cmppd256 (v4df,v4df,int) 10016v4sf __builtin_ia32_cmpps (v4sf,v4sf,int) 10017v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int) 10018v2df __builtin_ia32_cmpsd (v2df,v2df,int) 10019v4sf __builtin_ia32_cmpss (v4sf,v4sf,int) 10020v4df __builtin_ia32_cvtdq2pd256 (v4si) 10021v8sf __builtin_ia32_cvtdq2ps256 (v8si) 10022v4si __builtin_ia32_cvtpd2dq256 (v4df) 10023v4sf __builtin_ia32_cvtpd2ps256 (v4df) 10024v8si __builtin_ia32_cvtps2dq256 (v8sf) 10025v4df __builtin_ia32_cvtps2pd256 (v4sf) 10026v4si __builtin_ia32_cvttpd2dq256 (v4df) 10027v8si __builtin_ia32_cvttps2dq256 (v8sf) 10028v4df __builtin_ia32_divpd256 (v4df,v4df) 10029v8sf __builtin_ia32_divps256 (v8sf,v8sf) 10030v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int) 10031v4df __builtin_ia32_haddpd256 (v4df,v4df) 10032v8sf __builtin_ia32_haddps256 (v8sf,v8sf) 10033v4df __builtin_ia32_hsubpd256 (v4df,v4df) 10034v8sf __builtin_ia32_hsubps256 (v8sf,v8sf) 10035v32qi __builtin_ia32_lddqu256 (pcchar) 10036v32qi __builtin_ia32_loaddqu256 (pcchar) 10037v4df __builtin_ia32_loadupd256 (pcdouble) 10038v8sf __builtin_ia32_loadups256 (pcfloat) 10039v2df __builtin_ia32_maskloadpd (pcv2df,v2df) 10040v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df) 10041v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf) 10042v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf) 10043void __builtin_ia32_maskstorepd (pv2df,v2df,v2df) 10044void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df) 10045void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf) 10046void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf) 10047v4df __builtin_ia32_maxpd256 (v4df,v4df) 10048v8sf __builtin_ia32_maxps256 (v8sf,v8sf) 10049v4df __builtin_ia32_minpd256 (v4df,v4df) 10050v8sf __builtin_ia32_minps256 (v8sf,v8sf) 10051v4df __builtin_ia32_movddup256 (v4df) 10052int __builtin_ia32_movmskpd256 (v4df) 10053int __builtin_ia32_movmskps256 (v8sf) 10054v8sf __builtin_ia32_movshdup256 (v8sf) 10055v8sf __builtin_ia32_movsldup256 (v8sf) 10056v4df __builtin_ia32_mulpd256 (v4df,v4df) 10057v8sf __builtin_ia32_mulps256 (v8sf,v8sf) 10058v4df __builtin_ia32_orpd256 (v4df,v4df) 10059v8sf __builtin_ia32_orps256 (v8sf,v8sf) 10060v2df __builtin_ia32_pd_pd256 (v4df) 10061v4df __builtin_ia32_pd256_pd (v2df) 10062v4sf __builtin_ia32_ps_ps256 (v8sf) 10063v8sf __builtin_ia32_ps256_ps (v4sf) 10064int __builtin_ia32_ptestc256 (v4di,v4di,ptest) 10065int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest) 10066int __builtin_ia32_ptestz256 (v4di,v4di,ptest) 10067v8sf __builtin_ia32_rcpps256 (v8sf) 10068v4df __builtin_ia32_roundpd256 (v4df,int) 10069v8sf __builtin_ia32_roundps256 (v8sf,int) 10070v8sf __builtin_ia32_rsqrtps_nr256 (v8sf) 10071v8sf __builtin_ia32_rsqrtps256 (v8sf) 10072v4df __builtin_ia32_shufpd256 (v4df,v4df,int) 10073v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int) 10074v4si __builtin_ia32_si_si256 (v8si) 10075v8si __builtin_ia32_si256_si (v4si) 10076v4df __builtin_ia32_sqrtpd256 (v4df) 10077v8sf __builtin_ia32_sqrtps_nr256 (v8sf) 10078v8sf __builtin_ia32_sqrtps256 (v8sf) 10079void __builtin_ia32_storedqu256 (pchar,v32qi) 10080void __builtin_ia32_storeupd256 (pdouble,v4df) 10081void __builtin_ia32_storeups256 (pfloat,v8sf) 10082v4df __builtin_ia32_subpd256 (v4df,v4df) 10083v8sf __builtin_ia32_subps256 (v8sf,v8sf) 10084v4df __builtin_ia32_unpckhpd256 (v4df,v4df) 10085v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf) 10086v4df __builtin_ia32_unpcklpd256 (v4df,v4df) 10087v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf) 10088v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df) 10089v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf) 10090v4df __builtin_ia32_vbroadcastsd256 (pcdouble) 10091v4sf __builtin_ia32_vbroadcastss (pcfloat) 10092v8sf __builtin_ia32_vbroadcastss256 (pcfloat) 10093v2df __builtin_ia32_vextractf128_pd256 (v4df,int) 10094v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int) 10095v4si __builtin_ia32_vextractf128_si256 (v8si,int) 10096v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int) 10097v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int) 10098v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int) 10099v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int) 10100v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int) 10101v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int) 10102v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int) 10103v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int) 10104v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int) 10105v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int) 10106v2df __builtin_ia32_vpermilpd (v2df,int) 10107v4df __builtin_ia32_vpermilpd256 (v4df,int) 10108v4sf __builtin_ia32_vpermilps (v4sf,int) 10109v8sf __builtin_ia32_vpermilps256 (v8sf,int) 10110v2df __builtin_ia32_vpermilvarpd (v2df,v2di) 10111v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di) 10112v4sf __builtin_ia32_vpermilvarps (v4sf,v4si) 10113v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si) 10114int __builtin_ia32_vtestcpd (v2df,v2df,ptest) 10115int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest) 10116int __builtin_ia32_vtestcps (v4sf,v4sf,ptest) 10117int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest) 10118int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest) 10119int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest) 10120int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest) 10121int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest) 10122int __builtin_ia32_vtestzpd (v2df,v2df,ptest) 10123int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest) 10124int __builtin_ia32_vtestzps (v4sf,v4sf,ptest) 10125int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest) 10126void __builtin_ia32_vzeroall (void) 10127void __builtin_ia32_vzeroupper (void) 10128v4df __builtin_ia32_xorpd256 (v4df,v4df) 10129v8sf __builtin_ia32_xorps256 (v8sf,v8sf) 10130@end smallexample 10131 10132The following built-in functions are available when @option{-mavx2} is 10133used. All of them generate the machine instruction that is part of the 10134name. 10135 10136@smallexample 10137v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,v32qi,int) 10138v32qi __builtin_ia32_pabsb256 (v32qi) 10139v16hi __builtin_ia32_pabsw256 (v16hi) 10140v8si __builtin_ia32_pabsd256 (v8si) 10141v16hi __builtin_ia32_packssdw256 (v8si,v8si) 10142v32qi __builtin_ia32_packsswb256 (v16hi,v16hi) 10143v16hi __builtin_ia32_packusdw256 (v8si,v8si) 10144v32qi __builtin_ia32_packuswb256 (v16hi,v16hi) 10145v32qi __builtin_ia32_paddb256 (v32qi,v32qi) 10146v16hi __builtin_ia32_paddw256 (v16hi,v16hi) 10147v8si __builtin_ia32_paddd256 (v8si,v8si) 10148v4di __builtin_ia32_paddq256 (v4di,v4di) 10149v32qi __builtin_ia32_paddsb256 (v32qi,v32qi) 10150v16hi __builtin_ia32_paddsw256 (v16hi,v16hi) 10151v32qi __builtin_ia32_paddusb256 (v32qi,v32qi) 10152v16hi __builtin_ia32_paddusw256 (v16hi,v16hi) 10153v4di __builtin_ia32_palignr256 (v4di,v4di,int) 10154v4di __builtin_ia32_andsi256 (v4di,v4di) 10155v4di __builtin_ia32_andnotsi256 (v4di,v4di) 10156v32qi __builtin_ia32_pavgb256 (v32qi,v32qi) 10157v16hi __builtin_ia32_pavgw256 (v16hi,v16hi) 10158v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi) 10159v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int) 10160v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi) 10161v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi) 10162v8si __builtin_ia32_pcmpeqd256 (c8si,v8si) 10163v4di __builtin_ia32_pcmpeqq256 (v4di,v4di) 10164v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi) 10165v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi) 10166v8si __builtin_ia32_pcmpgtd256 (v8si,v8si) 10167v4di __builtin_ia32_pcmpgtq256 (v4di,v4di) 10168v16hi __builtin_ia32_phaddw256 (v16hi,v16hi) 10169v8si __builtin_ia32_phaddd256 (v8si,v8si) 10170v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi) 10171v16hi __builtin_ia32_phsubw256 (v16hi,v16hi) 10172v8si __builtin_ia32_phsubd256 (v8si,v8si) 10173v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi) 10174v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi) 10175v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi) 10176v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi) 10177v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi) 10178v8si __builtin_ia32_pmaxsd256 (v8si,v8si) 10179v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi) 10180v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi) 10181v8si __builtin_ia32_pmaxud256 (v8si,v8si) 10182v32qi __builtin_ia32_pminsb256 (v32qi,v32qi) 10183v16hi __builtin_ia32_pminsw256 (v16hi,v16hi) 10184v8si __builtin_ia32_pminsd256 (v8si,v8si) 10185v32qi __builtin_ia32_pminub256 (v32qi,v32qi) 10186v16hi __builtin_ia32_pminuw256 (v16hi,v16hi) 10187v8si __builtin_ia32_pminud256 (v8si,v8si) 10188int __builtin_ia32_pmovmskb256 (v32qi) 10189v16hi __builtin_ia32_pmovsxbw256 (v16qi) 10190v8si __builtin_ia32_pmovsxbd256 (v16qi) 10191v4di __builtin_ia32_pmovsxbq256 (v16qi) 10192v8si __builtin_ia32_pmovsxwd256 (v8hi) 10193v4di __builtin_ia32_pmovsxwq256 (v8hi) 10194v4di __builtin_ia32_pmovsxdq256 (v4si) 10195v16hi __builtin_ia32_pmovzxbw256 (v16qi) 10196v8si __builtin_ia32_pmovzxbd256 (v16qi) 10197v4di __builtin_ia32_pmovzxbq256 (v16qi) 10198v8si __builtin_ia32_pmovzxwd256 (v8hi) 10199v4di __builtin_ia32_pmovzxwq256 (v8hi) 10200v4di __builtin_ia32_pmovzxdq256 (v4si) 10201v4di __builtin_ia32_pmuldq256 (v8si,v8si) 10202v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi) 10203v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi) 10204v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi) 10205v16hi __builtin_ia32_pmullw256 (v16hi,v16hi) 10206v8si __builtin_ia32_pmulld256 (v8si,v8si) 10207v4di __builtin_ia32_pmuludq256 (v8si,v8si) 10208v4di __builtin_ia32_por256 (v4di,v4di) 10209v16hi __builtin_ia32_psadbw256 (v32qi,v32qi) 10210v32qi __builtin_ia32_pshufb256 (v32qi,v32qi) 10211v8si __builtin_ia32_pshufd256 (v8si,int) 10212v16hi __builtin_ia32_pshufhw256 (v16hi,int) 10213v16hi __builtin_ia32_pshuflw256 (v16hi,int) 10214v32qi __builtin_ia32_psignb256 (v32qi,v32qi) 10215v16hi __builtin_ia32_psignw256 (v16hi,v16hi) 10216v8si __builtin_ia32_psignd256 (v8si,v8si) 10217v4di __builtin_ia32_pslldqi256 (v4di,int) 10218v16hi __builtin_ia32_psllwi256 (16hi,int) 10219v16hi __builtin_ia32_psllw256(v16hi,v8hi) 10220v8si __builtin_ia32_pslldi256 (v8si,int) 10221v8si __builtin_ia32_pslld256(v8si,v4si) 10222v4di __builtin_ia32_psllqi256 (v4di,int) 10223v4di __builtin_ia32_psllq256(v4di,v2di) 10224v16hi __builtin_ia32_psrawi256 (v16hi,int) 10225v16hi __builtin_ia32_psraw256 (v16hi,v8hi) 10226v8si __builtin_ia32_psradi256 (v8si,int) 10227v8si __builtin_ia32_psrad256 (v8si,v4si) 10228v4di __builtin_ia32_psrldqi256 (v4di, int) 10229v16hi __builtin_ia32_psrlwi256 (v16hi,int) 10230v16hi __builtin_ia32_psrlw256 (v16hi,v8hi) 10231v8si __builtin_ia32_psrldi256 (v8si,int) 10232v8si __builtin_ia32_psrld256 (v8si,v4si) 10233v4di __builtin_ia32_psrlqi256 (v4di,int) 10234v4di __builtin_ia32_psrlq256(v4di,v2di) 10235v32qi __builtin_ia32_psubb256 (v32qi,v32qi) 10236v32hi __builtin_ia32_psubw256 (v16hi,v16hi) 10237v8si __builtin_ia32_psubd256 (v8si,v8si) 10238v4di __builtin_ia32_psubq256 (v4di,v4di) 10239v32qi __builtin_ia32_psubsb256 (v32qi,v32qi) 10240v16hi __builtin_ia32_psubsw256 (v16hi,v16hi) 10241v32qi __builtin_ia32_psubusb256 (v32qi,v32qi) 10242v16hi __builtin_ia32_psubusw256 (v16hi,v16hi) 10243v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi) 10244v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi) 10245v8si __builtin_ia32_punpckhdq256 (v8si,v8si) 10246v4di __builtin_ia32_punpckhqdq256 (v4di,v4di) 10247v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi) 10248v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi) 10249v8si __builtin_ia32_punpckldq256 (v8si,v8si) 10250v4di __builtin_ia32_punpcklqdq256 (v4di,v4di) 10251v4di __builtin_ia32_pxor256 (v4di,v4di) 10252v4di __builtin_ia32_movntdqa256 (pv4di) 10253v4sf __builtin_ia32_vbroadcastss_ps (v4sf) 10254v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf) 10255v4df __builtin_ia32_vbroadcastsd_pd256 (v2df) 10256v4di __builtin_ia32_vbroadcastsi256 (v2di) 10257v4si __builtin_ia32_pblendd128 (v4si,v4si) 10258v8si __builtin_ia32_pblendd256 (v8si,v8si) 10259v32qi __builtin_ia32_pbroadcastb256 (v16qi) 10260v16hi __builtin_ia32_pbroadcastw256 (v8hi) 10261v8si __builtin_ia32_pbroadcastd256 (v4si) 10262v4di __builtin_ia32_pbroadcastq256 (v2di) 10263v16qi __builtin_ia32_pbroadcastb128 (v16qi) 10264v8hi __builtin_ia32_pbroadcastw128 (v8hi) 10265v4si __builtin_ia32_pbroadcastd128 (v4si) 10266v2di __builtin_ia32_pbroadcastq128 (v2di) 10267v8si __builtin_ia32_permvarsi256 (v8si,v8si) 10268v4df __builtin_ia32_permdf256 (v4df,int) 10269v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf) 10270v4di __builtin_ia32_permdi256 (v4di,int) 10271v4di __builtin_ia32_permti256 (v4di,v4di,int) 10272v4di __builtin_ia32_extract128i256 (v4di,int) 10273v4di __builtin_ia32_insert128i256 (v4di,v2di,int) 10274v8si __builtin_ia32_maskloadd256 (pcv8si,v8si) 10275v4di __builtin_ia32_maskloadq256 (pcv4di,v4di) 10276v4si __builtin_ia32_maskloadd (pcv4si,v4si) 10277v2di __builtin_ia32_maskloadq (pcv2di,v2di) 10278void __builtin_ia32_maskstored256 (pv8si,v8si,v8si) 10279void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di) 10280void __builtin_ia32_maskstored (pv4si,v4si,v4si) 10281void __builtin_ia32_maskstoreq (pv2di,v2di,v2di) 10282v8si __builtin_ia32_psllv8si (v8si,v8si) 10283v4si __builtin_ia32_psllv4si (v4si,v4si) 10284v4di __builtin_ia32_psllv4di (v4di,v4di) 10285v2di __builtin_ia32_psllv2di (v2di,v2di) 10286v8si __builtin_ia32_psrav8si (v8si,v8si) 10287v4si __builtin_ia32_psrav4si (v4si,v4si) 10288v8si __builtin_ia32_psrlv8si (v8si,v8si) 10289v4si __builtin_ia32_psrlv4si (v4si,v4si) 10290v4di __builtin_ia32_psrlv4di (v4di,v4di) 10291v2di __builtin_ia32_psrlv2di (v2di,v2di) 10292v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int) 10293v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int) 10294v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int) 10295v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int) 10296v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int) 10297v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int) 10298v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int) 10299v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int) 10300v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int) 10301v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int) 10302v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int) 10303v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int) 10304v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int) 10305v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int) 10306v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int) 10307v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int) 10308@end smallexample 10309 10310The following built-in functions are available when @option{-maes} is 10311used. All of them generate the machine instruction that is part of the 10312name. 10313 10314@smallexample 10315v2di __builtin_ia32_aesenc128 (v2di, v2di) 10316v2di __builtin_ia32_aesenclast128 (v2di, v2di) 10317v2di __builtin_ia32_aesdec128 (v2di, v2di) 10318v2di __builtin_ia32_aesdeclast128 (v2di, v2di) 10319v2di __builtin_ia32_aeskeygenassist128 (v2di, const int) 10320v2di __builtin_ia32_aesimc128 (v2di) 10321@end smallexample 10322 10323The following built-in function is available when @option{-mpclmul} is 10324used. 10325 10326@table @code 10327@item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int) 10328Generates the @code{pclmulqdq} machine instruction. 10329@end table 10330 10331The following built-in function is available when @option{-mfsgsbase} is 10332used. All of them generate the machine instruction that is part of the 10333name. 10334 10335@smallexample 10336unsigned int __builtin_ia32_rdfsbase32 (void) 10337unsigned long long __builtin_ia32_rdfsbase64 (void) 10338unsigned int __builtin_ia32_rdgsbase32 (void) 10339unsigned long long __builtin_ia32_rdgsbase64 (void) 10340void _writefsbase_u32 (unsigned int) 10341void _writefsbase_u64 (unsigned long long) 10342void _writegsbase_u32 (unsigned int) 10343void _writegsbase_u64 (unsigned long long) 10344@end smallexample 10345 10346The following built-in function is available when @option{-mrdrnd} is 10347used. All of them generate the machine instruction that is part of the 10348name. 10349 10350@smallexample 10351unsigned int __builtin_ia32_rdrand16_step (unsigned short *) 10352unsigned int __builtin_ia32_rdrand32_step (unsigned int *) 10353unsigned int __builtin_ia32_rdrand64_step (unsigned long long *) 10354@end smallexample 10355 10356The following built-in functions are available when @option{-msse4a} is used. 10357All of them generate the machine instruction that is part of the name. 10358 10359@smallexample 10360void __builtin_ia32_movntsd (double *, v2df) 10361void __builtin_ia32_movntss (float *, v4sf) 10362v2di __builtin_ia32_extrq (v2di, v16qi) 10363v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int) 10364v2di __builtin_ia32_insertq (v2di, v2di) 10365v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int) 10366@end smallexample 10367 10368The following built-in functions are available when @option{-mxop} is used. 10369@smallexample 10370v2df __builtin_ia32_vfrczpd (v2df) 10371v4sf __builtin_ia32_vfrczps (v4sf) 10372v2df __builtin_ia32_vfrczsd (v2df, v2df) 10373v4sf __builtin_ia32_vfrczss (v4sf, v4sf) 10374v4df __builtin_ia32_vfrczpd256 (v4df) 10375v8sf __builtin_ia32_vfrczps256 (v8sf) 10376v2di __builtin_ia32_vpcmov (v2di, v2di, v2di) 10377v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di) 10378v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si) 10379v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi) 10380v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi) 10381v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df) 10382v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf) 10383v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di) 10384v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si) 10385v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi) 10386v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi) 10387v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df) 10388v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf) 10389v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi) 10390v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi) 10391v4si __builtin_ia32_vpcomeqd (v4si, v4si) 10392v2di __builtin_ia32_vpcomeqq (v2di, v2di) 10393v16qi __builtin_ia32_vpcomequb (v16qi, v16qi) 10394v4si __builtin_ia32_vpcomequd (v4si, v4si) 10395v2di __builtin_ia32_vpcomequq (v2di, v2di) 10396v8hi __builtin_ia32_vpcomequw (v8hi, v8hi) 10397v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi) 10398v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi) 10399v4si __builtin_ia32_vpcomfalsed (v4si, v4si) 10400v2di __builtin_ia32_vpcomfalseq (v2di, v2di) 10401v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi) 10402v4si __builtin_ia32_vpcomfalseud (v4si, v4si) 10403v2di __builtin_ia32_vpcomfalseuq (v2di, v2di) 10404v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi) 10405v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi) 10406v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi) 10407v4si __builtin_ia32_vpcomged (v4si, v4si) 10408v2di __builtin_ia32_vpcomgeq (v2di, v2di) 10409v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi) 10410v4si __builtin_ia32_vpcomgeud (v4si, v4si) 10411v2di __builtin_ia32_vpcomgeuq (v2di, v2di) 10412v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi) 10413v8hi __builtin_ia32_vpcomgew (v8hi, v8hi) 10414v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi) 10415v4si __builtin_ia32_vpcomgtd (v4si, v4si) 10416v2di __builtin_ia32_vpcomgtq (v2di, v2di) 10417v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi) 10418v4si __builtin_ia32_vpcomgtud (v4si, v4si) 10419v2di __builtin_ia32_vpcomgtuq (v2di, v2di) 10420v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi) 10421v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi) 10422v16qi __builtin_ia32_vpcomleb (v16qi, v16qi) 10423v4si __builtin_ia32_vpcomled (v4si, v4si) 10424v2di __builtin_ia32_vpcomleq (v2di, v2di) 10425v16qi __builtin_ia32_vpcomleub (v16qi, v16qi) 10426v4si __builtin_ia32_vpcomleud (v4si, v4si) 10427v2di __builtin_ia32_vpcomleuq (v2di, v2di) 10428v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi) 10429v8hi __builtin_ia32_vpcomlew (v8hi, v8hi) 10430v16qi __builtin_ia32_vpcomltb (v16qi, v16qi) 10431v4si __builtin_ia32_vpcomltd (v4si, v4si) 10432v2di __builtin_ia32_vpcomltq (v2di, v2di) 10433v16qi __builtin_ia32_vpcomltub (v16qi, v16qi) 10434v4si __builtin_ia32_vpcomltud (v4si, v4si) 10435v2di __builtin_ia32_vpcomltuq (v2di, v2di) 10436v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi) 10437v8hi __builtin_ia32_vpcomltw (v8hi, v8hi) 10438v16qi __builtin_ia32_vpcomneb (v16qi, v16qi) 10439v4si __builtin_ia32_vpcomned (v4si, v4si) 10440v2di __builtin_ia32_vpcomneq (v2di, v2di) 10441v16qi __builtin_ia32_vpcomneub (v16qi, v16qi) 10442v4si __builtin_ia32_vpcomneud (v4si, v4si) 10443v2di __builtin_ia32_vpcomneuq (v2di, v2di) 10444v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi) 10445v8hi __builtin_ia32_vpcomnew (v8hi, v8hi) 10446v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi) 10447v4si __builtin_ia32_vpcomtrued (v4si, v4si) 10448v2di __builtin_ia32_vpcomtrueq (v2di, v2di) 10449v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi) 10450v4si __builtin_ia32_vpcomtrueud (v4si, v4si) 10451v2di __builtin_ia32_vpcomtrueuq (v2di, v2di) 10452v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi) 10453v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi) 10454v4si __builtin_ia32_vphaddbd (v16qi) 10455v2di __builtin_ia32_vphaddbq (v16qi) 10456v8hi __builtin_ia32_vphaddbw (v16qi) 10457v2di __builtin_ia32_vphadddq (v4si) 10458v4si __builtin_ia32_vphaddubd (v16qi) 10459v2di __builtin_ia32_vphaddubq (v16qi) 10460v8hi __builtin_ia32_vphaddubw (v16qi) 10461v2di __builtin_ia32_vphaddudq (v4si) 10462v4si __builtin_ia32_vphadduwd (v8hi) 10463v2di __builtin_ia32_vphadduwq (v8hi) 10464v4si __builtin_ia32_vphaddwd (v8hi) 10465v2di __builtin_ia32_vphaddwq (v8hi) 10466v8hi __builtin_ia32_vphsubbw (v16qi) 10467v2di __builtin_ia32_vphsubdq (v4si) 10468v4si __builtin_ia32_vphsubwd (v8hi) 10469v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si) 10470v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di) 10471v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di) 10472v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si) 10473v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di) 10474v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di) 10475v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si) 10476v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi) 10477v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si) 10478v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi) 10479v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si) 10480v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si) 10481v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi) 10482v16qi __builtin_ia32_vprotb (v16qi, v16qi) 10483v4si __builtin_ia32_vprotd (v4si, v4si) 10484v2di __builtin_ia32_vprotq (v2di, v2di) 10485v8hi __builtin_ia32_vprotw (v8hi, v8hi) 10486v16qi __builtin_ia32_vpshab (v16qi, v16qi) 10487v4si __builtin_ia32_vpshad (v4si, v4si) 10488v2di __builtin_ia32_vpshaq (v2di, v2di) 10489v8hi __builtin_ia32_vpshaw (v8hi, v8hi) 10490v16qi __builtin_ia32_vpshlb (v16qi, v16qi) 10491v4si __builtin_ia32_vpshld (v4si, v4si) 10492v2di __builtin_ia32_vpshlq (v2di, v2di) 10493v8hi __builtin_ia32_vpshlw (v8hi, v8hi) 10494@end smallexample 10495 10496The following built-in functions are available when @option{-mfma4} is used. 10497All of them generate the machine instruction that is part of the name 10498with MMX registers. 10499 10500@smallexample 10501v2df __builtin_ia32_fmaddpd (v2df, v2df, v2df) 10502v4sf __builtin_ia32_fmaddps (v4sf, v4sf, v4sf) 10503v2df __builtin_ia32_fmaddsd (v2df, v2df, v2df) 10504v4sf __builtin_ia32_fmaddss (v4sf, v4sf, v4sf) 10505v2df __builtin_ia32_fmsubpd (v2df, v2df, v2df) 10506v4sf __builtin_ia32_fmsubps (v4sf, v4sf, v4sf) 10507v2df __builtin_ia32_fmsubsd (v2df, v2df, v2df) 10508v4sf __builtin_ia32_fmsubss (v4sf, v4sf, v4sf) 10509v2df __builtin_ia32_fnmaddpd (v2df, v2df, v2df) 10510v4sf __builtin_ia32_fnmaddps (v4sf, v4sf, v4sf) 10511v2df __builtin_ia32_fnmaddsd (v2df, v2df, v2df) 10512v4sf __builtin_ia32_fnmaddss (v4sf, v4sf, v4sf) 10513v2df __builtin_ia32_fnmsubpd (v2df, v2df, v2df) 10514v4sf __builtin_ia32_fnmsubps (v4sf, v4sf, v4sf) 10515v2df __builtin_ia32_fnmsubsd (v2df, v2df, v2df) 10516v4sf __builtin_ia32_fnmsubss (v4sf, v4sf, v4sf) 10517v2df __builtin_ia32_fmaddsubpd (v2df, v2df, v2df) 10518v4sf __builtin_ia32_fmaddsubps (v4sf, v4sf, v4sf) 10519v2df __builtin_ia32_fmsubaddpd (v2df, v2df, v2df) 10520v4sf __builtin_ia32_fmsubaddps (v4sf, v4sf, v4sf) 10521v4df __builtin_ia32_fmaddpd256 (v4df, v4df, v4df) 10522v8sf __builtin_ia32_fmaddps256 (v8sf, v8sf, v8sf) 10523v4df __builtin_ia32_fmsubpd256 (v4df, v4df, v4df) 10524v8sf __builtin_ia32_fmsubps256 (v8sf, v8sf, v8sf) 10525v4df __builtin_ia32_fnmaddpd256 (v4df, v4df, v4df) 10526v8sf __builtin_ia32_fnmaddps256 (v8sf, v8sf, v8sf) 10527v4df __builtin_ia32_fnmsubpd256 (v4df, v4df, v4df) 10528v8sf __builtin_ia32_fnmsubps256 (v8sf, v8sf, v8sf) 10529v4df __builtin_ia32_fmaddsubpd256 (v4df, v4df, v4df) 10530v8sf __builtin_ia32_fmaddsubps256 (v8sf, v8sf, v8sf) 10531v4df __builtin_ia32_fmsubaddpd256 (v4df, v4df, v4df) 10532v8sf __builtin_ia32_fmsubaddps256 (v8sf, v8sf, v8sf) 10533 10534@end smallexample 10535 10536The following built-in functions are available when @option{-mlwp} is used. 10537 10538@smallexample 10539void __builtin_ia32_llwpcb16 (void *); 10540void __builtin_ia32_llwpcb32 (void *); 10541void __builtin_ia32_llwpcb64 (void *); 10542void * __builtin_ia32_llwpcb16 (void); 10543void * __builtin_ia32_llwpcb32 (void); 10544void * __builtin_ia32_llwpcb64 (void); 10545void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short) 10546void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int) 10547void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int) 10548unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short) 10549unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int) 10550unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int) 10551@end smallexample 10552 10553The following built-in functions are available when @option{-mbmi} is used. 10554All of them generate the machine instruction that is part of the name. 10555@smallexample 10556unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int); 10557unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long); 10558@end smallexample 10559 10560The following built-in functions are available when @option{-mbmi2} is used. 10561All of them generate the machine instruction that is part of the name. 10562@smallexample 10563unsigned int _bzhi_u32 (unsigned int, unsigned int) 10564unsigned int _pdep_u32 (unsigned int, unsigned int) 10565unsigned int _pext_u32 (unsigned int, unsigned int) 10566unsigned long long _bzhi_u64 (unsigned long long, unsigned long long) 10567unsigned long long _pdep_u64 (unsigned long long, unsigned long long) 10568unsigned long long _pext_u64 (unsigned long long, unsigned long long) 10569@end smallexample 10570 10571The following built-in functions are available when @option{-mlzcnt} is used. 10572All of them generate the machine instruction that is part of the name. 10573@smallexample 10574unsigned short __builtin_ia32_lzcnt_16(unsigned short); 10575unsigned int __builtin_ia32_lzcnt_u32(unsigned int); 10576unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long); 10577@end smallexample 10578 10579The following built-in functions are available when @option{-mtbm} is used. 10580Both of them generate the immediate form of the bextr machine instruction. 10581@smallexample 10582unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int); 10583unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long); 10584@end smallexample 10585 10586 10587The following built-in functions are available when @option{-m3dnow} is used. 10588All of them generate the machine instruction that is part of the name. 10589 10590@smallexample 10591void __builtin_ia32_femms (void) 10592v8qi __builtin_ia32_pavgusb (v8qi, v8qi) 10593v2si __builtin_ia32_pf2id (v2sf) 10594v2sf __builtin_ia32_pfacc (v2sf, v2sf) 10595v2sf __builtin_ia32_pfadd (v2sf, v2sf) 10596v2si __builtin_ia32_pfcmpeq (v2sf, v2sf) 10597v2si __builtin_ia32_pfcmpge (v2sf, v2sf) 10598v2si __builtin_ia32_pfcmpgt (v2sf, v2sf) 10599v2sf __builtin_ia32_pfmax (v2sf, v2sf) 10600v2sf __builtin_ia32_pfmin (v2sf, v2sf) 10601v2sf __builtin_ia32_pfmul (v2sf, v2sf) 10602v2sf __builtin_ia32_pfrcp (v2sf) 10603v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf) 10604v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf) 10605v2sf __builtin_ia32_pfrsqrt (v2sf) 10606v2sf __builtin_ia32_pfrsqrtit1 (v2sf, v2sf) 10607v2sf __builtin_ia32_pfsub (v2sf, v2sf) 10608v2sf __builtin_ia32_pfsubr (v2sf, v2sf) 10609v2sf __builtin_ia32_pi2fd (v2si) 10610v4hi __builtin_ia32_pmulhrw (v4hi, v4hi) 10611@end smallexample 10612 10613The following built-in functions are available when both @option{-m3dnow} 10614and @option{-march=athlon} are used. All of them generate the machine 10615instruction that is part of the name. 10616 10617@smallexample 10618v2si __builtin_ia32_pf2iw (v2sf) 10619v2sf __builtin_ia32_pfnacc (v2sf, v2sf) 10620v2sf __builtin_ia32_pfpnacc (v2sf, v2sf) 10621v2sf __builtin_ia32_pi2fw (v2si) 10622v2sf __builtin_ia32_pswapdsf (v2sf) 10623v2si __builtin_ia32_pswapdsi (v2si) 10624@end smallexample 10625 10626@node MIPS DSP Built-in Functions 10627@subsection MIPS DSP Built-in Functions 10628 10629The MIPS DSP Application-Specific Extension (ASE) includes new 10630instructions that are designed to improve the performance of DSP and 10631media applications. It provides instructions that operate on packed 106328-bit/16-bit integer data, Q7, Q15 and Q31 fractional data. 10633 10634GCC supports MIPS DSP operations using both the generic 10635vector extensions (@pxref{Vector Extensions}) and a collection of 10636MIPS-specific built-in functions. Both kinds of support are 10637enabled by the @option{-mdsp} command-line option. 10638 10639Revision 2 of the ASE was introduced in the second half of 2006. 10640This revision adds extra instructions to the original ASE, but is 10641otherwise backwards-compatible with it. You can select revision 2 10642using the command-line option @option{-mdspr2}; this option implies 10643@option{-mdsp}. 10644 10645The SCOUNT and POS bits of the DSP control register are global. The 10646WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and 10647POS bits. During optimization, the compiler will not delete these 10648instructions and it will not delete calls to functions containing 10649these instructions. 10650 10651At present, GCC only provides support for operations on 32-bit 10652vectors. The vector type associated with 8-bit integer data is 10653usually called @code{v4i8}, the vector type associated with Q7 10654is usually called @code{v4q7}, the vector type associated with 16-bit 10655integer data is usually called @code{v2i16}, and the vector type 10656associated with Q15 is usually called @code{v2q15}. They can be 10657defined in C as follows: 10658 10659@smallexample 10660typedef signed char v4i8 __attribute__ ((vector_size(4))); 10661typedef signed char v4q7 __attribute__ ((vector_size(4))); 10662typedef short v2i16 __attribute__ ((vector_size(4))); 10663typedef short v2q15 __attribute__ ((vector_size(4))); 10664@end smallexample 10665 10666@code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are 10667initialized in the same way as aggregates. For example: 10668 10669@smallexample 10670v4i8 a = @{1, 2, 3, 4@}; 10671v4i8 b; 10672b = (v4i8) @{5, 6, 7, 8@}; 10673 10674v2q15 c = @{0x0fcb, 0x3a75@}; 10675v2q15 d; 10676d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@}; 10677@end smallexample 10678 10679@emph{Note:} The CPU's endianness determines the order in which values 10680are packed. On little-endian targets, the first value is the least 10681significant and the last value is the most significant. The opposite 10682order applies to big-endian targets. For example, the code above will 10683set the lowest byte of @code{a} to @code{1} on little-endian targets 10684and @code{4} on big-endian targets. 10685 10686@emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer 10687representation. As shown in this example, the integer representation 10688of a Q7 value can be obtained by multiplying the fractional value by 10689@code{0x1.0p7}. The equivalent for Q15 values is to multiply by 10690@code{0x1.0p15}. The equivalent for Q31 values is to multiply by 10691@code{0x1.0p31}. 10692 10693The table below lists the @code{v4i8} and @code{v2q15} operations for which 10694hardware support exists. @code{a} and @code{b} are @code{v4i8} values, 10695and @code{c} and @code{d} are @code{v2q15} values. 10696 10697@multitable @columnfractions .50 .50 10698@item C code @tab MIPS instruction 10699@item @code{a + b} @tab @code{addu.qb} 10700@item @code{c + d} @tab @code{addq.ph} 10701@item @code{a - b} @tab @code{subu.qb} 10702@item @code{c - d} @tab @code{subq.ph} 10703@end multitable 10704 10705The table below lists the @code{v2i16} operation for which 10706hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are 10707@code{v2i16} values. 10708 10709@multitable @columnfractions .50 .50 10710@item C code @tab MIPS instruction 10711@item @code{e * f} @tab @code{mul.ph} 10712@end multitable 10713 10714It is easier to describe the DSP built-in functions if we first define 10715the following types: 10716 10717@smallexample 10718typedef int q31; 10719typedef int i32; 10720typedef unsigned int ui32; 10721typedef long long a64; 10722@end smallexample 10723 10724@code{q31} and @code{i32} are actually the same as @code{int}, but we 10725use @code{q31} to indicate a Q31 fractional value and @code{i32} to 10726indicate a 32-bit integer value. Similarly, @code{a64} is the same as 10727@code{long long}, but we use @code{a64} to indicate values that will 10728be placed in one of the four DSP accumulators (@code{$ac0}, 10729@code{$ac1}, @code{$ac2} or @code{$ac3}). 10730 10731Also, some built-in functions prefer or require immediate numbers as 10732parameters, because the corresponding DSP instructions accept both immediate 10733numbers and register operands, or accept immediate numbers only. The 10734immediate parameters are listed as follows. 10735 10736@smallexample 10737imm0_3: 0 to 3. 10738imm0_7: 0 to 7. 10739imm0_15: 0 to 15. 10740imm0_31: 0 to 31. 10741imm0_63: 0 to 63. 10742imm0_255: 0 to 255. 10743imm_n32_31: -32 to 31. 10744imm_n512_511: -512 to 511. 10745@end smallexample 10746 10747The following built-in functions map directly to a particular MIPS DSP 10748instruction. Please refer to the architecture specification 10749for details on what each instruction does. 10750 10751@smallexample 10752v2q15 __builtin_mips_addq_ph (v2q15, v2q15) 10753v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15) 10754q31 __builtin_mips_addq_s_w (q31, q31) 10755v4i8 __builtin_mips_addu_qb (v4i8, v4i8) 10756v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8) 10757v2q15 __builtin_mips_subq_ph (v2q15, v2q15) 10758v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15) 10759q31 __builtin_mips_subq_s_w (q31, q31) 10760v4i8 __builtin_mips_subu_qb (v4i8, v4i8) 10761v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8) 10762i32 __builtin_mips_addsc (i32, i32) 10763i32 __builtin_mips_addwc (i32, i32) 10764i32 __builtin_mips_modsub (i32, i32) 10765i32 __builtin_mips_raddu_w_qb (v4i8) 10766v2q15 __builtin_mips_absq_s_ph (v2q15) 10767q31 __builtin_mips_absq_s_w (q31) 10768v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15) 10769v2q15 __builtin_mips_precrq_ph_w (q31, q31) 10770v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31) 10771v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15) 10772q31 __builtin_mips_preceq_w_phl (v2q15) 10773q31 __builtin_mips_preceq_w_phr (v2q15) 10774v2q15 __builtin_mips_precequ_ph_qbl (v4i8) 10775v2q15 __builtin_mips_precequ_ph_qbr (v4i8) 10776v2q15 __builtin_mips_precequ_ph_qbla (v4i8) 10777v2q15 __builtin_mips_precequ_ph_qbra (v4i8) 10778v2q15 __builtin_mips_preceu_ph_qbl (v4i8) 10779v2q15 __builtin_mips_preceu_ph_qbr (v4i8) 10780v2q15 __builtin_mips_preceu_ph_qbla (v4i8) 10781v2q15 __builtin_mips_preceu_ph_qbra (v4i8) 10782v4i8 __builtin_mips_shll_qb (v4i8, imm0_7) 10783v4i8 __builtin_mips_shll_qb (v4i8, i32) 10784v2q15 __builtin_mips_shll_ph (v2q15, imm0_15) 10785v2q15 __builtin_mips_shll_ph (v2q15, i32) 10786v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15) 10787v2q15 __builtin_mips_shll_s_ph (v2q15, i32) 10788q31 __builtin_mips_shll_s_w (q31, imm0_31) 10789q31 __builtin_mips_shll_s_w (q31, i32) 10790v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7) 10791v4i8 __builtin_mips_shrl_qb (v4i8, i32) 10792v2q15 __builtin_mips_shra_ph (v2q15, imm0_15) 10793v2q15 __builtin_mips_shra_ph (v2q15, i32) 10794v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15) 10795v2q15 __builtin_mips_shra_r_ph (v2q15, i32) 10796q31 __builtin_mips_shra_r_w (q31, imm0_31) 10797q31 __builtin_mips_shra_r_w (q31, i32) 10798v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15) 10799v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15) 10800v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15) 10801q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15) 10802q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15) 10803a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8) 10804a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8) 10805a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8) 10806a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8) 10807a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15) 10808a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31) 10809a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15) 10810a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31) 10811a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15) 10812a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15) 10813a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15) 10814a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15) 10815a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15) 10816i32 __builtin_mips_bitrev (i32) 10817i32 __builtin_mips_insv (i32, i32) 10818v4i8 __builtin_mips_repl_qb (imm0_255) 10819v4i8 __builtin_mips_repl_qb (i32) 10820v2q15 __builtin_mips_repl_ph (imm_n512_511) 10821v2q15 __builtin_mips_repl_ph (i32) 10822void __builtin_mips_cmpu_eq_qb (v4i8, v4i8) 10823void __builtin_mips_cmpu_lt_qb (v4i8, v4i8) 10824void __builtin_mips_cmpu_le_qb (v4i8, v4i8) 10825i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8) 10826i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8) 10827i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8) 10828void __builtin_mips_cmp_eq_ph (v2q15, v2q15) 10829void __builtin_mips_cmp_lt_ph (v2q15, v2q15) 10830void __builtin_mips_cmp_le_ph (v2q15, v2q15) 10831v4i8 __builtin_mips_pick_qb (v4i8, v4i8) 10832v2q15 __builtin_mips_pick_ph (v2q15, v2q15) 10833v2q15 __builtin_mips_packrl_ph (v2q15, v2q15) 10834i32 __builtin_mips_extr_w (a64, imm0_31) 10835i32 __builtin_mips_extr_w (a64, i32) 10836i32 __builtin_mips_extr_r_w (a64, imm0_31) 10837i32 __builtin_mips_extr_s_h (a64, i32) 10838i32 __builtin_mips_extr_rs_w (a64, imm0_31) 10839i32 __builtin_mips_extr_rs_w (a64, i32) 10840i32 __builtin_mips_extr_s_h (a64, imm0_31) 10841i32 __builtin_mips_extr_r_w (a64, i32) 10842i32 __builtin_mips_extp (a64, imm0_31) 10843i32 __builtin_mips_extp (a64, i32) 10844i32 __builtin_mips_extpdp (a64, imm0_31) 10845i32 __builtin_mips_extpdp (a64, i32) 10846a64 __builtin_mips_shilo (a64, imm_n32_31) 10847a64 __builtin_mips_shilo (a64, i32) 10848a64 __builtin_mips_mthlip (a64, i32) 10849void __builtin_mips_wrdsp (i32, imm0_63) 10850i32 __builtin_mips_rddsp (imm0_63) 10851i32 __builtin_mips_lbux (void *, i32) 10852i32 __builtin_mips_lhx (void *, i32) 10853i32 __builtin_mips_lwx (void *, i32) 10854a64 __builtin_mips_ldx (void *, i32) [MIPS64 only] 10855i32 __builtin_mips_bposge32 (void) 10856a64 __builtin_mips_madd (a64, i32, i32); 10857a64 __builtin_mips_maddu (a64, ui32, ui32); 10858a64 __builtin_mips_msub (a64, i32, i32); 10859a64 __builtin_mips_msubu (a64, ui32, ui32); 10860a64 __builtin_mips_mult (i32, i32); 10861a64 __builtin_mips_multu (ui32, ui32); 10862@end smallexample 10863 10864The following built-in functions map directly to a particular MIPS DSP REV 2 10865instruction. Please refer to the architecture specification 10866for details on what each instruction does. 10867 10868@smallexample 10869v4q7 __builtin_mips_absq_s_qb (v4q7); 10870v2i16 __builtin_mips_addu_ph (v2i16, v2i16); 10871v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16); 10872v4i8 __builtin_mips_adduh_qb (v4i8, v4i8); 10873v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8); 10874i32 __builtin_mips_append (i32, i32, imm0_31); 10875i32 __builtin_mips_balign (i32, i32, imm0_3); 10876i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8); 10877i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8); 10878i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8); 10879a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16); 10880a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16); 10881v2i16 __builtin_mips_mul_ph (v2i16, v2i16); 10882v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16); 10883q31 __builtin_mips_mulq_rs_w (q31, q31); 10884v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15); 10885q31 __builtin_mips_mulq_s_w (q31, q31); 10886a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16); 10887v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16); 10888v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31); 10889v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31); 10890i32 __builtin_mips_prepend (i32, i32, imm0_31); 10891v4i8 __builtin_mips_shra_qb (v4i8, imm0_7); 10892v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7); 10893v4i8 __builtin_mips_shra_qb (v4i8, i32); 10894v4i8 __builtin_mips_shra_r_qb (v4i8, i32); 10895v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15); 10896v2i16 __builtin_mips_shrl_ph (v2i16, i32); 10897v2i16 __builtin_mips_subu_ph (v2i16, v2i16); 10898v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16); 10899v4i8 __builtin_mips_subuh_qb (v4i8, v4i8); 10900v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8); 10901v2q15 __builtin_mips_addqh_ph (v2q15, v2q15); 10902v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15); 10903q31 __builtin_mips_addqh_w (q31, q31); 10904q31 __builtin_mips_addqh_r_w (q31, q31); 10905v2q15 __builtin_mips_subqh_ph (v2q15, v2q15); 10906v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15); 10907q31 __builtin_mips_subqh_w (q31, q31); 10908q31 __builtin_mips_subqh_r_w (q31, q31); 10909a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16); 10910a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16); 10911a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15); 10912a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15); 10913a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15); 10914a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15); 10915@end smallexample 10916 10917 10918@node MIPS Paired-Single Support 10919@subsection MIPS Paired-Single Support 10920 10921The MIPS64 architecture includes a number of instructions that 10922operate on pairs of single-precision floating-point values. 10923Each pair is packed into a 64-bit floating-point register, 10924with one element being designated the ``upper half'' and 10925the other being designated the ``lower half''. 10926 10927GCC supports paired-single operations using both the generic 10928vector extensions (@pxref{Vector Extensions}) and a collection of 10929MIPS-specific built-in functions. Both kinds of support are 10930enabled by the @option{-mpaired-single} command-line option. 10931 10932The vector type associated with paired-single values is usually 10933called @code{v2sf}. It can be defined in C as follows: 10934 10935@smallexample 10936typedef float v2sf __attribute__ ((vector_size (8))); 10937@end smallexample 10938 10939@code{v2sf} values are initialized in the same way as aggregates. 10940For example: 10941 10942@smallexample 10943v2sf a = @{1.5, 9.1@}; 10944v2sf b; 10945float e, f; 10946b = (v2sf) @{e, f@}; 10947@end smallexample 10948 10949@emph{Note:} The CPU's endianness determines which value is stored in 10950the upper half of a register and which value is stored in the lower half. 10951On little-endian targets, the first value is the lower one and the second 10952value is the upper one. The opposite order applies to big-endian targets. 10953For example, the code above will set the lower half of @code{a} to 10954@code{1.5} on little-endian targets and @code{9.1} on big-endian targets. 10955 10956@node MIPS Loongson Built-in Functions 10957@subsection MIPS Loongson Built-in Functions 10958 10959GCC provides intrinsics to access the SIMD instructions provided by the 10960ST Microelectronics Loongson-2E and -2F processors. These intrinsics, 10961available after inclusion of the @code{loongson.h} header file, 10962operate on the following 64-bit vector types: 10963 10964@itemize 10965@item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers; 10966@item @code{uint16x4_t}, a vector of four unsigned 16-bit integers; 10967@item @code{uint32x2_t}, a vector of two unsigned 32-bit integers; 10968@item @code{int8x8_t}, a vector of eight signed 8-bit integers; 10969@item @code{int16x4_t}, a vector of four signed 16-bit integers; 10970@item @code{int32x2_t}, a vector of two signed 32-bit integers. 10971@end itemize 10972 10973The intrinsics provided are listed below; each is named after the 10974machine instruction to which it corresponds, with suffixes added as 10975appropriate to distinguish intrinsics that expand to the same machine 10976instruction yet have different argument types. Refer to the architecture 10977documentation for a description of the functionality of each 10978instruction. 10979 10980@smallexample 10981int16x4_t packsswh (int32x2_t s, int32x2_t t); 10982int8x8_t packsshb (int16x4_t s, int16x4_t t); 10983uint8x8_t packushb (uint16x4_t s, uint16x4_t t); 10984uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t); 10985uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t); 10986uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t); 10987int32x2_t paddw_s (int32x2_t s, int32x2_t t); 10988int16x4_t paddh_s (int16x4_t s, int16x4_t t); 10989int8x8_t paddb_s (int8x8_t s, int8x8_t t); 10990uint64_t paddd_u (uint64_t s, uint64_t t); 10991int64_t paddd_s (int64_t s, int64_t t); 10992int16x4_t paddsh (int16x4_t s, int16x4_t t); 10993int8x8_t paddsb (int8x8_t s, int8x8_t t); 10994uint16x4_t paddush (uint16x4_t s, uint16x4_t t); 10995uint8x8_t paddusb (uint8x8_t s, uint8x8_t t); 10996uint64_t pandn_ud (uint64_t s, uint64_t t); 10997uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t); 10998uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t); 10999uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t); 11000int64_t pandn_sd (int64_t s, int64_t t); 11001int32x2_t pandn_sw (int32x2_t s, int32x2_t t); 11002int16x4_t pandn_sh (int16x4_t s, int16x4_t t); 11003int8x8_t pandn_sb (int8x8_t s, int8x8_t t); 11004uint16x4_t pavgh (uint16x4_t s, uint16x4_t t); 11005uint8x8_t pavgb (uint8x8_t s, uint8x8_t t); 11006uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t); 11007uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t); 11008uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t); 11009int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t); 11010int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t); 11011int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t); 11012uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t); 11013uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t); 11014uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t); 11015int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t); 11016int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t); 11017int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t); 11018uint16x4_t pextrh_u (uint16x4_t s, int field); 11019int16x4_t pextrh_s (int16x4_t s, int field); 11020uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t); 11021uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t); 11022uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t); 11023uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t); 11024int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t); 11025int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t); 11026int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t); 11027int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t); 11028int32x2_t pmaddhw (int16x4_t s, int16x4_t t); 11029int16x4_t pmaxsh (int16x4_t s, int16x4_t t); 11030uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t); 11031int16x4_t pminsh (int16x4_t s, int16x4_t t); 11032uint8x8_t pminub (uint8x8_t s, uint8x8_t t); 11033uint8x8_t pmovmskb_u (uint8x8_t s); 11034int8x8_t pmovmskb_s (int8x8_t s); 11035uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t); 11036int16x4_t pmulhh (int16x4_t s, int16x4_t t); 11037int16x4_t pmullh (int16x4_t s, int16x4_t t); 11038int64_t pmuluw (uint32x2_t s, uint32x2_t t); 11039uint8x8_t pasubub (uint8x8_t s, uint8x8_t t); 11040uint16x4_t biadd (uint8x8_t s); 11041uint16x4_t psadbh (uint8x8_t s, uint8x8_t t); 11042uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order); 11043int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order); 11044uint16x4_t psllh_u (uint16x4_t s, uint8_t amount); 11045int16x4_t psllh_s (int16x4_t s, uint8_t amount); 11046uint32x2_t psllw_u (uint32x2_t s, uint8_t amount); 11047int32x2_t psllw_s (int32x2_t s, uint8_t amount); 11048uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount); 11049int16x4_t psrlh_s (int16x4_t s, uint8_t amount); 11050uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount); 11051int32x2_t psrlw_s (int32x2_t s, uint8_t amount); 11052uint16x4_t psrah_u (uint16x4_t s, uint8_t amount); 11053int16x4_t psrah_s (int16x4_t s, uint8_t amount); 11054uint32x2_t psraw_u (uint32x2_t s, uint8_t amount); 11055int32x2_t psraw_s (int32x2_t s, uint8_t amount); 11056uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t); 11057uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t); 11058uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t); 11059int32x2_t psubw_s (int32x2_t s, int32x2_t t); 11060int16x4_t psubh_s (int16x4_t s, int16x4_t t); 11061int8x8_t psubb_s (int8x8_t s, int8x8_t t); 11062uint64_t psubd_u (uint64_t s, uint64_t t); 11063int64_t psubd_s (int64_t s, int64_t t); 11064int16x4_t psubsh (int16x4_t s, int16x4_t t); 11065int8x8_t psubsb (int8x8_t s, int8x8_t t); 11066uint16x4_t psubush (uint16x4_t s, uint16x4_t t); 11067uint8x8_t psubusb (uint8x8_t s, uint8x8_t t); 11068uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t); 11069uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t); 11070uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t); 11071int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t); 11072int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t); 11073int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t); 11074uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t); 11075uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t); 11076uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t); 11077int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t); 11078int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t); 11079int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t); 11080@end smallexample 11081 11082@menu 11083* Paired-Single Arithmetic:: 11084* Paired-Single Built-in Functions:: 11085* MIPS-3D Built-in Functions:: 11086@end menu 11087 11088@node Paired-Single Arithmetic 11089@subsubsection Paired-Single Arithmetic 11090 11091The table below lists the @code{v2sf} operations for which hardware 11092support exists. @code{a}, @code{b} and @code{c} are @code{v2sf} 11093values and @code{x} is an integral value. 11094 11095@multitable @columnfractions .50 .50 11096@item C code @tab MIPS instruction 11097@item @code{a + b} @tab @code{add.ps} 11098@item @code{a - b} @tab @code{sub.ps} 11099@item @code{-a} @tab @code{neg.ps} 11100@item @code{a * b} @tab @code{mul.ps} 11101@item @code{a * b + c} @tab @code{madd.ps} 11102@item @code{a * b - c} @tab @code{msub.ps} 11103@item @code{-(a * b + c)} @tab @code{nmadd.ps} 11104@item @code{-(a * b - c)} @tab @code{nmsub.ps} 11105@item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps} 11106@end multitable 11107 11108Note that the multiply-accumulate instructions can be disabled 11109using the command-line option @code{-mno-fused-madd}. 11110 11111@node Paired-Single Built-in Functions 11112@subsubsection Paired-Single Built-in Functions 11113 11114The following paired-single functions map directly to a particular 11115MIPS instruction. Please refer to the architecture specification 11116for details on what each instruction does. 11117 11118@table @code 11119@item v2sf __builtin_mips_pll_ps (v2sf, v2sf) 11120Pair lower lower (@code{pll.ps}). 11121 11122@item v2sf __builtin_mips_pul_ps (v2sf, v2sf) 11123Pair upper lower (@code{pul.ps}). 11124 11125@item v2sf __builtin_mips_plu_ps (v2sf, v2sf) 11126Pair lower upper (@code{plu.ps}). 11127 11128@item v2sf __builtin_mips_puu_ps (v2sf, v2sf) 11129Pair upper upper (@code{puu.ps}). 11130 11131@item v2sf __builtin_mips_cvt_ps_s (float, float) 11132Convert pair to paired single (@code{cvt.ps.s}). 11133 11134@item float __builtin_mips_cvt_s_pl (v2sf) 11135Convert pair lower to single (@code{cvt.s.pl}). 11136 11137@item float __builtin_mips_cvt_s_pu (v2sf) 11138Convert pair upper to single (@code{cvt.s.pu}). 11139 11140@item v2sf __builtin_mips_abs_ps (v2sf) 11141Absolute value (@code{abs.ps}). 11142 11143@item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int) 11144Align variable (@code{alnv.ps}). 11145 11146@emph{Note:} The value of the third parameter must be 0 or 4 11147modulo 8, otherwise the result will be unpredictable. Please read the 11148instruction description for details. 11149@end table 11150 11151The following multi-instruction functions are also available. 11152In each case, @var{cond} can be any of the 16 floating-point conditions: 11153@code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult}, 11154@code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl}, 11155@code{lt}, @code{nge}, @code{le} or @code{ngt}. 11156 11157@table @code 11158@item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 11159@itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 11160Conditional move based on floating point comparison (@code{c.@var{cond}.ps}, 11161@code{movt.ps}/@code{movf.ps}). 11162 11163The @code{movt} functions return the value @var{x} computed by: 11164 11165@smallexample 11166c.@var{cond}.ps @var{cc},@var{a},@var{b} 11167mov.ps @var{x},@var{c} 11168movt.ps @var{x},@var{d},@var{cc} 11169@end smallexample 11170 11171The @code{movf} functions are similar but use @code{movf.ps} instead 11172of @code{movt.ps}. 11173 11174@item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 11175@itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 11176Comparison of two paired-single values (@code{c.@var{cond}.ps}, 11177@code{bc1t}/@code{bc1f}). 11178 11179These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps} 11180and return either the upper or lower half of the result. For example: 11181 11182@smallexample 11183v2sf a, b; 11184if (__builtin_mips_upper_c_eq_ps (a, b)) 11185 upper_halves_are_equal (); 11186else 11187 upper_halves_are_unequal (); 11188 11189if (__builtin_mips_lower_c_eq_ps (a, b)) 11190 lower_halves_are_equal (); 11191else 11192 lower_halves_are_unequal (); 11193@end smallexample 11194@end table 11195 11196@node MIPS-3D Built-in Functions 11197@subsubsection MIPS-3D Built-in Functions 11198 11199The MIPS-3D Application-Specific Extension (ASE) includes additional 11200paired-single instructions that are designed to improve the performance 11201of 3D graphics operations. Support for these instructions is controlled 11202by the @option{-mips3d} command-line option. 11203 11204The functions listed below map directly to a particular MIPS-3D 11205instruction. Please refer to the architecture specification for 11206more details on what each instruction does. 11207 11208@table @code 11209@item v2sf __builtin_mips_addr_ps (v2sf, v2sf) 11210Reduction add (@code{addr.ps}). 11211 11212@item v2sf __builtin_mips_mulr_ps (v2sf, v2sf) 11213Reduction multiply (@code{mulr.ps}). 11214 11215@item v2sf __builtin_mips_cvt_pw_ps (v2sf) 11216Convert paired single to paired word (@code{cvt.pw.ps}). 11217 11218@item v2sf __builtin_mips_cvt_ps_pw (v2sf) 11219Convert paired word to paired single (@code{cvt.ps.pw}). 11220 11221@item float __builtin_mips_recip1_s (float) 11222@itemx double __builtin_mips_recip1_d (double) 11223@itemx v2sf __builtin_mips_recip1_ps (v2sf) 11224Reduced precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}). 11225 11226@item float __builtin_mips_recip2_s (float, float) 11227@itemx double __builtin_mips_recip2_d (double, double) 11228@itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf) 11229Reduced precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}). 11230 11231@item float __builtin_mips_rsqrt1_s (float) 11232@itemx double __builtin_mips_rsqrt1_d (double) 11233@itemx v2sf __builtin_mips_rsqrt1_ps (v2sf) 11234Reduced precision reciprocal square root (sequence step 1) 11235(@code{rsqrt1.@var{fmt}}). 11236 11237@item float __builtin_mips_rsqrt2_s (float, float) 11238@itemx double __builtin_mips_rsqrt2_d (double, double) 11239@itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf) 11240Reduced precision reciprocal square root (sequence step 2) 11241(@code{rsqrt2.@var{fmt}}). 11242@end table 11243 11244The following multi-instruction functions are also available. 11245In each case, @var{cond} can be any of the 16 floating-point conditions: 11246@code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult}, 11247@code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, 11248@code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}. 11249 11250@table @code 11251@item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b}) 11252@itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b}) 11253Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}}, 11254@code{bc1t}/@code{bc1f}). 11255 11256These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s} 11257or @code{cabs.@var{cond}.d} and return the result as a boolean value. 11258For example: 11259 11260@smallexample 11261float a, b; 11262if (__builtin_mips_cabs_eq_s (a, b)) 11263 true (); 11264else 11265 false (); 11266@end smallexample 11267 11268@item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 11269@itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 11270Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps}, 11271@code{bc1t}/@code{bc1f}). 11272 11273These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps} 11274and return either the upper or lower half of the result. For example: 11275 11276@smallexample 11277v2sf a, b; 11278if (__builtin_mips_upper_cabs_eq_ps (a, b)) 11279 upper_halves_are_equal (); 11280else 11281 upper_halves_are_unequal (); 11282 11283if (__builtin_mips_lower_cabs_eq_ps (a, b)) 11284 lower_halves_are_equal (); 11285else 11286 lower_halves_are_unequal (); 11287@end smallexample 11288 11289@item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 11290@itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 11291Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps}, 11292@code{movt.ps}/@code{movf.ps}). 11293 11294The @code{movt} functions return the value @var{x} computed by: 11295 11296@smallexample 11297cabs.@var{cond}.ps @var{cc},@var{a},@var{b} 11298mov.ps @var{x},@var{c} 11299movt.ps @var{x},@var{d},@var{cc} 11300@end smallexample 11301 11302The @code{movf} functions are similar but use @code{movf.ps} instead 11303of @code{movt.ps}. 11304 11305@item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 11306@itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 11307@itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 11308@itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 11309Comparison of two paired-single values 11310(@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps}, 11311@code{bc1any2t}/@code{bc1any2f}). 11312 11313These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps} 11314or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either 11315result is true and the @code{all} forms return true if both results are true. 11316For example: 11317 11318@smallexample 11319v2sf a, b; 11320if (__builtin_mips_any_c_eq_ps (a, b)) 11321 one_is_true (); 11322else 11323 both_are_false (); 11324 11325if (__builtin_mips_all_c_eq_ps (a, b)) 11326 both_are_true (); 11327else 11328 one_is_false (); 11329@end smallexample 11330 11331@item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 11332@itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 11333@itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 11334@itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 11335Comparison of four paired-single values 11336(@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps}, 11337@code{bc1any4t}/@code{bc1any4f}). 11338 11339These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps} 11340to compare @var{a} with @var{b} and to compare @var{c} with @var{d}. 11341The @code{any} forms return true if any of the four results are true 11342and the @code{all} forms return true if all four results are true. 11343For example: 11344 11345@smallexample 11346v2sf a, b, c, d; 11347if (__builtin_mips_any_c_eq_4s (a, b, c, d)) 11348 some_are_true (); 11349else 11350 all_are_false (); 11351 11352if (__builtin_mips_all_c_eq_4s (a, b, c, d)) 11353 all_are_true (); 11354else 11355 some_are_false (); 11356@end smallexample 11357@end table 11358 11359@node picoChip Built-in Functions 11360@subsection picoChip Built-in Functions 11361 11362GCC provides an interface to selected machine instructions from the 11363picoChip instruction set. 11364 11365@table @code 11366@item int __builtin_sbc (int @var{value}) 11367Sign bit count. Return the number of consecutive bits in @var{value} 11368which have the same value as the sign-bit. The result is the number of 11369leading sign bits minus one, giving the number of redundant sign bits in 11370@var{value}. 11371 11372@item int __builtin_byteswap (int @var{value}) 11373Byte swap. Return the result of swapping the upper and lower bytes of 11374@var{value}. 11375 11376@item int __builtin_brev (int @var{value}) 11377Bit reversal. Return the result of reversing the bits in 11378@var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1, 11379and so on. 11380 11381@item int __builtin_adds (int @var{x}, int @var{y}) 11382Saturating addition. Return the result of adding @var{x} and @var{y}, 11383storing the value 32767 if the result overflows. 11384 11385@item int __builtin_subs (int @var{x}, int @var{y}) 11386Saturating subtraction. Return the result of subtracting @var{y} from 11387@var{x}, storing the value @minus{}32768 if the result overflows. 11388 11389@item void __builtin_halt (void) 11390Halt. The processor will stop execution. This built-in is useful for 11391implementing assertions. 11392 11393@end table 11394 11395@node Other MIPS Built-in Functions 11396@subsection Other MIPS Built-in Functions 11397 11398GCC provides other MIPS-specific built-in functions: 11399 11400@table @code 11401@item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr}) 11402Insert a @samp{cache} instruction with operands @var{op} and @var{addr}. 11403GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE} 11404when this function is available. 11405@end table 11406 11407@node PowerPC AltiVec/VSX Built-in Functions 11408@subsection PowerPC AltiVec Built-in Functions 11409 11410GCC provides an interface for the PowerPC family of processors to access 11411the AltiVec operations described in Motorola's AltiVec Programming 11412Interface Manual. The interface is made available by including 11413@code{<altivec.h>} and using @option{-maltivec} and 11414@option{-mabi=altivec}. The interface supports the following vector 11415types. 11416 11417@smallexample 11418vector unsigned char 11419vector signed char 11420vector bool char 11421 11422vector unsigned short 11423vector signed short 11424vector bool short 11425vector pixel 11426 11427vector unsigned int 11428vector signed int 11429vector bool int 11430vector float 11431@end smallexample 11432 11433If @option{-mvsx} is used the following additional vector types are 11434implemented. 11435 11436@smallexample 11437vector unsigned long 11438vector signed long 11439vector double 11440@end smallexample 11441 11442The long types are only implemented for 64-bit code generation, and 11443the long type is only used in the floating point/integer conversion 11444instructions. 11445 11446GCC's implementation of the high-level language interface available from 11447C and C++ code differs from Motorola's documentation in several ways. 11448 11449@itemize @bullet 11450 11451@item 11452A vector constant is a list of constant expressions within curly braces. 11453 11454@item 11455A vector initializer requires no cast if the vector constant is of the 11456same type as the variable it is initializing. 11457 11458@item 11459If @code{signed} or @code{unsigned} is omitted, the signedness of the 11460vector type is the default signedness of the base type. The default 11461varies depending on the operating system, so a portable program should 11462always specify the signedness. 11463 11464@item 11465Compiling with @option{-maltivec} adds keywords @code{__vector}, 11466@code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and 11467@code{bool}. When compiling ISO C, the context-sensitive substitution 11468of the keywords @code{vector}, @code{pixel} and @code{bool} is 11469disabled. To use them, you must include @code{<altivec.h>} instead. 11470 11471@item 11472GCC allows using a @code{typedef} name as the type specifier for a 11473vector type. 11474 11475@item 11476For C, overloaded functions are implemented with macros so the following 11477does not work: 11478 11479@smallexample 11480 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo); 11481@end smallexample 11482 11483Since @code{vec_add} is a macro, the vector constant in the example 11484is treated as four separate arguments. Wrap the entire argument in 11485parentheses for this to work. 11486@end itemize 11487 11488@emph{Note:} Only the @code{<altivec.h>} interface is supported. 11489Internally, GCC uses built-in functions to achieve the functionality in 11490the aforementioned header file, but they are not supported and are 11491subject to change without notice. 11492 11493The following interfaces are supported for the generic and specific 11494AltiVec operations and the AltiVec predicates. In cases where there 11495is a direct mapping between generic and specific operations, only the 11496generic names are shown here, although the specific operations can also 11497be used. 11498 11499Arguments that are documented as @code{const int} require literal 11500integral values within the range required for that operation. 11501 11502@smallexample 11503vector signed char vec_abs (vector signed char); 11504vector signed short vec_abs (vector signed short); 11505vector signed int vec_abs (vector signed int); 11506vector float vec_abs (vector float); 11507 11508vector signed char vec_abss (vector signed char); 11509vector signed short vec_abss (vector signed short); 11510vector signed int vec_abss (vector signed int); 11511 11512vector signed char vec_add (vector bool char, vector signed char); 11513vector signed char vec_add (vector signed char, vector bool char); 11514vector signed char vec_add (vector signed char, vector signed char); 11515vector unsigned char vec_add (vector bool char, vector unsigned char); 11516vector unsigned char vec_add (vector unsigned char, vector bool char); 11517vector unsigned char vec_add (vector unsigned char, 11518 vector unsigned char); 11519vector signed short vec_add (vector bool short, vector signed short); 11520vector signed short vec_add (vector signed short, vector bool short); 11521vector signed short vec_add (vector signed short, vector signed short); 11522vector unsigned short vec_add (vector bool short, 11523 vector unsigned short); 11524vector unsigned short vec_add (vector unsigned short, 11525 vector bool short); 11526vector unsigned short vec_add (vector unsigned short, 11527 vector unsigned short); 11528vector signed int vec_add (vector bool int, vector signed int); 11529vector signed int vec_add (vector signed int, vector bool int); 11530vector signed int vec_add (vector signed int, vector signed int); 11531vector unsigned int vec_add (vector bool int, vector unsigned int); 11532vector unsigned int vec_add (vector unsigned int, vector bool int); 11533vector unsigned int vec_add (vector unsigned int, vector unsigned int); 11534vector float vec_add (vector float, vector float); 11535 11536vector float vec_vaddfp (vector float, vector float); 11537 11538vector signed int vec_vadduwm (vector bool int, vector signed int); 11539vector signed int vec_vadduwm (vector signed int, vector bool int); 11540vector signed int vec_vadduwm (vector signed int, vector signed int); 11541vector unsigned int vec_vadduwm (vector bool int, vector unsigned int); 11542vector unsigned int vec_vadduwm (vector unsigned int, vector bool int); 11543vector unsigned int vec_vadduwm (vector unsigned int, 11544 vector unsigned int); 11545 11546vector signed short vec_vadduhm (vector bool short, 11547 vector signed short); 11548vector signed short vec_vadduhm (vector signed short, 11549 vector bool short); 11550vector signed short vec_vadduhm (vector signed short, 11551 vector signed short); 11552vector unsigned short vec_vadduhm (vector bool short, 11553 vector unsigned short); 11554vector unsigned short vec_vadduhm (vector unsigned short, 11555 vector bool short); 11556vector unsigned short vec_vadduhm (vector unsigned short, 11557 vector unsigned short); 11558 11559vector signed char vec_vaddubm (vector bool char, vector signed char); 11560vector signed char vec_vaddubm (vector signed char, vector bool char); 11561vector signed char vec_vaddubm (vector signed char, vector signed char); 11562vector unsigned char vec_vaddubm (vector bool char, 11563 vector unsigned char); 11564vector unsigned char vec_vaddubm (vector unsigned char, 11565 vector bool char); 11566vector unsigned char vec_vaddubm (vector unsigned char, 11567 vector unsigned char); 11568 11569vector unsigned int vec_addc (vector unsigned int, vector unsigned int); 11570 11571vector unsigned char vec_adds (vector bool char, vector unsigned char); 11572vector unsigned char vec_adds (vector unsigned char, vector bool char); 11573vector unsigned char vec_adds (vector unsigned char, 11574 vector unsigned char); 11575vector signed char vec_adds (vector bool char, vector signed char); 11576vector signed char vec_adds (vector signed char, vector bool char); 11577vector signed char vec_adds (vector signed char, vector signed char); 11578vector unsigned short vec_adds (vector bool short, 11579 vector unsigned short); 11580vector unsigned short vec_adds (vector unsigned short, 11581 vector bool short); 11582vector unsigned short vec_adds (vector unsigned short, 11583 vector unsigned short); 11584vector signed short vec_adds (vector bool short, vector signed short); 11585vector signed short vec_adds (vector signed short, vector bool short); 11586vector signed short vec_adds (vector signed short, vector signed short); 11587vector unsigned int vec_adds (vector bool int, vector unsigned int); 11588vector unsigned int vec_adds (vector unsigned int, vector bool int); 11589vector unsigned int vec_adds (vector unsigned int, vector unsigned int); 11590vector signed int vec_adds (vector bool int, vector signed int); 11591vector signed int vec_adds (vector signed int, vector bool int); 11592vector signed int vec_adds (vector signed int, vector signed int); 11593 11594vector signed int vec_vaddsws (vector bool int, vector signed int); 11595vector signed int vec_vaddsws (vector signed int, vector bool int); 11596vector signed int vec_vaddsws (vector signed int, vector signed int); 11597 11598vector unsigned int vec_vadduws (vector bool int, vector unsigned int); 11599vector unsigned int vec_vadduws (vector unsigned int, vector bool int); 11600vector unsigned int vec_vadduws (vector unsigned int, 11601 vector unsigned int); 11602 11603vector signed short vec_vaddshs (vector bool short, 11604 vector signed short); 11605vector signed short vec_vaddshs (vector signed short, 11606 vector bool short); 11607vector signed short vec_vaddshs (vector signed short, 11608 vector signed short); 11609 11610vector unsigned short vec_vadduhs (vector bool short, 11611 vector unsigned short); 11612vector unsigned short vec_vadduhs (vector unsigned short, 11613 vector bool short); 11614vector unsigned short vec_vadduhs (vector unsigned short, 11615 vector unsigned short); 11616 11617vector signed char vec_vaddsbs (vector bool char, vector signed char); 11618vector signed char vec_vaddsbs (vector signed char, vector bool char); 11619vector signed char vec_vaddsbs (vector signed char, vector signed char); 11620 11621vector unsigned char vec_vaddubs (vector bool char, 11622 vector unsigned char); 11623vector unsigned char vec_vaddubs (vector unsigned char, 11624 vector bool char); 11625vector unsigned char vec_vaddubs (vector unsigned char, 11626 vector unsigned char); 11627 11628vector float vec_and (vector float, vector float); 11629vector float vec_and (vector float, vector bool int); 11630vector float vec_and (vector bool int, vector float); 11631vector bool int vec_and (vector bool int, vector bool int); 11632vector signed int vec_and (vector bool int, vector signed int); 11633vector signed int vec_and (vector signed int, vector bool int); 11634vector signed int vec_and (vector signed int, vector signed int); 11635vector unsigned int vec_and (vector bool int, vector unsigned int); 11636vector unsigned int vec_and (vector unsigned int, vector bool int); 11637vector unsigned int vec_and (vector unsigned int, vector unsigned int); 11638vector bool short vec_and (vector bool short, vector bool short); 11639vector signed short vec_and (vector bool short, vector signed short); 11640vector signed short vec_and (vector signed short, vector bool short); 11641vector signed short vec_and (vector signed short, vector signed short); 11642vector unsigned short vec_and (vector bool short, 11643 vector unsigned short); 11644vector unsigned short vec_and (vector unsigned short, 11645 vector bool short); 11646vector unsigned short vec_and (vector unsigned short, 11647 vector unsigned short); 11648vector signed char vec_and (vector bool char, vector signed char); 11649vector bool char vec_and (vector bool char, vector bool char); 11650vector signed char vec_and (vector signed char, vector bool char); 11651vector signed char vec_and (vector signed char, vector signed char); 11652vector unsigned char vec_and (vector bool char, vector unsigned char); 11653vector unsigned char vec_and (vector unsigned char, vector bool char); 11654vector unsigned char vec_and (vector unsigned char, 11655 vector unsigned char); 11656 11657vector float vec_andc (vector float, vector float); 11658vector float vec_andc (vector float, vector bool int); 11659vector float vec_andc (vector bool int, vector float); 11660vector bool int vec_andc (vector bool int, vector bool int); 11661vector signed int vec_andc (vector bool int, vector signed int); 11662vector signed int vec_andc (vector signed int, vector bool int); 11663vector signed int vec_andc (vector signed int, vector signed int); 11664vector unsigned int vec_andc (vector bool int, vector unsigned int); 11665vector unsigned int vec_andc (vector unsigned int, vector bool int); 11666vector unsigned int vec_andc (vector unsigned int, vector unsigned int); 11667vector bool short vec_andc (vector bool short, vector bool short); 11668vector signed short vec_andc (vector bool short, vector signed short); 11669vector signed short vec_andc (vector signed short, vector bool short); 11670vector signed short vec_andc (vector signed short, vector signed short); 11671vector unsigned short vec_andc (vector bool short, 11672 vector unsigned short); 11673vector unsigned short vec_andc (vector unsigned short, 11674 vector bool short); 11675vector unsigned short vec_andc (vector unsigned short, 11676 vector unsigned short); 11677vector signed char vec_andc (vector bool char, vector signed char); 11678vector bool char vec_andc (vector bool char, vector bool char); 11679vector signed char vec_andc (vector signed char, vector bool char); 11680vector signed char vec_andc (vector signed char, vector signed char); 11681vector unsigned char vec_andc (vector bool char, vector unsigned char); 11682vector unsigned char vec_andc (vector unsigned char, vector bool char); 11683vector unsigned char vec_andc (vector unsigned char, 11684 vector unsigned char); 11685 11686vector unsigned char vec_avg (vector unsigned char, 11687 vector unsigned char); 11688vector signed char vec_avg (vector signed char, vector signed char); 11689vector unsigned short vec_avg (vector unsigned short, 11690 vector unsigned short); 11691vector signed short vec_avg (vector signed short, vector signed short); 11692vector unsigned int vec_avg (vector unsigned int, vector unsigned int); 11693vector signed int vec_avg (vector signed int, vector signed int); 11694 11695vector signed int vec_vavgsw (vector signed int, vector signed int); 11696 11697vector unsigned int vec_vavguw (vector unsigned int, 11698 vector unsigned int); 11699 11700vector signed short vec_vavgsh (vector signed short, 11701 vector signed short); 11702 11703vector unsigned short vec_vavguh (vector unsigned short, 11704 vector unsigned short); 11705 11706vector signed char vec_vavgsb (vector signed char, vector signed char); 11707 11708vector unsigned char vec_vavgub (vector unsigned char, 11709 vector unsigned char); 11710 11711vector float vec_copysign (vector float); 11712 11713vector float vec_ceil (vector float); 11714 11715vector signed int vec_cmpb (vector float, vector float); 11716 11717vector bool char vec_cmpeq (vector signed char, vector signed char); 11718vector bool char vec_cmpeq (vector unsigned char, vector unsigned char); 11719vector bool short vec_cmpeq (vector signed short, vector signed short); 11720vector bool short vec_cmpeq (vector unsigned short, 11721 vector unsigned short); 11722vector bool int vec_cmpeq (vector signed int, vector signed int); 11723vector bool int vec_cmpeq (vector unsigned int, vector unsigned int); 11724vector bool int vec_cmpeq (vector float, vector float); 11725 11726vector bool int vec_vcmpeqfp (vector float, vector float); 11727 11728vector bool int vec_vcmpequw (vector signed int, vector signed int); 11729vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int); 11730 11731vector bool short vec_vcmpequh (vector signed short, 11732 vector signed short); 11733vector bool short vec_vcmpequh (vector unsigned short, 11734 vector unsigned short); 11735 11736vector bool char vec_vcmpequb (vector signed char, vector signed char); 11737vector bool char vec_vcmpequb (vector unsigned char, 11738 vector unsigned char); 11739 11740vector bool int vec_cmpge (vector float, vector float); 11741 11742vector bool char vec_cmpgt (vector unsigned char, vector unsigned char); 11743vector bool char vec_cmpgt (vector signed char, vector signed char); 11744vector bool short vec_cmpgt (vector unsigned short, 11745 vector unsigned short); 11746vector bool short vec_cmpgt (vector signed short, vector signed short); 11747vector bool int vec_cmpgt (vector unsigned int, vector unsigned int); 11748vector bool int vec_cmpgt (vector signed int, vector signed int); 11749vector bool int vec_cmpgt (vector float, vector float); 11750 11751vector bool int vec_vcmpgtfp (vector float, vector float); 11752 11753vector bool int vec_vcmpgtsw (vector signed int, vector signed int); 11754 11755vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int); 11756 11757vector bool short vec_vcmpgtsh (vector signed short, 11758 vector signed short); 11759 11760vector bool short vec_vcmpgtuh (vector unsigned short, 11761 vector unsigned short); 11762 11763vector bool char vec_vcmpgtsb (vector signed char, vector signed char); 11764 11765vector bool char vec_vcmpgtub (vector unsigned char, 11766 vector unsigned char); 11767 11768vector bool int vec_cmple (vector float, vector float); 11769 11770vector bool char vec_cmplt (vector unsigned char, vector unsigned char); 11771vector bool char vec_cmplt (vector signed char, vector signed char); 11772vector bool short vec_cmplt (vector unsigned short, 11773 vector unsigned short); 11774vector bool short vec_cmplt (vector signed short, vector signed short); 11775vector bool int vec_cmplt (vector unsigned int, vector unsigned int); 11776vector bool int vec_cmplt (vector signed int, vector signed int); 11777vector bool int vec_cmplt (vector float, vector float); 11778 11779vector float vec_ctf (vector unsigned int, const int); 11780vector float vec_ctf (vector signed int, const int); 11781 11782vector float vec_vcfsx (vector signed int, const int); 11783 11784vector float vec_vcfux (vector unsigned int, const int); 11785 11786vector signed int vec_cts (vector float, const int); 11787 11788vector unsigned int vec_ctu (vector float, const int); 11789 11790void vec_dss (const int); 11791 11792void vec_dssall (void); 11793 11794void vec_dst (const vector unsigned char *, int, const int); 11795void vec_dst (const vector signed char *, int, const int); 11796void vec_dst (const vector bool char *, int, const int); 11797void vec_dst (const vector unsigned short *, int, const int); 11798void vec_dst (const vector signed short *, int, const int); 11799void vec_dst (const vector bool short *, int, const int); 11800void vec_dst (const vector pixel *, int, const int); 11801void vec_dst (const vector unsigned int *, int, const int); 11802void vec_dst (const vector signed int *, int, const int); 11803void vec_dst (const vector bool int *, int, const int); 11804void vec_dst (const vector float *, int, const int); 11805void vec_dst (const unsigned char *, int, const int); 11806void vec_dst (const signed char *, int, const int); 11807void vec_dst (const unsigned short *, int, const int); 11808void vec_dst (const short *, int, const int); 11809void vec_dst (const unsigned int *, int, const int); 11810void vec_dst (const int *, int, const int); 11811void vec_dst (const unsigned long *, int, const int); 11812void vec_dst (const long *, int, const int); 11813void vec_dst (const float *, int, const int); 11814 11815void vec_dstst (const vector unsigned char *, int, const int); 11816void vec_dstst (const vector signed char *, int, const int); 11817void vec_dstst (const vector bool char *, int, const int); 11818void vec_dstst (const vector unsigned short *, int, const int); 11819void vec_dstst (const vector signed short *, int, const int); 11820void vec_dstst (const vector bool short *, int, const int); 11821void vec_dstst (const vector pixel *, int, const int); 11822void vec_dstst (const vector unsigned int *, int, const int); 11823void vec_dstst (const vector signed int *, int, const int); 11824void vec_dstst (const vector bool int *, int, const int); 11825void vec_dstst (const vector float *, int, const int); 11826void vec_dstst (const unsigned char *, int, const int); 11827void vec_dstst (const signed char *, int, const int); 11828void vec_dstst (const unsigned short *, int, const int); 11829void vec_dstst (const short *, int, const int); 11830void vec_dstst (const unsigned int *, int, const int); 11831void vec_dstst (const int *, int, const int); 11832void vec_dstst (const unsigned long *, int, const int); 11833void vec_dstst (const long *, int, const int); 11834void vec_dstst (const float *, int, const int); 11835 11836void vec_dststt (const vector unsigned char *, int, const int); 11837void vec_dststt (const vector signed char *, int, const int); 11838void vec_dststt (const vector bool char *, int, const int); 11839void vec_dststt (const vector unsigned short *, int, const int); 11840void vec_dststt (const vector signed short *, int, const int); 11841void vec_dststt (const vector bool short *, int, const int); 11842void vec_dststt (const vector pixel *, int, const int); 11843void vec_dststt (const vector unsigned int *, int, const int); 11844void vec_dststt (const vector signed int *, int, const int); 11845void vec_dststt (const vector bool int *, int, const int); 11846void vec_dststt (const vector float *, int, const int); 11847void vec_dststt (const unsigned char *, int, const int); 11848void vec_dststt (const signed char *, int, const int); 11849void vec_dststt (const unsigned short *, int, const int); 11850void vec_dststt (const short *, int, const int); 11851void vec_dststt (const unsigned int *, int, const int); 11852void vec_dststt (const int *, int, const int); 11853void vec_dststt (const unsigned long *, int, const int); 11854void vec_dststt (const long *, int, const int); 11855void vec_dststt (const float *, int, const int); 11856 11857void vec_dstt (const vector unsigned char *, int, const int); 11858void vec_dstt (const vector signed char *, int, const int); 11859void vec_dstt (const vector bool char *, int, const int); 11860void vec_dstt (const vector unsigned short *, int, const int); 11861void vec_dstt (const vector signed short *, int, const int); 11862void vec_dstt (const vector bool short *, int, const int); 11863void vec_dstt (const vector pixel *, int, const int); 11864void vec_dstt (const vector unsigned int *, int, const int); 11865void vec_dstt (const vector signed int *, int, const int); 11866void vec_dstt (const vector bool int *, int, const int); 11867void vec_dstt (const vector float *, int, const int); 11868void vec_dstt (const unsigned char *, int, const int); 11869void vec_dstt (const signed char *, int, const int); 11870void vec_dstt (const unsigned short *, int, const int); 11871void vec_dstt (const short *, int, const int); 11872void vec_dstt (const unsigned int *, int, const int); 11873void vec_dstt (const int *, int, const int); 11874void vec_dstt (const unsigned long *, int, const int); 11875void vec_dstt (const long *, int, const int); 11876void vec_dstt (const float *, int, const int); 11877 11878vector float vec_expte (vector float); 11879 11880vector float vec_floor (vector float); 11881 11882vector float vec_ld (int, const vector float *); 11883vector float vec_ld (int, const float *); 11884vector bool int vec_ld (int, const vector bool int *); 11885vector signed int vec_ld (int, const vector signed int *); 11886vector signed int vec_ld (int, const int *); 11887vector signed int vec_ld (int, const long *); 11888vector unsigned int vec_ld (int, const vector unsigned int *); 11889vector unsigned int vec_ld (int, const unsigned int *); 11890vector unsigned int vec_ld (int, const unsigned long *); 11891vector bool short vec_ld (int, const vector bool short *); 11892vector pixel vec_ld (int, const vector pixel *); 11893vector signed short vec_ld (int, const vector signed short *); 11894vector signed short vec_ld (int, const short *); 11895vector unsigned short vec_ld (int, const vector unsigned short *); 11896vector unsigned short vec_ld (int, const unsigned short *); 11897vector bool char vec_ld (int, const vector bool char *); 11898vector signed char vec_ld (int, const vector signed char *); 11899vector signed char vec_ld (int, const signed char *); 11900vector unsigned char vec_ld (int, const vector unsigned char *); 11901vector unsigned char vec_ld (int, const unsigned char *); 11902 11903vector signed char vec_lde (int, const signed char *); 11904vector unsigned char vec_lde (int, const unsigned char *); 11905vector signed short vec_lde (int, const short *); 11906vector unsigned short vec_lde (int, const unsigned short *); 11907vector float vec_lde (int, const float *); 11908vector signed int vec_lde (int, const int *); 11909vector unsigned int vec_lde (int, const unsigned int *); 11910vector signed int vec_lde (int, const long *); 11911vector unsigned int vec_lde (int, const unsigned long *); 11912 11913vector float vec_lvewx (int, float *); 11914vector signed int vec_lvewx (int, int *); 11915vector unsigned int vec_lvewx (int, unsigned int *); 11916vector signed int vec_lvewx (int, long *); 11917vector unsigned int vec_lvewx (int, unsigned long *); 11918 11919vector signed short vec_lvehx (int, short *); 11920vector unsigned short vec_lvehx (int, unsigned short *); 11921 11922vector signed char vec_lvebx (int, char *); 11923vector unsigned char vec_lvebx (int, unsigned char *); 11924 11925vector float vec_ldl (int, const vector float *); 11926vector float vec_ldl (int, const float *); 11927vector bool int vec_ldl (int, const vector bool int *); 11928vector signed int vec_ldl (int, const vector signed int *); 11929vector signed int vec_ldl (int, const int *); 11930vector signed int vec_ldl (int, const long *); 11931vector unsigned int vec_ldl (int, const vector unsigned int *); 11932vector unsigned int vec_ldl (int, const unsigned int *); 11933vector unsigned int vec_ldl (int, const unsigned long *); 11934vector bool short vec_ldl (int, const vector bool short *); 11935vector pixel vec_ldl (int, const vector pixel *); 11936vector signed short vec_ldl (int, const vector signed short *); 11937vector signed short vec_ldl (int, const short *); 11938vector unsigned short vec_ldl (int, const vector unsigned short *); 11939vector unsigned short vec_ldl (int, const unsigned short *); 11940vector bool char vec_ldl (int, const vector bool char *); 11941vector signed char vec_ldl (int, const vector signed char *); 11942vector signed char vec_ldl (int, const signed char *); 11943vector unsigned char vec_ldl (int, const vector unsigned char *); 11944vector unsigned char vec_ldl (int, const unsigned char *); 11945 11946vector float vec_loge (vector float); 11947 11948vector unsigned char vec_lvsl (int, const volatile unsigned char *); 11949vector unsigned char vec_lvsl (int, const volatile signed char *); 11950vector unsigned char vec_lvsl (int, const volatile unsigned short *); 11951vector unsigned char vec_lvsl (int, const volatile short *); 11952vector unsigned char vec_lvsl (int, const volatile unsigned int *); 11953vector unsigned char vec_lvsl (int, const volatile int *); 11954vector unsigned char vec_lvsl (int, const volatile unsigned long *); 11955vector unsigned char vec_lvsl (int, const volatile long *); 11956vector unsigned char vec_lvsl (int, const volatile float *); 11957 11958vector unsigned char vec_lvsr (int, const volatile unsigned char *); 11959vector unsigned char vec_lvsr (int, const volatile signed char *); 11960vector unsigned char vec_lvsr (int, const volatile unsigned short *); 11961vector unsigned char vec_lvsr (int, const volatile short *); 11962vector unsigned char vec_lvsr (int, const volatile unsigned int *); 11963vector unsigned char vec_lvsr (int, const volatile int *); 11964vector unsigned char vec_lvsr (int, const volatile unsigned long *); 11965vector unsigned char vec_lvsr (int, const volatile long *); 11966vector unsigned char vec_lvsr (int, const volatile float *); 11967 11968vector float vec_madd (vector float, vector float, vector float); 11969 11970vector signed short vec_madds (vector signed short, 11971 vector signed short, 11972 vector signed short); 11973 11974vector unsigned char vec_max (vector bool char, vector unsigned char); 11975vector unsigned char vec_max (vector unsigned char, vector bool char); 11976vector unsigned char vec_max (vector unsigned char, 11977 vector unsigned char); 11978vector signed char vec_max (vector bool char, vector signed char); 11979vector signed char vec_max (vector signed char, vector bool char); 11980vector signed char vec_max (vector signed char, vector signed char); 11981vector unsigned short vec_max (vector bool short, 11982 vector unsigned short); 11983vector unsigned short vec_max (vector unsigned short, 11984 vector bool short); 11985vector unsigned short vec_max (vector unsigned short, 11986 vector unsigned short); 11987vector signed short vec_max (vector bool short, vector signed short); 11988vector signed short vec_max (vector signed short, vector bool short); 11989vector signed short vec_max (vector signed short, vector signed short); 11990vector unsigned int vec_max (vector bool int, vector unsigned int); 11991vector unsigned int vec_max (vector unsigned int, vector bool int); 11992vector unsigned int vec_max (vector unsigned int, vector unsigned int); 11993vector signed int vec_max (vector bool int, vector signed int); 11994vector signed int vec_max (vector signed int, vector bool int); 11995vector signed int vec_max (vector signed int, vector signed int); 11996vector float vec_max (vector float, vector float); 11997 11998vector float vec_vmaxfp (vector float, vector float); 11999 12000vector signed int vec_vmaxsw (vector bool int, vector signed int); 12001vector signed int vec_vmaxsw (vector signed int, vector bool int); 12002vector signed int vec_vmaxsw (vector signed int, vector signed int); 12003 12004vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int); 12005vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int); 12006vector unsigned int vec_vmaxuw (vector unsigned int, 12007 vector unsigned int); 12008 12009vector signed short vec_vmaxsh (vector bool short, vector signed short); 12010vector signed short vec_vmaxsh (vector signed short, vector bool short); 12011vector signed short vec_vmaxsh (vector signed short, 12012 vector signed short); 12013 12014vector unsigned short vec_vmaxuh (vector bool short, 12015 vector unsigned short); 12016vector unsigned short vec_vmaxuh (vector unsigned short, 12017 vector bool short); 12018vector unsigned short vec_vmaxuh (vector unsigned short, 12019 vector unsigned short); 12020 12021vector signed char vec_vmaxsb (vector bool char, vector signed char); 12022vector signed char vec_vmaxsb (vector signed char, vector bool char); 12023vector signed char vec_vmaxsb (vector signed char, vector signed char); 12024 12025vector unsigned char vec_vmaxub (vector bool char, 12026 vector unsigned char); 12027vector unsigned char vec_vmaxub (vector unsigned char, 12028 vector bool char); 12029vector unsigned char vec_vmaxub (vector unsigned char, 12030 vector unsigned char); 12031 12032vector bool char vec_mergeh (vector bool char, vector bool char); 12033vector signed char vec_mergeh (vector signed char, vector signed char); 12034vector unsigned char vec_mergeh (vector unsigned char, 12035 vector unsigned char); 12036vector bool short vec_mergeh (vector bool short, vector bool short); 12037vector pixel vec_mergeh (vector pixel, vector pixel); 12038vector signed short vec_mergeh (vector signed short, 12039 vector signed short); 12040vector unsigned short vec_mergeh (vector unsigned short, 12041 vector unsigned short); 12042vector float vec_mergeh (vector float, vector float); 12043vector bool int vec_mergeh (vector bool int, vector bool int); 12044vector signed int vec_mergeh (vector signed int, vector signed int); 12045vector unsigned int vec_mergeh (vector unsigned int, 12046 vector unsigned int); 12047 12048vector float vec_vmrghw (vector float, vector float); 12049vector bool int vec_vmrghw (vector bool int, vector bool int); 12050vector signed int vec_vmrghw (vector signed int, vector signed int); 12051vector unsigned int vec_vmrghw (vector unsigned int, 12052 vector unsigned int); 12053 12054vector bool short vec_vmrghh (vector bool short, vector bool short); 12055vector signed short vec_vmrghh (vector signed short, 12056 vector signed short); 12057vector unsigned short vec_vmrghh (vector unsigned short, 12058 vector unsigned short); 12059vector pixel vec_vmrghh (vector pixel, vector pixel); 12060 12061vector bool char vec_vmrghb (vector bool char, vector bool char); 12062vector signed char vec_vmrghb (vector signed char, vector signed char); 12063vector unsigned char vec_vmrghb (vector unsigned char, 12064 vector unsigned char); 12065 12066vector bool char vec_mergel (vector bool char, vector bool char); 12067vector signed char vec_mergel (vector signed char, vector signed char); 12068vector unsigned char vec_mergel (vector unsigned char, 12069 vector unsigned char); 12070vector bool short vec_mergel (vector bool short, vector bool short); 12071vector pixel vec_mergel (vector pixel, vector pixel); 12072vector signed short vec_mergel (vector signed short, 12073 vector signed short); 12074vector unsigned short vec_mergel (vector unsigned short, 12075 vector unsigned short); 12076vector float vec_mergel (vector float, vector float); 12077vector bool int vec_mergel (vector bool int, vector bool int); 12078vector signed int vec_mergel (vector signed int, vector signed int); 12079vector unsigned int vec_mergel (vector unsigned int, 12080 vector unsigned int); 12081 12082vector float vec_vmrglw (vector float, vector float); 12083vector signed int vec_vmrglw (vector signed int, vector signed int); 12084vector unsigned int vec_vmrglw (vector unsigned int, 12085 vector unsigned int); 12086vector bool int vec_vmrglw (vector bool int, vector bool int); 12087 12088vector bool short vec_vmrglh (vector bool short, vector bool short); 12089vector signed short vec_vmrglh (vector signed short, 12090 vector signed short); 12091vector unsigned short vec_vmrglh (vector unsigned short, 12092 vector unsigned short); 12093vector pixel vec_vmrglh (vector pixel, vector pixel); 12094 12095vector bool char vec_vmrglb (vector bool char, vector bool char); 12096vector signed char vec_vmrglb (vector signed char, vector signed char); 12097vector unsigned char vec_vmrglb (vector unsigned char, 12098 vector unsigned char); 12099 12100vector unsigned short vec_mfvscr (void); 12101 12102vector unsigned char vec_min (vector bool char, vector unsigned char); 12103vector unsigned char vec_min (vector unsigned char, vector bool char); 12104vector unsigned char vec_min (vector unsigned char, 12105 vector unsigned char); 12106vector signed char vec_min (vector bool char, vector signed char); 12107vector signed char vec_min (vector signed char, vector bool char); 12108vector signed char vec_min (vector signed char, vector signed char); 12109vector unsigned short vec_min (vector bool short, 12110 vector unsigned short); 12111vector unsigned short vec_min (vector unsigned short, 12112 vector bool short); 12113vector unsigned short vec_min (vector unsigned short, 12114 vector unsigned short); 12115vector signed short vec_min (vector bool short, vector signed short); 12116vector signed short vec_min (vector signed short, vector bool short); 12117vector signed short vec_min (vector signed short, vector signed short); 12118vector unsigned int vec_min (vector bool int, vector unsigned int); 12119vector unsigned int vec_min (vector unsigned int, vector bool int); 12120vector unsigned int vec_min (vector unsigned int, vector unsigned int); 12121vector signed int vec_min (vector bool int, vector signed int); 12122vector signed int vec_min (vector signed int, vector bool int); 12123vector signed int vec_min (vector signed int, vector signed int); 12124vector float vec_min (vector float, vector float); 12125 12126vector float vec_vminfp (vector float, vector float); 12127 12128vector signed int vec_vminsw (vector bool int, vector signed int); 12129vector signed int vec_vminsw (vector signed int, vector bool int); 12130vector signed int vec_vminsw (vector signed int, vector signed int); 12131 12132vector unsigned int vec_vminuw (vector bool int, vector unsigned int); 12133vector unsigned int vec_vminuw (vector unsigned int, vector bool int); 12134vector unsigned int vec_vminuw (vector unsigned int, 12135 vector unsigned int); 12136 12137vector signed short vec_vminsh (vector bool short, vector signed short); 12138vector signed short vec_vminsh (vector signed short, vector bool short); 12139vector signed short vec_vminsh (vector signed short, 12140 vector signed short); 12141 12142vector unsigned short vec_vminuh (vector bool short, 12143 vector unsigned short); 12144vector unsigned short vec_vminuh (vector unsigned short, 12145 vector bool short); 12146vector unsigned short vec_vminuh (vector unsigned short, 12147 vector unsigned short); 12148 12149vector signed char vec_vminsb (vector bool char, vector signed char); 12150vector signed char vec_vminsb (vector signed char, vector bool char); 12151vector signed char vec_vminsb (vector signed char, vector signed char); 12152 12153vector unsigned char vec_vminub (vector bool char, 12154 vector unsigned char); 12155vector unsigned char vec_vminub (vector unsigned char, 12156 vector bool char); 12157vector unsigned char vec_vminub (vector unsigned char, 12158 vector unsigned char); 12159 12160vector signed short vec_mladd (vector signed short, 12161 vector signed short, 12162 vector signed short); 12163vector signed short vec_mladd (vector signed short, 12164 vector unsigned short, 12165 vector unsigned short); 12166vector signed short vec_mladd (vector unsigned short, 12167 vector signed short, 12168 vector signed short); 12169vector unsigned short vec_mladd (vector unsigned short, 12170 vector unsigned short, 12171 vector unsigned short); 12172 12173vector signed short vec_mradds (vector signed short, 12174 vector signed short, 12175 vector signed short); 12176 12177vector unsigned int vec_msum (vector unsigned char, 12178 vector unsigned char, 12179 vector unsigned int); 12180vector signed int vec_msum (vector signed char, 12181 vector unsigned char, 12182 vector signed int); 12183vector unsigned int vec_msum (vector unsigned short, 12184 vector unsigned short, 12185 vector unsigned int); 12186vector signed int vec_msum (vector signed short, 12187 vector signed short, 12188 vector signed int); 12189 12190vector signed int vec_vmsumshm (vector signed short, 12191 vector signed short, 12192 vector signed int); 12193 12194vector unsigned int vec_vmsumuhm (vector unsigned short, 12195 vector unsigned short, 12196 vector unsigned int); 12197 12198vector signed int vec_vmsummbm (vector signed char, 12199 vector unsigned char, 12200 vector signed int); 12201 12202vector unsigned int vec_vmsumubm (vector unsigned char, 12203 vector unsigned char, 12204 vector unsigned int); 12205 12206vector unsigned int vec_msums (vector unsigned short, 12207 vector unsigned short, 12208 vector unsigned int); 12209vector signed int vec_msums (vector signed short, 12210 vector signed short, 12211 vector signed int); 12212 12213vector signed int vec_vmsumshs (vector signed short, 12214 vector signed short, 12215 vector signed int); 12216 12217vector unsigned int vec_vmsumuhs (vector unsigned short, 12218 vector unsigned short, 12219 vector unsigned int); 12220 12221void vec_mtvscr (vector signed int); 12222void vec_mtvscr (vector unsigned int); 12223void vec_mtvscr (vector bool int); 12224void vec_mtvscr (vector signed short); 12225void vec_mtvscr (vector unsigned short); 12226void vec_mtvscr (vector bool short); 12227void vec_mtvscr (vector pixel); 12228void vec_mtvscr (vector signed char); 12229void vec_mtvscr (vector unsigned char); 12230void vec_mtvscr (vector bool char); 12231 12232vector unsigned short vec_mule (vector unsigned char, 12233 vector unsigned char); 12234vector signed short vec_mule (vector signed char, 12235 vector signed char); 12236vector unsigned int vec_mule (vector unsigned short, 12237 vector unsigned short); 12238vector signed int vec_mule (vector signed short, vector signed short); 12239 12240vector signed int vec_vmulesh (vector signed short, 12241 vector signed short); 12242 12243vector unsigned int vec_vmuleuh (vector unsigned short, 12244 vector unsigned short); 12245 12246vector signed short vec_vmulesb (vector signed char, 12247 vector signed char); 12248 12249vector unsigned short vec_vmuleub (vector unsigned char, 12250 vector unsigned char); 12251 12252vector unsigned short vec_mulo (vector unsigned char, 12253 vector unsigned char); 12254vector signed short vec_mulo (vector signed char, vector signed char); 12255vector unsigned int vec_mulo (vector unsigned short, 12256 vector unsigned short); 12257vector signed int vec_mulo (vector signed short, vector signed short); 12258 12259vector signed int vec_vmulosh (vector signed short, 12260 vector signed short); 12261 12262vector unsigned int vec_vmulouh (vector unsigned short, 12263 vector unsigned short); 12264 12265vector signed short vec_vmulosb (vector signed char, 12266 vector signed char); 12267 12268vector unsigned short vec_vmuloub (vector unsigned char, 12269 vector unsigned char); 12270 12271vector float vec_nmsub (vector float, vector float, vector float); 12272 12273vector float vec_nor (vector float, vector float); 12274vector signed int vec_nor (vector signed int, vector signed int); 12275vector unsigned int vec_nor (vector unsigned int, vector unsigned int); 12276vector bool int vec_nor (vector bool int, vector bool int); 12277vector signed short vec_nor (vector signed short, vector signed short); 12278vector unsigned short vec_nor (vector unsigned short, 12279 vector unsigned short); 12280vector bool short vec_nor (vector bool short, vector bool short); 12281vector signed char vec_nor (vector signed char, vector signed char); 12282vector unsigned char vec_nor (vector unsigned char, 12283 vector unsigned char); 12284vector bool char vec_nor (vector bool char, vector bool char); 12285 12286vector float vec_or (vector float, vector float); 12287vector float vec_or (vector float, vector bool int); 12288vector float vec_or (vector bool int, vector float); 12289vector bool int vec_or (vector bool int, vector bool int); 12290vector signed int vec_or (vector bool int, vector signed int); 12291vector signed int vec_or (vector signed int, vector bool int); 12292vector signed int vec_or (vector signed int, vector signed int); 12293vector unsigned int vec_or (vector bool int, vector unsigned int); 12294vector unsigned int vec_or (vector unsigned int, vector bool int); 12295vector unsigned int vec_or (vector unsigned int, vector unsigned int); 12296vector bool short vec_or (vector bool short, vector bool short); 12297vector signed short vec_or (vector bool short, vector signed short); 12298vector signed short vec_or (vector signed short, vector bool short); 12299vector signed short vec_or (vector signed short, vector signed short); 12300vector unsigned short vec_or (vector bool short, vector unsigned short); 12301vector unsigned short vec_or (vector unsigned short, vector bool short); 12302vector unsigned short vec_or (vector unsigned short, 12303 vector unsigned short); 12304vector signed char vec_or (vector bool char, vector signed char); 12305vector bool char vec_or (vector bool char, vector bool char); 12306vector signed char vec_or (vector signed char, vector bool char); 12307vector signed char vec_or (vector signed char, vector signed char); 12308vector unsigned char vec_or (vector bool char, vector unsigned char); 12309vector unsigned char vec_or (vector unsigned char, vector bool char); 12310vector unsigned char vec_or (vector unsigned char, 12311 vector unsigned char); 12312 12313vector signed char vec_pack (vector signed short, vector signed short); 12314vector unsigned char vec_pack (vector unsigned short, 12315 vector unsigned short); 12316vector bool char vec_pack (vector bool short, vector bool short); 12317vector signed short vec_pack (vector signed int, vector signed int); 12318vector unsigned short vec_pack (vector unsigned int, 12319 vector unsigned int); 12320vector bool short vec_pack (vector bool int, vector bool int); 12321 12322vector bool short vec_vpkuwum (vector bool int, vector bool int); 12323vector signed short vec_vpkuwum (vector signed int, vector signed int); 12324vector unsigned short vec_vpkuwum (vector unsigned int, 12325 vector unsigned int); 12326 12327vector bool char vec_vpkuhum (vector bool short, vector bool short); 12328vector signed char vec_vpkuhum (vector signed short, 12329 vector signed short); 12330vector unsigned char vec_vpkuhum (vector unsigned short, 12331 vector unsigned short); 12332 12333vector pixel vec_packpx (vector unsigned int, vector unsigned int); 12334 12335vector unsigned char vec_packs (vector unsigned short, 12336 vector unsigned short); 12337vector signed char vec_packs (vector signed short, vector signed short); 12338vector unsigned short vec_packs (vector unsigned int, 12339 vector unsigned int); 12340vector signed short vec_packs (vector signed int, vector signed int); 12341 12342vector signed short vec_vpkswss (vector signed int, vector signed int); 12343 12344vector unsigned short vec_vpkuwus (vector unsigned int, 12345 vector unsigned int); 12346 12347vector signed char vec_vpkshss (vector signed short, 12348 vector signed short); 12349 12350vector unsigned char vec_vpkuhus (vector unsigned short, 12351 vector unsigned short); 12352 12353vector unsigned char vec_packsu (vector unsigned short, 12354 vector unsigned short); 12355vector unsigned char vec_packsu (vector signed short, 12356 vector signed short); 12357vector unsigned short vec_packsu (vector unsigned int, 12358 vector unsigned int); 12359vector unsigned short vec_packsu (vector signed int, vector signed int); 12360 12361vector unsigned short vec_vpkswus (vector signed int, 12362 vector signed int); 12363 12364vector unsigned char vec_vpkshus (vector signed short, 12365 vector signed short); 12366 12367vector float vec_perm (vector float, 12368 vector float, 12369 vector unsigned char); 12370vector signed int vec_perm (vector signed int, 12371 vector signed int, 12372 vector unsigned char); 12373vector unsigned int vec_perm (vector unsigned int, 12374 vector unsigned int, 12375 vector unsigned char); 12376vector bool int vec_perm (vector bool int, 12377 vector bool int, 12378 vector unsigned char); 12379vector signed short vec_perm (vector signed short, 12380 vector signed short, 12381 vector unsigned char); 12382vector unsigned short vec_perm (vector unsigned short, 12383 vector unsigned short, 12384 vector unsigned char); 12385vector bool short vec_perm (vector bool short, 12386 vector bool short, 12387 vector unsigned char); 12388vector pixel vec_perm (vector pixel, 12389 vector pixel, 12390 vector unsigned char); 12391vector signed char vec_perm (vector signed char, 12392 vector signed char, 12393 vector unsigned char); 12394vector unsigned char vec_perm (vector unsigned char, 12395 vector unsigned char, 12396 vector unsigned char); 12397vector bool char vec_perm (vector bool char, 12398 vector bool char, 12399 vector unsigned char); 12400 12401vector float vec_re (vector float); 12402 12403vector signed char vec_rl (vector signed char, 12404 vector unsigned char); 12405vector unsigned char vec_rl (vector unsigned char, 12406 vector unsigned char); 12407vector signed short vec_rl (vector signed short, vector unsigned short); 12408vector unsigned short vec_rl (vector unsigned short, 12409 vector unsigned short); 12410vector signed int vec_rl (vector signed int, vector unsigned int); 12411vector unsigned int vec_rl (vector unsigned int, vector unsigned int); 12412 12413vector signed int vec_vrlw (vector signed int, vector unsigned int); 12414vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int); 12415 12416vector signed short vec_vrlh (vector signed short, 12417 vector unsigned short); 12418vector unsigned short vec_vrlh (vector unsigned short, 12419 vector unsigned short); 12420 12421vector signed char vec_vrlb (vector signed char, vector unsigned char); 12422vector unsigned char vec_vrlb (vector unsigned char, 12423 vector unsigned char); 12424 12425vector float vec_round (vector float); 12426 12427vector float vec_recip (vector float, vector float); 12428 12429vector float vec_rsqrt (vector float); 12430 12431vector float vec_rsqrte (vector float); 12432 12433vector float vec_sel (vector float, vector float, vector bool int); 12434vector float vec_sel (vector float, vector float, vector unsigned int); 12435vector signed int vec_sel (vector signed int, 12436 vector signed int, 12437 vector bool int); 12438vector signed int vec_sel (vector signed int, 12439 vector signed int, 12440 vector unsigned int); 12441vector unsigned int vec_sel (vector unsigned int, 12442 vector unsigned int, 12443 vector bool int); 12444vector unsigned int vec_sel (vector unsigned int, 12445 vector unsigned int, 12446 vector unsigned int); 12447vector bool int vec_sel (vector bool int, 12448 vector bool int, 12449 vector bool int); 12450vector bool int vec_sel (vector bool int, 12451 vector bool int, 12452 vector unsigned int); 12453vector signed short vec_sel (vector signed short, 12454 vector signed short, 12455 vector bool short); 12456vector signed short vec_sel (vector signed short, 12457 vector signed short, 12458 vector unsigned short); 12459vector unsigned short vec_sel (vector unsigned short, 12460 vector unsigned short, 12461 vector bool short); 12462vector unsigned short vec_sel (vector unsigned short, 12463 vector unsigned short, 12464 vector unsigned short); 12465vector bool short vec_sel (vector bool short, 12466 vector bool short, 12467 vector bool short); 12468vector bool short vec_sel (vector bool short, 12469 vector bool short, 12470 vector unsigned short); 12471vector signed char vec_sel (vector signed char, 12472 vector signed char, 12473 vector bool char); 12474vector signed char vec_sel (vector signed char, 12475 vector signed char, 12476 vector unsigned char); 12477vector unsigned char vec_sel (vector unsigned char, 12478 vector unsigned char, 12479 vector bool char); 12480vector unsigned char vec_sel (vector unsigned char, 12481 vector unsigned char, 12482 vector unsigned char); 12483vector bool char vec_sel (vector bool char, 12484 vector bool char, 12485 vector bool char); 12486vector bool char vec_sel (vector bool char, 12487 vector bool char, 12488 vector unsigned char); 12489 12490vector signed char vec_sl (vector signed char, 12491 vector unsigned char); 12492vector unsigned char vec_sl (vector unsigned char, 12493 vector unsigned char); 12494vector signed short vec_sl (vector signed short, vector unsigned short); 12495vector unsigned short vec_sl (vector unsigned short, 12496 vector unsigned short); 12497vector signed int vec_sl (vector signed int, vector unsigned int); 12498vector unsigned int vec_sl (vector unsigned int, vector unsigned int); 12499 12500vector signed int vec_vslw (vector signed int, vector unsigned int); 12501vector unsigned int vec_vslw (vector unsigned int, vector unsigned int); 12502 12503vector signed short vec_vslh (vector signed short, 12504 vector unsigned short); 12505vector unsigned short vec_vslh (vector unsigned short, 12506 vector unsigned short); 12507 12508vector signed char vec_vslb (vector signed char, vector unsigned char); 12509vector unsigned char vec_vslb (vector unsigned char, 12510 vector unsigned char); 12511 12512vector float vec_sld (vector float, vector float, const int); 12513vector signed int vec_sld (vector signed int, 12514 vector signed int, 12515 const int); 12516vector unsigned int vec_sld (vector unsigned int, 12517 vector unsigned int, 12518 const int); 12519vector bool int vec_sld (vector bool int, 12520 vector bool int, 12521 const int); 12522vector signed short vec_sld (vector signed short, 12523 vector signed short, 12524 const int); 12525vector unsigned short vec_sld (vector unsigned short, 12526 vector unsigned short, 12527 const int); 12528vector bool short vec_sld (vector bool short, 12529 vector bool short, 12530 const int); 12531vector pixel vec_sld (vector pixel, 12532 vector pixel, 12533 const int); 12534vector signed char vec_sld (vector signed char, 12535 vector signed char, 12536 const int); 12537vector unsigned char vec_sld (vector unsigned char, 12538 vector unsigned char, 12539 const int); 12540vector bool char vec_sld (vector bool char, 12541 vector bool char, 12542 const int); 12543 12544vector signed int vec_sll (vector signed int, 12545 vector unsigned int); 12546vector signed int vec_sll (vector signed int, 12547 vector unsigned short); 12548vector signed int vec_sll (vector signed int, 12549 vector unsigned char); 12550vector unsigned int vec_sll (vector unsigned int, 12551 vector unsigned int); 12552vector unsigned int vec_sll (vector unsigned int, 12553 vector unsigned short); 12554vector unsigned int vec_sll (vector unsigned int, 12555 vector unsigned char); 12556vector bool int vec_sll (vector bool int, 12557 vector unsigned int); 12558vector bool int vec_sll (vector bool int, 12559 vector unsigned short); 12560vector bool int vec_sll (vector bool int, 12561 vector unsigned char); 12562vector signed short vec_sll (vector signed short, 12563 vector unsigned int); 12564vector signed short vec_sll (vector signed short, 12565 vector unsigned short); 12566vector signed short vec_sll (vector signed short, 12567 vector unsigned char); 12568vector unsigned short vec_sll (vector unsigned short, 12569 vector unsigned int); 12570vector unsigned short vec_sll (vector unsigned short, 12571 vector unsigned short); 12572vector unsigned short vec_sll (vector unsigned short, 12573 vector unsigned char); 12574vector bool short vec_sll (vector bool short, vector unsigned int); 12575vector bool short vec_sll (vector bool short, vector unsigned short); 12576vector bool short vec_sll (vector bool short, vector unsigned char); 12577vector pixel vec_sll (vector pixel, vector unsigned int); 12578vector pixel vec_sll (vector pixel, vector unsigned short); 12579vector pixel vec_sll (vector pixel, vector unsigned char); 12580vector signed char vec_sll (vector signed char, vector unsigned int); 12581vector signed char vec_sll (vector signed char, vector unsigned short); 12582vector signed char vec_sll (vector signed char, vector unsigned char); 12583vector unsigned char vec_sll (vector unsigned char, 12584 vector unsigned int); 12585vector unsigned char vec_sll (vector unsigned char, 12586 vector unsigned short); 12587vector unsigned char vec_sll (vector unsigned char, 12588 vector unsigned char); 12589vector bool char vec_sll (vector bool char, vector unsigned int); 12590vector bool char vec_sll (vector bool char, vector unsigned short); 12591vector bool char vec_sll (vector bool char, vector unsigned char); 12592 12593vector float vec_slo (vector float, vector signed char); 12594vector float vec_slo (vector float, vector unsigned char); 12595vector signed int vec_slo (vector signed int, vector signed char); 12596vector signed int vec_slo (vector signed int, vector unsigned char); 12597vector unsigned int vec_slo (vector unsigned int, vector signed char); 12598vector unsigned int vec_slo (vector unsigned int, vector unsigned char); 12599vector signed short vec_slo (vector signed short, vector signed char); 12600vector signed short vec_slo (vector signed short, vector unsigned char); 12601vector unsigned short vec_slo (vector unsigned short, 12602 vector signed char); 12603vector unsigned short vec_slo (vector unsigned short, 12604 vector unsigned char); 12605vector pixel vec_slo (vector pixel, vector signed char); 12606vector pixel vec_slo (vector pixel, vector unsigned char); 12607vector signed char vec_slo (vector signed char, vector signed char); 12608vector signed char vec_slo (vector signed char, vector unsigned char); 12609vector unsigned char vec_slo (vector unsigned char, vector signed char); 12610vector unsigned char vec_slo (vector unsigned char, 12611 vector unsigned char); 12612 12613vector signed char vec_splat (vector signed char, const int); 12614vector unsigned char vec_splat (vector unsigned char, const int); 12615vector bool char vec_splat (vector bool char, const int); 12616vector signed short vec_splat (vector signed short, const int); 12617vector unsigned short vec_splat (vector unsigned short, const int); 12618vector bool short vec_splat (vector bool short, const int); 12619vector pixel vec_splat (vector pixel, const int); 12620vector float vec_splat (vector float, const int); 12621vector signed int vec_splat (vector signed int, const int); 12622vector unsigned int vec_splat (vector unsigned int, const int); 12623vector bool int vec_splat (vector bool int, const int); 12624 12625vector float vec_vspltw (vector float, const int); 12626vector signed int vec_vspltw (vector signed int, const int); 12627vector unsigned int vec_vspltw (vector unsigned int, const int); 12628vector bool int vec_vspltw (vector bool int, const int); 12629 12630vector bool short vec_vsplth (vector bool short, const int); 12631vector signed short vec_vsplth (vector signed short, const int); 12632vector unsigned short vec_vsplth (vector unsigned short, const int); 12633vector pixel vec_vsplth (vector pixel, const int); 12634 12635vector signed char vec_vspltb (vector signed char, const int); 12636vector unsigned char vec_vspltb (vector unsigned char, const int); 12637vector bool char vec_vspltb (vector bool char, const int); 12638 12639vector signed char vec_splat_s8 (const int); 12640 12641vector signed short vec_splat_s16 (const int); 12642 12643vector signed int vec_splat_s32 (const int); 12644 12645vector unsigned char vec_splat_u8 (const int); 12646 12647vector unsigned short vec_splat_u16 (const int); 12648 12649vector unsigned int vec_splat_u32 (const int); 12650 12651vector signed char vec_sr (vector signed char, vector unsigned char); 12652vector unsigned char vec_sr (vector unsigned char, 12653 vector unsigned char); 12654vector signed short vec_sr (vector signed short, 12655 vector unsigned short); 12656vector unsigned short vec_sr (vector unsigned short, 12657 vector unsigned short); 12658vector signed int vec_sr (vector signed int, vector unsigned int); 12659vector unsigned int vec_sr (vector unsigned int, vector unsigned int); 12660 12661vector signed int vec_vsrw (vector signed int, vector unsigned int); 12662vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int); 12663 12664vector signed short vec_vsrh (vector signed short, 12665 vector unsigned short); 12666vector unsigned short vec_vsrh (vector unsigned short, 12667 vector unsigned short); 12668 12669vector signed char vec_vsrb (vector signed char, vector unsigned char); 12670vector unsigned char vec_vsrb (vector unsigned char, 12671 vector unsigned char); 12672 12673vector signed char vec_sra (vector signed char, vector unsigned char); 12674vector unsigned char vec_sra (vector unsigned char, 12675 vector unsigned char); 12676vector signed short vec_sra (vector signed short, 12677 vector unsigned short); 12678vector unsigned short vec_sra (vector unsigned short, 12679 vector unsigned short); 12680vector signed int vec_sra (vector signed int, vector unsigned int); 12681vector unsigned int vec_sra (vector unsigned int, vector unsigned int); 12682 12683vector signed int vec_vsraw (vector signed int, vector unsigned int); 12684vector unsigned int vec_vsraw (vector unsigned int, 12685 vector unsigned int); 12686 12687vector signed short vec_vsrah (vector signed short, 12688 vector unsigned short); 12689vector unsigned short vec_vsrah (vector unsigned short, 12690 vector unsigned short); 12691 12692vector signed char vec_vsrab (vector signed char, vector unsigned char); 12693vector unsigned char vec_vsrab (vector unsigned char, 12694 vector unsigned char); 12695 12696vector signed int vec_srl (vector signed int, vector unsigned int); 12697vector signed int vec_srl (vector signed int, vector unsigned short); 12698vector signed int vec_srl (vector signed int, vector unsigned char); 12699vector unsigned int vec_srl (vector unsigned int, vector unsigned int); 12700vector unsigned int vec_srl (vector unsigned int, 12701 vector unsigned short); 12702vector unsigned int vec_srl (vector unsigned int, vector unsigned char); 12703vector bool int vec_srl (vector bool int, vector unsigned int); 12704vector bool int vec_srl (vector bool int, vector unsigned short); 12705vector bool int vec_srl (vector bool int, vector unsigned char); 12706vector signed short vec_srl (vector signed short, vector unsigned int); 12707vector signed short vec_srl (vector signed short, 12708 vector unsigned short); 12709vector signed short vec_srl (vector signed short, vector unsigned char); 12710vector unsigned short vec_srl (vector unsigned short, 12711 vector unsigned int); 12712vector unsigned short vec_srl (vector unsigned short, 12713 vector unsigned short); 12714vector unsigned short vec_srl (vector unsigned short, 12715 vector unsigned char); 12716vector bool short vec_srl (vector bool short, vector unsigned int); 12717vector bool short vec_srl (vector bool short, vector unsigned short); 12718vector bool short vec_srl (vector bool short, vector unsigned char); 12719vector pixel vec_srl (vector pixel, vector unsigned int); 12720vector pixel vec_srl (vector pixel, vector unsigned short); 12721vector pixel vec_srl (vector pixel, vector unsigned char); 12722vector signed char vec_srl (vector signed char, vector unsigned int); 12723vector signed char vec_srl (vector signed char, vector unsigned short); 12724vector signed char vec_srl (vector signed char, vector unsigned char); 12725vector unsigned char vec_srl (vector unsigned char, 12726 vector unsigned int); 12727vector unsigned char vec_srl (vector unsigned char, 12728 vector unsigned short); 12729vector unsigned char vec_srl (vector unsigned char, 12730 vector unsigned char); 12731vector bool char vec_srl (vector bool char, vector unsigned int); 12732vector bool char vec_srl (vector bool char, vector unsigned short); 12733vector bool char vec_srl (vector bool char, vector unsigned char); 12734 12735vector float vec_sro (vector float, vector signed char); 12736vector float vec_sro (vector float, vector unsigned char); 12737vector signed int vec_sro (vector signed int, vector signed char); 12738vector signed int vec_sro (vector signed int, vector unsigned char); 12739vector unsigned int vec_sro (vector unsigned int, vector signed char); 12740vector unsigned int vec_sro (vector unsigned int, vector unsigned char); 12741vector signed short vec_sro (vector signed short, vector signed char); 12742vector signed short vec_sro (vector signed short, vector unsigned char); 12743vector unsigned short vec_sro (vector unsigned short, 12744 vector signed char); 12745vector unsigned short vec_sro (vector unsigned short, 12746 vector unsigned char); 12747vector pixel vec_sro (vector pixel, vector signed char); 12748vector pixel vec_sro (vector pixel, vector unsigned char); 12749vector signed char vec_sro (vector signed char, vector signed char); 12750vector signed char vec_sro (vector signed char, vector unsigned char); 12751vector unsigned char vec_sro (vector unsigned char, vector signed char); 12752vector unsigned char vec_sro (vector unsigned char, 12753 vector unsigned char); 12754 12755void vec_st (vector float, int, vector float *); 12756void vec_st (vector float, int, float *); 12757void vec_st (vector signed int, int, vector signed int *); 12758void vec_st (vector signed int, int, int *); 12759void vec_st (vector unsigned int, int, vector unsigned int *); 12760void vec_st (vector unsigned int, int, unsigned int *); 12761void vec_st (vector bool int, int, vector bool int *); 12762void vec_st (vector bool int, int, unsigned int *); 12763void vec_st (vector bool int, int, int *); 12764void vec_st (vector signed short, int, vector signed short *); 12765void vec_st (vector signed short, int, short *); 12766void vec_st (vector unsigned short, int, vector unsigned short *); 12767void vec_st (vector unsigned short, int, unsigned short *); 12768void vec_st (vector bool short, int, vector bool short *); 12769void vec_st (vector bool short, int, unsigned short *); 12770void vec_st (vector pixel, int, vector pixel *); 12771void vec_st (vector pixel, int, unsigned short *); 12772void vec_st (vector pixel, int, short *); 12773void vec_st (vector bool short, int, short *); 12774void vec_st (vector signed char, int, vector signed char *); 12775void vec_st (vector signed char, int, signed char *); 12776void vec_st (vector unsigned char, int, vector unsigned char *); 12777void vec_st (vector unsigned char, int, unsigned char *); 12778void vec_st (vector bool char, int, vector bool char *); 12779void vec_st (vector bool char, int, unsigned char *); 12780void vec_st (vector bool char, int, signed char *); 12781 12782void vec_ste (vector signed char, int, signed char *); 12783void vec_ste (vector unsigned char, int, unsigned char *); 12784void vec_ste (vector bool char, int, signed char *); 12785void vec_ste (vector bool char, int, unsigned char *); 12786void vec_ste (vector signed short, int, short *); 12787void vec_ste (vector unsigned short, int, unsigned short *); 12788void vec_ste (vector bool short, int, short *); 12789void vec_ste (vector bool short, int, unsigned short *); 12790void vec_ste (vector pixel, int, short *); 12791void vec_ste (vector pixel, int, unsigned short *); 12792void vec_ste (vector float, int, float *); 12793void vec_ste (vector signed int, int, int *); 12794void vec_ste (vector unsigned int, int, unsigned int *); 12795void vec_ste (vector bool int, int, int *); 12796void vec_ste (vector bool int, int, unsigned int *); 12797 12798void vec_stvewx (vector float, int, float *); 12799void vec_stvewx (vector signed int, int, int *); 12800void vec_stvewx (vector unsigned int, int, unsigned int *); 12801void vec_stvewx (vector bool int, int, int *); 12802void vec_stvewx (vector bool int, int, unsigned int *); 12803 12804void vec_stvehx (vector signed short, int, short *); 12805void vec_stvehx (vector unsigned short, int, unsigned short *); 12806void vec_stvehx (vector bool short, int, short *); 12807void vec_stvehx (vector bool short, int, unsigned short *); 12808void vec_stvehx (vector pixel, int, short *); 12809void vec_stvehx (vector pixel, int, unsigned short *); 12810 12811void vec_stvebx (vector signed char, int, signed char *); 12812void vec_stvebx (vector unsigned char, int, unsigned char *); 12813void vec_stvebx (vector bool char, int, signed char *); 12814void vec_stvebx (vector bool char, int, unsigned char *); 12815 12816void vec_stl (vector float, int, vector float *); 12817void vec_stl (vector float, int, float *); 12818void vec_stl (vector signed int, int, vector signed int *); 12819void vec_stl (vector signed int, int, int *); 12820void vec_stl (vector unsigned int, int, vector unsigned int *); 12821void vec_stl (vector unsigned int, int, unsigned int *); 12822void vec_stl (vector bool int, int, vector bool int *); 12823void vec_stl (vector bool int, int, unsigned int *); 12824void vec_stl (vector bool int, int, int *); 12825void vec_stl (vector signed short, int, vector signed short *); 12826void vec_stl (vector signed short, int, short *); 12827void vec_stl (vector unsigned short, int, vector unsigned short *); 12828void vec_stl (vector unsigned short, int, unsigned short *); 12829void vec_stl (vector bool short, int, vector bool short *); 12830void vec_stl (vector bool short, int, unsigned short *); 12831void vec_stl (vector bool short, int, short *); 12832void vec_stl (vector pixel, int, vector pixel *); 12833void vec_stl (vector pixel, int, unsigned short *); 12834void vec_stl (vector pixel, int, short *); 12835void vec_stl (vector signed char, int, vector signed char *); 12836void vec_stl (vector signed char, int, signed char *); 12837void vec_stl (vector unsigned char, int, vector unsigned char *); 12838void vec_stl (vector unsigned char, int, unsigned char *); 12839void vec_stl (vector bool char, int, vector bool char *); 12840void vec_stl (vector bool char, int, unsigned char *); 12841void vec_stl (vector bool char, int, signed char *); 12842 12843vector signed char vec_sub (vector bool char, vector signed char); 12844vector signed char vec_sub (vector signed char, vector bool char); 12845vector signed char vec_sub (vector signed char, vector signed char); 12846vector unsigned char vec_sub (vector bool char, vector unsigned char); 12847vector unsigned char vec_sub (vector unsigned char, vector bool char); 12848vector unsigned char vec_sub (vector unsigned char, 12849 vector unsigned char); 12850vector signed short vec_sub (vector bool short, vector signed short); 12851vector signed short vec_sub (vector signed short, vector bool short); 12852vector signed short vec_sub (vector signed short, vector signed short); 12853vector unsigned short vec_sub (vector bool short, 12854 vector unsigned short); 12855vector unsigned short vec_sub (vector unsigned short, 12856 vector bool short); 12857vector unsigned short vec_sub (vector unsigned short, 12858 vector unsigned short); 12859vector signed int vec_sub (vector bool int, vector signed int); 12860vector signed int vec_sub (vector signed int, vector bool int); 12861vector signed int vec_sub (vector signed int, vector signed int); 12862vector unsigned int vec_sub (vector bool int, vector unsigned int); 12863vector unsigned int vec_sub (vector unsigned int, vector bool int); 12864vector unsigned int vec_sub (vector unsigned int, vector unsigned int); 12865vector float vec_sub (vector float, vector float); 12866 12867vector float vec_vsubfp (vector float, vector float); 12868 12869vector signed int vec_vsubuwm (vector bool int, vector signed int); 12870vector signed int vec_vsubuwm (vector signed int, vector bool int); 12871vector signed int vec_vsubuwm (vector signed int, vector signed int); 12872vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int); 12873vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int); 12874vector unsigned int vec_vsubuwm (vector unsigned int, 12875 vector unsigned int); 12876 12877vector signed short vec_vsubuhm (vector bool short, 12878 vector signed short); 12879vector signed short vec_vsubuhm (vector signed short, 12880 vector bool short); 12881vector signed short vec_vsubuhm (vector signed short, 12882 vector signed short); 12883vector unsigned short vec_vsubuhm (vector bool short, 12884 vector unsigned short); 12885vector unsigned short vec_vsubuhm (vector unsigned short, 12886 vector bool short); 12887vector unsigned short vec_vsubuhm (vector unsigned short, 12888 vector unsigned short); 12889 12890vector signed char vec_vsububm (vector bool char, vector signed char); 12891vector signed char vec_vsububm (vector signed char, vector bool char); 12892vector signed char vec_vsububm (vector signed char, vector signed char); 12893vector unsigned char vec_vsububm (vector bool char, 12894 vector unsigned char); 12895vector unsigned char vec_vsububm (vector unsigned char, 12896 vector bool char); 12897vector unsigned char vec_vsububm (vector unsigned char, 12898 vector unsigned char); 12899 12900vector unsigned int vec_subc (vector unsigned int, vector unsigned int); 12901 12902vector unsigned char vec_subs (vector bool char, vector unsigned char); 12903vector unsigned char vec_subs (vector unsigned char, vector bool char); 12904vector unsigned char vec_subs (vector unsigned char, 12905 vector unsigned char); 12906vector signed char vec_subs (vector bool char, vector signed char); 12907vector signed char vec_subs (vector signed char, vector bool char); 12908vector signed char vec_subs (vector signed char, vector signed char); 12909vector unsigned short vec_subs (vector bool short, 12910 vector unsigned short); 12911vector unsigned short vec_subs (vector unsigned short, 12912 vector bool short); 12913vector unsigned short vec_subs (vector unsigned short, 12914 vector unsigned short); 12915vector signed short vec_subs (vector bool short, vector signed short); 12916vector signed short vec_subs (vector signed short, vector bool short); 12917vector signed short vec_subs (vector signed short, vector signed short); 12918vector unsigned int vec_subs (vector bool int, vector unsigned int); 12919vector unsigned int vec_subs (vector unsigned int, vector bool int); 12920vector unsigned int vec_subs (vector unsigned int, vector unsigned int); 12921vector signed int vec_subs (vector bool int, vector signed int); 12922vector signed int vec_subs (vector signed int, vector bool int); 12923vector signed int vec_subs (vector signed int, vector signed int); 12924 12925vector signed int vec_vsubsws (vector bool int, vector signed int); 12926vector signed int vec_vsubsws (vector signed int, vector bool int); 12927vector signed int vec_vsubsws (vector signed int, vector signed int); 12928 12929vector unsigned int vec_vsubuws (vector bool int, vector unsigned int); 12930vector unsigned int vec_vsubuws (vector unsigned int, vector bool int); 12931vector unsigned int vec_vsubuws (vector unsigned int, 12932 vector unsigned int); 12933 12934vector signed short vec_vsubshs (vector bool short, 12935 vector signed short); 12936vector signed short vec_vsubshs (vector signed short, 12937 vector bool short); 12938vector signed short vec_vsubshs (vector signed short, 12939 vector signed short); 12940 12941vector unsigned short vec_vsubuhs (vector bool short, 12942 vector unsigned short); 12943vector unsigned short vec_vsubuhs (vector unsigned short, 12944 vector bool short); 12945vector unsigned short vec_vsubuhs (vector unsigned short, 12946 vector unsigned short); 12947 12948vector signed char vec_vsubsbs (vector bool char, vector signed char); 12949vector signed char vec_vsubsbs (vector signed char, vector bool char); 12950vector signed char vec_vsubsbs (vector signed char, vector signed char); 12951 12952vector unsigned char vec_vsububs (vector bool char, 12953 vector unsigned char); 12954vector unsigned char vec_vsububs (vector unsigned char, 12955 vector bool char); 12956vector unsigned char vec_vsububs (vector unsigned char, 12957 vector unsigned char); 12958 12959vector unsigned int vec_sum4s (vector unsigned char, 12960 vector unsigned int); 12961vector signed int vec_sum4s (vector signed char, vector signed int); 12962vector signed int vec_sum4s (vector signed short, vector signed int); 12963 12964vector signed int vec_vsum4shs (vector signed short, vector signed int); 12965 12966vector signed int vec_vsum4sbs (vector signed char, vector signed int); 12967 12968vector unsigned int vec_vsum4ubs (vector unsigned char, 12969 vector unsigned int); 12970 12971vector signed int vec_sum2s (vector signed int, vector signed int); 12972 12973vector signed int vec_sums (vector signed int, vector signed int); 12974 12975vector float vec_trunc (vector float); 12976 12977vector signed short vec_unpackh (vector signed char); 12978vector bool short vec_unpackh (vector bool char); 12979vector signed int vec_unpackh (vector signed short); 12980vector bool int vec_unpackh (vector bool short); 12981vector unsigned int vec_unpackh (vector pixel); 12982 12983vector bool int vec_vupkhsh (vector bool short); 12984vector signed int vec_vupkhsh (vector signed short); 12985 12986vector unsigned int vec_vupkhpx (vector pixel); 12987 12988vector bool short vec_vupkhsb (vector bool char); 12989vector signed short vec_vupkhsb (vector signed char); 12990 12991vector signed short vec_unpackl (vector signed char); 12992vector bool short vec_unpackl (vector bool char); 12993vector unsigned int vec_unpackl (vector pixel); 12994vector signed int vec_unpackl (vector signed short); 12995vector bool int vec_unpackl (vector bool short); 12996 12997vector unsigned int vec_vupklpx (vector pixel); 12998 12999vector bool int vec_vupklsh (vector bool short); 13000vector signed int vec_vupklsh (vector signed short); 13001 13002vector bool short vec_vupklsb (vector bool char); 13003vector signed short vec_vupklsb (vector signed char); 13004 13005vector float vec_xor (vector float, vector float); 13006vector float vec_xor (vector float, vector bool int); 13007vector float vec_xor (vector bool int, vector float); 13008vector bool int vec_xor (vector bool int, vector bool int); 13009vector signed int vec_xor (vector bool int, vector signed int); 13010vector signed int vec_xor (vector signed int, vector bool int); 13011vector signed int vec_xor (vector signed int, vector signed int); 13012vector unsigned int vec_xor (vector bool int, vector unsigned int); 13013vector unsigned int vec_xor (vector unsigned int, vector bool int); 13014vector unsigned int vec_xor (vector unsigned int, vector unsigned int); 13015vector bool short vec_xor (vector bool short, vector bool short); 13016vector signed short vec_xor (vector bool short, vector signed short); 13017vector signed short vec_xor (vector signed short, vector bool short); 13018vector signed short vec_xor (vector signed short, vector signed short); 13019vector unsigned short vec_xor (vector bool short, 13020 vector unsigned short); 13021vector unsigned short vec_xor (vector unsigned short, 13022 vector bool short); 13023vector unsigned short vec_xor (vector unsigned short, 13024 vector unsigned short); 13025vector signed char vec_xor (vector bool char, vector signed char); 13026vector bool char vec_xor (vector bool char, vector bool char); 13027vector signed char vec_xor (vector signed char, vector bool char); 13028vector signed char vec_xor (vector signed char, vector signed char); 13029vector unsigned char vec_xor (vector bool char, vector unsigned char); 13030vector unsigned char vec_xor (vector unsigned char, vector bool char); 13031vector unsigned char vec_xor (vector unsigned char, 13032 vector unsigned char); 13033 13034int vec_all_eq (vector signed char, vector bool char); 13035int vec_all_eq (vector signed char, vector signed char); 13036int vec_all_eq (vector unsigned char, vector bool char); 13037int vec_all_eq (vector unsigned char, vector unsigned char); 13038int vec_all_eq (vector bool char, vector bool char); 13039int vec_all_eq (vector bool char, vector unsigned char); 13040int vec_all_eq (vector bool char, vector signed char); 13041int vec_all_eq (vector signed short, vector bool short); 13042int vec_all_eq (vector signed short, vector signed short); 13043int vec_all_eq (vector unsigned short, vector bool short); 13044int vec_all_eq (vector unsigned short, vector unsigned short); 13045int vec_all_eq (vector bool short, vector bool short); 13046int vec_all_eq (vector bool short, vector unsigned short); 13047int vec_all_eq (vector bool short, vector signed short); 13048int vec_all_eq (vector pixel, vector pixel); 13049int vec_all_eq (vector signed int, vector bool int); 13050int vec_all_eq (vector signed int, vector signed int); 13051int vec_all_eq (vector unsigned int, vector bool int); 13052int vec_all_eq (vector unsigned int, vector unsigned int); 13053int vec_all_eq (vector bool int, vector bool int); 13054int vec_all_eq (vector bool int, vector unsigned int); 13055int vec_all_eq (vector bool int, vector signed int); 13056int vec_all_eq (vector float, vector float); 13057 13058int vec_all_ge (vector bool char, vector unsigned char); 13059int vec_all_ge (vector unsigned char, vector bool char); 13060int vec_all_ge (vector unsigned char, vector unsigned char); 13061int vec_all_ge (vector bool char, vector signed char); 13062int vec_all_ge (vector signed char, vector bool char); 13063int vec_all_ge (vector signed char, vector signed char); 13064int vec_all_ge (vector bool short, vector unsigned short); 13065int vec_all_ge (vector unsigned short, vector bool short); 13066int vec_all_ge (vector unsigned short, vector unsigned short); 13067int vec_all_ge (vector signed short, vector signed short); 13068int vec_all_ge (vector bool short, vector signed short); 13069int vec_all_ge (vector signed short, vector bool short); 13070int vec_all_ge (vector bool int, vector unsigned int); 13071int vec_all_ge (vector unsigned int, vector bool int); 13072int vec_all_ge (vector unsigned int, vector unsigned int); 13073int vec_all_ge (vector bool int, vector signed int); 13074int vec_all_ge (vector signed int, vector bool int); 13075int vec_all_ge (vector signed int, vector signed int); 13076int vec_all_ge (vector float, vector float); 13077 13078int vec_all_gt (vector bool char, vector unsigned char); 13079int vec_all_gt (vector unsigned char, vector bool char); 13080int vec_all_gt (vector unsigned char, vector unsigned char); 13081int vec_all_gt (vector bool char, vector signed char); 13082int vec_all_gt (vector signed char, vector bool char); 13083int vec_all_gt (vector signed char, vector signed char); 13084int vec_all_gt (vector bool short, vector unsigned short); 13085int vec_all_gt (vector unsigned short, vector bool short); 13086int vec_all_gt (vector unsigned short, vector unsigned short); 13087int vec_all_gt (vector bool short, vector signed short); 13088int vec_all_gt (vector signed short, vector bool short); 13089int vec_all_gt (vector signed short, vector signed short); 13090int vec_all_gt (vector bool int, vector unsigned int); 13091int vec_all_gt (vector unsigned int, vector bool int); 13092int vec_all_gt (vector unsigned int, vector unsigned int); 13093int vec_all_gt (vector bool int, vector signed int); 13094int vec_all_gt (vector signed int, vector bool int); 13095int vec_all_gt (vector signed int, vector signed int); 13096int vec_all_gt (vector float, vector float); 13097 13098int vec_all_in (vector float, vector float); 13099 13100int vec_all_le (vector bool char, vector unsigned char); 13101int vec_all_le (vector unsigned char, vector bool char); 13102int vec_all_le (vector unsigned char, vector unsigned char); 13103int vec_all_le (vector bool char, vector signed char); 13104int vec_all_le (vector signed char, vector bool char); 13105int vec_all_le (vector signed char, vector signed char); 13106int vec_all_le (vector bool short, vector unsigned short); 13107int vec_all_le (vector unsigned short, vector bool short); 13108int vec_all_le (vector unsigned short, vector unsigned short); 13109int vec_all_le (vector bool short, vector signed short); 13110int vec_all_le (vector signed short, vector bool short); 13111int vec_all_le (vector signed short, vector signed short); 13112int vec_all_le (vector bool int, vector unsigned int); 13113int vec_all_le (vector unsigned int, vector bool int); 13114int vec_all_le (vector unsigned int, vector unsigned int); 13115int vec_all_le (vector bool int, vector signed int); 13116int vec_all_le (vector signed int, vector bool int); 13117int vec_all_le (vector signed int, vector signed int); 13118int vec_all_le (vector float, vector float); 13119 13120int vec_all_lt (vector bool char, vector unsigned char); 13121int vec_all_lt (vector unsigned char, vector bool char); 13122int vec_all_lt (vector unsigned char, vector unsigned char); 13123int vec_all_lt (vector bool char, vector signed char); 13124int vec_all_lt (vector signed char, vector bool char); 13125int vec_all_lt (vector signed char, vector signed char); 13126int vec_all_lt (vector bool short, vector unsigned short); 13127int vec_all_lt (vector unsigned short, vector bool short); 13128int vec_all_lt (vector unsigned short, vector unsigned short); 13129int vec_all_lt (vector bool short, vector signed short); 13130int vec_all_lt (vector signed short, vector bool short); 13131int vec_all_lt (vector signed short, vector signed short); 13132int vec_all_lt (vector bool int, vector unsigned int); 13133int vec_all_lt (vector unsigned int, vector bool int); 13134int vec_all_lt (vector unsigned int, vector unsigned int); 13135int vec_all_lt (vector bool int, vector signed int); 13136int vec_all_lt (vector signed int, vector bool int); 13137int vec_all_lt (vector signed int, vector signed int); 13138int vec_all_lt (vector float, vector float); 13139 13140int vec_all_nan (vector float); 13141 13142int vec_all_ne (vector signed char, vector bool char); 13143int vec_all_ne (vector signed char, vector signed char); 13144int vec_all_ne (vector unsigned char, vector bool char); 13145int vec_all_ne (vector unsigned char, vector unsigned char); 13146int vec_all_ne (vector bool char, vector bool char); 13147int vec_all_ne (vector bool char, vector unsigned char); 13148int vec_all_ne (vector bool char, vector signed char); 13149int vec_all_ne (vector signed short, vector bool short); 13150int vec_all_ne (vector signed short, vector signed short); 13151int vec_all_ne (vector unsigned short, vector bool short); 13152int vec_all_ne (vector unsigned short, vector unsigned short); 13153int vec_all_ne (vector bool short, vector bool short); 13154int vec_all_ne (vector bool short, vector unsigned short); 13155int vec_all_ne (vector bool short, vector signed short); 13156int vec_all_ne (vector pixel, vector pixel); 13157int vec_all_ne (vector signed int, vector bool int); 13158int vec_all_ne (vector signed int, vector signed int); 13159int vec_all_ne (vector unsigned int, vector bool int); 13160int vec_all_ne (vector unsigned int, vector unsigned int); 13161int vec_all_ne (vector bool int, vector bool int); 13162int vec_all_ne (vector bool int, vector unsigned int); 13163int vec_all_ne (vector bool int, vector signed int); 13164int vec_all_ne (vector float, vector float); 13165 13166int vec_all_nge (vector float, vector float); 13167 13168int vec_all_ngt (vector float, vector float); 13169 13170int vec_all_nle (vector float, vector float); 13171 13172int vec_all_nlt (vector float, vector float); 13173 13174int vec_all_numeric (vector float); 13175 13176int vec_any_eq (vector signed char, vector bool char); 13177int vec_any_eq (vector signed char, vector signed char); 13178int vec_any_eq (vector unsigned char, vector bool char); 13179int vec_any_eq (vector unsigned char, vector unsigned char); 13180int vec_any_eq (vector bool char, vector bool char); 13181int vec_any_eq (vector bool char, vector unsigned char); 13182int vec_any_eq (vector bool char, vector signed char); 13183int vec_any_eq (vector signed short, vector bool short); 13184int vec_any_eq (vector signed short, vector signed short); 13185int vec_any_eq (vector unsigned short, vector bool short); 13186int vec_any_eq (vector unsigned short, vector unsigned short); 13187int vec_any_eq (vector bool short, vector bool short); 13188int vec_any_eq (vector bool short, vector unsigned short); 13189int vec_any_eq (vector bool short, vector signed short); 13190int vec_any_eq (vector pixel, vector pixel); 13191int vec_any_eq (vector signed int, vector bool int); 13192int vec_any_eq (vector signed int, vector signed int); 13193int vec_any_eq (vector unsigned int, vector bool int); 13194int vec_any_eq (vector unsigned int, vector unsigned int); 13195int vec_any_eq (vector bool int, vector bool int); 13196int vec_any_eq (vector bool int, vector unsigned int); 13197int vec_any_eq (vector bool int, vector signed int); 13198int vec_any_eq (vector float, vector float); 13199 13200int vec_any_ge (vector signed char, vector bool char); 13201int vec_any_ge (vector unsigned char, vector bool char); 13202int vec_any_ge (vector unsigned char, vector unsigned char); 13203int vec_any_ge (vector signed char, vector signed char); 13204int vec_any_ge (vector bool char, vector unsigned char); 13205int vec_any_ge (vector bool char, vector signed char); 13206int vec_any_ge (vector unsigned short, vector bool short); 13207int vec_any_ge (vector unsigned short, vector unsigned short); 13208int vec_any_ge (vector signed short, vector signed short); 13209int vec_any_ge (vector signed short, vector bool short); 13210int vec_any_ge (vector bool short, vector unsigned short); 13211int vec_any_ge (vector bool short, vector signed short); 13212int vec_any_ge (vector signed int, vector bool int); 13213int vec_any_ge (vector unsigned int, vector bool int); 13214int vec_any_ge (vector unsigned int, vector unsigned int); 13215int vec_any_ge (vector signed int, vector signed int); 13216int vec_any_ge (vector bool int, vector unsigned int); 13217int vec_any_ge (vector bool int, vector signed int); 13218int vec_any_ge (vector float, vector float); 13219 13220int vec_any_gt (vector bool char, vector unsigned char); 13221int vec_any_gt (vector unsigned char, vector bool char); 13222int vec_any_gt (vector unsigned char, vector unsigned char); 13223int vec_any_gt (vector bool char, vector signed char); 13224int vec_any_gt (vector signed char, vector bool char); 13225int vec_any_gt (vector signed char, vector signed char); 13226int vec_any_gt (vector bool short, vector unsigned short); 13227int vec_any_gt (vector unsigned short, vector bool short); 13228int vec_any_gt (vector unsigned short, vector unsigned short); 13229int vec_any_gt (vector bool short, vector signed short); 13230int vec_any_gt (vector signed short, vector bool short); 13231int vec_any_gt (vector signed short, vector signed short); 13232int vec_any_gt (vector bool int, vector unsigned int); 13233int vec_any_gt (vector unsigned int, vector bool int); 13234int vec_any_gt (vector unsigned int, vector unsigned int); 13235int vec_any_gt (vector bool int, vector signed int); 13236int vec_any_gt (vector signed int, vector bool int); 13237int vec_any_gt (vector signed int, vector signed int); 13238int vec_any_gt (vector float, vector float); 13239 13240int vec_any_le (vector bool char, vector unsigned char); 13241int vec_any_le (vector unsigned char, vector bool char); 13242int vec_any_le (vector unsigned char, vector unsigned char); 13243int vec_any_le (vector bool char, vector signed char); 13244int vec_any_le (vector signed char, vector bool char); 13245int vec_any_le (vector signed char, vector signed char); 13246int vec_any_le (vector bool short, vector unsigned short); 13247int vec_any_le (vector unsigned short, vector bool short); 13248int vec_any_le (vector unsigned short, vector unsigned short); 13249int vec_any_le (vector bool short, vector signed short); 13250int vec_any_le (vector signed short, vector bool short); 13251int vec_any_le (vector signed short, vector signed short); 13252int vec_any_le (vector bool int, vector unsigned int); 13253int vec_any_le (vector unsigned int, vector bool int); 13254int vec_any_le (vector unsigned int, vector unsigned int); 13255int vec_any_le (vector bool int, vector signed int); 13256int vec_any_le (vector signed int, vector bool int); 13257int vec_any_le (vector signed int, vector signed int); 13258int vec_any_le (vector float, vector float); 13259 13260int vec_any_lt (vector bool char, vector unsigned char); 13261int vec_any_lt (vector unsigned char, vector bool char); 13262int vec_any_lt (vector unsigned char, vector unsigned char); 13263int vec_any_lt (vector bool char, vector signed char); 13264int vec_any_lt (vector signed char, vector bool char); 13265int vec_any_lt (vector signed char, vector signed char); 13266int vec_any_lt (vector bool short, vector unsigned short); 13267int vec_any_lt (vector unsigned short, vector bool short); 13268int vec_any_lt (vector unsigned short, vector unsigned short); 13269int vec_any_lt (vector bool short, vector signed short); 13270int vec_any_lt (vector signed short, vector bool short); 13271int vec_any_lt (vector signed short, vector signed short); 13272int vec_any_lt (vector bool int, vector unsigned int); 13273int vec_any_lt (vector unsigned int, vector bool int); 13274int vec_any_lt (vector unsigned int, vector unsigned int); 13275int vec_any_lt (vector bool int, vector signed int); 13276int vec_any_lt (vector signed int, vector bool int); 13277int vec_any_lt (vector signed int, vector signed int); 13278int vec_any_lt (vector float, vector float); 13279 13280int vec_any_nan (vector float); 13281 13282int vec_any_ne (vector signed char, vector bool char); 13283int vec_any_ne (vector signed char, vector signed char); 13284int vec_any_ne (vector unsigned char, vector bool char); 13285int vec_any_ne (vector unsigned char, vector unsigned char); 13286int vec_any_ne (vector bool char, vector bool char); 13287int vec_any_ne (vector bool char, vector unsigned char); 13288int vec_any_ne (vector bool char, vector signed char); 13289int vec_any_ne (vector signed short, vector bool short); 13290int vec_any_ne (vector signed short, vector signed short); 13291int vec_any_ne (vector unsigned short, vector bool short); 13292int vec_any_ne (vector unsigned short, vector unsigned short); 13293int vec_any_ne (vector bool short, vector bool short); 13294int vec_any_ne (vector bool short, vector unsigned short); 13295int vec_any_ne (vector bool short, vector signed short); 13296int vec_any_ne (vector pixel, vector pixel); 13297int vec_any_ne (vector signed int, vector bool int); 13298int vec_any_ne (vector signed int, vector signed int); 13299int vec_any_ne (vector unsigned int, vector bool int); 13300int vec_any_ne (vector unsigned int, vector unsigned int); 13301int vec_any_ne (vector bool int, vector bool int); 13302int vec_any_ne (vector bool int, vector unsigned int); 13303int vec_any_ne (vector bool int, vector signed int); 13304int vec_any_ne (vector float, vector float); 13305 13306int vec_any_nge (vector float, vector float); 13307 13308int vec_any_ngt (vector float, vector float); 13309 13310int vec_any_nle (vector float, vector float); 13311 13312int vec_any_nlt (vector float, vector float); 13313 13314int vec_any_numeric (vector float); 13315 13316int vec_any_out (vector float, vector float); 13317@end smallexample 13318 13319If the vector/scalar (VSX) instruction set is available, the following 13320additional functions are available: 13321 13322@smallexample 13323vector double vec_abs (vector double); 13324vector double vec_add (vector double, vector double); 13325vector double vec_and (vector double, vector double); 13326vector double vec_and (vector double, vector bool long); 13327vector double vec_and (vector bool long, vector double); 13328vector double vec_andc (vector double, vector double); 13329vector double vec_andc (vector double, vector bool long); 13330vector double vec_andc (vector bool long, vector double); 13331vector double vec_ceil (vector double); 13332vector bool long vec_cmpeq (vector double, vector double); 13333vector bool long vec_cmpge (vector double, vector double); 13334vector bool long vec_cmpgt (vector double, vector double); 13335vector bool long vec_cmple (vector double, vector double); 13336vector bool long vec_cmplt (vector double, vector double); 13337vector float vec_div (vector float, vector float); 13338vector double vec_div (vector double, vector double); 13339vector double vec_floor (vector double); 13340vector double vec_ld (int, const vector double *); 13341vector double vec_ld (int, const double *); 13342vector double vec_ldl (int, const vector double *); 13343vector double vec_ldl (int, const double *); 13344vector unsigned char vec_lvsl (int, const volatile double *); 13345vector unsigned char vec_lvsr (int, const volatile double *); 13346vector double vec_madd (vector double, vector double, vector double); 13347vector double vec_max (vector double, vector double); 13348vector double vec_min (vector double, vector double); 13349vector float vec_msub (vector float, vector float, vector float); 13350vector double vec_msub (vector double, vector double, vector double); 13351vector float vec_mul (vector float, vector float); 13352vector double vec_mul (vector double, vector double); 13353vector float vec_nearbyint (vector float); 13354vector double vec_nearbyint (vector double); 13355vector float vec_nmadd (vector float, vector float, vector float); 13356vector double vec_nmadd (vector double, vector double, vector double); 13357vector double vec_nmsub (vector double, vector double, vector double); 13358vector double vec_nor (vector double, vector double); 13359vector double vec_or (vector double, vector double); 13360vector double vec_or (vector double, vector bool long); 13361vector double vec_or (vector bool long, vector double); 13362vector double vec_perm (vector double, 13363 vector double, 13364 vector unsigned char); 13365vector double vec_rint (vector double); 13366vector double vec_recip (vector double, vector double); 13367vector double vec_rsqrt (vector double); 13368vector double vec_rsqrte (vector double); 13369vector double vec_sel (vector double, vector double, vector bool long); 13370vector double vec_sel (vector double, vector double, vector unsigned long); 13371vector double vec_sub (vector double, vector double); 13372vector float vec_sqrt (vector float); 13373vector double vec_sqrt (vector double); 13374void vec_st (vector double, int, vector double *); 13375void vec_st (vector double, int, double *); 13376vector double vec_trunc (vector double); 13377vector double vec_xor (vector double, vector double); 13378vector double vec_xor (vector double, vector bool long); 13379vector double vec_xor (vector bool long, vector double); 13380int vec_all_eq (vector double, vector double); 13381int vec_all_ge (vector double, vector double); 13382int vec_all_gt (vector double, vector double); 13383int vec_all_le (vector double, vector double); 13384int vec_all_lt (vector double, vector double); 13385int vec_all_nan (vector double); 13386int vec_all_ne (vector double, vector double); 13387int vec_all_nge (vector double, vector double); 13388int vec_all_ngt (vector double, vector double); 13389int vec_all_nle (vector double, vector double); 13390int vec_all_nlt (vector double, vector double); 13391int vec_all_numeric (vector double); 13392int vec_any_eq (vector double, vector double); 13393int vec_any_ge (vector double, vector double); 13394int vec_any_gt (vector double, vector double); 13395int vec_any_le (vector double, vector double); 13396int vec_any_lt (vector double, vector double); 13397int vec_any_nan (vector double); 13398int vec_any_ne (vector double, vector double); 13399int vec_any_nge (vector double, vector double); 13400int vec_any_ngt (vector double, vector double); 13401int vec_any_nle (vector double, vector double); 13402int vec_any_nlt (vector double, vector double); 13403int vec_any_numeric (vector double); 13404 13405vector double vec_vsx_ld (int, const vector double *); 13406vector double vec_vsx_ld (int, const double *); 13407vector float vec_vsx_ld (int, const vector float *); 13408vector float vec_vsx_ld (int, const float *); 13409vector bool int vec_vsx_ld (int, const vector bool int *); 13410vector signed int vec_vsx_ld (int, const vector signed int *); 13411vector signed int vec_vsx_ld (int, const int *); 13412vector signed int vec_vsx_ld (int, const long *); 13413vector unsigned int vec_vsx_ld (int, const vector unsigned int *); 13414vector unsigned int vec_vsx_ld (int, const unsigned int *); 13415vector unsigned int vec_vsx_ld (int, const unsigned long *); 13416vector bool short vec_vsx_ld (int, const vector bool short *); 13417vector pixel vec_vsx_ld (int, const vector pixel *); 13418vector signed short vec_vsx_ld (int, const vector signed short *); 13419vector signed short vec_vsx_ld (int, const short *); 13420vector unsigned short vec_vsx_ld (int, const vector unsigned short *); 13421vector unsigned short vec_vsx_ld (int, const unsigned short *); 13422vector bool char vec_vsx_ld (int, const vector bool char *); 13423vector signed char vec_vsx_ld (int, const vector signed char *); 13424vector signed char vec_vsx_ld (int, const signed char *); 13425vector unsigned char vec_vsx_ld (int, const vector unsigned char *); 13426vector unsigned char vec_vsx_ld (int, const unsigned char *); 13427 13428void vec_vsx_st (vector double, int, vector double *); 13429void vec_vsx_st (vector double, int, double *); 13430void vec_vsx_st (vector float, int, vector float *); 13431void vec_vsx_st (vector float, int, float *); 13432void vec_vsx_st (vector signed int, int, vector signed int *); 13433void vec_vsx_st (vector signed int, int, int *); 13434void vec_vsx_st (vector unsigned int, int, vector unsigned int *); 13435void vec_vsx_st (vector unsigned int, int, unsigned int *); 13436void vec_vsx_st (vector bool int, int, vector bool int *); 13437void vec_vsx_st (vector bool int, int, unsigned int *); 13438void vec_vsx_st (vector bool int, int, int *); 13439void vec_vsx_st (vector signed short, int, vector signed short *); 13440void vec_vsx_st (vector signed short, int, short *); 13441void vec_vsx_st (vector unsigned short, int, vector unsigned short *); 13442void vec_vsx_st (vector unsigned short, int, unsigned short *); 13443void vec_vsx_st (vector bool short, int, vector bool short *); 13444void vec_vsx_st (vector bool short, int, unsigned short *); 13445void vec_vsx_st (vector pixel, int, vector pixel *); 13446void vec_vsx_st (vector pixel, int, unsigned short *); 13447void vec_vsx_st (vector pixel, int, short *); 13448void vec_vsx_st (vector bool short, int, short *); 13449void vec_vsx_st (vector signed char, int, vector signed char *); 13450void vec_vsx_st (vector signed char, int, signed char *); 13451void vec_vsx_st (vector unsigned char, int, vector unsigned char *); 13452void vec_vsx_st (vector unsigned char, int, unsigned char *); 13453void vec_vsx_st (vector bool char, int, vector bool char *); 13454void vec_vsx_st (vector bool char, int, unsigned char *); 13455void vec_vsx_st (vector bool char, int, signed char *); 13456@end smallexample 13457 13458Note that the @samp{vec_ld} and @samp{vec_st} builtins will always 13459generate the Altivec @samp{LVX} and @samp{STVX} instructions even 13460if the VSX instruction set is available. The @samp{vec_vsx_ld} and 13461@samp{vec_vsx_st} builtins will always generate the VSX @samp{LXVD2X}, 13462@samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions. 13463 13464GCC provides a few other builtins on Powerpc to access certain instructions: 13465@smallexample 13466float __builtin_recipdivf (float, float); 13467float __builtin_rsqrtf (float); 13468double __builtin_recipdiv (double, double); 13469double __builtin_rsqrt (double); 13470long __builtin_bpermd (long, long); 13471int __builtin_bswap16 (int); 13472@end smallexample 13473 13474The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and 13475@code{__builtin_rsqrtf} functions generate multiple instructions to 13476implement the reciprocal sqrt functionality using reciprocal sqrt 13477estimate instructions. 13478 13479The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf} 13480functions generate multiple instructions to implement division using 13481the reciprocal estimate instructions. 13482 13483@node RX Built-in Functions 13484@subsection RX Built-in Functions 13485GCC supports some of the RX instructions which cannot be expressed in 13486the C programming language via the use of built-in functions. The 13487following functions are supported: 13488 13489@deftypefn {Built-in Function} void __builtin_rx_brk (void) 13490Generates the @code{brk} machine instruction. 13491@end deftypefn 13492 13493@deftypefn {Built-in Function} void __builtin_rx_clrpsw (int) 13494Generates the @code{clrpsw} machine instruction to clear the specified 13495bit in the processor status word. 13496@end deftypefn 13497 13498@deftypefn {Built-in Function} void __builtin_rx_int (int) 13499Generates the @code{int} machine instruction to generate an interrupt 13500with the specified value. 13501@end deftypefn 13502 13503@deftypefn {Built-in Function} void __builtin_rx_machi (int, int) 13504Generates the @code{machi} machine instruction to add the result of 13505multiplying the top 16-bits of the two arguments into the 13506accumulator. 13507@end deftypefn 13508 13509@deftypefn {Built-in Function} void __builtin_rx_maclo (int, int) 13510Generates the @code{maclo} machine instruction to add the result of 13511multiplying the bottom 16-bits of the two arguments into the 13512accumulator. 13513@end deftypefn 13514 13515@deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int) 13516Generates the @code{mulhi} machine instruction to place the result of 13517multiplying the top 16-bits of the two arguments into the 13518accumulator. 13519@end deftypefn 13520 13521@deftypefn {Built-in Function} void __builtin_rx_mullo (int, int) 13522Generates the @code{mullo} machine instruction to place the result of 13523multiplying the bottom 16-bits of the two arguments into the 13524accumulator. 13525@end deftypefn 13526 13527@deftypefn {Built-in Function} int __builtin_rx_mvfachi (void) 13528Generates the @code{mvfachi} machine instruction to read the top 1352932-bits of the accumulator. 13530@end deftypefn 13531 13532@deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void) 13533Generates the @code{mvfacmi} machine instruction to read the middle 1353432-bits of the accumulator. 13535@end deftypefn 13536 13537@deftypefn {Built-in Function} int __builtin_rx_mvfc (int) 13538Generates the @code{mvfc} machine instruction which reads the control 13539register specified in its argument and returns its value. 13540@end deftypefn 13541 13542@deftypefn {Built-in Function} void __builtin_rx_mvtachi (int) 13543Generates the @code{mvtachi} machine instruction to set the top 1354432-bits of the accumulator. 13545@end deftypefn 13546 13547@deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int) 13548Generates the @code{mvtaclo} machine instruction to set the bottom 1354932-bits of the accumulator. 13550@end deftypefn 13551 13552@deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val) 13553Generates the @code{mvtc} machine instruction which sets control 13554register number @code{reg} to @code{val}. 13555@end deftypefn 13556 13557@deftypefn {Built-in Function} void __builtin_rx_mvtipl (int) 13558Generates the @code{mvtipl} machine instruction set the interrupt 13559priority level. 13560@end deftypefn 13561 13562@deftypefn {Built-in Function} void __builtin_rx_racw (int) 13563Generates the @code{racw} machine instruction to round the accumulator 13564according to the specified mode. 13565@end deftypefn 13566 13567@deftypefn {Built-in Function} int __builtin_rx_revw (int) 13568Generates the @code{revw} machine instruction which swaps the bytes in 13569the argument so that bits 0--7 now occupy bits 8--15 and vice versa, 13570and also bits 16--23 occupy bits 24--31 and vice versa. 13571@end deftypefn 13572 13573@deftypefn {Built-in Function} void __builtin_rx_rmpa (void) 13574Generates the @code{rmpa} machine instruction which initiates a 13575repeated multiply and accumulate sequence. 13576@end deftypefn 13577 13578@deftypefn {Built-in Function} void __builtin_rx_round (float) 13579Generates the @code{round} machine instruction which returns the 13580floating point argument rounded according to the current rounding mode 13581set in the floating point status word register. 13582@end deftypefn 13583 13584@deftypefn {Built-in Function} int __builtin_rx_sat (int) 13585Generates the @code{sat} machine instruction which returns the 13586saturated value of the argument. 13587@end deftypefn 13588 13589@deftypefn {Built-in Function} void __builtin_rx_setpsw (int) 13590Generates the @code{setpsw} machine instruction to set the specified 13591bit in the processor status word. 13592@end deftypefn 13593 13594@deftypefn {Built-in Function} void __builtin_rx_wait (void) 13595Generates the @code{wait} machine instruction. 13596@end deftypefn 13597 13598@node SPARC VIS Built-in Functions 13599@subsection SPARC VIS Built-in Functions 13600 13601GCC supports SIMD operations on the SPARC using both the generic vector 13602extensions (@pxref{Vector Extensions}) as well as built-in functions for 13603the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis} 13604switch, the VIS extension is exposed as the following built-in functions: 13605 13606@smallexample 13607typedef int v1si __attribute__ ((vector_size (4))); 13608typedef int v2si __attribute__ ((vector_size (8))); 13609typedef short v4hi __attribute__ ((vector_size (8))); 13610typedef short v2hi __attribute__ ((vector_size (4))); 13611typedef unsigned char v8qi __attribute__ ((vector_size (8))); 13612typedef unsigned char v4qi __attribute__ ((vector_size (4))); 13613 13614void __builtin_vis_write_gsr (int64_t); 13615int64_t __builtin_vis_read_gsr (void); 13616 13617void * __builtin_vis_alignaddr (void *, long); 13618void * __builtin_vis_alignaddrl (void *, long); 13619int64_t __builtin_vis_faligndatadi (int64_t, int64_t); 13620v2si __builtin_vis_faligndatav2si (v2si, v2si); 13621v4hi __builtin_vis_faligndatav4hi (v4si, v4si); 13622v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi); 13623 13624v4hi __builtin_vis_fexpand (v4qi); 13625 13626v4hi __builtin_vis_fmul8x16 (v4qi, v4hi); 13627v4hi __builtin_vis_fmul8x16au (v4qi, v2hi); 13628v4hi __builtin_vis_fmul8x16al (v4qi, v2hi); 13629v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi); 13630v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi); 13631v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi); 13632v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi); 13633 13634v4qi __builtin_vis_fpack16 (v4hi); 13635v8qi __builtin_vis_fpack32 (v2si, v8qi); 13636v2hi __builtin_vis_fpackfix (v2si); 13637v8qi __builtin_vis_fpmerge (v4qi, v4qi); 13638 13639int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t); 13640 13641long __builtin_vis_edge8 (void *, void *); 13642long __builtin_vis_edge8l (void *, void *); 13643long __builtin_vis_edge16 (void *, void *); 13644long __builtin_vis_edge16l (void *, void *); 13645long __builtin_vis_edge32 (void *, void *); 13646long __builtin_vis_edge32l (void *, void *); 13647 13648long __builtin_vis_fcmple16 (v4hi, v4hi); 13649long __builtin_vis_fcmple32 (v2si, v2si); 13650long __builtin_vis_fcmpne16 (v4hi, v4hi); 13651long __builtin_vis_fcmpne32 (v2si, v2si); 13652long __builtin_vis_fcmpgt16 (v4hi, v4hi); 13653long __builtin_vis_fcmpgt32 (v2si, v2si); 13654long __builtin_vis_fcmpeq16 (v4hi, v4hi); 13655long __builtin_vis_fcmpeq32 (v2si, v2si); 13656 13657v4hi __builtin_vis_fpadd16 (v4hi, v4hi); 13658v2hi __builtin_vis_fpadd16s (v2hi, v2hi); 13659v2si __builtin_vis_fpadd32 (v2si, v2si); 13660v1si __builtin_vis_fpadd32s (v1si, v1si); 13661v4hi __builtin_vis_fpsub16 (v4hi, v4hi); 13662v2hi __builtin_vis_fpsub16s (v2hi, v2hi); 13663v2si __builtin_vis_fpsub32 (v2si, v2si); 13664v1si __builtin_vis_fpsub32s (v1si, v1si); 13665 13666long __builtin_vis_array8 (long, long); 13667long __builtin_vis_array16 (long, long); 13668long __builtin_vis_array32 (long, long); 13669@end smallexample 13670 13671When you use the @option{-mvis2} switch, the VIS version 2.0 built-in 13672functions also become available: 13673 13674@smallexample 13675long __builtin_vis_bmask (long, long); 13676int64_t __builtin_vis_bshuffledi (int64_t, int64_t); 13677v2si __builtin_vis_bshufflev2si (v2si, v2si); 13678v4hi __builtin_vis_bshufflev2si (v4hi, v4hi); 13679v8qi __builtin_vis_bshufflev2si (v8qi, v8qi); 13680 13681long __builtin_vis_edge8n (void *, void *); 13682long __builtin_vis_edge8ln (void *, void *); 13683long __builtin_vis_edge16n (void *, void *); 13684long __builtin_vis_edge16ln (void *, void *); 13685long __builtin_vis_edge32n (void *, void *); 13686long __builtin_vis_edge32ln (void *, void *); 13687@end smallexample 13688 13689When you use the @option{-mvis3} switch, the VIS version 3.0 built-in 13690functions also become available: 13691 13692@smallexample 13693void __builtin_vis_cmask8 (long); 13694void __builtin_vis_cmask16 (long); 13695void __builtin_vis_cmask32 (long); 13696 13697v4hi __builtin_vis_fchksm16 (v4hi, v4hi); 13698 13699v4hi __builtin_vis_fsll16 (v4hi, v4hi); 13700v4hi __builtin_vis_fslas16 (v4hi, v4hi); 13701v4hi __builtin_vis_fsrl16 (v4hi, v4hi); 13702v4hi __builtin_vis_fsra16 (v4hi, v4hi); 13703v2si __builtin_vis_fsll16 (v2si, v2si); 13704v2si __builtin_vis_fslas16 (v2si, v2si); 13705v2si __builtin_vis_fsrl16 (v2si, v2si); 13706v2si __builtin_vis_fsra16 (v2si, v2si); 13707 13708long __builtin_vis_pdistn (v8qi, v8qi); 13709 13710v4hi __builtin_vis_fmean16 (v4hi, v4hi); 13711 13712int64_t __builtin_vis_fpadd64 (int64_t, int64_t); 13713int64_t __builtin_vis_fpsub64 (int64_t, int64_t); 13714 13715v4hi __builtin_vis_fpadds16 (v4hi, v4hi); 13716v2hi __builtin_vis_fpadds16s (v2hi, v2hi); 13717v4hi __builtin_vis_fpsubs16 (v4hi, v4hi); 13718v2hi __builtin_vis_fpsubs16s (v2hi, v2hi); 13719v2si __builtin_vis_fpadds32 (v2si, v2si); 13720v1si __builtin_vis_fpadds32s (v1si, v1si); 13721v2si __builtin_vis_fpsubs32 (v2si, v2si); 13722v1si __builtin_vis_fpsubs32s (v1si, v1si); 13723 13724long __builtin_vis_fucmple8 (v8qi, v8qi); 13725long __builtin_vis_fucmpne8 (v8qi, v8qi); 13726long __builtin_vis_fucmpgt8 (v8qi, v8qi); 13727long __builtin_vis_fucmpeq8 (v8qi, v8qi); 13728 13729float __builtin_vis_fhadds (float, float); 13730double __builtin_vis_fhaddd (double, double); 13731float __builtin_vis_fhsubs (float, float); 13732double __builtin_vis_fhsubd (double, double); 13733float __builtin_vis_fnhadds (float, float); 13734double __builtin_vis_fnhaddd (double, double); 13735 13736int64_t __builtin_vis_umulxhi (int64_t, int64_t); 13737int64_t __builtin_vis_xmulx (int64_t, int64_t); 13738int64_t __builtin_vis_xmulxhi (int64_t, int64_t); 13739@end smallexample 13740 13741@node SPU Built-in Functions 13742@subsection SPU Built-in Functions 13743 13744GCC provides extensions for the SPU processor as described in the 13745Sony/Toshiba/IBM SPU Language Extensions Specification, which can be 13746found at @uref{http://cell.scei.co.jp/} or 13747@uref{http://www.ibm.com/developerworks/power/cell/}. GCC's 13748implementation differs in several ways. 13749 13750@itemize @bullet 13751 13752@item 13753The optional extension of specifying vector constants in parentheses is 13754not supported. 13755 13756@item 13757A vector initializer requires no cast if the vector constant is of the 13758same type as the variable it is initializing. 13759 13760@item 13761If @code{signed} or @code{unsigned} is omitted, the signedness of the 13762vector type is the default signedness of the base type. The default 13763varies depending on the operating system, so a portable program should 13764always specify the signedness. 13765 13766@item 13767By default, the keyword @code{__vector} is added. The macro 13768@code{vector} is defined in @code{<spu_intrinsics.h>} and can be 13769undefined. 13770 13771@item 13772GCC allows using a @code{typedef} name as the type specifier for a 13773vector type. 13774 13775@item 13776For C, overloaded functions are implemented with macros so the following 13777does not work: 13778 13779@smallexample 13780 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo); 13781@end smallexample 13782 13783Since @code{spu_add} is a macro, the vector constant in the example 13784is treated as four separate arguments. Wrap the entire argument in 13785parentheses for this to work. 13786 13787@item 13788The extended version of @code{__builtin_expect} is not supported. 13789 13790@end itemize 13791 13792@emph{Note:} Only the interface described in the aforementioned 13793specification is supported. Internally, GCC uses built-in functions to 13794implement the required functionality, but these are not supported and 13795are subject to change without notice. 13796 13797@node TI C6X Built-in Functions 13798@subsection TI C6X Built-in Functions 13799 13800GCC provides intrinsics to access certain instructions of the TI C6X 13801processors. These intrinsics, listed below, are available after 13802inclusion of the @code{c6x_intrinsics.h} header file. They map directly 13803to C6X instructions. 13804 13805@smallexample 13806 13807int _sadd (int, int) 13808int _ssub (int, int) 13809int _sadd2 (int, int) 13810int _ssub2 (int, int) 13811long long _mpy2 (int, int) 13812long long _smpy2 (int, int) 13813int _add4 (int, int) 13814int _sub4 (int, int) 13815int _saddu4 (int, int) 13816 13817int _smpy (int, int) 13818int _smpyh (int, int) 13819int _smpyhl (int, int) 13820int _smpylh (int, int) 13821 13822int _sshl (int, int) 13823int _subc (int, int) 13824 13825int _avg2 (int, int) 13826int _avgu4 (int, int) 13827 13828int _clrr (int, int) 13829int _extr (int, int) 13830int _extru (int, int) 13831int _abs (int) 13832int _abs2 (int) 13833 13834@end smallexample 13835 13836@node TILE-Gx Built-in Functions 13837@subsection TILE-Gx Built-in Functions 13838 13839GCC provides intrinsics to access every instruction of the TILE-Gx 13840processor. The intrinsics are of the form: 13841 13842@smallexample 13843 13844unsigned long long __insn_@var{op} (...) 13845 13846@end smallexample 13847 13848Where @var{op} is the name of the instruction. Refer to the ISA manual 13849for the complete list of instructions. 13850 13851GCC also provides intrinsics to directly access the network registers. 13852The intrinsics are: 13853 13854@smallexample 13855 13856unsigned long long __tile_idn0_receive (void) 13857unsigned long long __tile_idn1_receive (void) 13858unsigned long long __tile_udn0_receive (void) 13859unsigned long long __tile_udn1_receive (void) 13860unsigned long long __tile_udn2_receive (void) 13861unsigned long long __tile_udn3_receive (void) 13862void __tile_idn_send (unsigned long long) 13863void __tile_udn_send (unsigned long long) 13864 13865@end smallexample 13866 13867The intrinsic @code{void __tile_network_barrier (void)} is used to 13868guarantee that no network operatons before it will be reordered with 13869those after it. 13870 13871@node TILEPro Built-in Functions 13872@subsection TILEPro Built-in Functions 13873 13874GCC provides intrinsics to access every instruction of the TILEPro 13875processor. The intrinsics are of the form: 13876 13877@smallexample 13878 13879unsigned __insn_@var{op} (...) 13880 13881@end smallexample 13882 13883Where @var{op} is the name of the instruction. Refer to the ISA manual 13884for the complete list of instructions. 13885 13886GCC also provides intrinsics to directly access the network registers. 13887The intrinsics are: 13888 13889@smallexample 13890 13891unsigned __tile_idn0_receive (void) 13892unsigned __tile_idn1_receive (void) 13893unsigned __tile_sn_receive (void) 13894unsigned __tile_udn0_receive (void) 13895unsigned __tile_udn1_receive (void) 13896unsigned __tile_udn2_receive (void) 13897unsigned __tile_udn3_receive (void) 13898void __tile_idn_send (unsigned) 13899void __tile_sn_send (unsigned) 13900void __tile_udn_send (unsigned) 13901 13902@end smallexample 13903 13904The intrinsic @code{void __tile_network_barrier (void)} is used to 13905guarantee that no network operatons before it will be reordered with 13906those after it. 13907 13908@node Target Format Checks 13909@section Format Checks Specific to Particular Target Machines 13910 13911For some target machines, GCC supports additional options to the 13912format attribute 13913(@pxref{Function Attributes,,Declaring Attributes of Functions}). 13914 13915@menu 13916* Solaris Format Checks:: 13917* Darwin Format Checks:: 13918@end menu 13919 13920@node Solaris Format Checks 13921@subsection Solaris Format Checks 13922 13923Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format 13924check. @code{cmn_err} accepts a subset of the standard @code{printf} 13925conversions, and the two-argument @code{%b} conversion for displaying 13926bit-fields. See the Solaris man page for @code{cmn_err} for more information. 13927 13928@node Darwin Format Checks 13929@subsection Darwin Format Checks 13930 13931Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format 13932attribute context. Declarations made with such attribution will be parsed for correct syntax 13933and format argument types. However, parsing of the format string itself is currently undefined 13934and will not be carried out by this version of the compiler. 13935 13936Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may 13937also be used as format arguments. Note that the relevant headers are only likely to be 13938available on Darwin (OSX) installations. On such installations, the XCode and system 13939documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and 13940associated functions. 13941 13942@node Pragmas 13943@section Pragmas Accepted by GCC 13944@cindex pragmas 13945@cindex @code{#pragma} 13946 13947GCC supports several types of pragmas, primarily in order to compile 13948code originally written for other compilers. Note that in general 13949we do not recommend the use of pragmas; @xref{Function Attributes}, 13950for further explanation. 13951 13952@menu 13953* ARM Pragmas:: 13954* M32C Pragmas:: 13955* MeP Pragmas:: 13956* RS/6000 and PowerPC Pragmas:: 13957* Darwin Pragmas:: 13958* Solaris Pragmas:: 13959* Symbol-Renaming Pragmas:: 13960* Structure-Packing Pragmas:: 13961* Weak Pragmas:: 13962* Diagnostic Pragmas:: 13963* Visibility Pragmas:: 13964* Push/Pop Macro Pragmas:: 13965* Function Specific Option Pragmas:: 13966@end menu 13967 13968@node ARM Pragmas 13969@subsection ARM Pragmas 13970 13971The ARM target defines pragmas for controlling the default addition of 13972@code{long_call} and @code{short_call} attributes to functions. 13973@xref{Function Attributes}, for information about the effects of these 13974attributes. 13975 13976@table @code 13977@item long_calls 13978@cindex pragma, long_calls 13979Set all subsequent functions to have the @code{long_call} attribute. 13980 13981@item no_long_calls 13982@cindex pragma, no_long_calls 13983Set all subsequent functions to have the @code{short_call} attribute. 13984 13985@item long_calls_off 13986@cindex pragma, long_calls_off 13987Do not affect the @code{long_call} or @code{short_call} attributes of 13988subsequent functions. 13989@end table 13990 13991@node M32C Pragmas 13992@subsection M32C Pragmas 13993 13994@table @code 13995@item GCC memregs @var{number} 13996@cindex pragma, memregs 13997Overrides the command-line option @code{-memregs=} for the current 13998file. Use with care! This pragma must be before any function in the 13999file, and mixing different memregs values in different objects may 14000make them incompatible. This pragma is useful when a 14001performance-critical function uses a memreg for temporary values, 14002as it may allow you to reduce the number of memregs used. 14003 14004@item ADDRESS @var{name} @var{address} 14005@cindex pragma, address 14006For any declared symbols matching @var{name}, this does three things 14007to that symbol: it forces the symbol to be located at the given 14008address (a number), it forces the symbol to be volatile, and it 14009changes the symbol's scope to be static. This pragma exists for 14010compatibility with other compilers, but note that the common 14011@code{1234H} numeric syntax is not supported (use @code{0x1234} 14012instead). Example: 14013 14014@example 14015#pragma ADDRESS port3 0x103 14016char port3; 14017@end example 14018 14019@end table 14020 14021@node MeP Pragmas 14022@subsection MeP Pragmas 14023 14024@table @code 14025 14026@item custom io_volatile (on|off) 14027@cindex pragma, custom io_volatile 14028Overrides the command line option @code{-mio-volatile} for the current 14029file. Note that for compatibility with future GCC releases, this 14030option should only be used once before any @code{io} variables in each 14031file. 14032 14033@item GCC coprocessor available @var{registers} 14034@cindex pragma, coprocessor available 14035Specifies which coprocessor registers are available to the register 14036allocator. @var{registers} may be a single register, register range 14037separated by ellipses, or comma-separated list of those. Example: 14038 14039@example 14040#pragma GCC coprocessor available $c0...$c10, $c28 14041@end example 14042 14043@item GCC coprocessor call_saved @var{registers} 14044@cindex pragma, coprocessor call_saved 14045Specifies which coprocessor registers are to be saved and restored by 14046any function using them. @var{registers} may be a single register, 14047register range separated by ellipses, or comma-separated list of 14048those. Example: 14049 14050@example 14051#pragma GCC coprocessor call_saved $c4...$c6, $c31 14052@end example 14053 14054@item GCC coprocessor subclass '(A|B|C|D)' = @var{registers} 14055@cindex pragma, coprocessor subclass 14056Creates and defines a register class. These register classes can be 14057used by inline @code{asm} constructs. @var{registers} may be a single 14058register, register range separated by ellipses, or comma-separated 14059list of those. Example: 14060 14061@example 14062#pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6 14063 14064asm ("cpfoo %0" : "=B" (x)); 14065@end example 14066 14067@item GCC disinterrupt @var{name} , @var{name} @dots{} 14068@cindex pragma, disinterrupt 14069For the named functions, the compiler adds code to disable interrupts 14070for the duration of those functions. Any functions so named, which 14071are not encountered in the source, cause a warning that the pragma was 14072not used. Examples: 14073 14074@example 14075#pragma disinterrupt foo 14076#pragma disinterrupt bar, grill 14077int foo () @{ @dots{} @} 14078@end example 14079 14080@item GCC call @var{name} , @var{name} @dots{} 14081@cindex pragma, call 14082For the named functions, the compiler always uses a register-indirect 14083call model when calling the named functions. Examples: 14084 14085@example 14086extern int foo (); 14087#pragma call foo 14088@end example 14089 14090@end table 14091 14092@node RS/6000 and PowerPC Pragmas 14093@subsection RS/6000 and PowerPC Pragmas 14094 14095The RS/6000 and PowerPC targets define one pragma for controlling 14096whether or not the @code{longcall} attribute is added to function 14097declarations by default. This pragma overrides the @option{-mlongcall} 14098option, but not the @code{longcall} and @code{shortcall} attributes. 14099@xref{RS/6000 and PowerPC Options}, for more information about when long 14100calls are and are not necessary. 14101 14102@table @code 14103@item longcall (1) 14104@cindex pragma, longcall 14105Apply the @code{longcall} attribute to all subsequent function 14106declarations. 14107 14108@item longcall (0) 14109Do not apply the @code{longcall} attribute to subsequent function 14110declarations. 14111@end table 14112 14113@c Describe h8300 pragmas here. 14114@c Describe sh pragmas here. 14115@c Describe v850 pragmas here. 14116 14117@node Darwin Pragmas 14118@subsection Darwin Pragmas 14119 14120The following pragmas are available for all architectures running the 14121Darwin operating system. These are useful for compatibility with other 14122Mac OS compilers. 14123 14124@table @code 14125@item mark @var{tokens}@dots{} 14126@cindex pragma, mark 14127This pragma is accepted, but has no effect. 14128 14129@item options align=@var{alignment} 14130@cindex pragma, options align 14131This pragma sets the alignment of fields in structures. The values of 14132@var{alignment} may be @code{mac68k}, to emulate m68k alignment, or 14133@code{power}, to emulate PowerPC alignment. Uses of this pragma nest 14134properly; to restore the previous setting, use @code{reset} for the 14135@var{alignment}. 14136 14137@item segment @var{tokens}@dots{} 14138@cindex pragma, segment 14139This pragma is accepted, but has no effect. 14140 14141@item unused (@var{var} [, @var{var}]@dots{}) 14142@cindex pragma, unused 14143This pragma declares variables to be possibly unused. GCC will not 14144produce warnings for the listed variables. The effect is similar to 14145that of the @code{unused} attribute, except that this pragma may appear 14146anywhere within the variables' scopes. 14147@end table 14148 14149@node Solaris Pragmas 14150@subsection Solaris Pragmas 14151 14152The Solaris target supports @code{#pragma redefine_extname} 14153(@pxref{Symbol-Renaming Pragmas}). It also supports additional 14154@code{#pragma} directives for compatibility with the system compiler. 14155 14156@table @code 14157@item align @var{alignment} (@var{variable} [, @var{variable}]...) 14158@cindex pragma, align 14159 14160Increase the minimum alignment of each @var{variable} to @var{alignment}. 14161This is the same as GCC's @code{aligned} attribute @pxref{Variable 14162Attributes}). Macro expansion occurs on the arguments to this pragma 14163when compiling C and Objective-C@. It does not currently occur when 14164compiling C++, but this is a bug which may be fixed in a future 14165release. 14166 14167@item fini (@var{function} [, @var{function}]...) 14168@cindex pragma, fini 14169 14170This pragma causes each listed @var{function} to be called after 14171main, or during shared module unloading, by adding a call to the 14172@code{.fini} section. 14173 14174@item init (@var{function} [, @var{function}]...) 14175@cindex pragma, init 14176 14177This pragma causes each listed @var{function} to be called during 14178initialization (before @code{main}) or during shared module loading, by 14179adding a call to the @code{.init} section. 14180 14181@end table 14182 14183@node Symbol-Renaming Pragmas 14184@subsection Symbol-Renaming Pragmas 14185 14186For compatibility with the Solaris and Tru64 UNIX system headers, GCC 14187supports two @code{#pragma} directives which change the name used in 14188assembly for a given declaration. @code{#pragma extern_prefix} is only 14189available on platforms whose system headers need it. To get this effect 14190on all platforms supported by GCC, use the asm labels extension (@pxref{Asm 14191Labels}). 14192 14193@table @code 14194@item redefine_extname @var{oldname} @var{newname} 14195@cindex pragma, redefine_extname 14196 14197This pragma gives the C function @var{oldname} the assembly symbol 14198@var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME} 14199will be defined if this pragma is available (currently on all platforms). 14200 14201@item extern_prefix @var{string} 14202@cindex pragma, extern_prefix 14203 14204This pragma causes all subsequent external function and variable 14205declarations to have @var{string} prepended to their assembly symbols. 14206This effect may be terminated with another @code{extern_prefix} pragma 14207whose argument is an empty string. The preprocessor macro 14208@code{__PRAGMA_EXTERN_PREFIX} will be defined if this pragma is 14209available (currently only on Tru64 UNIX)@. 14210@end table 14211 14212These pragmas and the asm labels extension interact in a complicated 14213manner. Here are some corner cases you may want to be aware of. 14214 14215@enumerate 14216@item Both pragmas silently apply only to declarations with external 14217linkage. Asm labels do not have this restriction. 14218 14219@item In C++, both pragmas silently apply only to declarations with 14220``C'' linkage. Again, asm labels do not have this restriction. 14221 14222@item If any of the three ways of changing the assembly name of a 14223declaration is applied to a declaration whose assembly name has 14224already been determined (either by a previous use of one of these 14225features, or because the compiler needed the assembly name in order to 14226generate code), and the new name is different, a warning issues and 14227the name does not change. 14228 14229@item The @var{oldname} used by @code{#pragma redefine_extname} is 14230always the C-language name. 14231 14232@item If @code{#pragma extern_prefix} is in effect, and a declaration 14233occurs with an asm label attached, the prefix is silently ignored for 14234that declaration. 14235 14236@item If @code{#pragma extern_prefix} and @code{#pragma redefine_extname} 14237apply to the same declaration, whichever triggered first wins, and a 14238warning issues if they contradict each other. (We would like to have 14239@code{#pragma redefine_extname} always win, for consistency with asm 14240labels, but if @code{#pragma extern_prefix} triggers first we have no 14241way of knowing that that happened.) 14242@end enumerate 14243 14244@node Structure-Packing Pragmas 14245@subsection Structure-Packing Pragmas 14246 14247For compatibility with Microsoft Windows compilers, GCC supports a 14248set of @code{#pragma} directives which change the maximum alignment of 14249members of structures (other than zero-width bitfields), unions, and 14250classes subsequently defined. The @var{n} value below always is required 14251to be a small power of two and specifies the new alignment in bytes. 14252 14253@enumerate 14254@item @code{#pragma pack(@var{n})} simply sets the new alignment. 14255@item @code{#pragma pack()} sets the alignment to the one that was in 14256effect when compilation started (see also command-line option 14257@option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}). 14258@item @code{#pragma pack(push[,@var{n}])} pushes the current alignment 14259setting on an internal stack and then optionally sets the new alignment. 14260@item @code{#pragma pack(pop)} restores the alignment setting to the one 14261saved at the top of the internal stack (and removes that stack entry). 14262Note that @code{#pragma pack([@var{n}])} does not influence this internal 14263stack; thus it is possible to have @code{#pragma pack(push)} followed by 14264multiple @code{#pragma pack(@var{n})} instances and finalized by a single 14265@code{#pragma pack(pop)}. 14266@end enumerate 14267 14268Some targets, e.g.@: i386 and powerpc, support the @code{ms_struct} 14269@code{#pragma} which lays out a structure as the documented 14270@code{__attribute__ ((ms_struct))}. 14271@enumerate 14272@item @code{#pragma ms_struct on} turns on the layout for structures 14273declared. 14274@item @code{#pragma ms_struct off} turns off the layout for structures 14275declared. 14276@item @code{#pragma ms_struct reset} goes back to the default layout. 14277@end enumerate 14278 14279@node Weak Pragmas 14280@subsection Weak Pragmas 14281 14282For compatibility with SVR4, GCC supports a set of @code{#pragma} 14283directives for declaring symbols to be weak, and defining weak 14284aliases. 14285 14286@table @code 14287@item #pragma weak @var{symbol} 14288@cindex pragma, weak 14289This pragma declares @var{symbol} to be weak, as if the declaration 14290had the attribute of the same name. The pragma may appear before 14291or after the declaration of @var{symbol}. It is not an error for 14292@var{symbol} to never be defined at all. 14293 14294@item #pragma weak @var{symbol1} = @var{symbol2} 14295This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}. 14296It is an error if @var{symbol2} is not defined in the current 14297translation unit. 14298@end table 14299 14300@node Diagnostic Pragmas 14301@subsection Diagnostic Pragmas 14302 14303GCC allows the user to selectively enable or disable certain types of 14304diagnostics, and change the kind of the diagnostic. For example, a 14305project's policy might require that all sources compile with 14306@option{-Werror} but certain files might have exceptions allowing 14307specific types of warnings. Or, a project might selectively enable 14308diagnostics and treat them as errors depending on which preprocessor 14309macros are defined. 14310 14311@table @code 14312@item #pragma GCC diagnostic @var{kind} @var{option} 14313@cindex pragma, diagnostic 14314 14315Modifies the disposition of a diagnostic. Note that not all 14316diagnostics are modifiable; at the moment only warnings (normally 14317controlled by @samp{-W@dots{}}) can be controlled, and not all of them. 14318Use @option{-fdiagnostics-show-option} to determine which diagnostics 14319are controllable and which option controls them. 14320 14321@var{kind} is @samp{error} to treat this diagnostic as an error, 14322@samp{warning} to treat it like a warning (even if @option{-Werror} is 14323in effect), or @samp{ignored} if the diagnostic is to be ignored. 14324@var{option} is a double quoted string which matches the command-line 14325option. 14326 14327@example 14328#pragma GCC diagnostic warning "-Wformat" 14329#pragma GCC diagnostic error "-Wformat" 14330#pragma GCC diagnostic ignored "-Wformat" 14331@end example 14332 14333Note that these pragmas override any command-line options. GCC keeps 14334track of the location of each pragma, and issues diagnostics according 14335to the state as of that point in the source file. Thus, pragmas occurring 14336after a line do not affect diagnostics caused by that line. 14337 14338@item #pragma GCC diagnostic push 14339@itemx #pragma GCC diagnostic pop 14340 14341Causes GCC to remember the state of the diagnostics as of each 14342@code{push}, and restore to that point at each @code{pop}. If a 14343@code{pop} has no matching @code{push}, the command line options are 14344restored. 14345 14346@example 14347#pragma GCC diagnostic error "-Wuninitialized" 14348 foo(a); /* error is given for this one */ 14349#pragma GCC diagnostic push 14350#pragma GCC diagnostic ignored "-Wuninitialized" 14351 foo(b); /* no diagnostic for this one */ 14352#pragma GCC diagnostic pop 14353 foo(c); /* error is given for this one */ 14354#pragma GCC diagnostic pop 14355 foo(d); /* depends on command line options */ 14356@end example 14357 14358@end table 14359 14360GCC also offers a simple mechanism for printing messages during 14361compilation. 14362 14363@table @code 14364@item #pragma message @var{string} 14365@cindex pragma, diagnostic 14366 14367Prints @var{string} as a compiler message on compilation. The message 14368is informational only, and is neither a compilation warning nor an error. 14369 14370@smallexample 14371#pragma message "Compiling " __FILE__ "..." 14372@end smallexample 14373 14374@var{string} may be parenthesized, and is printed with location 14375information. For example, 14376 14377@smallexample 14378#define DO_PRAGMA(x) _Pragma (#x) 14379#define TODO(x) DO_PRAGMA(message ("TODO - " #x)) 14380 14381TODO(Remember to fix this) 14382@end smallexample 14383 14384prints @samp{/tmp/file.c:4: note: #pragma message: 14385TODO - Remember to fix this}. 14386 14387@end table 14388 14389@node Visibility Pragmas 14390@subsection Visibility Pragmas 14391 14392@table @code 14393@item #pragma GCC visibility push(@var{visibility}) 14394@itemx #pragma GCC visibility pop 14395@cindex pragma, visibility 14396 14397This pragma allows the user to set the visibility for multiple 14398declarations without having to give each a visibility attribute 14399@xref{Function Attributes}, for more information about visibility and 14400the attribute syntax. 14401 14402In C++, @samp{#pragma GCC visibility} affects only namespace-scope 14403declarations. Class members and template specializations are not 14404affected; if you want to override the visibility for a particular 14405member or instantiation, you must use an attribute. 14406 14407@end table 14408 14409 14410@node Push/Pop Macro Pragmas 14411@subsection Push/Pop Macro Pragmas 14412 14413For compatibility with Microsoft Windows compilers, GCC supports 14414@samp{#pragma push_macro(@var{"macro_name"})} 14415and @samp{#pragma pop_macro(@var{"macro_name"})}. 14416 14417@table @code 14418@item #pragma push_macro(@var{"macro_name"}) 14419@cindex pragma, push_macro 14420This pragma saves the value of the macro named as @var{macro_name} to 14421the top of the stack for this macro. 14422 14423@item #pragma pop_macro(@var{"macro_name"}) 14424@cindex pragma, pop_macro 14425This pragma sets the value of the macro named as @var{macro_name} to 14426the value on top of the stack for this macro. If the stack for 14427@var{macro_name} is empty, the value of the macro remains unchanged. 14428@end table 14429 14430For example: 14431 14432@smallexample 14433#define X 1 14434#pragma push_macro("X") 14435#undef X 14436#define X -1 14437#pragma pop_macro("X") 14438int x [X]; 14439@end smallexample 14440 14441In this example, the definition of X as 1 is saved by @code{#pragma 14442push_macro} and restored by @code{#pragma pop_macro}. 14443 14444@node Function Specific Option Pragmas 14445@subsection Function Specific Option Pragmas 14446 14447@table @code 14448@item #pragma GCC target (@var{"string"}...) 14449@cindex pragma GCC target 14450 14451This pragma allows you to set target specific options for functions 14452defined later in the source file. One or more strings can be 14453specified. Each function that is defined after this point will be as 14454if @code{attribute((target("STRING")))} was specified for that 14455function. The parenthesis around the options is optional. 14456@xref{Function Attributes}, for more information about the 14457@code{target} attribute and the attribute syntax. 14458 14459The @code{#pragma GCC target} attribute is not implemented in GCC versions earlier 14460than 4.4 for the i386/x86_64 and 4.6 for the PowerPC backends. At 14461present, it is not implemented for other backends. 14462@end table 14463 14464@table @code 14465@item #pragma GCC optimize (@var{"string"}...) 14466@cindex pragma GCC optimize 14467 14468This pragma allows you to set global optimization options for functions 14469defined later in the source file. One or more strings can be 14470specified. Each function that is defined after this point will be as 14471if @code{attribute((optimize("STRING")))} was specified for that 14472function. The parenthesis around the options is optional. 14473@xref{Function Attributes}, for more information about the 14474@code{optimize} attribute and the attribute syntax. 14475 14476The @samp{#pragma GCC optimize} pragma is not implemented in GCC 14477versions earlier than 4.4. 14478@end table 14479 14480@table @code 14481@item #pragma GCC push_options 14482@itemx #pragma GCC pop_options 14483@cindex pragma GCC push_options 14484@cindex pragma GCC pop_options 14485 14486These pragmas maintain a stack of the current target and optimization 14487options. It is intended for include files where you temporarily want 14488to switch to using a different @samp{#pragma GCC target} or 14489@samp{#pragma GCC optimize} and then to pop back to the previous 14490options. 14491 14492The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options} 14493pragmas are not implemented in GCC versions earlier than 4.4. 14494@end table 14495 14496@table @code 14497@item #pragma GCC reset_options 14498@cindex pragma GCC reset_options 14499 14500This pragma clears the current @code{#pragma GCC target} and 14501@code{#pragma GCC optimize} to use the default switches as specified 14502on the command line. 14503 14504The @samp{#pragma GCC reset_options} pragma is not implemented in GCC 14505versions earlier than 4.4. 14506@end table 14507 14508@node Unnamed Fields 14509@section Unnamed struct/union fields within structs/unions 14510@cindex @code{struct} 14511@cindex @code{union} 14512 14513As permitted by ISO C11 and for compatibility with other compilers, 14514GCC allows you to define 14515a structure or union that contains, as fields, structures and unions 14516without names. For example: 14517 14518@smallexample 14519struct @{ 14520 int a; 14521 union @{ 14522 int b; 14523 float c; 14524 @}; 14525 int d; 14526@} foo; 14527@end smallexample 14528 14529In this example, the user would be able to access members of the unnamed 14530union with code like @samp{foo.b}. Note that only unnamed structs and 14531unions are allowed, you may not have, for example, an unnamed 14532@code{int}. 14533 14534You must never create such structures that cause ambiguous field definitions. 14535For example, this structure: 14536 14537@smallexample 14538struct @{ 14539 int a; 14540 struct @{ 14541 int a; 14542 @}; 14543@} foo; 14544@end smallexample 14545 14546It is ambiguous which @code{a} is being referred to with @samp{foo.a}. 14547The compiler gives errors for such constructs. 14548 14549@opindex fms-extensions 14550Unless @option{-fms-extensions} is used, the unnamed field must be a 14551structure or union definition without a tag (for example, @samp{struct 14552@{ int a; @};}). If @option{-fms-extensions} is used, the field may 14553also be a definition with a tag such as @samp{struct foo @{ int a; 14554@};}, a reference to a previously defined structure or union such as 14555@samp{struct foo;}, or a reference to a @code{typedef} name for a 14556previously defined structure or union type. 14557 14558@opindex fplan9-extensions 14559The option @option{-fplan9-extensions} enables 14560@option{-fms-extensions} as well as two other extensions. First, a 14561pointer to a structure is automatically converted to a pointer to an 14562anonymous field for assignments and function calls. For example: 14563 14564@smallexample 14565struct s1 @{ int a; @}; 14566struct s2 @{ struct s1; @}; 14567extern void f1 (struct s1 *); 14568void f2 (struct s2 *p) @{ f1 (p); @} 14569@end smallexample 14570 14571In the call to @code{f1} inside @code{f2}, the pointer @code{p} is 14572converted into a pointer to the anonymous field. 14573 14574Second, when the type of an anonymous field is a @code{typedef} for a 14575@code{struct} or @code{union}, code may refer to the field using the 14576name of the @code{typedef}. 14577 14578@smallexample 14579typedef struct @{ int a; @} s1; 14580struct s2 @{ s1; @}; 14581s1 f1 (struct s2 *p) @{ return p->s1; @} 14582@end smallexample 14583 14584These usages are only permitted when they are not ambiguous. 14585 14586@node Thread-Local 14587@section Thread-Local Storage 14588@cindex Thread-Local Storage 14589@cindex @acronym{TLS} 14590@cindex @code{__thread} 14591 14592Thread-local storage (@acronym{TLS}) is a mechanism by which variables 14593are allocated such that there is one instance of the variable per extant 14594thread. The run-time model GCC uses to implement this originates 14595in the IA-64 processor-specific ABI, but has since been migrated 14596to other processors as well. It requires significant support from 14597the linker (@command{ld}), dynamic linker (@command{ld.so}), and 14598system libraries (@file{libc.so} and @file{libpthread.so}), so it 14599is not available everywhere. 14600 14601At the user level, the extension is visible with a new storage 14602class keyword: @code{__thread}. For example: 14603 14604@smallexample 14605__thread int i; 14606extern __thread struct state s; 14607static __thread char *p; 14608@end smallexample 14609 14610The @code{__thread} specifier may be used alone, with the @code{extern} 14611or @code{static} specifiers, but with no other storage class specifier. 14612When used with @code{extern} or @code{static}, @code{__thread} must appear 14613immediately after the other storage class specifier. 14614 14615The @code{__thread} specifier may be applied to any global, file-scoped 14616static, function-scoped static, or static data member of a class. It may 14617not be applied to block-scoped automatic or non-static data member. 14618 14619When the address-of operator is applied to a thread-local variable, it is 14620evaluated at run-time and returns the address of the current thread's 14621instance of that variable. An address so obtained may be used by any 14622thread. When a thread terminates, any pointers to thread-local variables 14623in that thread become invalid. 14624 14625No static initialization may refer to the address of a thread-local variable. 14626 14627In C++, if an initializer is present for a thread-local variable, it must 14628be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++ 14629standard. 14630 14631See @uref{http://www.akkadia.org/drepper/tls.pdf, 14632ELF Handling For Thread-Local Storage} for a detailed explanation of 14633the four thread-local storage addressing models, and how the run-time 14634is expected to function. 14635 14636@menu 14637* C99 Thread-Local Edits:: 14638* C++98 Thread-Local Edits:: 14639@end menu 14640 14641@node C99 Thread-Local Edits 14642@subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage 14643 14644The following are a set of changes to ISO/IEC 9899:1999 (aka C99) 14645that document the exact semantics of the language extension. 14646 14647@itemize @bullet 14648@item 14649@cite{5.1.2 Execution environments} 14650 14651Add new text after paragraph 1 14652 14653@quotation 14654Within either execution environment, a @dfn{thread} is a flow of 14655control within a program. It is implementation defined whether 14656or not there may be more than one thread associated with a program. 14657It is implementation defined how threads beyond the first are 14658created, the name and type of the function called at thread 14659startup, and how threads may be terminated. However, objects 14660with thread storage duration shall be initialized before thread 14661startup. 14662@end quotation 14663 14664@item 14665@cite{6.2.4 Storage durations of objects} 14666 14667Add new text before paragraph 3 14668 14669@quotation 14670An object whose identifier is declared with the storage-class 14671specifier @w{@code{__thread}} has @dfn{thread storage duration}. 14672Its lifetime is the entire execution of the thread, and its 14673stored value is initialized only once, prior to thread startup. 14674@end quotation 14675 14676@item 14677@cite{6.4.1 Keywords} 14678 14679Add @code{__thread}. 14680 14681@item 14682@cite{6.7.1 Storage-class specifiers} 14683 14684Add @code{__thread} to the list of storage class specifiers in 14685paragraph 1. 14686 14687Change paragraph 2 to 14688 14689@quotation 14690With the exception of @code{__thread}, at most one storage-class 14691specifier may be given [@dots{}]. The @code{__thread} specifier may 14692be used alone, or immediately following @code{extern} or 14693@code{static}. 14694@end quotation 14695 14696Add new text after paragraph 6 14697 14698@quotation 14699The declaration of an identifier for a variable that has 14700block scope that specifies @code{__thread} shall also 14701specify either @code{extern} or @code{static}. 14702 14703The @code{__thread} specifier shall be used only with 14704variables. 14705@end quotation 14706@end itemize 14707 14708@node C++98 Thread-Local Edits 14709@subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage 14710 14711The following are a set of changes to ISO/IEC 14882:1998 (aka C++98) 14712that document the exact semantics of the language extension. 14713 14714@itemize @bullet 14715@item 14716@b{[intro.execution]} 14717 14718New text after paragraph 4 14719 14720@quotation 14721A @dfn{thread} is a flow of control within the abstract machine. 14722It is implementation defined whether or not there may be more than 14723one thread. 14724@end quotation 14725 14726New text after paragraph 7 14727 14728@quotation 14729It is unspecified whether additional action must be taken to 14730ensure when and whether side effects are visible to other threads. 14731@end quotation 14732 14733@item 14734@b{[lex.key]} 14735 14736Add @code{__thread}. 14737 14738@item 14739@b{[basic.start.main]} 14740 14741Add after paragraph 5 14742 14743@quotation 14744The thread that begins execution at the @code{main} function is called 14745the @dfn{main thread}. It is implementation defined how functions 14746beginning threads other than the main thread are designated or typed. 14747A function so designated, as well as the @code{main} function, is called 14748a @dfn{thread startup function}. It is implementation defined what 14749happens if a thread startup function returns. It is implementation 14750defined what happens to other threads when any thread calls @code{exit}. 14751@end quotation 14752 14753@item 14754@b{[basic.start.init]} 14755 14756Add after paragraph 4 14757 14758@quotation 14759The storage for an object of thread storage duration shall be 14760statically initialized before the first statement of the thread startup 14761function. An object of thread storage duration shall not require 14762dynamic initialization. 14763@end quotation 14764 14765@item 14766@b{[basic.start.term]} 14767 14768Add after paragraph 3 14769 14770@quotation 14771The type of an object with thread storage duration shall not have a 14772non-trivial destructor, nor shall it be an array type whose elements 14773(directly or indirectly) have non-trivial destructors. 14774@end quotation 14775 14776@item 14777@b{[basic.stc]} 14778 14779Add ``thread storage duration'' to the list in paragraph 1. 14780 14781Change paragraph 2 14782 14783@quotation 14784Thread, static, and automatic storage durations are associated with 14785objects introduced by declarations [@dots{}]. 14786@end quotation 14787 14788Add @code{__thread} to the list of specifiers in paragraph 3. 14789 14790@item 14791@b{[basic.stc.thread]} 14792 14793New section before @b{[basic.stc.static]} 14794 14795@quotation 14796The keyword @code{__thread} applied to a non-local object gives the 14797object thread storage duration. 14798 14799A local variable or class data member declared both @code{static} 14800and @code{__thread} gives the variable or member thread storage 14801duration. 14802@end quotation 14803 14804@item 14805@b{[basic.stc.static]} 14806 14807Change paragraph 1 14808 14809@quotation 14810All objects which have neither thread storage duration, dynamic 14811storage duration nor are local [@dots{}]. 14812@end quotation 14813 14814@item 14815@b{[dcl.stc]} 14816 14817Add @code{__thread} to the list in paragraph 1. 14818 14819Change paragraph 1 14820 14821@quotation 14822With the exception of @code{__thread}, at most one 14823@var{storage-class-specifier} shall appear in a given 14824@var{decl-specifier-seq}. The @code{__thread} specifier may 14825be used alone, or immediately following the @code{extern} or 14826@code{static} specifiers. [@dots{}] 14827@end quotation 14828 14829Add after paragraph 5 14830 14831@quotation 14832The @code{__thread} specifier can be applied only to the names of objects 14833and to anonymous unions. 14834@end quotation 14835 14836@item 14837@b{[class.mem]} 14838 14839Add after paragraph 6 14840 14841@quotation 14842Non-@code{static} members shall not be @code{__thread}. 14843@end quotation 14844@end itemize 14845 14846@node Binary constants 14847@section Binary constants using the @samp{0b} prefix 14848@cindex Binary constants using the @samp{0b} prefix 14849 14850Integer constants can be written as binary constants, consisting of a 14851sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or 14852@samp{0B}. This is particularly useful in environments that operate a 14853lot on the bit-level (like microcontrollers). 14854 14855The following statements are identical: 14856 14857@smallexample 14858i = 42; 14859i = 0x2a; 14860i = 052; 14861i = 0b101010; 14862@end smallexample 14863 14864The type of these constants follows the same rules as for octal or 14865hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL} 14866can be applied. 14867 14868@node C++ Extensions 14869@chapter Extensions to the C++ Language 14870@cindex extensions, C++ language 14871@cindex C++ language extensions 14872 14873The GNU compiler provides these extensions to the C++ language (and you 14874can also use most of the C language extensions in your C++ programs). If you 14875want to write code that checks whether these features are available, you can 14876test for the GNU compiler the same way as for C programs: check for a 14877predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to 14878test specifically for GNU C++ (@pxref{Common Predefined Macros,, 14879Predefined Macros,cpp,The GNU C Preprocessor}). 14880 14881@menu 14882* C++ Volatiles:: What constitutes an access to a volatile object. 14883* Restricted Pointers:: C99 restricted pointers and references. 14884* Vague Linkage:: Where G++ puts inlines, vtables and such. 14885* C++ Interface:: You can use a single C++ header file for both 14886 declarations and definitions. 14887* Template Instantiation:: Methods for ensuring that exactly one copy of 14888 each needed template instantiation is emitted. 14889* Bound member functions:: You can extract a function pointer to the 14890 method denoted by a @samp{->*} or @samp{.*} expression. 14891* C++ Attributes:: Variable, function, and type attributes for C++ only. 14892* Namespace Association:: Strong using-directives for namespace association. 14893* Type Traits:: Compiler support for type traits 14894* Java Exceptions:: Tweaking exception handling to work with Java. 14895* Deprecated Features:: Things will disappear from g++. 14896* Backwards Compatibility:: Compatibilities with earlier definitions of C++. 14897@end menu 14898 14899@node C++ Volatiles 14900@section When is a Volatile C++ Object Accessed? 14901@cindex accessing volatiles 14902@cindex volatile read 14903@cindex volatile write 14904@cindex volatile access 14905 14906The C++ standard differs from the C standard in its treatment of 14907volatile objects. It fails to specify what constitutes a volatile 14908access, except to say that C++ should behave in a similar manner to C 14909with respect to volatiles, where possible. However, the different 14910lvalueness of expressions between C and C++ complicate the behavior. 14911G++ behaves the same as GCC for volatile access, @xref{C 14912Extensions,,Volatiles}, for a description of GCC's behavior. 14913 14914The C and C++ language specifications differ when an object is 14915accessed in a void context: 14916 14917@smallexample 14918volatile int *src = @var{somevalue}; 14919*src; 14920@end smallexample 14921 14922The C++ standard specifies that such expressions do not undergo lvalue 14923to rvalue conversion, and that the type of the dereferenced object may 14924be incomplete. The C++ standard does not specify explicitly that it 14925is lvalue to rvalue conversion which is responsible for causing an 14926access. There is reason to believe that it is, because otherwise 14927certain simple expressions become undefined. However, because it 14928would surprise most programmers, G++ treats dereferencing a pointer to 14929volatile object of complete type as GCC would do for an equivalent 14930type in C@. When the object has incomplete type, G++ issues a 14931warning; if you wish to force an error, you must force a conversion to 14932rvalue with, for instance, a static cast. 14933 14934When using a reference to volatile, G++ does not treat equivalent 14935expressions as accesses to volatiles, but instead issues a warning that 14936no volatile is accessed. The rationale for this is that otherwise it 14937becomes difficult to determine where volatile access occur, and not 14938possible to ignore the return value from functions returning volatile 14939references. Again, if you wish to force a read, cast the reference to 14940an rvalue. 14941 14942G++ implements the same behavior as GCC does when assigning to a 14943volatile object -- there is no reread of the assigned-to object, the 14944assigned rvalue is reused. Note that in C++ assignment expressions 14945are lvalues, and if used as an lvalue, the volatile object will be 14946referred to. For instance, @var{vref} will refer to @var{vobj}, as 14947expected, in the following example: 14948 14949@smallexample 14950volatile int vobj; 14951volatile int &vref = vobj = @var{something}; 14952@end smallexample 14953 14954@node Restricted Pointers 14955@section Restricting Pointer Aliasing 14956@cindex restricted pointers 14957@cindex restricted references 14958@cindex restricted this pointer 14959 14960As with the C front end, G++ understands the C99 feature of restricted pointers, 14961specified with the @code{__restrict__}, or @code{__restrict} type 14962qualifier. Because you cannot compile C++ by specifying the @option{-std=c99} 14963language flag, @code{restrict} is not a keyword in C++. 14964 14965In addition to allowing restricted pointers, you can specify restricted 14966references, which indicate that the reference is not aliased in the local 14967context. 14968 14969@smallexample 14970void fn (int *__restrict__ rptr, int &__restrict__ rref) 14971@{ 14972 /* @r{@dots{}} */ 14973@} 14974@end smallexample 14975 14976@noindent 14977In the body of @code{fn}, @var{rptr} points to an unaliased integer and 14978@var{rref} refers to a (different) unaliased integer. 14979 14980You may also specify whether a member function's @var{this} pointer is 14981unaliased by using @code{__restrict__} as a member function qualifier. 14982 14983@smallexample 14984void T::fn () __restrict__ 14985@{ 14986 /* @r{@dots{}} */ 14987@} 14988@end smallexample 14989 14990@noindent 14991Within the body of @code{T::fn}, @var{this} will have the effective 14992definition @code{T *__restrict__ const this}. Notice that the 14993interpretation of a @code{__restrict__} member function qualifier is 14994different to that of @code{const} or @code{volatile} qualifier, in that it 14995is applied to the pointer rather than the object. This is consistent with 14996other compilers which implement restricted pointers. 14997 14998As with all outermost parameter qualifiers, @code{__restrict__} is 14999ignored in function definition matching. This means you only need to 15000specify @code{__restrict__} in a function definition, rather than 15001in a function prototype as well. 15002 15003@node Vague Linkage 15004@section Vague Linkage 15005@cindex vague linkage 15006 15007There are several constructs in C++ which require space in the object 15008file but are not clearly tied to a single translation unit. We say that 15009these constructs have ``vague linkage''. Typically such constructs are 15010emitted wherever they are needed, though sometimes we can be more 15011clever. 15012 15013@table @asis 15014@item Inline Functions 15015Inline functions are typically defined in a header file which can be 15016included in many different compilations. Hopefully they can usually be 15017inlined, but sometimes an out-of-line copy is necessary, if the address 15018of the function is taken or if inlining fails. In general, we emit an 15019out-of-line copy in all translation units where one is needed. As an 15020exception, we only emit inline virtual functions with the vtable, since 15021it will always require a copy. 15022 15023Local static variables and string constants used in an inline function 15024are also considered to have vague linkage, since they must be shared 15025between all inlined and out-of-line instances of the function. 15026 15027@item VTables 15028@cindex vtable 15029C++ virtual functions are implemented in most compilers using a lookup 15030table, known as a vtable. The vtable contains pointers to the virtual 15031functions provided by a class, and each object of the class contains a 15032pointer to its vtable (or vtables, in some multiple-inheritance 15033situations). If the class declares any non-inline, non-pure virtual 15034functions, the first one is chosen as the ``key method'' for the class, 15035and the vtable is only emitted in the translation unit where the key 15036method is defined. 15037 15038@emph{Note:} If the chosen key method is later defined as inline, the 15039vtable will still be emitted in every translation unit which defines it. 15040Make sure that any inline virtuals are declared inline in the class 15041body, even if they are not defined there. 15042 15043@item @code{type_info} objects 15044@cindex @code{type_info} 15045@cindex RTTI 15046C++ requires information about types to be written out in order to 15047implement @samp{dynamic_cast}, @samp{typeid} and exception handling. 15048For polymorphic classes (classes with virtual functions), the @samp{type_info} 15049object is written out along with the vtable so that @samp{dynamic_cast} 15050can determine the dynamic type of a class object at runtime. For all 15051other types, we write out the @samp{type_info} object when it is used: when 15052applying @samp{typeid} to an expression, throwing an object, or 15053referring to a type in a catch clause or exception specification. 15054 15055@item Template Instantiations 15056Most everything in this section also applies to template instantiations, 15057but there are other options as well. 15058@xref{Template Instantiation,,Where's the Template?}. 15059 15060@end table 15061 15062When used with GNU ld version 2.8 or later on an ELF system such as 15063GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of 15064these constructs will be discarded at link time. This is known as 15065COMDAT support. 15066 15067On targets that don't support COMDAT, but do support weak symbols, GCC 15068will use them. This way one copy will override all the others, but 15069the unused copies will still take up space in the executable. 15070 15071For targets which do not support either COMDAT or weak symbols, 15072most entities with vague linkage will be emitted as local symbols to 15073avoid duplicate definition errors from the linker. This will not happen 15074for local statics in inlines, however, as having multiple copies will 15075almost certainly break things. 15076 15077@xref{C++ Interface,,Declarations and Definitions in One Header}, for 15078another way to control placement of these constructs. 15079 15080@node C++ Interface 15081@section #pragma interface and implementation 15082 15083@cindex interface and implementation headers, C++ 15084@cindex C++ interface and implementation headers 15085@cindex pragmas, interface and implementation 15086 15087@code{#pragma interface} and @code{#pragma implementation} provide the 15088user with a way of explicitly directing the compiler to emit entities 15089with vague linkage (and debugging information) in a particular 15090translation unit. 15091 15092@emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in 15093most cases, because of COMDAT support and the ``key method'' heuristic 15094mentioned in @ref{Vague Linkage}. Using them can actually cause your 15095program to grow due to unnecessary out-of-line copies of inline 15096functions. Currently (3.4) the only benefit of these 15097@code{#pragma}s is reduced duplication of debugging information, and 15098that should be addressed soon on DWARF 2 targets with the use of 15099COMDAT groups. 15100 15101@table @code 15102@item #pragma interface 15103@itemx #pragma interface "@var{subdir}/@var{objects}.h" 15104@kindex #pragma interface 15105Use this directive in @emph{header files} that define object classes, to save 15106space in most of the object files that use those classes. Normally, 15107local copies of certain information (backup copies of inline member 15108functions, debugging information, and the internal tables that implement 15109virtual functions) must be kept in each object file that includes class 15110definitions. You can use this pragma to avoid such duplication. When a 15111header file containing @samp{#pragma interface} is included in a 15112compilation, this auxiliary information will not be generated (unless 15113the main input source file itself uses @samp{#pragma implementation}). 15114Instead, the object files will contain references to be resolved at link 15115time. 15116 15117The second form of this directive is useful for the case where you have 15118multiple headers with the same name in different directories. If you 15119use this form, you must specify the same string to @samp{#pragma 15120implementation}. 15121 15122@item #pragma implementation 15123@itemx #pragma implementation "@var{objects}.h" 15124@kindex #pragma implementation 15125Use this pragma in a @emph{main input file}, when you want full output from 15126included header files to be generated (and made globally visible). The 15127included header file, in turn, should use @samp{#pragma interface}. 15128Backup copies of inline member functions, debugging information, and the 15129internal tables used to implement virtual functions are all generated in 15130implementation files. 15131 15132@cindex implied @code{#pragma implementation} 15133@cindex @code{#pragma implementation}, implied 15134@cindex naming convention, implementation headers 15135If you use @samp{#pragma implementation} with no argument, it applies to 15136an include file with the same basename@footnote{A file's @dfn{basename} 15137was the name stripped of all leading path information and of trailing 15138suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source 15139file. For example, in @file{allclass.cc}, giving just 15140@samp{#pragma implementation} 15141by itself is equivalent to @samp{#pragma implementation "allclass.h"}. 15142 15143In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as 15144an implementation file whenever you would include it from 15145@file{allclass.cc} even if you never specified @samp{#pragma 15146implementation}. This was deemed to be more trouble than it was worth, 15147however, and disabled. 15148 15149Use the string argument if you want a single implementation file to 15150include code from multiple header files. (You must also use 15151@samp{#include} to include the header file; @samp{#pragma 15152implementation} only specifies how to use the file---it doesn't actually 15153include it.) 15154 15155There is no way to split up the contents of a single header file into 15156multiple implementation files. 15157@end table 15158 15159@cindex inlining and C++ pragmas 15160@cindex C++ pragmas, effect on inlining 15161@cindex pragmas in C++, effect on inlining 15162@samp{#pragma implementation} and @samp{#pragma interface} also have an 15163effect on function inlining. 15164 15165If you define a class in a header file marked with @samp{#pragma 15166interface}, the effect on an inline function defined in that class is 15167similar to an explicit @code{extern} declaration---the compiler emits 15168no code at all to define an independent version of the function. Its 15169definition is used only for inlining with its callers. 15170 15171@opindex fno-implement-inlines 15172Conversely, when you include the same header file in a main source file 15173that declares it as @samp{#pragma implementation}, the compiler emits 15174code for the function itself; this defines a version of the function 15175that can be found via pointers (or by callers compiled without 15176inlining). If all calls to the function can be inlined, you can avoid 15177emitting the function by compiling with @option{-fno-implement-inlines}. 15178If any calls were not inlined, you will get linker errors. 15179 15180@node Template Instantiation 15181@section Where's the Template? 15182@cindex template instantiation 15183 15184C++ templates are the first language feature to require more 15185intelligence from the environment than one usually finds on a UNIX 15186system. Somehow the compiler and linker have to make sure that each 15187template instance occurs exactly once in the executable if it is needed, 15188and not at all otherwise. There are two basic approaches to this 15189problem, which are referred to as the Borland model and the Cfront model. 15190 15191@table @asis 15192@item Borland model 15193Borland C++ solved the template instantiation problem by adding the code 15194equivalent of common blocks to their linker; the compiler emits template 15195instances in each translation unit that uses them, and the linker 15196collapses them together. The advantage of this model is that the linker 15197only has to consider the object files themselves; there is no external 15198complexity to worry about. This disadvantage is that compilation time 15199is increased because the template code is being compiled repeatedly. 15200Code written for this model tends to include definitions of all 15201templates in the header file, since they must be seen to be 15202instantiated. 15203 15204@item Cfront model 15205The AT&T C++ translator, Cfront, solved the template instantiation 15206problem by creating the notion of a template repository, an 15207automatically maintained place where template instances are stored. A 15208more modern version of the repository works as follows: As individual 15209object files are built, the compiler places any template definitions and 15210instantiations encountered in the repository. At link time, the link 15211wrapper adds in the objects in the repository and compiles any needed 15212instances that were not previously emitted. The advantages of this 15213model are more optimal compilation speed and the ability to use the 15214system linker; to implement the Borland model a compiler vendor also 15215needs to replace the linker. The disadvantages are vastly increased 15216complexity, and thus potential for error; for some code this can be 15217just as transparent, but in practice it can been very difficult to build 15218multiple programs in one directory and one program in multiple 15219directories. Code written for this model tends to separate definitions 15220of non-inline member templates into a separate file, which should be 15221compiled separately. 15222@end table 15223 15224When used with GNU ld version 2.8 or later on an ELF system such as 15225GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the 15226Borland model. On other systems, G++ implements neither automatic 15227model. 15228 15229A future version of G++ will support a hybrid model whereby the compiler 15230will emit any instantiations for which the template definition is 15231included in the compile, and store template definitions and 15232instantiation context information into the object file for the rest. 15233The link wrapper will extract that information as necessary and invoke 15234the compiler to produce the remaining instantiations. The linker will 15235then combine duplicate instantiations. 15236 15237In the mean time, you have the following options for dealing with 15238template instantiations: 15239 15240@enumerate 15241@item 15242@opindex frepo 15243Compile your template-using code with @option{-frepo}. The compiler will 15244generate files with the extension @samp{.rpo} listing all of the 15245template instantiations used in the corresponding object files which 15246could be instantiated there; the link wrapper, @samp{collect2}, will 15247then update the @samp{.rpo} files to tell the compiler where to place 15248those instantiations and rebuild any affected object files. The 15249link-time overhead is negligible after the first pass, as the compiler 15250will continue to place the instantiations in the same files. 15251 15252This is your best option for application code written for the Borland 15253model, as it will just work. Code written for the Cfront model will 15254need to be modified so that the template definitions are available at 15255one or more points of instantiation; usually this is as simple as adding 15256@code{#include <tmethods.cc>} to the end of each template header. 15257 15258For library code, if you want the library to provide all of the template 15259instantiations it needs, just try to link all of its object files 15260together; the link will fail, but cause the instantiations to be 15261generated as a side effect. Be warned, however, that this may cause 15262conflicts if multiple libraries try to provide the same instantiations. 15263For greater control, use explicit instantiation as described in the next 15264option. 15265 15266@item 15267@opindex fno-implicit-templates 15268Compile your code with @option{-fno-implicit-templates} to disable the 15269implicit generation of template instances, and explicitly instantiate 15270all the ones you use. This approach requires more knowledge of exactly 15271which instances you need than do the others, but it's less 15272mysterious and allows greater control. You can scatter the explicit 15273instantiations throughout your program, perhaps putting them in the 15274translation units where the instances are used or the translation units 15275that define the templates themselves; you can put all of the explicit 15276instantiations you need into one big file; or you can create small files 15277like 15278 15279@smallexample 15280#include "Foo.h" 15281#include "Foo.cc" 15282 15283template class Foo<int>; 15284template ostream& operator << 15285 (ostream&, const Foo<int>&); 15286@end smallexample 15287 15288for each of the instances you need, and create a template instantiation 15289library from those. 15290 15291If you are using Cfront-model code, you can probably get away with not 15292using @option{-fno-implicit-templates} when compiling files that don't 15293@samp{#include} the member template definitions. 15294 15295If you use one big file to do the instantiations, you may want to 15296compile it without @option{-fno-implicit-templates} so you get all of the 15297instances required by your explicit instantiations (but not by any 15298other files) without having to specify them as well. 15299 15300G++ has extended the template instantiation syntax given in the ISO 15301standard to allow forward declaration of explicit instantiations 15302(with @code{extern}), instantiation of the compiler support data for a 15303template class (i.e.@: the vtable) without instantiating any of its 15304members (with @code{inline}), and instantiation of only the static data 15305members of a template class, without the support data or member 15306functions (with (@code{static}): 15307 15308@smallexample 15309extern template int max (int, int); 15310inline template class Foo<int>; 15311static template class Foo<int>; 15312@end smallexample 15313 15314@item 15315Do nothing. Pretend G++ does implement automatic instantiation 15316management. Code written for the Borland model will work fine, but 15317each translation unit will contain instances of each of the templates it 15318uses. In a large program, this can lead to an unacceptable amount of code 15319duplication. 15320@end enumerate 15321 15322@node Bound member functions 15323@section Extracting the function pointer from a bound pointer to member function 15324@cindex pmf 15325@cindex pointer to member function 15326@cindex bound pointer to member function 15327 15328In C++, pointer to member functions (PMFs) are implemented using a wide 15329pointer of sorts to handle all the possible call mechanisms; the PMF 15330needs to store information about how to adjust the @samp{this} pointer, 15331and if the function pointed to is virtual, where to find the vtable, and 15332where in the vtable to look for the member function. If you are using 15333PMFs in an inner loop, you should really reconsider that decision. If 15334that is not an option, you can extract the pointer to the function that 15335would be called for a given object/PMF pair and call it directly inside 15336the inner loop, to save a bit of time. 15337 15338Note that you will still be paying the penalty for the call through a 15339function pointer; on most modern architectures, such a call defeats the 15340branch prediction features of the CPU@. This is also true of normal 15341virtual function calls. 15342 15343The syntax for this extension is 15344 15345@smallexample 15346extern A a; 15347extern int (A::*fp)(); 15348typedef int (*fptr)(A *); 15349 15350fptr p = (fptr)(a.*fp); 15351@end smallexample 15352 15353For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}), 15354no object is needed to obtain the address of the function. They can be 15355converted to function pointers directly: 15356 15357@smallexample 15358fptr p1 = (fptr)(&A::foo); 15359@end smallexample 15360 15361@opindex Wno-pmf-conversions 15362You must specify @option{-Wno-pmf-conversions} to use this extension. 15363 15364@node C++ Attributes 15365@section C++-Specific Variable, Function, and Type Attributes 15366 15367Some attributes only make sense for C++ programs. 15368 15369@table @code 15370@item init_priority (@var{priority}) 15371@cindex @code{init_priority} attribute 15372 15373 15374In Standard C++, objects defined at namespace scope are guaranteed to be 15375initialized in an order in strict accordance with that of their definitions 15376@emph{in a given translation unit}. No guarantee is made for initializations 15377across translation units. However, GNU C++ allows users to control the 15378order of initialization of objects defined at namespace scope with the 15379@code{init_priority} attribute by specifying a relative @var{priority}, 15380a constant integral expression currently bounded between 101 and 65535 15381inclusive. Lower numbers indicate a higher priority. 15382 15383In the following example, @code{A} would normally be created before 15384@code{B}, but the @code{init_priority} attribute has reversed that order: 15385 15386@smallexample 15387Some_Class A __attribute__ ((init_priority (2000))); 15388Some_Class B __attribute__ ((init_priority (543))); 15389@end smallexample 15390 15391@noindent 15392Note that the particular values of @var{priority} do not matter; only their 15393relative ordering. 15394 15395@item java_interface 15396@cindex @code{java_interface} attribute 15397 15398This type attribute informs C++ that the class is a Java interface. It may 15399only be applied to classes declared within an @code{extern "Java"} block. 15400Calls to methods declared in this interface will be dispatched using GCJ's 15401interface table mechanism, instead of regular virtual table dispatch. 15402 15403@end table 15404 15405See also @ref{Namespace Association}. 15406 15407@node Namespace Association 15408@section Namespace Association 15409 15410@strong{Caution:} The semantics of this extension are not fully 15411defined. Users should refrain from using this extension as its 15412semantics may change subtly over time. It is possible that this 15413extension will be removed in future versions of G++. 15414 15415A using-directive with @code{__attribute ((strong))} is stronger 15416than a normal using-directive in two ways: 15417 15418@itemize @bullet 15419@item 15420Templates from the used namespace can be specialized and explicitly 15421instantiated as though they were members of the using namespace. 15422 15423@item 15424The using namespace is considered an associated namespace of all 15425templates in the used namespace for purposes of argument-dependent 15426name lookup. 15427@end itemize 15428 15429The used namespace must be nested within the using namespace so that 15430normal unqualified lookup works properly. 15431 15432This is useful for composing a namespace transparently from 15433implementation namespaces. For example: 15434 15435@smallexample 15436namespace std @{ 15437 namespace debug @{ 15438 template <class T> struct A @{ @}; 15439 @} 15440 using namespace debug __attribute ((__strong__)); 15441 template <> struct A<int> @{ @}; // @r{ok to specialize} 15442 15443 template <class T> void f (A<T>); 15444@} 15445 15446int main() 15447@{ 15448 f (std::A<float>()); // @r{lookup finds} std::f 15449 f (std::A<int>()); 15450@} 15451@end smallexample 15452 15453@node Type Traits 15454@section Type Traits 15455 15456The C++ front-end implements syntactic extensions that allow to 15457determine at compile time various characteristics of a type (or of a 15458pair of types). 15459 15460@table @code 15461@item __has_nothrow_assign (type) 15462If @code{type} is const qualified or is a reference type then the trait is 15463false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait 15464is true, else if @code{type} is a cv class or union type with copy assignment 15465operators that are known not to throw an exception then the trait is true, 15466else it is false. Requires: @code{type} shall be a complete type, 15467(possibly cv-qualified) @code{void}, or an array of unknown bound. 15468 15469@item __has_nothrow_copy (type) 15470If @code{__has_trivial_copy (type)} is true then the trait is true, else if 15471@code{type} is a cv class or union type with copy constructors that 15472are known not to throw an exception then the trait is true, else it is false. 15473Requires: @code{type} shall be a complete type, (possibly cv-qualified) 15474@code{void}, or an array of unknown bound. 15475 15476@item __has_nothrow_constructor (type) 15477If @code{__has_trivial_constructor (type)} is true then the trait is 15478true, else if @code{type} is a cv class or union type (or array 15479thereof) with a default constructor that is known not to throw an 15480exception then the trait is true, else it is false. Requires: 15481@code{type} shall be a complete type, (possibly cv-qualified) 15482@code{void}, or an array of unknown bound. 15483 15484@item __has_trivial_assign (type) 15485If @code{type} is const qualified or is a reference type then the trait is 15486false. Otherwise if @code{__is_pod (type)} is true then the trait is 15487true, else if @code{type} is a cv class or union type with a trivial 15488copy assignment ([class.copy]) then the trait is true, else it is 15489false. Requires: @code{type} shall be a complete type, (possibly 15490cv-qualified) @code{void}, or an array of unknown bound. 15491 15492@item __has_trivial_copy (type) 15493If @code{__is_pod (type)} is true or @code{type} is a reference type 15494then the trait is true, else if @code{type} is a cv class or union type 15495with a trivial copy constructor ([class.copy]) then the trait 15496is true, else it is false. Requires: @code{type} shall be a complete 15497type, (possibly cv-qualified) @code{void}, or an array of unknown bound. 15498 15499@item __has_trivial_constructor (type) 15500If @code{__is_pod (type)} is true then the trait is true, else if 15501@code{type} is a cv class or union type (or array thereof) with a 15502trivial default constructor ([class.ctor]) then the trait is true, 15503else it is false. Requires: @code{type} shall be a complete 15504type, (possibly cv-qualified) @code{void}, or an array of unknown bound. 15505 15506@item __has_trivial_destructor (type) 15507If @code{__is_pod (type)} is true or @code{type} is a reference type then 15508the trait is true, else if @code{type} is a cv class or union type (or 15509array thereof) with a trivial destructor ([class.dtor]) then the trait 15510is true, else it is false. Requires: @code{type} shall be a complete 15511type, (possibly cv-qualified) @code{void}, or an array of unknown bound. 15512 15513@item __has_virtual_destructor (type) 15514If @code{type} is a class type with a virtual destructor 15515([class.dtor]) then the trait is true, else it is false. Requires: 15516@code{type} shall be a complete type, (possibly cv-qualified) 15517@code{void}, or an array of unknown bound. 15518 15519@item __is_abstract (type) 15520If @code{type} is an abstract class ([class.abstract]) then the trait 15521is true, else it is false. Requires: @code{type} shall be a complete 15522type, (possibly cv-qualified) @code{void}, or an array of unknown bound. 15523 15524@item __is_base_of (base_type, derived_type) 15525If @code{base_type} is a base class of @code{derived_type} 15526([class.derived]) then the trait is true, otherwise it is false. 15527Top-level cv qualifications of @code{base_type} and 15528@code{derived_type} are ignored. For the purposes of this trait, a 15529class type is considered is own base. Requires: if @code{__is_class 15530(base_type)} and @code{__is_class (derived_type)} are true and 15531@code{base_type} and @code{derived_type} are not the same type 15532(disregarding cv-qualifiers), @code{derived_type} shall be a complete 15533type. Diagnostic is produced if this requirement is not met. 15534 15535@item __is_class (type) 15536If @code{type} is a cv class type, and not a union type 15537([basic.compound]) the trait is true, else it is false. 15538 15539@item __is_empty (type) 15540If @code{__is_class (type)} is false then the trait is false. 15541Otherwise @code{type} is considered empty if and only if: @code{type} 15542has no non-static data members, or all non-static data members, if 15543any, are bit-fields of length 0, and @code{type} has no virtual 15544members, and @code{type} has no virtual base classes, and @code{type} 15545has no base classes @code{base_type} for which 15546@code{__is_empty (base_type)} is false. Requires: @code{type} shall 15547be a complete type, (possibly cv-qualified) @code{void}, or an array 15548of unknown bound. 15549 15550@item __is_enum (type) 15551If @code{type} is a cv enumeration type ([basic.compound]) the trait is 15552true, else it is false. 15553 15554@item __is_literal_type (type) 15555If @code{type} is a literal type ([basic.types]) the trait is 15556true, else it is false. Requires: @code{type} shall be a complete type, 15557(possibly cv-qualified) @code{void}, or an array of unknown bound. 15558 15559@item __is_pod (type) 15560If @code{type} is a cv POD type ([basic.types]) then the trait is true, 15561else it is false. Requires: @code{type} shall be a complete type, 15562(possibly cv-qualified) @code{void}, or an array of unknown bound. 15563 15564@item __is_polymorphic (type) 15565If @code{type} is a polymorphic class ([class.virtual]) then the trait 15566is true, else it is false. Requires: @code{type} shall be a complete 15567type, (possibly cv-qualified) @code{void}, or an array of unknown bound. 15568 15569@item __is_standard_layout (type) 15570If @code{type} is a standard-layout type ([basic.types]) the trait is 15571true, else it is false. Requires: @code{type} shall be a complete 15572type, (possibly cv-qualified) @code{void}, or an array of unknown bound. 15573 15574@item __is_trivial (type) 15575If @code{type} is a trivial type ([basic.types]) the trait is 15576true, else it is false. Requires: @code{type} shall be a complete 15577type, (possibly cv-qualified) @code{void}, or an array of unknown bound. 15578 15579@item __is_union (type) 15580If @code{type} is a cv union type ([basic.compound]) the trait is 15581true, else it is false. 15582 15583@item __underlying_type (type) 15584The underlying type of @code{type}. Requires: @code{type} shall be 15585an enumeration type ([dcl.enum]). 15586 15587@end table 15588 15589@node Java Exceptions 15590@section Java Exceptions 15591 15592The Java language uses a slightly different exception handling model 15593from C++. Normally, GNU C++ will automatically detect when you are 15594writing C++ code that uses Java exceptions, and handle them 15595appropriately. However, if C++ code only needs to execute destructors 15596when Java exceptions are thrown through it, GCC will guess incorrectly. 15597Sample problematic code is: 15598 15599@smallexample 15600 struct S @{ ~S(); @}; 15601 extern void bar(); // @r{is written in Java, and may throw exceptions} 15602 void foo() 15603 @{ 15604 S s; 15605 bar(); 15606 @} 15607@end smallexample 15608 15609@noindent 15610The usual effect of an incorrect guess is a link failure, complaining of 15611a missing routine called @samp{__gxx_personality_v0}. 15612 15613You can inform the compiler that Java exceptions are to be used in a 15614translation unit, irrespective of what it might think, by writing 15615@samp{@w{#pragma GCC java_exceptions}} at the head of the file. This 15616@samp{#pragma} must appear before any functions that throw or catch 15617exceptions, or run destructors when exceptions are thrown through them. 15618 15619You cannot mix Java and C++ exceptions in the same translation unit. It 15620is believed to be safe to throw a C++ exception from one file through 15621another file compiled for the Java exception model, or vice versa, but 15622there may be bugs in this area. 15623 15624@node Deprecated Features 15625@section Deprecated Features 15626 15627In the past, the GNU C++ compiler was extended to experiment with new 15628features, at a time when the C++ language was still evolving. Now that 15629the C++ standard is complete, some of those features are superseded by 15630superior alternatives. Using the old features might cause a warning in 15631some cases that the feature will be dropped in the future. In other 15632cases, the feature might be gone already. 15633 15634While the list below is not exhaustive, it documents some of the options 15635that are now deprecated: 15636 15637@table @code 15638@item -fexternal-templates 15639@itemx -falt-external-templates 15640These are two of the many ways for G++ to implement template 15641instantiation. @xref{Template Instantiation}. The C++ standard clearly 15642defines how template definitions have to be organized across 15643implementation units. G++ has an implicit instantiation mechanism that 15644should work just fine for standard-conforming code. 15645 15646@item -fstrict-prototype 15647@itemx -fno-strict-prototype 15648Previously it was possible to use an empty prototype parameter list to 15649indicate an unspecified number of parameters (like C), rather than no 15650parameters, as C++ demands. This feature has been removed, except where 15651it is required for backwards compatibility. @xref{Backwards Compatibility}. 15652@end table 15653 15654G++ allows a virtual function returning @samp{void *} to be overridden 15655by one returning a different pointer type. This extension to the 15656covariant return type rules is now deprecated and will be removed from a 15657future version. 15658 15659The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and 15660their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated 15661and are now removed from G++. Code using these operators should be 15662modified to use @code{std::min} and @code{std::max} instead. 15663 15664The named return value extension has been deprecated, and is now 15665removed from G++. 15666 15667The use of initializer lists with new expressions has been deprecated, 15668and is now removed from G++. 15669 15670Floating and complex non-type template parameters have been deprecated, 15671and are now removed from G++. 15672 15673The implicit typename extension has been deprecated and is now 15674removed from G++. 15675 15676The use of default arguments in function pointers, function typedefs 15677and other places where they are not permitted by the standard is 15678deprecated and will be removed from a future version of G++. 15679 15680G++ allows floating-point literals to appear in integral constant expressions, 15681e.g. @samp{ enum E @{ e = int(2.2 * 3.7) @} } 15682This extension is deprecated and will be removed from a future version. 15683 15684G++ allows static data members of const floating-point type to be declared 15685with an initializer in a class definition. The standard only allows 15686initializers for static members of const integral types and const 15687enumeration types so this extension has been deprecated and will be removed 15688from a future version. 15689 15690@node Backwards Compatibility 15691@section Backwards Compatibility 15692@cindex Backwards Compatibility 15693@cindex ARM [Annotated C++ Reference Manual] 15694 15695Now that there is a definitive ISO standard C++, G++ has a specification 15696to adhere to. The C++ language evolved over time, and features that 15697used to be acceptable in previous drafts of the standard, such as the ARM 15698[Annotated C++ Reference Manual], are no longer accepted. In order to allow 15699compilation of C++ written to such drafts, G++ contains some backwards 15700compatibilities. @emph{All such backwards compatibility features are 15701liable to disappear in future versions of G++.} They should be considered 15702deprecated. @xref{Deprecated Features}. 15703 15704@table @code 15705@item For scope 15706If a variable is declared at for scope, it used to remain in scope until 15707the end of the scope which contained the for statement (rather than just 15708within the for scope). G++ retains this, but issues a warning, if such a 15709variable is accessed outside the for scope. 15710 15711@item Implicit C language 15712Old C system header files did not contain an @code{extern "C" @{@dots{}@}} 15713scope to set the language. On such systems, all header files are 15714implicitly scoped inside a C language scope. Also, an empty prototype 15715@code{()} will be treated as an unspecified number of arguments, rather 15716than no arguments, as C++ demands. 15717@end table 15718