1@c Copyright (C) 1988-2015 Free Software Foundation, Inc. 2 3@c This is part of the GCC manual. 4@c For copying conditions, see the file gcc.texi. 5 6@node C Extensions 7@chapter Extensions to the C Language Family 8@cindex extensions, C language 9@cindex C language extensions 10 11@opindex pedantic 12GNU C provides several language features not found in ISO standard C@. 13(The @option{-pedantic} option directs GCC to print a warning message if 14any of these features is used.) To test for the availability of these 15features in conditional compilation, check for a predefined macro 16@code{__GNUC__}, which is always defined under GCC@. 17 18These extensions are available in C and Objective-C@. Most of them are 19also available in C++. @xref{C++ Extensions,,Extensions to the 20C++ Language}, for extensions that apply @emph{only} to C++. 21 22Some features that are in ISO C99 but not C90 or C++ are also, as 23extensions, accepted by GCC in C90 mode and in C++. 24 25@menu 26* Statement Exprs:: Putting statements and declarations inside expressions. 27* Local Labels:: Labels local to a block. 28* Labels as Values:: Getting pointers to labels, and computed gotos. 29* Nested Functions:: As in Algol and Pascal, lexical scoping of functions. 30* Constructing Calls:: Dispatching a call to another function. 31* Typeof:: @code{typeof}: referring to the type of an expression. 32* Conditionals:: Omitting the middle operand of a @samp{?:} expression. 33* __int128:: 128-bit integers---@code{__int128}. 34* Long Long:: Double-word integers---@code{long long int}. 35* Complex:: Data types for complex numbers. 36* Floating Types:: Additional Floating Types. 37* Half-Precision:: Half-Precision Floating Point. 38* Decimal Float:: Decimal Floating Types. 39* Hex Floats:: Hexadecimal floating-point constants. 40* Fixed-Point:: Fixed-Point Types. 41* Named Address Spaces::Named address spaces. 42* Zero Length:: Zero-length arrays. 43* Empty Structures:: Structures with no members. 44* Variable Length:: Arrays whose length is computed at run time. 45* Variadic Macros:: Macros with a variable number of arguments. 46* Escaped Newlines:: Slightly looser rules for escaped newlines. 47* Subscripting:: Any array can be subscripted, even if not an lvalue. 48* Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers. 49* Pointers to Arrays:: Pointers to arrays with qualifiers work as expected. 50* Initializers:: Non-constant initializers. 51* Compound Literals:: Compound literals give structures, unions 52 or arrays as values. 53* Designated Inits:: Labeling elements of initializers. 54* Case Ranges:: `case 1 ... 9' and such. 55* Cast to Union:: Casting to union type from any member of the union. 56* Mixed Declarations:: Mixing declarations and code. 57* Function Attributes:: Declaring that functions have no side effects, 58 or that they can never return. 59* Label Attributes:: Specifying attributes on labels. 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* Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler. 71* Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files. 72* Incomplete Enums:: @code{enum foo;}, with details to follow. 73* Function Names:: Printable strings which are the name of the current 74 function. 75* Return Address:: Getting the return or frame address of a function. 76* Vector Extensions:: Using vector instructions through built-in functions. 77* Offsetof:: Special syntax for implementing @code{offsetof}. 78* __sync Builtins:: Legacy built-in functions for atomic memory access. 79* __atomic Builtins:: Atomic built-in functions with memory model. 80* Integer Overflow Builtins:: Built-in functions to perform arithmetics and 81 arithmetic overflow checking. 82* x86 specific memory model extensions for transactional memory:: x86 memory models. 83* Object Size Checking:: Built-in functions for limited buffer overflow 84 checking. 85* Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker. 86* Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension. 87* Other Builtins:: Other built-in functions. 88* Target Builtins:: Built-in functions specific to particular targets. 89* Target Format Checks:: Format checks specific to particular targets. 90* Pragmas:: Pragmas accepted by GCC. 91* Unnamed Fields:: Unnamed struct/union fields within structs/unions. 92* Thread-Local:: Per-thread variables. 93* Binary constants:: Binary constants using the @samp{0b} prefix. 94@end menu 95 96@node Statement Exprs 97@section Statements and Declarations in Expressions 98@cindex statements inside expressions 99@cindex declarations inside expressions 100@cindex expressions containing statements 101@cindex macros, statements in expressions 102 103@c the above section title wrapped and causes an underfull hbox.. i 104@c changed it from "within" to "in". --mew 4feb93 105A compound statement enclosed in parentheses may appear as an expression 106in GNU C@. This allows you to use loops, switches, and local variables 107within an expression. 108 109Recall that a compound statement is a sequence of statements surrounded 110by braces; in this construct, parentheses go around the braces. For 111example: 112 113@smallexample 114(@{ int y = foo (); int z; 115 if (y > 0) z = y; 116 else z = - y; 117 z; @}) 118@end smallexample 119 120@noindent 121is a valid (though slightly more complex than necessary) expression 122for the absolute value of @code{foo ()}. 123 124The last thing in the compound statement should be an expression 125followed by a semicolon; the value of this subexpression serves as the 126value of the entire construct. (If you use some other kind of statement 127last within the braces, the construct has type @code{void}, and thus 128effectively no value.) 129 130This feature is especially useful in making macro definitions ``safe'' (so 131that they evaluate each operand exactly once). For example, the 132``maximum'' function is commonly defined as a macro in standard C as 133follows: 134 135@smallexample 136#define max(a,b) ((a) > (b) ? (a) : (b)) 137@end smallexample 138 139@noindent 140@cindex side effects, macro argument 141But this definition computes either @var{a} or @var{b} twice, with bad 142results if the operand has side effects. In GNU C, if you know the 143type of the operands (here taken as @code{int}), you can define 144the macro safely as follows: 145 146@smallexample 147#define maxint(a,b) \ 148 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @}) 149@end smallexample 150 151Embedded statements are not allowed in constant expressions, such as 152the value of an enumeration constant, the width of a bit-field, or 153the initial value of a static variable. 154 155If you don't know the type of the operand, you can still do this, but you 156must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}). 157 158In G++, the result value of a statement expression undergoes array and 159function pointer decay, and is returned by value to the enclosing 160expression. For instance, if @code{A} is a class, then 161 162@smallexample 163 A a; 164 165 (@{a;@}).Foo () 166@end smallexample 167 168@noindent 169constructs a temporary @code{A} object to hold the result of the 170statement expression, and that is used to invoke @code{Foo}. 171Therefore the @code{this} pointer observed by @code{Foo} is not the 172address of @code{a}. 173 174In a statement expression, any temporaries created within a statement 175are destroyed at that statement's end. This makes statement 176expressions inside macros slightly different from function calls. In 177the latter case temporaries introduced during argument evaluation are 178destroyed at the end of the statement that includes the function 179call. In the statement expression case they are destroyed during 180the statement expression. For instance, 181 182@smallexample 183#define macro(a) (@{__typeof__(a) b = (a); b + 3; @}) 184template<typename T> T function(T a) @{ T b = a; return b + 3; @} 185 186void foo () 187@{ 188 macro (X ()); 189 function (X ()); 190@} 191@end smallexample 192 193@noindent 194has different places where temporaries are destroyed. For the 195@code{macro} case, the temporary @code{X} is destroyed just after 196the initialization of @code{b}. In the @code{function} case that 197temporary is destroyed when the function returns. 198 199These considerations mean that it is probably a bad idea to use 200statement expressions of this form in header files that are designed to 201work with C++. (Note that some versions of the GNU C Library contained 202header files using statement expressions that lead to precisely this 203bug.) 204 205Jumping into a statement expression with @code{goto} or using a 206@code{switch} statement outside the statement expression with a 207@code{case} or @code{default} label inside the statement expression is 208not permitted. Jumping into a statement expression with a computed 209@code{goto} (@pxref{Labels as Values}) has undefined behavior. 210Jumping out of a statement expression is permitted, but if the 211statement expression is part of a larger expression then it is 212unspecified which other subexpressions of that expression have been 213evaluated except where the language definition requires certain 214subexpressions to be evaluated before or after the statement 215expression. In any case, as with a function call, the evaluation of a 216statement expression is not interleaved with the evaluation of other 217parts of the containing expression. For example, 218 219@smallexample 220 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz(); 221@end smallexample 222 223@noindent 224calls @code{foo} and @code{bar1} and does not call @code{baz} but 225may or may not call @code{bar2}. If @code{bar2} is called, it is 226called after @code{foo} and before @code{bar1}. 227 228@node Local Labels 229@section Locally Declared Labels 230@cindex local labels 231@cindex macros, local labels 232 233GCC allows you to declare @dfn{local labels} in any nested block 234scope. A local label is just like an ordinary label, but you can 235only reference it (with a @code{goto} statement, or by taking its 236address) within the block in which it is declared. 237 238A local label declaration looks like this: 239 240@smallexample 241__label__ @var{label}; 242@end smallexample 243 244@noindent 245or 246 247@smallexample 248__label__ @var{label1}, @var{label2}, /* @r{@dots{}} */; 249@end smallexample 250 251Local label declarations must come at the beginning of the block, 252before any ordinary declarations or statements. 253 254The label declaration defines the label @emph{name}, but does not define 255the label itself. You must do this in the usual way, with 256@code{@var{label}:}, within the statements of the statement expression. 257 258The local label feature is useful for complex macros. If a macro 259contains nested loops, a @code{goto} can be useful for breaking out of 260them. However, an ordinary label whose scope is the whole function 261cannot be used: if the macro can be expanded several times in one 262function, the label is multiply defined in that function. A 263local label avoids this problem. For example: 264 265@smallexample 266#define SEARCH(value, array, target) \ 267do @{ \ 268 __label__ found; \ 269 typeof (target) _SEARCH_target = (target); \ 270 typeof (*(array)) *_SEARCH_array = (array); \ 271 int i, j; \ 272 int value; \ 273 for (i = 0; i < max; i++) \ 274 for (j = 0; j < max; j++) \ 275 if (_SEARCH_array[i][j] == _SEARCH_target) \ 276 @{ (value) = i; goto found; @} \ 277 (value) = -1; \ 278 found:; \ 279@} while (0) 280@end smallexample 281 282This could also be written using a statement expression: 283 284@smallexample 285#define SEARCH(array, target) \ 286(@{ \ 287 __label__ found; \ 288 typeof (target) _SEARCH_target = (target); \ 289 typeof (*(array)) *_SEARCH_array = (array); \ 290 int i, j; \ 291 int value; \ 292 for (i = 0; i < max; i++) \ 293 for (j = 0; j < max; j++) \ 294 if (_SEARCH_array[i][j] == _SEARCH_target) \ 295 @{ value = i; goto found; @} \ 296 value = -1; \ 297 found: \ 298 value; \ 299@}) 300@end smallexample 301 302Local label declarations also make the labels they declare visible to 303nested functions, if there are any. @xref{Nested Functions}, for details. 304 305@node Labels as Values 306@section Labels as Values 307@cindex labels as values 308@cindex computed gotos 309@cindex goto with computed label 310@cindex address of a label 311 312You can get the address of a label defined in the current function 313(or a containing function) with the unary operator @samp{&&}. The 314value has type @code{void *}. This value is a constant and can be used 315wherever a constant of that type is valid. For example: 316 317@smallexample 318void *ptr; 319/* @r{@dots{}} */ 320ptr = &&foo; 321@end smallexample 322 323To use these values, you need to be able to jump to one. This is done 324with the computed goto statement@footnote{The analogous feature in 325Fortran is called an assigned goto, but that name seems inappropriate in 326C, where one can do more than simply store label addresses in label 327variables.}, @code{goto *@var{exp};}. For example, 328 329@smallexample 330goto *ptr; 331@end smallexample 332 333@noindent 334Any expression of type @code{void *} is allowed. 335 336One way of using these constants is in initializing a static array that 337serves as a jump table: 338 339@smallexample 340static void *array[] = @{ &&foo, &&bar, &&hack @}; 341@end smallexample 342 343@noindent 344Then you can select a label with indexing, like this: 345 346@smallexample 347goto *array[i]; 348@end smallexample 349 350@noindent 351Note that this does not check whether the subscript is in bounds---array 352indexing in C never does that. 353 354Such an array of label values serves a purpose much like that of the 355@code{switch} statement. The @code{switch} statement is cleaner, so 356use that rather than an array unless the problem does not fit a 357@code{switch} statement very well. 358 359Another use of label values is in an interpreter for threaded code. 360The labels within the interpreter function can be stored in the 361threaded code for super-fast dispatching. 362 363You may not use this mechanism to jump to code in a different function. 364If you do that, totally unpredictable things happen. The best way to 365avoid this is to store the label address only in automatic variables and 366never pass it as an argument. 367 368An alternate way to write the above example is 369 370@smallexample 371static const int array[] = @{ &&foo - &&foo, &&bar - &&foo, 372 &&hack - &&foo @}; 373goto *(&&foo + array[i]); 374@end smallexample 375 376@noindent 377This is more friendly to code living in shared libraries, as it reduces 378the number of dynamic relocations that are needed, and by consequence, 379allows the data to be read-only. 380This alternative with label differences is not supported for the AVR target, 381please use the first approach for AVR programs. 382 383The @code{&&foo} expressions for the same label might have different 384values if the containing function is inlined or cloned. If a program 385relies on them being always the same, 386@code{__attribute__((__noinline__,__noclone__))} should be used to 387prevent inlining and cloning. If @code{&&foo} is used in a static 388variable initializer, inlining and cloning is forbidden. 389 390@node Nested Functions 391@section Nested Functions 392@cindex nested functions 393@cindex downward funargs 394@cindex thunks 395 396A @dfn{nested function} is a function defined inside another function. 397Nested functions are supported as an extension in GNU C, but are not 398supported by GNU C++. 399 400The nested function's name is local to the block where it is defined. 401For example, here we define a nested function named @code{square}, and 402call it twice: 403 404@smallexample 405@group 406foo (double a, double b) 407@{ 408 double square (double z) @{ return z * z; @} 409 410 return square (a) + square (b); 411@} 412@end group 413@end smallexample 414 415The nested function can access all the variables of the containing 416function that are visible at the point of its definition. This is 417called @dfn{lexical scoping}. For example, here we show a nested 418function which uses an inherited variable named @code{offset}: 419 420@smallexample 421@group 422bar (int *array, int offset, int size) 423@{ 424 int access (int *array, int index) 425 @{ return array[index + offset]; @} 426 int i; 427 /* @r{@dots{}} */ 428 for (i = 0; i < size; i++) 429 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */ 430@} 431@end group 432@end smallexample 433 434Nested function definitions are permitted within functions in the places 435where variable definitions are allowed; that is, in any block, mixed 436with the other declarations and statements in the block. 437 438It is possible to call the nested function from outside the scope of its 439name by storing its address or passing the address to another function: 440 441@smallexample 442hack (int *array, int size) 443@{ 444 void store (int index, int value) 445 @{ array[index] = value; @} 446 447 intermediate (store, size); 448@} 449@end smallexample 450 451Here, the function @code{intermediate} receives the address of 452@code{store} as an argument. If @code{intermediate} calls @code{store}, 453the arguments given to @code{store} are used to store into @code{array}. 454But this technique works only so long as the containing function 455(@code{hack}, in this example) does not exit. 456 457If you try to call the nested function through its address after the 458containing function exits, all hell breaks loose. If you try 459to call it after a containing scope level exits, and if it refers 460to some of the variables that are no longer in scope, you may be lucky, 461but it's not wise to take the risk. If, however, the nested function 462does not refer to anything that has gone out of scope, you should be 463safe. 464 465GCC implements taking the address of a nested function using a technique 466called @dfn{trampolines}. This technique was described in 467@cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX 468C++ Conference Proceedings, October 17-21, 1988). 469 470A nested function can jump to a label inherited from a containing 471function, provided the label is explicitly declared in the containing 472function (@pxref{Local Labels}). Such a jump returns instantly to the 473containing function, exiting the nested function that did the 474@code{goto} and any intermediate functions as well. Here is an example: 475 476@smallexample 477@group 478bar (int *array, int offset, int size) 479@{ 480 __label__ failure; 481 int access (int *array, int index) 482 @{ 483 if (index > size) 484 goto failure; 485 return array[index + offset]; 486 @} 487 int i; 488 /* @r{@dots{}} */ 489 for (i = 0; i < size; i++) 490 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */ 491 /* @r{@dots{}} */ 492 return 0; 493 494 /* @r{Control comes here from @code{access} 495 if it detects an error.} */ 496 failure: 497 return -1; 498@} 499@end group 500@end smallexample 501 502A nested function always has no linkage. Declaring one with 503@code{extern} or @code{static} is erroneous. If you need to declare the nested function 504before its definition, use @code{auto} (which is otherwise meaningless 505for function declarations). 506 507@smallexample 508bar (int *array, int offset, int size) 509@{ 510 __label__ failure; 511 auto int access (int *, int); 512 /* @r{@dots{}} */ 513 int access (int *array, int index) 514 @{ 515 if (index > size) 516 goto failure; 517 return array[index + offset]; 518 @} 519 /* @r{@dots{}} */ 520@} 521@end smallexample 522 523@node Constructing Calls 524@section Constructing Function Calls 525@cindex constructing calls 526@cindex forwarding calls 527 528Using the built-in functions described below, you can record 529the arguments a function received, and call another function 530with the same arguments, without knowing the number or types 531of the arguments. 532 533You can also record the return value of that function call, 534and later return that value, without knowing what data type 535the function tried to return (as long as your caller expects 536that data type). 537 538However, these built-in functions may interact badly with some 539sophisticated features or other extensions of the language. It 540is, therefore, not recommended to use them outside very simple 541functions acting as mere forwarders for their arguments. 542 543@deftypefn {Built-in Function} {void *} __builtin_apply_args () 544This built-in function returns a pointer to data 545describing how to perform a call with the same arguments as are passed 546to the current function. 547 548The function saves the arg pointer register, structure value address, 549and all registers that might be used to pass arguments to a function 550into a block of memory allocated on the stack. Then it returns the 551address of that block. 552@end deftypefn 553 554@deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size}) 555This built-in function invokes @var{function} 556with a copy of the parameters described by @var{arguments} 557and @var{size}. 558 559The value of @var{arguments} should be the value returned by 560@code{__builtin_apply_args}. The argument @var{size} specifies the size 561of the stack argument data, in bytes. 562 563This function returns a pointer to data describing 564how to return whatever value is returned by @var{function}. The data 565is saved in a block of memory allocated on the stack. 566 567It is not always simple to compute the proper value for @var{size}. The 568value is used by @code{__builtin_apply} to compute the amount of data 569that should be pushed on the stack and copied from the incoming argument 570area. 571@end deftypefn 572 573@deftypefn {Built-in Function} {void} __builtin_return (void *@var{result}) 574This built-in function returns the value described by @var{result} from 575the containing function. You should specify, for @var{result}, a value 576returned by @code{__builtin_apply}. 577@end deftypefn 578 579@deftypefn {Built-in Function} {} __builtin_va_arg_pack () 580This built-in function represents all anonymous arguments of an inline 581function. It can be used only in inline functions that are always 582inlined, never compiled as a separate function, such as those using 583@code{__attribute__ ((__always_inline__))} or 584@code{__attribute__ ((__gnu_inline__))} extern inline functions. 585It must be only passed as last argument to some other function 586with variable arguments. This is useful for writing small wrapper 587inlines for variable argument functions, when using preprocessor 588macros is undesirable. For example: 589@smallexample 590extern int myprintf (FILE *f, const char *format, ...); 591extern inline __attribute__ ((__gnu_inline__)) int 592myprintf (FILE *f, const char *format, ...) 593@{ 594 int r = fprintf (f, "myprintf: "); 595 if (r < 0) 596 return r; 597 int s = fprintf (f, format, __builtin_va_arg_pack ()); 598 if (s < 0) 599 return s; 600 return r + s; 601@} 602@end smallexample 603@end deftypefn 604 605@deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len () 606This built-in function returns the number of anonymous arguments of 607an inline function. It can be used only in inline functions that 608are always inlined, never compiled as a separate function, such 609as those using @code{__attribute__ ((__always_inline__))} or 610@code{__attribute__ ((__gnu_inline__))} extern inline functions. 611For example following does link- or run-time checking of open 612arguments for optimized code: 613@smallexample 614#ifdef __OPTIMIZE__ 615extern inline __attribute__((__gnu_inline__)) int 616myopen (const char *path, int oflag, ...) 617@{ 618 if (__builtin_va_arg_pack_len () > 1) 619 warn_open_too_many_arguments (); 620 621 if (__builtin_constant_p (oflag)) 622 @{ 623 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1) 624 @{ 625 warn_open_missing_mode (); 626 return __open_2 (path, oflag); 627 @} 628 return open (path, oflag, __builtin_va_arg_pack ()); 629 @} 630 631 if (__builtin_va_arg_pack_len () < 1) 632 return __open_2 (path, oflag); 633 634 return open (path, oflag, __builtin_va_arg_pack ()); 635@} 636#endif 637@end smallexample 638@end deftypefn 639 640@node Typeof 641@section Referring to a Type with @code{typeof} 642@findex typeof 643@findex sizeof 644@cindex macros, types of arguments 645 646Another way to refer to the type of an expression is with @code{typeof}. 647The syntax of using of this keyword looks like @code{sizeof}, but the 648construct acts semantically like a type name defined with @code{typedef}. 649 650There are two ways of writing the argument to @code{typeof}: with an 651expression or with a type. Here is an example with an expression: 652 653@smallexample 654typeof (x[0](1)) 655@end smallexample 656 657@noindent 658This assumes that @code{x} is an array of pointers to functions; 659the type described is that of the values of the functions. 660 661Here is an example with a typename as the argument: 662 663@smallexample 664typeof (int *) 665@end smallexample 666 667@noindent 668Here the type described is that of pointers to @code{int}. 669 670If you are writing a header file that must work when included in ISO C 671programs, write @code{__typeof__} instead of @code{typeof}. 672@xref{Alternate Keywords}. 673 674A @code{typeof} construct can be used anywhere a typedef name can be 675used. For example, you can use it in a declaration, in a cast, or inside 676of @code{sizeof} or @code{typeof}. 677 678The operand of @code{typeof} is evaluated for its side effects if and 679only if it is an expression of variably modified type or the name of 680such a type. 681 682@code{typeof} is often useful in conjunction with 683statement expressions (@pxref{Statement Exprs}). 684Here is how the two together can 685be used to define a safe ``maximum'' macro which operates on any 686arithmetic type and evaluates each of its arguments exactly once: 687 688@smallexample 689#define max(a,b) \ 690 (@{ typeof (a) _a = (a); \ 691 typeof (b) _b = (b); \ 692 _a > _b ? _a : _b; @}) 693@end smallexample 694 695@cindex underscores in variables in macros 696@cindex @samp{_} in variables in macros 697@cindex local variables in macros 698@cindex variables, local, in macros 699@cindex macros, local variables in 700 701The reason for using names that start with underscores for the local 702variables is to avoid conflicts with variable names that occur within the 703expressions that are substituted for @code{a} and @code{b}. Eventually we 704hope to design a new form of declaration syntax that allows you to declare 705variables whose scopes start only after their initializers; this will be a 706more reliable way to prevent such conflicts. 707 708@noindent 709Some more examples of the use of @code{typeof}: 710 711@itemize @bullet 712@item 713This declares @code{y} with the type of what @code{x} points to. 714 715@smallexample 716typeof (*x) y; 717@end smallexample 718 719@item 720This declares @code{y} as an array of such values. 721 722@smallexample 723typeof (*x) y[4]; 724@end smallexample 725 726@item 727This declares @code{y} as an array of pointers to characters: 728 729@smallexample 730typeof (typeof (char *)[4]) y; 731@end smallexample 732 733@noindent 734It is equivalent to the following traditional C declaration: 735 736@smallexample 737char *y[4]; 738@end smallexample 739 740To see the meaning of the declaration using @code{typeof}, and why it 741might be a useful way to write, rewrite it with these macros: 742 743@smallexample 744#define pointer(T) typeof(T *) 745#define array(T, N) typeof(T [N]) 746@end smallexample 747 748@noindent 749Now the declaration can be rewritten this way: 750 751@smallexample 752array (pointer (char), 4) y; 753@end smallexample 754 755@noindent 756Thus, @code{array (pointer (char), 4)} is the type of arrays of 4 757pointers to @code{char}. 758@end itemize 759 760In GNU C, but not GNU C++, you may also declare the type of a variable 761as @code{__auto_type}. In that case, the declaration must declare 762only one variable, whose declarator must just be an identifier, the 763declaration must be initialized, and the type of the variable is 764determined by the initializer; the name of the variable is not in 765scope until after the initializer. (In C++, you should use C++11 766@code{auto} for this purpose.) Using @code{__auto_type}, the 767``maximum'' macro above could be written as: 768 769@smallexample 770#define max(a,b) \ 771 (@{ __auto_type _a = (a); \ 772 __auto_type _b = (b); \ 773 _a > _b ? _a : _b; @}) 774@end smallexample 775 776Using @code{__auto_type} instead of @code{typeof} has two advantages: 777 778@itemize @bullet 779@item Each argument to the macro appears only once in the expansion of 780the macro. This prevents the size of the macro expansion growing 781exponentially when calls to such macros are nested inside arguments of 782such macros. 783 784@item If the argument to the macro has variably modified type, it is 785evaluated only once when using @code{__auto_type}, but twice if 786@code{typeof} is used. 787@end itemize 788 789@node Conditionals 790@section Conditionals with Omitted Operands 791@cindex conditional expressions, extensions 792@cindex omitted middle-operands 793@cindex middle-operands, omitted 794@cindex extensions, @code{?:} 795@cindex @code{?:} extensions 796 797The middle operand in a conditional expression may be omitted. Then 798if the first operand is nonzero, its value is the value of the conditional 799expression. 800 801Therefore, the expression 802 803@smallexample 804x ? : y 805@end smallexample 806 807@noindent 808has the value of @code{x} if that is nonzero; otherwise, the value of 809@code{y}. 810 811This example is perfectly equivalent to 812 813@smallexample 814x ? x : y 815@end smallexample 816 817@cindex side effect in @code{?:} 818@cindex @code{?:} side effect 819@noindent 820In this simple case, the ability to omit the middle operand is not 821especially useful. When it becomes useful is when the first operand does, 822or may (if it is a macro argument), contain a side effect. Then repeating 823the operand in the middle would perform the side effect twice. Omitting 824the middle operand uses the value already computed without the undesirable 825effects of recomputing it. 826 827@node __int128 828@section 128-bit Integers 829@cindex @code{__int128} data types 830 831As an extension the integer scalar type @code{__int128} is supported for 832targets which have an integer mode wide enough to hold 128 bits. 833Simply write @code{__int128} for a signed 128-bit integer, or 834@code{unsigned __int128} for an unsigned 128-bit integer. There is no 835support in GCC for expressing an integer constant of type @code{__int128} 836for targets with @code{long long} integer less than 128 bits wide. 837 838@node Long Long 839@section Double-Word Integers 840@cindex @code{long long} data types 841@cindex double-word arithmetic 842@cindex multiprecision arithmetic 843@cindex @code{LL} integer suffix 844@cindex @code{ULL} integer suffix 845 846ISO C99 supports data types for integers that are at least 64 bits wide, 847and as an extension GCC supports them in C90 mode and in C++. 848Simply write @code{long long int} for a signed integer, or 849@code{unsigned long long int} for an unsigned integer. To make an 850integer constant of type @code{long long int}, add the suffix @samp{LL} 851to the integer. To make an integer constant of type @code{unsigned long 852long int}, add the suffix @samp{ULL} to the integer. 853 854You can use these types in arithmetic like any other integer types. 855Addition, subtraction, and bitwise boolean operations on these types 856are open-coded on all types of machines. Multiplication is open-coded 857if the machine supports a fullword-to-doubleword widening multiply 858instruction. Division and shifts are open-coded only on machines that 859provide special support. The operations that are not open-coded use 860special library routines that come with GCC@. 861 862There may be pitfalls when you use @code{long long} types for function 863arguments without function prototypes. If a function 864expects type @code{int} for its argument, and you pass a value of type 865@code{long long int}, confusion results because the caller and the 866subroutine disagree about the number of bytes for the argument. 867Likewise, if the function expects @code{long long int} and you pass 868@code{int}. The best way to avoid such problems is to use prototypes. 869 870@node Complex 871@section Complex Numbers 872@cindex complex numbers 873@cindex @code{_Complex} keyword 874@cindex @code{__complex__} keyword 875 876ISO C99 supports complex floating data types, and as an extension GCC 877supports them in C90 mode and in C++. GCC also supports complex integer data 878types which are not part of ISO C99. You can declare complex types 879using the keyword @code{_Complex}. As an extension, the older GNU 880keyword @code{__complex__} is also supported. 881 882For example, @samp{_Complex double x;} declares @code{x} as a 883variable whose real part and imaginary part are both of type 884@code{double}. @samp{_Complex short int y;} declares @code{y} to 885have real and imaginary parts of type @code{short int}; this is not 886likely to be useful, but it shows that the set of complex types is 887complete. 888 889To write a constant with a complex data type, use the suffix @samp{i} or 890@samp{j} (either one; they are equivalent). For example, @code{2.5fi} 891has type @code{_Complex float} and @code{3i} has type 892@code{_Complex int}. Such a constant always has a pure imaginary 893value, but you can form any complex value you like by adding one to a 894real constant. This is a GNU extension; if you have an ISO C99 895conforming C library (such as the GNU C Library), and want to construct complex 896constants of floating type, you should include @code{<complex.h>} and 897use the macros @code{I} or @code{_Complex_I} instead. 898 899@cindex @code{__real__} keyword 900@cindex @code{__imag__} keyword 901To extract the real part of a complex-valued expression @var{exp}, write 902@code{__real__ @var{exp}}. Likewise, use @code{__imag__} to 903extract the imaginary part. This is a GNU extension; for values of 904floating type, you should use the ISO C99 functions @code{crealf}, 905@code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and 906@code{cimagl}, declared in @code{<complex.h>} and also provided as 907built-in functions by GCC@. 908 909@cindex complex conjugation 910The operator @samp{~} performs complex conjugation when used on a value 911with a complex type. This is a GNU extension; for values of 912floating type, you should use the ISO C99 functions @code{conjf}, 913@code{conj} and @code{conjl}, declared in @code{<complex.h>} and also 914provided as built-in functions by GCC@. 915 916GCC can allocate complex automatic variables in a noncontiguous 917fashion; it's even possible for the real part to be in a register while 918the imaginary part is on the stack (or vice versa). Only the DWARF 2 919debug info format can represent this, so use of DWARF 2 is recommended. 920If you are using the stabs debug info format, GCC describes a noncontiguous 921complex variable as if it were two separate variables of noncomplex type. 922If the variable's actual name is @code{foo}, the two fictitious 923variables are named @code{foo$real} and @code{foo$imag}. You can 924examine and set these two fictitious variables with your debugger. 925 926@node Floating Types 927@section Additional Floating Types 928@cindex additional floating types 929@cindex @code{__float80} data type 930@cindex @code{__float128} data type 931@cindex @code{w} floating point suffix 932@cindex @code{q} floating point suffix 933@cindex @code{W} floating point suffix 934@cindex @code{Q} floating point suffix 935 936As an extension, GNU C supports additional floating 937types, @code{__float80} and @code{__float128} to support 80-bit 938(@code{XFmode}) and 128-bit (@code{TFmode}) floating types. 939Support for additional types includes the arithmetic operators: 940add, subtract, multiply, divide; unary arithmetic operators; 941relational operators; equality operators; and conversions to and from 942integer and other floating types. Use a suffix @samp{w} or @samp{W} 943in a literal constant of type @code{__float80} and @samp{q} or @samp{Q} 944for @code{_float128}. You can declare complex types using the 945corresponding internal complex type, @code{XCmode} for @code{__float80} 946type and @code{TCmode} for @code{__float128} type: 947 948@smallexample 949typedef _Complex float __attribute__((mode(TC))) _Complex128; 950typedef _Complex float __attribute__((mode(XC))) _Complex80; 951@end smallexample 952 953Not all targets support additional floating-point types. @code{__float80} 954and @code{__float128} types are supported on x86 and IA-64 targets. 955The @code{__float128} type is supported on hppa HP-UX targets. 956 957@node Half-Precision 958@section Half-Precision Floating Point 959@cindex half-precision floating point 960@cindex @code{__fp16} data type 961 962On ARM targets, GCC supports half-precision (16-bit) floating point via 963the @code{__fp16} type. You must enable this type explicitly 964with the @option{-mfp16-format} command-line option in order to use it. 965 966ARM supports two incompatible representations for half-precision 967floating-point values. You must choose one of the representations and 968use it consistently in your program. 969 970Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format. 971This format can represent normalized values in the range of @math{2^{-14}} to 65504. 972There are 11 bits of significand precision, approximately 3 973decimal digits. 974 975Specifying @option{-mfp16-format=alternative} selects the ARM 976alternative format. This representation is similar to the IEEE 977format, but does not support infinities or NaNs. Instead, the range 978of exponents is extended, so that this format can represent normalized 979values in the range of @math{2^{-14}} to 131008. 980 981The @code{__fp16} type is a storage format only. For purposes 982of arithmetic and other operations, @code{__fp16} values in C or C++ 983expressions are automatically promoted to @code{float}. In addition, 984you cannot declare a function with a return value or parameters 985of type @code{__fp16}. 986 987Note that conversions from @code{double} to @code{__fp16} 988involve an intermediate conversion to @code{float}. Because 989of rounding, this can sometimes produce a different result than a 990direct conversion. 991 992ARM provides hardware support for conversions between 993@code{__fp16} and @code{float} values 994as an extension to VFP and NEON (Advanced SIMD). GCC generates 995code using these hardware instructions if you compile with 996options to select an FPU that provides them; 997for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp}, 998in addition to the @option{-mfp16-format} option to select 999a half-precision format. 1000 1001Language-level support for the @code{__fp16} data type is 1002independent of whether GCC generates code using hardware floating-point 1003instructions. In cases where hardware support is not specified, GCC 1004implements conversions between @code{__fp16} and @code{float} values 1005as library calls. 1006 1007@node Decimal Float 1008@section Decimal Floating Types 1009@cindex decimal floating types 1010@cindex @code{_Decimal32} data type 1011@cindex @code{_Decimal64} data type 1012@cindex @code{_Decimal128} data type 1013@cindex @code{df} integer suffix 1014@cindex @code{dd} integer suffix 1015@cindex @code{dl} integer suffix 1016@cindex @code{DF} integer suffix 1017@cindex @code{DD} integer suffix 1018@cindex @code{DL} integer suffix 1019 1020As an extension, GNU C supports decimal floating types as 1021defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal 1022floating types in GCC will evolve as the draft technical report changes. 1023Calling conventions for any target might also change. Not all targets 1024support decimal floating types. 1025 1026The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and 1027@code{_Decimal128}. They use a radix of ten, unlike the floating types 1028@code{float}, @code{double}, and @code{long double} whose radix is not 1029specified by the C standard but is usually two. 1030 1031Support for decimal floating types includes the arithmetic operators 1032add, subtract, multiply, divide; unary arithmetic operators; 1033relational operators; equality operators; and conversions to and from 1034integer and other floating types. Use a suffix @samp{df} or 1035@samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd} 1036or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for 1037@code{_Decimal128}. 1038 1039GCC support of decimal float as specified by the draft technical report 1040is incomplete: 1041 1042@itemize @bullet 1043@item 1044When the value of a decimal floating type cannot be represented in the 1045integer type to which it is being converted, the result is undefined 1046rather than the result value specified by the draft technical report. 1047 1048@item 1049GCC does not provide the C library functionality associated with 1050@file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and 1051@file{wchar.h}, which must come from a separate C library implementation. 1052Because of this the GNU C compiler does not define macro 1053@code{__STDC_DEC_FP__} to indicate that the implementation conforms to 1054the technical report. 1055@end itemize 1056 1057Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128} 1058are supported by the DWARF 2 debug information format. 1059 1060@node Hex Floats 1061@section Hex Floats 1062@cindex hex floats 1063 1064ISO C99 supports floating-point numbers written not only in the usual 1065decimal notation, such as @code{1.55e1}, but also numbers such as 1066@code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC 1067supports this in C90 mode (except in some cases when strictly 1068conforming) and in C++. In that format the 1069@samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are 1070mandatory. The exponent is a decimal number that indicates the power of 10712 by which the significant part is multiplied. Thus @samp{0x1.f} is 1072@tex 1073$1 {15\over16}$, 1074@end tex 1075@ifnottex 10761 15/16, 1077@end ifnottex 1078@samp{p3} multiplies it by 8, and the value of @code{0x1.fp3} 1079is the same as @code{1.55e1}. 1080 1081Unlike for floating-point numbers in the decimal notation the exponent 1082is always required in the hexadecimal notation. Otherwise the compiler 1083would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This 1084could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the 1085extension for floating-point constants of type @code{float}. 1086 1087@node Fixed-Point 1088@section Fixed-Point Types 1089@cindex fixed-point types 1090@cindex @code{_Fract} data type 1091@cindex @code{_Accum} data type 1092@cindex @code{_Sat} data type 1093@cindex @code{hr} fixed-suffix 1094@cindex @code{r} fixed-suffix 1095@cindex @code{lr} fixed-suffix 1096@cindex @code{llr} fixed-suffix 1097@cindex @code{uhr} fixed-suffix 1098@cindex @code{ur} fixed-suffix 1099@cindex @code{ulr} fixed-suffix 1100@cindex @code{ullr} fixed-suffix 1101@cindex @code{hk} fixed-suffix 1102@cindex @code{k} fixed-suffix 1103@cindex @code{lk} fixed-suffix 1104@cindex @code{llk} fixed-suffix 1105@cindex @code{uhk} fixed-suffix 1106@cindex @code{uk} fixed-suffix 1107@cindex @code{ulk} fixed-suffix 1108@cindex @code{ullk} fixed-suffix 1109@cindex @code{HR} fixed-suffix 1110@cindex @code{R} fixed-suffix 1111@cindex @code{LR} fixed-suffix 1112@cindex @code{LLR} fixed-suffix 1113@cindex @code{UHR} fixed-suffix 1114@cindex @code{UR} fixed-suffix 1115@cindex @code{ULR} fixed-suffix 1116@cindex @code{ULLR} fixed-suffix 1117@cindex @code{HK} fixed-suffix 1118@cindex @code{K} fixed-suffix 1119@cindex @code{LK} fixed-suffix 1120@cindex @code{LLK} fixed-suffix 1121@cindex @code{UHK} fixed-suffix 1122@cindex @code{UK} fixed-suffix 1123@cindex @code{ULK} fixed-suffix 1124@cindex @code{ULLK} fixed-suffix 1125 1126As an extension, GNU C supports fixed-point types as 1127defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point 1128types in GCC will evolve as the draft technical report changes. 1129Calling conventions for any target might also change. Not all targets 1130support fixed-point types. 1131 1132The fixed-point types are 1133@code{short _Fract}, 1134@code{_Fract}, 1135@code{long _Fract}, 1136@code{long long _Fract}, 1137@code{unsigned short _Fract}, 1138@code{unsigned _Fract}, 1139@code{unsigned long _Fract}, 1140@code{unsigned long long _Fract}, 1141@code{_Sat short _Fract}, 1142@code{_Sat _Fract}, 1143@code{_Sat long _Fract}, 1144@code{_Sat long long _Fract}, 1145@code{_Sat unsigned short _Fract}, 1146@code{_Sat unsigned _Fract}, 1147@code{_Sat unsigned long _Fract}, 1148@code{_Sat unsigned long long _Fract}, 1149@code{short _Accum}, 1150@code{_Accum}, 1151@code{long _Accum}, 1152@code{long long _Accum}, 1153@code{unsigned short _Accum}, 1154@code{unsigned _Accum}, 1155@code{unsigned long _Accum}, 1156@code{unsigned long long _Accum}, 1157@code{_Sat short _Accum}, 1158@code{_Sat _Accum}, 1159@code{_Sat long _Accum}, 1160@code{_Sat long long _Accum}, 1161@code{_Sat unsigned short _Accum}, 1162@code{_Sat unsigned _Accum}, 1163@code{_Sat unsigned long _Accum}, 1164@code{_Sat unsigned long long _Accum}. 1165 1166Fixed-point data values contain fractional and optional integral parts. 1167The format of fixed-point data varies and depends on the target machine. 1168 1169Support for fixed-point types includes: 1170@itemize @bullet 1171@item 1172prefix and postfix increment and decrement operators (@code{++}, @code{--}) 1173@item 1174unary arithmetic operators (@code{+}, @code{-}, @code{!}) 1175@item 1176binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/}) 1177@item 1178binary shift operators (@code{<<}, @code{>>}) 1179@item 1180relational operators (@code{<}, @code{<=}, @code{>=}, @code{>}) 1181@item 1182equality operators (@code{==}, @code{!=}) 1183@item 1184assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=}, 1185@code{<<=}, @code{>>=}) 1186@item 1187conversions to and from integer, floating-point, or fixed-point types 1188@end itemize 1189 1190Use a suffix in a fixed-point literal constant: 1191@itemize 1192@item @samp{hr} or @samp{HR} for @code{short _Fract} and 1193@code{_Sat short _Fract} 1194@item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract} 1195@item @samp{lr} or @samp{LR} for @code{long _Fract} and 1196@code{_Sat long _Fract} 1197@item @samp{llr} or @samp{LLR} for @code{long long _Fract} and 1198@code{_Sat long long _Fract} 1199@item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and 1200@code{_Sat unsigned short _Fract} 1201@item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and 1202@code{_Sat unsigned _Fract} 1203@item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and 1204@code{_Sat unsigned long _Fract} 1205@item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract} 1206and @code{_Sat unsigned long long _Fract} 1207@item @samp{hk} or @samp{HK} for @code{short _Accum} and 1208@code{_Sat short _Accum} 1209@item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum} 1210@item @samp{lk} or @samp{LK} for @code{long _Accum} and 1211@code{_Sat long _Accum} 1212@item @samp{llk} or @samp{LLK} for @code{long long _Accum} and 1213@code{_Sat long long _Accum} 1214@item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and 1215@code{_Sat unsigned short _Accum} 1216@item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and 1217@code{_Sat unsigned _Accum} 1218@item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and 1219@code{_Sat unsigned long _Accum} 1220@item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum} 1221and @code{_Sat unsigned long long _Accum} 1222@end itemize 1223 1224GCC support of fixed-point types as specified by the draft technical report 1225is incomplete: 1226 1227@itemize @bullet 1228@item 1229Pragmas to control overflow and rounding behaviors are not implemented. 1230@end itemize 1231 1232Fixed-point types are supported by the DWARF 2 debug information format. 1233 1234@node Named Address Spaces 1235@section Named Address Spaces 1236@cindex Named Address Spaces 1237 1238As an extension, GNU C supports named address spaces as 1239defined in the N1275 draft of ISO/IEC DTR 18037. Support for named 1240address spaces in GCC will evolve as the draft technical report 1241changes. Calling conventions for any target might also change. At 1242present, only the AVR, SPU, M32C, and RL78 targets support address 1243spaces other than the generic address space. 1244 1245Address space identifiers may be used exactly like any other C type 1246qualifier (e.g., @code{const} or @code{volatile}). See the N1275 1247document for more details. 1248 1249@anchor{AVR Named Address Spaces} 1250@subsection AVR Named Address Spaces 1251 1252On the AVR target, there are several address spaces that can be used 1253in order to put read-only data into the flash memory and access that 1254data by means of the special instructions @code{LPM} or @code{ELPM} 1255needed to read from flash. 1256 1257Per default, any data including read-only data is located in RAM 1258(the generic address space) so that non-generic address spaces are 1259needed to locate read-only data in flash memory 1260@emph{and} to generate the right instructions to access this data 1261without using (inline) assembler code. 1262 1263@table @code 1264@item __flash 1265@cindex @code{__flash} AVR Named Address Spaces 1266The @code{__flash} qualifier locates data in the 1267@code{.progmem.data} section. Data is read using the @code{LPM} 1268instruction. Pointers to this address space are 16 bits wide. 1269 1270@item __flash1 1271@itemx __flash2 1272@itemx __flash3 1273@itemx __flash4 1274@itemx __flash5 1275@cindex @code{__flash1} AVR Named Address Spaces 1276@cindex @code{__flash2} AVR Named Address Spaces 1277@cindex @code{__flash3} AVR Named Address Spaces 1278@cindex @code{__flash4} AVR Named Address Spaces 1279@cindex @code{__flash5} AVR Named Address Spaces 1280These are 16-bit address spaces locating data in section 1281@code{.progmem@var{N}.data} where @var{N} refers to 1282address space @code{__flash@var{N}}. 1283The compiler sets the @code{RAMPZ} segment register appropriately 1284before reading data by means of the @code{ELPM} instruction. 1285 1286@item __memx 1287@cindex @code{__memx} AVR Named Address Spaces 1288This is a 24-bit address space that linearizes flash and RAM: 1289If the high bit of the address is set, data is read from 1290RAM using the lower two bytes as RAM address. 1291If the high bit of the address is clear, data is read from flash 1292with @code{RAMPZ} set according to the high byte of the address. 1293@xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}. 1294 1295Objects in this address space are located in @code{.progmemx.data}. 1296@end table 1297 1298@b{Example} 1299 1300@smallexample 1301char my_read (const __flash char ** p) 1302@{ 1303 /* p is a pointer to RAM that points to a pointer to flash. 1304 The first indirection of p reads that flash pointer 1305 from RAM and the second indirection reads a char from this 1306 flash address. */ 1307 1308 return **p; 1309@} 1310 1311/* Locate array[] in flash memory */ 1312const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @}; 1313 1314int i = 1; 1315 1316int main (void) 1317@{ 1318 /* Return 17 by reading from flash memory */ 1319 return array[array[i]]; 1320@} 1321@end smallexample 1322 1323@noindent 1324For each named address space supported by avr-gcc there is an equally 1325named but uppercase built-in macro defined. 1326The purpose is to facilitate testing if respective address space 1327support is available or not: 1328 1329@smallexample 1330#ifdef __FLASH 1331const __flash int var = 1; 1332 1333int read_var (void) 1334@{ 1335 return var; 1336@} 1337#else 1338#include <avr/pgmspace.h> /* From AVR-LibC */ 1339 1340const int var PROGMEM = 1; 1341 1342int read_var (void) 1343@{ 1344 return (int) pgm_read_word (&var); 1345@} 1346#endif /* __FLASH */ 1347@end smallexample 1348 1349@noindent 1350Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}} 1351locates data in flash but 1352accesses to these data read from generic address space, i.e.@: 1353from RAM, 1354so that you need special accessors like @code{pgm_read_byte} 1355from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} 1356together with attribute @code{progmem}. 1357 1358@noindent 1359@b{Limitations and caveats} 1360 1361@itemize 1362@item 1363Reading across the 64@tie{}KiB section boundary of 1364the @code{__flash} or @code{__flash@var{N}} address spaces 1365shows undefined behavior. The only address space that 1366supports reading across the 64@tie{}KiB flash segment boundaries is 1367@code{__memx}. 1368 1369@item 1370If you use one of the @code{__flash@var{N}} address spaces 1371you must arrange your linker script to locate the 1372@code{.progmem@var{N}.data} sections according to your needs. 1373 1374@item 1375Any data or pointers to the non-generic address spaces must 1376be qualified as @code{const}, i.e.@: as read-only data. 1377This still applies if the data in one of these address 1378spaces like software version number or calibration lookup table are intended to 1379be changed after load time by, say, a boot loader. In this case 1380the right qualification is @code{const} @code{volatile} so that the compiler 1381must not optimize away known values or insert them 1382as immediates into operands of instructions. 1383 1384@item 1385The following code initializes a variable @code{pfoo} 1386located in static storage with a 24-bit address: 1387@smallexample 1388extern const __memx char foo; 1389const __memx void *pfoo = &foo; 1390@end smallexample 1391 1392@noindent 1393Such code requires at least binutils 2.23, see 1394@w{@uref{http://sourceware.org/PR13503,PR13503}}. 1395 1396@end itemize 1397 1398@subsection M32C Named Address Spaces 1399@cindex @code{__far} M32C Named Address Spaces 1400 1401On the M32C target, with the R8C and M16C CPU variants, variables 1402qualified with @code{__far} are accessed using 32-bit addresses in 1403order to access memory beyond the first 64@tie{}Ki bytes. If 1404@code{__far} is used with the M32CM or M32C CPU variants, it has no 1405effect. 1406 1407@subsection RL78 Named Address Spaces 1408@cindex @code{__far} RL78 Named Address Spaces 1409 1410On the RL78 target, variables qualified with @code{__far} are accessed 1411with 32-bit pointers (20-bit addresses) rather than the default 16-bit 1412addresses. Non-far variables are assumed to appear in the topmost 141364@tie{}KiB of the address space. 1414 1415@subsection SPU Named Address Spaces 1416@cindex @code{__ea} SPU Named Address Spaces 1417 1418On the SPU target variables may be declared as 1419belonging to another address space by qualifying the type with the 1420@code{__ea} address space identifier: 1421 1422@smallexample 1423extern int __ea i; 1424@end smallexample 1425 1426@noindent 1427The compiler generates special code to access the variable @code{i}. 1428It may use runtime library 1429support, or generate special machine instructions to access that address 1430space. 1431 1432@node Zero Length 1433@section Arrays of Length Zero 1434@cindex arrays of length zero 1435@cindex zero-length arrays 1436@cindex length-zero arrays 1437@cindex flexible array members 1438 1439Zero-length arrays are allowed in GNU C@. They are very useful as the 1440last element of a structure that is really a header for a variable-length 1441object: 1442 1443@smallexample 1444struct line @{ 1445 int length; 1446 char contents[0]; 1447@}; 1448 1449struct line *thisline = (struct line *) 1450 malloc (sizeof (struct line) + this_length); 1451thisline->length = this_length; 1452@end smallexample 1453 1454In ISO C90, you would have to give @code{contents} a length of 1, which 1455means either you waste space or complicate the argument to @code{malloc}. 1456 1457In ISO C99, you would use a @dfn{flexible array member}, which is 1458slightly different in syntax and semantics: 1459 1460@itemize @bullet 1461@item 1462Flexible array members are written as @code{contents[]} without 1463the @code{0}. 1464 1465@item 1466Flexible array members have incomplete type, and so the @code{sizeof} 1467operator may not be applied. As a quirk of the original implementation 1468of zero-length arrays, @code{sizeof} evaluates to zero. 1469 1470@item 1471Flexible array members may only appear as the last member of a 1472@code{struct} that is otherwise non-empty. 1473 1474@item 1475A structure containing a flexible array member, or a union containing 1476such a structure (possibly recursively), may not be a member of a 1477structure or an element of an array. (However, these uses are 1478permitted by GCC as extensions.) 1479@end itemize 1480 1481Non-empty initialization of zero-length 1482arrays is treated like any case where there are more initializer 1483elements than the array holds, in that a suitable warning about ``excess 1484elements in array'' is given, and the excess elements (all of them, in 1485this case) are ignored. 1486 1487GCC allows static initialization of flexible array members. 1488This is equivalent to defining a new structure containing the original 1489structure followed by an array of sufficient size to contain the data. 1490E.g.@: in the following, @code{f1} is constructed as if it were declared 1491like @code{f2}. 1492 1493@smallexample 1494struct f1 @{ 1495 int x; int y[]; 1496@} f1 = @{ 1, @{ 2, 3, 4 @} @}; 1497 1498struct f2 @{ 1499 struct f1 f1; int data[3]; 1500@} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @}; 1501@end smallexample 1502 1503@noindent 1504The convenience of this extension is that @code{f1} has the desired 1505type, eliminating the need to consistently refer to @code{f2.f1}. 1506 1507This has symmetry with normal static arrays, in that an array of 1508unknown size is also written with @code{[]}. 1509 1510Of course, this extension only makes sense if the extra data comes at 1511the end of a top-level object, as otherwise we would be overwriting 1512data at subsequent offsets. To avoid undue complication and confusion 1513with initialization of deeply nested arrays, we simply disallow any 1514non-empty initialization except when the structure is the top-level 1515object. For example: 1516 1517@smallexample 1518struct foo @{ int x; int y[]; @}; 1519struct bar @{ struct foo z; @}; 1520 1521struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.} 1522struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.} 1523struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.} 1524struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.} 1525@end smallexample 1526 1527@node Empty Structures 1528@section Structures with No Members 1529@cindex empty structures 1530@cindex zero-size structures 1531 1532GCC permits a C structure to have no members: 1533 1534@smallexample 1535struct empty @{ 1536@}; 1537@end smallexample 1538 1539The structure has size zero. In C++, empty structures are part 1540of the language. G++ treats empty structures as if they had a single 1541member of type @code{char}. 1542 1543@node Variable Length 1544@section Arrays of Variable Length 1545@cindex variable-length arrays 1546@cindex arrays of variable length 1547@cindex VLAs 1548 1549Variable-length automatic arrays are allowed in ISO C99, and as an 1550extension GCC accepts them in C90 mode and in C++. These arrays are 1551declared like any other automatic arrays, but with a length that is not 1552a constant expression. The storage is allocated at the point of 1553declaration and deallocated when the block scope containing the declaration 1554exits. For 1555example: 1556 1557@smallexample 1558FILE * 1559concat_fopen (char *s1, char *s2, char *mode) 1560@{ 1561 char str[strlen (s1) + strlen (s2) + 1]; 1562 strcpy (str, s1); 1563 strcat (str, s2); 1564 return fopen (str, mode); 1565@} 1566@end smallexample 1567 1568@cindex scope of a variable length array 1569@cindex variable-length array scope 1570@cindex deallocating variable length arrays 1571Jumping or breaking out of the scope of the array name deallocates the 1572storage. Jumping into the scope is not allowed; you get an error 1573message for it. 1574 1575@cindex variable-length array in a structure 1576As an extension, GCC accepts variable-length arrays as a member of 1577a structure or a union. For example: 1578 1579@smallexample 1580void 1581foo (int n) 1582@{ 1583 struct S @{ int x[n]; @}; 1584@} 1585@end smallexample 1586 1587@cindex @code{alloca} vs variable-length arrays 1588You can use the function @code{alloca} to get an effect much like 1589variable-length arrays. The function @code{alloca} is available in 1590many other C implementations (but not in all). On the other hand, 1591variable-length arrays are more elegant. 1592 1593There are other differences between these two methods. Space allocated 1594with @code{alloca} exists until the containing @emph{function} returns. 1595The space for a variable-length array is deallocated as soon as the array 1596name's scope ends. (If you use both variable-length arrays and 1597@code{alloca} in the same function, deallocation of a variable-length array 1598also deallocates anything more recently allocated with @code{alloca}.) 1599 1600You can also use variable-length arrays as arguments to functions: 1601 1602@smallexample 1603struct entry 1604tester (int len, char data[len][len]) 1605@{ 1606 /* @r{@dots{}} */ 1607@} 1608@end smallexample 1609 1610The length of an array is computed once when the storage is allocated 1611and is remembered for the scope of the array in case you access it with 1612@code{sizeof}. 1613 1614If you want to pass the array first and the length afterward, you can 1615use a forward declaration in the parameter list---another GNU extension. 1616 1617@smallexample 1618struct entry 1619tester (int len; char data[len][len], int len) 1620@{ 1621 /* @r{@dots{}} */ 1622@} 1623@end smallexample 1624 1625@cindex parameter forward declaration 1626The @samp{int len} before the semicolon is a @dfn{parameter forward 1627declaration}, and it serves the purpose of making the name @code{len} 1628known when the declaration of @code{data} is parsed. 1629 1630You can write any number of such parameter forward declarations in the 1631parameter list. They can be separated by commas or semicolons, but the 1632last one must end with a semicolon, which is followed by the ``real'' 1633parameter declarations. Each forward declaration must match a ``real'' 1634declaration in parameter name and data type. ISO C99 does not support 1635parameter forward declarations. 1636 1637@node Variadic Macros 1638@section Macros with a Variable Number of Arguments. 1639@cindex variable number of arguments 1640@cindex macro with variable arguments 1641@cindex rest argument (in macro) 1642@cindex variadic macros 1643 1644In the ISO C standard of 1999, a macro can be declared to accept a 1645variable number of arguments much as a function can. The syntax for 1646defining the macro is similar to that of a function. Here is an 1647example: 1648 1649@smallexample 1650#define debug(format, ...) fprintf (stderr, format, __VA_ARGS__) 1651@end smallexample 1652 1653@noindent 1654Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of 1655such a macro, it represents the zero or more tokens until the closing 1656parenthesis that ends the invocation, including any commas. This set of 1657tokens replaces the identifier @code{__VA_ARGS__} in the macro body 1658wherever it appears. See the CPP manual for more information. 1659 1660GCC has long supported variadic macros, and used a different syntax that 1661allowed you to give a name to the variable arguments just like any other 1662argument. Here is an example: 1663 1664@smallexample 1665#define debug(format, args...) fprintf (stderr, format, args) 1666@end smallexample 1667 1668@noindent 1669This is in all ways equivalent to the ISO C example above, but arguably 1670more readable and descriptive. 1671 1672GNU CPP has two further variadic macro extensions, and permits them to 1673be used with either of the above forms of macro definition. 1674 1675In standard C, you are not allowed to leave the variable argument out 1676entirely; but you are allowed to pass an empty argument. For example, 1677this invocation is invalid in ISO C, because there is no comma after 1678the string: 1679 1680@smallexample 1681debug ("A message") 1682@end smallexample 1683 1684GNU CPP permits you to completely omit the variable arguments in this 1685way. In the above examples, the compiler would complain, though since 1686the expansion of the macro still has the extra comma after the format 1687string. 1688 1689To help solve this problem, CPP behaves specially for variable arguments 1690used with the token paste operator, @samp{##}. If instead you write 1691 1692@smallexample 1693#define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__) 1694@end smallexample 1695 1696@noindent 1697and if the variable arguments are omitted or empty, the @samp{##} 1698operator causes the preprocessor to remove the comma before it. If you 1699do provide some variable arguments in your macro invocation, GNU CPP 1700does not complain about the paste operation and instead places the 1701variable arguments after the comma. Just like any other pasted macro 1702argument, these arguments are not macro expanded. 1703 1704@node Escaped Newlines 1705@section Slightly Looser Rules for Escaped Newlines 1706@cindex escaped newlines 1707@cindex newlines (escaped) 1708 1709The preprocessor treatment of escaped newlines is more relaxed 1710than that specified by the C90 standard, which requires the newline 1711to immediately follow a backslash. 1712GCC's implementation allows whitespace in the form 1713of spaces, horizontal and vertical tabs, and form feeds between the 1714backslash and the subsequent newline. The preprocessor issues a 1715warning, but treats it as a valid escaped newline and combines the two 1716lines to form a single logical line. This works within comments and 1717tokens, as well as between tokens. Comments are @emph{not} treated as 1718whitespace for the purposes of this relaxation, since they have not 1719yet been replaced with spaces. 1720 1721@node Subscripting 1722@section Non-Lvalue Arrays May Have Subscripts 1723@cindex subscripting 1724@cindex arrays, non-lvalue 1725 1726@cindex subscripting and function values 1727In ISO C99, arrays that are not lvalues still decay to pointers, and 1728may be subscripted, although they may not be modified or used after 1729the next sequence point and the unary @samp{&} operator may not be 1730applied to them. As an extension, GNU C allows such arrays to be 1731subscripted in C90 mode, though otherwise they do not decay to 1732pointers outside C99 mode. For example, 1733this is valid in GNU C though not valid in C90: 1734 1735@smallexample 1736@group 1737struct foo @{int a[4];@}; 1738 1739struct foo f(); 1740 1741bar (int index) 1742@{ 1743 return f().a[index]; 1744@} 1745@end group 1746@end smallexample 1747 1748@node Pointer Arith 1749@section Arithmetic on @code{void}- and Function-Pointers 1750@cindex void pointers, arithmetic 1751@cindex void, size of pointer to 1752@cindex function pointers, arithmetic 1753@cindex function, size of pointer to 1754 1755In GNU C, addition and subtraction operations are supported on pointers to 1756@code{void} and on pointers to functions. This is done by treating the 1757size of a @code{void} or of a function as 1. 1758 1759A consequence of this is that @code{sizeof} is also allowed on @code{void} 1760and on function types, and returns 1. 1761 1762@opindex Wpointer-arith 1763The option @option{-Wpointer-arith} requests a warning if these extensions 1764are used. 1765 1766@node Pointers to Arrays 1767@section Pointers to Arrays with Qualifiers Work as Expected 1768@cindex pointers to arrays 1769@cindex const qualifier 1770 1771In GNU C, pointers to arrays with qualifiers work similar to pointers 1772to other qualified types. For example, a value of type @code{int (*)[5]} 1773can be used to initialize a variable of type @code{const int (*)[5]}. 1774These types are incompatible in ISO C because the @code{const} qualifier 1775is formally attached to the element type of the array and not the 1776array itself. 1777 1778@smallexample 1779extern void 1780transpose (int N, int M, double out[M][N], const double in[N][M]); 1781double x[3][2]; 1782double y[2][3]; 1783@r{@dots{}} 1784transpose(3, 2, y, x); 1785@end smallexample 1786 1787@node Initializers 1788@section Non-Constant Initializers 1789@cindex initializers, non-constant 1790@cindex non-constant initializers 1791 1792As in standard C++ and ISO C99, the elements of an aggregate initializer for an 1793automatic variable are not required to be constant expressions in GNU C@. 1794Here is an example of an initializer with run-time varying elements: 1795 1796@smallexample 1797foo (float f, float g) 1798@{ 1799 float beat_freqs[2] = @{ f-g, f+g @}; 1800 /* @r{@dots{}} */ 1801@} 1802@end smallexample 1803 1804@node Compound Literals 1805@section Compound Literals 1806@cindex constructor expressions 1807@cindex initializations in expressions 1808@cindex structures, constructor expression 1809@cindex expressions, constructor 1810@cindex compound literals 1811@c The GNU C name for what C99 calls compound literals was "constructor expressions". 1812 1813ISO C99 supports compound literals. A compound literal looks like 1814a cast containing an initializer. Its value is an object of the 1815type specified in the cast, containing the elements specified in 1816the initializer; it is an lvalue. As an extension, GCC supports 1817compound literals in C90 mode and in C++, though the semantics are 1818somewhat different in C++. 1819 1820Usually, the specified type is a structure. Assume that 1821@code{struct foo} and @code{structure} are declared as shown: 1822 1823@smallexample 1824struct foo @{int a; char b[2];@} structure; 1825@end smallexample 1826 1827@noindent 1828Here is an example of constructing a @code{struct foo} with a compound literal: 1829 1830@smallexample 1831structure = ((struct foo) @{x + y, 'a', 0@}); 1832@end smallexample 1833 1834@noindent 1835This is equivalent to writing the following: 1836 1837@smallexample 1838@{ 1839 struct foo temp = @{x + y, 'a', 0@}; 1840 structure = temp; 1841@} 1842@end smallexample 1843 1844You can also construct an array, though this is dangerous in C++, as 1845explained below. If all the elements of the compound literal are 1846(made up of) simple constant expressions, suitable for use in 1847initializers of objects of static storage duration, then the compound 1848literal can be coerced to a pointer to its first element and used in 1849such an initializer, as shown here: 1850 1851@smallexample 1852char **foo = (char *[]) @{ "x", "y", "z" @}; 1853@end smallexample 1854 1855Compound literals for scalar types and union types are 1856also allowed, but then the compound literal is equivalent 1857to a cast. 1858 1859As a GNU extension, GCC allows initialization of objects with static storage 1860duration by compound literals (which is not possible in ISO C99, because 1861the initializer is not a constant). 1862It is handled as if the object is initialized only with the bracket 1863enclosed list if the types of the compound literal and the object match. 1864The initializer list of the compound literal must be constant. 1865If the object being initialized has array type of unknown size, the size is 1866determined by compound literal size. 1867 1868@smallexample 1869static struct foo x = (struct foo) @{1, 'a', 'b'@}; 1870static int y[] = (int []) @{1, 2, 3@}; 1871static int z[] = (int [3]) @{1@}; 1872@end smallexample 1873 1874@noindent 1875The above lines are equivalent to the following: 1876@smallexample 1877static struct foo x = @{1, 'a', 'b'@}; 1878static int y[] = @{1, 2, 3@}; 1879static int z[] = @{1, 0, 0@}; 1880@end smallexample 1881 1882In C, a compound literal designates an unnamed object with static or 1883automatic storage duration. In C++, a compound literal designates a 1884temporary object, which only lives until the end of its 1885full-expression. As a result, well-defined C code that takes the 1886address of a subobject of a compound literal can be undefined in C++, 1887so the C++ compiler rejects the conversion of a temporary array to a pointer. 1888For instance, if the array compound literal example above appeared 1889inside a function, any subsequent use of @samp{foo} in C++ has 1890undefined behavior because the lifetime of the array ends after the 1891declaration of @samp{foo}. 1892 1893As an optimization, the C++ compiler sometimes gives array compound 1894literals longer lifetimes: when the array either appears outside a 1895function or has const-qualified type. If @samp{foo} and its 1896initializer had elements of @samp{char *const} type rather than 1897@samp{char *}, or if @samp{foo} were a global variable, the array 1898would have static storage duration. But it is probably safest just to 1899avoid the use of array compound literals in code compiled as C++. 1900 1901@node Designated Inits 1902@section Designated Initializers 1903@cindex initializers with labeled elements 1904@cindex labeled elements in initializers 1905@cindex case labels in initializers 1906@cindex designated initializers 1907 1908Standard C90 requires the elements of an initializer to appear in a fixed 1909order, the same as the order of the elements in the array or structure 1910being initialized. 1911 1912In ISO C99 you can give the elements in any order, specifying the array 1913indices or structure field names they apply to, and GNU C allows this as 1914an extension in C90 mode as well. This extension is not 1915implemented in GNU C++. 1916 1917To specify an array index, write 1918@samp{[@var{index}] =} before the element value. For example, 1919 1920@smallexample 1921int a[6] = @{ [4] = 29, [2] = 15 @}; 1922@end smallexample 1923 1924@noindent 1925is equivalent to 1926 1927@smallexample 1928int a[6] = @{ 0, 0, 15, 0, 29, 0 @}; 1929@end smallexample 1930 1931@noindent 1932The index values must be constant expressions, even if the array being 1933initialized is automatic. 1934 1935An alternative syntax for this that has been obsolete since GCC 2.5 but 1936GCC still accepts is to write @samp{[@var{index}]} before the element 1937value, with no @samp{=}. 1938 1939To initialize a range of elements to the same value, write 1940@samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU 1941extension. For example, 1942 1943@smallexample 1944int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @}; 1945@end smallexample 1946 1947@noindent 1948If the value in it has side-effects, the side-effects happen only once, 1949not for each initialized field by the range initializer. 1950 1951@noindent 1952Note that the length of the array is the highest value specified 1953plus one. 1954 1955In a structure initializer, specify the name of a field to initialize 1956with @samp{.@var{fieldname} =} before the element value. For example, 1957given the following structure, 1958 1959@smallexample 1960struct point @{ int x, y; @}; 1961@end smallexample 1962 1963@noindent 1964the following initialization 1965 1966@smallexample 1967struct point p = @{ .y = yvalue, .x = xvalue @}; 1968@end smallexample 1969 1970@noindent 1971is equivalent to 1972 1973@smallexample 1974struct point p = @{ xvalue, yvalue @}; 1975@end smallexample 1976 1977Another syntax that has the same meaning, obsolete since GCC 2.5, is 1978@samp{@var{fieldname}:}, as shown here: 1979 1980@smallexample 1981struct point p = @{ y: yvalue, x: xvalue @}; 1982@end smallexample 1983 1984Omitted field members are implicitly initialized the same as objects 1985that have static storage duration. 1986 1987@cindex designators 1988The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a 1989@dfn{designator}. You can also use a designator (or the obsolete colon 1990syntax) when initializing a union, to specify which element of the union 1991should be used. For example, 1992 1993@smallexample 1994union foo @{ int i; double d; @}; 1995 1996union foo f = @{ .d = 4 @}; 1997@end smallexample 1998 1999@noindent 2000converts 4 to a @code{double} to store it in the union using 2001the second element. By contrast, casting 4 to type @code{union foo} 2002stores it into the union as the integer @code{i}, since it is 2003an integer. (@xref{Cast to Union}.) 2004 2005You can combine this technique of naming elements with ordinary C 2006initialization of successive elements. Each initializer element that 2007does not have a designator applies to the next consecutive element of the 2008array or structure. For example, 2009 2010@smallexample 2011int a[6] = @{ [1] = v1, v2, [4] = v4 @}; 2012@end smallexample 2013 2014@noindent 2015is equivalent to 2016 2017@smallexample 2018int a[6] = @{ 0, v1, v2, 0, v4, 0 @}; 2019@end smallexample 2020 2021Labeling the elements of an array initializer is especially useful 2022when the indices are characters or belong to an @code{enum} type. 2023For example: 2024 2025@smallexample 2026int whitespace[256] 2027 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1, 2028 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @}; 2029@end smallexample 2030 2031@cindex designator lists 2032You can also write a series of @samp{.@var{fieldname}} and 2033@samp{[@var{index}]} designators before an @samp{=} to specify a 2034nested subobject to initialize; the list is taken relative to the 2035subobject corresponding to the closest surrounding brace pair. For 2036example, with the @samp{struct point} declaration above: 2037 2038@smallexample 2039struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @}; 2040@end smallexample 2041 2042@noindent 2043If the same field is initialized multiple times, it has the value from 2044the last initialization. If any such overridden initialization has 2045side-effect, it is unspecified whether the side-effect happens or not. 2046Currently, GCC discards them and issues a warning. 2047 2048@node Case Ranges 2049@section Case Ranges 2050@cindex case ranges 2051@cindex ranges in case statements 2052 2053You can specify a range of consecutive values in a single @code{case} label, 2054like this: 2055 2056@smallexample 2057case @var{low} ... @var{high}: 2058@end smallexample 2059 2060@noindent 2061This has the same effect as the proper number of individual @code{case} 2062labels, one for each integer value from @var{low} to @var{high}, inclusive. 2063 2064This feature is especially useful for ranges of ASCII character codes: 2065 2066@smallexample 2067case 'A' ... 'Z': 2068@end smallexample 2069 2070@strong{Be careful:} Write spaces around the @code{...}, for otherwise 2071it may be parsed wrong when you use it with integer values. For example, 2072write this: 2073 2074@smallexample 2075case 1 ... 5: 2076@end smallexample 2077 2078@noindent 2079rather than this: 2080 2081@smallexample 2082case 1...5: 2083@end smallexample 2084 2085@node Cast to Union 2086@section Cast to a Union Type 2087@cindex cast to a union 2088@cindex union, casting to a 2089 2090A cast to union type is similar to other casts, except that the type 2091specified is a union type. You can specify the type either with 2092@code{union @var{tag}} or with a typedef name. A cast to union is actually 2093a constructor, not a cast, and hence does not yield an lvalue like 2094normal casts. (@xref{Compound Literals}.) 2095 2096The types that may be cast to the union type are those of the members 2097of the union. Thus, given the following union and variables: 2098 2099@smallexample 2100union foo @{ int i; double d; @}; 2101int x; 2102double y; 2103@end smallexample 2104 2105@noindent 2106both @code{x} and @code{y} can be cast to type @code{union foo}. 2107 2108Using the cast as the right-hand side of an assignment to a variable of 2109union type is equivalent to storing in a member of the union: 2110 2111@smallexample 2112union foo u; 2113/* @r{@dots{}} */ 2114u = (union foo) x @equiv{} u.i = x 2115u = (union foo) y @equiv{} u.d = y 2116@end smallexample 2117 2118You can also use the union cast as a function argument: 2119 2120@smallexample 2121void hack (union foo); 2122/* @r{@dots{}} */ 2123hack ((union foo) x); 2124@end smallexample 2125 2126@node Mixed Declarations 2127@section Mixed Declarations and Code 2128@cindex mixed declarations and code 2129@cindex declarations, mixed with code 2130@cindex code, mixed with declarations 2131 2132ISO C99 and ISO C++ allow declarations and code to be freely mixed 2133within compound statements. As an extension, GNU C also allows this in 2134C90 mode. For example, you could do: 2135 2136@smallexample 2137int i; 2138/* @r{@dots{}} */ 2139i++; 2140int j = i + 2; 2141@end smallexample 2142 2143Each identifier is visible from where it is declared until the end of 2144the enclosing block. 2145 2146@node Function Attributes 2147@section Declaring Attributes of Functions 2148@cindex function attributes 2149@cindex declaring attributes of functions 2150@cindex functions that never return 2151@cindex functions that return more than once 2152@cindex functions that have no side effects 2153@cindex functions in arbitrary sections 2154@cindex functions that behave like malloc 2155@cindex @code{volatile} applied to function 2156@cindex @code{const} applied to function 2157@cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments 2158@cindex functions with non-null pointer arguments 2159@cindex functions that are passed arguments in registers on x86-32 2160@cindex functions that pop the argument stack on x86-32 2161@cindex functions that do not pop the argument stack on x86-32 2162@cindex functions that have different compilation options on x86-32 2163@cindex functions that have different optimization options 2164@cindex functions that are dynamically resolved 2165 2166In GNU C, you declare certain things about functions called in your program 2167which help the compiler optimize function calls and check your code more 2168carefully. 2169 2170The keyword @code{__attribute__} allows you to specify special 2171attributes when making a declaration. This keyword is followed by an 2172attribute specification inside double parentheses. The following 2173attributes are currently defined for functions on all targets: 2174@code{aligned}, @code{alloc_size}, @code{alloc_align}, @code{assume_aligned}, 2175@code{noreturn}, @code{returns_twice}, @code{noinline}, @code{noclone}, 2176@code{no_icf}, 2177@code{always_inline}, @code{flatten}, @code{pure}, @code{const}, 2178@code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg}, 2179@code{no_instrument_function}, @code{no_split_stack}, 2180@code{section}, @code{constructor}, 2181@code{destructor}, @code{used}, @code{unused}, @code{deprecated}, 2182@code{weak}, @code{malloc}, @code{alias}, @code{ifunc}, 2183@code{warn_unused_result}, @code{nonnull}, 2184@code{returns_nonnull}, @code{gnu_inline}, 2185@code{externally_visible}, @code{hot}, @code{cold}, @code{artificial}, 2186@code{no_sanitize_address}, @code{no_address_safety_analysis}, 2187@code{no_sanitize_thread}, 2188@code{no_sanitize_undefined}, @code{no_reorder}, @code{bnd_legacy}, 2189@code{bnd_instrument}, @code{stack_protect}, 2190@code{error} and @code{warning}. 2191Several other attributes are defined for functions on particular 2192target systems. Other attributes, including @code{section} are 2193supported for variables declarations (@pxref{Variable Attributes}), 2194labels (@pxref{Label Attributes}) 2195and for types (@pxref{Type Attributes}). 2196 2197GCC plugins may provide their own attributes. 2198 2199You may also specify attributes with @samp{__} preceding and following 2200each keyword. This allows you to use them in header files without 2201being concerned about a possible macro of the same name. For example, 2202you may use @code{__noreturn__} instead of @code{noreturn}. 2203 2204@xref{Attribute Syntax}, for details of the exact syntax for using 2205attributes. 2206 2207@table @code 2208@c Keep this table alphabetized by attribute name. Treat _ as space. 2209 2210@item alias ("@var{target}") 2211@cindex @code{alias} function attribute 2212The @code{alias} attribute causes the declaration to be emitted as an 2213alias for another symbol, which must be specified. For instance, 2214 2215@smallexample 2216void __f () @{ /* @r{Do something.} */; @} 2217void f () __attribute__ ((weak, alias ("__f"))); 2218@end smallexample 2219 2220@noindent 2221defines @samp{f} to be a weak alias for @samp{__f}. In C++, the 2222mangled name for the target must be used. It is an error if @samp{__f} 2223is not defined in the same translation unit. 2224 2225Not all target machines support this attribute. 2226 2227@item aligned (@var{alignment}) 2228@cindex @code{aligned} function attribute 2229This attribute specifies a minimum alignment for the function, 2230measured in bytes. 2231 2232You cannot use this attribute to decrease the alignment of a function, 2233only to increase it. However, when you explicitly specify a function 2234alignment this overrides the effect of the 2235@option{-falign-functions} (@pxref{Optimize Options}) option for this 2236function. 2237 2238Note that the effectiveness of @code{aligned} attributes may be 2239limited by inherent limitations in your linker. On many systems, the 2240linker is only able to arrange for functions to be aligned up to a 2241certain maximum alignment. (For some linkers, the maximum supported 2242alignment may be very very small.) See your linker documentation for 2243further information. 2244 2245The @code{aligned} attribute can also be used for variables and fields 2246(@pxref{Variable Attributes}.) 2247 2248@item alloc_size 2249@cindex @code{alloc_size} function attribute 2250The @code{alloc_size} attribute is used to tell the compiler that the 2251function return value points to memory, where the size is given by 2252one or two of the functions parameters. GCC uses this 2253information to improve the correctness of @code{__builtin_object_size}. 2254 2255The function parameter(s) denoting the allocated size are specified by 2256one or two integer arguments supplied to the attribute. The allocated size 2257is either the value of the single function argument specified or the product 2258of the two function arguments specified. Argument numbering starts at 2259one. 2260 2261For instance, 2262 2263@smallexample 2264void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2))) 2265void* my_realloc(void*, size_t) __attribute__((alloc_size(2))) 2266@end smallexample 2267 2268@noindent 2269declares that @code{my_calloc} returns memory of the size given by 2270the product of parameter 1 and 2 and that @code{my_realloc} returns memory 2271of the size given by parameter 2. 2272 2273@item alloc_align 2274@cindex @code{alloc_align} function attribute 2275The @code{alloc_align} attribute is used to tell the compiler that the 2276function return value points to memory, where the returned pointer minimum 2277alignment is given by one of the functions parameters. GCC uses this 2278information to improve pointer alignment analysis. 2279 2280The function parameter denoting the allocated alignment is specified by 2281one integer argument, whose number is the argument of the attribute. 2282Argument numbering starts at one. 2283 2284For instance, 2285 2286@smallexample 2287void* my_memalign(size_t, size_t) __attribute__((alloc_align(1))) 2288@end smallexample 2289 2290@noindent 2291declares that @code{my_memalign} returns memory with minimum alignment 2292given by parameter 1. 2293 2294@item assume_aligned 2295@cindex @code{assume_aligned} function attribute 2296The @code{assume_aligned} attribute is used to tell the compiler that the 2297function return value points to memory, where the returned pointer minimum 2298alignment is given by the first argument. 2299If the attribute has two arguments, the second argument is misalignment offset. 2300 2301For instance 2302 2303@smallexample 2304void* my_alloc1(size_t) __attribute__((assume_aligned(16))) 2305void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8))) 2306@end smallexample 2307 2308@noindent 2309declares that @code{my_alloc1} returns 16-byte aligned pointer and 2310that @code{my_alloc2} returns a pointer whose value modulo 32 is equal 2311to 8. 2312 2313@item always_inline 2314@cindex @code{always_inline} function attribute 2315Generally, functions are not inlined unless optimization is specified. 2316For functions declared inline, this attribute inlines the function 2317independent of any restrictions that otherwise apply to inlining. 2318Failure to inline such a function is diagnosed as an error. 2319Note that if such a function is called indirectly the compiler may 2320or may not inline it depending on optimization level and a failure 2321to inline an indirect call may or may not be diagnosed. 2322 2323@item gnu_inline 2324@cindex @code{gnu_inline} function attribute 2325This attribute should be used with a function that is also declared 2326with the @code{inline} keyword. It directs GCC to treat the function 2327as if it were defined in gnu90 mode even when compiling in C99 or 2328gnu99 mode. 2329 2330If the function is declared @code{extern}, then this definition of the 2331function is used only for inlining. In no case is the function 2332compiled as a standalone function, not even if you take its address 2333explicitly. Such an address becomes an external reference, as if you 2334had only declared the function, and had not defined it. This has 2335almost the effect of a macro. The way to use this is to put a 2336function definition in a header file with this attribute, and put 2337another copy of the function, without @code{extern}, in a library 2338file. The definition in the header file causes most calls to the 2339function to be inlined. If any uses of the function remain, they 2340refer to the single copy in the library. Note that the two 2341definitions of the functions need not be precisely the same, although 2342if they do not have the same effect your program may behave oddly. 2343 2344In C, if the function is neither @code{extern} nor @code{static}, then 2345the function is compiled as a standalone function, as well as being 2346inlined where possible. 2347 2348This is how GCC traditionally handled functions declared 2349@code{inline}. Since ISO C99 specifies a different semantics for 2350@code{inline}, this function attribute is provided as a transition 2351measure and as a useful feature in its own right. This attribute is 2352available in GCC 4.1.3 and later. It is available if either of the 2353preprocessor macros @code{__GNUC_GNU_INLINE__} or 2354@code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline 2355Function is As Fast As a Macro}. 2356 2357In C++, this attribute does not depend on @code{extern} in any way, 2358but it still requires the @code{inline} keyword to enable its special 2359behavior. 2360 2361@item artificial 2362@cindex @code{artificial} function attribute 2363This attribute is useful for small inline wrappers that if possible 2364should appear during debugging as a unit. Depending on the debug 2365info format it either means marking the function as artificial 2366or using the caller location for all instructions within the inlined 2367body. 2368 2369@item bank_switch 2370@cindex @code{bank_switch} function attribute, M32C 2371When added to an interrupt handler with the M32C port, causes the 2372prologue and epilogue to use bank switching to preserve the registers 2373rather than saving them on the stack. 2374 2375@item flatten 2376@cindex @code{flatten} function attribute 2377Generally, inlining into a function is limited. For a function marked with 2378this attribute, every call inside this function is inlined, if possible. 2379Whether the function itself is considered for inlining depends on its size and 2380the current inlining parameters. 2381 2382@item error ("@var{message}") 2383@cindex @code{error} function attribute 2384If this attribute is used on a function declaration and a call to such a function 2385is not eliminated through dead code elimination or other optimizations, an error 2386that includes @var{message} is diagnosed. This is useful 2387for compile-time checking, especially together with @code{__builtin_constant_p} 2388and inline functions where checking the inline function arguments is not 2389possible through @code{extern char [(condition) ? 1 : -1];} tricks. 2390While it is possible to leave the function undefined and thus invoke 2391a link failure, when using this attribute the problem is diagnosed 2392earlier and with exact location of the call even in presence of inline 2393functions or when not emitting debugging information. 2394 2395@item warning ("@var{message}") 2396@cindex @code{warning} function attribute 2397If this attribute is used on a function declaration and a call to such a function 2398is not eliminated through dead code elimination or other optimizations, a warning 2399that includes @var{message} is diagnosed. This is useful 2400for compile-time checking, especially together with @code{__builtin_constant_p} 2401and inline functions. While it is possible to define the function with 2402a message in @code{.gnu.warning*} section, when using this attribute the problem 2403is diagnosed earlier and with exact location of the call even in presence 2404of inline functions or when not emitting debugging information. 2405 2406@item cdecl 2407@cindex @code{cdecl} function attribute, x86-32 2408@cindex functions that do pop the argument stack on x86-32 2409@opindex mrtd 2410On the x86-32 targets, the @code{cdecl} attribute causes the compiler to 2411assume that the calling function pops off the stack space used to 2412pass arguments. This is 2413useful to override the effects of the @option{-mrtd} switch. 2414 2415@item const 2416@cindex @code{const} function attribute 2417Many functions do not examine any values except their arguments, and 2418have no effects except the return value. Basically this is just slightly 2419more strict class than the @code{pure} attribute below, since function is not 2420allowed to read global memory. 2421 2422@cindex pointer arguments 2423Note that a function that has pointer arguments and examines the data 2424pointed to must @emph{not} be declared @code{const}. Likewise, a 2425function that calls a non-@code{const} function usually must not be 2426@code{const}. It does not make sense for a @code{const} function to 2427return @code{void}. 2428 2429@item constructor 2430@itemx destructor 2431@itemx constructor (@var{priority}) 2432@itemx destructor (@var{priority}) 2433@cindex @code{constructor} function attribute 2434@cindex @code{destructor} function attribute 2435The @code{constructor} attribute causes the function to be called 2436automatically before execution enters @code{main ()}. Similarly, the 2437@code{destructor} attribute causes the function to be called 2438automatically after @code{main ()} completes or @code{exit ()} is 2439called. Functions with these attributes are useful for 2440initializing data that is used implicitly during the execution of 2441the program. 2442 2443You may provide an optional integer priority to control the order in 2444which constructor and destructor functions are run. A constructor 2445with a smaller priority number runs before a constructor with a larger 2446priority number; the opposite relationship holds for destructors. So, 2447if you have a constructor that allocates a resource and a destructor 2448that deallocates the same resource, both functions typically have the 2449same priority. The priorities for constructor and destructor 2450functions are the same as those specified for namespace-scope C++ 2451objects (@pxref{C++ Attributes}). 2452 2453These attributes are not currently implemented for Objective-C@. 2454 2455@item deprecated 2456@itemx deprecated (@var{msg}) 2457@cindex @code{deprecated} function attribute 2458The @code{deprecated} attribute results in a warning if the function 2459is used anywhere in the source file. This is useful when identifying 2460functions that are expected to be removed in a future version of a 2461program. The warning also includes the location of the declaration 2462of the deprecated function, to enable users to easily find further 2463information about why the function is deprecated, or what they should 2464do instead. Note that the warnings only occurs for uses: 2465 2466@smallexample 2467int old_fn () __attribute__ ((deprecated)); 2468int old_fn (); 2469int (*fn_ptr)() = old_fn; 2470@end smallexample 2471 2472@noindent 2473results in a warning on line 3 but not line 2. The optional @var{msg} 2474argument, which must be a string, is printed in the warning if 2475present. 2476 2477The @code{deprecated} attribute can also be used for variables and 2478types (@pxref{Variable Attributes}, @pxref{Type Attributes}.) 2479 2480@item disinterrupt 2481@cindex @code{disinterrupt} function attribute, Epiphany 2482@cindex @code{disinterrupt} function attribute, MeP 2483On Epiphany and MeP targets, this attribute causes the compiler to emit 2484instructions to disable interrupts for the duration of the given 2485function. 2486 2487@item dllexport 2488@cindex @code{dllexport} function attribute 2489@cindex @code{__declspec(dllexport)} 2490On Microsoft Windows targets and Symbian OS targets the 2491@code{dllexport} attribute causes the compiler to provide a global 2492pointer to a pointer in a DLL, so that it can be referenced with the 2493@code{dllimport} attribute. On Microsoft Windows targets, the pointer 2494name is formed by combining @code{_imp__} and the function or variable 2495name. 2496 2497You can use @code{__declspec(dllexport)} as a synonym for 2498@code{__attribute__ ((dllexport))} for compatibility with other 2499compilers. 2500 2501On systems that support the @code{visibility} attribute, this 2502attribute also implies ``default'' visibility. It is an error to 2503explicitly specify any other visibility. 2504 2505GCC's default behavior is to emit all inline functions with the 2506@code{dllexport} attribute. Since this can cause object file-size bloat, 2507you can use @option{-fno-keep-inline-dllexport}, which tells GCC to 2508ignore the attribute for inlined functions unless the 2509@option{-fkeep-inline-functions} flag is used instead. 2510 2511The attribute is ignored for undefined symbols. 2512 2513When applied to C++ classes, the attribute marks defined non-inlined 2514member functions and static data members as exports. Static consts 2515initialized in-class are not marked unless they are also defined 2516out-of-class. 2517 2518For Microsoft Windows targets there are alternative methods for 2519including the symbol in the DLL's export table such as using a 2520@file{.def} file with an @code{EXPORTS} section or, with GNU ld, using 2521the @option{--export-all} linker flag. 2522 2523@item dllimport 2524@cindex @code{dllimport} function attribute 2525@cindex @code{__declspec(dllimport)} 2526On Microsoft Windows and Symbian OS targets, the @code{dllimport} 2527attribute causes the compiler to reference a function or variable via 2528a global pointer to a pointer that is set up by the DLL exporting the 2529symbol. The attribute implies @code{extern}. On Microsoft Windows 2530targets, the pointer name is formed by combining @code{_imp__} and the 2531function or variable name. 2532 2533You can use @code{__declspec(dllimport)} as a synonym for 2534@code{__attribute__ ((dllimport))} for compatibility with other 2535compilers. 2536 2537On systems that support the @code{visibility} attribute, this 2538attribute also implies ``default'' visibility. It is an error to 2539explicitly specify any other visibility. 2540 2541Currently, the attribute is ignored for inlined functions. If the 2542attribute is applied to a symbol @emph{definition}, an error is reported. 2543If a symbol previously declared @code{dllimport} is later defined, the 2544attribute is ignored in subsequent references, and a warning is emitted. 2545The attribute is also overridden by a subsequent declaration as 2546@code{dllexport}. 2547 2548When applied to C++ classes, the attribute marks non-inlined 2549member functions and static data members as imports. However, the 2550attribute is ignored for virtual methods to allow creation of vtables 2551using thunks. 2552 2553On the SH Symbian OS target the @code{dllimport} attribute also has 2554another affect---it can cause the vtable and run-time type information 2555for a class to be exported. This happens when the class has a 2556dllimported constructor or a non-inline, non-pure virtual function 2557and, for either of those two conditions, the class also has an inline 2558constructor or destructor and has a key function that is defined in 2559the current translation unit. 2560 2561For Microsoft Windows targets the use of the @code{dllimport} 2562attribute on functions is not necessary, but provides a small 2563performance benefit by eliminating a thunk in the DLL@. The use of the 2564@code{dllimport} attribute on imported variables can be avoided by passing the 2565@option{--enable-auto-import} switch to the GNU linker. As with 2566functions, using the attribute for a variable eliminates a thunk in 2567the DLL@. 2568 2569One drawback to using this attribute is that a pointer to a 2570@emph{variable} marked as @code{dllimport} cannot be used as a constant 2571address. However, a pointer to a @emph{function} with the 2572@code{dllimport} attribute can be used as a constant initializer; in 2573this case, the address of a stub function in the import lib is 2574referenced. On Microsoft Windows targets, the attribute can be disabled 2575for functions by setting the @option{-mnop-fun-dllimport} flag. 2576 2577@item exception 2578@cindex @code{exception} function attribute 2579@cindex exception handler functions, NDS32 2580Use this attribute on the NDS32 target to indicate that the specified function 2581is an exception handler. The compiler will generate corresponding sections 2582for use in an exception handler. 2583 2584@item exception_handler 2585@cindex @code{exception_handler} function attribute 2586@cindex exception handler functions, Blackfin 2587Use this attribute on the Blackfin to indicate that the specified function 2588is an exception handler. The compiler generates function entry and 2589exit sequences suitable for use in an exception handler when this 2590attribute is present. 2591 2592@item externally_visible 2593@cindex @code{externally_visible} function attribute 2594This attribute, attached to a global variable or function, nullifies 2595the effect of the @option{-fwhole-program} command-line option, so the 2596object remains visible outside the current compilation unit. 2597 2598If @option{-fwhole-program} is used together with @option{-flto} and 2599@command{gold} is used as the linker plugin, 2600@code{externally_visible} attributes are automatically added to functions 2601(not variable yet due to a current @command{gold} issue) 2602that are accessed outside of LTO objects according to resolution file 2603produced by @command{gold}. 2604For other linkers that cannot generate resolution file, 2605explicit @code{externally_visible} attributes are still necessary. 2606 2607@item far 2608@cindex @code{far} function attribute 2609 2610On MeP targets this causes the compiler to use a calling convention 2611that assumes the called function is too far away for the built-in 2612addressing modes. 2613 2614@item fast_interrupt 2615@cindex @code{fast_interrupt} function attribute, M32C 2616@cindex @code{fast_interrupt} function attribute, RX 2617Use this attribute on the M32C and RX ports to indicate that the specified 2618function is a fast interrupt handler. This is just like the 2619@code{interrupt} attribute, except that @code{freit} is used to return 2620instead of @code{reit}. 2621 2622@item fastcall 2623@cindex @code{fastcall} function attribute, x86-32 2624@cindex functions that pop the argument stack on x86-32 2625On x86-32 targets, the @code{fastcall} attribute causes the compiler to 2626pass the first argument (if of integral type) in the register ECX and 2627the second argument (if of integral type) in the register EDX@. Subsequent 2628and other typed arguments are passed on the stack. The called function 2629pops the arguments off the stack. If the number of arguments is variable all 2630arguments are pushed on the stack. 2631 2632@item thiscall 2633@cindex @code{thiscall} function attribute, x86-32 2634@cindex functions that pop the argument stack on x86-32 2635On x86-32 targets, the @code{thiscall} attribute causes the compiler to 2636pass the first argument (if of integral type) in the register ECX. 2637Subsequent and other typed arguments are passed on the stack. The called 2638function pops the arguments off the stack. 2639If the number of arguments is variable all arguments are pushed on the 2640stack. 2641The @code{thiscall} attribute is intended for C++ non-static member functions. 2642As a GCC extension, this calling convention can be used for C functions 2643and for static member methods. 2644 2645@item format (@var{archetype}, @var{string-index}, @var{first-to-check}) 2646@cindex @code{format} function attribute 2647@opindex Wformat 2648The @code{format} attribute specifies that a function takes @code{printf}, 2649@code{scanf}, @code{strftime} or @code{strfmon} style arguments that 2650should be type-checked against a format string. For example, the 2651declaration: 2652 2653@smallexample 2654extern int 2655my_printf (void *my_object, const char *my_format, ...) 2656 __attribute__ ((format (printf, 2, 3))); 2657@end smallexample 2658 2659@noindent 2660causes the compiler to check the arguments in calls to @code{my_printf} 2661for consistency with the @code{printf} style format string argument 2662@code{my_format}. 2663 2664The parameter @var{archetype} determines how the format string is 2665interpreted, and should be @code{printf}, @code{scanf}, @code{strftime}, 2666@code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or 2667@code{strfmon}. (You can also use @code{__printf__}, 2668@code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On 2669MinGW targets, @code{ms_printf}, @code{ms_scanf}, and 2670@code{ms_strftime} are also present. 2671@var{archetype} values such as @code{printf} refer to the formats accepted 2672by the system's C runtime library, 2673while values prefixed with @samp{gnu_} always refer 2674to the formats accepted by the GNU C Library. On Microsoft Windows 2675targets, values prefixed with @samp{ms_} refer to the formats accepted by the 2676@file{msvcrt.dll} library. 2677The parameter @var{string-index} 2678specifies which argument is the format string argument (starting 2679from 1), while @var{first-to-check} is the number of the first 2680argument to check against the format string. For functions 2681where the arguments are not available to be checked (such as 2682@code{vprintf}), specify the third parameter as zero. In this case the 2683compiler only checks the format string for consistency. For 2684@code{strftime} formats, the third parameter is required to be zero. 2685Since non-static C++ methods have an implicit @code{this} argument, the 2686arguments of such methods should be counted from two, not one, when 2687giving values for @var{string-index} and @var{first-to-check}. 2688 2689In the example above, the format string (@code{my_format}) is the second 2690argument of the function @code{my_print}, and the arguments to check 2691start with the third argument, so the correct parameters for the format 2692attribute are 2 and 3. 2693 2694@opindex ffreestanding 2695@opindex fno-builtin 2696The @code{format} attribute allows you to identify your own functions 2697that take format strings as arguments, so that GCC can check the 2698calls to these functions for errors. The compiler always (unless 2699@option{-ffreestanding} or @option{-fno-builtin} is used) checks formats 2700for the standard library functions @code{printf}, @code{fprintf}, 2701@code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime}, 2702@code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such 2703warnings are requested (using @option{-Wformat}), so there is no need to 2704modify the header file @file{stdio.h}. In C99 mode, the functions 2705@code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and 2706@code{vsscanf} are also checked. Except in strictly conforming C 2707standard modes, the X/Open function @code{strfmon} is also checked as 2708are @code{printf_unlocked} and @code{fprintf_unlocked}. 2709@xref{C Dialect Options,,Options Controlling C Dialect}. 2710 2711For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is 2712recognized in the same context. Declarations including these format attributes 2713are parsed for correct syntax, however the result of checking of such format 2714strings is not yet defined, and is not carried out by this version of the 2715compiler. 2716 2717The target may also provide additional types of format checks. 2718@xref{Target Format Checks,,Format Checks Specific to Particular 2719Target Machines}. 2720 2721@item format_arg (@var{string-index}) 2722@cindex @code{format_arg} function attribute 2723@opindex Wformat-nonliteral 2724The @code{format_arg} attribute specifies that a function takes a format 2725string for a @code{printf}, @code{scanf}, @code{strftime} or 2726@code{strfmon} style function and modifies it (for example, to translate 2727it into another language), so the result can be passed to a 2728@code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style 2729function (with the remaining arguments to the format function the same 2730as they would have been for the unmodified string). For example, the 2731declaration: 2732 2733@smallexample 2734extern char * 2735my_dgettext (char *my_domain, const char *my_format) 2736 __attribute__ ((format_arg (2))); 2737@end smallexample 2738 2739@noindent 2740causes the compiler to check the arguments in calls to a @code{printf}, 2741@code{scanf}, @code{strftime} or @code{strfmon} type function, whose 2742format string argument is a call to the @code{my_dgettext} function, for 2743consistency with the format string argument @code{my_format}. If the 2744@code{format_arg} attribute had not been specified, all the compiler 2745could tell in such calls to format functions would be that the format 2746string argument is not constant; this would generate a warning when 2747@option{-Wformat-nonliteral} is used, but the calls could not be checked 2748without the attribute. 2749 2750The parameter @var{string-index} specifies which argument is the format 2751string argument (starting from one). Since non-static C++ methods have 2752an implicit @code{this} argument, the arguments of such methods should 2753be counted from two. 2754 2755The @code{format_arg} attribute allows you to identify your own 2756functions that modify format strings, so that GCC can check the 2757calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} 2758type function whose operands are a call to one of your own function. 2759The compiler always treats @code{gettext}, @code{dgettext}, and 2760@code{dcgettext} in this manner except when strict ISO C support is 2761requested by @option{-ansi} or an appropriate @option{-std} option, or 2762@option{-ffreestanding} or @option{-fno-builtin} 2763is used. @xref{C Dialect Options,,Options 2764Controlling C Dialect}. 2765 2766For Objective-C dialects, the @code{format-arg} attribute may refer to an 2767@code{NSString} reference for compatibility with the @code{format} attribute 2768above. 2769 2770The target may also allow additional types in @code{format-arg} attributes. 2771@xref{Target Format Checks,,Format Checks Specific to Particular 2772Target Machines}. 2773 2774@item function_vector 2775@cindex @code{function_vector} function attribute, H8/300 2776@cindex @code{function_vector} function attribute, M16C/M32C 2777@cindex @code{function_vector} function attribute, SH 2778@cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors 2779Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified 2780function should be called through the function vector. Calling a 2781function through the function vector reduces code size, however; 2782the function vector has a limited size (maximum 128 entries on the H8/300 2783and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector. 2784 2785On SH2A targets, this attribute declares a function to be called using the 2786TBR relative addressing mode. The argument to this attribute is the entry 2787number of the same function in a vector table containing all the TBR 2788relative addressable functions. For correct operation the TBR must be setup 2789accordingly to point to the start of the vector table before any functions with 2790this attribute are invoked. Usually a good place to do the initialization is 2791the startup routine. The TBR relative vector table can have at max 256 function 2792entries. The jumps to these functions are generated using a SH2A specific, 2793non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD 2794from GNU binutils version 2.7 or later for this attribute to work correctly. 2795 2796Please refer the example of M16C target, to see the use of this 2797attribute while declaring a function, 2798 2799In an application, for a function being called once, this attribute 2800saves at least 8 bytes of code; and if other successive calls are being 2801made to the same function, it saves 2 bytes of code per each of these 2802calls. 2803 2804On M16C/M32C targets, the @code{function_vector} attribute declares a 2805special page subroutine call function. Use of this attribute reduces 2806the code size by 2 bytes for each call generated to the 2807subroutine. The argument to the attribute is the vector number entry 2808from the special page vector table which contains the 16 low-order 2809bits of the subroutine's entry address. Each vector table has special 2810page number (18 to 255) that is used in @code{jsrs} instructions. 2811Jump addresses of the routines are generated by adding 0x0F0000 (in 2812case of M16C targets) or 0xFF0000 (in case of M32C targets), to the 28132-byte addresses set in the vector table. Therefore you need to ensure 2814that all the special page vector routines should get mapped within the 2815address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF 2816(for M32C). 2817 2818In the following example 2 bytes are saved for each call to 2819function @code{foo}. 2820 2821@smallexample 2822void foo (void) __attribute__((function_vector(0x18))); 2823void foo (void) 2824@{ 2825@} 2826 2827void bar (void) 2828@{ 2829 foo(); 2830@} 2831@end smallexample 2832 2833If functions are defined in one file and are called in another file, 2834then be sure to write this declaration in both files. 2835 2836This attribute is ignored for R8C target. 2837 2838@item ifunc ("@var{resolver}") 2839@cindex @code{ifunc} function attribute 2840The @code{ifunc} attribute is used to mark a function as an indirect 2841function using the STT_GNU_IFUNC symbol type extension to the ELF 2842standard. This allows the resolution of the symbol value to be 2843determined dynamically at load time, and an optimized version of the 2844routine can be selected for the particular processor or other system 2845characteristics determined then. To use this attribute, first define 2846the implementation functions available, and a resolver function that 2847returns a pointer to the selected implementation function. The 2848implementation functions' declarations must match the API of the 2849function being implemented, the resolver's declaration is be a 2850function returning pointer to void function returning void: 2851 2852@smallexample 2853void *my_memcpy (void *dst, const void *src, size_t len) 2854@{ 2855 @dots{} 2856@} 2857 2858static void (*resolve_memcpy (void)) (void) 2859@{ 2860 return my_memcpy; // we'll just always select this routine 2861@} 2862@end smallexample 2863 2864@noindent 2865The exported header file declaring the function the user calls would 2866contain: 2867 2868@smallexample 2869extern void *memcpy (void *, const void *, size_t); 2870@end smallexample 2871 2872@noindent 2873allowing the user to call this as a regular function, unaware of the 2874implementation. Finally, the indirect function needs to be defined in 2875the same translation unit as the resolver function: 2876 2877@smallexample 2878void *memcpy (void *, const void *, size_t) 2879 __attribute__ ((ifunc ("resolve_memcpy"))); 2880@end smallexample 2881 2882Indirect functions cannot be weak. Binutils version 2.20.1 or higher 2883and GNU C Library version 2.11.1 are required to use this feature. 2884 2885@item interrupt 2886@cindex @code{interrupt} function attribute, ARC 2887@cindex @code{interrupt} function attribute, ARM 2888@cindex @code{interrupt} function attribute, AVR 2889@cindex @code{interrupt} function attribute, CR16 2890@cindex @code{interrupt} function attribute, Epiphany 2891@cindex @code{interrupt} function attribute, M32C 2892@cindex @code{interrupt} function attribute, M32R/D 2893@cindex @code{interrupt} function attribute, m68k 2894@cindex @code{interrupt} function attribute, MeP 2895@cindex @code{interrupt} function attribute, MIPS 2896@cindex @code{interrupt} function attribute, MSP430 2897@cindex @code{interrupt} function attribute, NDS32 2898@cindex @code{interrupt} function attribute, RL78 2899@cindex @code{interrupt} function attribute, RX 2900@cindex @code{interrupt} function attribute, Visium 2901@cindex @code{interrupt} function attribute, Xstormy16 2902Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D, 2903m68k, MeP, MIPS, MSP430, NDS32, RL78, RX, Visium and Xstormy16 ports to indicate 2904that the specified function is an interrupt handler. The compiler generates 2905function entry and exit sequences suitable for use in an interrupt handler 2906when this attribute is present. With Epiphany targets it may also generate 2907a special section with code to initialize the interrupt vector table. 2908 2909Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze, 2910and SH processors can be specified via the @code{interrupt_handler} attribute. 2911 2912Note, on the ARC, you must specify the kind of interrupt to be handled 2913in a parameter to the interrupt attribute like this: 2914 2915@smallexample 2916void f () __attribute__ ((interrupt ("ilink1"))); 2917@end smallexample 2918 2919Permissible values for this parameter are: @w{@code{ilink1}} and 2920@w{@code{ilink2}}. 2921 2922Note, on the AVR, the hardware globally disables interrupts when an 2923interrupt is executed. The first instruction of an interrupt handler 2924declared with this attribute is a @code{SEI} instruction to 2925re-enable interrupts. See also the @code{signal} function attribute 2926that does not insert a @code{SEI} instruction. If both @code{signal} and 2927@code{interrupt} are specified for the same function, @code{signal} 2928is silently ignored. 2929 2930Note, for the ARM, you can specify the kind of interrupt to be handled by 2931adding an optional parameter to the interrupt attribute like this: 2932 2933@smallexample 2934void f () __attribute__ ((interrupt ("IRQ"))); 2935@end smallexample 2936 2937@noindent 2938Permissible values for this parameter are: @code{IRQ}, @code{FIQ}, 2939@code{SWI}, @code{ABORT} and @code{UNDEF}. 2940 2941On ARMv7-M the interrupt type is ignored, and the attribute means the function 2942may be called with a word-aligned stack pointer. 2943 2944Note, for the MSP430 you can provide an argument to the interrupt 2945attribute which specifies a name or number. If the argument is a 2946number it indicates the slot in the interrupt vector table (0 - 31) to 2947which this handler should be assigned. If the argument is a name it 2948is treated as a symbolic name for the vector slot. These names should 2949match up with appropriate entries in the linker script. By default 2950the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and 2951@code{reset} for vector 31 are recognized. 2952 2953You can also use the following function attributes to modify how 2954normal functions interact with interrupt functions: 2955 2956@table @code 2957@item critical 2958@cindex @code{critical} function attribute, MSP430 2959Critical functions disable interrupts upon entry and restore the 2960previous interrupt state upon exit. Critical functions cannot also 2961have the @code{naked} or @code{reentrant} attributes. They can have 2962the @code{interrupt} attribute. 2963 2964@item reentrant 2965@cindex @code{reentrant} function attribute, MSP430 2966Reentrant functions disable interrupts upon entry and enable them 2967upon exit. Reentrant functions cannot also have the @code{naked} 2968or @code{critical} attributes. They can have the @code{interrupt} 2969attribute. 2970 2971@item wakeup 2972@cindex @code{wakeup} function attribute, MSP430 2973This attribute only applies to interrupt functions. It is silently 2974ignored if applied to a non-interrupt function. A wakeup interrupt 2975function will rouse the processor from any low-power state that it 2976might be in when the function exits. 2977 2978@end table 2979 2980On Epiphany targets one or more optional parameters can be added like this: 2981 2982@smallexample 2983void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler (); 2984@end smallexample 2985 2986Permissible values for these parameters are: @w{@code{reset}}, 2987@w{@code{software_exception}}, @w{@code{page_miss}}, 2988@w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}}, 2989@w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}. 2990Multiple parameters indicate that multiple entries in the interrupt 2991vector table should be initialized for this function, i.e.@: for each 2992parameter @w{@var{name}}, a jump to the function is emitted in 2993the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted 2994entirely, in which case no interrupt vector table entry is provided. 2995 2996Note, on Epiphany targets, interrupts are enabled inside the function 2997unless the @code{disinterrupt} attribute is also specified. 2998 2999On Epiphany targets, you can also use the following attribute to 3000modify the behavior of an interrupt handler: 3001@table @code 3002@item forwarder_section 3003@cindex @code{forwarder_section} function attribute, Epiphany 3004The interrupt handler may be in external memory which cannot be 3005reached by a branch instruction, so generate a local memory trampoline 3006to transfer control. The single parameter identifies the section where 3007the trampoline is placed. 3008@end table 3009 3010The following examples are all valid uses of these attributes on 3011Epiphany targets: 3012@smallexample 3013void __attribute__ ((interrupt)) universal_handler (); 3014void __attribute__ ((interrupt ("dma1"))) dma1_handler (); 3015void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler (); 3016void __attribute__ ((interrupt ("timer0"), disinterrupt)) 3017 fast_timer_handler (); 3018void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp"))) 3019 external_dma_handler (); 3020@end smallexample 3021 3022On MIPS targets, you can use the following attributes to modify the behavior 3023of an interrupt handler: 3024@table @code 3025@item use_shadow_register_set 3026@cindex @code{use_shadow_register_set} function attribute, MIPS 3027Assume that the handler uses a shadow register set, instead of 3028the main general-purpose registers. 3029 3030@item keep_interrupts_masked 3031@cindex @code{keep_interrupts_masked} function attribute, MIPS 3032Keep interrupts masked for the whole function. Without this attribute, 3033GCC tries to reenable interrupts for as much of the function as it can. 3034 3035@item use_debug_exception_return 3036@cindex @code{use_debug_exception_return} function attribute, MIPS 3037Return using the @code{deret} instruction. Interrupt handlers that don't 3038have this attribute return using @code{eret} instead. 3039@end table 3040 3041You can use any combination of these attributes, as shown below: 3042@smallexample 3043void __attribute__ ((interrupt)) v0 (); 3044void __attribute__ ((interrupt, use_shadow_register_set)) v1 (); 3045void __attribute__ ((interrupt, keep_interrupts_masked)) v2 (); 3046void __attribute__ ((interrupt, use_debug_exception_return)) v3 (); 3047void __attribute__ ((interrupt, use_shadow_register_set, 3048 keep_interrupts_masked)) v4 (); 3049void __attribute__ ((interrupt, use_shadow_register_set, 3050 use_debug_exception_return)) v5 (); 3051void __attribute__ ((interrupt, keep_interrupts_masked, 3052 use_debug_exception_return)) v6 (); 3053void __attribute__ ((interrupt, use_shadow_register_set, 3054 keep_interrupts_masked, 3055 use_debug_exception_return)) v7 (); 3056@end smallexample 3057 3058On NDS32 target, this attribute indicates that the specified function 3059is an interrupt handler. The compiler generates corresponding sections 3060for use in an interrupt handler. You can use the following attributes 3061to modify the behavior: 3062@table @code 3063@item nested 3064@cindex @code{nested} function attribute, NDS32 3065This interrupt service routine is interruptible. 3066@item not_nested 3067@cindex @code{not_nested} function attribute, NDS32 3068This interrupt service routine is not interruptible. 3069@item nested_ready 3070@cindex @code{nested_ready} function attribute, NDS32 3071This interrupt service routine is interruptible after @code{PSW.GIE} 3072(global interrupt enable) is set. This allows interrupt service routine to 3073finish some short critical code before enabling interrupts. 3074@item save_all 3075@cindex @code{save_all} function attribute, NDS32 3076The system will help save all registers into stack before entering 3077interrupt handler. 3078@item partial_save 3079@cindex @code{partial_save} function attribute, NDS32 3080The system will help save caller registers into stack before entering 3081interrupt handler. 3082@end table 3083 3084@cindex @code{brk_interrupt} function attribute, RL78 3085On RL78, use @code{brk_interrupt} instead of @code{interrupt} for 3086handlers intended to be used with the @code{BRK} opcode (i.e.@: those 3087that must end with @code{RETB} instead of @code{RETI}). 3088 3089On RX targets, you may specify one or more vector numbers as arguments 3090to the attribute, as well as naming an alternate table name. 3091Parameters are handled sequentially, so one handler can be assigned to 3092multiple entries in multiple tables. One may also pass the magic 3093string @code{"$default"} which causes the function to be used for any 3094unfilled slots in the current table. 3095 3096This example shows a simple assignment of a function to one vector in 3097the default table (note that preprocessor macros may be used for 3098chip-specific symbolic vector names): 3099@smallexample 3100void __attribute__ ((interrupt (5))) txd1_handler (); 3101@end smallexample 3102 3103This example assigns a function to two slots in the default table 3104(using preprocessor macros defined elsewhere) and makes it the default 3105for the @code{dct} table: 3106@smallexample 3107void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default"))) 3108 txd1_handler (); 3109@end smallexample 3110 3111@item interrupt_handler 3112@cindex @code{interrupt_handler} function attribute, Blackfin 3113@cindex @code{interrupt_handler} function attribute, m68k 3114@cindex @code{interrupt_handler} function attribute, H8/300 3115@cindex @code{interrupt_handler} function attribute, SH 3116Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to 3117indicate that the specified function is an interrupt handler. The compiler 3118generates function entry and exit sequences suitable for use in an 3119interrupt handler when this attribute is present. 3120 3121@item interrupt_thread 3122@cindex @code{interrupt_thread} function attribute, fido 3123Use this attribute on fido, a subarchitecture of the m68k, to indicate 3124that the specified function is an interrupt handler that is designed 3125to run as a thread. The compiler omits generate prologue/epilogue 3126sequences and replaces the return instruction with a @code{sleep} 3127instruction. This attribute is available only on fido. 3128 3129@item isr 3130@cindex @code{isr} function attribute, ARM 3131Use this attribute on ARM to write Interrupt Service Routines. This is an 3132alias to the @code{interrupt} attribute above. 3133 3134@item kspisusp 3135@cindex @code{kspisusp} function attribute, Blackfin 3136@cindex User stack pointer in interrupts on the Blackfin 3137When used together with @code{interrupt_handler}, @code{exception_handler} 3138or @code{nmi_handler}, code is generated to load the stack pointer 3139from the USP register in the function prologue. 3140 3141@item l1_text 3142@cindex @code{l1_text} function attribute, Blackfin 3143This attribute specifies a function to be placed into L1 Instruction 3144SRAM@. The function is put into a specific section named @code{.l1.text}. 3145With @option{-mfdpic}, function calls with a such function as the callee 3146or caller uses inlined PLT. 3147 3148@item l2 3149@cindex @code{l2} function attribute, Blackfin 3150On the Blackfin, this attribute specifies a function to be placed into L2 3151SRAM. The function is put into a specific section named 3152@code{.l1.text}. With @option{-mfdpic}, callers of such functions use 3153an inlined PLT. 3154 3155@item leaf 3156@cindex @code{leaf} function attribute 3157Calls to external functions with this attribute must return to the current 3158compilation unit only by return or by exception handling. In particular, leaf 3159functions are not allowed to call callback function passed to it from the current 3160compilation unit or directly call functions exported by the unit or longjmp 3161into the unit. Leaf function might still call functions from other compilation 3162units and thus they are not necessarily leaf in the sense that they contain no 3163function calls at all. 3164 3165The attribute is intended for library functions to improve dataflow analysis. 3166The compiler takes the hint that any data not escaping the current compilation unit can 3167not be used or modified by the leaf function. For example, the @code{sin} function 3168is a leaf function, but @code{qsort} is not. 3169 3170Note that leaf functions might invoke signals and signal handlers might be 3171defined in the current compilation unit and use static variables. The only 3172compliant way to write such a signal handler is to declare such variables 3173@code{volatile}. 3174 3175The attribute has no effect on functions defined within the current compilation 3176unit. This is to allow easy merging of multiple compilation units into one, 3177for example, by using the link-time optimization. For this reason the 3178attribute is not allowed on types to annotate indirect calls. 3179 3180@item long_call 3181@itemx medium_call 3182@itemx short_call 3183@cindex @code{long_call} function attribute, ARC 3184@cindex @code{long_call} function attribute, ARM 3185@cindex @code{long_call} function attribute, Epiphany 3186@cindex @code{medium_call} function attribute, ARC 3187@cindex @code{short_call} function attribute, ARC 3188@cindex @code{short_call} function attribute, ARM 3189@cindex @code{short_call} function attribute, Epiphany 3190@cindex indirect calls, ARC 3191@cindex indirect calls, ARM 3192@cindex indirect calls, Epiphany 3193These attributes specify how a particular function is called on 3194ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC. 3195These attributes override the 3196@option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options}) 3197and @option{-mmedium-calls} (@pxref{ARC Options}) 3198command-line switches and @code{#pragma long_calls} settings. For ARM, the 3199@code{long_call} attribute indicates that the function might be far 3200away from the call site and require a different (more expensive) 3201calling sequence. The @code{short_call} attribute always places 3202the offset to the function from the call site into the @samp{BL} 3203instruction directly. 3204 3205For ARC, a function marked with the @code{long_call} attribute is 3206always called using register-indirect jump-and-link instructions, 3207thereby enabling the called function to be placed anywhere within the 320832-bit address space. A function marked with the @code{medium_call} 3209attribute will always be close enough to be called with an unconditional 3210branch-and-link instruction, which has a 25-bit offset from 3211the call site. A function marked with the @code{short_call} 3212attribute will always be close enough to be called with a conditional 3213branch-and-link instruction, which has a 21-bit offset from 3214the call site. 3215 3216@item longcall 3217@itemx shortcall 3218@cindex indirect calls, Blackfin 3219@cindex indirect calls, PowerPC 3220@cindex @code{longcall} function attribute, Blackfin 3221@cindex @code{longcall} function attribute, PowerPC 3222@cindex @code{shortcall} function attribute, Blackfin 3223@cindex @code{shortcall} function attribute, PowerPC 3224On Blackfin and PowerPC, the @code{longcall} attribute 3225indicates that the function might be far away from the call site and 3226require a different (more expensive) calling sequence. The 3227@code{shortcall} attribute indicates that the function is always close 3228enough for the shorter calling sequence to be used. These attributes 3229override both the @option{-mlongcall} switch and, on the RS/6000 and 3230PowerPC, the @code{#pragma longcall} setting. 3231 3232@xref{RS/6000 and PowerPC Options}, for more information on whether long 3233calls are necessary. 3234 3235@item long_call 3236@itemx near 3237@itemx far 3238@cindex indirect calls, MIPS 3239@cindex @code{long_call} function attribute, MIPS 3240@cindex @code{near} function attribute, MIPS 3241@cindex @code{far} function attribute, MIPS 3242These attributes specify how a particular function is called on MIPS@. 3243The attributes override the @option{-mlong-calls} (@pxref{MIPS Options}) 3244command-line switch. The @code{long_call} and @code{far} attributes are 3245synonyms, and cause the compiler to always call 3246the function by first loading its address into a register, and then using 3247the contents of that register. The @code{near} attribute has the opposite 3248effect; it specifies that non-PIC calls should be made using the more 3249efficient @code{jal} instruction. 3250 3251@item malloc 3252@cindex @code{malloc} function attribute 3253This tells the compiler that a function is @code{malloc}-like, i.e., 3254that the pointer @var{P} returned by the function cannot alias any 3255other pointer valid when the function returns, and moreover no 3256pointers to valid objects occur in any storage addressed by @var{P}. 3257 3258Using this attribute can improve optimization. Functions like 3259@code{malloc} and @code{calloc} have this property because they return 3260a pointer to uninitialized or zeroed-out storage. However, functions 3261like @code{realloc} do not have this property, as they can return a 3262pointer to storage containing pointers. 3263 3264@item mips16 3265@itemx nomips16 3266@cindex @code{mips16} function attribute, MIPS 3267@cindex @code{nomips16} function attribute, MIPS 3268 3269On MIPS targets, you can use the @code{mips16} and @code{nomips16} 3270function attributes to locally select or turn off MIPS16 code generation. 3271A function with the @code{mips16} attribute is emitted as MIPS16 code, 3272while MIPS16 code generation is disabled for functions with the 3273@code{nomips16} attribute. These attributes override the 3274@option{-mips16} and @option{-mno-mips16} options on the command line 3275(@pxref{MIPS Options}). 3276 3277When compiling files containing mixed MIPS16 and non-MIPS16 code, the 3278preprocessor symbol @code{__mips16} reflects the setting on the command line, 3279not that within individual functions. Mixed MIPS16 and non-MIPS16 code 3280may interact badly with some GCC extensions such as @code{__builtin_apply} 3281(@pxref{Constructing Calls}). 3282 3283@item micromips, MIPS 3284@itemx nomicromips, MIPS 3285@cindex @code{micromips} function attribute 3286@cindex @code{nomicromips} function attribute 3287 3288On MIPS targets, you can use the @code{micromips} and @code{nomicromips} 3289function attributes to locally select or turn off microMIPS code generation. 3290A function with the @code{micromips} attribute is emitted as microMIPS code, 3291while microMIPS code generation is disabled for functions with the 3292@code{nomicromips} attribute. These attributes override the 3293@option{-mmicromips} and @option{-mno-micromips} options on the command line 3294(@pxref{MIPS Options}). 3295 3296When compiling files containing mixed microMIPS and non-microMIPS code, the 3297preprocessor symbol @code{__mips_micromips} reflects the setting on the 3298command line, 3299not that within individual functions. Mixed microMIPS and non-microMIPS code 3300may interact badly with some GCC extensions such as @code{__builtin_apply} 3301(@pxref{Constructing Calls}). 3302 3303@item model (@var{model-name}) 3304@cindex @code{model} function attribute, M32R/D 3305@cindex function addressability on the M32R/D 3306 3307On the M32R/D, use this attribute to set the addressability of an 3308object, and of the code generated for a function. The identifier 3309@var{model-name} is one of @code{small}, @code{medium}, or 3310@code{large}, representing each of the code models. 3311 3312Small model objects live in the lower 16MB of memory (so that their 3313addresses can be loaded with the @code{ld24} instruction), and are 3314callable with the @code{bl} instruction. 3315 3316Medium model objects may live anywhere in the 32-bit address space (the 3317compiler generates @code{seth/add3} instructions to load their addresses), 3318and are callable with the @code{bl} instruction. 3319 3320Large model objects may live anywhere in the 32-bit address space (the 3321compiler generates @code{seth/add3} instructions to load their addresses), 3322and may not be reachable with the @code{bl} instruction (the compiler 3323generates the much slower @code{seth/add3/jl} instruction sequence). 3324 3325@item ms_abi 3326@itemx sysv_abi 3327@cindex @code{ms_abi} function attribute, x86 3328@cindex @code{sysv_abi} function attribute, x86 3329 3330On 32-bit and 64-bit x86 targets, you can use an ABI attribute 3331to indicate which calling convention should be used for a function. The 3332@code{ms_abi} attribute tells the compiler to use the Microsoft ABI, 3333while the @code{sysv_abi} attribute tells the compiler to use the ABI 3334used on GNU/Linux and other systems. The default is to use the Microsoft ABI 3335when targeting Windows. On all other systems, the default is the x86/AMD ABI. 3336 3337Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently 3338requires the @option{-maccumulate-outgoing-args} option. 3339 3340@item callee_pop_aggregate_return (@var{number}) 3341@cindex @code{callee_pop_aggregate_return} function attribute, x86 3342 3343On x86-32 targets, you can use this attribute to control how 3344aggregates are returned in memory. If the caller is responsible for 3345popping the hidden pointer together with the rest of the arguments, specify 3346@var{number} equal to zero. If callee is responsible for popping the 3347hidden pointer, specify @var{number} equal to one. 3348 3349The default x86-32 ABI assumes that the callee pops the 3350stack for hidden pointer. However, on x86-32 Microsoft Windows targets, 3351the compiler assumes that the 3352caller pops the stack for hidden pointer. 3353 3354@item ms_hook_prologue 3355@cindex @code{ms_hook_prologue} function attribute, x86 3356 3357On 32-bit and 64-bit x86 targets, you can use 3358this function attribute to make GCC generate the ``hot-patching'' function 3359prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2 3360and newer. 3361 3362@item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label}) 3363@cindex @code{hotpatch} function attribute, S/390 3364 3365On S/390 System z targets, you can use this function attribute to 3366make GCC generate a ``hot-patching'' function prologue. If the 3367@option{-mhotpatch=} command-line option is used at the same time, 3368the @code{hotpatch} attribute takes precedence. The first of the 3369two arguments specifies the number of halfwords to be added before 3370the function label. A second argument can be used to specify the 3371number of halfwords to be added after the function label. For 3372both arguments the maximum allowed value is 1000000. 3373 3374If both arguments are zero, hotpatching is disabled. 3375 3376@item naked 3377@cindex @code{naked} function attribute, ARM 3378@cindex @code{naked} function attribute, AVR 3379@cindex @code{naked} function attribute, MCORE 3380@cindex @code{naked} function attribute, MSP430 3381@cindex @code{naked} function attribute, NDS32 3382@cindex @code{naked} function attribute, RL78 3383@cindex @code{naked} function attribute, RX 3384@cindex @code{naked} function attribute, SPU 3385@cindex function without prologue/epilogue code 3386This attribute is available on the ARM, AVR, MCORE, MSP430, NDS32, 3387RL78, RX and SPU ports. It allows the compiler to construct the 3388requisite function declaration, while allowing the body of the 3389function to be assembly code. The specified function will not have 3390prologue/epilogue sequences generated by the compiler. Only basic 3391@code{asm} statements can safely be included in naked functions 3392(@pxref{Basic Asm}). While using extended @code{asm} or a mixture of 3393basic @code{asm} and C code may appear to work, they cannot be 3394depended upon to work reliably and are not supported. 3395 3396@item near 3397@cindex @code{near} function attribute, MeP 3398@cindex functions that do not handle memory bank switching on 68HC11/68HC12 3399On MeP targets this attribute causes the compiler to assume the called 3400function is close enough to use the normal calling convention, 3401overriding the @option{-mtf} command-line option. 3402 3403@item nesting 3404@cindex @code{nesting} function attribute, Blackfin 3405@cindex Allow nesting in an interrupt handler on the Blackfin processor 3406Use this attribute together with @code{interrupt_handler}, 3407@code{exception_handler} or @code{nmi_handler} to indicate that the function 3408entry code should enable nested interrupts or exceptions. 3409 3410@item nmi_handler 3411@cindex @code{nmi_handler} function attribute, Blackfin 3412@cindex NMI handler functions on the Blackfin processor 3413Use this attribute on the Blackfin to indicate that the specified function 3414is an NMI handler. The compiler generates function entry and 3415exit sequences suitable for use in an NMI handler when this 3416attribute is present. 3417 3418@item nocompression 3419@cindex @code{nocompression} function attribute, MIPS 3420On MIPS targets, you can use the @code{nocompression} function attribute 3421to locally turn off MIPS16 and microMIPS code generation. This attribute 3422overrides the @option{-mips16} and @option{-mmicromips} options on the 3423command line (@pxref{MIPS Options}). 3424 3425@item no_instrument_function 3426@cindex @code{no_instrument_function} function attribute 3427@opindex finstrument-functions 3428If @option{-finstrument-functions} is given, profiling function calls are 3429generated at entry and exit of most user-compiled functions. 3430Functions with this attribute are not so instrumented. 3431 3432@item no_split_stack 3433@cindex @code{no_split_stack} function attribute 3434@opindex fsplit-stack 3435If @option{-fsplit-stack} is given, functions have a small 3436prologue which decides whether to split the stack. Functions with the 3437@code{no_split_stack} attribute do not have that prologue, and thus 3438may run with only a small amount of stack space available. 3439 3440@item stack_protect 3441@cindex @code{stack_protect} function attribute 3442This function attribute make a stack protection of the function if 3443flags @option{fstack-protector} or @option{fstack-protector-strong} 3444or @option{fstack-protector-explicit} are set. 3445 3446@item noinline 3447@cindex @code{noinline} function attribute 3448This function attribute prevents a function from being considered for 3449inlining. 3450@c Don't enumerate the optimizations by name here; we try to be 3451@c future-compatible with this mechanism. 3452If the function does not have side-effects, there are optimizations 3453other than inlining that cause function calls to be optimized away, 3454although the function call is live. To keep such calls from being 3455optimized away, put 3456@smallexample 3457asm (""); 3458@end smallexample 3459 3460@noindent 3461(@pxref{Extended Asm}) in the called function, to serve as a special 3462side-effect. 3463 3464@item noclone 3465@cindex @code{noclone} function attribute 3466This function attribute prevents a function from being considered for 3467cloning---a mechanism that produces specialized copies of functions 3468and which is (currently) performed by interprocedural constant 3469propagation. 3470 3471@item no_icf 3472@cindex @code{no_icf} function attribute 3473This function attribute prevents a functions from being merged with another 3474semantically equivalent function. 3475 3476@item nonnull (@var{arg-index}, @dots{}) 3477@cindex @code{nonnull} function attribute 3478The @code{nonnull} attribute specifies that some function parameters should 3479be non-null pointers. For instance, the declaration: 3480 3481@smallexample 3482extern void * 3483my_memcpy (void *dest, const void *src, size_t len) 3484 __attribute__((nonnull (1, 2))); 3485@end smallexample 3486 3487@noindent 3488causes the compiler to check that, in calls to @code{my_memcpy}, 3489arguments @var{dest} and @var{src} are non-null. If the compiler 3490determines that a null pointer is passed in an argument slot marked 3491as non-null, and the @option{-Wnonnull} option is enabled, a warning 3492is issued. The compiler may also choose to make optimizations based 3493on the knowledge that certain function arguments will never be null. 3494 3495If no argument index list is given to the @code{nonnull} attribute, 3496all pointer arguments are marked as non-null. To illustrate, the 3497following declaration is equivalent to the previous example: 3498 3499@smallexample 3500extern void * 3501my_memcpy (void *dest, const void *src, size_t len) 3502 __attribute__((nonnull)); 3503@end smallexample 3504 3505@item no_reorder 3506@cindex @code{no_reorder} function attribute 3507Do not reorder functions or variables marked @code{no_reorder} 3508against each other or top level assembler statements the executable. 3509The actual order in the program will depend on the linker command 3510line. Static variables marked like this are also not removed. 3511This has a similar effect 3512as the @option{-fno-toplevel-reorder} option, but only applies to the 3513marked symbols. 3514 3515@item returns_nonnull 3516@cindex @code{returns_nonnull} function attribute 3517The @code{returns_nonnull} attribute specifies that the function 3518return value should be a non-null pointer. For instance, the declaration: 3519 3520@smallexample 3521extern void * 3522mymalloc (size_t len) __attribute__((returns_nonnull)); 3523@end smallexample 3524 3525@noindent 3526lets the compiler optimize callers based on the knowledge 3527that the return value will never be null. 3528 3529@item noreturn 3530@cindex @code{noreturn} function attribute 3531A few standard library functions, such as @code{abort} and @code{exit}, 3532cannot return. GCC knows this automatically. Some programs define 3533their own functions that never return. You can declare them 3534@code{noreturn} to tell the compiler this fact. For example, 3535 3536@smallexample 3537@group 3538void fatal () __attribute__ ((noreturn)); 3539 3540void 3541fatal (/* @r{@dots{}} */) 3542@{ 3543 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */ 3544 exit (1); 3545@} 3546@end group 3547@end smallexample 3548 3549The @code{noreturn} keyword tells the compiler to assume that 3550@code{fatal} cannot return. It can then optimize without regard to what 3551would happen if @code{fatal} ever did return. This makes slightly 3552better code. More importantly, it helps avoid spurious warnings of 3553uninitialized variables. 3554 3555The @code{noreturn} keyword does not affect the exceptional path when that 3556applies: a @code{noreturn}-marked function may still return to the caller 3557by throwing an exception or calling @code{longjmp}. 3558 3559Do not assume that registers saved by the calling function are 3560restored before calling the @code{noreturn} function. 3561 3562It does not make sense for a @code{noreturn} function to have a return 3563type other than @code{void}. 3564 3565@item nothrow 3566@cindex @code{nothrow} function attribute 3567The @code{nothrow} attribute is used to inform the compiler that a 3568function cannot throw an exception. For example, most functions in 3569the standard C library can be guaranteed not to throw an exception 3570with the notable exceptions of @code{qsort} and @code{bsearch} that 3571take function pointer arguments. 3572 3573@item nosave_low_regs 3574@cindex @code{nosave_low_regs} function attribute, SH 3575Use this attribute on SH targets to indicate that an @code{interrupt_handler} 3576function should not save and restore registers R0..R7. This can be used on SH3* 3577and SH4* targets that have a second R0..R7 register bank for non-reentrant 3578interrupt handlers. 3579 3580@item optimize 3581@cindex @code{optimize} function attribute 3582The @code{optimize} attribute is used to specify that a function is to 3583be compiled with different optimization options than specified on the 3584command line. Arguments can either be numbers or strings. Numbers 3585are assumed to be an optimization level. Strings that begin with 3586@code{O} are assumed to be an optimization option, while other options 3587are assumed to be used with a @code{-f} prefix. You can also use the 3588@samp{#pragma GCC optimize} pragma to set the optimization options 3589that affect more than one function. 3590@xref{Function Specific Option Pragmas}, for details about the 3591@samp{#pragma GCC optimize} pragma. 3592 3593This can be used for instance to have frequently-executed functions 3594compiled with more aggressive optimization options that produce faster 3595and larger code, while other functions can be compiled with less 3596aggressive options. 3597 3598@item OS_main 3599@itemx OS_task 3600@cindex @code{OS_main} function attribute, AVR 3601@cindex @code{OS_task} function attribute, AVR 3602On AVR, functions with the @code{OS_main} or @code{OS_task} attribute 3603do not save/restore any call-saved register in their prologue/epilogue. 3604 3605The @code{OS_main} attribute can be used when there @emph{is 3606guarantee} that interrupts are disabled at the time when the function 3607is entered. This saves resources when the stack pointer has to be 3608changed to set up a frame for local variables. 3609 3610The @code{OS_task} attribute can be used when there is @emph{no 3611guarantee} that interrupts are disabled at that time when the function 3612is entered like for, e@.g@. task functions in a multi-threading operating 3613system. In that case, changing the stack pointer register is 3614guarded by save/clear/restore of the global interrupt enable flag. 3615 3616The differences to the @code{naked} function attribute are: 3617@itemize @bullet 3618@item @code{naked} functions do not have a return instruction whereas 3619@code{OS_main} and @code{OS_task} functions have a @code{RET} or 3620@code{RETI} return instruction. 3621@item @code{naked} functions do not set up a frame for local variables 3622or a frame pointer whereas @code{OS_main} and @code{OS_task} do this 3623as needed. 3624@end itemize 3625 3626@item pcs 3627@cindex @code{pcs} function attribute, ARM 3628 3629The @code{pcs} attribute can be used to control the calling convention 3630used for a function on ARM. The attribute takes an argument that specifies 3631the calling convention to use. 3632 3633When compiling using the AAPCS ABI (or a variant of it) then valid 3634values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In 3635order to use a variant other than @code{"aapcs"} then the compiler must 3636be permitted to use the appropriate co-processor registers (i.e., the 3637VFP registers must be available in order to use @code{"aapcs-vfp"}). 3638For example, 3639 3640@smallexample 3641/* Argument passed in r0, and result returned in r0+r1. */ 3642double f2d (float) __attribute__((pcs("aapcs"))); 3643@end smallexample 3644 3645Variadic functions always use the @code{"aapcs"} calling convention and 3646the compiler rejects attempts to specify an alternative. 3647 3648@item pure 3649@cindex @code{pure} function attribute 3650Many functions have no effects except the return value and their 3651return value depends only on the parameters and/or global variables. 3652Such a function can be subject 3653to common subexpression elimination and loop optimization just as an 3654arithmetic operator would be. These functions should be declared 3655with the attribute @code{pure}. For example, 3656 3657@smallexample 3658int square (int) __attribute__ ((pure)); 3659@end smallexample 3660 3661@noindent 3662says that the hypothetical function @code{square} is safe to call 3663fewer times than the program says. 3664 3665Some of common examples of pure functions are @code{strlen} or @code{memcmp}. 3666Interesting non-pure functions are functions with infinite loops or those 3667depending on volatile memory or other system resource, that may change between 3668two consecutive calls (such as @code{feof} in a multithreading environment). 3669 3670@item hot 3671@cindex @code{hot} function attribute 3672The @code{hot} attribute on a function is used to inform the compiler that 3673the function is a hot spot of the compiled program. The function is 3674optimized more aggressively and on many targets it is placed into a special 3675subsection of the text section so all hot functions appear close together, 3676improving locality. 3677 3678When profile feedback is available, via @option{-fprofile-use}, hot functions 3679are automatically detected and this attribute is ignored. 3680 3681@item cold 3682@cindex @code{cold} function attribute 3683The @code{cold} attribute on functions is used to inform the compiler that 3684the function is unlikely to be executed. The function is optimized for 3685size rather than speed and on many targets it is placed into a special 3686subsection of the text section so all cold functions appear close together, 3687improving code locality of non-cold parts of program. The paths leading 3688to calls of cold functions within code are marked as unlikely by the branch 3689prediction mechanism. It is thus useful to mark functions used to handle 3690unlikely conditions, such as @code{perror}, as cold to improve optimization 3691of hot functions that do call marked functions in rare occasions. 3692 3693When profile feedback is available, via @option{-fprofile-use}, cold functions 3694are automatically detected and this attribute is ignored. 3695 3696@item no_sanitize_address 3697@itemx no_address_safety_analysis 3698@cindex @code{no_sanitize_address} function attribute 3699The @code{no_sanitize_address} attribute on functions is used 3700to inform the compiler that it should not instrument memory accesses 3701in the function when compiling with the @option{-fsanitize=address} option. 3702The @code{no_address_safety_analysis} is a deprecated alias of the 3703@code{no_sanitize_address} attribute, new code should use 3704@code{no_sanitize_address}. 3705 3706@item no_sanitize_thread 3707@cindex @code{no_sanitize_thread} function attribute 3708The @code{no_sanitize_thread} attribute on functions is used 3709to inform the compiler that it should not instrument memory accesses 3710in the function when compiling with the @option{-fsanitize=thread} option. 3711 3712@item no_sanitize_undefined 3713@cindex @code{no_sanitize_undefined} function attribute 3714The @code{no_sanitize_undefined} attribute on functions is used 3715to inform the compiler that it should not check for undefined behavior 3716in the function when compiling with the @option{-fsanitize=undefined} option. 3717 3718@item bnd_legacy 3719@cindex @code{bnd_legacy} function attribute 3720@cindex Pointer Bounds Checker attributes 3721The @code{bnd_legacy} attribute on functions is used to inform the 3722compiler that the function should not be instrumented when compiled 3723with the @option{-fcheck-pointer-bounds} option. 3724 3725@item bnd_instrument 3726@cindex @code{bnd_instrument} function attribute 3727The @code{bnd_instrument} attribute on functions is used to inform the 3728compiler that the function should be instrumented when compiled 3729with the @option{-fchkp-instrument-marked-only} option. 3730 3731@item regparm (@var{number}) 3732@cindex @code{regparm} function attribute, x86 3733@cindex functions that are passed arguments in registers on x86-32 3734On x86-32 targets, the @code{regparm} attribute causes the compiler to 3735pass arguments number one to @var{number} if they are of integral type 3736in registers EAX, EDX, and ECX instead of on the stack. Functions that 3737take a variable number of arguments continue to be passed all of their 3738arguments on the stack. 3739 3740Beware that on some ELF systems this attribute is unsuitable for 3741global functions in shared libraries with lazy binding (which is the 3742default). Lazy binding sends the first call via resolving code in 3743the loader, which might assume EAX, EDX and ECX can be clobbered, as 3744per the standard calling conventions. Solaris 8 is affected by this. 3745Systems with the GNU C Library version 2.1 or higher 3746and FreeBSD are believed to be 3747safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be 3748disabled with the linker or the loader if desired, to avoid the 3749problem.) 3750 3751@item reset 3752@cindex @code{reset} function attribute, NDS32 3753@cindex reset handler functions 3754Use this attribute on the NDS32 target to indicate that the specified function 3755is a reset handler. The compiler will generate corresponding sections 3756for use in a reset handler. You can use the following attributes 3757to provide extra exception handling: 3758@table @code 3759@item nmi 3760@cindex @code{nmi} function attribute, NDS32 3761Provide a user-defined function to handle NMI exception. 3762@item warm 3763@cindex @code{warm} function attribute, NDS32 3764Provide a user-defined function to handle warm reset exception. 3765@end table 3766 3767@item sseregparm 3768@cindex @code{sseregparm} function attribute, x86 3769On x86-32 targets with SSE support, the @code{sseregparm} attribute 3770causes the compiler to pass up to 3 floating-point arguments in 3771SSE registers instead of on the stack. Functions that take a 3772variable number of arguments continue to pass all of their 3773floating-point arguments on the stack. 3774 3775@item force_align_arg_pointer 3776@cindex @code{force_align_arg_pointer} function attribute, x86 3777On x86 targets, the @code{force_align_arg_pointer} attribute may be 3778applied to individual function definitions, generating an alternate 3779prologue and epilogue that realigns the run-time stack if necessary. 3780This supports mixing legacy codes that run with a 4-byte aligned stack 3781with modern codes that keep a 16-byte stack for SSE compatibility. 3782 3783@item renesas 3784@cindex @code{renesas} function attribute, SH 3785On SH targets this attribute specifies that the function or struct follows the 3786Renesas ABI. 3787 3788@item resbank 3789@cindex @code{resbank} function attribute, SH 3790On the SH2A target, this attribute enables the high-speed register 3791saving and restoration using a register bank for @code{interrupt_handler} 3792routines. Saving to the bank is performed automatically after the CPU 3793accepts an interrupt that uses a register bank. 3794 3795The nineteen 32-bit registers comprising general register R0 to R14, 3796control register GBR, and system registers MACH, MACL, and PR and the 3797vector table address offset are saved into a register bank. Register 3798banks are stacked in first-in last-out (FILO) sequence. Restoration 3799from the bank is executed by issuing a RESBANK instruction. 3800 3801@item returns_twice 3802@cindex @code{returns_twice} function attribute 3803The @code{returns_twice} attribute tells the compiler that a function may 3804return more than one time. The compiler ensures that all registers 3805are dead before calling such a function and emits a warning about 3806the variables that may be clobbered after the second return from the 3807function. Examples of such functions are @code{setjmp} and @code{vfork}. 3808The @code{longjmp}-like counterpart of such function, if any, might need 3809to be marked with the @code{noreturn} attribute. 3810 3811@item saveall 3812@cindex @code{saveall} function attribute, Blackfin 3813@cindex @code{saveall} function attribute, H8/300 3814@cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S 3815Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that 3816all registers except the stack pointer should be saved in the prologue 3817regardless of whether they are used or not. 3818 3819@item save_volatiles 3820@cindex @code{save_volatiles} function attribute, MicroBlaze 3821Use this attribute on the MicroBlaze to indicate that the function is 3822an interrupt handler. All volatile registers (in addition to non-volatile 3823registers) are saved in the function prologue. If the function is a leaf 3824function, only volatiles used by the function are saved. A normal function 3825return is generated instead of a return from interrupt. 3826 3827@item break_handler 3828@cindex @code{break_handler} function attribute, MicroBlaze 3829@cindex break handler functions 3830Use this attribute on the MicroBlaze ports to indicate that 3831the specified function is a break handler. The compiler generates function 3832entry and exit sequences suitable for use in an break handler when this 3833attribute is present. The return from @code{break_handler} is done through 3834the @code{rtbd} instead of @code{rtsd}. 3835 3836@smallexample 3837void f () __attribute__ ((break_handler)); 3838@end smallexample 3839 3840@item section ("@var{section-name}") 3841@cindex @code{section} function attribute 3842Normally, the compiler places the code it generates in the @code{text} section. 3843Sometimes, however, you need additional sections, or you need certain 3844particular functions to appear in special sections. The @code{section} 3845attribute specifies that a function lives in a particular section. 3846For example, the declaration: 3847 3848@smallexample 3849extern void foobar (void) __attribute__ ((section ("bar"))); 3850@end smallexample 3851 3852@noindent 3853puts the function @code{foobar} in the @code{bar} section. 3854 3855Some file formats do not support arbitrary sections so the @code{section} 3856attribute is not available on all platforms. 3857If you need to map the entire contents of a module to a particular 3858section, consider using the facilities of the linker instead. 3859 3860@item sentinel 3861@cindex @code{sentinel} function attribute 3862This function attribute ensures that a parameter in a function call is 3863an explicit @code{NULL}. The attribute is only valid on variadic 3864functions. By default, the sentinel is located at position zero, the 3865last parameter of the function call. If an optional integer position 3866argument P is supplied to the attribute, the sentinel must be located at 3867position P counting backwards from the end of the argument list. 3868 3869@smallexample 3870__attribute__ ((sentinel)) 3871is equivalent to 3872__attribute__ ((sentinel(0))) 3873@end smallexample 3874 3875The attribute is automatically set with a position of 0 for the built-in 3876functions @code{execl} and @code{execlp}. The built-in function 3877@code{execle} has the attribute set with a position of 1. 3878 3879A valid @code{NULL} in this context is defined as zero with any pointer 3880type. If your system defines the @code{NULL} macro with an integer type 3881then you need to add an explicit cast. GCC replaces @code{stddef.h} 3882with a copy that redefines NULL appropriately. 3883 3884The warnings for missing or incorrect sentinels are enabled with 3885@option{-Wformat}. 3886 3887@item short_call 3888See @code{long_call}. 3889 3890@item shortcall 3891See @code{longcall}. 3892 3893@item signal 3894@cindex @code{signal} function attribute, AVR 3895Use this attribute on the AVR to indicate that the specified 3896function is an interrupt handler. The compiler generates function 3897entry and exit sequences suitable for use in an interrupt handler when this 3898attribute is present. 3899 3900See also the @code{interrupt} function attribute. 3901 3902The AVR hardware globally disables interrupts when an interrupt is executed. 3903Interrupt handler functions defined with the @code{signal} attribute 3904do not re-enable interrupts. It is save to enable interrupts in a 3905@code{signal} handler. This ``save'' only applies to the code 3906generated by the compiler and not to the IRQ layout of the 3907application which is responsibility of the application. 3908 3909If both @code{signal} and @code{interrupt} are specified for the same 3910function, @code{signal} is silently ignored. 3911 3912@item sp_switch 3913@cindex @code{sp_switch} function attribute, SH 3914Use this attribute on the SH to indicate an @code{interrupt_handler} 3915function should switch to an alternate stack. It expects a string 3916argument that names a global variable holding the address of the 3917alternate stack. 3918 3919@smallexample 3920void *alt_stack; 3921void f () __attribute__ ((interrupt_handler, 3922 sp_switch ("alt_stack"))); 3923@end smallexample 3924 3925@item stdcall 3926@cindex @code{stdcall} function attribute, x86-32 3927@cindex functions that pop the argument stack on x86-32 3928On x86-32 targets, the @code{stdcall} attribute causes the compiler to 3929assume that the called function pops off the stack space used to 3930pass arguments, unless it takes a variable number of arguments. 3931 3932@item syscall_linkage 3933@cindex @code{syscall_linkage} function attribute, IA-64 3934This attribute is used to modify the IA-64 calling convention by marking 3935all input registers as live at all function exits. This makes it possible 3936to restart a system call after an interrupt without having to save/restore 3937the input registers. This also prevents kernel data from leaking into 3938application code. 3939 3940@item target 3941@cindex @code{target} function attribute 3942The @code{target} attribute is used to specify that a function is to 3943be compiled with different target options than specified on the 3944command line. This can be used for instance to have functions 3945compiled with a different ISA (instruction set architecture) than the 3946default. You can also use the @samp{#pragma GCC target} pragma to set 3947more than one function to be compiled with specific target options. 3948@xref{Function Specific Option Pragmas}, for details about the 3949@samp{#pragma GCC target} pragma. 3950 3951For instance on an x86, you could compile one function with 3952@code{target("sse4.1,arch=core2")} and another with 3953@code{target("sse4a,arch=amdfam10")}. This is equivalent to 3954compiling the first function with @option{-msse4.1} and 3955@option{-march=core2} options, and the second function with 3956@option{-msse4a} and @option{-march=amdfam10} options. It is up to the 3957user to make sure that a function is only invoked on a machine that 3958supports the particular ISA it is compiled for (for example by using 3959@code{cpuid} on x86 to determine what feature bits and architecture 3960family are used). 3961 3962@smallexample 3963int core2_func (void) __attribute__ ((__target__ ("arch=core2"))); 3964int sse3_func (void) __attribute__ ((__target__ ("sse3"))); 3965@end smallexample 3966 3967You can either use multiple 3968strings to specify multiple options, or separate the options 3969with a comma (@samp{,}). 3970 3971The @code{target} attribute is presently implemented for 3972x86, PowerPC, and Nios II targets only. 3973The options supported are specific to each target. 3974 3975On the x86, the following options are allowed: 3976 3977@table @samp 3978@item abm 3979@itemx no-abm 3980@cindex @code{target("abm")} function attribute, x86 3981Enable/disable the generation of the advanced bit instructions. 3982 3983@item aes 3984@itemx no-aes 3985@cindex @code{target("aes")} function attribute, x86 3986Enable/disable the generation of the AES instructions. 3987 3988@item default 3989@cindex @code{target("default")} function attribute, x86 3990@xref{Function Multiversioning}, where it is used to specify the 3991default function version. 3992 3993@item mmx 3994@itemx no-mmx 3995@cindex @code{target("mmx")} function attribute, x86 3996Enable/disable the generation of the MMX instructions. 3997 3998@item pclmul 3999@itemx no-pclmul 4000@cindex @code{target("pclmul")} function attribute, x86 4001Enable/disable the generation of the PCLMUL instructions. 4002 4003@item popcnt 4004@itemx no-popcnt 4005@cindex @code{target("popcnt")} function attribute, x86 4006Enable/disable the generation of the POPCNT instruction. 4007 4008@item sse 4009@itemx no-sse 4010@cindex @code{target("sse")} function attribute, x86 4011Enable/disable the generation of the SSE instructions. 4012 4013@item sse2 4014@itemx no-sse2 4015@cindex @code{target("sse2")} function attribute, x86 4016Enable/disable the generation of the SSE2 instructions. 4017 4018@item sse3 4019@itemx no-sse3 4020@cindex @code{target("sse3")} function attribute, x86 4021Enable/disable the generation of the SSE3 instructions. 4022 4023@item sse4 4024@itemx no-sse4 4025@cindex @code{target("sse4")} function attribute, x86 4026Enable/disable the generation of the SSE4 instructions (both SSE4.1 4027and SSE4.2). 4028 4029@item sse4.1 4030@itemx no-sse4.1 4031@cindex @code{target("sse4.1")} function attribute, x86 4032Enable/disable the generation of the sse4.1 instructions. 4033 4034@item sse4.2 4035@itemx no-sse4.2 4036@cindex @code{target("sse4.2")} function attribute, x86 4037Enable/disable the generation of the sse4.2 instructions. 4038 4039@item sse4a 4040@itemx no-sse4a 4041@cindex @code{target("sse4a")} function attribute, x86 4042Enable/disable the generation of the SSE4A instructions. 4043 4044@item fma4 4045@itemx no-fma4 4046@cindex @code{target("fma4")} function attribute, x86 4047Enable/disable the generation of the FMA4 instructions. 4048 4049@item xop 4050@itemx no-xop 4051@cindex @code{target("xop")} function attribute, x86 4052Enable/disable the generation of the XOP instructions. 4053 4054@item lwp 4055@itemx no-lwp 4056@cindex @code{target("lwp")} function attribute, x86 4057Enable/disable the generation of the LWP instructions. 4058 4059@item ssse3 4060@itemx no-ssse3 4061@cindex @code{target("ssse3")} function attribute, x86 4062Enable/disable the generation of the SSSE3 instructions. 4063 4064@item cld 4065@itemx no-cld 4066@cindex @code{target("cld")} function attribute, x86 4067Enable/disable the generation of the CLD before string moves. 4068 4069@item fancy-math-387 4070@itemx no-fancy-math-387 4071@cindex @code{target("fancy-math-387")} function attribute, x86 4072Enable/disable the generation of the @code{sin}, @code{cos}, and 4073@code{sqrt} instructions on the 387 floating-point unit. 4074 4075@item fused-madd 4076@itemx no-fused-madd 4077@cindex @code{target("fused-madd")} function attribute, x86 4078Enable/disable the generation of the fused multiply/add instructions. 4079 4080@item ieee-fp 4081@itemx no-ieee-fp 4082@cindex @code{target("ieee-fp")} function attribute, x86 4083Enable/disable the generation of floating point that depends on IEEE arithmetic. 4084 4085@item inline-all-stringops 4086@itemx no-inline-all-stringops 4087@cindex @code{target("inline-all-stringops")} function attribute, x86 4088Enable/disable inlining of string operations. 4089 4090@item inline-stringops-dynamically 4091@itemx no-inline-stringops-dynamically 4092@cindex @code{target("inline-stringops-dynamically")} function attribute, x86 4093Enable/disable the generation of the inline code to do small string 4094operations and calling the library routines for large operations. 4095 4096@item align-stringops 4097@itemx no-align-stringops 4098@cindex @code{target("align-stringops")} function attribute, x86 4099Do/do not align destination of inlined string operations. 4100 4101@item recip 4102@itemx no-recip 4103@cindex @code{target("recip")} function attribute, x86 4104Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS 4105instructions followed an additional Newton-Raphson step instead of 4106doing a floating-point division. 4107 4108@item arch=@var{ARCH} 4109@cindex @code{target("arch=@var{ARCH}")} function attribute, x86 4110Specify the architecture to generate code for in compiling the function. 4111 4112@item tune=@var{TUNE} 4113@cindex @code{target("tune=@var{TUNE}")} function attribute, x86 4114Specify the architecture to tune for in compiling the function. 4115 4116@item fpmath=@var{FPMATH} 4117@cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86 4118Specify which floating-point unit to use. The 4119@code{target("fpmath=sse,387")} option must be specified as 4120@code{target("fpmath=sse+387")} because the comma would separate 4121different options. 4122 4123@item indirect_branch("@var{choice}") 4124@cindex @code{indirect_branch} function attribute, x86 4125On x86 targets, the @code{indirect_branch} attribute causes the compiler 4126to convert indirect call and jump with @var{choice}. @samp{keep} 4127keeps indirect call and jump unmodified. @samp{thunk} converts indirect 4128call and jump to call and return thunk. @samp{thunk-inline} converts 4129indirect call and jump to inlined call and return thunk. 4130@samp{thunk-extern} converts indirect call and jump to external call 4131and return thunk provided in a separate object file. 4132 4133@item function_return("@var{choice}") 4134@cindex @code{function_return} function attribute, x86 4135On x86 targets, the @code{function_return} attribute causes the compiler 4136to convert function return with @var{choice}. @samp{keep} keeps function 4137return unmodified. @samp{thunk} converts function return to call and 4138return thunk. @samp{thunk-inline} converts function return to inlined 4139call and return thunk. @samp{thunk-extern} converts function return to 4140external call and return thunk provided in a separate object file. 4141@end table 4142 4143On the PowerPC, the following options are allowed: 4144 4145@table @samp 4146@item altivec 4147@itemx no-altivec 4148@cindex @code{target("altivec")} function attribute, PowerPC 4149Generate code that uses (does not use) AltiVec instructions. In 415032-bit code, you cannot enable AltiVec instructions unless 4151@option{-mabi=altivec} is used on the command line. 4152 4153@item cmpb 4154@itemx no-cmpb 4155@cindex @code{target("cmpb")} function attribute, PowerPC 4156Generate code that uses (does not use) the compare bytes instruction 4157implemented on the POWER6 processor and other processors that support 4158the PowerPC V2.05 architecture. 4159 4160@item dlmzb 4161@itemx no-dlmzb 4162@cindex @code{target("dlmzb")} function attribute, PowerPC 4163Generate code that uses (does not use) the string-search @samp{dlmzb} 4164instruction on the IBM 405, 440, 464 and 476 processors. This instruction is 4165generated by default when targeting those processors. 4166 4167@item fprnd 4168@itemx no-fprnd 4169@cindex @code{target("fprnd")} function attribute, PowerPC 4170Generate code that uses (does not use) the FP round to integer 4171instructions implemented on the POWER5+ processor and other processors 4172that support the PowerPC V2.03 architecture. 4173 4174@item hard-dfp 4175@itemx no-hard-dfp 4176@cindex @code{target("hard-dfp")} function attribute, PowerPC 4177Generate code that uses (does not use) the decimal floating-point 4178instructions implemented on some POWER processors. 4179 4180@item isel 4181@itemx no-isel 4182@cindex @code{target("isel")} function attribute, PowerPC 4183Generate code that uses (does not use) ISEL instruction. 4184 4185@item mfcrf 4186@itemx no-mfcrf 4187@cindex @code{target("mfcrf")} function attribute, PowerPC 4188Generate code that uses (does not use) the move from condition 4189register field instruction implemented on the POWER4 processor and 4190other processors that support the PowerPC V2.01 architecture. 4191 4192@item mfpgpr 4193@itemx no-mfpgpr 4194@cindex @code{target("mfpgpr")} function attribute, PowerPC 4195Generate code that uses (does not use) the FP move to/from general 4196purpose register instructions implemented on the POWER6X processor and 4197other processors that support the extended PowerPC V2.05 architecture. 4198 4199@item mulhw 4200@itemx no-mulhw 4201@cindex @code{target("mulhw")} function attribute, PowerPC 4202Generate code that uses (does not use) the half-word multiply and 4203multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors. 4204These instructions are generated by default when targeting those 4205processors. 4206 4207@item multiple 4208@itemx no-multiple 4209@cindex @code{target("multiple")} function attribute, PowerPC 4210Generate code that uses (does not use) the load multiple word 4211instructions and the store multiple word instructions. 4212 4213@item update 4214@itemx no-update 4215@cindex @code{target("update")} function attribute, PowerPC 4216Generate code that uses (does not use) the load or store instructions 4217that update the base register to the address of the calculated memory 4218location. 4219 4220@item popcntb 4221@itemx no-popcntb 4222@cindex @code{target("popcntb")} function attribute, PowerPC 4223Generate code that uses (does not use) the popcount and double-precision 4224FP reciprocal estimate instruction implemented on the POWER5 4225processor and other processors that support the PowerPC V2.02 4226architecture. 4227 4228@item popcntd 4229@itemx no-popcntd 4230@cindex @code{target("popcntd")} function attribute, PowerPC 4231Generate code that uses (does not use) the popcount instruction 4232implemented on the POWER7 processor and other processors that support 4233the PowerPC V2.06 architecture. 4234 4235@item powerpc-gfxopt 4236@itemx no-powerpc-gfxopt 4237@cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC 4238Generate code that uses (does not use) the optional PowerPC 4239architecture instructions in the Graphics group, including 4240floating-point select. 4241 4242@item powerpc-gpopt 4243@itemx no-powerpc-gpopt 4244@cindex @code{target("powerpc-gpopt")} function attribute, PowerPC 4245Generate code that uses (does not use) the optional PowerPC 4246architecture instructions in the General Purpose group, including 4247floating-point square root. 4248 4249@item recip-precision 4250@itemx no-recip-precision 4251@cindex @code{target("recip-precision")} function attribute, PowerPC 4252Assume (do not assume) that the reciprocal estimate instructions 4253provide higher-precision estimates than is mandated by the PowerPC 4254ABI. 4255 4256@item string 4257@itemx no-string 4258@cindex @code{target("string")} function attribute, PowerPC 4259Generate code that uses (does not use) the load string instructions 4260and the store string word instructions to save multiple registers and 4261do small block moves. 4262 4263@item vsx 4264@itemx no-vsx 4265@cindex @code{target("vsx")} function attribute, PowerPC 4266Generate code that uses (does not use) vector/scalar (VSX) 4267instructions, and also enable the use of built-in functions that allow 4268more direct access to the VSX instruction set. In 32-bit code, you 4269cannot enable VSX or AltiVec instructions unless 4270@option{-mabi=altivec} is used on the command line. 4271 4272@item friz 4273@itemx no-friz 4274@cindex @code{target("friz")} function attribute, PowerPC 4275Generate (do not generate) the @code{friz} instruction when the 4276@option{-funsafe-math-optimizations} option is used to optimize 4277rounding a floating-point value to 64-bit integer and back to floating 4278point. The @code{friz} instruction does not return the same value if 4279the floating-point number is too large to fit in an integer. 4280 4281@item avoid-indexed-addresses 4282@itemx no-avoid-indexed-addresses 4283@cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC 4284Generate code that tries to avoid (not avoid) the use of indexed load 4285or store instructions. 4286 4287@item paired 4288@itemx no-paired 4289@cindex @code{target("paired")} function attribute, PowerPC 4290Generate code that uses (does not use) the generation of PAIRED simd 4291instructions. 4292 4293@item longcall 4294@itemx no-longcall 4295@cindex @code{target("longcall")} function attribute, PowerPC 4296Generate code that assumes (does not assume) that all calls are far 4297away so that a longer more expensive calling sequence is required. 4298 4299@item cpu=@var{CPU} 4300@cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC 4301Specify the architecture to generate code for when compiling the 4302function. If you select the @code{target("cpu=power7")} attribute when 4303generating 32-bit code, VSX and AltiVec instructions are not generated 4304unless you use the @option{-mabi=altivec} option on the command line. 4305 4306@item tune=@var{TUNE} 4307@cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC 4308Specify the architecture to tune for when compiling the function. If 4309you do not specify the @code{target("tune=@var{TUNE}")} attribute and 4310you do specify the @code{target("cpu=@var{CPU}")} attribute, 4311compilation tunes for the @var{CPU} architecture, and not the 4312default tuning specified on the command line. 4313@end table 4314 4315When compiling for Nios II, the following options are allowed: 4316 4317@table @samp 4318@item custom-@var{insn}=@var{N} 4319@itemx no-custom-@var{insn} 4320@cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II 4321@cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II 4322Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a 4323custom instruction with encoding @var{N} when generating code that uses 4324@var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of 4325the custom instruction @var{insn}. 4326These target attributes correspond to the 4327@option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}} 4328command-line options, and support the same set of @var{insn} keywords. 4329@xref{Nios II Options}, for more information. 4330 4331@item custom-fpu-cfg=@var{name} 4332@cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II 4333This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}} 4334command-line option, to select a predefined set of custom instructions 4335named @var{name}. 4336@xref{Nios II Options}, for more information. 4337@end table 4338 4339On the x86 and PowerPC back ends, the inliner does not inline a 4340function that has different target options than the caller, unless the 4341callee has a subset of the target options of the caller. For example 4342a function declared with @code{target("sse3")} can inline a function 4343with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}. 4344 4345@item trap_exit 4346@cindex @code{trap_exit} function attribute, SH 4347Use this attribute on the SH for an @code{interrupt_handler} to return using 4348@code{trapa} instead of @code{rte}. This attribute expects an integer 4349argument specifying the trap number to be used. 4350 4351@item trapa_handler 4352@cindex @code{trapa_handler} function attribute, SH 4353On SH targets this function attribute is similar to @code{interrupt_handler} 4354but it does not save and restore all registers. 4355 4356@item unused 4357@cindex @code{unused} function attribute 4358This attribute, attached to a function, means that the function is meant 4359to be possibly unused. GCC does not produce a warning for this 4360function. 4361 4362@item used 4363@cindex @code{used} function attribute 4364This attribute, attached to a function, means that code must be emitted 4365for the function even if it appears that the function is not referenced. 4366This is useful, for example, when the function is referenced only in 4367inline assembly. 4368 4369When applied to a member function of a C++ class template, the 4370attribute also means that the function is instantiated if the 4371class itself is instantiated. 4372 4373@item vector 4374@cindex @code{vector} function attribute, RX 4375This RX attribute is similar to the @code{interrupt} attribute, including its 4376parameters, but does not make the function an interrupt-handler type 4377function (i.e. it retains the normal C function calling ABI). See the 4378@code{interrupt} attribute for a description of its arguments. 4379 4380@item version_id 4381@cindex @code{version_id} function attribute, IA-64 4382This IA-64 HP-UX attribute, attached to a global variable or function, renames a 4383symbol to contain a version string, thus allowing for function level 4384versioning. HP-UX system header files may use function level versioning 4385for some system calls. 4386 4387@smallexample 4388extern int foo () __attribute__((version_id ("20040821"))); 4389@end smallexample 4390 4391@noindent 4392Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}. 4393 4394@item visibility ("@var{visibility_type}") 4395@cindex @code{visibility} function attribute 4396This attribute affects the linkage of the declaration to which it is attached. 4397There are four supported @var{visibility_type} values: default, 4398hidden, protected or internal visibility. 4399 4400@smallexample 4401void __attribute__ ((visibility ("protected"))) 4402f () @{ /* @r{Do something.} */; @} 4403int i __attribute__ ((visibility ("hidden"))); 4404@end smallexample 4405 4406The possible values of @var{visibility_type} correspond to the 4407visibility settings in the ELF gABI. 4408 4409@table @dfn 4410@c keep this list of visibilities in alphabetical order. 4411 4412@item default 4413Default visibility is the normal case for the object file format. 4414This value is available for the visibility attribute to override other 4415options that may change the assumed visibility of entities. 4416 4417On ELF, default visibility means that the declaration is visible to other 4418modules and, in shared libraries, means that the declared entity may be 4419overridden. 4420 4421On Darwin, default visibility means that the declaration is visible to 4422other modules. 4423 4424Default visibility corresponds to ``external linkage'' in the language. 4425 4426@item hidden 4427Hidden visibility indicates that the entity declared has a new 4428form of linkage, which we call ``hidden linkage''. Two 4429declarations of an object with hidden linkage refer to the same object 4430if they are in the same shared object. 4431 4432@item internal 4433Internal visibility is like hidden visibility, but with additional 4434processor specific semantics. Unless otherwise specified by the 4435psABI, GCC defines internal visibility to mean that a function is 4436@emph{never} called from another module. Compare this with hidden 4437functions which, while they cannot be referenced directly by other 4438modules, can be referenced indirectly via function pointers. By 4439indicating that a function cannot be called from outside the module, 4440GCC may for instance omit the load of a PIC register since it is known 4441that the calling function loaded the correct value. 4442 4443@item protected 4444Protected visibility is like default visibility except that it 4445indicates that references within the defining module bind to the 4446definition in that module. That is, the declared entity cannot be 4447overridden by another module. 4448 4449@end table 4450 4451All visibilities are supported on many, but not all, ELF targets 4452(supported when the assembler supports the @samp{.visibility} 4453pseudo-op). Default visibility is supported everywhere. Hidden 4454visibility is supported on Darwin targets. 4455 4456The visibility attribute should be applied only to declarations that 4457would otherwise have external linkage. The attribute should be applied 4458consistently, so that the same entity should not be declared with 4459different settings of the attribute. 4460 4461In C++, the visibility attribute applies to types as well as functions 4462and objects, because in C++ types have linkage. A class must not have 4463greater visibility than its non-static data member types and bases, 4464and class members default to the visibility of their class. Also, a 4465declaration without explicit visibility is limited to the visibility 4466of its type. 4467 4468In C++, you can mark member functions and static member variables of a 4469class with the visibility attribute. This is useful if you know a 4470particular method or static member variable should only be used from 4471one shared object; then you can mark it hidden while the rest of the 4472class has default visibility. Care must be taken to avoid breaking 4473the One Definition Rule; for example, it is usually not useful to mark 4474an inline method as hidden without marking the whole class as hidden. 4475 4476A C++ namespace declaration can also have the visibility attribute. 4477 4478@smallexample 4479namespace nspace1 __attribute__ ((visibility ("protected"))) 4480@{ /* @r{Do something.} */; @} 4481@end smallexample 4482 4483This attribute applies only to the particular namespace body, not to 4484other definitions of the same namespace; it is equivalent to using 4485@samp{#pragma GCC visibility} before and after the namespace 4486definition (@pxref{Visibility Pragmas}). 4487 4488In C++, if a template argument has limited visibility, this 4489restriction is implicitly propagated to the template instantiation. 4490Otherwise, template instantiations and specializations default to the 4491visibility of their template. 4492 4493If both the template and enclosing class have explicit visibility, the 4494visibility from the template is used. 4495 4496@item vliw 4497@cindex @code{vliw} function attribute, MeP 4498On MeP, the @code{vliw} attribute tells the compiler to emit 4499instructions in VLIW mode instead of core mode. Note that this 4500attribute is not allowed unless a VLIW coprocessor has been configured 4501and enabled through command-line options. 4502 4503@item warn_unused_result 4504@cindex @code{warn_unused_result} function attribute 4505The @code{warn_unused_result} attribute causes a warning to be emitted 4506if a caller of the function with this attribute does not use its 4507return value. This is useful for functions where not checking 4508the result is either a security problem or always a bug, such as 4509@code{realloc}. 4510 4511@smallexample 4512int fn () __attribute__ ((warn_unused_result)); 4513int foo () 4514@{ 4515 if (fn () < 0) return -1; 4516 fn (); 4517 return 0; 4518@} 4519@end smallexample 4520 4521@noindent 4522results in warning on line 5. 4523 4524@item weak 4525@cindex @code{weak} function attribute 4526The @code{weak} attribute causes the declaration to be emitted as a weak 4527symbol rather than a global. This is primarily useful in defining 4528library functions that can be overridden in user code, though it can 4529also be used with non-function declarations. Weak symbols are supported 4530for ELF targets, and also for a.out targets when using the GNU assembler 4531and linker. 4532 4533@item weakref 4534@itemx weakref ("@var{target}") 4535@cindex @code{weakref} function attribute 4536The @code{weakref} attribute marks a declaration as a weak reference. 4537Without arguments, it should be accompanied by an @code{alias} attribute 4538naming the target symbol. Optionally, the @var{target} may be given as 4539an argument to @code{weakref} itself. In either case, @code{weakref} 4540implicitly marks the declaration as @code{weak}. Without a 4541@var{target}, given as an argument to @code{weakref} or to @code{alias}, 4542@code{weakref} is equivalent to @code{weak}. 4543 4544@smallexample 4545static int x() __attribute__ ((weakref ("y"))); 4546/* is equivalent to... */ 4547static int x() __attribute__ ((weak, weakref, alias ("y"))); 4548/* and to... */ 4549static int x() __attribute__ ((weakref)); 4550static int x() __attribute__ ((alias ("y"))); 4551@end smallexample 4552 4553A weak reference is an alias that does not by itself require a 4554definition to be given for the target symbol. If the target symbol is 4555only referenced through weak references, then it becomes a @code{weak} 4556undefined symbol. If it is directly referenced, however, then such 4557strong references prevail, and a definition is required for the 4558symbol, not necessarily in the same translation unit. 4559 4560The effect is equivalent to moving all references to the alias to a 4561separate translation unit, renaming the alias to the aliased symbol, 4562declaring it as weak, compiling the two separate translation units and 4563performing a reloadable link on them. 4564 4565At present, a declaration to which @code{weakref} is attached can 4566only be @code{static}. 4567 4568@end table 4569 4570You can specify multiple attributes in a declaration by separating them 4571by commas within the double parentheses or by immediately following an 4572attribute declaration with another attribute declaration. 4573 4574@cindex @code{#pragma}, reason for not using 4575@cindex pragma, reason for not using 4576Some people object to the @code{__attribute__} feature, suggesting that 4577ISO C's @code{#pragma} should be used instead. At the time 4578@code{__attribute__} was designed, there were two reasons for not doing 4579this. 4580 4581@enumerate 4582@item 4583It is impossible to generate @code{#pragma} commands from a macro. 4584 4585@item 4586There is no telling what the same @code{#pragma} might mean in another 4587compiler. 4588@end enumerate 4589 4590These two reasons applied to almost any application that might have been 4591proposed for @code{#pragma}. It was basically a mistake to use 4592@code{#pragma} for @emph{anything}. 4593 4594The ISO C99 standard includes @code{_Pragma}, which now allows pragmas 4595to be generated from macros. In addition, a @code{#pragma GCC} 4596namespace is now in use for GCC-specific pragmas. However, it has been 4597found convenient to use @code{__attribute__} to achieve a natural 4598attachment of attributes to their corresponding declarations, whereas 4599@code{#pragma GCC} is of use for constructs that do not naturally form 4600part of the grammar. @xref{Pragmas,,Pragmas Accepted by GCC}. 4601 4602@node Label Attributes 4603@section Label Attributes 4604@cindex Label Attributes 4605 4606GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for 4607details of the exact syntax for using attributes. Other attributes are 4608available for functions (@pxref{Function Attributes}), variables 4609(@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}). 4610 4611This example uses the @code{cold} label attribute to indicate the 4612@code{ErrorHandling} branch is unlikely to be taken and that the 4613@code{ErrorHandling} label is unused: 4614 4615@smallexample 4616 4617 asm goto ("some asm" : : : : NoError); 4618 4619/* This branch (the fall-through from the asm) is less commonly used */ 4620ErrorHandling: 4621 __attribute__((cold, unused)); /* Semi-colon is required here */ 4622 printf("error\n"); 4623 return 0; 4624 4625NoError: 4626 printf("no error\n"); 4627 return 1; 4628@end smallexample 4629 4630@table @code 4631@item unused 4632@cindex @code{unused} label attribute 4633This feature is intended for program-generated code that may contain 4634unused labels, but which is compiled with @option{-Wall}. It is 4635not normally appropriate to use in it human-written code, though it 4636could be useful in cases where the code that jumps to the label is 4637contained within an @code{#ifdef} conditional. 4638 4639@item hot 4640@cindex @code{hot} label attribute 4641The @code{hot} attribute on a label is used to inform the compiler that 4642the path following the label is more likely than paths that are not so 4643annotated. This attribute is used in cases where @code{__builtin_expect} 4644cannot be used, for instance with computed goto or @code{asm goto}. 4645 4646@item cold 4647@cindex @code{cold} label attribute 4648The @code{cold} attribute on labels is used to inform the compiler that 4649the path following the label is unlikely to be executed. This attribute 4650is used in cases where @code{__builtin_expect} cannot be used, for instance 4651with computed goto or @code{asm goto}. 4652 4653@end table 4654 4655@node Attribute Syntax 4656@section Attribute Syntax 4657@cindex attribute syntax 4658 4659This section describes the syntax with which @code{__attribute__} may be 4660used, and the constructs to which attribute specifiers bind, for the C 4661language. Some details may vary for C++ and Objective-C@. Because of 4662infelicities in the grammar for attributes, some forms described here 4663may not be successfully parsed in all cases. 4664 4665There are some problems with the semantics of attributes in C++. For 4666example, there are no manglings for attributes, although they may affect 4667code generation, so problems may arise when attributed types are used in 4668conjunction with templates or overloading. Similarly, @code{typeid} 4669does not distinguish between types with different attributes. Support 4670for attributes in C++ may be restricted in future to attributes on 4671declarations only, but not on nested declarators. 4672 4673@xref{Function Attributes}, for details of the semantics of attributes 4674applying to functions. @xref{Variable Attributes}, for details of the 4675semantics of attributes applying to variables. @xref{Type Attributes}, 4676for details of the semantics of attributes applying to structure, union 4677and enumerated types. 4678@xref{Label Attributes}, for details of the semantics of attributes 4679applying to labels. 4680 4681An @dfn{attribute specifier} is of the form 4682@code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list} 4683is a possibly empty comma-separated sequence of @dfn{attributes}, where 4684each attribute is one of the following: 4685 4686@itemize @bullet 4687@item 4688Empty. Empty attributes are ignored. 4689 4690@item 4691A word (which may be an identifier such as @code{unused}, or a reserved 4692word such as @code{const}). 4693 4694@item 4695A word, followed by, in parentheses, parameters for the attribute. 4696These parameters take one of the following forms: 4697 4698@itemize @bullet 4699@item 4700An identifier. For example, @code{mode} attributes use this form. 4701 4702@item 4703An identifier followed by a comma and a non-empty comma-separated list 4704of expressions. For example, @code{format} attributes use this form. 4705 4706@item 4707A possibly empty comma-separated list of expressions. For example, 4708@code{format_arg} attributes use this form with the list being a single 4709integer constant expression, and @code{alias} attributes use this form 4710with the list being a single string constant. 4711@end itemize 4712@end itemize 4713 4714An @dfn{attribute specifier list} is a sequence of one or more attribute 4715specifiers, not separated by any other tokens. 4716 4717@subsubheading Label Attributes 4718 4719In GNU C, an attribute specifier list may appear after the colon following a 4720label, other than a @code{case} or @code{default} label. GNU C++ only permits 4721attributes on labels if the attribute specifier is immediately 4722followed by a semicolon (i.e., the label applies to an empty 4723statement). If the semicolon is missing, C++ label attributes are 4724ambiguous, as it is permissible for a declaration, which could begin 4725with an attribute list, to be labelled in C++. Declarations cannot be 4726labelled in C90 or C99, so the ambiguity does not arise there. 4727 4728@subsubheading Type Attributes 4729 4730An attribute specifier list may appear as part of a @code{struct}, 4731@code{union} or @code{enum} specifier. It may go either immediately 4732after the @code{struct}, @code{union} or @code{enum} keyword, or after 4733the closing brace. The former syntax is preferred. 4734Where attribute specifiers follow the closing brace, they are considered 4735to relate to the structure, union or enumerated type defined, not to any 4736enclosing declaration the type specifier appears in, and the type 4737defined is not complete until after the attribute specifiers. 4738@c Otherwise, there would be the following problems: a shift/reduce 4739@c conflict between attributes binding the struct/union/enum and 4740@c binding to the list of specifiers/qualifiers; and "aligned" 4741@c attributes could use sizeof for the structure, but the size could be 4742@c changed later by "packed" attributes. 4743 4744 4745@subsubheading All other attributes 4746 4747Otherwise, an attribute specifier appears as part of a declaration, 4748counting declarations of unnamed parameters and type names, and relates 4749to that declaration (which may be nested in another declaration, for 4750example in the case of a parameter declaration), or to a particular declarator 4751within a declaration. Where an 4752attribute specifier is applied to a parameter declared as a function or 4753an array, it should apply to the function or array rather than the 4754pointer to which the parameter is implicitly converted, but this is not 4755yet correctly implemented. 4756 4757Any list of specifiers and qualifiers at the start of a declaration may 4758contain attribute specifiers, whether or not such a list may in that 4759context contain storage class specifiers. (Some attributes, however, 4760are essentially in the nature of storage class specifiers, and only make 4761sense where storage class specifiers may be used; for example, 4762@code{section}.) There is one necessary limitation to this syntax: the 4763first old-style parameter declaration in a function definition cannot 4764begin with an attribute specifier, because such an attribute applies to 4765the function instead by syntax described below (which, however, is not 4766yet implemented in this case). In some other cases, attribute 4767specifiers are permitted by this grammar but not yet supported by the 4768compiler. All attribute specifiers in this place relate to the 4769declaration as a whole. In the obsolescent usage where a type of 4770@code{int} is implied by the absence of type specifiers, such a list of 4771specifiers and qualifiers may be an attribute specifier list with no 4772other specifiers or qualifiers. 4773 4774At present, the first parameter in a function prototype must have some 4775type specifier that is not an attribute specifier; this resolves an 4776ambiguity in the interpretation of @code{void f(int 4777(__attribute__((foo)) x))}, but is subject to change. At present, if 4778the parentheses of a function declarator contain only attributes then 4779those attributes are ignored, rather than yielding an error or warning 4780or implying a single parameter of type int, but this is subject to 4781change. 4782 4783An attribute specifier list may appear immediately before a declarator 4784(other than the first) in a comma-separated list of declarators in a 4785declaration of more than one identifier using a single list of 4786specifiers and qualifiers. Such attribute specifiers apply 4787only to the identifier before whose declarator they appear. For 4788example, in 4789 4790@smallexample 4791__attribute__((noreturn)) void d0 (void), 4792 __attribute__((format(printf, 1, 2))) d1 (const char *, ...), 4793 d2 (void); 4794@end smallexample 4795 4796@noindent 4797the @code{noreturn} attribute applies to all the functions 4798declared; the @code{format} attribute only applies to @code{d1}. 4799 4800An attribute specifier list may appear immediately before the comma, 4801@code{=} or semicolon terminating the declaration of an identifier other 4802than a function definition. Such attribute specifiers apply 4803to the declared object or function. Where an 4804assembler name for an object or function is specified (@pxref{Asm 4805Labels}), the attribute must follow the @code{asm} 4806specification. 4807 4808An attribute specifier list may, in future, be permitted to appear after 4809the declarator in a function definition (before any old-style parameter 4810declarations or the function body). 4811 4812Attribute specifiers may be mixed with type qualifiers appearing inside 4813the @code{[]} of a parameter array declarator, in the C99 construct by 4814which such qualifiers are applied to the pointer to which the array is 4815implicitly converted. Such attribute specifiers apply to the pointer, 4816not to the array, but at present this is not implemented and they are 4817ignored. 4818 4819An attribute specifier list may appear at the start of a nested 4820declarator. At present, there are some limitations in this usage: the 4821attributes correctly apply to the declarator, but for most individual 4822attributes the semantics this implies are not implemented. 4823When attribute specifiers follow the @code{*} of a pointer 4824declarator, they may be mixed with any type qualifiers present. 4825The following describes the formal semantics of this syntax. It makes the 4826most sense if you are familiar with the formal specification of 4827declarators in the ISO C standard. 4828 4829Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T 4830D1}, where @code{T} contains declaration specifiers that specify a type 4831@var{Type} (such as @code{int}) and @code{D1} is a declarator that 4832contains an identifier @var{ident}. The type specified for @var{ident} 4833for derived declarators whose type does not include an attribute 4834specifier is as in the ISO C standard. 4835 4836If @code{D1} has the form @code{( @var{attribute-specifier-list} D )}, 4837and the declaration @code{T D} specifies the type 4838``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then 4839@code{T D1} specifies the type ``@var{derived-declarator-type-list} 4840@var{attribute-specifier-list} @var{Type}'' for @var{ident}. 4841 4842If @code{D1} has the form @code{* 4843@var{type-qualifier-and-attribute-specifier-list} D}, and the 4844declaration @code{T D} specifies the type 4845``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then 4846@code{T D1} specifies the type ``@var{derived-declarator-type-list} 4847@var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for 4848@var{ident}. 4849 4850For example, 4851 4852@smallexample 4853void (__attribute__((noreturn)) ****f) (void); 4854@end smallexample 4855 4856@noindent 4857specifies the type ``pointer to pointer to pointer to pointer to 4858non-returning function returning @code{void}''. As another example, 4859 4860@smallexample 4861char *__attribute__((aligned(8))) *f; 4862@end smallexample 4863 4864@noindent 4865specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''. 4866Note again that this does not work with most attributes; for example, 4867the usage of @samp{aligned} and @samp{noreturn} attributes given above 4868is not yet supported. 4869 4870For compatibility with existing code written for compiler versions that 4871did not implement attributes on nested declarators, some laxity is 4872allowed in the placing of attributes. If an attribute that only applies 4873to types is applied to a declaration, it is treated as applying to 4874the type of that declaration. If an attribute that only applies to 4875declarations is applied to the type of a declaration, it is treated 4876as applying to that declaration; and, for compatibility with code 4877placing the attributes immediately before the identifier declared, such 4878an attribute applied to a function return type is treated as 4879applying to the function type, and such an attribute applied to an array 4880element type is treated as applying to the array type. If an 4881attribute that only applies to function types is applied to a 4882pointer-to-function type, it is treated as applying to the pointer 4883target type; if such an attribute is applied to a function return type 4884that is not a pointer-to-function type, it is treated as applying 4885to the function type. 4886 4887@node Function Prototypes 4888@section Prototypes and Old-Style Function Definitions 4889@cindex function prototype declarations 4890@cindex old-style function definitions 4891@cindex promotion of formal parameters 4892 4893GNU C extends ISO C to allow a function prototype to override a later 4894old-style non-prototype definition. Consider the following example: 4895 4896@smallexample 4897/* @r{Use prototypes unless the compiler is old-fashioned.} */ 4898#ifdef __STDC__ 4899#define P(x) x 4900#else 4901#define P(x) () 4902#endif 4903 4904/* @r{Prototype function declaration.} */ 4905int isroot P((uid_t)); 4906 4907/* @r{Old-style function definition.} */ 4908int 4909isroot (x) /* @r{??? lossage here ???} */ 4910 uid_t x; 4911@{ 4912 return x == 0; 4913@} 4914@end smallexample 4915 4916Suppose the type @code{uid_t} happens to be @code{short}. ISO C does 4917not allow this example, because subword arguments in old-style 4918non-prototype definitions are promoted. Therefore in this example the 4919function definition's argument is really an @code{int}, which does not 4920match the prototype argument type of @code{short}. 4921 4922This restriction of ISO C makes it hard to write code that is portable 4923to traditional C compilers, because the programmer does not know 4924whether the @code{uid_t} type is @code{short}, @code{int}, or 4925@code{long}. Therefore, in cases like these GNU C allows a prototype 4926to override a later old-style definition. More precisely, in GNU C, a 4927function prototype argument type overrides the argument type specified 4928by a later old-style definition if the former type is the same as the 4929latter type before promotion. Thus in GNU C the above example is 4930equivalent to the following: 4931 4932@smallexample 4933int isroot (uid_t); 4934 4935int 4936isroot (uid_t x) 4937@{ 4938 return x == 0; 4939@} 4940@end smallexample 4941 4942@noindent 4943GNU C++ does not support old-style function definitions, so this 4944extension is irrelevant. 4945 4946@node C++ Comments 4947@section C++ Style Comments 4948@cindex @code{//} 4949@cindex C++ comments 4950@cindex comments, C++ style 4951 4952In GNU C, you may use C++ style comments, which start with @samp{//} and 4953continue until the end of the line. Many other C implementations allow 4954such comments, and they are included in the 1999 C standard. However, 4955C++ style comments are not recognized if you specify an @option{-std} 4956option specifying a version of ISO C before C99, or @option{-ansi} 4957(equivalent to @option{-std=c90}). 4958 4959@node Dollar Signs 4960@section Dollar Signs in Identifier Names 4961@cindex $ 4962@cindex dollar signs in identifier names 4963@cindex identifier names, dollar signs in 4964 4965In GNU C, you may normally use dollar signs in identifier names. 4966This is because many traditional C implementations allow such identifiers. 4967However, dollar signs in identifiers are not supported on a few target 4968machines, typically because the target assembler does not allow them. 4969 4970@node Character Escapes 4971@section The Character @key{ESC} in Constants 4972 4973You can use the sequence @samp{\e} in a string or character constant to 4974stand for the ASCII character @key{ESC}. 4975 4976@node Variable Attributes 4977@section Specifying Attributes of Variables 4978@cindex attribute of variables 4979@cindex variable attributes 4980 4981The keyword @code{__attribute__} allows you to specify special 4982attributes of variables or structure fields. This keyword is followed 4983by an attribute specification inside double parentheses. Some 4984attributes are currently defined generically for variables. 4985Other attributes are defined for variables on particular target 4986systems. Other attributes are available for functions 4987(@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for 4988types (@pxref{Type Attributes}). 4989Other front ends might define more attributes 4990(@pxref{C++ Extensions,,Extensions to the C++ Language}). 4991 4992You may also specify attributes with @samp{__} preceding and following 4993each keyword. This allows you to use them in header files without 4994being concerned about a possible macro of the same name. For example, 4995you may use @code{__aligned__} instead of @code{aligned}. 4996 4997@xref{Attribute Syntax}, for details of the exact syntax for using 4998attributes. 4999 5000@table @code 5001@cindex @code{aligned} variable attribute 5002@item aligned (@var{alignment}) 5003This attribute specifies a minimum alignment for the variable or 5004structure field, measured in bytes. For example, the declaration: 5005 5006@smallexample 5007int x __attribute__ ((aligned (16))) = 0; 5008@end smallexample 5009 5010@noindent 5011causes the compiler to allocate the global variable @code{x} on a 501216-byte boundary. On a 68040, this could be used in conjunction with 5013an @code{asm} expression to access the @code{move16} instruction which 5014requires 16-byte aligned operands. 5015 5016You can also specify the alignment of structure fields. For example, to 5017create a double-word aligned @code{int} pair, you could write: 5018 5019@smallexample 5020struct foo @{ int x[2] __attribute__ ((aligned (8))); @}; 5021@end smallexample 5022 5023@noindent 5024This is an alternative to creating a union with a @code{double} member, 5025which forces the union to be double-word aligned. 5026 5027As in the preceding examples, you can explicitly specify the alignment 5028(in bytes) that you wish the compiler to use for a given variable or 5029structure field. Alternatively, you can leave out the alignment factor 5030and just ask the compiler to align a variable or field to the 5031default alignment for the target architecture you are compiling for. 5032The default alignment is sufficient for all scalar types, but may not be 5033enough for all vector types on a target that supports vector operations. 5034The default alignment is fixed for a particular target ABI. 5035 5036GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__}, 5037which is the largest alignment ever used for any data type on the 5038target machine you are compiling for. For example, you could write: 5039 5040@smallexample 5041short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__))); 5042@end smallexample 5043 5044The compiler automatically sets the alignment for the declared 5045variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can 5046often make copy operations more efficient, because the compiler can 5047use whatever instructions copy the biggest chunks of memory when 5048performing copies to or from the variables or fields that you have 5049aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__} 5050may change depending on command-line options. 5051 5052When used on a struct, or struct member, the @code{aligned} attribute can 5053only increase the alignment; in order to decrease it, the @code{packed} 5054attribute must be specified as well. When used as part of a typedef, the 5055@code{aligned} attribute can both increase and decrease alignment, and 5056specifying the @code{packed} attribute generates a warning. 5057 5058Note that the effectiveness of @code{aligned} attributes may be limited 5059by inherent limitations in your linker. On many systems, the linker is 5060only able to arrange for variables to be aligned up to a certain maximum 5061alignment. (For some linkers, the maximum supported alignment may 5062be very very small.) If your linker is only able to align variables 5063up to a maximum of 8-byte alignment, then specifying @code{aligned(16)} 5064in an @code{__attribute__} still only provides you with 8-byte 5065alignment. See your linker documentation for further information. 5066 5067The @code{aligned} attribute can also be used for functions 5068(@pxref{Function Attributes}.) 5069 5070@item cleanup (@var{cleanup_function}) 5071@cindex @code{cleanup} variable attribute 5072The @code{cleanup} attribute runs a function when the variable goes 5073out of scope. This attribute can only be applied to auto function 5074scope variables; it may not be applied to parameters or variables 5075with static storage duration. The function must take one parameter, 5076a pointer to a type compatible with the variable. The return value 5077of the function (if any) is ignored. 5078 5079If @option{-fexceptions} is enabled, then @var{cleanup_function} 5080is run during the stack unwinding that happens during the 5081processing of the exception. Note that the @code{cleanup} attribute 5082does not allow the exception to be caught, only to perform an action. 5083It is undefined what happens if @var{cleanup_function} does not 5084return normally. 5085 5086@item common 5087@itemx nocommon 5088@cindex @code{common} variable attribute 5089@cindex @code{nocommon} variable attribute 5090@opindex fcommon 5091@opindex fno-common 5092The @code{common} attribute requests GCC to place a variable in 5093``common'' storage. The @code{nocommon} attribute requests the 5094opposite---to allocate space for it directly. 5095 5096These attributes override the default chosen by the 5097@option{-fno-common} and @option{-fcommon} flags respectively. 5098 5099@item deprecated 5100@itemx deprecated (@var{msg}) 5101@cindex @code{deprecated} variable attribute 5102The @code{deprecated} attribute results in a warning if the variable 5103is used anywhere in the source file. This is useful when identifying 5104variables that are expected to be removed in a future version of a 5105program. The warning also includes the location of the declaration 5106of the deprecated variable, to enable users to easily find further 5107information about why the variable is deprecated, or what they should 5108do instead. Note that the warning only occurs for uses: 5109 5110@smallexample 5111extern int old_var __attribute__ ((deprecated)); 5112extern int old_var; 5113int new_fn () @{ return old_var; @} 5114@end smallexample 5115 5116@noindent 5117results in a warning on line 3 but not line 2. The optional @var{msg} 5118argument, which must be a string, is printed in the warning if 5119present. 5120 5121The @code{deprecated} attribute can also be used for functions and 5122types (@pxref{Function Attributes}, @pxref{Type Attributes}.) 5123 5124@item mode (@var{mode}) 5125@cindex @code{mode} variable attribute 5126This attribute specifies the data type for the declaration---whichever 5127type corresponds to the mode @var{mode}. This in effect lets you 5128request an integer or floating-point type according to its width. 5129 5130You may also specify a mode of @code{byte} or @code{__byte__} to 5131indicate the mode corresponding to a one-byte integer, @code{word} or 5132@code{__word__} for the mode of a one-word integer, and @code{pointer} 5133or @code{__pointer__} for the mode used to represent pointers. 5134 5135@item packed 5136@cindex @code{packed} variable attribute 5137The @code{packed} attribute specifies that a variable or structure field 5138should have the smallest possible alignment---one byte for a variable, 5139and one bit for a field, unless you specify a larger value with the 5140@code{aligned} attribute. 5141 5142Here is a structure in which the field @code{x} is packed, so that it 5143immediately follows @code{a}: 5144 5145@smallexample 5146struct foo 5147@{ 5148 char a; 5149 int x[2] __attribute__ ((packed)); 5150@}; 5151@end smallexample 5152 5153@emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the 5154@code{packed} attribute on bit-fields of type @code{char}. This has 5155been fixed in GCC 4.4 but the change can lead to differences in the 5156structure layout. See the documentation of 5157@option{-Wpacked-bitfield-compat} for more information. 5158 5159@item section ("@var{section-name}") 5160@cindex @code{section} variable attribute 5161Normally, the compiler places the objects it generates in sections like 5162@code{data} and @code{bss}. Sometimes, however, you need additional sections, 5163or you need certain particular variables to appear in special sections, 5164for example to map to special hardware. The @code{section} 5165attribute specifies that a variable (or function) lives in a particular 5166section. For example, this small program uses several specific section names: 5167 5168@smallexample 5169struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @}; 5170struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @}; 5171char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @}; 5172int init_data __attribute__ ((section ("INITDATA"))); 5173 5174main() 5175@{ 5176 /* @r{Initialize stack pointer} */ 5177 init_sp (stack + sizeof (stack)); 5178 5179 /* @r{Initialize initialized data} */ 5180 memcpy (&init_data, &data, &edata - &data); 5181 5182 /* @r{Turn on the serial ports} */ 5183 init_duart (&a); 5184 init_duart (&b); 5185@} 5186@end smallexample 5187 5188@noindent 5189Use the @code{section} attribute with 5190@emph{global} variables and not @emph{local} variables, 5191as shown in the example. 5192 5193You may use the @code{section} attribute with initialized or 5194uninitialized global variables but the linker requires 5195each object be defined once, with the exception that uninitialized 5196variables tentatively go in the @code{common} (or @code{bss}) section 5197and can be multiply ``defined''. Using the @code{section} attribute 5198changes what section the variable goes into and may cause the 5199linker to issue an error if an uninitialized variable has multiple 5200definitions. You can force a variable to be initialized with the 5201@option{-fno-common} flag or the @code{nocommon} attribute. 5202 5203Some file formats do not support arbitrary sections so the @code{section} 5204attribute is not available on all platforms. 5205If you need to map the entire contents of a module to a particular 5206section, consider using the facilities of the linker instead. 5207 5208@item shared 5209@cindex @code{shared} variable attribute 5210On Microsoft Windows, in addition to putting variable definitions in a named 5211section, the section can also be shared among all running copies of an 5212executable or DLL@. For example, this small program defines shared data 5213by putting it in a named section @code{shared} and marking the section 5214shareable: 5215 5216@smallexample 5217int foo __attribute__((section ("shared"), shared)) = 0; 5218 5219int 5220main() 5221@{ 5222 /* @r{Read and write foo. All running 5223 copies see the same value.} */ 5224 return 0; 5225@} 5226@end smallexample 5227 5228@noindent 5229You may only use the @code{shared} attribute along with @code{section} 5230attribute with a fully-initialized global definition because of the way 5231linkers work. See @code{section} attribute for more information. 5232 5233The @code{shared} attribute is only available on Microsoft Windows@. 5234 5235@item tls_model ("@var{tls_model}") 5236@cindex @code{tls_model} variable attribute 5237The @code{tls_model} attribute sets thread-local storage model 5238(@pxref{Thread-Local}) of a particular @code{__thread} variable, 5239overriding @option{-ftls-model=} command-line switch on a per-variable 5240basis. 5241The @var{tls_model} argument should be one of @code{global-dynamic}, 5242@code{local-dynamic}, @code{initial-exec} or @code{local-exec}. 5243 5244Not all targets support this attribute. 5245 5246@item unused 5247@cindex @code{unused} variable attribute 5248This attribute, attached to a variable, means that the variable is meant 5249to be possibly unused. GCC does not produce a warning for this 5250variable. 5251 5252@item used 5253@cindex @code{used} variable attribute 5254This attribute, attached to a variable with static storage, means that 5255the variable must be emitted even if it appears that the variable is not 5256referenced. 5257 5258When applied to a static data member of a C++ class template, the 5259attribute also means that the member is instantiated if the 5260class itself is instantiated. 5261 5262@item vector_size (@var{bytes}) 5263@cindex @code{vector_size} variable attribute 5264This attribute specifies the vector size for the variable, measured in 5265bytes. For example, the declaration: 5266 5267@smallexample 5268int foo __attribute__ ((vector_size (16))); 5269@end smallexample 5270 5271@noindent 5272causes the compiler to set the mode for @code{foo}, to be 16 bytes, 5273divided into @code{int} sized units. Assuming a 32-bit int (a vector of 52744 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@. 5275 5276This attribute is only applicable to integral and float scalars, 5277although arrays, pointers, and function return values are allowed in 5278conjunction with this construct. 5279 5280Aggregates with this attribute are invalid, even if they are of the same 5281size as a corresponding scalar. For example, the declaration: 5282 5283@smallexample 5284struct S @{ int a; @}; 5285struct S __attribute__ ((vector_size (16))) foo; 5286@end smallexample 5287 5288@noindent 5289is invalid even if the size of the structure is the same as the size of 5290the @code{int}. 5291 5292@item selectany 5293@cindex @code{selectany} variable attribute 5294The @code{selectany} attribute causes an initialized global variable to 5295have link-once semantics. When multiple definitions of the variable are 5296encountered by the linker, the first is selected and the remainder are 5297discarded. Following usage by the Microsoft compiler, the linker is told 5298@emph{not} to warn about size or content differences of the multiple 5299definitions. 5300 5301Although the primary usage of this attribute is for POD types, the 5302attribute can also be applied to global C++ objects that are initialized 5303by a constructor. In this case, the static initialization and destruction 5304code for the object is emitted in each translation defining the object, 5305but the calls to the constructor and destructor are protected by a 5306link-once guard variable. 5307 5308The @code{selectany} attribute is only available on Microsoft Windows 5309targets. You can use @code{__declspec (selectany)} as a synonym for 5310@code{__attribute__ ((selectany))} for compatibility with other 5311compilers. 5312 5313@item weak 5314@cindex @code{weak} variable attribute 5315The @code{weak} attribute is described in @ref{Function Attributes}. 5316 5317@item dllimport 5318@cindex @code{dllimport} variable attribute 5319The @code{dllimport} attribute is described in @ref{Function Attributes}. 5320 5321@item dllexport 5322@cindex @code{dllexport} variable attribute 5323The @code{dllexport} attribute is described in @ref{Function Attributes}. 5324 5325@end table 5326 5327@anchor{AVR Variable Attributes} 5328@subsection AVR Variable Attributes 5329 5330@table @code 5331@item progmem 5332@cindex @code{progmem} variable attribute, AVR 5333The @code{progmem} attribute is used on the AVR to place read-only 5334data in the non-volatile program memory (flash). The @code{progmem} 5335attribute accomplishes this by putting respective variables into a 5336section whose name starts with @code{.progmem}. 5337 5338This attribute works similar to the @code{section} attribute 5339but adds additional checking. Notice that just like the 5340@code{section} attribute, @code{progmem} affects the location 5341of the data but not how this data is accessed. 5342 5343In order to read data located with the @code{progmem} attribute 5344(inline) assembler must be used. 5345@smallexample 5346/* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */ 5347#include <avr/pgmspace.h> 5348 5349/* Locate var in flash memory */ 5350const int var[2] PROGMEM = @{ 1, 2 @}; 5351 5352int read_var (int i) 5353@{ 5354 /* Access var[] by accessor macro from avr/pgmspace.h */ 5355 return (int) pgm_read_word (& var[i]); 5356@} 5357@end smallexample 5358 5359AVR is a Harvard architecture processor and data and read-only data 5360normally resides in the data memory (RAM). 5361 5362See also the @ref{AVR Named Address Spaces} section for 5363an alternate way to locate and access data in flash memory. 5364 5365@item io 5366@itemx io (@var{addr}) 5367@cindex @code{io} variable attribute, AVR 5368Variables with the @code{io} attribute are used to address 5369memory-mapped peripherals in the io address range. 5370If an address is specified, the variable 5371is assigned that address, and the value is interpreted as an 5372address in the data address space. 5373Example: 5374 5375@smallexample 5376volatile int porta __attribute__((io (0x22))); 5377@end smallexample 5378 5379The address specified in the address in the data address range. 5380 5381Otherwise, the variable it is not assigned an address, but the 5382compiler will still use in/out instructions where applicable, 5383assuming some other module assigns an address in the io address range. 5384Example: 5385 5386@smallexample 5387extern volatile int porta __attribute__((io)); 5388@end smallexample 5389 5390@item io_low 5391@itemx io_low (@var{addr}) 5392@cindex @code{io_low} variable attribute, AVR 5393This is like the @code{io} attribute, but additionally it informs the 5394compiler that the object lies in the lower half of the I/O area, 5395allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis} 5396instructions. 5397 5398@item address 5399@itemx address (@var{addr}) 5400@cindex @code{address} variable attribute, AVR 5401Variables with the @code{address} attribute are used to address 5402memory-mapped peripherals that may lie outside the io address range. 5403 5404@smallexample 5405volatile int porta __attribute__((address (0x600))); 5406@end smallexample 5407 5408@end table 5409 5410@subsection Blackfin Variable Attributes 5411 5412Three attributes are currently defined for the Blackfin. 5413 5414@table @code 5415@item l1_data 5416@itemx l1_data_A 5417@itemx l1_data_B 5418@cindex @code{l1_data} variable attribute, Blackfin 5419@cindex @code{l1_data_A} variable attribute, Blackfin 5420@cindex @code{l1_data_B} variable attribute, Blackfin 5421Use these attributes on the Blackfin to place the variable into L1 Data SRAM. 5422Variables with @code{l1_data} attribute are put into the specific section 5423named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into 5424the specific section named @code{.l1.data.A}. Those with @code{l1_data_B} 5425attribute are put into the specific section named @code{.l1.data.B}. 5426 5427@item l2 5428@cindex @code{l2} variable attribute, Blackfin 5429Use this attribute on the Blackfin to place the variable into L2 SRAM. 5430Variables with @code{l2} attribute are put into the specific section 5431named @code{.l2.data}. 5432@end table 5433 5434@subsection H8/300 Variable Attributes 5435 5436These variable attributes are available for H8/300 targets: 5437 5438@table @code 5439@item eightbit_data 5440@cindex @code{eightbit_data} variable attribute, H8/300 5441@cindex eight-bit data on the H8/300, H8/300H, and H8S 5442Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified 5443variable should be placed into the eight-bit data section. 5444The compiler generates more efficient code for certain operations 5445on data in the eight-bit data area. Note the eight-bit data area is limited to 5446256 bytes of data. 5447 5448You must use GAS and GLD from GNU binutils version 2.7 or later for 5449this attribute to work correctly. 5450 5451@item tiny_data 5452@cindex @code{tiny_data} variable attribute, H8/300 5453@cindex tiny data section on the H8/300H and H8S 5454Use this attribute on the H8/300H and H8S to indicate that the specified 5455variable should be placed into the tiny data section. 5456The compiler generates more efficient code for loads and stores 5457on data in the tiny data section. Note the tiny data area is limited to 5458slightly under 32KB of data. 5459 5460@end table 5461 5462@subsection IA-64 Variable Attributes 5463 5464The IA-64 back end supports the following variable attribute: 5465 5466@table @code 5467@item model (@var{model-name}) 5468@cindex @code{model} variable attribute, IA-64 5469 5470On IA-64, use this attribute to set the addressability of an object. 5471At present, the only supported identifier for @var{model-name} is 5472@code{small}, indicating addressability via ``small'' (22-bit) 5473addresses (so that their addresses can be loaded with the @code{addl} 5474instruction). Caveat: such addressing is by definition not position 5475independent and hence this attribute must not be used for objects 5476defined by shared libraries. 5477 5478@end table 5479 5480@subsection M32R/D Variable Attributes 5481 5482One attribute is currently defined for the M32R/D@. 5483 5484@table @code 5485@item model (@var{model-name}) 5486@cindex @code{model-name} variable attribute, M32R/D 5487@cindex variable addressability on the M32R/D 5488Use this attribute on the M32R/D to set the addressability of an object. 5489The identifier @var{model-name} is one of @code{small}, @code{medium}, 5490or @code{large}, representing each of the code models. 5491 5492Small model objects live in the lower 16MB of memory (so that their 5493addresses can be loaded with the @code{ld24} instruction). 5494 5495Medium and large model objects may live anywhere in the 32-bit address space 5496(the compiler generates @code{seth/add3} instructions to load their 5497addresses). 5498@end table 5499 5500@anchor{MeP Variable Attributes} 5501@subsection MeP Variable Attributes 5502 5503The MeP target has a number of addressing modes and busses. The 5504@code{near} space spans the standard memory space's first 16 megabytes 5505(24 bits). The @code{far} space spans the entire 32-bit memory space. 5506The @code{based} space is a 128-byte region in the memory space that 5507is addressed relative to the @code{$tp} register. The @code{tiny} 5508space is a 65536-byte region relative to the @code{$gp} register. In 5509addition to these memory regions, the MeP target has a separate 16-bit 5510control bus which is specified with @code{cb} attributes. 5511 5512@table @code 5513 5514@item based 5515@cindex @code{based} variable attribute, MeP 5516Any variable with the @code{based} attribute is assigned to the 5517@code{.based} section, and is accessed with relative to the 5518@code{$tp} register. 5519 5520@item tiny 5521@cindex @code{tiny} variable attribute, MeP 5522Likewise, the @code{tiny} attribute assigned variables to the 5523@code{.tiny} section, relative to the @code{$gp} register. 5524 5525@item near 5526@cindex @code{near} variable attribute, MeP 5527Variables with the @code{near} attribute are assumed to have addresses 5528that fit in a 24-bit addressing mode. This is the default for large 5529variables (@code{-mtiny=4} is the default) but this attribute can 5530override @code{-mtiny=} for small variables, or override @code{-ml}. 5531 5532@item far 5533@cindex @code{far} variable attribute, MeP 5534Variables with the @code{far} attribute are addressed using a full 553532-bit address. Since this covers the entire memory space, this 5536allows modules to make no assumptions about where variables might be 5537stored. 5538 5539@item io 5540@cindex @code{io} variable attribute, MeP 5541@itemx io (@var{addr}) 5542Variables with the @code{io} attribute are used to address 5543memory-mapped peripherals. If an address is specified, the variable 5544is assigned that address, else it is not assigned an address (it is 5545assumed some other module assigns an address). Example: 5546 5547@smallexample 5548int timer_count __attribute__((io(0x123))); 5549@end smallexample 5550 5551@item cb 5552@itemx cb (@var{addr}) 5553@cindex @code{cb} variable attribute, MeP 5554Variables with the @code{cb} attribute are used to access the control 5555bus, using special instructions. @code{addr} indicates the control bus 5556address. Example: 5557 5558@smallexample 5559int cpu_clock __attribute__((cb(0x123))); 5560@end smallexample 5561 5562@end table 5563 5564@subsection PowerPC Variable Attributes 5565 5566Three attributes currently are defined for PowerPC configurations: 5567@code{altivec}, @code{ms_struct} and @code{gcc_struct}. 5568 5569@cindex @code{ms_struct} variable attribute, PowerPC 5570@cindex @code{gcc_struct} variable attribute, PowerPC 5571For full documentation of the struct attributes please see the 5572documentation in @ref{x86 Variable Attributes}. 5573 5574@cindex @code{altivec} variable attribute, PowerPC 5575For documentation of @code{altivec} attribute please see the 5576documentation in @ref{PowerPC Type Attributes}. 5577 5578@subsection SPU Variable Attributes 5579 5580@cindex @code{spu_vector} variable attribute, SPU 5581The SPU supports the @code{spu_vector} attribute for variables. For 5582documentation of this attribute please see the documentation in 5583@ref{SPU Type Attributes}. 5584 5585@anchor{x86 Variable Attributes} 5586@subsection x86 Variable Attributes 5587 5588Two attributes are currently defined for x86 configurations: 5589@code{ms_struct} and @code{gcc_struct}. 5590 5591@table @code 5592@item ms_struct 5593@itemx gcc_struct 5594@cindex @code{ms_struct} variable attribute, x86 5595@cindex @code{gcc_struct} variable attribute, x86 5596 5597If @code{packed} is used on a structure, or if bit-fields are used, 5598it may be that the Microsoft ABI lays out the structure differently 5599than the way GCC normally does. Particularly when moving packed 5600data between functions compiled with GCC and the native Microsoft compiler 5601(either via function call or as data in a file), it may be necessary to access 5602either format. 5603 5604Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86 5605compilers to match the native Microsoft compiler. 5606 5607The Microsoft structure layout algorithm is fairly simple with the exception 5608of the bit-field packing. 5609The padding and alignment of members of structures and whether a bit-field 5610can straddle a storage-unit boundary are determine by these rules: 5611 5612@enumerate 5613@item Structure members are stored sequentially in the order in which they are 5614declared: the first member has the lowest memory address and the last member 5615the highest. 5616 5617@item Every data object has an alignment requirement. The alignment requirement 5618for all data except structures, unions, and arrays is either the size of the 5619object or the current packing size (specified with either the 5620@code{aligned} attribute or the @code{pack} pragma), 5621whichever is less. For structures, unions, and arrays, 5622the alignment requirement is the largest alignment requirement of its members. 5623Every object is allocated an offset so that: 5624 5625@smallexample 5626offset % alignment_requirement == 0 5627@end smallexample 5628 5629@item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation 5630unit if the integral types are the same size and if the next bit-field fits 5631into the current allocation unit without crossing the boundary imposed by the 5632common alignment requirements of the bit-fields. 5633@end enumerate 5634 5635MSVC interprets zero-length bit-fields in the following ways: 5636 5637@enumerate 5638@item If a zero-length bit-field is inserted between two bit-fields that 5639are normally coalesced, the bit-fields are not coalesced. 5640 5641For example: 5642 5643@smallexample 5644struct 5645 @{ 5646 unsigned long bf_1 : 12; 5647 unsigned long : 0; 5648 unsigned long bf_2 : 12; 5649 @} t1; 5650@end smallexample 5651 5652@noindent 5653The size of @code{t1} is 8 bytes with the zero-length bit-field. If the 5654zero-length bit-field were removed, @code{t1}'s size would be 4 bytes. 5655 5656@item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the 5657alignment of the zero-length bit-field is greater than the member that follows it, 5658@code{bar}, @code{bar} is aligned as the type of the zero-length bit-field. 5659 5660For example: 5661 5662@smallexample 5663struct 5664 @{ 5665 char foo : 4; 5666 short : 0; 5667 char bar; 5668 @} t2; 5669 5670struct 5671 @{ 5672 char foo : 4; 5673 short : 0; 5674 double bar; 5675 @} t3; 5676@end smallexample 5677 5678@noindent 5679For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1. 5680Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length 5681bit-field does not affect the alignment of @code{bar} or, as a result, the size 5682of the structure. 5683 5684Taking this into account, it is important to note the following: 5685 5686@enumerate 5687@item If a zero-length bit-field follows a normal bit-field, the type of the 5688zero-length bit-field may affect the alignment of the structure as whole. For 5689example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a 5690normal bit-field, and is of type short. 5691 5692@item Even if a zero-length bit-field is not followed by a normal bit-field, it may 5693still affect the alignment of the structure: 5694 5695@smallexample 5696struct 5697 @{ 5698 char foo : 6; 5699 long : 0; 5700 @} t4; 5701@end smallexample 5702 5703@noindent 5704Here, @code{t4} takes up 4 bytes. 5705@end enumerate 5706 5707@item Zero-length bit-fields following non-bit-field members are ignored: 5708 5709@smallexample 5710struct 5711 @{ 5712 char foo; 5713 long : 0; 5714 char bar; 5715 @} t5; 5716@end smallexample 5717 5718@noindent 5719Here, @code{t5} takes up 2 bytes. 5720@end enumerate 5721@end table 5722 5723@subsection Xstormy16 Variable Attributes 5724 5725One attribute is currently defined for xstormy16 configurations: 5726@code{below100}. 5727 5728@table @code 5729@item below100 5730@cindex @code{below100} variable attribute, Xstormy16 5731 5732If a variable has the @code{below100} attribute (@code{BELOW100} is 5733allowed also), GCC places the variable in the first 0x100 bytes of 5734memory and use special opcodes to access it. Such variables are 5735placed in either the @code{.bss_below100} section or the 5736@code{.data_below100} section. 5737 5738@end table 5739 5740@node Type Attributes 5741@section Specifying Attributes of Types 5742@cindex attribute of types 5743@cindex type attributes 5744 5745The keyword @code{__attribute__} allows you to specify special 5746attributes of @code{struct} and @code{union} types when you define 5747such types. This keyword is followed by an attribute specification 5748inside double parentheses. Eight attributes are currently defined for 5749types: @code{aligned}, @code{packed}, @code{transparent_union}, 5750@code{unused}, @code{deprecated}, @code{visibility}, @code{may_alias} 5751and @code{bnd_variable_size}. Other attributes are defined for 5752functions (@pxref{Function Attributes}), labels (@pxref{Label 5753Attributes}) and for variables (@pxref{Variable Attributes}). 5754 5755You may also specify any one of these attributes with @samp{__} 5756preceding and following its keyword. This allows you to use these 5757attributes in header files without being concerned about a possible 5758macro of the same name. For example, you may use @code{__aligned__} 5759instead of @code{aligned}. 5760 5761You may specify type attributes in an enum, struct or union type 5762declaration or definition, or for other types in a @code{typedef} 5763declaration. 5764 5765For an enum, struct or union type, you may specify attributes either 5766between the enum, struct or union tag and the name of the type, or 5767just past the closing curly brace of the @emph{definition}. The 5768former syntax is preferred. 5769 5770@xref{Attribute Syntax}, for details of the exact syntax for using 5771attributes. 5772 5773@table @code 5774@cindex @code{aligned} type attribute 5775@item aligned (@var{alignment}) 5776This attribute specifies a minimum alignment (in bytes) for variables 5777of the specified type. For example, the declarations: 5778 5779@smallexample 5780struct S @{ short f[3]; @} __attribute__ ((aligned (8))); 5781typedef int more_aligned_int __attribute__ ((aligned (8))); 5782@end smallexample 5783 5784@noindent 5785force the compiler to ensure (as far as it can) that each variable whose 5786type is @code{struct S} or @code{more_aligned_int} is allocated and 5787aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all 5788variables of type @code{struct S} aligned to 8-byte boundaries allows 5789the compiler to use the @code{ldd} and @code{std} (doubleword load and 5790store) instructions when copying one variable of type @code{struct S} to 5791another, thus improving run-time efficiency. 5792 5793Note that the alignment of any given @code{struct} or @code{union} type 5794is required by the ISO C standard to be at least a perfect multiple of 5795the lowest common multiple of the alignments of all of the members of 5796the @code{struct} or @code{union} in question. This means that you @emph{can} 5797effectively adjust the alignment of a @code{struct} or @code{union} 5798type by attaching an @code{aligned} attribute to any one of the members 5799of such a type, but the notation illustrated in the example above is a 5800more obvious, intuitive, and readable way to request the compiler to 5801adjust the alignment of an entire @code{struct} or @code{union} type. 5802 5803As in the preceding example, you can explicitly specify the alignment 5804(in bytes) that you wish the compiler to use for a given @code{struct} 5805or @code{union} type. Alternatively, you can leave out the alignment factor 5806and just ask the compiler to align a type to the maximum 5807useful alignment for the target machine you are compiling for. For 5808example, you could write: 5809 5810@smallexample 5811struct S @{ short f[3]; @} __attribute__ ((aligned)); 5812@end smallexample 5813 5814Whenever you leave out the alignment factor in an @code{aligned} 5815attribute specification, the compiler automatically sets the alignment 5816for the type to the largest alignment that is ever used for any data 5817type on the target machine you are compiling for. Doing this can often 5818make copy operations more efficient, because the compiler can use 5819whatever instructions copy the biggest chunks of memory when performing 5820copies to or from the variables that have types that you have aligned 5821this way. 5822 5823In the example above, if the size of each @code{short} is 2 bytes, then 5824the size of the entire @code{struct S} type is 6 bytes. The smallest 5825power of two that is greater than or equal to that is 8, so the 5826compiler sets the alignment for the entire @code{struct S} type to 8 5827bytes. 5828 5829Note that although you can ask the compiler to select a time-efficient 5830alignment for a given type and then declare only individual stand-alone 5831objects of that type, the compiler's ability to select a time-efficient 5832alignment is primarily useful only when you plan to create arrays of 5833variables having the relevant (efficiently aligned) type. If you 5834declare or use arrays of variables of an efficiently-aligned type, then 5835it is likely that your program also does pointer arithmetic (or 5836subscripting, which amounts to the same thing) on pointers to the 5837relevant type, and the code that the compiler generates for these 5838pointer arithmetic operations is often more efficient for 5839efficiently-aligned types than for other types. 5840 5841The @code{aligned} attribute can only increase the alignment; but you 5842can decrease it by specifying @code{packed} as well. See below. 5843 5844Note that the effectiveness of @code{aligned} attributes may be limited 5845by inherent limitations in your linker. On many systems, the linker is 5846only able to arrange for variables to be aligned up to a certain maximum 5847alignment. (For some linkers, the maximum supported alignment may 5848be very very small.) If your linker is only able to align variables 5849up to a maximum of 8-byte alignment, then specifying @code{aligned(16)} 5850in an @code{__attribute__} still only provides you with 8-byte 5851alignment. See your linker documentation for further information. 5852 5853@item packed 5854@cindex @code{packed} type attribute 5855This attribute, attached to @code{struct} or @code{union} type 5856definition, specifies that each member (other than zero-width bit-fields) 5857of the structure or union is placed to minimize the memory required. When 5858attached to an @code{enum} definition, it indicates that the smallest 5859integral type should be used. 5860 5861@opindex fshort-enums 5862Specifying this attribute for @code{struct} and @code{union} types is 5863equivalent to specifying the @code{packed} attribute on each of the 5864structure or union members. Specifying the @option{-fshort-enums} 5865flag on the line is equivalent to specifying the @code{packed} 5866attribute on all @code{enum} definitions. 5867 5868In the following example @code{struct my_packed_struct}'s members are 5869packed closely together, but the internal layout of its @code{s} member 5870is not packed---to do that, @code{struct my_unpacked_struct} needs to 5871be packed too. 5872 5873@smallexample 5874struct my_unpacked_struct 5875 @{ 5876 char c; 5877 int i; 5878 @}; 5879 5880struct __attribute__ ((__packed__)) my_packed_struct 5881 @{ 5882 char c; 5883 int i; 5884 struct my_unpacked_struct s; 5885 @}; 5886@end smallexample 5887 5888You may only specify this attribute on the definition of an @code{enum}, 5889@code{struct} or @code{union}, not on a @code{typedef} that does not 5890also define the enumerated type, structure or union. 5891 5892@item transparent_union 5893@cindex @code{transparent_union} type attribute 5894 5895This attribute, attached to a @code{union} type definition, indicates 5896that any function parameter having that union type causes calls to that 5897function to be treated in a special way. 5898 5899First, the argument corresponding to a transparent union type can be of 5900any type in the union; no cast is required. Also, if the union contains 5901a pointer type, the corresponding argument can be a null pointer 5902constant or a void pointer expression; and if the union contains a void 5903pointer type, the corresponding argument can be any pointer expression. 5904If the union member type is a pointer, qualifiers like @code{const} on 5905the referenced type must be respected, just as with normal pointer 5906conversions. 5907 5908Second, the argument is passed to the function using the calling 5909conventions of the first member of the transparent union, not the calling 5910conventions of the union itself. All members of the union must have the 5911same machine representation; this is necessary for this argument passing 5912to work properly. 5913 5914Transparent unions are designed for library functions that have multiple 5915interfaces for compatibility reasons. For example, suppose the 5916@code{wait} function must accept either a value of type @code{int *} to 5917comply with POSIX, or a value of type @code{union wait *} to comply with 5918the 4.1BSD interface. If @code{wait}'s parameter were @code{void *}, 5919@code{wait} would accept both kinds of arguments, but it would also 5920accept any other pointer type and this would make argument type checking 5921less useful. Instead, @code{<sys/wait.h>} might define the interface 5922as follows: 5923 5924@smallexample 5925typedef union __attribute__ ((__transparent_union__)) 5926 @{ 5927 int *__ip; 5928 union wait *__up; 5929 @} wait_status_ptr_t; 5930 5931pid_t wait (wait_status_ptr_t); 5932@end smallexample 5933 5934@noindent 5935This interface allows either @code{int *} or @code{union wait *} 5936arguments to be passed, using the @code{int *} calling convention. 5937The program can call @code{wait} with arguments of either type: 5938 5939@smallexample 5940int w1 () @{ int w; return wait (&w); @} 5941int w2 () @{ union wait w; return wait (&w); @} 5942@end smallexample 5943 5944@noindent 5945With this interface, @code{wait}'s implementation might look like this: 5946 5947@smallexample 5948pid_t wait (wait_status_ptr_t p) 5949@{ 5950 return waitpid (-1, p.__ip, 0); 5951@} 5952@end smallexample 5953 5954@item unused 5955@cindex @code{unused} type attribute 5956When attached to a type (including a @code{union} or a @code{struct}), 5957this attribute means that variables of that type are meant to appear 5958possibly unused. GCC does not produce a warning for any variables of 5959that type, even if the variable appears to do nothing. This is often 5960the case with lock or thread classes, which are usually defined and then 5961not referenced, but contain constructors and destructors that have 5962nontrivial bookkeeping functions. 5963 5964@item deprecated 5965@itemx deprecated (@var{msg}) 5966@cindex @code{deprecated} type attribute 5967The @code{deprecated} attribute results in a warning if the type 5968is used anywhere in the source file. This is useful when identifying 5969types that are expected to be removed in a future version of a program. 5970If possible, the warning also includes the location of the declaration 5971of the deprecated type, to enable users to easily find further 5972information about why the type is deprecated, or what they should do 5973instead. Note that the warnings only occur for uses and then only 5974if the type is being applied to an identifier that itself is not being 5975declared as deprecated. 5976 5977@smallexample 5978typedef int T1 __attribute__ ((deprecated)); 5979T1 x; 5980typedef T1 T2; 5981T2 y; 5982typedef T1 T3 __attribute__ ((deprecated)); 5983T3 z __attribute__ ((deprecated)); 5984@end smallexample 5985 5986@noindent 5987results in a warning on line 2 and 3 but not lines 4, 5, or 6. No 5988warning is issued for line 4 because T2 is not explicitly 5989deprecated. Line 5 has no warning because T3 is explicitly 5990deprecated. Similarly for line 6. The optional @var{msg} 5991argument, which must be a string, is printed in the warning if 5992present. 5993 5994The @code{deprecated} attribute can also be used for functions and 5995variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.) 5996 5997@item may_alias 5998@cindex @code{may_alias} type attribute 5999Accesses through pointers to types with this attribute are not subject 6000to type-based alias analysis, but are instead assumed to be able to alias 6001any other type of objects. 6002In the context of section 6.5 paragraph 7 of the C99 standard, 6003an lvalue expression 6004dereferencing such a pointer is treated like having a character type. 6005See @option{-fstrict-aliasing} for more information on aliasing issues. 6006This extension exists to support some vector APIs, in which pointers to 6007one vector type are permitted to alias pointers to a different vector type. 6008 6009Note that an object of a type with this attribute does not have any 6010special semantics. 6011 6012Example of use: 6013 6014@smallexample 6015typedef short __attribute__((__may_alias__)) short_a; 6016 6017int 6018main (void) 6019@{ 6020 int a = 0x12345678; 6021 short_a *b = (short_a *) &a; 6022 6023 b[1] = 0; 6024 6025 if (a == 0x12345678) 6026 abort(); 6027 6028 exit(0); 6029@} 6030@end smallexample 6031 6032@noindent 6033If you replaced @code{short_a} with @code{short} in the variable 6034declaration, the above program would abort when compiled with 6035@option{-fstrict-aliasing}, which is on by default at @option{-O2} or 6036above. 6037 6038@item visibility 6039@cindex @code{visibility} type attribute 6040In C++, attribute visibility (@pxref{Function Attributes}) can also be 6041applied to class, struct, union and enum types. Unlike other type 6042attributes, the attribute must appear between the initial keyword and 6043the name of the type; it cannot appear after the body of the type. 6044 6045Note that the type visibility is applied to vague linkage entities 6046associated with the class (vtable, typeinfo node, etc.). In 6047particular, if a class is thrown as an exception in one shared object 6048and caught in another, the class must have default visibility. 6049Otherwise the two shared objects are unable to use the same 6050typeinfo node and exception handling will break. 6051 6052@item designated_init 6053@cindex @code{designated_init} type attribute 6054This attribute may only be applied to structure types. It indicates 6055that any initialization of an object of this type must use designated 6056initializers rather than positional initializers. The intent of this 6057attribute is to allow the programmer to indicate that a structure's 6058layout may change, and that therefore relying on positional 6059initialization will result in future breakage. 6060 6061GCC emits warnings based on this attribute by default; use 6062@option{-Wno-designated-init} to suppress them. 6063 6064@item bnd_variable_size 6065@cindex @code{bnd_variable_size} type attribute 6066@cindex Pointer Bounds Checker attributes 6067When applied to a structure field, this attribute tells Pointer 6068Bounds Checker that the size of this field should not be computed 6069using static type information. It may be used to mark variably-sized 6070static array fields placed at the end of a structure. 6071 6072@smallexample 6073struct S 6074@{ 6075 int size; 6076 char data[1]; 6077@} 6078S *p = (S *)malloc (sizeof(S) + 100); 6079p->data[10] = 0; //Bounds violation 6080@end smallexample 6081 6082@noindent 6083By using an attribute for the field we may avoid unwanted bound 6084violation checks: 6085 6086@smallexample 6087struct S 6088@{ 6089 int size; 6090 char data[1] __attribute__((bnd_variable_size)); 6091@} 6092S *p = (S *)malloc (sizeof(S) + 100); 6093p->data[10] = 0; //OK 6094@end smallexample 6095 6096@end table 6097 6098To specify multiple attributes, separate them by commas within the 6099double parentheses: for example, @samp{__attribute__ ((aligned (16), 6100packed))}. 6101 6102@subsection ARM Type Attributes 6103 6104@cindex @code{notshared} type attribute, ARM 6105On those ARM targets that support @code{dllimport} (such as Symbian 6106OS), you can use the @code{notshared} attribute to indicate that the 6107virtual table and other similar data for a class should not be 6108exported from a DLL@. For example: 6109 6110@smallexample 6111class __declspec(notshared) C @{ 6112public: 6113 __declspec(dllimport) C(); 6114 virtual void f(); 6115@} 6116 6117__declspec(dllexport) 6118C::C() @{@} 6119@end smallexample 6120 6121@noindent 6122In this code, @code{C::C} is exported from the current DLL, but the 6123virtual table for @code{C} is not exported. (You can use 6124@code{__attribute__} instead of @code{__declspec} if you prefer, but 6125most Symbian OS code uses @code{__declspec}.) 6126 6127@anchor{MeP Type Attributes} 6128@subsection MeP Type Attributes 6129 6130@cindex @code{based} type attribute, MeP 6131@cindex @code{tiny} type attribute, MeP 6132@cindex @code{near} type attribute, MeP 6133@cindex @code{far} type attribute, MeP 6134Many of the MeP variable attributes may be applied to types as well. 6135Specifically, the @code{based}, @code{tiny}, @code{near}, and 6136@code{far} attributes may be applied to either. The @code{io} and 6137@code{cb} attributes may not be applied to types. 6138 6139@anchor{PowerPC Type Attributes} 6140@subsection PowerPC Type Attributes 6141 6142Three attributes currently are defined for PowerPC configurations: 6143@code{altivec}, @code{ms_struct} and @code{gcc_struct}. 6144 6145@cindex @code{ms_struct} type attribute, PowerPC 6146@cindex @code{gcc_struct} type attribute, PowerPC 6147For full documentation of the @code{ms_struct} and @code{gcc_struct} 6148attributes please see the documentation in @ref{x86 Type Attributes}. 6149 6150@cindex @code{altivec} type attribute, PowerPC 6151The @code{altivec} attribute allows one to declare AltiVec vector data 6152types supported by the AltiVec Programming Interface Manual. The 6153attribute requires an argument to specify one of three vector types: 6154@code{vector__}, @code{pixel__} (always followed by unsigned short), 6155and @code{bool__} (always followed by unsigned). 6156 6157@smallexample 6158__attribute__((altivec(vector__))) 6159__attribute__((altivec(pixel__))) unsigned short 6160__attribute__((altivec(bool__))) unsigned 6161@end smallexample 6162 6163These attributes mainly are intended to support the @code{__vector}, 6164@code{__pixel}, and @code{__bool} AltiVec keywords. 6165 6166@anchor{SPU Type Attributes} 6167@subsection SPU Type Attributes 6168 6169@cindex @code{spu_vector} type attribute, SPU 6170The SPU supports the @code{spu_vector} attribute for types. This attribute 6171allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU 6172Language Extensions Specification. It is intended to support the 6173@code{__vector} keyword. 6174 6175@anchor{x86 Type Attributes} 6176@subsection x86 Type Attributes 6177 6178Two attributes are currently defined for x86 configurations: 6179@code{ms_struct} and @code{gcc_struct}. 6180 6181@table @code 6182 6183@item ms_struct 6184@itemx gcc_struct 6185@cindex @code{ms_struct} type attribute, x86 6186@cindex @code{gcc_struct} type attribute, x86 6187 6188If @code{packed} is used on a structure, or if bit-fields are used 6189it may be that the Microsoft ABI packs them differently 6190than GCC normally packs them. Particularly when moving packed 6191data between functions compiled with GCC and the native Microsoft compiler 6192(either via function call or as data in a file), it may be necessary to access 6193either format. 6194 6195Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86 6196compilers to match the native Microsoft compiler. 6197@end table 6198 6199@node Alignment 6200@section Inquiring on Alignment of Types or Variables 6201@cindex alignment 6202@cindex type alignment 6203@cindex variable alignment 6204 6205The keyword @code{__alignof__} allows you to inquire about how an object 6206is aligned, or the minimum alignment usually required by a type. Its 6207syntax is just like @code{sizeof}. 6208 6209For example, if the target machine requires a @code{double} value to be 6210aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8. 6211This is true on many RISC machines. On more traditional machine 6212designs, @code{__alignof__ (double)} is 4 or even 2. 6213 6214Some machines never actually require alignment; they allow reference to any 6215data type even at an odd address. For these machines, @code{__alignof__} 6216reports the smallest alignment that GCC gives the data type, usually as 6217mandated by the target ABI. 6218 6219If the operand of @code{__alignof__} is an lvalue rather than a type, 6220its value is the required alignment for its type, taking into account 6221any minimum alignment specified with GCC's @code{__attribute__} 6222extension (@pxref{Variable Attributes}). For example, after this 6223declaration: 6224 6225@smallexample 6226struct foo @{ int x; char y; @} foo1; 6227@end smallexample 6228 6229@noindent 6230the value of @code{__alignof__ (foo1.y)} is 1, even though its actual 6231alignment is probably 2 or 4, the same as @code{__alignof__ (int)}. 6232 6233It is an error to ask for the alignment of an incomplete type. 6234 6235 6236@node Inline 6237@section An Inline Function is As Fast As a Macro 6238@cindex inline functions 6239@cindex integrating function code 6240@cindex open coding 6241@cindex macros, inline alternative 6242 6243By declaring a function inline, you can direct GCC to make 6244calls to that function faster. One way GCC can achieve this is to 6245integrate that function's code into the code for its callers. This 6246makes execution faster by eliminating the function-call overhead; in 6247addition, if any of the actual argument values are constant, their 6248known values may permit simplifications at compile time so that not 6249all of the inline function's code needs to be included. The effect on 6250code size is less predictable; object code may be larger or smaller 6251with function inlining, depending on the particular case. You can 6252also direct GCC to try to integrate all ``simple enough'' functions 6253into their callers with the option @option{-finline-functions}. 6254 6255GCC implements three different semantics of declaring a function 6256inline. One is available with @option{-std=gnu89} or 6257@option{-fgnu89-inline} or when @code{gnu_inline} attribute is present 6258on all inline declarations, another when 6259@option{-std=c99}, @option{-std=c11}, 6260@option{-std=gnu99} or @option{-std=gnu11} 6261(without @option{-fgnu89-inline}), and the third 6262is used when compiling C++. 6263 6264To declare a function inline, use the @code{inline} keyword in its 6265declaration, like this: 6266 6267@smallexample 6268static inline int 6269inc (int *a) 6270@{ 6271 return (*a)++; 6272@} 6273@end smallexample 6274 6275If you are writing a header file to be included in ISO C90 programs, write 6276@code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}. 6277 6278The three types of inlining behave similarly in two important cases: 6279when the @code{inline} keyword is used on a @code{static} function, 6280like the example above, and when a function is first declared without 6281using the @code{inline} keyword and then is defined with 6282@code{inline}, like this: 6283 6284@smallexample 6285extern int inc (int *a); 6286inline int 6287inc (int *a) 6288@{ 6289 return (*a)++; 6290@} 6291@end smallexample 6292 6293In both of these common cases, the program behaves the same as if you 6294had not used the @code{inline} keyword, except for its speed. 6295 6296@cindex inline functions, omission of 6297@opindex fkeep-inline-functions 6298When a function is both inline and @code{static}, if all calls to the 6299function are integrated into the caller, and the function's address is 6300never used, then the function's own assembler code is never referenced. 6301In this case, GCC does not actually output assembler code for the 6302function, unless you specify the option @option{-fkeep-inline-functions}. 6303Some calls cannot be integrated for various reasons (in particular, 6304calls that precede the function's definition cannot be integrated, and 6305neither can recursive calls within the definition). If there is a 6306nonintegrated call, then the function is compiled to assembler code as 6307usual. The function must also be compiled as usual if the program 6308refers to its address, because that can't be inlined. 6309 6310@opindex Winline 6311Note that certain usages in a function definition can make it unsuitable 6312for inline substitution. Among these usages are: variadic functions, use of 6313@code{alloca}, use of variable-length data types (@pxref{Variable Length}), 6314use of computed goto (@pxref{Labels as Values}), use of nonlocal goto, 6315and nested functions (@pxref{Nested Functions}). Using @option{-Winline} 6316warns when a function marked @code{inline} could not be substituted, 6317and gives the reason for the failure. 6318 6319@cindex automatic @code{inline} for C++ member fns 6320@cindex @code{inline} automatic for C++ member fns 6321@cindex member fns, automatically @code{inline} 6322@cindex C++ member fns, automatically @code{inline} 6323@opindex fno-default-inline 6324As required by ISO C++, GCC considers member functions defined within 6325the body of a class to be marked inline even if they are 6326not explicitly declared with the @code{inline} keyword. You can 6327override this with @option{-fno-default-inline}; @pxref{C++ Dialect 6328Options,,Options Controlling C++ Dialect}. 6329 6330GCC does not inline any functions when not optimizing unless you specify 6331the @samp{always_inline} attribute for the function, like this: 6332 6333@smallexample 6334/* @r{Prototype.} */ 6335inline void foo (const char) __attribute__((always_inline)); 6336@end smallexample 6337 6338The remainder of this section is specific to GNU C90 inlining. 6339 6340@cindex non-static inline function 6341When an inline function is not @code{static}, then the compiler must assume 6342that there may be calls from other source files; since a global symbol can 6343be defined only once in any program, the function must not be defined in 6344the other source files, so the calls therein cannot be integrated. 6345Therefore, a non-@code{static} inline function is always compiled on its 6346own in the usual fashion. 6347 6348If you specify both @code{inline} and @code{extern} in the function 6349definition, then the definition is used only for inlining. In no case 6350is the function compiled on its own, not even if you refer to its 6351address explicitly. Such an address becomes an external reference, as 6352if you had only declared the function, and had not defined it. 6353 6354This combination of @code{inline} and @code{extern} has almost the 6355effect of a macro. The way to use it is to put a function definition in 6356a header file with these keywords, and put another copy of the 6357definition (lacking @code{inline} and @code{extern}) in a library file. 6358The definition in the header file causes most calls to the function 6359to be inlined. If any uses of the function remain, they refer to 6360the single copy in the library. 6361 6362@node Volatiles 6363@section When is a Volatile Object Accessed? 6364@cindex accessing volatiles 6365@cindex volatile read 6366@cindex volatile write 6367@cindex volatile access 6368 6369C has the concept of volatile objects. These are normally accessed by 6370pointers and used for accessing hardware or inter-thread 6371communication. The standard encourages compilers to refrain from 6372optimizations concerning accesses to volatile objects, but leaves it 6373implementation defined as to what constitutes a volatile access. The 6374minimum requirement is that at a sequence point all previous accesses 6375to volatile objects have stabilized and no subsequent accesses have 6376occurred. Thus an implementation is free to reorder and combine 6377volatile accesses that occur between sequence points, but cannot do 6378so for accesses across a sequence point. The use of volatile does 6379not allow you to violate the restriction on updating objects multiple 6380times between two sequence points. 6381 6382Accesses to non-volatile objects are not ordered with respect to 6383volatile accesses. You cannot use a volatile object as a memory 6384barrier to order a sequence of writes to non-volatile memory. For 6385instance: 6386 6387@smallexample 6388int *ptr = @var{something}; 6389volatile int vobj; 6390*ptr = @var{something}; 6391vobj = 1; 6392@end smallexample 6393 6394@noindent 6395Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed 6396that the write to @var{*ptr} occurs by the time the update 6397of @var{vobj} happens. If you need this guarantee, you must use 6398a stronger memory barrier such as: 6399 6400@smallexample 6401int *ptr = @var{something}; 6402volatile int vobj; 6403*ptr = @var{something}; 6404asm volatile ("" : : : "memory"); 6405vobj = 1; 6406@end smallexample 6407 6408A scalar volatile object is read when it is accessed in a void context: 6409 6410@smallexample 6411volatile int *src = @var{somevalue}; 6412*src; 6413@end smallexample 6414 6415Such expressions are rvalues, and GCC implements this as a 6416read of the volatile object being pointed to. 6417 6418Assignments are also expressions and have an rvalue. However when 6419assigning to a scalar volatile, the volatile object is not reread, 6420regardless of whether the assignment expression's rvalue is used or 6421not. If the assignment's rvalue is used, the value is that assigned 6422to the volatile object. For instance, there is no read of @var{vobj} 6423in all the following cases: 6424 6425@smallexample 6426int obj; 6427volatile int vobj; 6428vobj = @var{something}; 6429obj = vobj = @var{something}; 6430obj ? vobj = @var{onething} : vobj = @var{anotherthing}; 6431obj = (@var{something}, vobj = @var{anotherthing}); 6432@end smallexample 6433 6434If you need to read the volatile object after an assignment has 6435occurred, you must use a separate expression with an intervening 6436sequence point. 6437 6438As bit-fields are not individually addressable, volatile bit-fields may 6439be implicitly read when written to, or when adjacent bit-fields are 6440accessed. Bit-field operations may be optimized such that adjacent 6441bit-fields are only partially accessed, if they straddle a storage unit 6442boundary. For these reasons it is unwise to use volatile bit-fields to 6443access hardware. 6444 6445@node Using Assembly Language with C 6446@section How to Use Inline Assembly Language in C Code 6447@cindex @code{asm} keyword 6448@cindex assembly language in C 6449@cindex inline assembly language 6450@cindex mixing assembly language and C 6451 6452The @code{asm} keyword allows you to embed assembler instructions 6453within C code. GCC provides two forms of inline @code{asm} 6454statements. A @dfn{basic @code{asm}} statement is one with no 6455operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}} 6456statement (@pxref{Extended Asm}) includes one or more operands. 6457The extended form is preferred for mixing C and assembly language 6458within a function, but to include assembly language at 6459top level you must use basic @code{asm}. 6460 6461You can also use the @code{asm} keyword to override the assembler name 6462for a C symbol, or to place a C variable in a specific register. 6463 6464@menu 6465* Basic Asm:: Inline assembler without operands. 6466* Extended Asm:: Inline assembler with operands. 6467* Constraints:: Constraints for @code{asm} operands 6468* Asm Labels:: Specifying the assembler name to use for a C symbol. 6469* Explicit Reg Vars:: Defining variables residing in specified registers. 6470* Size of an asm:: How GCC calculates the size of an @code{asm} block. 6471@end menu 6472 6473@node Basic Asm 6474@subsection Basic Asm --- Assembler Instructions Without Operands 6475@cindex basic @code{asm} 6476@cindex assembly language in C, basic 6477 6478A basic @code{asm} statement has the following syntax: 6479 6480@example 6481asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} ) 6482@end example 6483 6484The @code{asm} keyword is a GNU extension. 6485When writing code that can be compiled with @option{-ansi} and the 6486various @option{-std} options, use @code{__asm__} instead of 6487@code{asm} (@pxref{Alternate Keywords}). 6488 6489@subsubheading Qualifiers 6490@table @code 6491@item volatile 6492The optional @code{volatile} qualifier has no effect. 6493All basic @code{asm} blocks are implicitly volatile. 6494@end table 6495 6496@subsubheading Parameters 6497@table @var 6498 6499@item AssemblerInstructions 6500This is a literal string that specifies the assembler code. The string can 6501contain any instructions recognized by the assembler, including directives. 6502GCC does not parse the assembler instructions themselves and 6503does not know what they mean or even whether they are valid assembler input. 6504 6505You may place multiple assembler instructions together in a single @code{asm} 6506string, separated by the characters normally used in assembly code for the 6507system. A combination that works in most places is a newline to break the 6508line, plus a tab character (written as @samp{\n\t}). 6509Some assemblers allow semicolons as a line separator. However, 6510note that some assembler dialects use semicolons to start a comment. 6511@end table 6512 6513@subsubheading Remarks 6514Using extended @code{asm} typically produces smaller, safer, and more 6515efficient code, and in most cases it is a better solution than basic 6516@code{asm}. However, there are two situations where only basic @code{asm} 6517can be used: 6518 6519@itemize @bullet 6520@item 6521Extended @code{asm} statements have to be inside a C 6522function, so to write inline assembly language at file scope (``top-level''), 6523outside of C functions, you must use basic @code{asm}. 6524You can use this technique to emit assembler directives, 6525define assembly language macros that can be invoked elsewhere in the file, 6526or write entire functions in assembly language. 6527 6528@item 6529Functions declared 6530with the @code{naked} attribute also require basic @code{asm} 6531(@pxref{Function Attributes}). 6532@end itemize 6533 6534Safely accessing C data and calling functions from basic @code{asm} is more 6535complex than it may appear. To access C data, it is better to use extended 6536@code{asm}. 6537 6538Do not expect a sequence of @code{asm} statements to remain perfectly 6539consecutive after compilation. If certain instructions need to remain 6540consecutive in the output, put them in a single multi-instruction @code{asm} 6541statement. Note that GCC's optimizers can move @code{asm} statements 6542relative to other code, including across jumps. 6543 6544@code{asm} statements may not perform jumps into other @code{asm} statements. 6545GCC does not know about these jumps, and therefore cannot take 6546account of them when deciding how to optimize. Jumps from @code{asm} to C 6547labels are only supported in extended @code{asm}. 6548 6549Under certain circumstances, GCC may duplicate (or remove duplicates of) your 6550assembly code when optimizing. This can lead to unexpected duplicate 6551symbol errors during compilation if your assembly code defines symbols or 6552labels. 6553 6554Since GCC does not parse the @var{AssemblerInstructions}, it has no 6555visibility of any symbols it references. This may result in GCC discarding 6556those symbols as unreferenced. 6557 6558The compiler copies the assembler instructions in a basic @code{asm} 6559verbatim to the assembly language output file, without 6560processing dialects or any of the @samp{%} operators that are available with 6561extended @code{asm}. This results in minor differences between basic 6562@code{asm} strings and extended @code{asm} templates. For example, to refer to 6563registers you might use @samp{%eax} in basic @code{asm} and 6564@samp{%%eax} in extended @code{asm}. 6565 6566On targets such as x86 that support multiple assembler dialects, 6567all basic @code{asm} blocks use the assembler dialect specified by the 6568@option{-masm} command-line option (@pxref{x86 Options}). 6569Basic @code{asm} provides no 6570mechanism to provide different assembler strings for different dialects. 6571 6572Here is an example of basic @code{asm} for i386: 6573 6574@example 6575/* Note that this code will not compile with -masm=intel */ 6576#define DebugBreak() asm("int $3") 6577@end example 6578 6579@node Extended Asm 6580@subsection Extended Asm - Assembler Instructions with C Expression Operands 6581@cindex extended @code{asm} 6582@cindex assembly language in C, extended 6583 6584With extended @code{asm} you can read and write C variables from 6585assembler and perform jumps from assembler code to C labels. 6586Extended @code{asm} syntax uses colons (@samp{:}) to delimit 6587the operand parameters after the assembler template: 6588 6589@example 6590asm @r{[}volatile@r{]} ( @var{AssemblerTemplate} 6591 : @var{OutputOperands} 6592 @r{[} : @var{InputOperands} 6593 @r{[} : @var{Clobbers} @r{]} @r{]}) 6594 6595asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate} 6596 : 6597 : @var{InputOperands} 6598 : @var{Clobbers} 6599 : @var{GotoLabels}) 6600@end example 6601 6602The @code{asm} keyword is a GNU extension. 6603When writing code that can be compiled with @option{-ansi} and the 6604various @option{-std} options, use @code{__asm__} instead of 6605@code{asm} (@pxref{Alternate Keywords}). 6606 6607@subsubheading Qualifiers 6608@table @code 6609 6610@item volatile 6611The typical use of extended @code{asm} statements is to manipulate input 6612values to produce output values. However, your @code{asm} statements may 6613also produce side effects. If so, you may need to use the @code{volatile} 6614qualifier to disable certain optimizations. @xref{Volatile}. 6615 6616@item goto 6617This qualifier informs the compiler that the @code{asm} statement may 6618perform a jump to one of the labels listed in the @var{GotoLabels}. 6619@xref{GotoLabels}. 6620@end table 6621 6622@subsubheading Parameters 6623@table @var 6624@item AssemblerTemplate 6625This is a literal string that is the template for the assembler code. It is a 6626combination of fixed text and tokens that refer to the input, output, 6627and goto parameters. @xref{AssemblerTemplate}. 6628 6629@item OutputOperands 6630A comma-separated list of the C variables modified by the instructions in the 6631@var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}. 6632 6633@item InputOperands 6634A comma-separated list of C expressions read by the instructions in the 6635@var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}. 6636 6637@item Clobbers 6638A comma-separated list of registers or other values changed by the 6639@var{AssemblerTemplate}, beyond those listed as outputs. 6640An empty list is permitted. @xref{Clobbers}. 6641 6642@item GotoLabels 6643When you are using the @code{goto} form of @code{asm}, this section contains 6644the list of all C labels to which the code in the 6645@var{AssemblerTemplate} may jump. 6646@xref{GotoLabels}. 6647 6648@code{asm} statements may not perform jumps into other @code{asm} statements, 6649only to the listed @var{GotoLabels}. 6650GCC's optimizers do not know about other jumps; therefore they cannot take 6651account of them when deciding how to optimize. 6652@end table 6653 6654The total number of input + output + goto operands is limited to 30. 6655 6656@subsubheading Remarks 6657The @code{asm} statement allows you to include assembly instructions directly 6658within C code. This may help you to maximize performance in time-sensitive 6659code or to access assembly instructions that are not readily available to C 6660programs. 6661 6662Note that extended @code{asm} statements must be inside a function. Only 6663basic @code{asm} may be outside functions (@pxref{Basic Asm}). 6664Functions declared with the @code{naked} attribute also require basic 6665@code{asm} (@pxref{Function Attributes}). 6666 6667While the uses of @code{asm} are many and varied, it may help to think of an 6668@code{asm} statement as a series of low-level instructions that convert input 6669parameters to output parameters. So a simple (if not particularly useful) 6670example for i386 using @code{asm} might look like this: 6671 6672@example 6673int src = 1; 6674int dst; 6675 6676asm ("mov %1, %0\n\t" 6677 "add $1, %0" 6678 : "=r" (dst) 6679 : "r" (src)); 6680 6681printf("%d\n", dst); 6682@end example 6683 6684This code copies @code{src} to @code{dst} and add 1 to @code{dst}. 6685 6686@anchor{Volatile} 6687@subsubsection Volatile 6688@cindex volatile @code{asm} 6689@cindex @code{asm} volatile 6690 6691GCC's optimizers sometimes discard @code{asm} statements if they determine 6692there is no need for the output variables. Also, the optimizers may move 6693code out of loops if they believe that the code will always return the same 6694result (i.e. none of its input values change between calls). Using the 6695@code{volatile} qualifier disables these optimizations. @code{asm} statements 6696that have no output operands, including @code{asm goto} statements, 6697are implicitly volatile. 6698 6699This i386 code demonstrates a case that does not use (or require) the 6700@code{volatile} qualifier. If it is performing assertion checking, this code 6701uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 6702unreferenced by any code. As a result, the optimizers can discard the 6703@code{asm} statement, which in turn removes the need for the entire 6704@code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 6705isn't needed you allow the optimizers to produce the most efficient code 6706possible. 6707 6708@example 6709void DoCheck(uint32_t dwSomeValue) 6710@{ 6711 uint32_t dwRes; 6712 6713 // Assumes dwSomeValue is not zero. 6714 asm ("bsfl %1,%0" 6715 : "=r" (dwRes) 6716 : "r" (dwSomeValue) 6717 : "cc"); 6718 6719 assert(dwRes > 3); 6720@} 6721@end example 6722 6723The next example shows a case where the optimizers can recognize that the input 6724(@code{dwSomeValue}) never changes during the execution of the function and can 6725therefore move the @code{asm} outside the loop to produce more efficient code. 6726Again, using @code{volatile} disables this type of optimization. 6727 6728@example 6729void do_print(uint32_t dwSomeValue) 6730@{ 6731 uint32_t dwRes; 6732 6733 for (uint32_t x=0; x < 5; x++) 6734 @{ 6735 // Assumes dwSomeValue is not zero. 6736 asm ("bsfl %1,%0" 6737 : "=r" (dwRes) 6738 : "r" (dwSomeValue) 6739 : "cc"); 6740 6741 printf("%u: %u %u\n", x, dwSomeValue, dwRes); 6742 @} 6743@} 6744@end example 6745 6746The following example demonstrates a case where you need to use the 6747@code{volatile} qualifier. 6748It uses the x86 @code{rdtsc} instruction, which reads 6749the computer's time-stamp counter. Without the @code{volatile} qualifier, 6750the optimizers might assume that the @code{asm} block will always return the 6751same value and therefore optimize away the second call. 6752 6753@example 6754uint64_t msr; 6755 6756asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX. 6757 "shl $32, %%rdx\n\t" // Shift the upper bits left. 6758 "or %%rdx, %0" // 'Or' in the lower bits. 6759 : "=a" (msr) 6760 : 6761 : "rdx"); 6762 6763printf("msr: %llx\n", msr); 6764 6765// Do other work... 6766 6767// Reprint the timestamp 6768asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX. 6769 "shl $32, %%rdx\n\t" // Shift the upper bits left. 6770 "or %%rdx, %0" // 'Or' in the lower bits. 6771 : "=a" (msr) 6772 : 6773 : "rdx"); 6774 6775printf("msr: %llx\n", msr); 6776@end example 6777 6778GCC's optimizers do not treat this code like the non-volatile code in the 6779earlier examples. They do not move it out of loops or omit it on the 6780assumption that the result from a previous call is still valid. 6781 6782Note that the compiler can move even volatile @code{asm} instructions relative 6783to other code, including across jump instructions. For example, on many 6784targets there is a system register that controls the rounding mode of 6785floating-point operations. Setting it with a volatile @code{asm}, as in the 6786following PowerPC example, does not work reliably. 6787 6788@example 6789asm volatile("mtfsf 255, %0" : : "f" (fpenv)); 6790sum = x + y; 6791@end example 6792 6793The compiler may move the addition back before the volatile @code{asm}. To 6794make it work as expected, add an artificial dependency to the @code{asm} by 6795referencing a variable in the subsequent code, for example: 6796 6797@example 6798asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv)); 6799sum = x + y; 6800@end example 6801 6802Under certain circumstances, GCC may duplicate (or remove duplicates of) your 6803assembly code when optimizing. This can lead to unexpected duplicate symbol 6804errors during compilation if your asm code defines symbols or labels. 6805Using @samp{%=} 6806(@pxref{AssemblerTemplate}) may help resolve this problem. 6807 6808@anchor{AssemblerTemplate} 6809@subsubsection Assembler Template 6810@cindex @code{asm} assembler template 6811 6812An assembler template is a literal string containing assembler instructions. 6813The compiler replaces tokens in the template that refer 6814to inputs, outputs, and goto labels, 6815and then outputs the resulting string to the assembler. The 6816string can contain any instructions recognized by the assembler, including 6817directives. GCC does not parse the assembler instructions 6818themselves and does not know what they mean or even whether they are valid 6819assembler input. However, it does count the statements 6820(@pxref{Size of an asm}). 6821 6822You may place multiple assembler instructions together in a single @code{asm} 6823string, separated by the characters normally used in assembly code for the 6824system. A combination that works in most places is a newline to break the 6825line, plus a tab character to move to the instruction field (written as 6826@samp{\n\t}). 6827Some assemblers allow semicolons as a line separator. However, note 6828that some assembler dialects use semicolons to start a comment. 6829 6830Do not expect a sequence of @code{asm} statements to remain perfectly 6831consecutive after compilation, even when you are using the @code{volatile} 6832qualifier. If certain instructions need to remain consecutive in the output, 6833put them in a single multi-instruction asm statement. 6834 6835Accessing data from C programs without using input/output operands (such as 6836by using global symbols directly from the assembler template) may not work as 6837expected. Similarly, calling functions directly from an assembler template 6838requires a detailed understanding of the target assembler and ABI. 6839 6840Since GCC does not parse the assembler template, 6841it has no visibility of any 6842symbols it references. This may result in GCC discarding those symbols as 6843unreferenced unless they are also listed as input, output, or goto operands. 6844 6845@subsubheading Special format strings 6846 6847In addition to the tokens described by the input, output, and goto operands, 6848these tokens have special meanings in the assembler template: 6849 6850@table @samp 6851@item %% 6852Outputs a single @samp{%} into the assembler code. 6853 6854@item %= 6855Outputs a number that is unique to each instance of the @code{asm} 6856statement in the entire compilation. This option is useful when creating local 6857labels and referring to them multiple times in a single template that 6858generates multiple assembler instructions. 6859 6860@item %@{ 6861@itemx %| 6862@itemx %@} 6863Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively) 6864into the assembler code. When unescaped, these characters have special 6865meaning to indicate multiple assembler dialects, as described below. 6866@end table 6867 6868@subsubheading Multiple assembler dialects in @code{asm} templates 6869 6870On targets such as x86, GCC supports multiple assembler dialects. 6871The @option{-masm} option controls which dialect GCC uses as its 6872default for inline assembler. The target-specific documentation for the 6873@option{-masm} option contains the list of supported dialects, as well as the 6874default dialect if the option is not specified. This information may be 6875important to understand, since assembler code that works correctly when 6876compiled using one dialect will likely fail if compiled using another. 6877@xref{x86 Options}. 6878 6879If your code needs to support multiple assembler dialects (for example, if 6880you are writing public headers that need to support a variety of compilation 6881options), use constructs of this form: 6882 6883@example 6884@{ dialect0 | dialect1 | dialect2... @} 6885@end example 6886 6887This construct outputs @code{dialect0} 6888when using dialect #0 to compile the code, 6889@code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 6890braces than the number of dialects the compiler supports, the construct 6891outputs nothing. 6892 6893For example, if an x86 compiler supports two dialects 6894(@samp{att}, @samp{intel}), an 6895assembler template such as this: 6896 6897@example 6898"bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2" 6899@end example 6900 6901@noindent 6902is equivalent to one of 6903 6904@example 6905"btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */} 6906"bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */} 6907@end example 6908 6909Using that same compiler, this code: 6910 6911@example 6912"xchg@{l@}\t@{%%@}ebx, %1" 6913@end example 6914 6915@noindent 6916corresponds to either 6917 6918@example 6919"xchgl\t%%ebx, %1" @r{/* att dialect */} 6920"xchg\tebx, %1" @r{/* intel dialect */} 6921@end example 6922 6923There is no support for nesting dialect alternatives. 6924 6925@anchor{OutputOperands} 6926@subsubsection Output Operands 6927@cindex @code{asm} output operands 6928 6929An @code{asm} statement has zero or more output operands indicating the names 6930of C variables modified by the assembler code. 6931 6932In this i386 example, @code{old} (referred to in the template string as 6933@code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 6934(@code{%2}) is an input: 6935 6936@example 6937bool old; 6938 6939__asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base. 6940 "sbb %0,%0" // Use the CF to calculate old. 6941 : "=r" (old), "+rm" (*Base) 6942 : "Ir" (Offset) 6943 : "cc"); 6944 6945return old; 6946@end example 6947 6948Operands are separated by commas. Each operand has this format: 6949 6950@example 6951@r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename}) 6952@end example 6953 6954@table @var 6955@item asmSymbolicName 6956Specifies a symbolic name for the operand. 6957Reference the name in the assembler template 6958by enclosing it in square brackets 6959(i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 6960that contains the definition. Any valid C variable name is acceptable, 6961including names already defined in the surrounding code. No two operands 6962within the same @code{asm} statement can use the same symbolic name. 6963 6964When not using an @var{asmSymbolicName}, use the (zero-based) position 6965of the operand 6966in the list of operands in the assembler template. For example if there are 6967three output operands, use @samp{%0} in the template to refer to the first, 6968@samp{%1} for the second, and @samp{%2} for the third. 6969 6970@item constraint 6971A string constant specifying constraints on the placement of the operand; 6972@xref{Constraints}, for details. 6973 6974Output constraints must begin with either @samp{=} (a variable overwriting an 6975existing value) or @samp{+} (when reading and writing). When using 6976@samp{=}, do not assume the location contains the existing value 6977on entry to the @code{asm}, except 6978when the operand is tied to an input; @pxref{InputOperands,,Input Operands}. 6979 6980After the prefix, there must be one or more additional constraints 6981(@pxref{Constraints}) that describe where the value resides. Common 6982constraints include @samp{r} for register and @samp{m} for memory. 6983When you list more than one possible location (for example, @code{"=rm"}), 6984the compiler chooses the most efficient one based on the current context. 6985If you list as many alternates as the @code{asm} statement allows, you permit 6986the optimizers to produce the best possible code. 6987If you must use a specific register, but your Machine Constraints do not 6988provide sufficient control to select the specific register you want, 6989local register variables may provide a solution (@pxref{Local Reg Vars}). 6990 6991@item cvariablename 6992Specifies a C lvalue expression to hold the output, typically a variable name. 6993The enclosing parentheses are a required part of the syntax. 6994 6995@end table 6996 6997When the compiler selects the registers to use to 6998represent the output operands, it does not use any of the clobbered registers 6999(@pxref{Clobbers}). 7000 7001Output operand expressions must be lvalues. The compiler cannot check whether 7002the operands have data types that are reasonable for the instruction being 7003executed. For output expressions that are not directly addressable (for 7004example a bit-field), the constraint must allow a register. In that case, GCC 7005uses the register as the output of the @code{asm}, and then stores that 7006register into the output. 7007 7008Operands using the @samp{+} constraint modifier count as two operands 7009(that is, both as input and output) towards the total maximum of 30 operands 7010per @code{asm} statement. 7011 7012Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output 7013operands that must not overlap an input. Otherwise, 7014GCC may allocate the output operand in the same register as an unrelated 7015input operand, on the assumption that the assembler code consumes its 7016inputs before producing outputs. This assumption may be false if the assembler 7017code actually consists of more than one instruction. 7018 7019The same problem can occur if one output parameter (@var{a}) allows a register 7020constraint and another output parameter (@var{b}) allows a memory constraint. 7021The code generated by GCC to access the memory address in @var{b} can contain 7022registers which @emph{might} be shared by @var{a}, and GCC considers those 7023registers to be inputs to the asm. As above, GCC assumes that such input 7024registers are consumed before any outputs are written. This assumption may 7025result in incorrect behavior if the asm writes to @var{a} before using 7026@var{b}. Combining the @samp{&} modifier with the register constraint on @var{a} 7027ensures that modifying @var{a} does not affect the address referenced by 7028@var{b}. Otherwise, the location of @var{b} 7029is undefined if @var{a} is modified before using @var{b}. 7030 7031@code{asm} supports operand modifiers on operands (for example @samp{%k2} 7032instead of simply @samp{%2}). Typically these qualifiers are hardware 7033dependent. The list of supported modifiers for x86 is found at 7034@ref{x86Operandmodifiers,x86 Operand modifiers}. 7035 7036If the C code that follows the @code{asm} makes no use of any of the output 7037operands, use @code{volatile} for the @code{asm} statement to prevent the 7038optimizers from discarding the @code{asm} statement as unneeded 7039(see @ref{Volatile}). 7040 7041This code makes no use of the optional @var{asmSymbolicName}. Therefore it 7042references the first output operand as @code{%0} (were there a second, it 7043would be @code{%1}, etc). The number of the first input operand is one greater 7044than that of the last output operand. In this i386 example, that makes 7045@code{Mask} referenced as @code{%1}: 7046 7047@example 7048uint32_t Mask = 1234; 7049uint32_t Index; 7050 7051 asm ("bsfl %1, %0" 7052 : "=r" (Index) 7053 : "r" (Mask) 7054 : "cc"); 7055@end example 7056 7057That code overwrites the variable @code{Index} (@samp{=}), 7058placing the value in a register (@samp{r}). 7059Using the generic @samp{r} constraint instead of a constraint for a specific 7060register allows the compiler to pick the register to use, which can result 7061in more efficient code. This may not be possible if an assembler instruction 7062requires a specific register. 7063 7064The following i386 example uses the @var{asmSymbolicName} syntax. 7065It produces the 7066same result as the code above, but some may consider it more readable or more 7067maintainable since reordering index numbers is not necessary when adding or 7068removing operands. The names @code{aIndex} and @code{aMask} 7069are only used in this example to emphasize which 7070names get used where. 7071It is acceptable to reuse the names @code{Index} and @code{Mask}. 7072 7073@example 7074uint32_t Mask = 1234; 7075uint32_t Index; 7076 7077 asm ("bsfl %[aMask], %[aIndex]" 7078 : [aIndex] "=r" (Index) 7079 : [aMask] "r" (Mask) 7080 : "cc"); 7081@end example 7082 7083Here are some more examples of output operands. 7084 7085@example 7086uint32_t c = 1; 7087uint32_t d; 7088uint32_t *e = &c; 7089 7090asm ("mov %[e], %[d]" 7091 : [d] "=rm" (d) 7092 : [e] "rm" (*e)); 7093@end example 7094 7095Here, @code{d} may either be in a register or in memory. Since the compiler 7096might already have the current value of the @code{uint32_t} location 7097pointed to by @code{e} 7098in a register, you can enable it to choose the best location 7099for @code{d} by specifying both constraints. 7100 7101@anchor{InputOperands} 7102@subsubsection Input Operands 7103@cindex @code{asm} input operands 7104@cindex @code{asm} expressions 7105 7106Input operands make values from C variables and expressions available to the 7107assembly code. 7108 7109Operands are separated by commas. Each operand has this format: 7110 7111@example 7112@r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression}) 7113@end example 7114 7115@table @var 7116@item asmSymbolicName 7117Specifies a symbolic name for the operand. 7118Reference the name in the assembler template 7119by enclosing it in square brackets 7120(i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 7121that contains the definition. Any valid C variable name is acceptable, 7122including names already defined in the surrounding code. No two operands 7123within the same @code{asm} statement can use the same symbolic name. 7124 7125When not using an @var{asmSymbolicName}, use the (zero-based) position 7126of the operand 7127in the list of operands in the assembler template. For example if there are 7128two output operands and three inputs, 7129use @samp{%2} in the template to refer to the first input operand, 7130@samp{%3} for the second, and @samp{%4} for the third. 7131 7132@item constraint 7133A string constant specifying constraints on the placement of the operand; 7134@xref{Constraints}, for details. 7135 7136Input constraint strings may not begin with either @samp{=} or @samp{+}. 7137When you list more than one possible location (for example, @samp{"irm"}), 7138the compiler chooses the most efficient one based on the current context. 7139If you must use a specific register, but your Machine Constraints do not 7140provide sufficient control to select the specific register you want, 7141local register variables may provide a solution (@pxref{Local Reg Vars}). 7142 7143Input constraints can also be digits (for example, @code{"0"}). This indicates 7144that the specified input must be in the same place as the output constraint 7145at the (zero-based) index in the output constraint list. 7146When using @var{asmSymbolicName} syntax for the output operands, 7147you may use these names (enclosed in brackets @samp{[]}) instead of digits. 7148 7149@item cexpression 7150This is the C variable or expression being passed to the @code{asm} statement 7151as input. The enclosing parentheses are a required part of the syntax. 7152 7153@end table 7154 7155When the compiler selects the registers to use to represent the input 7156operands, it does not use any of the clobbered registers (@pxref{Clobbers}). 7157 7158If there are no output operands but there are input operands, place two 7159consecutive colons where the output operands would go: 7160 7161@example 7162__asm__ ("some instructions" 7163 : /* No outputs. */ 7164 : "r" (Offset / 8)); 7165@end example 7166 7167@strong{Warning:} Do @emph{not} modify the contents of input-only operands 7168(except for inputs tied to outputs). The compiler assumes that on exit from 7169the @code{asm} statement these operands contain the same values as they 7170had before executing the statement. 7171It is @emph{not} possible to use clobbers 7172to inform the compiler that the values in these inputs are changing. One 7173common work-around is to tie the changing input variable to an output variable 7174that never gets used. Note, however, that if the code that follows the 7175@code{asm} statement makes no use of any of the output operands, the GCC 7176optimizers may discard the @code{asm} statement as unneeded 7177(see @ref{Volatile}). 7178 7179@code{asm} supports operand modifiers on operands (for example @samp{%k2} 7180instead of simply @samp{%2}). Typically these qualifiers are hardware 7181dependent. The list of supported modifiers for x86 is found at 7182@ref{x86Operandmodifiers,x86 Operand modifiers}. 7183 7184In this example using the fictitious @code{combine} instruction, the 7185constraint @code{"0"} for input operand 1 says that it must occupy the same 7186location as output operand 0. Only input operands may use numbers in 7187constraints, and they must each refer to an output operand. Only a number (or 7188the symbolic assembler name) in the constraint can guarantee that one operand 7189is in the same place as another. The mere fact that @code{foo} is the value of 7190both operands is not enough to guarantee that they are in the same place in 7191the generated assembler code. 7192 7193@example 7194asm ("combine %2, %0" 7195 : "=r" (foo) 7196 : "0" (foo), "g" (bar)); 7197@end example 7198 7199Here is an example using symbolic names. 7200 7201@example 7202asm ("cmoveq %1, %2, %[result]" 7203 : [result] "=r"(result) 7204 : "r" (test), "r" (new), "[result]" (old)); 7205@end example 7206 7207@anchor{Clobbers} 7208@subsubsection Clobbers 7209@cindex @code{asm} clobbers 7210 7211While the compiler is aware of changes to entries listed in the output 7212operands, the inline @code{asm} code may modify more than just the outputs. For 7213example, calculations may require additional registers, or the processor may 7214overwrite a register as a side effect of a particular assembler instruction. 7215In order to inform the compiler of these changes, list them in the clobber 7216list. Clobber list items are either register names or the special clobbers 7217(listed below). Each clobber list item is a string constant 7218enclosed in double quotes and separated by commas. 7219 7220Clobber descriptions may not in any way overlap with an input or output 7221operand. For example, you may not have an operand describing a register class 7222with one member when listing that register in the clobber list. Variables 7223declared to live in specific registers (@pxref{Explicit Reg Vars}) and used 7224as @code{asm} input or output operands must have no part mentioned in the 7225clobber description. In particular, there is no way to specify that input 7226operands get modified without also specifying them as output operands. 7227 7228When the compiler selects which registers to use to represent input and output 7229operands, it does not use any of the clobbered registers. As a result, 7230clobbered registers are available for any use in the assembler code. 7231 7232Here is a realistic example for the VAX showing the use of clobbered 7233registers: 7234 7235@example 7236asm volatile ("movc3 %0, %1, %2" 7237 : /* No outputs. */ 7238 : "g" (from), "g" (to), "g" (count) 7239 : "r0", "r1", "r2", "r3", "r4", "r5"); 7240@end example 7241 7242Also, there are two special clobber arguments: 7243 7244@table @code 7245@item "cc" 7246The @code{"cc"} clobber indicates that the assembler code modifies the flags 7247register. On some machines, GCC represents the condition codes as a specific 7248hardware register; @code{"cc"} serves to name this register. 7249On other machines, condition code handling is different, 7250and specifying @code{"cc"} has no effect. But 7251it is valid no matter what the target. 7252 7253@item "memory" 7254The @code{"memory"} clobber tells the compiler that the assembly code 7255performs memory 7256reads or writes to items other than those listed in the input and output 7257operands (for example, accessing the memory pointed to by one of the input 7258parameters). To ensure memory contains correct values, GCC may need to flush 7259specific register values to memory before executing the @code{asm}. Further, 7260the compiler does not assume that any values read from memory before an 7261@code{asm} remain unchanged after that @code{asm}; it reloads them as 7262needed. 7263Using the @code{"memory"} clobber effectively forms a read/write 7264memory barrier for the compiler. 7265 7266Note that this clobber does not prevent the @emph{processor} from doing 7267speculative reads past the @code{asm} statement. To prevent that, you need 7268processor-specific fence instructions. 7269 7270Flushing registers to memory has performance implications and may be an issue 7271for time-sensitive code. You can use a trick to avoid this if the size of 7272the memory being accessed is known at compile time. For example, if accessing 7273ten bytes of a string, use a memory input like: 7274 7275@code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}. 7276 7277@end table 7278 7279@anchor{GotoLabels} 7280@subsubsection Goto Labels 7281@cindex @code{asm} goto labels 7282 7283@code{asm goto} allows assembly code to jump to one or more C labels. The 7284@var{GotoLabels} section in an @code{asm goto} statement contains 7285a comma-separated 7286list of all C labels to which the assembler code may jump. GCC assumes that 7287@code{asm} execution falls through to the next statement (if this is not the 7288case, consider using the @code{__builtin_unreachable} intrinsic after the 7289@code{asm} statement). Optimization of @code{asm goto} may be improved by 7290using the @code{hot} and @code{cold} label attributes (@pxref{Label 7291Attributes}). 7292 7293An @code{asm goto} statement cannot have outputs. 7294This is due to an internal restriction of 7295the compiler: control transfer instructions cannot have outputs. 7296If the assembler code does modify anything, use the @code{"memory"} clobber 7297to force the 7298optimizers to flush all register values to memory and reload them if 7299necessary after the @code{asm} statement. 7300 7301Also note that an @code{asm goto} statement is always implicitly 7302considered volatile. 7303 7304To reference a label in the assembler template, 7305prefix it with @samp{%l} (lowercase @samp{L}) followed 7306by its (zero-based) position in @var{GotoLabels} plus the number of input 7307operands. For example, if the @code{asm} has three inputs and references two 7308labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}). 7309 7310Alternately, you can reference labels using the actual C label name enclosed 7311in brackets. For example, to reference a label named @code{carry}, you can 7312use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels} 7313section when using this approach. 7314 7315Here is an example of @code{asm goto} for i386: 7316 7317@example 7318asm goto ( 7319 "btl %1, %0\n\t" 7320 "jc %l2" 7321 : /* No outputs. */ 7322 : "r" (p1), "r" (p2) 7323 : "cc" 7324 : carry); 7325 7326return 0; 7327 7328carry: 7329return 1; 7330@end example 7331 7332The following example shows an @code{asm goto} that uses a memory clobber. 7333 7334@example 7335int frob(int x) 7336@{ 7337 int y; 7338 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5" 7339 : /* No outputs. */ 7340 : "r"(x), "r"(&y) 7341 : "r5", "memory" 7342 : error); 7343 return y; 7344error: 7345 return -1; 7346@} 7347@end example 7348 7349@anchor{x86Operandmodifiers} 7350@subsubsection x86 Operand Modifiers 7351 7352References to input, output, and goto operands in the assembler template 7353of extended @code{asm} statements can use 7354modifiers to affect the way the operands are formatted in 7355the code output to the assembler. For example, the 7356following code uses the @samp{h} and @samp{b} modifiers for x86: 7357 7358@example 7359uint16_t num; 7360asm volatile ("xchg %h0, %b0" : "+a" (num) ); 7361@end example 7362 7363@noindent 7364These modifiers generate this assembler code: 7365 7366@example 7367xchg %ah, %al 7368@end example 7369 7370The rest of this discussion uses the following code for illustrative purposes. 7371 7372@example 7373int main() 7374@{ 7375 int iInt = 1; 7376 7377top: 7378 7379 asm volatile goto ("some assembler instructions here" 7380 : /* No outputs. */ 7381 : "q" (iInt), "X" (sizeof(unsigned char) + 1) 7382 : /* No clobbers. */ 7383 : top); 7384@} 7385@end example 7386 7387With no modifiers, this is what the output from the operands would be for the 7388@samp{att} and @samp{intel} dialects of assembler: 7389 7390@multitable {Operand} {masm=att} {OFFSET FLAT:.L2} 7391@headitem Operand @tab masm=att @tab masm=intel 7392@item @code{%0} 7393@tab @code{%eax} 7394@tab @code{eax} 7395@item @code{%1} 7396@tab @code{$2} 7397@tab @code{2} 7398@item @code{%2} 7399@tab @code{$.L2} 7400@tab @code{OFFSET FLAT:.L2} 7401@end multitable 7402 7403The table below shows the list of supported modifiers and their effects. 7404 7405@multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel} 7406@headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel} 7407@item @code{z} 7408@tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}). 7409@tab @code{%z0} 7410@tab @code{l} 7411@tab 7412@item @code{b} 7413@tab Print the QImode name of the register. 7414@tab @code{%b0} 7415@tab @code{%al} 7416@tab @code{al} 7417@item @code{h} 7418@tab Print the QImode name for a ``high'' register. 7419@tab @code{%h0} 7420@tab @code{%ah} 7421@tab @code{ah} 7422@item @code{w} 7423@tab Print the HImode name of the register. 7424@tab @code{%w0} 7425@tab @code{%ax} 7426@tab @code{ax} 7427@item @code{k} 7428@tab Print the SImode name of the register. 7429@tab @code{%k0} 7430@tab @code{%eax} 7431@tab @code{eax} 7432@item @code{q} 7433@tab Print the DImode name of the register. 7434@tab @code{%q0} 7435@tab @code{%rax} 7436@tab @code{rax} 7437@item @code{l} 7438@tab Print the label name with no punctuation. 7439@tab @code{%l2} 7440@tab @code{.L2} 7441@tab @code{.L2} 7442@item @code{c} 7443@tab Require a constant operand and print the constant expression with no punctuation. 7444@tab @code{%c1} 7445@tab @code{2} 7446@tab @code{2} 7447@end multitable 7448 7449@anchor{x86floatingpointasmoperands} 7450@subsubsection x86 Floating-Point @code{asm} Operands 7451 7452On x86 targets, there are several rules on the usage of stack-like registers 7453in the operands of an @code{asm}. These rules apply only to the operands 7454that are stack-like registers: 7455 7456@enumerate 7457@item 7458Given a set of input registers that die in an @code{asm}, it is 7459necessary to know which are implicitly popped by the @code{asm}, and 7460which must be explicitly popped by GCC@. 7461 7462An input register that is implicitly popped by the @code{asm} must be 7463explicitly clobbered, unless it is constrained to match an 7464output operand. 7465 7466@item 7467For any input register that is implicitly popped by an @code{asm}, it is 7468necessary to know how to adjust the stack to compensate for the pop. 7469If any non-popped input is closer to the top of the reg-stack than 7470the implicitly popped register, it would not be possible to know what the 7471stack looked like---it's not clear how the rest of the stack ``slides 7472up''. 7473 7474All implicitly popped input registers must be closer to the top of 7475the reg-stack than any input that is not implicitly popped. 7476 7477It is possible that if an input dies in an @code{asm}, the compiler might 7478use the input register for an output reload. Consider this example: 7479 7480@smallexample 7481asm ("foo" : "=t" (a) : "f" (b)); 7482@end smallexample 7483 7484@noindent 7485This code says that input @code{b} is not popped by the @code{asm}, and that 7486the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one 7487deeper after the @code{asm} than it was before. But, it is possible that 7488reload may think that it can use the same register for both the input and 7489the output. 7490 7491To prevent this from happening, 7492if any input operand uses the @samp{f} constraint, all output register 7493constraints must use the @samp{&} early-clobber modifier. 7494 7495The example above is correctly written as: 7496 7497@smallexample 7498asm ("foo" : "=&t" (a) : "f" (b)); 7499@end smallexample 7500 7501@item 7502Some operands need to be in particular places on the stack. All 7503output operands fall in this category---GCC has no other way to 7504know which registers the outputs appear in unless you indicate 7505this in the constraints. 7506 7507Output operands must specifically indicate which register an output 7508appears in after an @code{asm}. @samp{=f} is not allowed: the operand 7509constraints must select a class with a single register. 7510 7511@item 7512Output operands may not be ``inserted'' between existing stack registers. 7513Since no 387 opcode uses a read/write operand, all output operands 7514are dead before the @code{asm}, and are pushed by the @code{asm}. 7515It makes no sense to push anywhere but the top of the reg-stack. 7516 7517Output operands must start at the top of the reg-stack: output 7518operands may not ``skip'' a register. 7519 7520@item 7521Some @code{asm} statements may need extra stack space for internal 7522calculations. This can be guaranteed by clobbering stack registers 7523unrelated to the inputs and outputs. 7524 7525@end enumerate 7526 7527This @code{asm} 7528takes one input, which is internally popped, and produces two outputs. 7529 7530@smallexample 7531asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp)); 7532@end smallexample 7533 7534@noindent 7535This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode, 7536and replaces them with one output. The @code{st(1)} clobber is necessary 7537for the compiler to know that @code{fyl2xp1} pops both inputs. 7538 7539@smallexample 7540asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)"); 7541@end smallexample 7542 7543@lowersections 7544@include md.texi 7545@raisesections 7546 7547@node Asm Labels 7548@subsection Controlling Names Used in Assembler Code 7549@cindex assembler names for identifiers 7550@cindex names used in assembler code 7551@cindex identifiers, names in assembler code 7552 7553You can specify the name to be used in the assembler code for a C 7554function or variable by writing the @code{asm} (or @code{__asm__}) 7555keyword after the declarator as follows: 7556 7557@smallexample 7558int foo asm ("myfoo") = 2; 7559@end smallexample 7560 7561@noindent 7562This specifies that the name to be used for the variable @code{foo} in 7563the assembler code should be @samp{myfoo} rather than the usual 7564@samp{_foo}. 7565 7566On systems where an underscore is normally prepended to the name of a C 7567function or variable, this feature allows you to define names for the 7568linker that do not start with an underscore. 7569 7570It does not make sense to use this feature with a non-static local 7571variable since such variables do not have assembler names. If you are 7572trying to put the variable in a particular register, see @ref{Explicit 7573Reg Vars}. GCC presently accepts such code with a warning, but will 7574probably be changed to issue an error, rather than a warning, in the 7575future. 7576 7577You cannot use @code{asm} in this way in a function @emph{definition}; but 7578you can get the same effect by writing a declaration for the function 7579before its definition and putting @code{asm} there, like this: 7580 7581@smallexample 7582extern func () asm ("FUNC"); 7583 7584func (x, y) 7585 int x, y; 7586/* @r{@dots{}} */ 7587@end smallexample 7588 7589It is up to you to make sure that the assembler names you choose do not 7590conflict with any other assembler symbols. Also, you must not use a 7591register name; that would produce completely invalid assembler code. GCC 7592does not as yet have the ability to store static variables in registers. 7593Perhaps that will be added. 7594 7595@node Explicit Reg Vars 7596@subsection Variables in Specified Registers 7597@cindex explicit register variables 7598@cindex variables in specified registers 7599@cindex specified registers 7600@cindex registers, global allocation 7601 7602GNU C allows you to put a few global variables into specified hardware 7603registers. You can also specify the register in which an ordinary 7604register variable should be allocated. 7605 7606@itemize @bullet 7607@item 7608Global register variables reserve registers throughout the program. 7609This may be useful in programs such as programming language 7610interpreters that have a couple of global variables that are accessed 7611very often. 7612 7613@item 7614Local register variables in specific registers do not reserve the 7615registers, except at the point where they are used as input or output 7616operands in an @code{asm} statement and the @code{asm} statement itself is 7617not deleted. The compiler's data flow analysis is capable of determining 7618where the specified registers contain live values, and where they are 7619available for other uses. Stores into local register variables may be deleted 7620when they appear to be dead according to dataflow analysis. References 7621to local register variables may be deleted or moved or simplified. 7622 7623These local variables are sometimes convenient for use with the extended 7624@code{asm} feature (@pxref{Extended Asm}), if you want to write one 7625output of the assembler instruction directly into a particular register. 7626(This works provided the register you specify fits the constraints 7627specified for that operand in the @code{asm}.) 7628@end itemize 7629 7630@menu 7631* Global Reg Vars:: 7632* Local Reg Vars:: 7633@end menu 7634 7635@node Global Reg Vars 7636@subsubsection Defining Global Register Variables 7637@cindex global register variables 7638@cindex registers, global variables in 7639 7640You can define a global register variable in GNU C like this: 7641 7642@smallexample 7643register int *foo asm ("a5"); 7644@end smallexample 7645 7646@noindent 7647Here @code{a5} is the name of the register that should be used. Choose a 7648register that is normally saved and restored by function calls on your 7649machine, so that library routines will not clobber it. 7650 7651Naturally the register name is CPU-dependent, so you need to 7652conditionalize your program according to CPU type. The register 7653@code{a5} is a good choice on a 68000 for a variable of pointer 7654type. On machines with register windows, be sure to choose a ``global'' 7655register that is not affected magically by the function call mechanism. 7656 7657In addition, different operating systems on the same CPU may differ in how they 7658name the registers; then you need additional conditionals. For 7659example, some 68000 operating systems call this register @code{%a5}. 7660 7661Eventually there may be a way of asking the compiler to choose a register 7662automatically, but first we need to figure out how it should choose and 7663how to enable you to guide the choice. No solution is evident. 7664 7665Defining a global register variable in a certain register reserves that 7666register entirely for this use, at least within the current compilation. 7667The register is not allocated for any other purpose in the functions 7668in the current compilation, and is not saved and restored by 7669these functions. Stores into this register are never deleted even if they 7670appear to be dead, but references may be deleted or moved or 7671simplified. 7672 7673It is not safe to access the global register variables from signal 7674handlers, or from more than one thread of control, because the system 7675library routines may temporarily use the register for other things (unless 7676you recompile them specially for the task at hand). 7677 7678@cindex @code{qsort}, and global register variables 7679It is not safe for one function that uses a global register variable to 7680call another such function @code{foo} by way of a third function 7681@code{lose} that is compiled without knowledge of this variable (i.e.@: in a 7682different source file in which the variable isn't declared). This is 7683because @code{lose} might save the register and put some other value there. 7684For example, you can't expect a global register variable to be available in 7685the comparison-function that you pass to @code{qsort}, since @code{qsort} 7686might have put something else in that register. (If you are prepared to 7687recompile @code{qsort} with the same global register variable, you can 7688solve this problem.) 7689 7690If you want to recompile @code{qsort} or other source files that do not 7691actually use your global register variable, so that they do not use that 7692register for any other purpose, then it suffices to specify the compiler 7693option @option{-ffixed-@var{reg}}. You need not actually add a global 7694register declaration to their source code. 7695 7696A function that can alter the value of a global register variable cannot 7697safely be called from a function compiled without this variable, because it 7698could clobber the value the caller expects to find there on return. 7699Therefore, the function that is the entry point into the part of the 7700program that uses the global register variable must explicitly save and 7701restore the value that belongs to its caller. 7702 7703@cindex register variable after @code{longjmp} 7704@cindex global register after @code{longjmp} 7705@cindex value after @code{longjmp} 7706@findex longjmp 7707@findex setjmp 7708On most machines, @code{longjmp} restores to each global register 7709variable the value it had at the time of the @code{setjmp}. On some 7710machines, however, @code{longjmp} does not change the value of global 7711register variables. To be portable, the function that called @code{setjmp} 7712should make other arrangements to save the values of the global register 7713variables, and to restore them in a @code{longjmp}. This way, the same 7714thing happens regardless of what @code{longjmp} does. 7715 7716All global register variable declarations must precede all function 7717definitions. If such a declaration could appear after function 7718definitions, the declaration would be too late to prevent the register from 7719being used for other purposes in the preceding functions. 7720 7721Global register variables may not have initial values, because an 7722executable file has no means to supply initial contents for a register. 7723 7724On the SPARC, there are reports that g3 @dots{} g7 are suitable 7725registers, but certain library functions, such as @code{getwd}, as well 7726as the subroutines for division and remainder, modify g3 and g4. g1 and 7727g2 are local temporaries. 7728 7729On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7. 7730Of course, it does not do to use more than a few of those. 7731 7732@node Local Reg Vars 7733@subsubsection Specifying Registers for Local Variables 7734@cindex local variables, specifying registers 7735@cindex specifying registers for local variables 7736@cindex registers for local variables 7737 7738You can define a local register variable with a specified register 7739like this: 7740 7741@smallexample 7742register int *foo asm ("a5"); 7743@end smallexample 7744 7745@noindent 7746Here @code{a5} is the name of the register that should be used. Note 7747that this is the same syntax used for defining global register 7748variables, but for a local variable it appears within a function. 7749 7750Naturally the register name is CPU-dependent, but this is not a 7751problem, since specific registers are most often useful with explicit 7752assembler instructions (@pxref{Extended Asm}). Both of these things 7753generally require that you conditionalize your program according to 7754CPU type. 7755 7756In addition, operating systems on one type of CPU may differ in how they 7757name the registers; then you need additional conditionals. For 7758example, some 68000 operating systems call this register @code{%a5}. 7759 7760Defining such a register variable does not reserve the register; it 7761remains available for other uses in places where flow control determines 7762the variable's value is not live. 7763 7764This option does not guarantee that GCC generates code that has 7765this variable in the register you specify at all times. You may not 7766code an explicit reference to this register in the assembler 7767instruction template part of an @code{asm} statement and assume it 7768always refers to this variable. 7769However, using the variable as an input or output operand to the @code{asm} 7770guarantees that the specified register is used for that operand. 7771@xref{Extended Asm}, for more information. 7772 7773Stores into local register variables may be deleted when they appear to be dead 7774according to dataflow analysis. References to local register variables may 7775be deleted or moved or simplified. 7776 7777As with global register variables, it is recommended that you choose a 7778register that is normally saved and restored by function calls on 7779your machine, so that library routines will not clobber it. 7780 7781Sometimes when writing inline @code{asm} code, you need to make an operand be a 7782specific register, but there's no matching constraint letter for that 7783register. To force the operand into that register, create a local variable 7784and specify the register in the variable's declaration. Then use the local 7785variable for the asm operand and specify any constraint letter that matches 7786the register: 7787 7788@smallexample 7789register int *p1 asm ("r0") = @dots{}; 7790register int *p2 asm ("r1") = @dots{}; 7791register int *result asm ("r0"); 7792asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2)); 7793@end smallexample 7794 7795@emph{Warning:} In the above example, be aware that a register (for example r0) can be 7796call-clobbered by subsequent code, including function calls and library calls 7797for arithmetic operators on other variables (for example the initialization 7798of p2). In this case, use temporary variables for expressions between the 7799register assignments: 7800 7801@smallexample 7802int t1 = @dots{}; 7803register int *p1 asm ("r0") = @dots{}; 7804register int *p2 asm ("r1") = t1; 7805register int *result asm ("r0"); 7806asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2)); 7807@end smallexample 7808 7809@node Size of an asm 7810@subsection Size of an @code{asm} 7811 7812Some targets require that GCC track the size of each instruction used 7813in order to generate correct code. Because the final length of the 7814code produced by an @code{asm} statement is only known by the 7815assembler, GCC must make an estimate as to how big it will be. It 7816does this by counting the number of instructions in the pattern of the 7817@code{asm} and multiplying that by the length of the longest 7818instruction supported by that processor. (When working out the number 7819of instructions, it assumes that any occurrence of a newline or of 7820whatever statement separator character is supported by the assembler -- 7821typically @samp{;} --- indicates the end of an instruction.) 7822 7823Normally, GCC's estimate is adequate to ensure that correct 7824code is generated, but it is possible to confuse the compiler if you use 7825pseudo instructions or assembler macros that expand into multiple real 7826instructions, or if you use assembler directives that expand to more 7827space in the object file than is needed for a single instruction. 7828If this happens then the assembler may produce a diagnostic saying that 7829a label is unreachable. 7830 7831@node Alternate Keywords 7832@section Alternate Keywords 7833@cindex alternate keywords 7834@cindex keywords, alternate 7835 7836@option{-ansi} and the various @option{-std} options disable certain 7837keywords. This causes trouble when you want to use GNU C extensions, or 7838a general-purpose header file that should be usable by all programs, 7839including ISO C programs. The keywords @code{asm}, @code{typeof} and 7840@code{inline} are not available in programs compiled with 7841@option{-ansi} or @option{-std} (although @code{inline} can be used in a 7842program compiled with @option{-std=c99} or @option{-std=c11}). The 7843ISO C99 keyword 7844@code{restrict} is only available when @option{-std=gnu99} (which will 7845eventually be the default) or @option{-std=c99} (or the equivalent 7846@option{-std=iso9899:1999}), or an option for a later standard 7847version, is used. 7848 7849The way to solve these problems is to put @samp{__} at the beginning and 7850end of each problematical keyword. For example, use @code{__asm__} 7851instead of @code{asm}, and @code{__inline__} instead of @code{inline}. 7852 7853Other C compilers won't accept these alternative keywords; if you want to 7854compile with another compiler, you can define the alternate keywords as 7855macros to replace them with the customary keywords. It looks like this: 7856 7857@smallexample 7858#ifndef __GNUC__ 7859#define __asm__ asm 7860#endif 7861@end smallexample 7862 7863@findex __extension__ 7864@opindex pedantic 7865@option{-pedantic} and other options cause warnings for many GNU C extensions. 7866You can 7867prevent such warnings within one expression by writing 7868@code{__extension__} before the expression. @code{__extension__} has no 7869effect aside from this. 7870 7871@node Incomplete Enums 7872@section Incomplete @code{enum} Types 7873 7874You can define an @code{enum} tag without specifying its possible values. 7875This results in an incomplete type, much like what you get if you write 7876@code{struct foo} without describing the elements. A later declaration 7877that does specify the possible values completes the type. 7878 7879You can't allocate variables or storage using the type while it is 7880incomplete. However, you can work with pointers to that type. 7881 7882This extension may not be very useful, but it makes the handling of 7883@code{enum} more consistent with the way @code{struct} and @code{union} 7884are handled. 7885 7886This extension is not supported by GNU C++. 7887 7888@node Function Names 7889@section Function Names as Strings 7890@cindex @code{__func__} identifier 7891@cindex @code{__FUNCTION__} identifier 7892@cindex @code{__PRETTY_FUNCTION__} identifier 7893 7894GCC provides three magic variables that hold the name of the current 7895function, as a string. The first of these is @code{__func__}, which 7896is part of the C99 standard: 7897 7898The identifier @code{__func__} is implicitly declared by the translator 7899as if, immediately following the opening brace of each function 7900definition, the declaration 7901 7902@smallexample 7903static const char __func__[] = "function-name"; 7904@end smallexample 7905 7906@noindent 7907appeared, where function-name is the name of the lexically-enclosing 7908function. This name is the unadorned name of the function. 7909 7910@code{__FUNCTION__} is another name for @code{__func__}, provided for 7911backward compatibility with old versions of GCC. 7912 7913In C, @code{__PRETTY_FUNCTION__} is yet another name for 7914@code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains 7915the type signature of the function as well as its bare name. For 7916example, this program: 7917 7918@smallexample 7919extern "C" @{ 7920extern int printf (char *, ...); 7921@} 7922 7923class a @{ 7924 public: 7925 void sub (int i) 7926 @{ 7927 printf ("__FUNCTION__ = %s\n", __FUNCTION__); 7928 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__); 7929 @} 7930@}; 7931 7932int 7933main (void) 7934@{ 7935 a ax; 7936 ax.sub (0); 7937 return 0; 7938@} 7939@end smallexample 7940 7941@noindent 7942gives this output: 7943 7944@smallexample 7945__FUNCTION__ = sub 7946__PRETTY_FUNCTION__ = void a::sub(int) 7947@end smallexample 7948 7949These identifiers are variables, not preprocessor macros, and may not 7950be used to initialize @code{char} arrays or be concatenated with other string 7951literals. 7952 7953@node Return Address 7954@section Getting the Return or Frame Address of a Function 7955 7956These functions may be used to get information about the callers of a 7957function. 7958 7959@deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level}) 7960This function returns the return address of the current function, or of 7961one of its callers. The @var{level} argument is number of frames to 7962scan up the call stack. A value of @code{0} yields the return address 7963of the current function, a value of @code{1} yields the return address 7964of the caller of the current function, and so forth. When inlining 7965the expected behavior is that the function returns the address of 7966the function that is returned to. To work around this behavior use 7967the @code{noinline} function attribute. 7968 7969The @var{level} argument must be a constant integer. 7970 7971On some machines it may be impossible to determine the return address of 7972any function other than the current one; in such cases, or when the top 7973of the stack has been reached, this function returns @code{0} or a 7974random value. In addition, @code{__builtin_frame_address} may be used 7975to determine if the top of the stack has been reached. 7976 7977Additional post-processing of the returned value may be needed, see 7978@code{__builtin_extract_return_addr}. 7979 7980This function should only be used with a nonzero argument for debugging 7981purposes. 7982@end deftypefn 7983 7984@deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr}) 7985The address as returned by @code{__builtin_return_address} may have to be fed 7986through this function to get the actual encoded address. For example, on the 798731-bit S/390 platform the highest bit has to be masked out, or on SPARC 7988platforms an offset has to be added for the true next instruction to be 7989executed. 7990 7991If no fixup is needed, this function simply passes through @var{addr}. 7992@end deftypefn 7993 7994@deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr}) 7995This function does the reverse of @code{__builtin_extract_return_addr}. 7996@end deftypefn 7997 7998@deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level}) 7999This function is similar to @code{__builtin_return_address}, but it 8000returns the address of the function frame rather than the return address 8001of the function. Calling @code{__builtin_frame_address} with a value of 8002@code{0} yields the frame address of the current function, a value of 8003@code{1} yields the frame address of the caller of the current function, 8004and so forth. 8005 8006The frame is the area on the stack that holds local variables and saved 8007registers. The frame address is normally the address of the first word 8008pushed on to the stack by the function. However, the exact definition 8009depends upon the processor and the calling convention. If the processor 8010has a dedicated frame pointer register, and the function has a frame, 8011then @code{__builtin_frame_address} returns the value of the frame 8012pointer register. 8013 8014On some machines it may be impossible to determine the frame address of 8015any function other than the current one; in such cases, or when the top 8016of the stack has been reached, this function returns @code{0} if 8017the first frame pointer is properly initialized by the startup code. 8018 8019This function should only be used with a nonzero argument for debugging 8020purposes. 8021@end deftypefn 8022 8023@node Vector Extensions 8024@section Using Vector Instructions through Built-in Functions 8025 8026On some targets, the instruction set contains SIMD vector instructions which 8027operate on multiple values contained in one large register at the same time. 8028For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used 8029this way. 8030 8031The first step in using these extensions is to provide the necessary data 8032types. This should be done using an appropriate @code{typedef}: 8033 8034@smallexample 8035typedef int v4si __attribute__ ((vector_size (16))); 8036@end smallexample 8037 8038@noindent 8039The @code{int} type specifies the base type, while the attribute specifies 8040the vector size for the variable, measured in bytes. For example, the 8041declaration above causes the compiler to set the mode for the @code{v4si} 8042type to be 16 bytes wide and divided into @code{int} sized units. For 8043a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the 8044corresponding mode of @code{foo} is @acronym{V4SI}. 8045 8046The @code{vector_size} attribute is only applicable to integral and 8047float scalars, although arrays, pointers, and function return values 8048are allowed in conjunction with this construct. Only sizes that are 8049a power of two are currently allowed. 8050 8051All the basic integer types can be used as base types, both as signed 8052and as unsigned: @code{char}, @code{short}, @code{int}, @code{long}, 8053@code{long long}. In addition, @code{float} and @code{double} can be 8054used to build floating-point vector types. 8055 8056Specifying a combination that is not valid for the current architecture 8057causes GCC to synthesize the instructions using a narrower mode. 8058For example, if you specify a variable of type @code{V4SI} and your 8059architecture does not allow for this specific SIMD type, GCC 8060produces code that uses 4 @code{SIs}. 8061 8062The types defined in this manner can be used with a subset of normal C 8063operations. Currently, GCC allows using the following operators 8064on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@. 8065 8066The operations behave like C++ @code{valarrays}. Addition is defined as 8067the addition of the corresponding elements of the operands. For 8068example, in the code below, each of the 4 elements in @var{a} is 8069added to the corresponding 4 elements in @var{b} and the resulting 8070vector is stored in @var{c}. 8071 8072@smallexample 8073typedef int v4si __attribute__ ((vector_size (16))); 8074 8075v4si a, b, c; 8076 8077c = a + b; 8078@end smallexample 8079 8080Subtraction, multiplication, division, and the logical operations 8081operate in a similar manner. Likewise, the result of using the unary 8082minus or complement operators on a vector type is a vector whose 8083elements are the negative or complemented values of the corresponding 8084elements in the operand. 8085 8086It is possible to use shifting operators @code{<<}, @code{>>} on 8087integer-type vectors. The operation is defined as following: @code{@{a0, 8088a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1, 8089@dots{}, an >> bn@}}@. Vector operands must have the same number of 8090elements. 8091 8092For convenience, it is allowed to use a binary vector operation 8093where one operand is a scalar. In that case the compiler transforms 8094the scalar operand into a vector where each element is the scalar from 8095the operation. The transformation happens only if the scalar could be 8096safely converted to the vector-element type. 8097Consider the following code. 8098 8099@smallexample 8100typedef int v4si __attribute__ ((vector_size (16))); 8101 8102v4si a, b, c; 8103long l; 8104 8105a = b + 1; /* a = b + @{1,1,1,1@}; */ 8106a = 2 * b; /* a = @{2,2,2,2@} * b; */ 8107 8108a = l + a; /* Error, cannot convert long to int. */ 8109@end smallexample 8110 8111Vectors can be subscripted as if the vector were an array with 8112the same number of elements and base type. Out of bound accesses 8113invoke undefined behavior at run time. Warnings for out of bound 8114accesses for vector subscription can be enabled with 8115@option{-Warray-bounds}. 8116 8117Vector comparison is supported with standard comparison 8118operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be 8119vector expressions of integer-type or real-type. Comparison between 8120integer-type vectors and real-type vectors are not supported. The 8121result of the comparison is a vector of the same width and number of 8122elements as the comparison operands with a signed integral element 8123type. 8124 8125Vectors are compared element-wise producing 0 when comparison is false 8126and -1 (constant of the appropriate type where all bits are set) 8127otherwise. Consider the following example. 8128 8129@smallexample 8130typedef int v4si __attribute__ ((vector_size (16))); 8131 8132v4si a = @{1,2,3,4@}; 8133v4si b = @{3,2,1,4@}; 8134v4si c; 8135 8136c = a > b; /* The result would be @{0, 0,-1, 0@} */ 8137c = a == b; /* The result would be @{0,-1, 0,-1@} */ 8138@end smallexample 8139 8140In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where 8141@code{b} and @code{c} are vectors of the same type and @code{a} is an 8142integer vector with the same number of elements of the same size as @code{b} 8143and @code{c}, computes all three arguments and creates a vector 8144@code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in 8145OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}. 8146As in the case of binary operations, this syntax is also accepted when 8147one of @code{b} or @code{c} is a scalar that is then transformed into a 8148vector. If both @code{b} and @code{c} are scalars and the type of 8149@code{true?b:c} has the same size as the element type of @code{a}, then 8150@code{b} and @code{c} are converted to a vector type whose elements have 8151this type and with the same number of elements as @code{a}. 8152 8153In C++, the logic operators @code{!, &&, ||} are available for vectors. 8154@code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to 8155@code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}. 8156For mixed operations between a scalar @code{s} and a vector @code{v}, 8157@code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is 8158short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}. 8159 8160Vector shuffling is available using functions 8161@code{__builtin_shuffle (vec, mask)} and 8162@code{__builtin_shuffle (vec0, vec1, mask)}. 8163Both functions construct a permutation of elements from one or two 8164vectors and return a vector of the same type as the input vector(s). 8165The @var{mask} is an integral vector with the same width (@var{W}) 8166and element count (@var{N}) as the output vector. 8167 8168The elements of the input vectors are numbered in memory ordering of 8169@var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The 8170elements of @var{mask} are considered modulo @var{N} in the single-operand 8171case and modulo @math{2*@var{N}} in the two-operand case. 8172 8173Consider the following example, 8174 8175@smallexample 8176typedef int v4si __attribute__ ((vector_size (16))); 8177 8178v4si a = @{1,2,3,4@}; 8179v4si b = @{5,6,7,8@}; 8180v4si mask1 = @{0,1,1,3@}; 8181v4si mask2 = @{0,4,2,5@}; 8182v4si res; 8183 8184res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */ 8185res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */ 8186@end smallexample 8187 8188Note that @code{__builtin_shuffle} is intentionally semantically 8189compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions. 8190 8191You can declare variables and use them in function calls and returns, as 8192well as in assignments and some casts. You can specify a vector type as 8193a return type for a function. Vector types can also be used as function 8194arguments. It is possible to cast from one vector type to another, 8195provided they are of the same size (in fact, you can also cast vectors 8196to and from other datatypes of the same size). 8197 8198You cannot operate between vectors of different lengths or different 8199signedness without a cast. 8200 8201@node Offsetof 8202@section Support for @code{offsetof} 8203@findex __builtin_offsetof 8204 8205GCC implements for both C and C++ a syntactic extension to implement 8206the @code{offsetof} macro. 8207 8208@smallexample 8209primary: 8210 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")" 8211 8212offsetof_member_designator: 8213 @code{identifier} 8214 | offsetof_member_designator "." @code{identifier} 8215 | offsetof_member_designator "[" @code{expr} "]" 8216@end smallexample 8217 8218This extension is sufficient such that 8219 8220@smallexample 8221#define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member}) 8222@end smallexample 8223 8224@noindent 8225is a suitable definition of the @code{offsetof} macro. In C++, @var{type} 8226may be dependent. In either case, @var{member} may consist of a single 8227identifier, or a sequence of member accesses and array references. 8228 8229@node __sync Builtins 8230@section Legacy @code{__sync} Built-in Functions for Atomic Memory Access 8231 8232The following built-in functions 8233are intended to be compatible with those described 8234in the @cite{Intel Itanium Processor-specific Application Binary Interface}, 8235section 7.4. As such, they depart from the normal GCC practice of using 8236the @samp{__builtin_} prefix, and further that they are overloaded such that 8237they work on multiple types. 8238 8239The definition given in the Intel documentation allows only for the use of 8240the types @code{int}, @code{long}, @code{long long} as well as their unsigned 8241counterparts. GCC allows any integral scalar or pointer type that is 82421, 2, 4 or 8 bytes in length. 8243 8244Not all operations are supported by all target processors. If a particular 8245operation cannot be implemented on the target processor, a warning is 8246generated and a call to an external function is generated. The external 8247function carries the same name as the built-in version, 8248with an additional suffix 8249@samp{_@var{n}} where @var{n} is the size of the data type. 8250 8251@c ??? Should we have a mechanism to suppress this warning? This is almost 8252@c useful for implementing the operation under the control of an external 8253@c mutex. 8254 8255In most cases, these built-in functions are considered a @dfn{full barrier}. 8256That is, 8257no memory operand is moved across the operation, either forward or 8258backward. Further, instructions are issued as necessary to prevent the 8259processor from speculating loads across the operation and from queuing stores 8260after the operation. 8261 8262All of the routines are described in the Intel documentation to take 8263``an optional list of variables protected by the memory barrier''. It's 8264not clear what is meant by that; it could mean that @emph{only} the 8265following variables are protected, or it could mean that these variables 8266should in addition be protected. At present GCC ignores this list and 8267protects all variables that are globally accessible. If in the future 8268we make some use of this list, an empty list will continue to mean all 8269globally accessible variables. 8270 8271@table @code 8272@item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...) 8273@itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...) 8274@itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...) 8275@itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...) 8276@itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...) 8277@itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...) 8278@findex __sync_fetch_and_add 8279@findex __sync_fetch_and_sub 8280@findex __sync_fetch_and_or 8281@findex __sync_fetch_and_and 8282@findex __sync_fetch_and_xor 8283@findex __sync_fetch_and_nand 8284These built-in functions perform the operation suggested by the name, and 8285returns the value that had previously been in memory. That is, 8286 8287@smallexample 8288@{ tmp = *ptr; *ptr @var{op}= value; return tmp; @} 8289@{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand 8290@end smallexample 8291 8292@emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand} 8293as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}. 8294 8295@item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...) 8296@itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...) 8297@itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...) 8298@itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...) 8299@itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...) 8300@itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...) 8301@findex __sync_add_and_fetch 8302@findex __sync_sub_and_fetch 8303@findex __sync_or_and_fetch 8304@findex __sync_and_and_fetch 8305@findex __sync_xor_and_fetch 8306@findex __sync_nand_and_fetch 8307These built-in functions perform the operation suggested by the name, and 8308return the new value. That is, 8309 8310@smallexample 8311@{ *ptr @var{op}= value; return *ptr; @} 8312@{ *ptr = ~(*ptr & value); return *ptr; @} // nand 8313@end smallexample 8314 8315@emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch} 8316as @code{*ptr = ~(*ptr & value)} instead of 8317@code{*ptr = ~*ptr & value}. 8318 8319@item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...) 8320@itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...) 8321@findex __sync_bool_compare_and_swap 8322@findex __sync_val_compare_and_swap 8323These built-in functions perform an atomic compare and swap. 8324That is, if the current 8325value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into 8326@code{*@var{ptr}}. 8327 8328The ``bool'' version returns true if the comparison is successful and 8329@var{newval} is written. The ``val'' version returns the contents 8330of @code{*@var{ptr}} before the operation. 8331 8332@item __sync_synchronize (...) 8333@findex __sync_synchronize 8334This built-in function issues a full memory barrier. 8335 8336@item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...) 8337@findex __sync_lock_test_and_set 8338This built-in function, as described by Intel, is not a traditional test-and-set 8339operation, but rather an atomic exchange operation. It writes @var{value} 8340into @code{*@var{ptr}}, and returns the previous contents of 8341@code{*@var{ptr}}. 8342 8343Many targets have only minimal support for such locks, and do not support 8344a full exchange operation. In this case, a target may support reduced 8345functionality here by which the @emph{only} valid value to store is the 8346immediate constant 1. The exact value actually stored in @code{*@var{ptr}} 8347is implementation defined. 8348 8349This built-in function is not a full barrier, 8350but rather an @dfn{acquire barrier}. 8351This means that references after the operation cannot move to (or be 8352speculated to) before the operation, but previous memory stores may not 8353be globally visible yet, and previous memory loads may not yet be 8354satisfied. 8355 8356@item void __sync_lock_release (@var{type} *ptr, ...) 8357@findex __sync_lock_release 8358This built-in function releases the lock acquired by 8359@code{__sync_lock_test_and_set}. 8360Normally this means writing the constant 0 to @code{*@var{ptr}}. 8361 8362This built-in function is not a full barrier, 8363but rather a @dfn{release barrier}. 8364This means that all previous memory stores are globally visible, and all 8365previous memory loads have been satisfied, but following memory reads 8366are not prevented from being speculated to before the barrier. 8367@end table 8368 8369@node __atomic Builtins 8370@section Built-in Functions for Memory Model Aware Atomic Operations 8371 8372The following built-in functions approximately match the requirements for 8373C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in 8374functions, but all also have a memory model parameter. These are all 8375identified by being prefixed with @samp{__atomic}, and most are overloaded 8376such that they work with multiple types. 8377 8378GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8 8379bytes in length. 16-byte integral types are also allowed if 8380@samp{__int128} (@pxref{__int128}) is supported by the architecture. 8381 8382Target architectures are encouraged to provide their own patterns for 8383each of these built-in functions. If no target is provided, the original 8384non-memory model set of @samp{__sync} atomic built-in functions are 8385utilized, along with any required synchronization fences surrounding it in 8386order to achieve the proper behavior. Execution in this case is subject 8387to the same restrictions as those built-in functions. 8388 8389If there is no pattern or mechanism to provide a lock free instruction 8390sequence, a call is made to an external routine with the same parameters 8391to be resolved at run time. 8392 8393The four non-arithmetic functions (load, store, exchange, and 8394compare_exchange) all have a generic version as well. This generic 8395version works on any data type. If the data type size maps to one 8396of the integral sizes that may have lock free support, the generic 8397version utilizes the lock free built-in function. Otherwise an 8398external call is left to be resolved at run time. This external call is 8399the same format with the addition of a @samp{size_t} parameter inserted 8400as the first parameter indicating the size of the object being pointed to. 8401All objects must be the same size. 8402 8403There are 6 different memory models that can be specified. These map 8404to the same names in the C++11 standard. Refer there or to the 8405@uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on 8406atomic synchronization} for more detailed definitions. These memory 8407models integrate both barriers to code motion as well as synchronization 8408requirements with other threads. These are listed in approximately 8409ascending order of strength. It is also possible to use target specific 8410flags for memory model flags, like Hardware Lock Elision. 8411 8412@table @code 8413@item __ATOMIC_RELAXED 8414No barriers or synchronization. 8415@item __ATOMIC_CONSUME 8416Data dependency only for both barrier and synchronization with another 8417thread. 8418@item __ATOMIC_ACQUIRE 8419Barrier to hoisting of code and synchronizes with release (or stronger) 8420semantic stores from another thread. 8421@item __ATOMIC_RELEASE 8422Barrier to sinking of code and synchronizes with acquire (or stronger) 8423semantic loads from another thread. 8424@item __ATOMIC_ACQ_REL 8425Full barrier in both directions and synchronizes with acquire loads and 8426release stores in another thread. 8427@item __ATOMIC_SEQ_CST 8428Full barrier in both directions and synchronizes with acquire loads and 8429release stores in all threads. 8430@end table 8431 8432When implementing patterns for these built-in functions, the memory model 8433parameter can be ignored as long as the pattern implements the most 8434restrictive @code{__ATOMIC_SEQ_CST} model. Any of the other memory models 8435execute correctly with this memory model but they may not execute as 8436efficiently as they could with a more appropriate implementation of the 8437relaxed requirements. 8438 8439Note that the C++11 standard allows for the memory model parameter to be 8440determined at run time rather than at compile time. These built-in 8441functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather 8442than invoke a runtime library call or inline a switch statement. This is 8443standard compliant, safe, and the simplest approach for now. 8444 8445The memory model parameter is a signed int, but only the lower 16 bits are 8446reserved for the memory model. The remainder of the signed int is reserved 8447for target use and should be 0. Use of the predefined atomic values 8448ensures proper usage. 8449 8450@deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel) 8451This built-in function implements an atomic load operation. It returns the 8452contents of @code{*@var{ptr}}. 8453 8454The valid memory model variants are 8455@code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE}, 8456and @code{__ATOMIC_CONSUME}. 8457 8458@end deftypefn 8459 8460@deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel) 8461This is the generic version of an atomic load. It returns the 8462contents of @code{*@var{ptr}} in @code{*@var{ret}}. 8463 8464@end deftypefn 8465 8466@deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel) 8467This built-in function implements an atomic store operation. It writes 8468@code{@var{val}} into @code{*@var{ptr}}. 8469 8470The valid memory model variants are 8471@code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}. 8472 8473@end deftypefn 8474 8475@deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel) 8476This is the generic version of an atomic store. It stores the value 8477of @code{*@var{val}} into @code{*@var{ptr}}. 8478 8479@end deftypefn 8480 8481@deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel) 8482This built-in function implements an atomic exchange operation. It writes 8483@var{val} into @code{*@var{ptr}}, and returns the previous contents of 8484@code{*@var{ptr}}. 8485 8486The valid memory model variants are 8487@code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE}, 8488@code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}. 8489 8490@end deftypefn 8491 8492@deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel) 8493This is the generic version of an atomic exchange. It stores the 8494contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value 8495of @code{*@var{ptr}} is copied into @code{*@var{ret}}. 8496 8497@end deftypefn 8498 8499@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) 8500This built-in function implements an atomic compare and exchange operation. 8501This compares the contents of @code{*@var{ptr}} with the contents of 8502@code{*@var{expected}} and if equal, writes @var{desired} into 8503@code{*@var{ptr}}. If they are not equal, the current contents of 8504@code{*@var{ptr}} is written into @code{*@var{expected}}. @var{weak} is true 8505for weak compare_exchange, and false for the strong variation. Many targets 8506only offer the strong variation and ignore the parameter. When in doubt, use 8507the strong variation. 8508 8509True is returned if @var{desired} is written into 8510@code{*@var{ptr}} and the execution is considered to conform to the 8511memory model specified by @var{success_memmodel}. There are no 8512restrictions on what memory model can be used here. 8513 8514False is returned otherwise, and the execution is considered to conform 8515to @var{failure_memmodel}. This memory model cannot be 8516@code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a 8517stronger model than that specified by @var{success_memmodel}. 8518 8519@end deftypefn 8520 8521@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) 8522This built-in function implements the generic version of 8523@code{__atomic_compare_exchange}. The function is virtually identical to 8524@code{__atomic_compare_exchange_n}, except the desired value is also a 8525pointer. 8526 8527@end deftypefn 8528 8529@deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel) 8530@deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel) 8531@deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel) 8532@deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel) 8533@deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel) 8534@deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel) 8535These built-in functions perform the operation suggested by the name, and 8536return the result of the operation. That is, 8537 8538@smallexample 8539@{ *ptr @var{op}= val; return *ptr; @} 8540@end smallexample 8541 8542All memory models are valid. 8543 8544@end deftypefn 8545 8546@deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel) 8547@deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel) 8548@deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel) 8549@deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel) 8550@deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel) 8551@deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel) 8552These built-in functions perform the operation suggested by the name, and 8553return the value that had previously been in @code{*@var{ptr}}. That is, 8554 8555@smallexample 8556@{ tmp = *ptr; *ptr @var{op}= val; return tmp; @} 8557@end smallexample 8558 8559All memory models are valid. 8560 8561@end deftypefn 8562 8563@deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel) 8564 8565This built-in function performs an atomic test-and-set operation on 8566the byte at @code{*@var{ptr}}. The byte is set to some implementation 8567defined nonzero ``set'' value and the return value is @code{true} if and only 8568if the previous contents were ``set''. 8569It should be only used for operands of type @code{bool} or @code{char}. For 8570other types only part of the value may be set. 8571 8572All memory models are valid. 8573 8574@end deftypefn 8575 8576@deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel) 8577 8578This built-in function performs an atomic clear operation on 8579@code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0. 8580It should be only used for operands of type @code{bool} or @code{char} and 8581in conjunction with @code{__atomic_test_and_set}. 8582For other types it may only clear partially. If the type is not @code{bool} 8583prefer using @code{__atomic_store}. 8584 8585The valid memory model variants are 8586@code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and 8587@code{__ATOMIC_RELEASE}. 8588 8589@end deftypefn 8590 8591@deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel) 8592 8593This built-in function acts as a synchronization fence between threads 8594based on the specified memory model. 8595 8596All memory orders are valid. 8597 8598@end deftypefn 8599 8600@deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel) 8601 8602This built-in function acts as a synchronization fence between a thread 8603and signal handlers based in the same thread. 8604 8605All memory orders are valid. 8606 8607@end deftypefn 8608 8609@deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr) 8610 8611This built-in function returns true if objects of @var{size} bytes always 8612generate lock free atomic instructions for the target architecture. 8613@var{size} must resolve to a compile-time constant and the result also 8614resolves to a compile-time constant. 8615 8616@var{ptr} is an optional pointer to the object that may be used to determine 8617alignment. A value of 0 indicates typical alignment should be used. The 8618compiler may also ignore this parameter. 8619 8620@smallexample 8621if (_atomic_always_lock_free (sizeof (long long), 0)) 8622@end smallexample 8623 8624@end deftypefn 8625 8626@deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr) 8627 8628This built-in function returns true if objects of @var{size} bytes always 8629generate lock free atomic instructions for the target architecture. If 8630it is not known to be lock free a call is made to a runtime routine named 8631@code{__atomic_is_lock_free}. 8632 8633@var{ptr} is an optional pointer to the object that may be used to determine 8634alignment. A value of 0 indicates typical alignment should be used. The 8635compiler may also ignore this parameter. 8636@end deftypefn 8637 8638@node Integer Overflow Builtins 8639@section Built-in Functions to Perform Arithmetic with Overflow Checking 8640 8641The following built-in functions allow performing simple arithmetic operations 8642together with checking whether the operations overflowed. 8643 8644@deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res) 8645@deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res) 8646@deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res) 8647@deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res) 8648@deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res) 8649@deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res) 8650@deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res) 8651 8652These built-in functions promote the first two operands into infinite precision signed 8653type and perform addition on those promoted operands. The result is then 8654cast to the type the third pointer argument points to and stored there. 8655If the stored result is equal to the infinite precision result, the built-in 8656functions return false, otherwise they return true. As the addition is 8657performed in infinite signed precision, these built-in functions have fully defined 8658behavior for all argument values. 8659 8660The first built-in function allows arbitrary integral types for operands and 8661the result type must be pointer to some integer type, the rest of the built-in 8662functions have explicit integer types. 8663 8664The compiler will attempt to use hardware instructions to implement 8665these built-in functions where possible, like conditional jump on overflow 8666after addition, conditional jump on carry etc. 8667 8668@end deftypefn 8669 8670@deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res) 8671@deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res) 8672@deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res) 8673@deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res) 8674@deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res) 8675@deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res) 8676@deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res) 8677 8678These built-in functions are similar to the add overflow checking built-in 8679functions above, except they perform subtraction, subtract the second argument 8680from the first one, instead of addition. 8681 8682@end deftypefn 8683 8684@deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res) 8685@deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res) 8686@deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res) 8687@deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res) 8688@deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res) 8689@deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res) 8690@deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res) 8691 8692These built-in functions are similar to the add overflow checking built-in 8693functions above, except they perform multiplication, instead of addition. 8694 8695@end deftypefn 8696 8697@node x86 specific memory model extensions for transactional memory 8698@section x86-Specific Memory Model Extensions for Transactional Memory 8699 8700The x86 architecture supports additional memory ordering flags 8701to mark lock critical sections for hardware lock elision. 8702These must be specified in addition to an existing memory model to 8703atomic intrinsics. 8704 8705@table @code 8706@item __ATOMIC_HLE_ACQUIRE 8707Start lock elision on a lock variable. 8708Memory model must be @code{__ATOMIC_ACQUIRE} or stronger. 8709@item __ATOMIC_HLE_RELEASE 8710End lock elision on a lock variable. 8711Memory model must be @code{__ATOMIC_RELEASE} or stronger. 8712@end table 8713 8714When a lock acquire fails it is required for good performance to abort 8715the transaction quickly. This can be done with a @code{_mm_pause} 8716 8717@smallexample 8718#include <immintrin.h> // For _mm_pause 8719 8720int lockvar; 8721 8722/* Acquire lock with lock elision */ 8723while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE)) 8724 _mm_pause(); /* Abort failed transaction */ 8725... 8726/* Free lock with lock elision */ 8727__atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE); 8728@end smallexample 8729 8730@node Object Size Checking 8731@section Object Size Checking Built-in Functions 8732@findex __builtin_object_size 8733@findex __builtin___memcpy_chk 8734@findex __builtin___mempcpy_chk 8735@findex __builtin___memmove_chk 8736@findex __builtin___memset_chk 8737@findex __builtin___strcpy_chk 8738@findex __builtin___stpcpy_chk 8739@findex __builtin___strncpy_chk 8740@findex __builtin___strcat_chk 8741@findex __builtin___strncat_chk 8742@findex __builtin___sprintf_chk 8743@findex __builtin___snprintf_chk 8744@findex __builtin___vsprintf_chk 8745@findex __builtin___vsnprintf_chk 8746@findex __builtin___printf_chk 8747@findex __builtin___vprintf_chk 8748@findex __builtin___fprintf_chk 8749@findex __builtin___vfprintf_chk 8750 8751GCC implements a limited buffer overflow protection mechanism 8752that can prevent some buffer overflow attacks. 8753 8754@deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type}) 8755is a built-in construct that returns a constant number of bytes from 8756@var{ptr} to the end of the object @var{ptr} pointer points to 8757(if known at compile time). @code{__builtin_object_size} never evaluates 8758its arguments for side-effects. If there are any side-effects in them, it 8759returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0} 8760for @var{type} 2 or 3. If there are multiple objects @var{ptr} can 8761point to and all of them are known at compile time, the returned number 8762is the maximum of remaining byte counts in those objects if @var{type} & 2 is 87630 and minimum if nonzero. If it is not possible to determine which objects 8764@var{ptr} points to at compile time, @code{__builtin_object_size} should 8765return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0} 8766for @var{type} 2 or 3. 8767 8768@var{type} is an integer constant from 0 to 3. If the least significant 8769bit is clear, objects are whole variables, if it is set, a closest 8770surrounding subobject is considered the object a pointer points to. 8771The second bit determines if maximum or minimum of remaining bytes 8772is computed. 8773 8774@smallexample 8775struct V @{ char buf1[10]; int b; char buf2[10]; @} var; 8776char *p = &var.buf1[1], *q = &var.b; 8777 8778/* Here the object p points to is var. */ 8779assert (__builtin_object_size (p, 0) == sizeof (var) - 1); 8780/* The subobject p points to is var.buf1. */ 8781assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1); 8782/* The object q points to is var. */ 8783assert (__builtin_object_size (q, 0) 8784 == (char *) (&var + 1) - (char *) &var.b); 8785/* The subobject q points to is var.b. */ 8786assert (__builtin_object_size (q, 1) == sizeof (var.b)); 8787@end smallexample 8788@end deftypefn 8789 8790There are built-in functions added for many common string operation 8791functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk} 8792built-in is provided. This built-in has an additional last argument, 8793which is the number of bytes remaining in object the @var{dest} 8794argument points to or @code{(size_t) -1} if the size is not known. 8795 8796The built-in functions are optimized into the normal string functions 8797like @code{memcpy} if the last argument is @code{(size_t) -1} or if 8798it is known at compile time that the destination object will not 8799be overflown. If the compiler can determine at compile time the 8800object will be always overflown, it issues a warning. 8801 8802The intended use can be e.g.@: 8803 8804@smallexample 8805#undef memcpy 8806#define bos0(dest) __builtin_object_size (dest, 0) 8807#define memcpy(dest, src, n) \ 8808 __builtin___memcpy_chk (dest, src, n, bos0 (dest)) 8809 8810char *volatile p; 8811char buf[10]; 8812/* It is unknown what object p points to, so this is optimized 8813 into plain memcpy - no checking is possible. */ 8814memcpy (p, "abcde", n); 8815/* Destination is known and length too. It is known at compile 8816 time there will be no overflow. */ 8817memcpy (&buf[5], "abcde", 5); 8818/* Destination is known, but the length is not known at compile time. 8819 This will result in __memcpy_chk call that can check for overflow 8820 at run time. */ 8821memcpy (&buf[5], "abcde", n); 8822/* Destination is known and it is known at compile time there will 8823 be overflow. There will be a warning and __memcpy_chk call that 8824 will abort the program at run time. */ 8825memcpy (&buf[6], "abcde", 5); 8826@end smallexample 8827 8828Such built-in functions are provided for @code{memcpy}, @code{mempcpy}, 8829@code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy}, 8830@code{strcat} and @code{strncat}. 8831 8832There are also checking built-in functions for formatted output functions. 8833@smallexample 8834int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...); 8835int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os, 8836 const char *fmt, ...); 8837int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt, 8838 va_list ap); 8839int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os, 8840 const char *fmt, va_list ap); 8841@end smallexample 8842 8843The added @var{flag} argument is passed unchanged to @code{__sprintf_chk} 8844etc.@: functions and can contain implementation specific flags on what 8845additional security measures the checking function might take, such as 8846handling @code{%n} differently. 8847 8848The @var{os} argument is the object size @var{s} points to, like in the 8849other built-in functions. There is a small difference in the behavior 8850though, if @var{os} is @code{(size_t) -1}, the built-in functions are 8851optimized into the non-checking functions only if @var{flag} is 0, otherwise 8852the checking function is called with @var{os} argument set to 8853@code{(size_t) -1}. 8854 8855In addition to this, there are checking built-in functions 8856@code{__builtin___printf_chk}, @code{__builtin___vprintf_chk}, 8857@code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}. 8858These have just one additional argument, @var{flag}, right before 8859format string @var{fmt}. If the compiler is able to optimize them to 8860@code{fputc} etc.@: functions, it does, otherwise the checking function 8861is called and the @var{flag} argument passed to it. 8862 8863@node Pointer Bounds Checker builtins 8864@section Pointer Bounds Checker Built-in Functions 8865@cindex Pointer Bounds Checker builtins 8866@findex __builtin___bnd_set_ptr_bounds 8867@findex __builtin___bnd_narrow_ptr_bounds 8868@findex __builtin___bnd_copy_ptr_bounds 8869@findex __builtin___bnd_init_ptr_bounds 8870@findex __builtin___bnd_null_ptr_bounds 8871@findex __builtin___bnd_store_ptr_bounds 8872@findex __builtin___bnd_chk_ptr_lbounds 8873@findex __builtin___bnd_chk_ptr_ubounds 8874@findex __builtin___bnd_chk_ptr_bounds 8875@findex __builtin___bnd_get_ptr_lbound 8876@findex __builtin___bnd_get_ptr_ubound 8877 8878GCC provides a set of built-in functions to control Pointer Bounds Checker 8879instrumentation. Note that all Pointer Bounds Checker builtins can be used 8880even if you compile with Pointer Bounds Checker off 8881(@option{-fno-check-pointer-bounds}). 8882The behavior may differ in such case as documented below. 8883 8884@deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size}) 8885 8886This built-in function returns a new pointer with the value of @var{q}, and 8887associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer 8888Bounds Checker off, the built-in function just returns the first argument. 8889 8890@smallexample 8891extern void *__wrap_malloc (size_t n) 8892@{ 8893 void *p = (void *)__real_malloc (n); 8894 if (!p) return __builtin___bnd_null_ptr_bounds (p); 8895 return __builtin___bnd_set_ptr_bounds (p, n); 8896@} 8897@end smallexample 8898 8899@end deftypefn 8900 8901@deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size}) 8902 8903This built-in function returns a new pointer with the value of @var{p} 8904and associates it with the narrowed bounds formed by the intersection 8905of bounds associated with @var{q} and the bounds 8906[@var{p}, @var{p} + @var{size} - 1]. 8907With Pointer Bounds Checker off, the built-in function just returns the first 8908argument. 8909 8910@smallexample 8911void init_objects (object *objs, size_t size) 8912@{ 8913 size_t i; 8914 /* Initialize objects one-by-one passing pointers with bounds of 8915 an object, not the full array of objects. */ 8916 for (i = 0; i < size; i++) 8917 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs, 8918 sizeof(object))); 8919@} 8920@end smallexample 8921 8922@end deftypefn 8923 8924@deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r}) 8925 8926This built-in function returns a new pointer with the value of @var{q}, 8927and associates it with the bounds already associated with pointer @var{r}. 8928With Pointer Bounds Checker off, the built-in function just returns the first 8929argument. 8930 8931@smallexample 8932/* Here is a way to get pointer to object's field but 8933 still with the full object's bounds. */ 8934int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field, 8935 objptr); 8936@end smallexample 8937 8938@end deftypefn 8939 8940@deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q}) 8941 8942This built-in function returns a new pointer with the value of @var{q}, and 8943associates it with INIT (allowing full memory access) bounds. With Pointer 8944Bounds Checker off, the built-in function just returns the first argument. 8945 8946@end deftypefn 8947 8948@deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q}) 8949 8950This built-in function returns a new pointer with the value of @var{q}, and 8951associates it with NULL (allowing no memory access) bounds. With Pointer 8952Bounds Checker off, the built-in function just returns the first argument. 8953 8954@end deftypefn 8955 8956@deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val}) 8957 8958This built-in function stores the bounds associated with pointer @var{ptr_val} 8959and location @var{ptr_addr} into Bounds Table. This can be useful to propagate 8960bounds from legacy code without touching the associated pointer's memory when 8961pointers are copied as integers. With Pointer Bounds Checker off, the built-in 8962function call is ignored. 8963 8964@end deftypefn 8965 8966@deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q}) 8967 8968This built-in function checks if the pointer @var{q} is within the lower 8969bound of its associated bounds. With Pointer Bounds Checker off, the built-in 8970function call is ignored. 8971 8972@smallexample 8973extern void *__wrap_memset (void *dst, int c, size_t len) 8974@{ 8975 if (len > 0) 8976 @{ 8977 __builtin___bnd_chk_ptr_lbounds (dst); 8978 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1); 8979 __real_memset (dst, c, len); 8980 @} 8981 return dst; 8982@} 8983@end smallexample 8984 8985@end deftypefn 8986 8987@deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q}) 8988 8989This built-in function checks if the pointer @var{q} is within the upper 8990bound of its associated bounds. With Pointer Bounds Checker off, the built-in 8991function call is ignored. 8992 8993@end deftypefn 8994 8995@deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size}) 8996 8997This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within 8998the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker 8999off, the built-in function call is ignored. 9000 9001@smallexample 9002extern void *__wrap_memcpy (void *dst, const void *src, size_t n) 9003@{ 9004 if (n > 0) 9005 @{ 9006 __bnd_chk_ptr_bounds (dst, n); 9007 __bnd_chk_ptr_bounds (src, n); 9008 __real_memcpy (dst, src, n); 9009 @} 9010 return dst; 9011@} 9012@end smallexample 9013 9014@end deftypefn 9015 9016@deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q}) 9017 9018This built-in function returns the lower bound associated 9019with the pointer @var{q}, as a pointer value. 9020This is useful for debugging using @code{printf}. 9021With Pointer Bounds Checker off, the built-in function returns 0. 9022 9023@smallexample 9024void *lb = __builtin___bnd_get_ptr_lbound (q); 9025void *ub = __builtin___bnd_get_ptr_ubound (q); 9026printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub); 9027@end smallexample 9028 9029@end deftypefn 9030 9031@deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q}) 9032 9033This built-in function returns the upper bound (which is a pointer) associated 9034with the pointer @var{q}. With Pointer Bounds Checker off, 9035the built-in function returns -1. 9036 9037@end deftypefn 9038 9039@node Cilk Plus Builtins 9040@section Cilk Plus C/C++ Language Extension Built-in Functions 9041 9042GCC provides support for the following built-in reduction functions if Cilk Plus 9043is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag. 9044 9045@itemize @bullet 9046@item @code{__sec_implicit_index} 9047@item @code{__sec_reduce} 9048@item @code{__sec_reduce_add} 9049@item @code{__sec_reduce_all_nonzero} 9050@item @code{__sec_reduce_all_zero} 9051@item @code{__sec_reduce_any_nonzero} 9052@item @code{__sec_reduce_any_zero} 9053@item @code{__sec_reduce_max} 9054@item @code{__sec_reduce_min} 9055@item @code{__sec_reduce_max_ind} 9056@item @code{__sec_reduce_min_ind} 9057@item @code{__sec_reduce_mul} 9058@item @code{__sec_reduce_mutating} 9059@end itemize 9060 9061Further details and examples about these built-in functions are described 9062in the Cilk Plus language manual which can be found at 9063@uref{https://www.cilkplus.org}. 9064 9065@node Other Builtins 9066@section Other Built-in Functions Provided by GCC 9067@cindex built-in functions 9068@findex __builtin_call_with_static_chain 9069@findex __builtin_fpclassify 9070@findex __builtin_isfinite 9071@findex __builtin_isnormal 9072@findex __builtin_isgreater 9073@findex __builtin_isgreaterequal 9074@findex __builtin_isinf_sign 9075@findex __builtin_isless 9076@findex __builtin_islessequal 9077@findex __builtin_islessgreater 9078@findex __builtin_isunordered 9079@findex __builtin_powi 9080@findex __builtin_powif 9081@findex __builtin_powil 9082@findex _Exit 9083@findex _exit 9084@findex abort 9085@findex abs 9086@findex acos 9087@findex acosf 9088@findex acosh 9089@findex acoshf 9090@findex acoshl 9091@findex acosl 9092@findex alloca 9093@findex asin 9094@findex asinf 9095@findex asinh 9096@findex asinhf 9097@findex asinhl 9098@findex asinl 9099@findex atan 9100@findex atan2 9101@findex atan2f 9102@findex atan2l 9103@findex atanf 9104@findex atanh 9105@findex atanhf 9106@findex atanhl 9107@findex atanl 9108@findex bcmp 9109@findex bzero 9110@findex cabs 9111@findex cabsf 9112@findex cabsl 9113@findex cacos 9114@findex cacosf 9115@findex cacosh 9116@findex cacoshf 9117@findex cacoshl 9118@findex cacosl 9119@findex calloc 9120@findex carg 9121@findex cargf 9122@findex cargl 9123@findex casin 9124@findex casinf 9125@findex casinh 9126@findex casinhf 9127@findex casinhl 9128@findex casinl 9129@findex catan 9130@findex catanf 9131@findex catanh 9132@findex catanhf 9133@findex catanhl 9134@findex catanl 9135@findex cbrt 9136@findex cbrtf 9137@findex cbrtl 9138@findex ccos 9139@findex ccosf 9140@findex ccosh 9141@findex ccoshf 9142@findex ccoshl 9143@findex ccosl 9144@findex ceil 9145@findex ceilf 9146@findex ceill 9147@findex cexp 9148@findex cexpf 9149@findex cexpl 9150@findex cimag 9151@findex cimagf 9152@findex cimagl 9153@findex clog 9154@findex clogf 9155@findex clogl 9156@findex conj 9157@findex conjf 9158@findex conjl 9159@findex copysign 9160@findex copysignf 9161@findex copysignl 9162@findex cos 9163@findex cosf 9164@findex cosh 9165@findex coshf 9166@findex coshl 9167@findex cosl 9168@findex cpow 9169@findex cpowf 9170@findex cpowl 9171@findex cproj 9172@findex cprojf 9173@findex cprojl 9174@findex creal 9175@findex crealf 9176@findex creall 9177@findex csin 9178@findex csinf 9179@findex csinh 9180@findex csinhf 9181@findex csinhl 9182@findex csinl 9183@findex csqrt 9184@findex csqrtf 9185@findex csqrtl 9186@findex ctan 9187@findex ctanf 9188@findex ctanh 9189@findex ctanhf 9190@findex ctanhl 9191@findex ctanl 9192@findex dcgettext 9193@findex dgettext 9194@findex drem 9195@findex dremf 9196@findex dreml 9197@findex erf 9198@findex erfc 9199@findex erfcf 9200@findex erfcl 9201@findex erff 9202@findex erfl 9203@findex exit 9204@findex exp 9205@findex exp10 9206@findex exp10f 9207@findex exp10l 9208@findex exp2 9209@findex exp2f 9210@findex exp2l 9211@findex expf 9212@findex expl 9213@findex expm1 9214@findex expm1f 9215@findex expm1l 9216@findex fabs 9217@findex fabsf 9218@findex fabsl 9219@findex fdim 9220@findex fdimf 9221@findex fdiml 9222@findex ffs 9223@findex floor 9224@findex floorf 9225@findex floorl 9226@findex fma 9227@findex fmaf 9228@findex fmal 9229@findex fmax 9230@findex fmaxf 9231@findex fmaxl 9232@findex fmin 9233@findex fminf 9234@findex fminl 9235@findex fmod 9236@findex fmodf 9237@findex fmodl 9238@findex fprintf 9239@findex fprintf_unlocked 9240@findex fputs 9241@findex fputs_unlocked 9242@findex frexp 9243@findex frexpf 9244@findex frexpl 9245@findex fscanf 9246@findex gamma 9247@findex gammaf 9248@findex gammal 9249@findex gamma_r 9250@findex gammaf_r 9251@findex gammal_r 9252@findex gettext 9253@findex hypot 9254@findex hypotf 9255@findex hypotl 9256@findex ilogb 9257@findex ilogbf 9258@findex ilogbl 9259@findex imaxabs 9260@findex index 9261@findex isalnum 9262@findex isalpha 9263@findex isascii 9264@findex isblank 9265@findex iscntrl 9266@findex isdigit 9267@findex isgraph 9268@findex islower 9269@findex isprint 9270@findex ispunct 9271@findex isspace 9272@findex isupper 9273@findex iswalnum 9274@findex iswalpha 9275@findex iswblank 9276@findex iswcntrl 9277@findex iswdigit 9278@findex iswgraph 9279@findex iswlower 9280@findex iswprint 9281@findex iswpunct 9282@findex iswspace 9283@findex iswupper 9284@findex iswxdigit 9285@findex isxdigit 9286@findex j0 9287@findex j0f 9288@findex j0l 9289@findex j1 9290@findex j1f 9291@findex j1l 9292@findex jn 9293@findex jnf 9294@findex jnl 9295@findex labs 9296@findex ldexp 9297@findex ldexpf 9298@findex ldexpl 9299@findex lgamma 9300@findex lgammaf 9301@findex lgammal 9302@findex lgamma_r 9303@findex lgammaf_r 9304@findex lgammal_r 9305@findex llabs 9306@findex llrint 9307@findex llrintf 9308@findex llrintl 9309@findex llround 9310@findex llroundf 9311@findex llroundl 9312@findex log 9313@findex log10 9314@findex log10f 9315@findex log10l 9316@findex log1p 9317@findex log1pf 9318@findex log1pl 9319@findex log2 9320@findex log2f 9321@findex log2l 9322@findex logb 9323@findex logbf 9324@findex logbl 9325@findex logf 9326@findex logl 9327@findex lrint 9328@findex lrintf 9329@findex lrintl 9330@findex lround 9331@findex lroundf 9332@findex lroundl 9333@findex malloc 9334@findex memchr 9335@findex memcmp 9336@findex memcpy 9337@findex mempcpy 9338@findex memset 9339@findex modf 9340@findex modff 9341@findex modfl 9342@findex nearbyint 9343@findex nearbyintf 9344@findex nearbyintl 9345@findex nextafter 9346@findex nextafterf 9347@findex nextafterl 9348@findex nexttoward 9349@findex nexttowardf 9350@findex nexttowardl 9351@findex pow 9352@findex pow10 9353@findex pow10f 9354@findex pow10l 9355@findex powf 9356@findex powl 9357@findex printf 9358@findex printf_unlocked 9359@findex putchar 9360@findex puts 9361@findex remainder 9362@findex remainderf 9363@findex remainderl 9364@findex remquo 9365@findex remquof 9366@findex remquol 9367@findex rindex 9368@findex rint 9369@findex rintf 9370@findex rintl 9371@findex round 9372@findex roundf 9373@findex roundl 9374@findex scalb 9375@findex scalbf 9376@findex scalbl 9377@findex scalbln 9378@findex scalblnf 9379@findex scalblnf 9380@findex scalbn 9381@findex scalbnf 9382@findex scanfnl 9383@findex signbit 9384@findex signbitf 9385@findex signbitl 9386@findex signbitd32 9387@findex signbitd64 9388@findex signbitd128 9389@findex significand 9390@findex significandf 9391@findex significandl 9392@findex sin 9393@findex sincos 9394@findex sincosf 9395@findex sincosl 9396@findex sinf 9397@findex sinh 9398@findex sinhf 9399@findex sinhl 9400@findex sinl 9401@findex snprintf 9402@findex sprintf 9403@findex sqrt 9404@findex sqrtf 9405@findex sqrtl 9406@findex sscanf 9407@findex stpcpy 9408@findex stpncpy 9409@findex strcasecmp 9410@findex strcat 9411@findex strchr 9412@findex strcmp 9413@findex strcpy 9414@findex strcspn 9415@findex strdup 9416@findex strfmon 9417@findex strftime 9418@findex strlen 9419@findex strncasecmp 9420@findex strncat 9421@findex strncmp 9422@findex strncpy 9423@findex strndup 9424@findex strpbrk 9425@findex strrchr 9426@findex strspn 9427@findex strstr 9428@findex tan 9429@findex tanf 9430@findex tanh 9431@findex tanhf 9432@findex tanhl 9433@findex tanl 9434@findex tgamma 9435@findex tgammaf 9436@findex tgammal 9437@findex toascii 9438@findex tolower 9439@findex toupper 9440@findex towlower 9441@findex towupper 9442@findex trunc 9443@findex truncf 9444@findex truncl 9445@findex vfprintf 9446@findex vfscanf 9447@findex vprintf 9448@findex vscanf 9449@findex vsnprintf 9450@findex vsprintf 9451@findex vsscanf 9452@findex y0 9453@findex y0f 9454@findex y0l 9455@findex y1 9456@findex y1f 9457@findex y1l 9458@findex yn 9459@findex ynf 9460@findex ynl 9461 9462GCC provides a large number of built-in functions other than the ones 9463mentioned above. Some of these are for internal use in the processing 9464of exceptions or variable-length argument lists and are not 9465documented here because they may change from time to time; we do not 9466recommend general use of these functions. 9467 9468The remaining functions are provided for optimization purposes. 9469 9470@opindex fno-builtin 9471GCC includes built-in versions of many of the functions in the standard 9472C library. The versions prefixed with @code{__builtin_} are always 9473treated as having the same meaning as the C library function even if you 9474specify the @option{-fno-builtin} option. (@pxref{C Dialect Options}) 9475Many of these functions are only optimized in certain cases; if they are 9476not optimized in a particular case, a call to the library function is 9477emitted. 9478 9479@opindex ansi 9480@opindex std 9481Outside strict ISO C mode (@option{-ansi}, @option{-std=c90}, 9482@option{-std=c99} or @option{-std=c11}), the functions 9483@code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero}, 9484@code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml}, 9485@code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll}, 9486@code{ffsl}, @code{ffs}, @code{fprintf_unlocked}, 9487@code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma}, 9488@code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext}, 9489@code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0}, 9490@code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn}, 9491@code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy}, 9492@code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked}, 9493@code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb}, 9494@code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32}, 9495@code{signbitd64}, @code{signbitd128}, @code{significandf}, 9496@code{significandl}, @code{significand}, @code{sincosf}, 9497@code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy}, 9498@code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp}, 9499@code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0}, 9500@code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and 9501@code{yn} 9502may be handled as built-in functions. 9503All these functions have corresponding versions 9504prefixed with @code{__builtin_}, which may be used even in strict C90 9505mode. 9506 9507The ISO C99 functions 9508@code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf}, 9509@code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh}, 9510@code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf}, 9511@code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos}, 9512@code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf}, 9513@code{casinhl}, @code{casinh}, @code{casinl}, @code{casin}, 9514@code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh}, 9515@code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt}, 9516@code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl}, 9517@code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf}, 9518@code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog}, 9519@code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl}, 9520@code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf}, 9521@code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal}, 9522@code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl}, 9523@code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf}, 9524@code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan}, 9525@code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl}, 9526@code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f}, 9527@code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim}, 9528@code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax}, 9529@code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf}, 9530@code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb}, 9531@code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf}, 9532@code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl}, 9533@code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround}, 9534@code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l}, 9535@code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf}, 9536@code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl}, 9537@code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint}, 9538@code{nextafterf}, @code{nextafterl}, @code{nextafter}, 9539@code{nexttowardf}, @code{nexttowardl}, @code{nexttoward}, 9540@code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof}, 9541@code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint}, 9542@code{roundf}, @code{roundl}, @code{round}, @code{scalblnf}, 9543@code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl}, 9544@code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal}, 9545@code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc}, 9546@code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf} 9547are handled as built-in functions 9548except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}). 9549 9550There are also built-in versions of the ISO C99 functions 9551@code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f}, 9552@code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill}, 9553@code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf}, 9554@code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl}, 9555@code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf}, 9556@code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl}, 9557@code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf}, 9558@code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl}, 9559@code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl} 9560that are recognized in any mode since ISO C90 reserves these names for 9561the purpose to which ISO C99 puts them. All these functions have 9562corresponding versions prefixed with @code{__builtin_}. 9563 9564The ISO C94 functions 9565@code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit}, 9566@code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct}, 9567@code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and 9568@code{towupper} 9569are handled as built-in functions 9570except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}). 9571 9572The ISO C90 functions 9573@code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2}, 9574@code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos}, 9575@code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod}, 9576@code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf}, 9577@code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit}, 9578@code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct}, 9579@code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower}, 9580@code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log}, 9581@code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy}, 9582@code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar}, 9583@code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf}, 9584@code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat}, 9585@code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn}, 9586@code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy}, 9587@code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr}, 9588@code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf} 9589are all recognized as built-in functions unless 9590@option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}} 9591is specified for an individual function). All of these functions have 9592corresponding versions prefixed with @code{__builtin_}. 9593 9594GCC provides built-in versions of the ISO C99 floating-point comparison 9595macros that avoid raising exceptions for unordered operands. They have 9596the same names as the standard macros ( @code{isgreater}, 9597@code{isgreaterequal}, @code{isless}, @code{islessequal}, 9598@code{islessgreater}, and @code{isunordered}) , with @code{__builtin_} 9599prefixed. We intend for a library implementor to be able to simply 9600@code{#define} each standard macro to its built-in equivalent. 9601In the same fashion, GCC provides @code{fpclassify}, @code{isfinite}, 9602@code{isinf_sign} and @code{isnormal} built-ins used with 9603@code{__builtin_} prefixed. The @code{isinf} and @code{isnan} 9604built-in functions appear both with and without the @code{__builtin_} prefix. 9605 9606@deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2}) 9607 9608You can use the built-in function @code{__builtin_types_compatible_p} to 9609determine whether two types are the same. 9610 9611This built-in function returns 1 if the unqualified versions of the 9612types @var{type1} and @var{type2} (which are types, not expressions) are 9613compatible, 0 otherwise. The result of this built-in function can be 9614used in integer constant expressions. 9615 9616This built-in function ignores top level qualifiers (e.g., @code{const}, 9617@code{volatile}). For example, @code{int} is equivalent to @code{const 9618int}. 9619 9620The type @code{int[]} and @code{int[5]} are compatible. On the other 9621hand, @code{int} and @code{char *} are not compatible, even if the size 9622of their types, on the particular architecture are the same. Also, the 9623amount of pointer indirection is taken into account when determining 9624similarity. Consequently, @code{short *} is not similar to 9625@code{short **}. Furthermore, two types that are typedefed are 9626considered compatible if their underlying types are compatible. 9627 9628An @code{enum} type is not considered to be compatible with another 9629@code{enum} type even if both are compatible with the same integer 9630type; this is what the C standard specifies. 9631For example, @code{enum @{foo, bar@}} is not similar to 9632@code{enum @{hot, dog@}}. 9633 9634You typically use this function in code whose execution varies 9635depending on the arguments' types. For example: 9636 9637@smallexample 9638#define foo(x) \ 9639 (@{ \ 9640 typeof (x) tmp = (x); \ 9641 if (__builtin_types_compatible_p (typeof (x), long double)) \ 9642 tmp = foo_long_double (tmp); \ 9643 else if (__builtin_types_compatible_p (typeof (x), double)) \ 9644 tmp = foo_double (tmp); \ 9645 else if (__builtin_types_compatible_p (typeof (x), float)) \ 9646 tmp = foo_float (tmp); \ 9647 else \ 9648 abort (); \ 9649 tmp; \ 9650 @}) 9651@end smallexample 9652 9653@emph{Note:} This construct is only available for C@. 9654 9655@end deftypefn 9656 9657@deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp}) 9658 9659The @var{call_exp} expression must be a function call, and the 9660@var{pointer_exp} expression must be a pointer. The @var{pointer_exp} 9661is passed to the function call in the target's static chain location. 9662The result of builtin is the result of the function call. 9663 9664@emph{Note:} This builtin is only available for C@. 9665This builtin can be used to call Go closures from C. 9666 9667@end deftypefn 9668 9669@deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2}) 9670 9671You can use the built-in function @code{__builtin_choose_expr} to 9672evaluate code depending on the value of a constant expression. This 9673built-in function returns @var{exp1} if @var{const_exp}, which is an 9674integer constant expression, is nonzero. Otherwise it returns @var{exp2}. 9675 9676This built-in function is analogous to the @samp{? :} operator in C, 9677except that the expression returned has its type unaltered by promotion 9678rules. Also, the built-in function does not evaluate the expression 9679that is not chosen. For example, if @var{const_exp} evaluates to true, 9680@var{exp2} is not evaluated even if it has side-effects. 9681 9682This built-in function can return an lvalue if the chosen argument is an 9683lvalue. 9684 9685If @var{exp1} is returned, the return type is the same as @var{exp1}'s 9686type. Similarly, if @var{exp2} is returned, its return type is the same 9687as @var{exp2}. 9688 9689Example: 9690 9691@smallexample 9692#define foo(x) \ 9693 __builtin_choose_expr ( \ 9694 __builtin_types_compatible_p (typeof (x), double), \ 9695 foo_double (x), \ 9696 __builtin_choose_expr ( \ 9697 __builtin_types_compatible_p (typeof (x), float), \ 9698 foo_float (x), \ 9699 /* @r{The void expression results in a compile-time error} \ 9700 @r{when assigning the result to something.} */ \ 9701 (void)0)) 9702@end smallexample 9703 9704@emph{Note:} This construct is only available for C@. Furthermore, the 9705unused expression (@var{exp1} or @var{exp2} depending on the value of 9706@var{const_exp}) may still generate syntax errors. This may change in 9707future revisions. 9708 9709@end deftypefn 9710 9711@deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag}) 9712 9713The built-in function @code{__builtin_complex} is provided for use in 9714implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and 9715@code{CMPLXL}. @var{real} and @var{imag} must have the same type, a 9716real binary floating-point type, and the result has the corresponding 9717complex type with real and imaginary parts @var{real} and @var{imag}. 9718Unlike @samp{@var{real} + I * @var{imag}}, this works even when 9719infinities, NaNs and negative zeros are involved. 9720 9721@end deftypefn 9722 9723@deftypefn {Built-in Function} int __builtin_constant_p (@var{exp}) 9724You can use the built-in function @code{__builtin_constant_p} to 9725determine if a value is known to be constant at compile time and hence 9726that GCC can perform constant-folding on expressions involving that 9727value. The argument of the function is the value to test. The function 9728returns the integer 1 if the argument is known to be a compile-time 9729constant and 0 if it is not known to be a compile-time constant. A 9730return of 0 does not indicate that the value is @emph{not} a constant, 9731but merely that GCC cannot prove it is a constant with the specified 9732value of the @option{-O} option. 9733 9734You typically use this function in an embedded application where 9735memory is a critical resource. If you have some complex calculation, 9736you may want it to be folded if it involves constants, but need to call 9737a function if it does not. For example: 9738 9739@smallexample 9740#define Scale_Value(X) \ 9741 (__builtin_constant_p (X) \ 9742 ? ((X) * SCALE + OFFSET) : Scale (X)) 9743@end smallexample 9744 9745You may use this built-in function in either a macro or an inline 9746function. However, if you use it in an inlined function and pass an 9747argument of the function as the argument to the built-in, GCC 9748never returns 1 when you call the inline function with a string constant 9749or compound literal (@pxref{Compound Literals}) and does not return 1 9750when you pass a constant numeric value to the inline function unless you 9751specify the @option{-O} option. 9752 9753You may also use @code{__builtin_constant_p} in initializers for static 9754data. For instance, you can write 9755 9756@smallexample 9757static const int table[] = @{ 9758 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1, 9759 /* @r{@dots{}} */ 9760@}; 9761@end smallexample 9762 9763@noindent 9764This is an acceptable initializer even if @var{EXPRESSION} is not a 9765constant expression, including the case where 9766@code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be 9767folded to a constant but @var{EXPRESSION} contains operands that are 9768not otherwise permitted in a static initializer (for example, 9769@code{0 && foo ()}). GCC must be more conservative about evaluating the 9770built-in in this case, because it has no opportunity to perform 9771optimization. 9772@end deftypefn 9773 9774@deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c}) 9775@opindex fprofile-arcs 9776You may use @code{__builtin_expect} to provide the compiler with 9777branch prediction information. In general, you should prefer to 9778use actual profile feedback for this (@option{-fprofile-arcs}), as 9779programmers are notoriously bad at predicting how their programs 9780actually perform. However, there are applications in which this 9781data is hard to collect. 9782 9783The return value is the value of @var{exp}, which should be an integral 9784expression. The semantics of the built-in are that it is expected that 9785@var{exp} == @var{c}. For example: 9786 9787@smallexample 9788if (__builtin_expect (x, 0)) 9789 foo (); 9790@end smallexample 9791 9792@noindent 9793indicates that we do not expect to call @code{foo}, since 9794we expect @code{x} to be zero. Since you are limited to integral 9795expressions for @var{exp}, you should use constructions such as 9796 9797@smallexample 9798if (__builtin_expect (ptr != NULL, 1)) 9799 foo (*ptr); 9800@end smallexample 9801 9802@noindent 9803when testing pointer or floating-point values. 9804@end deftypefn 9805 9806@deftypefn {Built-in Function} void __builtin_trap (void) 9807This function causes the program to exit abnormally. GCC implements 9808this function by using a target-dependent mechanism (such as 9809intentionally executing an illegal instruction) or by calling 9810@code{abort}. The mechanism used may vary from release to release so 9811you should not rely on any particular implementation. 9812@end deftypefn 9813 9814@deftypefn {Built-in Function} void __builtin_unreachable (void) 9815If control flow reaches the point of the @code{__builtin_unreachable}, 9816the program is undefined. It is useful in situations where the 9817compiler cannot deduce the unreachability of the code. 9818 9819One such case is immediately following an @code{asm} statement that 9820either never terminates, or one that transfers control elsewhere 9821and never returns. In this example, without the 9822@code{__builtin_unreachable}, GCC issues a warning that control 9823reaches the end of a non-void function. It also generates code 9824to return after the @code{asm}. 9825 9826@smallexample 9827int f (int c, int v) 9828@{ 9829 if (c) 9830 @{ 9831 return v; 9832 @} 9833 else 9834 @{ 9835 asm("jmp error_handler"); 9836 __builtin_unreachable (); 9837 @} 9838@} 9839@end smallexample 9840 9841@noindent 9842Because the @code{asm} statement unconditionally transfers control out 9843of the function, control never reaches the end of the function 9844body. The @code{__builtin_unreachable} is in fact unreachable and 9845communicates this fact to the compiler. 9846 9847Another use for @code{__builtin_unreachable} is following a call a 9848function that never returns but that is not declared 9849@code{__attribute__((noreturn))}, as in this example: 9850 9851@smallexample 9852void function_that_never_returns (void); 9853 9854int g (int c) 9855@{ 9856 if (c) 9857 @{ 9858 return 1; 9859 @} 9860 else 9861 @{ 9862 function_that_never_returns (); 9863 __builtin_unreachable (); 9864 @} 9865@} 9866@end smallexample 9867 9868@end deftypefn 9869 9870@deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...) 9871This function returns its first argument, and allows the compiler 9872to assume that the returned pointer is at least @var{align} bytes 9873aligned. This built-in can have either two or three arguments, 9874if it has three, the third argument should have integer type, and 9875if it is nonzero means misalignment offset. For example: 9876 9877@smallexample 9878void *x = __builtin_assume_aligned (arg, 16); 9879@end smallexample 9880 9881@noindent 9882means that the compiler can assume @code{x}, set to @code{arg}, is at least 988316-byte aligned, while: 9884 9885@smallexample 9886void *x = __builtin_assume_aligned (arg, 32, 8); 9887@end smallexample 9888 9889@noindent 9890means that the compiler can assume for @code{x}, set to @code{arg}, that 9891@code{(char *) x - 8} is 32-byte aligned. 9892@end deftypefn 9893 9894@deftypefn {Built-in Function} int __builtin_LINE () 9895This function is the equivalent to the preprocessor @code{__LINE__} 9896macro and returns the line number of the invocation of the built-in. 9897In a C++ default argument for a function @var{F}, it gets the line number of 9898the call to @var{F}. 9899@end deftypefn 9900 9901@deftypefn {Built-in Function} {const char *} __builtin_FUNCTION () 9902This function is the equivalent to the preprocessor @code{__FUNCTION__} 9903macro and returns the function name the invocation of the built-in is in. 9904@end deftypefn 9905 9906@deftypefn {Built-in Function} {const char *} __builtin_FILE () 9907This function is the equivalent to the preprocessor @code{__FILE__} 9908macro and returns the file name the invocation of the built-in is in. 9909In a C++ default argument for a function @var{F}, it gets the file name of 9910the call to @var{F}. 9911@end deftypefn 9912 9913@deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end}) 9914This function is used to flush the processor's instruction cache for 9915the region of memory between @var{begin} inclusive and @var{end} 9916exclusive. Some targets require that the instruction cache be 9917flushed, after modifying memory containing code, in order to obtain 9918deterministic behavior. 9919 9920If the target does not require instruction cache flushes, 9921@code{__builtin___clear_cache} has no effect. Otherwise either 9922instructions are emitted in-line to clear the instruction cache or a 9923call to the @code{__clear_cache} function in libgcc is made. 9924@end deftypefn 9925 9926@deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...) 9927This function is used to minimize cache-miss latency by moving data into 9928a cache before it is accessed. 9929You can insert calls to @code{__builtin_prefetch} into code for which 9930you know addresses of data in memory that is likely to be accessed soon. 9931If the target supports them, data prefetch instructions are generated. 9932If the prefetch is done early enough before the access then the data will 9933be in the cache by the time it is accessed. 9934 9935The value of @var{addr} is the address of the memory to prefetch. 9936There are two optional arguments, @var{rw} and @var{locality}. 9937The value of @var{rw} is a compile-time constant one or zero; one 9938means that the prefetch is preparing for a write to the memory address 9939and zero, the default, means that the prefetch is preparing for a read. 9940The value @var{locality} must be a compile-time constant integer between 9941zero and three. A value of zero means that the data has no temporal 9942locality, so it need not be left in the cache after the access. A value 9943of three means that the data has a high degree of temporal locality and 9944should be left in all levels of cache possible. Values of one and two 9945mean, respectively, a low or moderate degree of temporal locality. The 9946default is three. 9947 9948@smallexample 9949for (i = 0; i < n; i++) 9950 @{ 9951 a[i] = a[i] + b[i]; 9952 __builtin_prefetch (&a[i+j], 1, 1); 9953 __builtin_prefetch (&b[i+j], 0, 1); 9954 /* @r{@dots{}} */ 9955 @} 9956@end smallexample 9957 9958Data prefetch does not generate faults if @var{addr} is invalid, but 9959the address expression itself must be valid. For example, a prefetch 9960of @code{p->next} does not fault if @code{p->next} is not a valid 9961address, but evaluation faults if @code{p} is not a valid address. 9962 9963If the target does not support data prefetch, the address expression 9964is evaluated if it includes side effects but no other code is generated 9965and GCC does not issue a warning. 9966@end deftypefn 9967 9968@deftypefn {Built-in Function} double __builtin_huge_val (void) 9969Returns a positive infinity, if supported by the floating-point format, 9970else @code{DBL_MAX}. This function is suitable for implementing the 9971ISO C macro @code{HUGE_VAL}. 9972@end deftypefn 9973 9974@deftypefn {Built-in Function} float __builtin_huge_valf (void) 9975Similar to @code{__builtin_huge_val}, except the return type is @code{float}. 9976@end deftypefn 9977 9978@deftypefn {Built-in Function} {long double} __builtin_huge_vall (void) 9979Similar to @code{__builtin_huge_val}, except the return 9980type is @code{long double}. 9981@end deftypefn 9982 9983@deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...) 9984This built-in implements the C99 fpclassify functionality. The first 9985five int arguments should be the target library's notion of the 9986possible FP classes and are used for return values. They must be 9987constant values and they must appear in this order: @code{FP_NAN}, 9988@code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and 9989@code{FP_ZERO}. The ellipsis is for exactly one floating-point value 9990to classify. GCC treats the last argument as type-generic, which 9991means it does not do default promotion from float to double. 9992@end deftypefn 9993 9994@deftypefn {Built-in Function} double __builtin_inf (void) 9995Similar to @code{__builtin_huge_val}, except a warning is generated 9996if the target floating-point format does not support infinities. 9997@end deftypefn 9998 9999@deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void) 10000Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}. 10001@end deftypefn 10002 10003@deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void) 10004Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}. 10005@end deftypefn 10006 10007@deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void) 10008Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}. 10009@end deftypefn 10010 10011@deftypefn {Built-in Function} float __builtin_inff (void) 10012Similar to @code{__builtin_inf}, except the return type is @code{float}. 10013This function is suitable for implementing the ISO C99 macro @code{INFINITY}. 10014@end deftypefn 10015 10016@deftypefn {Built-in Function} {long double} __builtin_infl (void) 10017Similar to @code{__builtin_inf}, except the return 10018type is @code{long double}. 10019@end deftypefn 10020 10021@deftypefn {Built-in Function} int __builtin_isinf_sign (...) 10022Similar to @code{isinf}, except the return value is -1 for 10023an argument of @code{-Inf} and 1 for an argument of @code{+Inf}. 10024Note while the parameter list is an 10025ellipsis, this function only accepts exactly one floating-point 10026argument. GCC treats this parameter as type-generic, which means it 10027does not do default promotion from float to double. 10028@end deftypefn 10029 10030@deftypefn {Built-in Function} double __builtin_nan (const char *str) 10031This is an implementation of the ISO C99 function @code{nan}. 10032 10033Since ISO C99 defines this function in terms of @code{strtod}, which we 10034do not implement, a description of the parsing is in order. The string 10035is parsed as by @code{strtol}; that is, the base is recognized by 10036leading @samp{0} or @samp{0x} prefixes. The number parsed is placed 10037in the significand such that the least significant bit of the number 10038is at the least significant bit of the significand. The number is 10039truncated to fit the significand field provided. The significand is 10040forced to be a quiet NaN@. 10041 10042This function, if given a string literal all of which would have been 10043consumed by @code{strtol}, is evaluated early enough that it is considered a 10044compile-time constant. 10045@end deftypefn 10046 10047@deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str) 10048Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}. 10049@end deftypefn 10050 10051@deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str) 10052Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}. 10053@end deftypefn 10054 10055@deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str) 10056Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}. 10057@end deftypefn 10058 10059@deftypefn {Built-in Function} float __builtin_nanf (const char *str) 10060Similar to @code{__builtin_nan}, except the return type is @code{float}. 10061@end deftypefn 10062 10063@deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str) 10064Similar to @code{__builtin_nan}, except the return type is @code{long double}. 10065@end deftypefn 10066 10067@deftypefn {Built-in Function} double __builtin_nans (const char *str) 10068Similar to @code{__builtin_nan}, except the significand is forced 10069to be a signaling NaN@. The @code{nans} function is proposed by 10070@uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}. 10071@end deftypefn 10072 10073@deftypefn {Built-in Function} float __builtin_nansf (const char *str) 10074Similar to @code{__builtin_nans}, except the return type is @code{float}. 10075@end deftypefn 10076 10077@deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str) 10078Similar to @code{__builtin_nans}, except the return type is @code{long double}. 10079@end deftypefn 10080 10081@deftypefn {Built-in Function} int __builtin_ffs (int x) 10082Returns one plus the index of the least significant 1-bit of @var{x}, or 10083if @var{x} is zero, returns zero. 10084@end deftypefn 10085 10086@deftypefn {Built-in Function} int __builtin_clz (unsigned int x) 10087Returns the number of leading 0-bits in @var{x}, starting at the most 10088significant bit position. If @var{x} is 0, the result is undefined. 10089@end deftypefn 10090 10091@deftypefn {Built-in Function} int __builtin_ctz (unsigned int x) 10092Returns the number of trailing 0-bits in @var{x}, starting at the least 10093significant bit position. If @var{x} is 0, the result is undefined. 10094@end deftypefn 10095 10096@deftypefn {Built-in Function} int __builtin_clrsb (int x) 10097Returns the number of leading redundant sign bits in @var{x}, i.e.@: the 10098number of bits following the most significant bit that are identical 10099to it. There are no special cases for 0 or other values. 10100@end deftypefn 10101 10102@deftypefn {Built-in Function} int __builtin_popcount (unsigned int x) 10103Returns the number of 1-bits in @var{x}. 10104@end deftypefn 10105 10106@deftypefn {Built-in Function} int __builtin_parity (unsigned int x) 10107Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x} 10108modulo 2. 10109@end deftypefn 10110 10111@deftypefn {Built-in Function} int __builtin_ffsl (long) 10112Similar to @code{__builtin_ffs}, except the argument type is 10113@code{long}. 10114@end deftypefn 10115 10116@deftypefn {Built-in Function} int __builtin_clzl (unsigned long) 10117Similar to @code{__builtin_clz}, except the argument type is 10118@code{unsigned long}. 10119@end deftypefn 10120 10121@deftypefn {Built-in Function} int __builtin_ctzl (unsigned long) 10122Similar to @code{__builtin_ctz}, except the argument type is 10123@code{unsigned long}. 10124@end deftypefn 10125 10126@deftypefn {Built-in Function} int __builtin_clrsbl (long) 10127Similar to @code{__builtin_clrsb}, except the argument type is 10128@code{long}. 10129@end deftypefn 10130 10131@deftypefn {Built-in Function} int __builtin_popcountl (unsigned long) 10132Similar to @code{__builtin_popcount}, except the argument type is 10133@code{unsigned long}. 10134@end deftypefn 10135 10136@deftypefn {Built-in Function} int __builtin_parityl (unsigned long) 10137Similar to @code{__builtin_parity}, except the argument type is 10138@code{unsigned long}. 10139@end deftypefn 10140 10141@deftypefn {Built-in Function} int __builtin_ffsll (long long) 10142Similar to @code{__builtin_ffs}, except the argument type is 10143@code{long long}. 10144@end deftypefn 10145 10146@deftypefn {Built-in Function} int __builtin_clzll (unsigned long long) 10147Similar to @code{__builtin_clz}, except the argument type is 10148@code{unsigned long long}. 10149@end deftypefn 10150 10151@deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long) 10152Similar to @code{__builtin_ctz}, except the argument type is 10153@code{unsigned long long}. 10154@end deftypefn 10155 10156@deftypefn {Built-in Function} int __builtin_clrsbll (long long) 10157Similar to @code{__builtin_clrsb}, except the argument type is 10158@code{long long}. 10159@end deftypefn 10160 10161@deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long) 10162Similar to @code{__builtin_popcount}, except the argument type is 10163@code{unsigned long long}. 10164@end deftypefn 10165 10166@deftypefn {Built-in Function} int __builtin_parityll (unsigned long long) 10167Similar to @code{__builtin_parity}, except the argument type is 10168@code{unsigned long long}. 10169@end deftypefn 10170 10171@deftypefn {Built-in Function} double __builtin_powi (double, int) 10172Returns the first argument raised to the power of the second. Unlike the 10173@code{pow} function no guarantees about precision and rounding are made. 10174@end deftypefn 10175 10176@deftypefn {Built-in Function} float __builtin_powif (float, int) 10177Similar to @code{__builtin_powi}, except the argument and return types 10178are @code{float}. 10179@end deftypefn 10180 10181@deftypefn {Built-in Function} {long double} __builtin_powil (long double, int) 10182Similar to @code{__builtin_powi}, except the argument and return types 10183are @code{long double}. 10184@end deftypefn 10185 10186@deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x) 10187Returns @var{x} with the order of the bytes reversed; for example, 10188@code{0xaabb} becomes @code{0xbbaa}. Byte here always means 10189exactly 8 bits. 10190@end deftypefn 10191 10192@deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x) 10193Similar to @code{__builtin_bswap16}, except the argument and return types 10194are 32 bit. 10195@end deftypefn 10196 10197@deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x) 10198Similar to @code{__builtin_bswap32}, except the argument and return types 10199are 64 bit. 10200@end deftypefn 10201 10202@node Target Builtins 10203@section Built-in Functions Specific to Particular Target Machines 10204 10205On some target machines, GCC supports many built-in functions specific 10206to those machines. Generally these generate calls to specific machine 10207instructions, but allow the compiler to schedule those calls. 10208 10209@menu 10210* AArch64 Built-in Functions:: 10211* Alpha Built-in Functions:: 10212* Altera Nios II Built-in Functions:: 10213* ARC Built-in Functions:: 10214* ARC SIMD Built-in Functions:: 10215* ARM iWMMXt Built-in Functions:: 10216* ARM C Language Extensions (ACLE):: 10217* ARM Floating Point Status and Control Intrinsics:: 10218* AVR Built-in Functions:: 10219* Blackfin Built-in Functions:: 10220* FR-V Built-in Functions:: 10221* MIPS DSP Built-in Functions:: 10222* MIPS Paired-Single Support:: 10223* MIPS Loongson Built-in Functions:: 10224* Other MIPS Built-in Functions:: 10225* MSP430 Built-in Functions:: 10226* NDS32 Built-in Functions:: 10227* picoChip Built-in Functions:: 10228* PowerPC Built-in Functions:: 10229* PowerPC AltiVec/VSX Built-in Functions:: 10230* PowerPC Hardware Transactional Memory Built-in Functions:: 10231* RX Built-in Functions:: 10232* S/390 System z Built-in Functions:: 10233* SH Built-in Functions:: 10234* SPARC VIS Built-in Functions:: 10235* SPU Built-in Functions:: 10236* TI C6X Built-in Functions:: 10237* TILE-Gx Built-in Functions:: 10238* TILEPro Built-in Functions:: 10239* x86 Built-in Functions:: 10240* x86 transactional memory intrinsics:: 10241@end menu 10242 10243@node AArch64 Built-in Functions 10244@subsection AArch64 Built-in Functions 10245 10246These built-in functions are available for the AArch64 family of 10247processors. 10248@smallexample 10249unsigned int __builtin_aarch64_get_fpcr () 10250void __builtin_aarch64_set_fpcr (unsigned int) 10251unsigned int __builtin_aarch64_get_fpsr () 10252void __builtin_aarch64_set_fpsr (unsigned int) 10253@end smallexample 10254 10255@node Alpha Built-in Functions 10256@subsection Alpha Built-in Functions 10257 10258These built-in functions are available for the Alpha family of 10259processors, depending on the command-line switches used. 10260 10261The following built-in functions are always available. They 10262all generate the machine instruction that is part of the name. 10263 10264@smallexample 10265long __builtin_alpha_implver (void) 10266long __builtin_alpha_rpcc (void) 10267long __builtin_alpha_amask (long) 10268long __builtin_alpha_cmpbge (long, long) 10269long __builtin_alpha_extbl (long, long) 10270long __builtin_alpha_extwl (long, long) 10271long __builtin_alpha_extll (long, long) 10272long __builtin_alpha_extql (long, long) 10273long __builtin_alpha_extwh (long, long) 10274long __builtin_alpha_extlh (long, long) 10275long __builtin_alpha_extqh (long, long) 10276long __builtin_alpha_insbl (long, long) 10277long __builtin_alpha_inswl (long, long) 10278long __builtin_alpha_insll (long, long) 10279long __builtin_alpha_insql (long, long) 10280long __builtin_alpha_inswh (long, long) 10281long __builtin_alpha_inslh (long, long) 10282long __builtin_alpha_insqh (long, long) 10283long __builtin_alpha_mskbl (long, long) 10284long __builtin_alpha_mskwl (long, long) 10285long __builtin_alpha_mskll (long, long) 10286long __builtin_alpha_mskql (long, long) 10287long __builtin_alpha_mskwh (long, long) 10288long __builtin_alpha_msklh (long, long) 10289long __builtin_alpha_mskqh (long, long) 10290long __builtin_alpha_umulh (long, long) 10291long __builtin_alpha_zap (long, long) 10292long __builtin_alpha_zapnot (long, long) 10293@end smallexample 10294 10295The following built-in functions are always with @option{-mmax} 10296or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or 10297later. They all generate the machine instruction that is part 10298of the name. 10299 10300@smallexample 10301long __builtin_alpha_pklb (long) 10302long __builtin_alpha_pkwb (long) 10303long __builtin_alpha_unpkbl (long) 10304long __builtin_alpha_unpkbw (long) 10305long __builtin_alpha_minub8 (long, long) 10306long __builtin_alpha_minsb8 (long, long) 10307long __builtin_alpha_minuw4 (long, long) 10308long __builtin_alpha_minsw4 (long, long) 10309long __builtin_alpha_maxub8 (long, long) 10310long __builtin_alpha_maxsb8 (long, long) 10311long __builtin_alpha_maxuw4 (long, long) 10312long __builtin_alpha_maxsw4 (long, long) 10313long __builtin_alpha_perr (long, long) 10314@end smallexample 10315 10316The following built-in functions are always with @option{-mcix} 10317or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or 10318later. They all generate the machine instruction that is part 10319of the name. 10320 10321@smallexample 10322long __builtin_alpha_cttz (long) 10323long __builtin_alpha_ctlz (long) 10324long __builtin_alpha_ctpop (long) 10325@end smallexample 10326 10327The following built-in functions are available on systems that use the OSF/1 10328PALcode. Normally they invoke the @code{rduniq} and @code{wruniq} 10329PAL calls, but when invoked with @option{-mtls-kernel}, they invoke 10330@code{rdval} and @code{wrval}. 10331 10332@smallexample 10333void *__builtin_thread_pointer (void) 10334void __builtin_set_thread_pointer (void *) 10335@end smallexample 10336 10337@node Altera Nios II Built-in Functions 10338@subsection Altera Nios II Built-in Functions 10339 10340These built-in functions are available for the Altera Nios II 10341family of processors. 10342 10343The following built-in functions are always available. They 10344all generate the machine instruction that is part of the name. 10345 10346@example 10347int __builtin_ldbio (volatile const void *) 10348int __builtin_ldbuio (volatile const void *) 10349int __builtin_ldhio (volatile const void *) 10350int __builtin_ldhuio (volatile const void *) 10351int __builtin_ldwio (volatile const void *) 10352void __builtin_stbio (volatile void *, int) 10353void __builtin_sthio (volatile void *, int) 10354void __builtin_stwio (volatile void *, int) 10355void __builtin_sync (void) 10356int __builtin_rdctl (int) 10357void __builtin_wrctl (int, int) 10358@end example 10359 10360The following built-in functions are always available. They 10361all generate a Nios II Custom Instruction. The name of the 10362function represents the types that the function takes and 10363returns. The letter before the @code{n} is the return type 10364or void if absent. The @code{n} represents the first parameter 10365to all the custom instructions, the custom instruction number. 10366The two letters after the @code{n} represent the up to two 10367parameters to the function. 10368 10369The letters represent the following data types: 10370@table @code 10371@item <no letter> 10372@code{void} for return type and no parameter for parameter types. 10373 10374@item i 10375@code{int} for return type and parameter type 10376 10377@item f 10378@code{float} for return type and parameter type 10379 10380@item p 10381@code{void *} for return type and parameter type 10382 10383@end table 10384 10385And the function names are: 10386@example 10387void __builtin_custom_n (void) 10388void __builtin_custom_ni (int) 10389void __builtin_custom_nf (float) 10390void __builtin_custom_np (void *) 10391void __builtin_custom_nii (int, int) 10392void __builtin_custom_nif (int, float) 10393void __builtin_custom_nip (int, void *) 10394void __builtin_custom_nfi (float, int) 10395void __builtin_custom_nff (float, float) 10396void __builtin_custom_nfp (float, void *) 10397void __builtin_custom_npi (void *, int) 10398void __builtin_custom_npf (void *, float) 10399void __builtin_custom_npp (void *, void *) 10400int __builtin_custom_in (void) 10401int __builtin_custom_ini (int) 10402int __builtin_custom_inf (float) 10403int __builtin_custom_inp (void *) 10404int __builtin_custom_inii (int, int) 10405int __builtin_custom_inif (int, float) 10406int __builtin_custom_inip (int, void *) 10407int __builtin_custom_infi (float, int) 10408int __builtin_custom_inff (float, float) 10409int __builtin_custom_infp (float, void *) 10410int __builtin_custom_inpi (void *, int) 10411int __builtin_custom_inpf (void *, float) 10412int __builtin_custom_inpp (void *, void *) 10413float __builtin_custom_fn (void) 10414float __builtin_custom_fni (int) 10415float __builtin_custom_fnf (float) 10416float __builtin_custom_fnp (void *) 10417float __builtin_custom_fnii (int, int) 10418float __builtin_custom_fnif (int, float) 10419float __builtin_custom_fnip (int, void *) 10420float __builtin_custom_fnfi (float, int) 10421float __builtin_custom_fnff (float, float) 10422float __builtin_custom_fnfp (float, void *) 10423float __builtin_custom_fnpi (void *, int) 10424float __builtin_custom_fnpf (void *, float) 10425float __builtin_custom_fnpp (void *, void *) 10426void * __builtin_custom_pn (void) 10427void * __builtin_custom_pni (int) 10428void * __builtin_custom_pnf (float) 10429void * __builtin_custom_pnp (void *) 10430void * __builtin_custom_pnii (int, int) 10431void * __builtin_custom_pnif (int, float) 10432void * __builtin_custom_pnip (int, void *) 10433void * __builtin_custom_pnfi (float, int) 10434void * __builtin_custom_pnff (float, float) 10435void * __builtin_custom_pnfp (float, void *) 10436void * __builtin_custom_pnpi (void *, int) 10437void * __builtin_custom_pnpf (void *, float) 10438void * __builtin_custom_pnpp (void *, void *) 10439@end example 10440 10441@node ARC Built-in Functions 10442@subsection ARC Built-in Functions 10443 10444The following built-in functions are provided for ARC targets. The 10445built-ins generate the corresponding assembly instructions. In the 10446examples given below, the generated code often requires an operand or 10447result to be in a register. Where necessary further code will be 10448generated to ensure this is true, but for brevity this is not 10449described in each case. 10450 10451@emph{Note:} Using a built-in to generate an instruction not supported 10452by a target may cause problems. At present the compiler is not 10453guaranteed to detect such misuse, and as a result an internal compiler 10454error may be generated. 10455 10456@deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval}) 10457Return 1 if @var{val} is known to have the byte alignment given 10458by @var{alignval}, otherwise return 0. 10459Note that this is different from 10460@smallexample 10461__alignof__(*(char *)@var{val}) >= alignval 10462@end smallexample 10463because __alignof__ sees only the type of the dereference, whereas 10464__builtin_arc_align uses alignment information from the pointer 10465as well as from the pointed-to type. 10466The information available will depend on optimization level. 10467@end deftypefn 10468 10469@deftypefn {Built-in Function} void __builtin_arc_brk (void) 10470Generates 10471@example 10472brk 10473@end example 10474@end deftypefn 10475 10476@deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno}) 10477The operand is the number of a register to be read. Generates: 10478@example 10479mov @var{dest}, r@var{regno} 10480@end example 10481where the value in @var{dest} will be the result returned from the 10482built-in. 10483@end deftypefn 10484 10485@deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val}) 10486The first operand is the number of a register to be written, the 10487second operand is a compile time constant to write into that 10488register. Generates: 10489@example 10490mov r@var{regno}, @var{val} 10491@end example 10492@end deftypefn 10493 10494@deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b}) 10495Only available if either @option{-mcpu=ARC700} or @option{-meA} is set. 10496Generates: 10497@example 10498divaw @var{dest}, @var{a}, @var{b} 10499@end example 10500where the value in @var{dest} will be the result returned from the 10501built-in. 10502@end deftypefn 10503 10504@deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a}) 10505Generates 10506@example 10507flag @var{a} 10508@end example 10509@end deftypefn 10510 10511@deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr}) 10512The operand, @var{auxv}, is the address of an auxiliary register and 10513must be a compile time constant. Generates: 10514@example 10515lr @var{dest}, [@var{auxr}] 10516@end example 10517Where the value in @var{dest} will be the result returned from the 10518built-in. 10519@end deftypefn 10520 10521@deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b}) 10522Only available with @option{-mmul64}. Generates: 10523@example 10524mul64 @var{a}, @var{b} 10525@end example 10526@end deftypefn 10527 10528@deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b}) 10529Only available with @option{-mmul64}. Generates: 10530@example 10531mulu64 @var{a}, @var{b} 10532@end example 10533@end deftypefn 10534 10535@deftypefn {Built-in Function} void __builtin_arc_nop (void) 10536Generates: 10537@example 10538nop 10539@end example 10540@end deftypefn 10541 10542@deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src}) 10543Only valid if the @samp{norm} instruction is available through the 10544@option{-mnorm} option or by default with @option{-mcpu=ARC700}. 10545Generates: 10546@example 10547norm @var{dest}, @var{src} 10548@end example 10549Where the value in @var{dest} will be the result returned from the 10550built-in. 10551@end deftypefn 10552 10553@deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src}) 10554Only valid if the @samp{normw} instruction is available through the 10555@option{-mnorm} option or by default with @option{-mcpu=ARC700}. 10556Generates: 10557@example 10558normw @var{dest}, @var{src} 10559@end example 10560Where the value in @var{dest} will be the result returned from the 10561built-in. 10562@end deftypefn 10563 10564@deftypefn {Built-in Function} void __builtin_arc_rtie (void) 10565Generates: 10566@example 10567rtie 10568@end example 10569@end deftypefn 10570 10571@deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a} 10572Generates: 10573@example 10574sleep @var{a} 10575@end example 10576@end deftypefn 10577 10578@deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val}) 10579The first argument, @var{auxv}, is the address of an auxiliary 10580register, the second argument, @var{val}, is a compile time constant 10581to be written to the register. Generates: 10582@example 10583sr @var{auxr}, [@var{val}] 10584@end example 10585@end deftypefn 10586 10587@deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src}) 10588Only valid with @option{-mswap}. Generates: 10589@example 10590swap @var{dest}, @var{src} 10591@end example 10592Where the value in @var{dest} will be the result returned from the 10593built-in. 10594@end deftypefn 10595 10596@deftypefn {Built-in Function} void __builtin_arc_swi (void) 10597Generates: 10598@example 10599swi 10600@end example 10601@end deftypefn 10602 10603@deftypefn {Built-in Function} void __builtin_arc_sync (void) 10604Only available with @option{-mcpu=ARC700}. Generates: 10605@example 10606sync 10607@end example 10608@end deftypefn 10609 10610@deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c}) 10611Only available with @option{-mcpu=ARC700}. Generates: 10612@example 10613trap_s @var{c} 10614@end example 10615@end deftypefn 10616 10617@deftypefn {Built-in Function} void __builtin_arc_unimp_s (void) 10618Only available with @option{-mcpu=ARC700}. Generates: 10619@example 10620unimp_s 10621@end example 10622@end deftypefn 10623 10624The instructions generated by the following builtins are not 10625considered as candidates for scheduling. They are not moved around by 10626the compiler during scheduling, and thus can be expected to appear 10627where they are put in the C code: 10628@example 10629__builtin_arc_brk() 10630__builtin_arc_core_read() 10631__builtin_arc_core_write() 10632__builtin_arc_flag() 10633__builtin_arc_lr() 10634__builtin_arc_sleep() 10635__builtin_arc_sr() 10636__builtin_arc_swi() 10637@end example 10638 10639@node ARC SIMD Built-in Functions 10640@subsection ARC SIMD Built-in Functions 10641 10642SIMD builtins provided by the compiler can be used to generate the 10643vector instructions. This section describes the available builtins 10644and their usage in programs. With the @option{-msimd} option, the 10645compiler provides 128-bit vector types, which can be specified using 10646the @code{vector_size} attribute. The header file @file{arc-simd.h} 10647can be included to use the following predefined types: 10648@example 10649typedef int __v4si __attribute__((vector_size(16))); 10650typedef short __v8hi __attribute__((vector_size(16))); 10651@end example 10652 10653These types can be used to define 128-bit variables. The built-in 10654functions listed in the following section can be used on these 10655variables to generate the vector operations. 10656 10657For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file 10658@file{arc-simd.h} also provides equivalent macros called 10659@code{_@var{someinsn}} that can be used for programming ease and 10660improved readability. The following macros for DMA control are also 10661provided: 10662@example 10663#define _setup_dma_in_channel_reg _vdiwr 10664#define _setup_dma_out_channel_reg _vdowr 10665@end example 10666 10667The following is a complete list of all the SIMD built-ins provided 10668for ARC, grouped by calling signature. 10669 10670The following take two @code{__v8hi} arguments and return a 10671@code{__v8hi} result: 10672@example 10673__v8hi __builtin_arc_vaddaw (__v8hi, __v8hi) 10674__v8hi __builtin_arc_vaddw (__v8hi, __v8hi) 10675__v8hi __builtin_arc_vand (__v8hi, __v8hi) 10676__v8hi __builtin_arc_vandaw (__v8hi, __v8hi) 10677__v8hi __builtin_arc_vavb (__v8hi, __v8hi) 10678__v8hi __builtin_arc_vavrb (__v8hi, __v8hi) 10679__v8hi __builtin_arc_vbic (__v8hi, __v8hi) 10680__v8hi __builtin_arc_vbicaw (__v8hi, __v8hi) 10681__v8hi __builtin_arc_vdifaw (__v8hi, __v8hi) 10682__v8hi __builtin_arc_vdifw (__v8hi, __v8hi) 10683__v8hi __builtin_arc_veqw (__v8hi, __v8hi) 10684__v8hi __builtin_arc_vh264f (__v8hi, __v8hi) 10685__v8hi __builtin_arc_vh264ft (__v8hi, __v8hi) 10686__v8hi __builtin_arc_vh264fw (__v8hi, __v8hi) 10687__v8hi __builtin_arc_vlew (__v8hi, __v8hi) 10688__v8hi __builtin_arc_vltw (__v8hi, __v8hi) 10689__v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi) 10690__v8hi __builtin_arc_vmaxw (__v8hi, __v8hi) 10691__v8hi __builtin_arc_vminaw (__v8hi, __v8hi) 10692__v8hi __builtin_arc_vminw (__v8hi, __v8hi) 10693__v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi) 10694__v8hi __builtin_arc_vmr1w (__v8hi, __v8hi) 10695__v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi) 10696__v8hi __builtin_arc_vmr2w (__v8hi, __v8hi) 10697__v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi) 10698__v8hi __builtin_arc_vmr3w (__v8hi, __v8hi) 10699__v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi) 10700__v8hi __builtin_arc_vmr4w (__v8hi, __v8hi) 10701__v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi) 10702__v8hi __builtin_arc_vmr5w (__v8hi, __v8hi) 10703__v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi) 10704__v8hi __builtin_arc_vmr6w (__v8hi, __v8hi) 10705__v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi) 10706__v8hi __builtin_arc_vmr7w (__v8hi, __v8hi) 10707__v8hi __builtin_arc_vmrb (__v8hi, __v8hi) 10708__v8hi __builtin_arc_vmulaw (__v8hi, __v8hi) 10709__v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi) 10710__v8hi __builtin_arc_vmulfw (__v8hi, __v8hi) 10711__v8hi __builtin_arc_vmulw (__v8hi, __v8hi) 10712__v8hi __builtin_arc_vnew (__v8hi, __v8hi) 10713__v8hi __builtin_arc_vor (__v8hi, __v8hi) 10714__v8hi __builtin_arc_vsubaw (__v8hi, __v8hi) 10715__v8hi __builtin_arc_vsubw (__v8hi, __v8hi) 10716__v8hi __builtin_arc_vsummw (__v8hi, __v8hi) 10717__v8hi __builtin_arc_vvc1f (__v8hi, __v8hi) 10718__v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi) 10719__v8hi __builtin_arc_vxor (__v8hi, __v8hi) 10720__v8hi __builtin_arc_vxoraw (__v8hi, __v8hi) 10721@end example 10722 10723The following take one @code{__v8hi} and one @code{int} argument and return a 10724@code{__v8hi} result: 10725 10726@example 10727__v8hi __builtin_arc_vbaddw (__v8hi, int) 10728__v8hi __builtin_arc_vbmaxw (__v8hi, int) 10729__v8hi __builtin_arc_vbminw (__v8hi, int) 10730__v8hi __builtin_arc_vbmulaw (__v8hi, int) 10731__v8hi __builtin_arc_vbmulfw (__v8hi, int) 10732__v8hi __builtin_arc_vbmulw (__v8hi, int) 10733__v8hi __builtin_arc_vbrsubw (__v8hi, int) 10734__v8hi __builtin_arc_vbsubw (__v8hi, int) 10735@end example 10736 10737The following take one @code{__v8hi} argument and one @code{int} argument which 10738must be a 3-bit compile time constant indicating a register number 10739I0-I7. They return a @code{__v8hi} result. 10740@example 10741__v8hi __builtin_arc_vasrw (__v8hi, const int) 10742__v8hi __builtin_arc_vsr8 (__v8hi, const int) 10743__v8hi __builtin_arc_vsr8aw (__v8hi, const int) 10744@end example 10745 10746The following take one @code{__v8hi} argument and one @code{int} 10747argument which must be a 6-bit compile time constant. They return a 10748@code{__v8hi} result. 10749@example 10750__v8hi __builtin_arc_vasrpwbi (__v8hi, const int) 10751__v8hi __builtin_arc_vasrrpwbi (__v8hi, const int) 10752__v8hi __builtin_arc_vasrrwi (__v8hi, const int) 10753__v8hi __builtin_arc_vasrsrwi (__v8hi, const int) 10754__v8hi __builtin_arc_vasrwi (__v8hi, const int) 10755__v8hi __builtin_arc_vsr8awi (__v8hi, const int) 10756__v8hi __builtin_arc_vsr8i (__v8hi, const int) 10757@end example 10758 10759The following take one @code{__v8hi} argument and one @code{int} argument which 10760must be a 8-bit compile time constant. They return a @code{__v8hi} 10761result. 10762@example 10763__v8hi __builtin_arc_vd6tapf (__v8hi, const int) 10764__v8hi __builtin_arc_vmvaw (__v8hi, const int) 10765__v8hi __builtin_arc_vmvw (__v8hi, const int) 10766__v8hi __builtin_arc_vmvzw (__v8hi, const int) 10767@end example 10768 10769The following take two @code{int} arguments, the second of which which 10770must be a 8-bit compile time constant. They return a @code{__v8hi} 10771result: 10772@example 10773__v8hi __builtin_arc_vmovaw (int, const int) 10774__v8hi __builtin_arc_vmovw (int, const int) 10775__v8hi __builtin_arc_vmovzw (int, const int) 10776@end example 10777 10778The following take a single @code{__v8hi} argument and return a 10779@code{__v8hi} result: 10780@example 10781__v8hi __builtin_arc_vabsaw (__v8hi) 10782__v8hi __builtin_arc_vabsw (__v8hi) 10783__v8hi __builtin_arc_vaddsuw (__v8hi) 10784__v8hi __builtin_arc_vexch1 (__v8hi) 10785__v8hi __builtin_arc_vexch2 (__v8hi) 10786__v8hi __builtin_arc_vexch4 (__v8hi) 10787__v8hi __builtin_arc_vsignw (__v8hi) 10788__v8hi __builtin_arc_vupbaw (__v8hi) 10789__v8hi __builtin_arc_vupbw (__v8hi) 10790__v8hi __builtin_arc_vupsbaw (__v8hi) 10791__v8hi __builtin_arc_vupsbw (__v8hi) 10792@end example 10793 10794The following take two @code{int} arguments and return no result: 10795@example 10796void __builtin_arc_vdirun (int, int) 10797void __builtin_arc_vdorun (int, int) 10798@end example 10799 10800The following take two @code{int} arguments and return no result. The 10801first argument must a 3-bit compile time constant indicating one of 10802the DR0-DR7 DMA setup channels: 10803@example 10804void __builtin_arc_vdiwr (const int, int) 10805void __builtin_arc_vdowr (const int, int) 10806@end example 10807 10808The following take an @code{int} argument and return no result: 10809@example 10810void __builtin_arc_vendrec (int) 10811void __builtin_arc_vrec (int) 10812void __builtin_arc_vrecrun (int) 10813void __builtin_arc_vrun (int) 10814@end example 10815 10816The following take a @code{__v8hi} argument and two @code{int} 10817arguments and return a @code{__v8hi} result. The second argument must 10818be a 3-bit compile time constants, indicating one the registers I0-I7, 10819and the third argument must be an 8-bit compile time constant. 10820 10821@emph{Note:} Although the equivalent hardware instructions do not take 10822an SIMD register as an operand, these builtins overwrite the relevant 10823bits of the @code{__v8hi} register provided as the first argument with 10824the value loaded from the @code{[Ib, u8]} location in the SDM. 10825 10826@example 10827__v8hi __builtin_arc_vld32 (__v8hi, const int, const int) 10828__v8hi __builtin_arc_vld32wh (__v8hi, const int, const int) 10829__v8hi __builtin_arc_vld32wl (__v8hi, const int, const int) 10830__v8hi __builtin_arc_vld64 (__v8hi, const int, const int) 10831@end example 10832 10833The following take two @code{int} arguments and return a @code{__v8hi} 10834result. The first argument must be a 3-bit compile time constants, 10835indicating one the registers I0-I7, and the second argument must be an 108368-bit compile time constant. 10837 10838@example 10839__v8hi __builtin_arc_vld128 (const int, const int) 10840__v8hi __builtin_arc_vld64w (const int, const int) 10841@end example 10842 10843The following take a @code{__v8hi} argument and two @code{int} 10844arguments and return no result. The second argument must be a 3-bit 10845compile time constants, indicating one the registers I0-I7, and the 10846third argument must be an 8-bit compile time constant. 10847 10848@example 10849void __builtin_arc_vst128 (__v8hi, const int, const int) 10850void __builtin_arc_vst64 (__v8hi, const int, const int) 10851@end example 10852 10853The following take a @code{__v8hi} argument and three @code{int} 10854arguments and return no result. The second argument must be a 3-bit 10855compile-time constant, identifying the 16-bit sub-register to be 10856stored, the third argument must be a 3-bit compile time constants, 10857indicating one the registers I0-I7, and the fourth argument must be an 108588-bit compile time constant. 10859 10860@example 10861void __builtin_arc_vst16_n (__v8hi, const int, const int, const int) 10862void __builtin_arc_vst32_n (__v8hi, const int, const int, const int) 10863@end example 10864 10865@node ARM iWMMXt Built-in Functions 10866@subsection ARM iWMMXt Built-in Functions 10867 10868These built-in functions are available for the ARM family of 10869processors when the @option{-mcpu=iwmmxt} switch is used: 10870 10871@smallexample 10872typedef int v2si __attribute__ ((vector_size (8))); 10873typedef short v4hi __attribute__ ((vector_size (8))); 10874typedef char v8qi __attribute__ ((vector_size (8))); 10875 10876int __builtin_arm_getwcgr0 (void) 10877void __builtin_arm_setwcgr0 (int) 10878int __builtin_arm_getwcgr1 (void) 10879void __builtin_arm_setwcgr1 (int) 10880int __builtin_arm_getwcgr2 (void) 10881void __builtin_arm_setwcgr2 (int) 10882int __builtin_arm_getwcgr3 (void) 10883void __builtin_arm_setwcgr3 (int) 10884int __builtin_arm_textrmsb (v8qi, int) 10885int __builtin_arm_textrmsh (v4hi, int) 10886int __builtin_arm_textrmsw (v2si, int) 10887int __builtin_arm_textrmub (v8qi, int) 10888int __builtin_arm_textrmuh (v4hi, int) 10889int __builtin_arm_textrmuw (v2si, int) 10890v8qi __builtin_arm_tinsrb (v8qi, int, int) 10891v4hi __builtin_arm_tinsrh (v4hi, int, int) 10892v2si __builtin_arm_tinsrw (v2si, int, int) 10893long long __builtin_arm_tmia (long long, int, int) 10894long long __builtin_arm_tmiabb (long long, int, int) 10895long long __builtin_arm_tmiabt (long long, int, int) 10896long long __builtin_arm_tmiaph (long long, int, int) 10897long long __builtin_arm_tmiatb (long long, int, int) 10898long long __builtin_arm_tmiatt (long long, int, int) 10899int __builtin_arm_tmovmskb (v8qi) 10900int __builtin_arm_tmovmskh (v4hi) 10901int __builtin_arm_tmovmskw (v2si) 10902long long __builtin_arm_waccb (v8qi) 10903long long __builtin_arm_wacch (v4hi) 10904long long __builtin_arm_waccw (v2si) 10905v8qi __builtin_arm_waddb (v8qi, v8qi) 10906v8qi __builtin_arm_waddbss (v8qi, v8qi) 10907v8qi __builtin_arm_waddbus (v8qi, v8qi) 10908v4hi __builtin_arm_waddh (v4hi, v4hi) 10909v4hi __builtin_arm_waddhss (v4hi, v4hi) 10910v4hi __builtin_arm_waddhus (v4hi, v4hi) 10911v2si __builtin_arm_waddw (v2si, v2si) 10912v2si __builtin_arm_waddwss (v2si, v2si) 10913v2si __builtin_arm_waddwus (v2si, v2si) 10914v8qi __builtin_arm_walign (v8qi, v8qi, int) 10915long long __builtin_arm_wand(long long, long long) 10916long long __builtin_arm_wandn (long long, long long) 10917v8qi __builtin_arm_wavg2b (v8qi, v8qi) 10918v8qi __builtin_arm_wavg2br (v8qi, v8qi) 10919v4hi __builtin_arm_wavg2h (v4hi, v4hi) 10920v4hi __builtin_arm_wavg2hr (v4hi, v4hi) 10921v8qi __builtin_arm_wcmpeqb (v8qi, v8qi) 10922v4hi __builtin_arm_wcmpeqh (v4hi, v4hi) 10923v2si __builtin_arm_wcmpeqw (v2si, v2si) 10924v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi) 10925v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi) 10926v2si __builtin_arm_wcmpgtsw (v2si, v2si) 10927v8qi __builtin_arm_wcmpgtub (v8qi, v8qi) 10928v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi) 10929v2si __builtin_arm_wcmpgtuw (v2si, v2si) 10930long long __builtin_arm_wmacs (long long, v4hi, v4hi) 10931long long __builtin_arm_wmacsz (v4hi, v4hi) 10932long long __builtin_arm_wmacu (long long, v4hi, v4hi) 10933long long __builtin_arm_wmacuz (v4hi, v4hi) 10934v4hi __builtin_arm_wmadds (v4hi, v4hi) 10935v4hi __builtin_arm_wmaddu (v4hi, v4hi) 10936v8qi __builtin_arm_wmaxsb (v8qi, v8qi) 10937v4hi __builtin_arm_wmaxsh (v4hi, v4hi) 10938v2si __builtin_arm_wmaxsw (v2si, v2si) 10939v8qi __builtin_arm_wmaxub (v8qi, v8qi) 10940v4hi __builtin_arm_wmaxuh (v4hi, v4hi) 10941v2si __builtin_arm_wmaxuw (v2si, v2si) 10942v8qi __builtin_arm_wminsb (v8qi, v8qi) 10943v4hi __builtin_arm_wminsh (v4hi, v4hi) 10944v2si __builtin_arm_wminsw (v2si, v2si) 10945v8qi __builtin_arm_wminub (v8qi, v8qi) 10946v4hi __builtin_arm_wminuh (v4hi, v4hi) 10947v2si __builtin_arm_wminuw (v2si, v2si) 10948v4hi __builtin_arm_wmulsm (v4hi, v4hi) 10949v4hi __builtin_arm_wmulul (v4hi, v4hi) 10950v4hi __builtin_arm_wmulum (v4hi, v4hi) 10951long long __builtin_arm_wor (long long, long long) 10952v2si __builtin_arm_wpackdss (long long, long long) 10953v2si __builtin_arm_wpackdus (long long, long long) 10954v8qi __builtin_arm_wpackhss (v4hi, v4hi) 10955v8qi __builtin_arm_wpackhus (v4hi, v4hi) 10956v4hi __builtin_arm_wpackwss (v2si, v2si) 10957v4hi __builtin_arm_wpackwus (v2si, v2si) 10958long long __builtin_arm_wrord (long long, long long) 10959long long __builtin_arm_wrordi (long long, int) 10960v4hi __builtin_arm_wrorh (v4hi, long long) 10961v4hi __builtin_arm_wrorhi (v4hi, int) 10962v2si __builtin_arm_wrorw (v2si, long long) 10963v2si __builtin_arm_wrorwi (v2si, int) 10964v2si __builtin_arm_wsadb (v2si, v8qi, v8qi) 10965v2si __builtin_arm_wsadbz (v8qi, v8qi) 10966v2si __builtin_arm_wsadh (v2si, v4hi, v4hi) 10967v2si __builtin_arm_wsadhz (v4hi, v4hi) 10968v4hi __builtin_arm_wshufh (v4hi, int) 10969long long __builtin_arm_wslld (long long, long long) 10970long long __builtin_arm_wslldi (long long, int) 10971v4hi __builtin_arm_wsllh (v4hi, long long) 10972v4hi __builtin_arm_wsllhi (v4hi, int) 10973v2si __builtin_arm_wsllw (v2si, long long) 10974v2si __builtin_arm_wsllwi (v2si, int) 10975long long __builtin_arm_wsrad (long long, long long) 10976long long __builtin_arm_wsradi (long long, int) 10977v4hi __builtin_arm_wsrah (v4hi, long long) 10978v4hi __builtin_arm_wsrahi (v4hi, int) 10979v2si __builtin_arm_wsraw (v2si, long long) 10980v2si __builtin_arm_wsrawi (v2si, int) 10981long long __builtin_arm_wsrld (long long, long long) 10982long long __builtin_arm_wsrldi (long long, int) 10983v4hi __builtin_arm_wsrlh (v4hi, long long) 10984v4hi __builtin_arm_wsrlhi (v4hi, int) 10985v2si __builtin_arm_wsrlw (v2si, long long) 10986v2si __builtin_arm_wsrlwi (v2si, int) 10987v8qi __builtin_arm_wsubb (v8qi, v8qi) 10988v8qi __builtin_arm_wsubbss (v8qi, v8qi) 10989v8qi __builtin_arm_wsubbus (v8qi, v8qi) 10990v4hi __builtin_arm_wsubh (v4hi, v4hi) 10991v4hi __builtin_arm_wsubhss (v4hi, v4hi) 10992v4hi __builtin_arm_wsubhus (v4hi, v4hi) 10993v2si __builtin_arm_wsubw (v2si, v2si) 10994v2si __builtin_arm_wsubwss (v2si, v2si) 10995v2si __builtin_arm_wsubwus (v2si, v2si) 10996v4hi __builtin_arm_wunpckehsb (v8qi) 10997v2si __builtin_arm_wunpckehsh (v4hi) 10998long long __builtin_arm_wunpckehsw (v2si) 10999v4hi __builtin_arm_wunpckehub (v8qi) 11000v2si __builtin_arm_wunpckehuh (v4hi) 11001long long __builtin_arm_wunpckehuw (v2si) 11002v4hi __builtin_arm_wunpckelsb (v8qi) 11003v2si __builtin_arm_wunpckelsh (v4hi) 11004long long __builtin_arm_wunpckelsw (v2si) 11005v4hi __builtin_arm_wunpckelub (v8qi) 11006v2si __builtin_arm_wunpckeluh (v4hi) 11007long long __builtin_arm_wunpckeluw (v2si) 11008v8qi __builtin_arm_wunpckihb (v8qi, v8qi) 11009v4hi __builtin_arm_wunpckihh (v4hi, v4hi) 11010v2si __builtin_arm_wunpckihw (v2si, v2si) 11011v8qi __builtin_arm_wunpckilb (v8qi, v8qi) 11012v4hi __builtin_arm_wunpckilh (v4hi, v4hi) 11013v2si __builtin_arm_wunpckilw (v2si, v2si) 11014long long __builtin_arm_wxor (long long, long long) 11015long long __builtin_arm_wzero () 11016@end smallexample 11017 11018 11019@node ARM C Language Extensions (ACLE) 11020@subsection ARM C Language Extensions (ACLE) 11021 11022GCC implements extensions for C as described in the ARM C Language 11023Extensions (ACLE) specification, which can be found at 11024@uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}. 11025 11026As a part of ACLE, GCC implements extensions for Advanced SIMD as described in 11027the ARM C Language Extensions Specification. The complete list of Advanced SIMD 11028intrinsics can be found at 11029@uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}. 11030The built-in intrinsics for the Advanced SIMD extension are available when 11031NEON is enabled. 11032 11033Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both 11034back ends support CRC32 intrinsics from @file{arm_acle.h}. The ARM back end's 1103516-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1. 11036AArch64's back end does not have support for 16-bit floating point Advanced SIMD 11037intrinsics yet. 11038 11039See @ref{ARM Options} and @ref{AArch64 Options} for more information on the 11040availability of extensions. 11041 11042@node ARM Floating Point Status and Control Intrinsics 11043@subsection ARM Floating Point Status and Control Intrinsics 11044 11045These built-in functions are available for the ARM family of 11046processors with floating-point unit. 11047 11048@smallexample 11049unsigned int __builtin_arm_get_fpscr () 11050void __builtin_arm_set_fpscr (unsigned int) 11051@end smallexample 11052 11053@node AVR Built-in Functions 11054@subsection AVR Built-in Functions 11055 11056For each built-in function for AVR, there is an equally named, 11057uppercase built-in macro defined. That way users can easily query if 11058or if not a specific built-in is implemented or not. For example, if 11059@code{__builtin_avr_nop} is available the macro 11060@code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise. 11061 11062The following built-in functions map to the respective machine 11063instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep}, 11064@code{wdr}, @code{swap}, @code{fmul}, @code{fmuls} 11065resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented 11066as library call if no hardware multiplier is available. 11067 11068@smallexample 11069void __builtin_avr_nop (void) 11070void __builtin_avr_sei (void) 11071void __builtin_avr_cli (void) 11072void __builtin_avr_sleep (void) 11073void __builtin_avr_wdr (void) 11074unsigned char __builtin_avr_swap (unsigned char) 11075unsigned int __builtin_avr_fmul (unsigned char, unsigned char) 11076int __builtin_avr_fmuls (char, char) 11077int __builtin_avr_fmulsu (char, unsigned char) 11078@end smallexample 11079 11080In order to delay execution for a specific number of cycles, GCC 11081implements 11082@smallexample 11083void __builtin_avr_delay_cycles (unsigned long ticks) 11084@end smallexample 11085 11086@noindent 11087@code{ticks} is the number of ticks to delay execution. Note that this 11088built-in does not take into account the effect of interrupts that 11089might increase delay time. @code{ticks} must be a compile-time 11090integer constant; delays with a variable number of cycles are not supported. 11091 11092@smallexample 11093char __builtin_avr_flash_segment (const __memx void*) 11094@end smallexample 11095 11096@noindent 11097This built-in takes a byte address to the 24-bit 11098@ref{AVR Named Address Spaces,address space} @code{__memx} and returns 11099the number of the flash segment (the 64 KiB chunk) where the address 11100points to. Counting starts at @code{0}. 11101If the address does not point to flash memory, return @code{-1}. 11102 11103@smallexample 11104unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val) 11105@end smallexample 11106 11107@noindent 11108Insert bits from @var{bits} into @var{val} and return the resulting 11109value. The nibbles of @var{map} determine how the insertion is 11110performed: Let @var{X} be the @var{n}-th nibble of @var{map} 11111@enumerate 11112@item If @var{X} is @code{0xf}, 11113then the @var{n}-th bit of @var{val} is returned unaltered. 11114 11115@item If X is in the range 0@dots{}7, 11116then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits} 11117 11118@item If X is in the range 8@dots{}@code{0xe}, 11119then the @var{n}-th result bit is undefined. 11120@end enumerate 11121 11122@noindent 11123One typical use case for this built-in is adjusting input and 11124output values to non-contiguous port layouts. Some examples: 11125 11126@smallexample 11127// same as val, bits is unused 11128__builtin_avr_insert_bits (0xffffffff, bits, val) 11129@end smallexample 11130 11131@smallexample 11132// same as bits, val is unused 11133__builtin_avr_insert_bits (0x76543210, bits, val) 11134@end smallexample 11135 11136@smallexample 11137// same as rotating bits by 4 11138__builtin_avr_insert_bits (0x32107654, bits, 0) 11139@end smallexample 11140 11141@smallexample 11142// high nibble of result is the high nibble of val 11143// low nibble of result is the low nibble of bits 11144__builtin_avr_insert_bits (0xffff3210, bits, val) 11145@end smallexample 11146 11147@smallexample 11148// reverse the bit order of bits 11149__builtin_avr_insert_bits (0x01234567, bits, 0) 11150@end smallexample 11151 11152@node Blackfin Built-in Functions 11153@subsection Blackfin Built-in Functions 11154 11155Currently, there are two Blackfin-specific built-in functions. These are 11156used for generating @code{CSYNC} and @code{SSYNC} machine insns without 11157using inline assembly; by using these built-in functions the compiler can 11158automatically add workarounds for hardware errata involving these 11159instructions. These functions are named as follows: 11160 11161@smallexample 11162void __builtin_bfin_csync (void) 11163void __builtin_bfin_ssync (void) 11164@end smallexample 11165 11166@node FR-V Built-in Functions 11167@subsection FR-V Built-in Functions 11168 11169GCC provides many FR-V-specific built-in functions. In general, 11170these functions are intended to be compatible with those described 11171by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu 11172Semiconductor}. The two exceptions are @code{__MDUNPACKH} and 11173@code{__MBTOHE}, the GCC forms of which pass 128-bit values by 11174pointer rather than by value. 11175 11176Most of the functions are named after specific FR-V instructions. 11177Such functions are said to be ``directly mapped'' and are summarized 11178here in tabular form. 11179 11180@menu 11181* Argument Types:: 11182* Directly-mapped Integer Functions:: 11183* Directly-mapped Media Functions:: 11184* Raw read/write Functions:: 11185* Other Built-in Functions:: 11186@end menu 11187 11188@node Argument Types 11189@subsubsection Argument Types 11190 11191The arguments to the built-in functions can be divided into three groups: 11192register numbers, compile-time constants and run-time values. In order 11193to make this classification clear at a glance, the arguments and return 11194values are given the following pseudo types: 11195 11196@multitable @columnfractions .20 .30 .15 .35 11197@item Pseudo type @tab Real C type @tab Constant? @tab Description 11198@item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword 11199@item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word 11200@item @code{sw1} @tab @code{int} @tab No @tab a signed word 11201@item @code{uw2} @tab @code{unsigned long long} @tab No 11202@tab an unsigned doubleword 11203@item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword 11204@item @code{const} @tab @code{int} @tab Yes @tab an integer constant 11205@item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number 11206@item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number 11207@end multitable 11208 11209These pseudo types are not defined by GCC, they are simply a notational 11210convenience used in this manual. 11211 11212Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2} 11213and @code{sw2} are evaluated at run time. They correspond to 11214register operands in the underlying FR-V instructions. 11215 11216@code{const} arguments represent immediate operands in the underlying 11217FR-V instructions. They must be compile-time constants. 11218 11219@code{acc} arguments are evaluated at compile time and specify the number 11220of an accumulator register. For example, an @code{acc} argument of 2 11221selects the ACC2 register. 11222 11223@code{iacc} arguments are similar to @code{acc} arguments but specify the 11224number of an IACC register. See @pxref{Other Built-in Functions} 11225for more details. 11226 11227@node Directly-mapped Integer Functions 11228@subsubsection Directly-Mapped Integer Functions 11229 11230The functions listed below map directly to FR-V I-type instructions. 11231 11232@multitable @columnfractions .45 .32 .23 11233@item Function prototype @tab Example usage @tab Assembly output 11234@item @code{sw1 __ADDSS (sw1, sw1)} 11235@tab @code{@var{c} = __ADDSS (@var{a}, @var{b})} 11236@tab @code{ADDSS @var{a},@var{b},@var{c}} 11237@item @code{sw1 __SCAN (sw1, sw1)} 11238@tab @code{@var{c} = __SCAN (@var{a}, @var{b})} 11239@tab @code{SCAN @var{a},@var{b},@var{c}} 11240@item @code{sw1 __SCUTSS (sw1)} 11241@tab @code{@var{b} = __SCUTSS (@var{a})} 11242@tab @code{SCUTSS @var{a},@var{b}} 11243@item @code{sw1 __SLASS (sw1, sw1)} 11244@tab @code{@var{c} = __SLASS (@var{a}, @var{b})} 11245@tab @code{SLASS @var{a},@var{b},@var{c}} 11246@item @code{void __SMASS (sw1, sw1)} 11247@tab @code{__SMASS (@var{a}, @var{b})} 11248@tab @code{SMASS @var{a},@var{b}} 11249@item @code{void __SMSSS (sw1, sw1)} 11250@tab @code{__SMSSS (@var{a}, @var{b})} 11251@tab @code{SMSSS @var{a},@var{b}} 11252@item @code{void __SMU (sw1, sw1)} 11253@tab @code{__SMU (@var{a}, @var{b})} 11254@tab @code{SMU @var{a},@var{b}} 11255@item @code{sw2 __SMUL (sw1, sw1)} 11256@tab @code{@var{c} = __SMUL (@var{a}, @var{b})} 11257@tab @code{SMUL @var{a},@var{b},@var{c}} 11258@item @code{sw1 __SUBSS (sw1, sw1)} 11259@tab @code{@var{c} = __SUBSS (@var{a}, @var{b})} 11260@tab @code{SUBSS @var{a},@var{b},@var{c}} 11261@item @code{uw2 __UMUL (uw1, uw1)} 11262@tab @code{@var{c} = __UMUL (@var{a}, @var{b})} 11263@tab @code{UMUL @var{a},@var{b},@var{c}} 11264@end multitable 11265 11266@node Directly-mapped Media Functions 11267@subsubsection Directly-Mapped Media Functions 11268 11269The functions listed below map directly to FR-V M-type instructions. 11270 11271@multitable @columnfractions .45 .32 .23 11272@item Function prototype @tab Example usage @tab Assembly output 11273@item @code{uw1 __MABSHS (sw1)} 11274@tab @code{@var{b} = __MABSHS (@var{a})} 11275@tab @code{MABSHS @var{a},@var{b}} 11276@item @code{void __MADDACCS (acc, acc)} 11277@tab @code{__MADDACCS (@var{b}, @var{a})} 11278@tab @code{MADDACCS @var{a},@var{b}} 11279@item @code{sw1 __MADDHSS (sw1, sw1)} 11280@tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})} 11281@tab @code{MADDHSS @var{a},@var{b},@var{c}} 11282@item @code{uw1 __MADDHUS (uw1, uw1)} 11283@tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})} 11284@tab @code{MADDHUS @var{a},@var{b},@var{c}} 11285@item @code{uw1 __MAND (uw1, uw1)} 11286@tab @code{@var{c} = __MAND (@var{a}, @var{b})} 11287@tab @code{MAND @var{a},@var{b},@var{c}} 11288@item @code{void __MASACCS (acc, acc)} 11289@tab @code{__MASACCS (@var{b}, @var{a})} 11290@tab @code{MASACCS @var{a},@var{b}} 11291@item @code{uw1 __MAVEH (uw1, uw1)} 11292@tab @code{@var{c} = __MAVEH (@var{a}, @var{b})} 11293@tab @code{MAVEH @var{a},@var{b},@var{c}} 11294@item @code{uw2 __MBTOH (uw1)} 11295@tab @code{@var{b} = __MBTOH (@var{a})} 11296@tab @code{MBTOH @var{a},@var{b}} 11297@item @code{void __MBTOHE (uw1 *, uw1)} 11298@tab @code{__MBTOHE (&@var{b}, @var{a})} 11299@tab @code{MBTOHE @var{a},@var{b}} 11300@item @code{void __MCLRACC (acc)} 11301@tab @code{__MCLRACC (@var{a})} 11302@tab @code{MCLRACC @var{a}} 11303@item @code{void __MCLRACCA (void)} 11304@tab @code{__MCLRACCA ()} 11305@tab @code{MCLRACCA} 11306@item @code{uw1 __Mcop1 (uw1, uw1)} 11307@tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})} 11308@tab @code{Mcop1 @var{a},@var{b},@var{c}} 11309@item @code{uw1 __Mcop2 (uw1, uw1)} 11310@tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})} 11311@tab @code{Mcop2 @var{a},@var{b},@var{c}} 11312@item @code{uw1 __MCPLHI (uw2, const)} 11313@tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})} 11314@tab @code{MCPLHI @var{a},#@var{b},@var{c}} 11315@item @code{uw1 __MCPLI (uw2, const)} 11316@tab @code{@var{c} = __MCPLI (@var{a}, @var{b})} 11317@tab @code{MCPLI @var{a},#@var{b},@var{c}} 11318@item @code{void __MCPXIS (acc, sw1, sw1)} 11319@tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})} 11320@tab @code{MCPXIS @var{a},@var{b},@var{c}} 11321@item @code{void __MCPXIU (acc, uw1, uw1)} 11322@tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})} 11323@tab @code{MCPXIU @var{a},@var{b},@var{c}} 11324@item @code{void __MCPXRS (acc, sw1, sw1)} 11325@tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})} 11326@tab @code{MCPXRS @var{a},@var{b},@var{c}} 11327@item @code{void __MCPXRU (acc, uw1, uw1)} 11328@tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})} 11329@tab @code{MCPXRU @var{a},@var{b},@var{c}} 11330@item @code{uw1 __MCUT (acc, uw1)} 11331@tab @code{@var{c} = __MCUT (@var{a}, @var{b})} 11332@tab @code{MCUT @var{a},@var{b},@var{c}} 11333@item @code{uw1 __MCUTSS (acc, sw1)} 11334@tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})} 11335@tab @code{MCUTSS @var{a},@var{b},@var{c}} 11336@item @code{void __MDADDACCS (acc, acc)} 11337@tab @code{__MDADDACCS (@var{b}, @var{a})} 11338@tab @code{MDADDACCS @var{a},@var{b}} 11339@item @code{void __MDASACCS (acc, acc)} 11340@tab @code{__MDASACCS (@var{b}, @var{a})} 11341@tab @code{MDASACCS @var{a},@var{b}} 11342@item @code{uw2 __MDCUTSSI (acc, const)} 11343@tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})} 11344@tab @code{MDCUTSSI @var{a},#@var{b},@var{c}} 11345@item @code{uw2 __MDPACKH (uw2, uw2)} 11346@tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})} 11347@tab @code{MDPACKH @var{a},@var{b},@var{c}} 11348@item @code{uw2 __MDROTLI (uw2, const)} 11349@tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})} 11350@tab @code{MDROTLI @var{a},#@var{b},@var{c}} 11351@item @code{void __MDSUBACCS (acc, acc)} 11352@tab @code{__MDSUBACCS (@var{b}, @var{a})} 11353@tab @code{MDSUBACCS @var{a},@var{b}} 11354@item @code{void __MDUNPACKH (uw1 *, uw2)} 11355@tab @code{__MDUNPACKH (&@var{b}, @var{a})} 11356@tab @code{MDUNPACKH @var{a},@var{b}} 11357@item @code{uw2 __MEXPDHD (uw1, const)} 11358@tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})} 11359@tab @code{MEXPDHD @var{a},#@var{b},@var{c}} 11360@item @code{uw1 __MEXPDHW (uw1, const)} 11361@tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})} 11362@tab @code{MEXPDHW @var{a},#@var{b},@var{c}} 11363@item @code{uw1 __MHDSETH (uw1, const)} 11364@tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})} 11365@tab @code{MHDSETH @var{a},#@var{b},@var{c}} 11366@item @code{sw1 __MHDSETS (const)} 11367@tab @code{@var{b} = __MHDSETS (@var{a})} 11368@tab @code{MHDSETS #@var{a},@var{b}} 11369@item @code{uw1 __MHSETHIH (uw1, const)} 11370@tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})} 11371@tab @code{MHSETHIH #@var{a},@var{b}} 11372@item @code{sw1 __MHSETHIS (sw1, const)} 11373@tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})} 11374@tab @code{MHSETHIS #@var{a},@var{b}} 11375@item @code{uw1 __MHSETLOH (uw1, const)} 11376@tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})} 11377@tab @code{MHSETLOH #@var{a},@var{b}} 11378@item @code{sw1 __MHSETLOS (sw1, const)} 11379@tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})} 11380@tab @code{MHSETLOS #@var{a},@var{b}} 11381@item @code{uw1 __MHTOB (uw2)} 11382@tab @code{@var{b} = __MHTOB (@var{a})} 11383@tab @code{MHTOB @var{a},@var{b}} 11384@item @code{void __MMACHS (acc, sw1, sw1)} 11385@tab @code{__MMACHS (@var{c}, @var{a}, @var{b})} 11386@tab @code{MMACHS @var{a},@var{b},@var{c}} 11387@item @code{void __MMACHU (acc, uw1, uw1)} 11388@tab @code{__MMACHU (@var{c}, @var{a}, @var{b})} 11389@tab @code{MMACHU @var{a},@var{b},@var{c}} 11390@item @code{void __MMRDHS (acc, sw1, sw1)} 11391@tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})} 11392@tab @code{MMRDHS @var{a},@var{b},@var{c}} 11393@item @code{void __MMRDHU (acc, uw1, uw1)} 11394@tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})} 11395@tab @code{MMRDHU @var{a},@var{b},@var{c}} 11396@item @code{void __MMULHS (acc, sw1, sw1)} 11397@tab @code{__MMULHS (@var{c}, @var{a}, @var{b})} 11398@tab @code{MMULHS @var{a},@var{b},@var{c}} 11399@item @code{void __MMULHU (acc, uw1, uw1)} 11400@tab @code{__MMULHU (@var{c}, @var{a}, @var{b})} 11401@tab @code{MMULHU @var{a},@var{b},@var{c}} 11402@item @code{void __MMULXHS (acc, sw1, sw1)} 11403@tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})} 11404@tab @code{MMULXHS @var{a},@var{b},@var{c}} 11405@item @code{void __MMULXHU (acc, uw1, uw1)} 11406@tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})} 11407@tab @code{MMULXHU @var{a},@var{b},@var{c}} 11408@item @code{uw1 __MNOT (uw1)} 11409@tab @code{@var{b} = __MNOT (@var{a})} 11410@tab @code{MNOT @var{a},@var{b}} 11411@item @code{uw1 __MOR (uw1, uw1)} 11412@tab @code{@var{c} = __MOR (@var{a}, @var{b})} 11413@tab @code{MOR @var{a},@var{b},@var{c}} 11414@item @code{uw1 __MPACKH (uh, uh)} 11415@tab @code{@var{c} = __MPACKH (@var{a}, @var{b})} 11416@tab @code{MPACKH @var{a},@var{b},@var{c}} 11417@item @code{sw2 __MQADDHSS (sw2, sw2)} 11418@tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})} 11419@tab @code{MQADDHSS @var{a},@var{b},@var{c}} 11420@item @code{uw2 __MQADDHUS (uw2, uw2)} 11421@tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})} 11422@tab @code{MQADDHUS @var{a},@var{b},@var{c}} 11423@item @code{void __MQCPXIS (acc, sw2, sw2)} 11424@tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})} 11425@tab @code{MQCPXIS @var{a},@var{b},@var{c}} 11426@item @code{void __MQCPXIU (acc, uw2, uw2)} 11427@tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})} 11428@tab @code{MQCPXIU @var{a},@var{b},@var{c}} 11429@item @code{void __MQCPXRS (acc, sw2, sw2)} 11430@tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})} 11431@tab @code{MQCPXRS @var{a},@var{b},@var{c}} 11432@item @code{void __MQCPXRU (acc, uw2, uw2)} 11433@tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})} 11434@tab @code{MQCPXRU @var{a},@var{b},@var{c}} 11435@item @code{sw2 __MQLCLRHS (sw2, sw2)} 11436@tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})} 11437@tab @code{MQLCLRHS @var{a},@var{b},@var{c}} 11438@item @code{sw2 __MQLMTHS (sw2, sw2)} 11439@tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})} 11440@tab @code{MQLMTHS @var{a},@var{b},@var{c}} 11441@item @code{void __MQMACHS (acc, sw2, sw2)} 11442@tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})} 11443@tab @code{MQMACHS @var{a},@var{b},@var{c}} 11444@item @code{void __MQMACHU (acc, uw2, uw2)} 11445@tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})} 11446@tab @code{MQMACHU @var{a},@var{b},@var{c}} 11447@item @code{void __MQMACXHS (acc, sw2, sw2)} 11448@tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})} 11449@tab @code{MQMACXHS @var{a},@var{b},@var{c}} 11450@item @code{void __MQMULHS (acc, sw2, sw2)} 11451@tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})} 11452@tab @code{MQMULHS @var{a},@var{b},@var{c}} 11453@item @code{void __MQMULHU (acc, uw2, uw2)} 11454@tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})} 11455@tab @code{MQMULHU @var{a},@var{b},@var{c}} 11456@item @code{void __MQMULXHS (acc, sw2, sw2)} 11457@tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})} 11458@tab @code{MQMULXHS @var{a},@var{b},@var{c}} 11459@item @code{void __MQMULXHU (acc, uw2, uw2)} 11460@tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})} 11461@tab @code{MQMULXHU @var{a},@var{b},@var{c}} 11462@item @code{sw2 __MQSATHS (sw2, sw2)} 11463@tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})} 11464@tab @code{MQSATHS @var{a},@var{b},@var{c}} 11465@item @code{uw2 __MQSLLHI (uw2, int)} 11466@tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})} 11467@tab @code{MQSLLHI @var{a},@var{b},@var{c}} 11468@item @code{sw2 __MQSRAHI (sw2, int)} 11469@tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})} 11470@tab @code{MQSRAHI @var{a},@var{b},@var{c}} 11471@item @code{sw2 __MQSUBHSS (sw2, sw2)} 11472@tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})} 11473@tab @code{MQSUBHSS @var{a},@var{b},@var{c}} 11474@item @code{uw2 __MQSUBHUS (uw2, uw2)} 11475@tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})} 11476@tab @code{MQSUBHUS @var{a},@var{b},@var{c}} 11477@item @code{void __MQXMACHS (acc, sw2, sw2)} 11478@tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})} 11479@tab @code{MQXMACHS @var{a},@var{b},@var{c}} 11480@item @code{void __MQXMACXHS (acc, sw2, sw2)} 11481@tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})} 11482@tab @code{MQXMACXHS @var{a},@var{b},@var{c}} 11483@item @code{uw1 __MRDACC (acc)} 11484@tab @code{@var{b} = __MRDACC (@var{a})} 11485@tab @code{MRDACC @var{a},@var{b}} 11486@item @code{uw1 __MRDACCG (acc)} 11487@tab @code{@var{b} = __MRDACCG (@var{a})} 11488@tab @code{MRDACCG @var{a},@var{b}} 11489@item @code{uw1 __MROTLI (uw1, const)} 11490@tab @code{@var{c} = __MROTLI (@var{a}, @var{b})} 11491@tab @code{MROTLI @var{a},#@var{b},@var{c}} 11492@item @code{uw1 __MROTRI (uw1, const)} 11493@tab @code{@var{c} = __MROTRI (@var{a}, @var{b})} 11494@tab @code{MROTRI @var{a},#@var{b},@var{c}} 11495@item @code{sw1 __MSATHS (sw1, sw1)} 11496@tab @code{@var{c} = __MSATHS (@var{a}, @var{b})} 11497@tab @code{MSATHS @var{a},@var{b},@var{c}} 11498@item @code{uw1 __MSATHU (uw1, uw1)} 11499@tab @code{@var{c} = __MSATHU (@var{a}, @var{b})} 11500@tab @code{MSATHU @var{a},@var{b},@var{c}} 11501@item @code{uw1 __MSLLHI (uw1, const)} 11502@tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})} 11503@tab @code{MSLLHI @var{a},#@var{b},@var{c}} 11504@item @code{sw1 __MSRAHI (sw1, const)} 11505@tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})} 11506@tab @code{MSRAHI @var{a},#@var{b},@var{c}} 11507@item @code{uw1 __MSRLHI (uw1, const)} 11508@tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})} 11509@tab @code{MSRLHI @var{a},#@var{b},@var{c}} 11510@item @code{void __MSUBACCS (acc, acc)} 11511@tab @code{__MSUBACCS (@var{b}, @var{a})} 11512@tab @code{MSUBACCS @var{a},@var{b}} 11513@item @code{sw1 __MSUBHSS (sw1, sw1)} 11514@tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})} 11515@tab @code{MSUBHSS @var{a},@var{b},@var{c}} 11516@item @code{uw1 __MSUBHUS (uw1, uw1)} 11517@tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})} 11518@tab @code{MSUBHUS @var{a},@var{b},@var{c}} 11519@item @code{void __MTRAP (void)} 11520@tab @code{__MTRAP ()} 11521@tab @code{MTRAP} 11522@item @code{uw2 __MUNPACKH (uw1)} 11523@tab @code{@var{b} = __MUNPACKH (@var{a})} 11524@tab @code{MUNPACKH @var{a},@var{b}} 11525@item @code{uw1 __MWCUT (uw2, uw1)} 11526@tab @code{@var{c} = __MWCUT (@var{a}, @var{b})} 11527@tab @code{MWCUT @var{a},@var{b},@var{c}} 11528@item @code{void __MWTACC (acc, uw1)} 11529@tab @code{__MWTACC (@var{b}, @var{a})} 11530@tab @code{MWTACC @var{a},@var{b}} 11531@item @code{void __MWTACCG (acc, uw1)} 11532@tab @code{__MWTACCG (@var{b}, @var{a})} 11533@tab @code{MWTACCG @var{a},@var{b}} 11534@item @code{uw1 __MXOR (uw1, uw1)} 11535@tab @code{@var{c} = __MXOR (@var{a}, @var{b})} 11536@tab @code{MXOR @var{a},@var{b},@var{c}} 11537@end multitable 11538 11539@node Raw read/write Functions 11540@subsubsection Raw Read/Write Functions 11541 11542This sections describes built-in functions related to read and write 11543instructions to access memory. These functions generate 11544@code{membar} instructions to flush the I/O load and stores where 11545appropriate, as described in Fujitsu's manual described above. 11546 11547@table @code 11548 11549@item unsigned char __builtin_read8 (void *@var{data}) 11550@item unsigned short __builtin_read16 (void *@var{data}) 11551@item unsigned long __builtin_read32 (void *@var{data}) 11552@item unsigned long long __builtin_read64 (void *@var{data}) 11553 11554@item void __builtin_write8 (void *@var{data}, unsigned char @var{datum}) 11555@item void __builtin_write16 (void *@var{data}, unsigned short @var{datum}) 11556@item void __builtin_write32 (void *@var{data}, unsigned long @var{datum}) 11557@item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum}) 11558@end table 11559 11560@node Other Built-in Functions 11561@subsubsection Other Built-in Functions 11562 11563This section describes built-in functions that are not named after 11564a specific FR-V instruction. 11565 11566@table @code 11567@item sw2 __IACCreadll (iacc @var{reg}) 11568Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved 11569for future expansion and must be 0. 11570 11571@item sw1 __IACCreadl (iacc @var{reg}) 11572Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1. 11573Other values of @var{reg} are rejected as invalid. 11574 11575@item void __IACCsetll (iacc @var{reg}, sw2 @var{x}) 11576Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument 11577is reserved for future expansion and must be 0. 11578 11579@item void __IACCsetl (iacc @var{reg}, sw1 @var{x}) 11580Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg} 11581is 1. Other values of @var{reg} are rejected as invalid. 11582 11583@item void __data_prefetch0 (const void *@var{x}) 11584Use the @code{dcpl} instruction to load the contents of address @var{x} 11585into the data cache. 11586 11587@item void __data_prefetch (const void *@var{x}) 11588Use the @code{nldub} instruction to load the contents of address @var{x} 11589into the data cache. The instruction is issued in slot I1@. 11590@end table 11591 11592@node MIPS DSP Built-in Functions 11593@subsection MIPS DSP Built-in Functions 11594 11595The MIPS DSP Application-Specific Extension (ASE) includes new 11596instructions that are designed to improve the performance of DSP and 11597media applications. It provides instructions that operate on packed 115988-bit/16-bit integer data, Q7, Q15 and Q31 fractional data. 11599 11600GCC supports MIPS DSP operations using both the generic 11601vector extensions (@pxref{Vector Extensions}) and a collection of 11602MIPS-specific built-in functions. Both kinds of support are 11603enabled by the @option{-mdsp} command-line option. 11604 11605Revision 2 of the ASE was introduced in the second half of 2006. 11606This revision adds extra instructions to the original ASE, but is 11607otherwise backwards-compatible with it. You can select revision 2 11608using the command-line option @option{-mdspr2}; this option implies 11609@option{-mdsp}. 11610 11611The SCOUNT and POS bits of the DSP control register are global. The 11612WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and 11613POS bits. During optimization, the compiler does not delete these 11614instructions and it does not delete calls to functions containing 11615these instructions. 11616 11617At present, GCC only provides support for operations on 32-bit 11618vectors. The vector type associated with 8-bit integer data is 11619usually called @code{v4i8}, the vector type associated with Q7 11620is usually called @code{v4q7}, the vector type associated with 16-bit 11621integer data is usually called @code{v2i16}, and the vector type 11622associated with Q15 is usually called @code{v2q15}. They can be 11623defined in C as follows: 11624 11625@smallexample 11626typedef signed char v4i8 __attribute__ ((vector_size(4))); 11627typedef signed char v4q7 __attribute__ ((vector_size(4))); 11628typedef short v2i16 __attribute__ ((vector_size(4))); 11629typedef short v2q15 __attribute__ ((vector_size(4))); 11630@end smallexample 11631 11632@code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are 11633initialized in the same way as aggregates. For example: 11634 11635@smallexample 11636v4i8 a = @{1, 2, 3, 4@}; 11637v4i8 b; 11638b = (v4i8) @{5, 6, 7, 8@}; 11639 11640v2q15 c = @{0x0fcb, 0x3a75@}; 11641v2q15 d; 11642d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@}; 11643@end smallexample 11644 11645@emph{Note:} The CPU's endianness determines the order in which values 11646are packed. On little-endian targets, the first value is the least 11647significant and the last value is the most significant. The opposite 11648order applies to big-endian targets. For example, the code above 11649sets the lowest byte of @code{a} to @code{1} on little-endian targets 11650and @code{4} on big-endian targets. 11651 11652@emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer 11653representation. As shown in this example, the integer representation 11654of a Q7 value can be obtained by multiplying the fractional value by 11655@code{0x1.0p7}. The equivalent for Q15 values is to multiply by 11656@code{0x1.0p15}. The equivalent for Q31 values is to multiply by 11657@code{0x1.0p31}. 11658 11659The table below lists the @code{v4i8} and @code{v2q15} operations for which 11660hardware support exists. @code{a} and @code{b} are @code{v4i8} values, 11661and @code{c} and @code{d} are @code{v2q15} values. 11662 11663@multitable @columnfractions .50 .50 11664@item C code @tab MIPS instruction 11665@item @code{a + b} @tab @code{addu.qb} 11666@item @code{c + d} @tab @code{addq.ph} 11667@item @code{a - b} @tab @code{subu.qb} 11668@item @code{c - d} @tab @code{subq.ph} 11669@end multitable 11670 11671The table below lists the @code{v2i16} operation for which 11672hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are 11673@code{v2i16} values. 11674 11675@multitable @columnfractions .50 .50 11676@item C code @tab MIPS instruction 11677@item @code{e * f} @tab @code{mul.ph} 11678@end multitable 11679 11680It is easier to describe the DSP built-in functions if we first define 11681the following types: 11682 11683@smallexample 11684typedef int q31; 11685typedef int i32; 11686typedef unsigned int ui32; 11687typedef long long a64; 11688@end smallexample 11689 11690@code{q31} and @code{i32} are actually the same as @code{int}, but we 11691use @code{q31} to indicate a Q31 fractional value and @code{i32} to 11692indicate a 32-bit integer value. Similarly, @code{a64} is the same as 11693@code{long long}, but we use @code{a64} to indicate values that are 11694placed in one of the four DSP accumulators (@code{$ac0}, 11695@code{$ac1}, @code{$ac2} or @code{$ac3}). 11696 11697Also, some built-in functions prefer or require immediate numbers as 11698parameters, because the corresponding DSP instructions accept both immediate 11699numbers and register operands, or accept immediate numbers only. The 11700immediate parameters are listed as follows. 11701 11702@smallexample 11703imm0_3: 0 to 3. 11704imm0_7: 0 to 7. 11705imm0_15: 0 to 15. 11706imm0_31: 0 to 31. 11707imm0_63: 0 to 63. 11708imm0_255: 0 to 255. 11709imm_n32_31: -32 to 31. 11710imm_n512_511: -512 to 511. 11711@end smallexample 11712 11713The following built-in functions map directly to a particular MIPS DSP 11714instruction. Please refer to the architecture specification 11715for details on what each instruction does. 11716 11717@smallexample 11718v2q15 __builtin_mips_addq_ph (v2q15, v2q15) 11719v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15) 11720q31 __builtin_mips_addq_s_w (q31, q31) 11721v4i8 __builtin_mips_addu_qb (v4i8, v4i8) 11722v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8) 11723v2q15 __builtin_mips_subq_ph (v2q15, v2q15) 11724v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15) 11725q31 __builtin_mips_subq_s_w (q31, q31) 11726v4i8 __builtin_mips_subu_qb (v4i8, v4i8) 11727v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8) 11728i32 __builtin_mips_addsc (i32, i32) 11729i32 __builtin_mips_addwc (i32, i32) 11730i32 __builtin_mips_modsub (i32, i32) 11731i32 __builtin_mips_raddu_w_qb (v4i8) 11732v2q15 __builtin_mips_absq_s_ph (v2q15) 11733q31 __builtin_mips_absq_s_w (q31) 11734v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15) 11735v2q15 __builtin_mips_precrq_ph_w (q31, q31) 11736v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31) 11737v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15) 11738q31 __builtin_mips_preceq_w_phl (v2q15) 11739q31 __builtin_mips_preceq_w_phr (v2q15) 11740v2q15 __builtin_mips_precequ_ph_qbl (v4i8) 11741v2q15 __builtin_mips_precequ_ph_qbr (v4i8) 11742v2q15 __builtin_mips_precequ_ph_qbla (v4i8) 11743v2q15 __builtin_mips_precequ_ph_qbra (v4i8) 11744v2q15 __builtin_mips_preceu_ph_qbl (v4i8) 11745v2q15 __builtin_mips_preceu_ph_qbr (v4i8) 11746v2q15 __builtin_mips_preceu_ph_qbla (v4i8) 11747v2q15 __builtin_mips_preceu_ph_qbra (v4i8) 11748v4i8 __builtin_mips_shll_qb (v4i8, imm0_7) 11749v4i8 __builtin_mips_shll_qb (v4i8, i32) 11750v2q15 __builtin_mips_shll_ph (v2q15, imm0_15) 11751v2q15 __builtin_mips_shll_ph (v2q15, i32) 11752v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15) 11753v2q15 __builtin_mips_shll_s_ph (v2q15, i32) 11754q31 __builtin_mips_shll_s_w (q31, imm0_31) 11755q31 __builtin_mips_shll_s_w (q31, i32) 11756v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7) 11757v4i8 __builtin_mips_shrl_qb (v4i8, i32) 11758v2q15 __builtin_mips_shra_ph (v2q15, imm0_15) 11759v2q15 __builtin_mips_shra_ph (v2q15, i32) 11760v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15) 11761v2q15 __builtin_mips_shra_r_ph (v2q15, i32) 11762q31 __builtin_mips_shra_r_w (q31, imm0_31) 11763q31 __builtin_mips_shra_r_w (q31, i32) 11764v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15) 11765v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15) 11766v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15) 11767q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15) 11768q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15) 11769a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8) 11770a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8) 11771a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8) 11772a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8) 11773a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15) 11774a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31) 11775a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15) 11776a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31) 11777a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15) 11778a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15) 11779a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15) 11780a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15) 11781a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15) 11782i32 __builtin_mips_bitrev (i32) 11783i32 __builtin_mips_insv (i32, i32) 11784v4i8 __builtin_mips_repl_qb (imm0_255) 11785v4i8 __builtin_mips_repl_qb (i32) 11786v2q15 __builtin_mips_repl_ph (imm_n512_511) 11787v2q15 __builtin_mips_repl_ph (i32) 11788void __builtin_mips_cmpu_eq_qb (v4i8, v4i8) 11789void __builtin_mips_cmpu_lt_qb (v4i8, v4i8) 11790void __builtin_mips_cmpu_le_qb (v4i8, v4i8) 11791i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8) 11792i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8) 11793i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8) 11794void __builtin_mips_cmp_eq_ph (v2q15, v2q15) 11795void __builtin_mips_cmp_lt_ph (v2q15, v2q15) 11796void __builtin_mips_cmp_le_ph (v2q15, v2q15) 11797v4i8 __builtin_mips_pick_qb (v4i8, v4i8) 11798v2q15 __builtin_mips_pick_ph (v2q15, v2q15) 11799v2q15 __builtin_mips_packrl_ph (v2q15, v2q15) 11800i32 __builtin_mips_extr_w (a64, imm0_31) 11801i32 __builtin_mips_extr_w (a64, i32) 11802i32 __builtin_mips_extr_r_w (a64, imm0_31) 11803i32 __builtin_mips_extr_s_h (a64, i32) 11804i32 __builtin_mips_extr_rs_w (a64, imm0_31) 11805i32 __builtin_mips_extr_rs_w (a64, i32) 11806i32 __builtin_mips_extr_s_h (a64, imm0_31) 11807i32 __builtin_mips_extr_r_w (a64, i32) 11808i32 __builtin_mips_extp (a64, imm0_31) 11809i32 __builtin_mips_extp (a64, i32) 11810i32 __builtin_mips_extpdp (a64, imm0_31) 11811i32 __builtin_mips_extpdp (a64, i32) 11812a64 __builtin_mips_shilo (a64, imm_n32_31) 11813a64 __builtin_mips_shilo (a64, i32) 11814a64 __builtin_mips_mthlip (a64, i32) 11815void __builtin_mips_wrdsp (i32, imm0_63) 11816i32 __builtin_mips_rddsp (imm0_63) 11817i32 __builtin_mips_lbux (void *, i32) 11818i32 __builtin_mips_lhx (void *, i32) 11819i32 __builtin_mips_lwx (void *, i32) 11820a64 __builtin_mips_ldx (void *, i32) [MIPS64 only] 11821i32 __builtin_mips_bposge32 (void) 11822a64 __builtin_mips_madd (a64, i32, i32); 11823a64 __builtin_mips_maddu (a64, ui32, ui32); 11824a64 __builtin_mips_msub (a64, i32, i32); 11825a64 __builtin_mips_msubu (a64, ui32, ui32); 11826a64 __builtin_mips_mult (i32, i32); 11827a64 __builtin_mips_multu (ui32, ui32); 11828@end smallexample 11829 11830The following built-in functions map directly to a particular MIPS DSP REV 2 11831instruction. Please refer to the architecture specification 11832for details on what each instruction does. 11833 11834@smallexample 11835v4q7 __builtin_mips_absq_s_qb (v4q7); 11836v2i16 __builtin_mips_addu_ph (v2i16, v2i16); 11837v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16); 11838v4i8 __builtin_mips_adduh_qb (v4i8, v4i8); 11839v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8); 11840i32 __builtin_mips_append (i32, i32, imm0_31); 11841i32 __builtin_mips_balign (i32, i32, imm0_3); 11842i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8); 11843i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8); 11844i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8); 11845a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16); 11846a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16); 11847v2i16 __builtin_mips_mul_ph (v2i16, v2i16); 11848v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16); 11849q31 __builtin_mips_mulq_rs_w (q31, q31); 11850v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15); 11851q31 __builtin_mips_mulq_s_w (q31, q31); 11852a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16); 11853v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16); 11854v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31); 11855v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31); 11856i32 __builtin_mips_prepend (i32, i32, imm0_31); 11857v4i8 __builtin_mips_shra_qb (v4i8, imm0_7); 11858v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7); 11859v4i8 __builtin_mips_shra_qb (v4i8, i32); 11860v4i8 __builtin_mips_shra_r_qb (v4i8, i32); 11861v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15); 11862v2i16 __builtin_mips_shrl_ph (v2i16, i32); 11863v2i16 __builtin_mips_subu_ph (v2i16, v2i16); 11864v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16); 11865v4i8 __builtin_mips_subuh_qb (v4i8, v4i8); 11866v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8); 11867v2q15 __builtin_mips_addqh_ph (v2q15, v2q15); 11868v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15); 11869q31 __builtin_mips_addqh_w (q31, q31); 11870q31 __builtin_mips_addqh_r_w (q31, q31); 11871v2q15 __builtin_mips_subqh_ph (v2q15, v2q15); 11872v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15); 11873q31 __builtin_mips_subqh_w (q31, q31); 11874q31 __builtin_mips_subqh_r_w (q31, q31); 11875a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16); 11876a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16); 11877a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15); 11878a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15); 11879a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15); 11880a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15); 11881@end smallexample 11882 11883 11884@node MIPS Paired-Single Support 11885@subsection MIPS Paired-Single Support 11886 11887The MIPS64 architecture includes a number of instructions that 11888operate on pairs of single-precision floating-point values. 11889Each pair is packed into a 64-bit floating-point register, 11890with one element being designated the ``upper half'' and 11891the other being designated the ``lower half''. 11892 11893GCC supports paired-single operations using both the generic 11894vector extensions (@pxref{Vector Extensions}) and a collection of 11895MIPS-specific built-in functions. Both kinds of support are 11896enabled by the @option{-mpaired-single} command-line option. 11897 11898The vector type associated with paired-single values is usually 11899called @code{v2sf}. It can be defined in C as follows: 11900 11901@smallexample 11902typedef float v2sf __attribute__ ((vector_size (8))); 11903@end smallexample 11904 11905@code{v2sf} values are initialized in the same way as aggregates. 11906For example: 11907 11908@smallexample 11909v2sf a = @{1.5, 9.1@}; 11910v2sf b; 11911float e, f; 11912b = (v2sf) @{e, f@}; 11913@end smallexample 11914 11915@emph{Note:} The CPU's endianness determines which value is stored in 11916the upper half of a register and which value is stored in the lower half. 11917On little-endian targets, the first value is the lower one and the second 11918value is the upper one. The opposite order applies to big-endian targets. 11919For example, the code above sets the lower half of @code{a} to 11920@code{1.5} on little-endian targets and @code{9.1} on big-endian targets. 11921 11922@node MIPS Loongson Built-in Functions 11923@subsection MIPS Loongson Built-in Functions 11924 11925GCC provides intrinsics to access the SIMD instructions provided by the 11926ST Microelectronics Loongson-2E and -2F processors. These intrinsics, 11927available after inclusion of the @code{loongson.h} header file, 11928operate on the following 64-bit vector types: 11929 11930@itemize 11931@item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers; 11932@item @code{uint16x4_t}, a vector of four unsigned 16-bit integers; 11933@item @code{uint32x2_t}, a vector of two unsigned 32-bit integers; 11934@item @code{int8x8_t}, a vector of eight signed 8-bit integers; 11935@item @code{int16x4_t}, a vector of four signed 16-bit integers; 11936@item @code{int32x2_t}, a vector of two signed 32-bit integers. 11937@end itemize 11938 11939The intrinsics provided are listed below; each is named after the 11940machine instruction to which it corresponds, with suffixes added as 11941appropriate to distinguish intrinsics that expand to the same machine 11942instruction yet have different argument types. Refer to the architecture 11943documentation for a description of the functionality of each 11944instruction. 11945 11946@smallexample 11947int16x4_t packsswh (int32x2_t s, int32x2_t t); 11948int8x8_t packsshb (int16x4_t s, int16x4_t t); 11949uint8x8_t packushb (uint16x4_t s, uint16x4_t t); 11950uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t); 11951uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t); 11952uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t); 11953int32x2_t paddw_s (int32x2_t s, int32x2_t t); 11954int16x4_t paddh_s (int16x4_t s, int16x4_t t); 11955int8x8_t paddb_s (int8x8_t s, int8x8_t t); 11956uint64_t paddd_u (uint64_t s, uint64_t t); 11957int64_t paddd_s (int64_t s, int64_t t); 11958int16x4_t paddsh (int16x4_t s, int16x4_t t); 11959int8x8_t paddsb (int8x8_t s, int8x8_t t); 11960uint16x4_t paddush (uint16x4_t s, uint16x4_t t); 11961uint8x8_t paddusb (uint8x8_t s, uint8x8_t t); 11962uint64_t pandn_ud (uint64_t s, uint64_t t); 11963uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t); 11964uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t); 11965uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t); 11966int64_t pandn_sd (int64_t s, int64_t t); 11967int32x2_t pandn_sw (int32x2_t s, int32x2_t t); 11968int16x4_t pandn_sh (int16x4_t s, int16x4_t t); 11969int8x8_t pandn_sb (int8x8_t s, int8x8_t t); 11970uint16x4_t pavgh (uint16x4_t s, uint16x4_t t); 11971uint8x8_t pavgb (uint8x8_t s, uint8x8_t t); 11972uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t); 11973uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t); 11974uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t); 11975int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t); 11976int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t); 11977int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t); 11978uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t); 11979uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t); 11980uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t); 11981int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t); 11982int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t); 11983int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t); 11984uint16x4_t pextrh_u (uint16x4_t s, int field); 11985int16x4_t pextrh_s (int16x4_t s, int field); 11986uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t); 11987uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t); 11988uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t); 11989uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t); 11990int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t); 11991int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t); 11992int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t); 11993int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t); 11994int32x2_t pmaddhw (int16x4_t s, int16x4_t t); 11995int16x4_t pmaxsh (int16x4_t s, int16x4_t t); 11996uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t); 11997int16x4_t pminsh (int16x4_t s, int16x4_t t); 11998uint8x8_t pminub (uint8x8_t s, uint8x8_t t); 11999uint8x8_t pmovmskb_u (uint8x8_t s); 12000int8x8_t pmovmskb_s (int8x8_t s); 12001uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t); 12002int16x4_t pmulhh (int16x4_t s, int16x4_t t); 12003int16x4_t pmullh (int16x4_t s, int16x4_t t); 12004int64_t pmuluw (uint32x2_t s, uint32x2_t t); 12005uint8x8_t pasubub (uint8x8_t s, uint8x8_t t); 12006uint16x4_t biadd (uint8x8_t s); 12007uint16x4_t psadbh (uint8x8_t s, uint8x8_t t); 12008uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order); 12009int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order); 12010uint16x4_t psllh_u (uint16x4_t s, uint8_t amount); 12011int16x4_t psllh_s (int16x4_t s, uint8_t amount); 12012uint32x2_t psllw_u (uint32x2_t s, uint8_t amount); 12013int32x2_t psllw_s (int32x2_t s, uint8_t amount); 12014uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount); 12015int16x4_t psrlh_s (int16x4_t s, uint8_t amount); 12016uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount); 12017int32x2_t psrlw_s (int32x2_t s, uint8_t amount); 12018uint16x4_t psrah_u (uint16x4_t s, uint8_t amount); 12019int16x4_t psrah_s (int16x4_t s, uint8_t amount); 12020uint32x2_t psraw_u (uint32x2_t s, uint8_t amount); 12021int32x2_t psraw_s (int32x2_t s, uint8_t amount); 12022uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t); 12023uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t); 12024uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t); 12025int32x2_t psubw_s (int32x2_t s, int32x2_t t); 12026int16x4_t psubh_s (int16x4_t s, int16x4_t t); 12027int8x8_t psubb_s (int8x8_t s, int8x8_t t); 12028uint64_t psubd_u (uint64_t s, uint64_t t); 12029int64_t psubd_s (int64_t s, int64_t t); 12030int16x4_t psubsh (int16x4_t s, int16x4_t t); 12031int8x8_t psubsb (int8x8_t s, int8x8_t t); 12032uint16x4_t psubush (uint16x4_t s, uint16x4_t t); 12033uint8x8_t psubusb (uint8x8_t s, uint8x8_t t); 12034uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t); 12035uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t); 12036uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t); 12037int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t); 12038int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t); 12039int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t); 12040uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t); 12041uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t); 12042uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t); 12043int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t); 12044int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t); 12045int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t); 12046@end smallexample 12047 12048@menu 12049* Paired-Single Arithmetic:: 12050* Paired-Single Built-in Functions:: 12051* MIPS-3D Built-in Functions:: 12052@end menu 12053 12054@node Paired-Single Arithmetic 12055@subsubsection Paired-Single Arithmetic 12056 12057The table below lists the @code{v2sf} operations for which hardware 12058support exists. @code{a}, @code{b} and @code{c} are @code{v2sf} 12059values and @code{x} is an integral value. 12060 12061@multitable @columnfractions .50 .50 12062@item C code @tab MIPS instruction 12063@item @code{a + b} @tab @code{add.ps} 12064@item @code{a - b} @tab @code{sub.ps} 12065@item @code{-a} @tab @code{neg.ps} 12066@item @code{a * b} @tab @code{mul.ps} 12067@item @code{a * b + c} @tab @code{madd.ps} 12068@item @code{a * b - c} @tab @code{msub.ps} 12069@item @code{-(a * b + c)} @tab @code{nmadd.ps} 12070@item @code{-(a * b - c)} @tab @code{nmsub.ps} 12071@item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps} 12072@end multitable 12073 12074Note that the multiply-accumulate instructions can be disabled 12075using the command-line option @code{-mno-fused-madd}. 12076 12077@node Paired-Single Built-in Functions 12078@subsubsection Paired-Single Built-in Functions 12079 12080The following paired-single functions map directly to a particular 12081MIPS instruction. Please refer to the architecture specification 12082for details on what each instruction does. 12083 12084@table @code 12085@item v2sf __builtin_mips_pll_ps (v2sf, v2sf) 12086Pair lower lower (@code{pll.ps}). 12087 12088@item v2sf __builtin_mips_pul_ps (v2sf, v2sf) 12089Pair upper lower (@code{pul.ps}). 12090 12091@item v2sf __builtin_mips_plu_ps (v2sf, v2sf) 12092Pair lower upper (@code{plu.ps}). 12093 12094@item v2sf __builtin_mips_puu_ps (v2sf, v2sf) 12095Pair upper upper (@code{puu.ps}). 12096 12097@item v2sf __builtin_mips_cvt_ps_s (float, float) 12098Convert pair to paired single (@code{cvt.ps.s}). 12099 12100@item float __builtin_mips_cvt_s_pl (v2sf) 12101Convert pair lower to single (@code{cvt.s.pl}). 12102 12103@item float __builtin_mips_cvt_s_pu (v2sf) 12104Convert pair upper to single (@code{cvt.s.pu}). 12105 12106@item v2sf __builtin_mips_abs_ps (v2sf) 12107Absolute value (@code{abs.ps}). 12108 12109@item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int) 12110Align variable (@code{alnv.ps}). 12111 12112@emph{Note:} The value of the third parameter must be 0 or 4 12113modulo 8, otherwise the result is unpredictable. Please read the 12114instruction description for details. 12115@end table 12116 12117The following multi-instruction functions are also available. 12118In each case, @var{cond} can be any of the 16 floating-point conditions: 12119@code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult}, 12120@code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl}, 12121@code{lt}, @code{nge}, @code{le} or @code{ngt}. 12122 12123@table @code 12124@item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 12125@itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 12126Conditional move based on floating-point comparison (@code{c.@var{cond}.ps}, 12127@code{movt.ps}/@code{movf.ps}). 12128 12129The @code{movt} functions return the value @var{x} computed by: 12130 12131@smallexample 12132c.@var{cond}.ps @var{cc},@var{a},@var{b} 12133mov.ps @var{x},@var{c} 12134movt.ps @var{x},@var{d},@var{cc} 12135@end smallexample 12136 12137The @code{movf} functions are similar but use @code{movf.ps} instead 12138of @code{movt.ps}. 12139 12140@item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 12141@itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 12142Comparison of two paired-single values (@code{c.@var{cond}.ps}, 12143@code{bc1t}/@code{bc1f}). 12144 12145These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps} 12146and return either the upper or lower half of the result. For example: 12147 12148@smallexample 12149v2sf a, b; 12150if (__builtin_mips_upper_c_eq_ps (a, b)) 12151 upper_halves_are_equal (); 12152else 12153 upper_halves_are_unequal (); 12154 12155if (__builtin_mips_lower_c_eq_ps (a, b)) 12156 lower_halves_are_equal (); 12157else 12158 lower_halves_are_unequal (); 12159@end smallexample 12160@end table 12161 12162@node MIPS-3D Built-in Functions 12163@subsubsection MIPS-3D Built-in Functions 12164 12165The MIPS-3D Application-Specific Extension (ASE) includes additional 12166paired-single instructions that are designed to improve the performance 12167of 3D graphics operations. Support for these instructions is controlled 12168by the @option{-mips3d} command-line option. 12169 12170The functions listed below map directly to a particular MIPS-3D 12171instruction. Please refer to the architecture specification for 12172more details on what each instruction does. 12173 12174@table @code 12175@item v2sf __builtin_mips_addr_ps (v2sf, v2sf) 12176Reduction add (@code{addr.ps}). 12177 12178@item v2sf __builtin_mips_mulr_ps (v2sf, v2sf) 12179Reduction multiply (@code{mulr.ps}). 12180 12181@item v2sf __builtin_mips_cvt_pw_ps (v2sf) 12182Convert paired single to paired word (@code{cvt.pw.ps}). 12183 12184@item v2sf __builtin_mips_cvt_ps_pw (v2sf) 12185Convert paired word to paired single (@code{cvt.ps.pw}). 12186 12187@item float __builtin_mips_recip1_s (float) 12188@itemx double __builtin_mips_recip1_d (double) 12189@itemx v2sf __builtin_mips_recip1_ps (v2sf) 12190Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}). 12191 12192@item float __builtin_mips_recip2_s (float, float) 12193@itemx double __builtin_mips_recip2_d (double, double) 12194@itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf) 12195Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}). 12196 12197@item float __builtin_mips_rsqrt1_s (float) 12198@itemx double __builtin_mips_rsqrt1_d (double) 12199@itemx v2sf __builtin_mips_rsqrt1_ps (v2sf) 12200Reduced-precision reciprocal square root (sequence step 1) 12201(@code{rsqrt1.@var{fmt}}). 12202 12203@item float __builtin_mips_rsqrt2_s (float, float) 12204@itemx double __builtin_mips_rsqrt2_d (double, double) 12205@itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf) 12206Reduced-precision reciprocal square root (sequence step 2) 12207(@code{rsqrt2.@var{fmt}}). 12208@end table 12209 12210The following multi-instruction functions are also available. 12211In each case, @var{cond} can be any of the 16 floating-point conditions: 12212@code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult}, 12213@code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, 12214@code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}. 12215 12216@table @code 12217@item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b}) 12218@itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b}) 12219Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}}, 12220@code{bc1t}/@code{bc1f}). 12221 12222These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s} 12223or @code{cabs.@var{cond}.d} and return the result as a boolean value. 12224For example: 12225 12226@smallexample 12227float a, b; 12228if (__builtin_mips_cabs_eq_s (a, b)) 12229 true (); 12230else 12231 false (); 12232@end smallexample 12233 12234@item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 12235@itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 12236Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps}, 12237@code{bc1t}/@code{bc1f}). 12238 12239These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps} 12240and return either the upper or lower half of the result. For example: 12241 12242@smallexample 12243v2sf a, b; 12244if (__builtin_mips_upper_cabs_eq_ps (a, b)) 12245 upper_halves_are_equal (); 12246else 12247 upper_halves_are_unequal (); 12248 12249if (__builtin_mips_lower_cabs_eq_ps (a, b)) 12250 lower_halves_are_equal (); 12251else 12252 lower_halves_are_unequal (); 12253@end smallexample 12254 12255@item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 12256@itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 12257Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps}, 12258@code{movt.ps}/@code{movf.ps}). 12259 12260The @code{movt} functions return the value @var{x} computed by: 12261 12262@smallexample 12263cabs.@var{cond}.ps @var{cc},@var{a},@var{b} 12264mov.ps @var{x},@var{c} 12265movt.ps @var{x},@var{d},@var{cc} 12266@end smallexample 12267 12268The @code{movf} functions are similar but use @code{movf.ps} instead 12269of @code{movt.ps}. 12270 12271@item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 12272@itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 12273@itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 12274@itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}) 12275Comparison of two paired-single values 12276(@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps}, 12277@code{bc1any2t}/@code{bc1any2f}). 12278 12279These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps} 12280or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either 12281result is true and the @code{all} forms return true if both results are true. 12282For example: 12283 12284@smallexample 12285v2sf a, b; 12286if (__builtin_mips_any_c_eq_ps (a, b)) 12287 one_is_true (); 12288else 12289 both_are_false (); 12290 12291if (__builtin_mips_all_c_eq_ps (a, b)) 12292 both_are_true (); 12293else 12294 one_is_false (); 12295@end smallexample 12296 12297@item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 12298@itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 12299@itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 12300@itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d}) 12301Comparison of four paired-single values 12302(@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps}, 12303@code{bc1any4t}/@code{bc1any4f}). 12304 12305These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps} 12306to compare @var{a} with @var{b} and to compare @var{c} with @var{d}. 12307The @code{any} forms return true if any of the four results are true 12308and the @code{all} forms return true if all four results are true. 12309For example: 12310 12311@smallexample 12312v2sf a, b, c, d; 12313if (__builtin_mips_any_c_eq_4s (a, b, c, d)) 12314 some_are_true (); 12315else 12316 all_are_false (); 12317 12318if (__builtin_mips_all_c_eq_4s (a, b, c, d)) 12319 all_are_true (); 12320else 12321 some_are_false (); 12322@end smallexample 12323@end table 12324 12325@node Other MIPS Built-in Functions 12326@subsection Other MIPS Built-in Functions 12327 12328GCC provides other MIPS-specific built-in functions: 12329 12330@table @code 12331@item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr}) 12332Insert a @samp{cache} instruction with operands @var{op} and @var{addr}. 12333GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE} 12334when this function is available. 12335 12336@item unsigned int __builtin_mips_get_fcsr (void) 12337@itemx void __builtin_mips_set_fcsr (unsigned int @var{value}) 12338Get and set the contents of the floating-point control and status register 12339(FPU control register 31). These functions are only available in hard-float 12340code but can be called in both MIPS16 and non-MIPS16 contexts. 12341 12342@code{__builtin_mips_set_fcsr} can be used to change any bit of the 12343register except the condition codes, which GCC assumes are preserved. 12344@end table 12345 12346@node MSP430 Built-in Functions 12347@subsection MSP430 Built-in Functions 12348 12349GCC provides a couple of special builtin functions to aid in the 12350writing of interrupt handlers in C. 12351 12352@table @code 12353@item __bic_SR_register_on_exit (int @var{mask}) 12354This clears the indicated bits in the saved copy of the status register 12355currently residing on the stack. This only works inside interrupt 12356handlers and the changes to the status register will only take affect 12357once the handler returns. 12358 12359@item __bis_SR_register_on_exit (int @var{mask}) 12360This sets the indicated bits in the saved copy of the status register 12361currently residing on the stack. This only works inside interrupt 12362handlers and the changes to the status register will only take affect 12363once the handler returns. 12364 12365@item __delay_cycles (long long @var{cycles}) 12366This inserts an instruction sequence that takes exactly @var{cycles} 12367cycles (between 0 and about 17E9) to complete. The inserted sequence 12368may use jumps, loops, or no-ops, and does not interfere with any other 12369instructions. Note that @var{cycles} must be a compile-time constant 12370integer - that is, you must pass a number, not a variable that may be 12371optimized to a constant later. The number of cycles delayed by this 12372builtin is exact. 12373@end table 12374 12375@node NDS32 Built-in Functions 12376@subsection NDS32 Built-in Functions 12377 12378These built-in functions are available for the NDS32 target: 12379 12380@deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr}) 12381Insert an ISYNC instruction into the instruction stream where 12382@var{addr} is an instruction address for serialization. 12383@end deftypefn 12384 12385@deftypefn {Built-in Function} void __builtin_nds32_isb (void) 12386Insert an ISB instruction into the instruction stream. 12387@end deftypefn 12388 12389@deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr}) 12390Return the content of a system register which is mapped by @var{sr}. 12391@end deftypefn 12392 12393@deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr}) 12394Return the content of a user space register which is mapped by @var{usr}. 12395@end deftypefn 12396 12397@deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr}) 12398Move the @var{value} to a system register which is mapped by @var{sr}. 12399@end deftypefn 12400 12401@deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr}) 12402Move the @var{value} to a user space register which is mapped by @var{usr}. 12403@end deftypefn 12404 12405@deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void) 12406Enable global interrupt. 12407@end deftypefn 12408 12409@deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void) 12410Disable global interrupt. 12411@end deftypefn 12412 12413@node picoChip Built-in Functions 12414@subsection picoChip Built-in Functions 12415 12416GCC provides an interface to selected machine instructions from the 12417picoChip instruction set. 12418 12419@table @code 12420@item int __builtin_sbc (int @var{value}) 12421Sign bit count. Return the number of consecutive bits in @var{value} 12422that have the same value as the sign bit. The result is the number of 12423leading sign bits minus one, giving the number of redundant sign bits in 12424@var{value}. 12425 12426@item int __builtin_byteswap (int @var{value}) 12427Byte swap. Return the result of swapping the upper and lower bytes of 12428@var{value}. 12429 12430@item int __builtin_brev (int @var{value}) 12431Bit reversal. Return the result of reversing the bits in 12432@var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1, 12433and so on. 12434 12435@item int __builtin_adds (int @var{x}, int @var{y}) 12436Saturating addition. Return the result of adding @var{x} and @var{y}, 12437storing the value 32767 if the result overflows. 12438 12439@item int __builtin_subs (int @var{x}, int @var{y}) 12440Saturating subtraction. Return the result of subtracting @var{y} from 12441@var{x}, storing the value @minus{}32768 if the result overflows. 12442 12443@item void __builtin_halt (void) 12444Halt. The processor stops execution. This built-in is useful for 12445implementing assertions. 12446 12447@end table 12448 12449@node PowerPC Built-in Functions 12450@subsection PowerPC Built-in Functions 12451 12452These built-in functions are available for the PowerPC family of 12453processors: 12454@smallexample 12455float __builtin_recipdivf (float, float); 12456float __builtin_rsqrtf (float); 12457double __builtin_recipdiv (double, double); 12458double __builtin_rsqrt (double); 12459uint64_t __builtin_ppc_get_timebase (); 12460unsigned long __builtin_ppc_mftb (); 12461double __builtin_unpack_longdouble (long double, int); 12462long double __builtin_pack_longdouble (double, double); 12463@end smallexample 12464 12465The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and 12466@code{__builtin_rsqrtf} functions generate multiple instructions to 12467implement the reciprocal sqrt functionality using reciprocal sqrt 12468estimate instructions. 12469 12470The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf} 12471functions generate multiple instructions to implement division using 12472the reciprocal estimate instructions. 12473 12474The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb} 12475functions generate instructions to read the Time Base Register. The 12476@code{__builtin_ppc_get_timebase} function may generate multiple 12477instructions and always returns the 64 bits of the Time Base Register. 12478The @code{__builtin_ppc_mftb} function always generates one instruction and 12479returns the Time Base Register value as an unsigned long, throwing away 12480the most significant word on 32-bit environments. 12481 12482The following built-in functions are available for the PowerPC family 12483of processors, starting with ISA 2.06 or later (@option{-mcpu=power7} 12484or @option{-mpopcntd}): 12485@smallexample 12486long __builtin_bpermd (long, long); 12487int __builtin_divwe (int, int); 12488int __builtin_divweo (int, int); 12489unsigned int __builtin_divweu (unsigned int, unsigned int); 12490unsigned int __builtin_divweuo (unsigned int, unsigned int); 12491long __builtin_divde (long, long); 12492long __builtin_divdeo (long, long); 12493unsigned long __builtin_divdeu (unsigned long, unsigned long); 12494unsigned long __builtin_divdeuo (unsigned long, unsigned long); 12495unsigned int cdtbcd (unsigned int); 12496unsigned int cbcdtd (unsigned int); 12497unsigned int addg6s (unsigned int, unsigned int); 12498@end smallexample 12499 12500The @code{__builtin_divde}, @code{__builtin_divdeo}, 12501@code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a 1250264-bit environment support ISA 2.06 or later. 12503 12504The following built-in functions are available for the PowerPC family 12505of processors when hardware decimal floating point 12506(@option{-mhard-dfp}) is available: 12507@smallexample 12508long long __builtin_dxex (_Decimal64); 12509long long __builtin_dxexq (_Decimal128); 12510_Decimal64 __builtin_ddedpd (int, _Decimal64); 12511_Decimal128 __builtin_ddedpdq (int, _Decimal128); 12512_Decimal64 __builtin_denbcd (int, _Decimal64); 12513_Decimal128 __builtin_denbcdq (int, _Decimal128); 12514_Decimal64 __builtin_diex (long long, _Decimal64); 12515_Decimal128 _builtin_diexq (long long, _Decimal128); 12516_Decimal64 __builtin_dscli (_Decimal64, int); 12517_Decimal128 __builtin_dscliq (_Decimal128, int); 12518_Decimal64 __builtin_dscri (_Decimal64, int); 12519_Decimal128 __builtin_dscriq (_Decimal128, int); 12520unsigned long long __builtin_unpack_dec128 (_Decimal128, int); 12521_Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long); 12522@end smallexample 12523 12524The following built-in functions are available for the PowerPC family 12525of processors when the Vector Scalar (vsx) instruction set is 12526available: 12527@smallexample 12528unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int); 12529vector __int128_t __builtin_pack_vector_int128 (unsigned long long, 12530 unsigned long long); 12531@end smallexample 12532 12533@node PowerPC AltiVec/VSX Built-in Functions 12534@subsection PowerPC AltiVec Built-in Functions 12535 12536GCC provides an interface for the PowerPC family of processors to access 12537the AltiVec operations described in Motorola's AltiVec Programming 12538Interface Manual. The interface is made available by including 12539@code{<altivec.h>} and using @option{-maltivec} and 12540@option{-mabi=altivec}. The interface supports the following vector 12541types. 12542 12543@smallexample 12544vector unsigned char 12545vector signed char 12546vector bool char 12547 12548vector unsigned short 12549vector signed short 12550vector bool short 12551vector pixel 12552 12553vector unsigned int 12554vector signed int 12555vector bool int 12556vector float 12557@end smallexample 12558 12559If @option{-mvsx} is used the following additional vector types are 12560implemented. 12561 12562@smallexample 12563vector unsigned long 12564vector signed long 12565vector double 12566@end smallexample 12567 12568The long types are only implemented for 64-bit code generation, and 12569the long type is only used in the floating point/integer conversion 12570instructions. 12571 12572GCC's implementation of the high-level language interface available from 12573C and C++ code differs from Motorola's documentation in several ways. 12574 12575@itemize @bullet 12576 12577@item 12578A vector constant is a list of constant expressions within curly braces. 12579 12580@item 12581A vector initializer requires no cast if the vector constant is of the 12582same type as the variable it is initializing. 12583 12584@item 12585If @code{signed} or @code{unsigned} is omitted, the signedness of the 12586vector type is the default signedness of the base type. The default 12587varies depending on the operating system, so a portable program should 12588always specify the signedness. 12589 12590@item 12591Compiling with @option{-maltivec} adds keywords @code{__vector}, 12592@code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and 12593@code{bool}. When compiling ISO C, the context-sensitive substitution 12594of the keywords @code{vector}, @code{pixel} and @code{bool} is 12595disabled. To use them, you must include @code{<altivec.h>} instead. 12596 12597@item 12598GCC allows using a @code{typedef} name as the type specifier for a 12599vector type. 12600 12601@item 12602For C, overloaded functions are implemented with macros so the following 12603does not work: 12604 12605@smallexample 12606 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo); 12607@end smallexample 12608 12609@noindent 12610Since @code{vec_add} is a macro, the vector constant in the example 12611is treated as four separate arguments. Wrap the entire argument in 12612parentheses for this to work. 12613@end itemize 12614 12615@emph{Note:} Only the @code{<altivec.h>} interface is supported. 12616Internally, GCC uses built-in functions to achieve the functionality in 12617the aforementioned header file, but they are not supported and are 12618subject to change without notice. 12619 12620The following interfaces are supported for the generic and specific 12621AltiVec operations and the AltiVec predicates. In cases where there 12622is a direct mapping between generic and specific operations, only the 12623generic names are shown here, although the specific operations can also 12624be used. 12625 12626Arguments that are documented as @code{const int} require literal 12627integral values within the range required for that operation. 12628 12629@smallexample 12630vector signed char vec_abs (vector signed char); 12631vector signed short vec_abs (vector signed short); 12632vector signed int vec_abs (vector signed int); 12633vector float vec_abs (vector float); 12634 12635vector signed char vec_abss (vector signed char); 12636vector signed short vec_abss (vector signed short); 12637vector signed int vec_abss (vector signed int); 12638 12639vector signed char vec_add (vector bool char, vector signed char); 12640vector signed char vec_add (vector signed char, vector bool char); 12641vector signed char vec_add (vector signed char, vector signed char); 12642vector unsigned char vec_add (vector bool char, vector unsigned char); 12643vector unsigned char vec_add (vector unsigned char, vector bool char); 12644vector unsigned char vec_add (vector unsigned char, 12645 vector unsigned char); 12646vector signed short vec_add (vector bool short, vector signed short); 12647vector signed short vec_add (vector signed short, vector bool short); 12648vector signed short vec_add (vector signed short, vector signed short); 12649vector unsigned short vec_add (vector bool short, 12650 vector unsigned short); 12651vector unsigned short vec_add (vector unsigned short, 12652 vector bool short); 12653vector unsigned short vec_add (vector unsigned short, 12654 vector unsigned short); 12655vector signed int vec_add (vector bool int, vector signed int); 12656vector signed int vec_add (vector signed int, vector bool int); 12657vector signed int vec_add (vector signed int, vector signed int); 12658vector unsigned int vec_add (vector bool int, vector unsigned int); 12659vector unsigned int vec_add (vector unsigned int, vector bool int); 12660vector unsigned int vec_add (vector unsigned int, vector unsigned int); 12661vector float vec_add (vector float, vector float); 12662 12663vector float vec_vaddfp (vector float, vector float); 12664 12665vector signed int vec_vadduwm (vector bool int, vector signed int); 12666vector signed int vec_vadduwm (vector signed int, vector bool int); 12667vector signed int vec_vadduwm (vector signed int, vector signed int); 12668vector unsigned int vec_vadduwm (vector bool int, vector unsigned int); 12669vector unsigned int vec_vadduwm (vector unsigned int, vector bool int); 12670vector unsigned int vec_vadduwm (vector unsigned int, 12671 vector unsigned int); 12672 12673vector signed short vec_vadduhm (vector bool short, 12674 vector signed short); 12675vector signed short vec_vadduhm (vector signed short, 12676 vector bool short); 12677vector signed short vec_vadduhm (vector signed short, 12678 vector signed short); 12679vector unsigned short vec_vadduhm (vector bool short, 12680 vector unsigned short); 12681vector unsigned short vec_vadduhm (vector unsigned short, 12682 vector bool short); 12683vector unsigned short vec_vadduhm (vector unsigned short, 12684 vector unsigned short); 12685 12686vector signed char vec_vaddubm (vector bool char, vector signed char); 12687vector signed char vec_vaddubm (vector signed char, vector bool char); 12688vector signed char vec_vaddubm (vector signed char, vector signed char); 12689vector unsigned char vec_vaddubm (vector bool char, 12690 vector unsigned char); 12691vector unsigned char vec_vaddubm (vector unsigned char, 12692 vector bool char); 12693vector unsigned char vec_vaddubm (vector unsigned char, 12694 vector unsigned char); 12695 12696vector unsigned int vec_addc (vector unsigned int, vector unsigned int); 12697 12698vector unsigned char vec_adds (vector bool char, vector unsigned char); 12699vector unsigned char vec_adds (vector unsigned char, vector bool char); 12700vector unsigned char vec_adds (vector unsigned char, 12701 vector unsigned char); 12702vector signed char vec_adds (vector bool char, vector signed char); 12703vector signed char vec_adds (vector signed char, vector bool char); 12704vector signed char vec_adds (vector signed char, vector signed char); 12705vector unsigned short vec_adds (vector bool short, 12706 vector unsigned short); 12707vector unsigned short vec_adds (vector unsigned short, 12708 vector bool short); 12709vector unsigned short vec_adds (vector unsigned short, 12710 vector unsigned short); 12711vector signed short vec_adds (vector bool short, vector signed short); 12712vector signed short vec_adds (vector signed short, vector bool short); 12713vector signed short vec_adds (vector signed short, vector signed short); 12714vector unsigned int vec_adds (vector bool int, vector unsigned int); 12715vector unsigned int vec_adds (vector unsigned int, vector bool int); 12716vector unsigned int vec_adds (vector unsigned int, vector unsigned int); 12717vector signed int vec_adds (vector bool int, vector signed int); 12718vector signed int vec_adds (vector signed int, vector bool int); 12719vector signed int vec_adds (vector signed int, vector signed int); 12720 12721vector signed int vec_vaddsws (vector bool int, vector signed int); 12722vector signed int vec_vaddsws (vector signed int, vector bool int); 12723vector signed int vec_vaddsws (vector signed int, vector signed int); 12724 12725vector unsigned int vec_vadduws (vector bool int, vector unsigned int); 12726vector unsigned int vec_vadduws (vector unsigned int, vector bool int); 12727vector unsigned int vec_vadduws (vector unsigned int, 12728 vector unsigned int); 12729 12730vector signed short vec_vaddshs (vector bool short, 12731 vector signed short); 12732vector signed short vec_vaddshs (vector signed short, 12733 vector bool short); 12734vector signed short vec_vaddshs (vector signed short, 12735 vector signed short); 12736 12737vector unsigned short vec_vadduhs (vector bool short, 12738 vector unsigned short); 12739vector unsigned short vec_vadduhs (vector unsigned short, 12740 vector bool short); 12741vector unsigned short vec_vadduhs (vector unsigned short, 12742 vector unsigned short); 12743 12744vector signed char vec_vaddsbs (vector bool char, vector signed char); 12745vector signed char vec_vaddsbs (vector signed char, vector bool char); 12746vector signed char vec_vaddsbs (vector signed char, vector signed char); 12747 12748vector unsigned char vec_vaddubs (vector bool char, 12749 vector unsigned char); 12750vector unsigned char vec_vaddubs (vector unsigned char, 12751 vector bool char); 12752vector unsigned char vec_vaddubs (vector unsigned char, 12753 vector unsigned char); 12754 12755vector float vec_and (vector float, vector float); 12756vector float vec_and (vector float, vector bool int); 12757vector float vec_and (vector bool int, vector float); 12758vector bool int vec_and (vector bool int, vector bool int); 12759vector signed int vec_and (vector bool int, vector signed int); 12760vector signed int vec_and (vector signed int, vector bool int); 12761vector signed int vec_and (vector signed int, vector signed int); 12762vector unsigned int vec_and (vector bool int, vector unsigned int); 12763vector unsigned int vec_and (vector unsigned int, vector bool int); 12764vector unsigned int vec_and (vector unsigned int, vector unsigned int); 12765vector bool short vec_and (vector bool short, vector bool short); 12766vector signed short vec_and (vector bool short, vector signed short); 12767vector signed short vec_and (vector signed short, vector bool short); 12768vector signed short vec_and (vector signed short, vector signed short); 12769vector unsigned short vec_and (vector bool short, 12770 vector unsigned short); 12771vector unsigned short vec_and (vector unsigned short, 12772 vector bool short); 12773vector unsigned short vec_and (vector unsigned short, 12774 vector unsigned short); 12775vector signed char vec_and (vector bool char, vector signed char); 12776vector bool char vec_and (vector bool char, vector bool char); 12777vector signed char vec_and (vector signed char, vector bool char); 12778vector signed char vec_and (vector signed char, vector signed char); 12779vector unsigned char vec_and (vector bool char, vector unsigned char); 12780vector unsigned char vec_and (vector unsigned char, vector bool char); 12781vector unsigned char vec_and (vector unsigned char, 12782 vector unsigned char); 12783 12784vector float vec_andc (vector float, vector float); 12785vector float vec_andc (vector float, vector bool int); 12786vector float vec_andc (vector bool int, vector float); 12787vector bool int vec_andc (vector bool int, vector bool int); 12788vector signed int vec_andc (vector bool int, vector signed int); 12789vector signed int vec_andc (vector signed int, vector bool int); 12790vector signed int vec_andc (vector signed int, vector signed int); 12791vector unsigned int vec_andc (vector bool int, vector unsigned int); 12792vector unsigned int vec_andc (vector unsigned int, vector bool int); 12793vector unsigned int vec_andc (vector unsigned int, vector unsigned int); 12794vector bool short vec_andc (vector bool short, vector bool short); 12795vector signed short vec_andc (vector bool short, vector signed short); 12796vector signed short vec_andc (vector signed short, vector bool short); 12797vector signed short vec_andc (vector signed short, vector signed short); 12798vector unsigned short vec_andc (vector bool short, 12799 vector unsigned short); 12800vector unsigned short vec_andc (vector unsigned short, 12801 vector bool short); 12802vector unsigned short vec_andc (vector unsigned short, 12803 vector unsigned short); 12804vector signed char vec_andc (vector bool char, vector signed char); 12805vector bool char vec_andc (vector bool char, vector bool char); 12806vector signed char vec_andc (vector signed char, vector bool char); 12807vector signed char vec_andc (vector signed char, vector signed char); 12808vector unsigned char vec_andc (vector bool char, vector unsigned char); 12809vector unsigned char vec_andc (vector unsigned char, vector bool char); 12810vector unsigned char vec_andc (vector unsigned char, 12811 vector unsigned char); 12812 12813vector unsigned char vec_avg (vector unsigned char, 12814 vector unsigned char); 12815vector signed char vec_avg (vector signed char, vector signed char); 12816vector unsigned short vec_avg (vector unsigned short, 12817 vector unsigned short); 12818vector signed short vec_avg (vector signed short, vector signed short); 12819vector unsigned int vec_avg (vector unsigned int, vector unsigned int); 12820vector signed int vec_avg (vector signed int, vector signed int); 12821 12822vector signed int vec_vavgsw (vector signed int, vector signed int); 12823 12824vector unsigned int vec_vavguw (vector unsigned int, 12825 vector unsigned int); 12826 12827vector signed short vec_vavgsh (vector signed short, 12828 vector signed short); 12829 12830vector unsigned short vec_vavguh (vector unsigned short, 12831 vector unsigned short); 12832 12833vector signed char vec_vavgsb (vector signed char, vector signed char); 12834 12835vector unsigned char vec_vavgub (vector unsigned char, 12836 vector unsigned char); 12837 12838vector float vec_copysign (vector float); 12839 12840vector float vec_ceil (vector float); 12841 12842vector signed int vec_cmpb (vector float, vector float); 12843 12844vector bool char vec_cmpeq (vector signed char, vector signed char); 12845vector bool char vec_cmpeq (vector unsigned char, vector unsigned char); 12846vector bool short vec_cmpeq (vector signed short, vector signed short); 12847vector bool short vec_cmpeq (vector unsigned short, 12848 vector unsigned short); 12849vector bool int vec_cmpeq (vector signed int, vector signed int); 12850vector bool int vec_cmpeq (vector unsigned int, vector unsigned int); 12851vector bool int vec_cmpeq (vector float, vector float); 12852 12853vector bool int vec_vcmpeqfp (vector float, vector float); 12854 12855vector bool int vec_vcmpequw (vector signed int, vector signed int); 12856vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int); 12857 12858vector bool short vec_vcmpequh (vector signed short, 12859 vector signed short); 12860vector bool short vec_vcmpequh (vector unsigned short, 12861 vector unsigned short); 12862 12863vector bool char vec_vcmpequb (vector signed char, vector signed char); 12864vector bool char vec_vcmpequb (vector unsigned char, 12865 vector unsigned char); 12866 12867vector bool int vec_cmpge (vector float, vector float); 12868 12869vector bool char vec_cmpgt (vector unsigned char, vector unsigned char); 12870vector bool char vec_cmpgt (vector signed char, vector signed char); 12871vector bool short vec_cmpgt (vector unsigned short, 12872 vector unsigned short); 12873vector bool short vec_cmpgt (vector signed short, vector signed short); 12874vector bool int vec_cmpgt (vector unsigned int, vector unsigned int); 12875vector bool int vec_cmpgt (vector signed int, vector signed int); 12876vector bool int vec_cmpgt (vector float, vector float); 12877 12878vector bool int vec_vcmpgtfp (vector float, vector float); 12879 12880vector bool int vec_vcmpgtsw (vector signed int, vector signed int); 12881 12882vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int); 12883 12884vector bool short vec_vcmpgtsh (vector signed short, 12885 vector signed short); 12886 12887vector bool short vec_vcmpgtuh (vector unsigned short, 12888 vector unsigned short); 12889 12890vector bool char vec_vcmpgtsb (vector signed char, vector signed char); 12891 12892vector bool char vec_vcmpgtub (vector unsigned char, 12893 vector unsigned char); 12894 12895vector bool int vec_cmple (vector float, vector float); 12896 12897vector bool char vec_cmplt (vector unsigned char, vector unsigned char); 12898vector bool char vec_cmplt (vector signed char, vector signed char); 12899vector bool short vec_cmplt (vector unsigned short, 12900 vector unsigned short); 12901vector bool short vec_cmplt (vector signed short, vector signed short); 12902vector bool int vec_cmplt (vector unsigned int, vector unsigned int); 12903vector bool int vec_cmplt (vector signed int, vector signed int); 12904vector bool int vec_cmplt (vector float, vector float); 12905 12906vector float vec_cpsgn (vector float, vector float); 12907 12908vector float vec_ctf (vector unsigned int, const int); 12909vector float vec_ctf (vector signed int, const int); 12910vector double vec_ctf (vector unsigned long, const int); 12911vector double vec_ctf (vector signed long, const int); 12912 12913vector float vec_vcfsx (vector signed int, const int); 12914 12915vector float vec_vcfux (vector unsigned int, const int); 12916 12917vector signed int vec_cts (vector float, const int); 12918vector signed long vec_cts (vector double, const int); 12919 12920vector unsigned int vec_ctu (vector float, const int); 12921vector unsigned long vec_ctu (vector double, const int); 12922 12923void vec_dss (const int); 12924 12925void vec_dssall (void); 12926 12927void vec_dst (const vector unsigned char *, int, const int); 12928void vec_dst (const vector signed char *, int, const int); 12929void vec_dst (const vector bool char *, int, const int); 12930void vec_dst (const vector unsigned short *, int, const int); 12931void vec_dst (const vector signed short *, int, const int); 12932void vec_dst (const vector bool short *, int, const int); 12933void vec_dst (const vector pixel *, int, const int); 12934void vec_dst (const vector unsigned int *, int, const int); 12935void vec_dst (const vector signed int *, int, const int); 12936void vec_dst (const vector bool int *, int, const int); 12937void vec_dst (const vector float *, int, const int); 12938void vec_dst (const unsigned char *, int, const int); 12939void vec_dst (const signed char *, int, const int); 12940void vec_dst (const unsigned short *, int, const int); 12941void vec_dst (const short *, int, const int); 12942void vec_dst (const unsigned int *, int, const int); 12943void vec_dst (const int *, int, const int); 12944void vec_dst (const unsigned long *, int, const int); 12945void vec_dst (const long *, int, const int); 12946void vec_dst (const float *, int, const int); 12947 12948void vec_dstst (const vector unsigned char *, int, const int); 12949void vec_dstst (const vector signed char *, int, const int); 12950void vec_dstst (const vector bool char *, int, const int); 12951void vec_dstst (const vector unsigned short *, int, const int); 12952void vec_dstst (const vector signed short *, int, const int); 12953void vec_dstst (const vector bool short *, int, const int); 12954void vec_dstst (const vector pixel *, int, const int); 12955void vec_dstst (const vector unsigned int *, int, const int); 12956void vec_dstst (const vector signed int *, int, const int); 12957void vec_dstst (const vector bool int *, int, const int); 12958void vec_dstst (const vector float *, int, const int); 12959void vec_dstst (const unsigned char *, int, const int); 12960void vec_dstst (const signed char *, int, const int); 12961void vec_dstst (const unsigned short *, int, const int); 12962void vec_dstst (const short *, int, const int); 12963void vec_dstst (const unsigned int *, int, const int); 12964void vec_dstst (const int *, int, const int); 12965void vec_dstst (const unsigned long *, int, const int); 12966void vec_dstst (const long *, int, const int); 12967void vec_dstst (const float *, int, const int); 12968 12969void vec_dststt (const vector unsigned char *, int, const int); 12970void vec_dststt (const vector signed char *, int, const int); 12971void vec_dststt (const vector bool char *, int, const int); 12972void vec_dststt (const vector unsigned short *, int, const int); 12973void vec_dststt (const vector signed short *, int, const int); 12974void vec_dststt (const vector bool short *, int, const int); 12975void vec_dststt (const vector pixel *, int, const int); 12976void vec_dststt (const vector unsigned int *, int, const int); 12977void vec_dststt (const vector signed int *, int, const int); 12978void vec_dststt (const vector bool int *, int, const int); 12979void vec_dststt (const vector float *, int, const int); 12980void vec_dststt (const unsigned char *, int, const int); 12981void vec_dststt (const signed char *, int, const int); 12982void vec_dststt (const unsigned short *, int, const int); 12983void vec_dststt (const short *, int, const int); 12984void vec_dststt (const unsigned int *, int, const int); 12985void vec_dststt (const int *, int, const int); 12986void vec_dststt (const unsigned long *, int, const int); 12987void vec_dststt (const long *, int, const int); 12988void vec_dststt (const float *, int, const int); 12989 12990void vec_dstt (const vector unsigned char *, int, const int); 12991void vec_dstt (const vector signed char *, int, const int); 12992void vec_dstt (const vector bool char *, int, const int); 12993void vec_dstt (const vector unsigned short *, int, const int); 12994void vec_dstt (const vector signed short *, int, const int); 12995void vec_dstt (const vector bool short *, int, const int); 12996void vec_dstt (const vector pixel *, int, const int); 12997void vec_dstt (const vector unsigned int *, int, const int); 12998void vec_dstt (const vector signed int *, int, const int); 12999void vec_dstt (const vector bool int *, int, const int); 13000void vec_dstt (const vector float *, int, const int); 13001void vec_dstt (const unsigned char *, int, const int); 13002void vec_dstt (const signed char *, int, const int); 13003void vec_dstt (const unsigned short *, int, const int); 13004void vec_dstt (const short *, int, const int); 13005void vec_dstt (const unsigned int *, int, const int); 13006void vec_dstt (const int *, int, const int); 13007void vec_dstt (const unsigned long *, int, const int); 13008void vec_dstt (const long *, int, const int); 13009void vec_dstt (const float *, int, const int); 13010 13011vector float vec_expte (vector float); 13012 13013vector float vec_floor (vector float); 13014 13015vector float vec_ld (int, const vector float *); 13016vector float vec_ld (int, const float *); 13017vector bool int vec_ld (int, const vector bool int *); 13018vector signed int vec_ld (int, const vector signed int *); 13019vector signed int vec_ld (int, const int *); 13020vector signed int vec_ld (int, const long *); 13021vector unsigned int vec_ld (int, const vector unsigned int *); 13022vector unsigned int vec_ld (int, const unsigned int *); 13023vector unsigned int vec_ld (int, const unsigned long *); 13024vector bool short vec_ld (int, const vector bool short *); 13025vector pixel vec_ld (int, const vector pixel *); 13026vector signed short vec_ld (int, const vector signed short *); 13027vector signed short vec_ld (int, const short *); 13028vector unsigned short vec_ld (int, const vector unsigned short *); 13029vector unsigned short vec_ld (int, const unsigned short *); 13030vector bool char vec_ld (int, const vector bool char *); 13031vector signed char vec_ld (int, const vector signed char *); 13032vector signed char vec_ld (int, const signed char *); 13033vector unsigned char vec_ld (int, const vector unsigned char *); 13034vector unsigned char vec_ld (int, const unsigned char *); 13035 13036vector signed char vec_lde (int, const signed char *); 13037vector unsigned char vec_lde (int, const unsigned char *); 13038vector signed short vec_lde (int, const short *); 13039vector unsigned short vec_lde (int, const unsigned short *); 13040vector float vec_lde (int, const float *); 13041vector signed int vec_lde (int, const int *); 13042vector unsigned int vec_lde (int, const unsigned int *); 13043vector signed int vec_lde (int, const long *); 13044vector unsigned int vec_lde (int, const unsigned long *); 13045 13046vector float vec_lvewx (int, float *); 13047vector signed int vec_lvewx (int, int *); 13048vector unsigned int vec_lvewx (int, unsigned int *); 13049vector signed int vec_lvewx (int, long *); 13050vector unsigned int vec_lvewx (int, unsigned long *); 13051 13052vector signed short vec_lvehx (int, short *); 13053vector unsigned short vec_lvehx (int, unsigned short *); 13054 13055vector signed char vec_lvebx (int, char *); 13056vector unsigned char vec_lvebx (int, unsigned char *); 13057 13058vector float vec_ldl (int, const vector float *); 13059vector float vec_ldl (int, const float *); 13060vector bool int vec_ldl (int, const vector bool int *); 13061vector signed int vec_ldl (int, const vector signed int *); 13062vector signed int vec_ldl (int, const int *); 13063vector signed int vec_ldl (int, const long *); 13064vector unsigned int vec_ldl (int, const vector unsigned int *); 13065vector unsigned int vec_ldl (int, const unsigned int *); 13066vector unsigned int vec_ldl (int, const unsigned long *); 13067vector bool short vec_ldl (int, const vector bool short *); 13068vector pixel vec_ldl (int, const vector pixel *); 13069vector signed short vec_ldl (int, const vector signed short *); 13070vector signed short vec_ldl (int, const short *); 13071vector unsigned short vec_ldl (int, const vector unsigned short *); 13072vector unsigned short vec_ldl (int, const unsigned short *); 13073vector bool char vec_ldl (int, const vector bool char *); 13074vector signed char vec_ldl (int, const vector signed char *); 13075vector signed char vec_ldl (int, const signed char *); 13076vector unsigned char vec_ldl (int, const vector unsigned char *); 13077vector unsigned char vec_ldl (int, const unsigned char *); 13078 13079vector float vec_loge (vector float); 13080 13081vector unsigned char vec_lvsl (int, const volatile unsigned char *); 13082vector unsigned char vec_lvsl (int, const volatile signed char *); 13083vector unsigned char vec_lvsl (int, const volatile unsigned short *); 13084vector unsigned char vec_lvsl (int, const volatile short *); 13085vector unsigned char vec_lvsl (int, const volatile unsigned int *); 13086vector unsigned char vec_lvsl (int, const volatile int *); 13087vector unsigned char vec_lvsl (int, const volatile unsigned long *); 13088vector unsigned char vec_lvsl (int, const volatile long *); 13089vector unsigned char vec_lvsl (int, const volatile float *); 13090 13091vector unsigned char vec_lvsr (int, const volatile unsigned char *); 13092vector unsigned char vec_lvsr (int, const volatile signed char *); 13093vector unsigned char vec_lvsr (int, const volatile unsigned short *); 13094vector unsigned char vec_lvsr (int, const volatile short *); 13095vector unsigned char vec_lvsr (int, const volatile unsigned int *); 13096vector unsigned char vec_lvsr (int, const volatile int *); 13097vector unsigned char vec_lvsr (int, const volatile unsigned long *); 13098vector unsigned char vec_lvsr (int, const volatile long *); 13099vector unsigned char vec_lvsr (int, const volatile float *); 13100 13101vector float vec_madd (vector float, vector float, vector float); 13102 13103vector signed short vec_madds (vector signed short, 13104 vector signed short, 13105 vector signed short); 13106 13107vector unsigned char vec_max (vector bool char, vector unsigned char); 13108vector unsigned char vec_max (vector unsigned char, vector bool char); 13109vector unsigned char vec_max (vector unsigned char, 13110 vector unsigned char); 13111vector signed char vec_max (vector bool char, vector signed char); 13112vector signed char vec_max (vector signed char, vector bool char); 13113vector signed char vec_max (vector signed char, vector signed char); 13114vector unsigned short vec_max (vector bool short, 13115 vector unsigned short); 13116vector unsigned short vec_max (vector unsigned short, 13117 vector bool short); 13118vector unsigned short vec_max (vector unsigned short, 13119 vector unsigned short); 13120vector signed short vec_max (vector bool short, vector signed short); 13121vector signed short vec_max (vector signed short, vector bool short); 13122vector signed short vec_max (vector signed short, vector signed short); 13123vector unsigned int vec_max (vector bool int, vector unsigned int); 13124vector unsigned int vec_max (vector unsigned int, vector bool int); 13125vector unsigned int vec_max (vector unsigned int, vector unsigned int); 13126vector signed int vec_max (vector bool int, vector signed int); 13127vector signed int vec_max (vector signed int, vector bool int); 13128vector signed int vec_max (vector signed int, vector signed int); 13129vector float vec_max (vector float, vector float); 13130 13131vector float vec_vmaxfp (vector float, vector float); 13132 13133vector signed int vec_vmaxsw (vector bool int, vector signed int); 13134vector signed int vec_vmaxsw (vector signed int, vector bool int); 13135vector signed int vec_vmaxsw (vector signed int, vector signed int); 13136 13137vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int); 13138vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int); 13139vector unsigned int vec_vmaxuw (vector unsigned int, 13140 vector unsigned int); 13141 13142vector signed short vec_vmaxsh (vector bool short, vector signed short); 13143vector signed short vec_vmaxsh (vector signed short, vector bool short); 13144vector signed short vec_vmaxsh (vector signed short, 13145 vector signed short); 13146 13147vector unsigned short vec_vmaxuh (vector bool short, 13148 vector unsigned short); 13149vector unsigned short vec_vmaxuh (vector unsigned short, 13150 vector bool short); 13151vector unsigned short vec_vmaxuh (vector unsigned short, 13152 vector unsigned short); 13153 13154vector signed char vec_vmaxsb (vector bool char, vector signed char); 13155vector signed char vec_vmaxsb (vector signed char, vector bool char); 13156vector signed char vec_vmaxsb (vector signed char, vector signed char); 13157 13158vector unsigned char vec_vmaxub (vector bool char, 13159 vector unsigned char); 13160vector unsigned char vec_vmaxub (vector unsigned char, 13161 vector bool char); 13162vector unsigned char vec_vmaxub (vector unsigned char, 13163 vector unsigned char); 13164 13165vector bool char vec_mergeh (vector bool char, vector bool char); 13166vector signed char vec_mergeh (vector signed char, vector signed char); 13167vector unsigned char vec_mergeh (vector unsigned char, 13168 vector unsigned char); 13169vector bool short vec_mergeh (vector bool short, vector bool short); 13170vector pixel vec_mergeh (vector pixel, vector pixel); 13171vector signed short vec_mergeh (vector signed short, 13172 vector signed short); 13173vector unsigned short vec_mergeh (vector unsigned short, 13174 vector unsigned short); 13175vector float vec_mergeh (vector float, vector float); 13176vector bool int vec_mergeh (vector bool int, vector bool int); 13177vector signed int vec_mergeh (vector signed int, vector signed int); 13178vector unsigned int vec_mergeh (vector unsigned int, 13179 vector unsigned int); 13180 13181vector float vec_vmrghw (vector float, vector float); 13182vector bool int vec_vmrghw (vector bool int, vector bool int); 13183vector signed int vec_vmrghw (vector signed int, vector signed int); 13184vector unsigned int vec_vmrghw (vector unsigned int, 13185 vector unsigned int); 13186 13187vector bool short vec_vmrghh (vector bool short, vector bool short); 13188vector signed short vec_vmrghh (vector signed short, 13189 vector signed short); 13190vector unsigned short vec_vmrghh (vector unsigned short, 13191 vector unsigned short); 13192vector pixel vec_vmrghh (vector pixel, vector pixel); 13193 13194vector bool char vec_vmrghb (vector bool char, vector bool char); 13195vector signed char vec_vmrghb (vector signed char, vector signed char); 13196vector unsigned char vec_vmrghb (vector unsigned char, 13197 vector unsigned char); 13198 13199vector bool char vec_mergel (vector bool char, vector bool char); 13200vector signed char vec_mergel (vector signed char, vector signed char); 13201vector unsigned char vec_mergel (vector unsigned char, 13202 vector unsigned char); 13203vector bool short vec_mergel (vector bool short, vector bool short); 13204vector pixel vec_mergel (vector pixel, vector pixel); 13205vector signed short vec_mergel (vector signed short, 13206 vector signed short); 13207vector unsigned short vec_mergel (vector unsigned short, 13208 vector unsigned short); 13209vector float vec_mergel (vector float, vector float); 13210vector bool int vec_mergel (vector bool int, vector bool int); 13211vector signed int vec_mergel (vector signed int, vector signed int); 13212vector unsigned int vec_mergel (vector unsigned int, 13213 vector unsigned int); 13214 13215vector float vec_vmrglw (vector float, vector float); 13216vector signed int vec_vmrglw (vector signed int, vector signed int); 13217vector unsigned int vec_vmrglw (vector unsigned int, 13218 vector unsigned int); 13219vector bool int vec_vmrglw (vector bool int, vector bool int); 13220 13221vector bool short vec_vmrglh (vector bool short, vector bool short); 13222vector signed short vec_vmrglh (vector signed short, 13223 vector signed short); 13224vector unsigned short vec_vmrglh (vector unsigned short, 13225 vector unsigned short); 13226vector pixel vec_vmrglh (vector pixel, vector pixel); 13227 13228vector bool char vec_vmrglb (vector bool char, vector bool char); 13229vector signed char vec_vmrglb (vector signed char, vector signed char); 13230vector unsigned char vec_vmrglb (vector unsigned char, 13231 vector unsigned char); 13232 13233vector unsigned short vec_mfvscr (void); 13234 13235vector unsigned char vec_min (vector bool char, vector unsigned char); 13236vector unsigned char vec_min (vector unsigned char, vector bool char); 13237vector unsigned char vec_min (vector unsigned char, 13238 vector unsigned char); 13239vector signed char vec_min (vector bool char, vector signed char); 13240vector signed char vec_min (vector signed char, vector bool char); 13241vector signed char vec_min (vector signed char, vector signed char); 13242vector unsigned short vec_min (vector bool short, 13243 vector unsigned short); 13244vector unsigned short vec_min (vector unsigned short, 13245 vector bool short); 13246vector unsigned short vec_min (vector unsigned short, 13247 vector unsigned short); 13248vector signed short vec_min (vector bool short, vector signed short); 13249vector signed short vec_min (vector signed short, vector bool short); 13250vector signed short vec_min (vector signed short, vector signed short); 13251vector unsigned int vec_min (vector bool int, vector unsigned int); 13252vector unsigned int vec_min (vector unsigned int, vector bool int); 13253vector unsigned int vec_min (vector unsigned int, vector unsigned int); 13254vector signed int vec_min (vector bool int, vector signed int); 13255vector signed int vec_min (vector signed int, vector bool int); 13256vector signed int vec_min (vector signed int, vector signed int); 13257vector float vec_min (vector float, vector float); 13258 13259vector float vec_vminfp (vector float, vector float); 13260 13261vector signed int vec_vminsw (vector bool int, vector signed int); 13262vector signed int vec_vminsw (vector signed int, vector bool int); 13263vector signed int vec_vminsw (vector signed int, vector signed int); 13264 13265vector unsigned int vec_vminuw (vector bool int, vector unsigned int); 13266vector unsigned int vec_vminuw (vector unsigned int, vector bool int); 13267vector unsigned int vec_vminuw (vector unsigned int, 13268 vector unsigned int); 13269 13270vector signed short vec_vminsh (vector bool short, vector signed short); 13271vector signed short vec_vminsh (vector signed short, vector bool short); 13272vector signed short vec_vminsh (vector signed short, 13273 vector signed short); 13274 13275vector unsigned short vec_vminuh (vector bool short, 13276 vector unsigned short); 13277vector unsigned short vec_vminuh (vector unsigned short, 13278 vector bool short); 13279vector unsigned short vec_vminuh (vector unsigned short, 13280 vector unsigned short); 13281 13282vector signed char vec_vminsb (vector bool char, vector signed char); 13283vector signed char vec_vminsb (vector signed char, vector bool char); 13284vector signed char vec_vminsb (vector signed char, vector signed char); 13285 13286vector unsigned char vec_vminub (vector bool char, 13287 vector unsigned char); 13288vector unsigned char vec_vminub (vector unsigned char, 13289 vector bool char); 13290vector unsigned char vec_vminub (vector unsigned char, 13291 vector unsigned char); 13292 13293vector signed short vec_mladd (vector signed short, 13294 vector signed short, 13295 vector signed short); 13296vector signed short vec_mladd (vector signed short, 13297 vector unsigned short, 13298 vector unsigned short); 13299vector signed short vec_mladd (vector unsigned short, 13300 vector signed short, 13301 vector signed short); 13302vector unsigned short vec_mladd (vector unsigned short, 13303 vector unsigned short, 13304 vector unsigned short); 13305 13306vector signed short vec_mradds (vector signed short, 13307 vector signed short, 13308 vector signed short); 13309 13310vector unsigned int vec_msum (vector unsigned char, 13311 vector unsigned char, 13312 vector unsigned int); 13313vector signed int vec_msum (vector signed char, 13314 vector unsigned char, 13315 vector signed int); 13316vector unsigned int vec_msum (vector unsigned short, 13317 vector unsigned short, 13318 vector unsigned int); 13319vector signed int vec_msum (vector signed short, 13320 vector signed short, 13321 vector signed int); 13322 13323vector signed int vec_vmsumshm (vector signed short, 13324 vector signed short, 13325 vector signed int); 13326 13327vector unsigned int vec_vmsumuhm (vector unsigned short, 13328 vector unsigned short, 13329 vector unsigned int); 13330 13331vector signed int vec_vmsummbm (vector signed char, 13332 vector unsigned char, 13333 vector signed int); 13334 13335vector unsigned int vec_vmsumubm (vector unsigned char, 13336 vector unsigned char, 13337 vector unsigned int); 13338 13339vector unsigned int vec_msums (vector unsigned short, 13340 vector unsigned short, 13341 vector unsigned int); 13342vector signed int vec_msums (vector signed short, 13343 vector signed short, 13344 vector signed int); 13345 13346vector signed int vec_vmsumshs (vector signed short, 13347 vector signed short, 13348 vector signed int); 13349 13350vector unsigned int vec_vmsumuhs (vector unsigned short, 13351 vector unsigned short, 13352 vector unsigned int); 13353 13354void vec_mtvscr (vector signed int); 13355void vec_mtvscr (vector unsigned int); 13356void vec_mtvscr (vector bool int); 13357void vec_mtvscr (vector signed short); 13358void vec_mtvscr (vector unsigned short); 13359void vec_mtvscr (vector bool short); 13360void vec_mtvscr (vector pixel); 13361void vec_mtvscr (vector signed char); 13362void vec_mtvscr (vector unsigned char); 13363void vec_mtvscr (vector bool char); 13364 13365vector unsigned short vec_mule (vector unsigned char, 13366 vector unsigned char); 13367vector signed short vec_mule (vector signed char, 13368 vector signed char); 13369vector unsigned int vec_mule (vector unsigned short, 13370 vector unsigned short); 13371vector signed int vec_mule (vector signed short, vector signed short); 13372 13373vector signed int vec_vmulesh (vector signed short, 13374 vector signed short); 13375 13376vector unsigned int vec_vmuleuh (vector unsigned short, 13377 vector unsigned short); 13378 13379vector signed short vec_vmulesb (vector signed char, 13380 vector signed char); 13381 13382vector unsigned short vec_vmuleub (vector unsigned char, 13383 vector unsigned char); 13384 13385vector unsigned short vec_mulo (vector unsigned char, 13386 vector unsigned char); 13387vector signed short vec_mulo (vector signed char, vector signed char); 13388vector unsigned int vec_mulo (vector unsigned short, 13389 vector unsigned short); 13390vector signed int vec_mulo (vector signed short, vector signed short); 13391 13392vector signed int vec_vmulosh (vector signed short, 13393 vector signed short); 13394 13395vector unsigned int vec_vmulouh (vector unsigned short, 13396 vector unsigned short); 13397 13398vector signed short vec_vmulosb (vector signed char, 13399 vector signed char); 13400 13401vector unsigned short vec_vmuloub (vector unsigned char, 13402 vector unsigned char); 13403 13404vector float vec_nmsub (vector float, vector float, vector float); 13405 13406vector float vec_nor (vector float, vector float); 13407vector signed int vec_nor (vector signed int, vector signed int); 13408vector unsigned int vec_nor (vector unsigned int, vector unsigned int); 13409vector bool int vec_nor (vector bool int, vector bool int); 13410vector signed short vec_nor (vector signed short, vector signed short); 13411vector unsigned short vec_nor (vector unsigned short, 13412 vector unsigned short); 13413vector bool short vec_nor (vector bool short, vector bool short); 13414vector signed char vec_nor (vector signed char, vector signed char); 13415vector unsigned char vec_nor (vector unsigned char, 13416 vector unsigned char); 13417vector bool char vec_nor (vector bool char, vector bool char); 13418 13419vector float vec_or (vector float, vector float); 13420vector float vec_or (vector float, vector bool int); 13421vector float vec_or (vector bool int, vector float); 13422vector bool int vec_or (vector bool int, vector bool int); 13423vector signed int vec_or (vector bool int, vector signed int); 13424vector signed int vec_or (vector signed int, vector bool int); 13425vector signed int vec_or (vector signed int, vector signed int); 13426vector unsigned int vec_or (vector bool int, vector unsigned int); 13427vector unsigned int vec_or (vector unsigned int, vector bool int); 13428vector unsigned int vec_or (vector unsigned int, vector unsigned int); 13429vector bool short vec_or (vector bool short, vector bool short); 13430vector signed short vec_or (vector bool short, vector signed short); 13431vector signed short vec_or (vector signed short, vector bool short); 13432vector signed short vec_or (vector signed short, vector signed short); 13433vector unsigned short vec_or (vector bool short, vector unsigned short); 13434vector unsigned short vec_or (vector unsigned short, vector bool short); 13435vector unsigned short vec_or (vector unsigned short, 13436 vector unsigned short); 13437vector signed char vec_or (vector bool char, vector signed char); 13438vector bool char vec_or (vector bool char, vector bool char); 13439vector signed char vec_or (vector signed char, vector bool char); 13440vector signed char vec_or (vector signed char, vector signed char); 13441vector unsigned char vec_or (vector bool char, vector unsigned char); 13442vector unsigned char vec_or (vector unsigned char, vector bool char); 13443vector unsigned char vec_or (vector unsigned char, 13444 vector unsigned char); 13445 13446vector signed char vec_pack (vector signed short, vector signed short); 13447vector unsigned char vec_pack (vector unsigned short, 13448 vector unsigned short); 13449vector bool char vec_pack (vector bool short, vector bool short); 13450vector signed short vec_pack (vector signed int, vector signed int); 13451vector unsigned short vec_pack (vector unsigned int, 13452 vector unsigned int); 13453vector bool short vec_pack (vector bool int, vector bool int); 13454 13455vector bool short vec_vpkuwum (vector bool int, vector bool int); 13456vector signed short vec_vpkuwum (vector signed int, vector signed int); 13457vector unsigned short vec_vpkuwum (vector unsigned int, 13458 vector unsigned int); 13459 13460vector bool char vec_vpkuhum (vector bool short, vector bool short); 13461vector signed char vec_vpkuhum (vector signed short, 13462 vector signed short); 13463vector unsigned char vec_vpkuhum (vector unsigned short, 13464 vector unsigned short); 13465 13466vector pixel vec_packpx (vector unsigned int, vector unsigned int); 13467 13468vector unsigned char vec_packs (vector unsigned short, 13469 vector unsigned short); 13470vector signed char vec_packs (vector signed short, vector signed short); 13471vector unsigned short vec_packs (vector unsigned int, 13472 vector unsigned int); 13473vector signed short vec_packs (vector signed int, vector signed int); 13474 13475vector signed short vec_vpkswss (vector signed int, vector signed int); 13476 13477vector unsigned short vec_vpkuwus (vector unsigned int, 13478 vector unsigned int); 13479 13480vector signed char vec_vpkshss (vector signed short, 13481 vector signed short); 13482 13483vector unsigned char vec_vpkuhus (vector unsigned short, 13484 vector unsigned short); 13485 13486vector unsigned char vec_packsu (vector unsigned short, 13487 vector unsigned short); 13488vector unsigned char vec_packsu (vector signed short, 13489 vector signed short); 13490vector unsigned short vec_packsu (vector unsigned int, 13491 vector unsigned int); 13492vector unsigned short vec_packsu (vector signed int, vector signed int); 13493 13494vector unsigned short vec_vpkswus (vector signed int, 13495 vector signed int); 13496 13497vector unsigned char vec_vpkshus (vector signed short, 13498 vector signed short); 13499 13500vector float vec_perm (vector float, 13501 vector float, 13502 vector unsigned char); 13503vector signed int vec_perm (vector signed int, 13504 vector signed int, 13505 vector unsigned char); 13506vector unsigned int vec_perm (vector unsigned int, 13507 vector unsigned int, 13508 vector unsigned char); 13509vector bool int vec_perm (vector bool int, 13510 vector bool int, 13511 vector unsigned char); 13512vector signed short vec_perm (vector signed short, 13513 vector signed short, 13514 vector unsigned char); 13515vector unsigned short vec_perm (vector unsigned short, 13516 vector unsigned short, 13517 vector unsigned char); 13518vector bool short vec_perm (vector bool short, 13519 vector bool short, 13520 vector unsigned char); 13521vector pixel vec_perm (vector pixel, 13522 vector pixel, 13523 vector unsigned char); 13524vector signed char vec_perm (vector signed char, 13525 vector signed char, 13526 vector unsigned char); 13527vector unsigned char vec_perm (vector unsigned char, 13528 vector unsigned char, 13529 vector unsigned char); 13530vector bool char vec_perm (vector bool char, 13531 vector bool char, 13532 vector unsigned char); 13533 13534vector float vec_re (vector float); 13535 13536vector signed char vec_rl (vector signed char, 13537 vector unsigned char); 13538vector unsigned char vec_rl (vector unsigned char, 13539 vector unsigned char); 13540vector signed short vec_rl (vector signed short, vector unsigned short); 13541vector unsigned short vec_rl (vector unsigned short, 13542 vector unsigned short); 13543vector signed int vec_rl (vector signed int, vector unsigned int); 13544vector unsigned int vec_rl (vector unsigned int, vector unsigned int); 13545 13546vector signed int vec_vrlw (vector signed int, vector unsigned int); 13547vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int); 13548 13549vector signed short vec_vrlh (vector signed short, 13550 vector unsigned short); 13551vector unsigned short vec_vrlh (vector unsigned short, 13552 vector unsigned short); 13553 13554vector signed char vec_vrlb (vector signed char, vector unsigned char); 13555vector unsigned char vec_vrlb (vector unsigned char, 13556 vector unsigned char); 13557 13558vector float vec_round (vector float); 13559 13560vector float vec_recip (vector float, vector float); 13561 13562vector float vec_rsqrt (vector float); 13563 13564vector float vec_rsqrte (vector float); 13565 13566vector float vec_sel (vector float, vector float, vector bool int); 13567vector float vec_sel (vector float, vector float, vector unsigned int); 13568vector signed int vec_sel (vector signed int, 13569 vector signed int, 13570 vector bool int); 13571vector signed int vec_sel (vector signed int, 13572 vector signed int, 13573 vector unsigned int); 13574vector unsigned int vec_sel (vector unsigned int, 13575 vector unsigned int, 13576 vector bool int); 13577vector unsigned int vec_sel (vector unsigned int, 13578 vector unsigned int, 13579 vector unsigned int); 13580vector bool int vec_sel (vector bool int, 13581 vector bool int, 13582 vector bool int); 13583vector bool int vec_sel (vector bool int, 13584 vector bool int, 13585 vector unsigned int); 13586vector signed short vec_sel (vector signed short, 13587 vector signed short, 13588 vector bool short); 13589vector signed short vec_sel (vector signed short, 13590 vector signed short, 13591 vector unsigned short); 13592vector unsigned short vec_sel (vector unsigned short, 13593 vector unsigned short, 13594 vector bool short); 13595vector unsigned short vec_sel (vector unsigned short, 13596 vector unsigned short, 13597 vector unsigned short); 13598vector bool short vec_sel (vector bool short, 13599 vector bool short, 13600 vector bool short); 13601vector bool short vec_sel (vector bool short, 13602 vector bool short, 13603 vector unsigned short); 13604vector signed char vec_sel (vector signed char, 13605 vector signed char, 13606 vector bool char); 13607vector signed char vec_sel (vector signed char, 13608 vector signed char, 13609 vector unsigned char); 13610vector unsigned char vec_sel (vector unsigned char, 13611 vector unsigned char, 13612 vector bool char); 13613vector unsigned char vec_sel (vector unsigned char, 13614 vector unsigned char, 13615 vector unsigned char); 13616vector bool char vec_sel (vector bool char, 13617 vector bool char, 13618 vector bool char); 13619vector bool char vec_sel (vector bool char, 13620 vector bool char, 13621 vector unsigned char); 13622 13623vector signed char vec_sl (vector signed char, 13624 vector unsigned char); 13625vector unsigned char vec_sl (vector unsigned char, 13626 vector unsigned char); 13627vector signed short vec_sl (vector signed short, vector unsigned short); 13628vector unsigned short vec_sl (vector unsigned short, 13629 vector unsigned short); 13630vector signed int vec_sl (vector signed int, vector unsigned int); 13631vector unsigned int vec_sl (vector unsigned int, vector unsigned int); 13632 13633vector signed int vec_vslw (vector signed int, vector unsigned int); 13634vector unsigned int vec_vslw (vector unsigned int, vector unsigned int); 13635 13636vector signed short vec_vslh (vector signed short, 13637 vector unsigned short); 13638vector unsigned short vec_vslh (vector unsigned short, 13639 vector unsigned short); 13640 13641vector signed char vec_vslb (vector signed char, vector unsigned char); 13642vector unsigned char vec_vslb (vector unsigned char, 13643 vector unsigned char); 13644 13645vector float vec_sld (vector float, vector float, const int); 13646vector signed int vec_sld (vector signed int, 13647 vector signed int, 13648 const int); 13649vector unsigned int vec_sld (vector unsigned int, 13650 vector unsigned int, 13651 const int); 13652vector bool int vec_sld (vector bool int, 13653 vector bool int, 13654 const int); 13655vector signed short vec_sld (vector signed short, 13656 vector signed short, 13657 const int); 13658vector unsigned short vec_sld (vector unsigned short, 13659 vector unsigned short, 13660 const int); 13661vector bool short vec_sld (vector bool short, 13662 vector bool short, 13663 const int); 13664vector pixel vec_sld (vector pixel, 13665 vector pixel, 13666 const int); 13667vector signed char vec_sld (vector signed char, 13668 vector signed char, 13669 const int); 13670vector unsigned char vec_sld (vector unsigned char, 13671 vector unsigned char, 13672 const int); 13673vector bool char vec_sld (vector bool char, 13674 vector bool char, 13675 const int); 13676 13677vector signed int vec_sll (vector signed int, 13678 vector unsigned int); 13679vector signed int vec_sll (vector signed int, 13680 vector unsigned short); 13681vector signed int vec_sll (vector signed int, 13682 vector unsigned char); 13683vector unsigned int vec_sll (vector unsigned int, 13684 vector unsigned int); 13685vector unsigned int vec_sll (vector unsigned int, 13686 vector unsigned short); 13687vector unsigned int vec_sll (vector unsigned int, 13688 vector unsigned char); 13689vector bool int vec_sll (vector bool int, 13690 vector unsigned int); 13691vector bool int vec_sll (vector bool int, 13692 vector unsigned short); 13693vector bool int vec_sll (vector bool int, 13694 vector unsigned char); 13695vector signed short vec_sll (vector signed short, 13696 vector unsigned int); 13697vector signed short vec_sll (vector signed short, 13698 vector unsigned short); 13699vector signed short vec_sll (vector signed short, 13700 vector unsigned char); 13701vector unsigned short vec_sll (vector unsigned short, 13702 vector unsigned int); 13703vector unsigned short vec_sll (vector unsigned short, 13704 vector unsigned short); 13705vector unsigned short vec_sll (vector unsigned short, 13706 vector unsigned char); 13707vector bool short vec_sll (vector bool short, vector unsigned int); 13708vector bool short vec_sll (vector bool short, vector unsigned short); 13709vector bool short vec_sll (vector bool short, vector unsigned char); 13710vector pixel vec_sll (vector pixel, vector unsigned int); 13711vector pixel vec_sll (vector pixel, vector unsigned short); 13712vector pixel vec_sll (vector pixel, vector unsigned char); 13713vector signed char vec_sll (vector signed char, vector unsigned int); 13714vector signed char vec_sll (vector signed char, vector unsigned short); 13715vector signed char vec_sll (vector signed char, vector unsigned char); 13716vector unsigned char vec_sll (vector unsigned char, 13717 vector unsigned int); 13718vector unsigned char vec_sll (vector unsigned char, 13719 vector unsigned short); 13720vector unsigned char vec_sll (vector unsigned char, 13721 vector unsigned char); 13722vector bool char vec_sll (vector bool char, vector unsigned int); 13723vector bool char vec_sll (vector bool char, vector unsigned short); 13724vector bool char vec_sll (vector bool char, vector unsigned char); 13725 13726vector float vec_slo (vector float, vector signed char); 13727vector float vec_slo (vector float, vector unsigned char); 13728vector signed int vec_slo (vector signed int, vector signed char); 13729vector signed int vec_slo (vector signed int, vector unsigned char); 13730vector unsigned int vec_slo (vector unsigned int, vector signed char); 13731vector unsigned int vec_slo (vector unsigned int, vector unsigned char); 13732vector signed short vec_slo (vector signed short, vector signed char); 13733vector signed short vec_slo (vector signed short, vector unsigned char); 13734vector unsigned short vec_slo (vector unsigned short, 13735 vector signed char); 13736vector unsigned short vec_slo (vector unsigned short, 13737 vector unsigned char); 13738vector pixel vec_slo (vector pixel, vector signed char); 13739vector pixel vec_slo (vector pixel, vector unsigned char); 13740vector signed char vec_slo (vector signed char, vector signed char); 13741vector signed char vec_slo (vector signed char, vector unsigned char); 13742vector unsigned char vec_slo (vector unsigned char, vector signed char); 13743vector unsigned char vec_slo (vector unsigned char, 13744 vector unsigned char); 13745 13746vector signed char vec_splat (vector signed char, const int); 13747vector unsigned char vec_splat (vector unsigned char, const int); 13748vector bool char vec_splat (vector bool char, const int); 13749vector signed short vec_splat (vector signed short, const int); 13750vector unsigned short vec_splat (vector unsigned short, const int); 13751vector bool short vec_splat (vector bool short, const int); 13752vector pixel vec_splat (vector pixel, const int); 13753vector float vec_splat (vector float, const int); 13754vector signed int vec_splat (vector signed int, const int); 13755vector unsigned int vec_splat (vector unsigned int, const int); 13756vector bool int vec_splat (vector bool int, const int); 13757vector signed long vec_splat (vector signed long, const int); 13758vector unsigned long vec_splat (vector unsigned long, const int); 13759 13760vector signed char vec_splats (signed char); 13761vector unsigned char vec_splats (unsigned char); 13762vector signed short vec_splats (signed short); 13763vector unsigned short vec_splats (unsigned short); 13764vector signed int vec_splats (signed int); 13765vector unsigned int vec_splats (unsigned int); 13766vector float vec_splats (float); 13767 13768vector float vec_vspltw (vector float, const int); 13769vector signed int vec_vspltw (vector signed int, const int); 13770vector unsigned int vec_vspltw (vector unsigned int, const int); 13771vector bool int vec_vspltw (vector bool int, const int); 13772 13773vector bool short vec_vsplth (vector bool short, const int); 13774vector signed short vec_vsplth (vector signed short, const int); 13775vector unsigned short vec_vsplth (vector unsigned short, const int); 13776vector pixel vec_vsplth (vector pixel, const int); 13777 13778vector signed char vec_vspltb (vector signed char, const int); 13779vector unsigned char vec_vspltb (vector unsigned char, const int); 13780vector bool char vec_vspltb (vector bool char, const int); 13781 13782vector signed char vec_splat_s8 (const int); 13783 13784vector signed short vec_splat_s16 (const int); 13785 13786vector signed int vec_splat_s32 (const int); 13787 13788vector unsigned char vec_splat_u8 (const int); 13789 13790vector unsigned short vec_splat_u16 (const int); 13791 13792vector unsigned int vec_splat_u32 (const int); 13793 13794vector signed char vec_sr (vector signed char, vector unsigned char); 13795vector unsigned char vec_sr (vector unsigned char, 13796 vector unsigned char); 13797vector signed short vec_sr (vector signed short, 13798 vector unsigned short); 13799vector unsigned short vec_sr (vector unsigned short, 13800 vector unsigned short); 13801vector signed int vec_sr (vector signed int, vector unsigned int); 13802vector unsigned int vec_sr (vector unsigned int, vector unsigned int); 13803 13804vector signed int vec_vsrw (vector signed int, vector unsigned int); 13805vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int); 13806 13807vector signed short vec_vsrh (vector signed short, 13808 vector unsigned short); 13809vector unsigned short vec_vsrh (vector unsigned short, 13810 vector unsigned short); 13811 13812vector signed char vec_vsrb (vector signed char, vector unsigned char); 13813vector unsigned char vec_vsrb (vector unsigned char, 13814 vector unsigned char); 13815 13816vector signed char vec_sra (vector signed char, vector unsigned char); 13817vector unsigned char vec_sra (vector unsigned char, 13818 vector unsigned char); 13819vector signed short vec_sra (vector signed short, 13820 vector unsigned short); 13821vector unsigned short vec_sra (vector unsigned short, 13822 vector unsigned short); 13823vector signed int vec_sra (vector signed int, vector unsigned int); 13824vector unsigned int vec_sra (vector unsigned int, vector unsigned int); 13825 13826vector signed int vec_vsraw (vector signed int, vector unsigned int); 13827vector unsigned int vec_vsraw (vector unsigned int, 13828 vector unsigned int); 13829 13830vector signed short vec_vsrah (vector signed short, 13831 vector unsigned short); 13832vector unsigned short vec_vsrah (vector unsigned short, 13833 vector unsigned short); 13834 13835vector signed char vec_vsrab (vector signed char, vector unsigned char); 13836vector unsigned char vec_vsrab (vector unsigned char, 13837 vector unsigned char); 13838 13839vector signed int vec_srl (vector signed int, vector unsigned int); 13840vector signed int vec_srl (vector signed int, vector unsigned short); 13841vector signed int vec_srl (vector signed int, vector unsigned char); 13842vector unsigned int vec_srl (vector unsigned int, vector unsigned int); 13843vector unsigned int vec_srl (vector unsigned int, 13844 vector unsigned short); 13845vector unsigned int vec_srl (vector unsigned int, vector unsigned char); 13846vector bool int vec_srl (vector bool int, vector unsigned int); 13847vector bool int vec_srl (vector bool int, vector unsigned short); 13848vector bool int vec_srl (vector bool int, vector unsigned char); 13849vector signed short vec_srl (vector signed short, vector unsigned int); 13850vector signed short vec_srl (vector signed short, 13851 vector unsigned short); 13852vector signed short vec_srl (vector signed short, vector unsigned char); 13853vector unsigned short vec_srl (vector unsigned short, 13854 vector unsigned int); 13855vector unsigned short vec_srl (vector unsigned short, 13856 vector unsigned short); 13857vector unsigned short vec_srl (vector unsigned short, 13858 vector unsigned char); 13859vector bool short vec_srl (vector bool short, vector unsigned int); 13860vector bool short vec_srl (vector bool short, vector unsigned short); 13861vector bool short vec_srl (vector bool short, vector unsigned char); 13862vector pixel vec_srl (vector pixel, vector unsigned int); 13863vector pixel vec_srl (vector pixel, vector unsigned short); 13864vector pixel vec_srl (vector pixel, vector unsigned char); 13865vector signed char vec_srl (vector signed char, vector unsigned int); 13866vector signed char vec_srl (vector signed char, vector unsigned short); 13867vector signed char vec_srl (vector signed char, vector unsigned char); 13868vector unsigned char vec_srl (vector unsigned char, 13869 vector unsigned int); 13870vector unsigned char vec_srl (vector unsigned char, 13871 vector unsigned short); 13872vector unsigned char vec_srl (vector unsigned char, 13873 vector unsigned char); 13874vector bool char vec_srl (vector bool char, vector unsigned int); 13875vector bool char vec_srl (vector bool char, vector unsigned short); 13876vector bool char vec_srl (vector bool char, vector unsigned char); 13877 13878vector float vec_sro (vector float, vector signed char); 13879vector float vec_sro (vector float, vector unsigned char); 13880vector signed int vec_sro (vector signed int, vector signed char); 13881vector signed int vec_sro (vector signed int, vector unsigned char); 13882vector unsigned int vec_sro (vector unsigned int, vector signed char); 13883vector unsigned int vec_sro (vector unsigned int, vector unsigned char); 13884vector signed short vec_sro (vector signed short, vector signed char); 13885vector signed short vec_sro (vector signed short, vector unsigned char); 13886vector unsigned short vec_sro (vector unsigned short, 13887 vector signed char); 13888vector unsigned short vec_sro (vector unsigned short, 13889 vector unsigned char); 13890vector pixel vec_sro (vector pixel, vector signed char); 13891vector pixel vec_sro (vector pixel, vector unsigned char); 13892vector signed char vec_sro (vector signed char, vector signed char); 13893vector signed char vec_sro (vector signed char, vector unsigned char); 13894vector unsigned char vec_sro (vector unsigned char, vector signed char); 13895vector unsigned char vec_sro (vector unsigned char, 13896 vector unsigned char); 13897 13898void vec_st (vector float, int, vector float *); 13899void vec_st (vector float, int, float *); 13900void vec_st (vector signed int, int, vector signed int *); 13901void vec_st (vector signed int, int, int *); 13902void vec_st (vector unsigned int, int, vector unsigned int *); 13903void vec_st (vector unsigned int, int, unsigned int *); 13904void vec_st (vector bool int, int, vector bool int *); 13905void vec_st (vector bool int, int, unsigned int *); 13906void vec_st (vector bool int, int, int *); 13907void vec_st (vector signed short, int, vector signed short *); 13908void vec_st (vector signed short, int, short *); 13909void vec_st (vector unsigned short, int, vector unsigned short *); 13910void vec_st (vector unsigned short, int, unsigned short *); 13911void vec_st (vector bool short, int, vector bool short *); 13912void vec_st (vector bool short, int, unsigned short *); 13913void vec_st (vector pixel, int, vector pixel *); 13914void vec_st (vector pixel, int, unsigned short *); 13915void vec_st (vector pixel, int, short *); 13916void vec_st (vector bool short, int, short *); 13917void vec_st (vector signed char, int, vector signed char *); 13918void vec_st (vector signed char, int, signed char *); 13919void vec_st (vector unsigned char, int, vector unsigned char *); 13920void vec_st (vector unsigned char, int, unsigned char *); 13921void vec_st (vector bool char, int, vector bool char *); 13922void vec_st (vector bool char, int, unsigned char *); 13923void vec_st (vector bool char, int, signed char *); 13924 13925void vec_ste (vector signed char, int, signed char *); 13926void vec_ste (vector unsigned char, int, unsigned char *); 13927void vec_ste (vector bool char, int, signed char *); 13928void vec_ste (vector bool char, int, unsigned char *); 13929void vec_ste (vector signed short, int, short *); 13930void vec_ste (vector unsigned short, int, unsigned short *); 13931void vec_ste (vector bool short, int, short *); 13932void vec_ste (vector bool short, int, unsigned short *); 13933void vec_ste (vector pixel, int, short *); 13934void vec_ste (vector pixel, int, unsigned short *); 13935void vec_ste (vector float, int, float *); 13936void vec_ste (vector signed int, int, int *); 13937void vec_ste (vector unsigned int, int, unsigned int *); 13938void vec_ste (vector bool int, int, int *); 13939void vec_ste (vector bool int, int, unsigned int *); 13940 13941void vec_stvewx (vector float, int, float *); 13942void vec_stvewx (vector signed int, int, int *); 13943void vec_stvewx (vector unsigned int, int, unsigned int *); 13944void vec_stvewx (vector bool int, int, int *); 13945void vec_stvewx (vector bool int, int, unsigned int *); 13946 13947void vec_stvehx (vector signed short, int, short *); 13948void vec_stvehx (vector unsigned short, int, unsigned short *); 13949void vec_stvehx (vector bool short, int, short *); 13950void vec_stvehx (vector bool short, int, unsigned short *); 13951void vec_stvehx (vector pixel, int, short *); 13952void vec_stvehx (vector pixel, int, unsigned short *); 13953 13954void vec_stvebx (vector signed char, int, signed char *); 13955void vec_stvebx (vector unsigned char, int, unsigned char *); 13956void vec_stvebx (vector bool char, int, signed char *); 13957void vec_stvebx (vector bool char, int, unsigned char *); 13958 13959void vec_stl (vector float, int, vector float *); 13960void vec_stl (vector float, int, float *); 13961void vec_stl (vector signed int, int, vector signed int *); 13962void vec_stl (vector signed int, int, int *); 13963void vec_stl (vector unsigned int, int, vector unsigned int *); 13964void vec_stl (vector unsigned int, int, unsigned int *); 13965void vec_stl (vector bool int, int, vector bool int *); 13966void vec_stl (vector bool int, int, unsigned int *); 13967void vec_stl (vector bool int, int, int *); 13968void vec_stl (vector signed short, int, vector signed short *); 13969void vec_stl (vector signed short, int, short *); 13970void vec_stl (vector unsigned short, int, vector unsigned short *); 13971void vec_stl (vector unsigned short, int, unsigned short *); 13972void vec_stl (vector bool short, int, vector bool short *); 13973void vec_stl (vector bool short, int, unsigned short *); 13974void vec_stl (vector bool short, int, short *); 13975void vec_stl (vector pixel, int, vector pixel *); 13976void vec_stl (vector pixel, int, unsigned short *); 13977void vec_stl (vector pixel, int, short *); 13978void vec_stl (vector signed char, int, vector signed char *); 13979void vec_stl (vector signed char, int, signed char *); 13980void vec_stl (vector unsigned char, int, vector unsigned char *); 13981void vec_stl (vector unsigned char, int, unsigned char *); 13982void vec_stl (vector bool char, int, vector bool char *); 13983void vec_stl (vector bool char, int, unsigned char *); 13984void vec_stl (vector bool char, int, signed char *); 13985 13986vector signed char vec_sub (vector bool char, vector signed char); 13987vector signed char vec_sub (vector signed char, vector bool char); 13988vector signed char vec_sub (vector signed char, vector signed char); 13989vector unsigned char vec_sub (vector bool char, vector unsigned char); 13990vector unsigned char vec_sub (vector unsigned char, vector bool char); 13991vector unsigned char vec_sub (vector unsigned char, 13992 vector unsigned char); 13993vector signed short vec_sub (vector bool short, vector signed short); 13994vector signed short vec_sub (vector signed short, vector bool short); 13995vector signed short vec_sub (vector signed short, vector signed short); 13996vector unsigned short vec_sub (vector bool short, 13997 vector unsigned short); 13998vector unsigned short vec_sub (vector unsigned short, 13999 vector bool short); 14000vector unsigned short vec_sub (vector unsigned short, 14001 vector unsigned short); 14002vector signed int vec_sub (vector bool int, vector signed int); 14003vector signed int vec_sub (vector signed int, vector bool int); 14004vector signed int vec_sub (vector signed int, vector signed int); 14005vector unsigned int vec_sub (vector bool int, vector unsigned int); 14006vector unsigned int vec_sub (vector unsigned int, vector bool int); 14007vector unsigned int vec_sub (vector unsigned int, vector unsigned int); 14008vector float vec_sub (vector float, vector float); 14009 14010vector float vec_vsubfp (vector float, vector float); 14011 14012vector signed int vec_vsubuwm (vector bool int, vector signed int); 14013vector signed int vec_vsubuwm (vector signed int, vector bool int); 14014vector signed int vec_vsubuwm (vector signed int, vector signed int); 14015vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int); 14016vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int); 14017vector unsigned int vec_vsubuwm (vector unsigned int, 14018 vector unsigned int); 14019 14020vector signed short vec_vsubuhm (vector bool short, 14021 vector signed short); 14022vector signed short vec_vsubuhm (vector signed short, 14023 vector bool short); 14024vector signed short vec_vsubuhm (vector signed short, 14025 vector signed short); 14026vector unsigned short vec_vsubuhm (vector bool short, 14027 vector unsigned short); 14028vector unsigned short vec_vsubuhm (vector unsigned short, 14029 vector bool short); 14030vector unsigned short vec_vsubuhm (vector unsigned short, 14031 vector unsigned short); 14032 14033vector signed char vec_vsububm (vector bool char, vector signed char); 14034vector signed char vec_vsububm (vector signed char, vector bool char); 14035vector signed char vec_vsububm (vector signed char, vector signed char); 14036vector unsigned char vec_vsububm (vector bool char, 14037 vector unsigned char); 14038vector unsigned char vec_vsububm (vector unsigned char, 14039 vector bool char); 14040vector unsigned char vec_vsububm (vector unsigned char, 14041 vector unsigned char); 14042 14043vector unsigned int vec_subc (vector unsigned int, vector unsigned int); 14044 14045vector unsigned char vec_subs (vector bool char, vector unsigned char); 14046vector unsigned char vec_subs (vector unsigned char, vector bool char); 14047vector unsigned char vec_subs (vector unsigned char, 14048 vector unsigned char); 14049vector signed char vec_subs (vector bool char, vector signed char); 14050vector signed char vec_subs (vector signed char, vector bool char); 14051vector signed char vec_subs (vector signed char, vector signed char); 14052vector unsigned short vec_subs (vector bool short, 14053 vector unsigned short); 14054vector unsigned short vec_subs (vector unsigned short, 14055 vector bool short); 14056vector unsigned short vec_subs (vector unsigned short, 14057 vector unsigned short); 14058vector signed short vec_subs (vector bool short, vector signed short); 14059vector signed short vec_subs (vector signed short, vector bool short); 14060vector signed short vec_subs (vector signed short, vector signed short); 14061vector unsigned int vec_subs (vector bool int, vector unsigned int); 14062vector unsigned int vec_subs (vector unsigned int, vector bool int); 14063vector unsigned int vec_subs (vector unsigned int, vector unsigned int); 14064vector signed int vec_subs (vector bool int, vector signed int); 14065vector signed int vec_subs (vector signed int, vector bool int); 14066vector signed int vec_subs (vector signed int, vector signed int); 14067 14068vector signed int vec_vsubsws (vector bool int, vector signed int); 14069vector signed int vec_vsubsws (vector signed int, vector bool int); 14070vector signed int vec_vsubsws (vector signed int, vector signed int); 14071 14072vector unsigned int vec_vsubuws (vector bool int, vector unsigned int); 14073vector unsigned int vec_vsubuws (vector unsigned int, vector bool int); 14074vector unsigned int vec_vsubuws (vector unsigned int, 14075 vector unsigned int); 14076 14077vector signed short vec_vsubshs (vector bool short, 14078 vector signed short); 14079vector signed short vec_vsubshs (vector signed short, 14080 vector bool short); 14081vector signed short vec_vsubshs (vector signed short, 14082 vector signed short); 14083 14084vector unsigned short vec_vsubuhs (vector bool short, 14085 vector unsigned short); 14086vector unsigned short vec_vsubuhs (vector unsigned short, 14087 vector bool short); 14088vector unsigned short vec_vsubuhs (vector unsigned short, 14089 vector unsigned short); 14090 14091vector signed char vec_vsubsbs (vector bool char, vector signed char); 14092vector signed char vec_vsubsbs (vector signed char, vector bool char); 14093vector signed char vec_vsubsbs (vector signed char, vector signed char); 14094 14095vector unsigned char vec_vsububs (vector bool char, 14096 vector unsigned char); 14097vector unsigned char vec_vsububs (vector unsigned char, 14098 vector bool char); 14099vector unsigned char vec_vsububs (vector unsigned char, 14100 vector unsigned char); 14101 14102vector unsigned int vec_sum4s (vector unsigned char, 14103 vector unsigned int); 14104vector signed int vec_sum4s (vector signed char, vector signed int); 14105vector signed int vec_sum4s (vector signed short, vector signed int); 14106 14107vector signed int vec_vsum4shs (vector signed short, vector signed int); 14108 14109vector signed int vec_vsum4sbs (vector signed char, vector signed int); 14110 14111vector unsigned int vec_vsum4ubs (vector unsigned char, 14112 vector unsigned int); 14113 14114vector signed int vec_sum2s (vector signed int, vector signed int); 14115 14116vector signed int vec_sums (vector signed int, vector signed int); 14117 14118vector float vec_trunc (vector float); 14119 14120vector signed short vec_unpackh (vector signed char); 14121vector bool short vec_unpackh (vector bool char); 14122vector signed int vec_unpackh (vector signed short); 14123vector bool int vec_unpackh (vector bool short); 14124vector unsigned int vec_unpackh (vector pixel); 14125 14126vector bool int vec_vupkhsh (vector bool short); 14127vector signed int vec_vupkhsh (vector signed short); 14128 14129vector unsigned int vec_vupkhpx (vector pixel); 14130 14131vector bool short vec_vupkhsb (vector bool char); 14132vector signed short vec_vupkhsb (vector signed char); 14133 14134vector signed short vec_unpackl (vector signed char); 14135vector bool short vec_unpackl (vector bool char); 14136vector unsigned int vec_unpackl (vector pixel); 14137vector signed int vec_unpackl (vector signed short); 14138vector bool int vec_unpackl (vector bool short); 14139 14140vector unsigned int vec_vupklpx (vector pixel); 14141 14142vector bool int vec_vupklsh (vector bool short); 14143vector signed int vec_vupklsh (vector signed short); 14144 14145vector bool short vec_vupklsb (vector bool char); 14146vector signed short vec_vupklsb (vector signed char); 14147 14148vector float vec_xor (vector float, vector float); 14149vector float vec_xor (vector float, vector bool int); 14150vector float vec_xor (vector bool int, vector float); 14151vector bool int vec_xor (vector bool int, vector bool int); 14152vector signed int vec_xor (vector bool int, vector signed int); 14153vector signed int vec_xor (vector signed int, vector bool int); 14154vector signed int vec_xor (vector signed int, vector signed int); 14155vector unsigned int vec_xor (vector bool int, vector unsigned int); 14156vector unsigned int vec_xor (vector unsigned int, vector bool int); 14157vector unsigned int vec_xor (vector unsigned int, vector unsigned int); 14158vector bool short vec_xor (vector bool short, vector bool short); 14159vector signed short vec_xor (vector bool short, vector signed short); 14160vector signed short vec_xor (vector signed short, vector bool short); 14161vector signed short vec_xor (vector signed short, vector signed short); 14162vector unsigned short vec_xor (vector bool short, 14163 vector unsigned short); 14164vector unsigned short vec_xor (vector unsigned short, 14165 vector bool short); 14166vector unsigned short vec_xor (vector unsigned short, 14167 vector unsigned short); 14168vector signed char vec_xor (vector bool char, vector signed char); 14169vector bool char vec_xor (vector bool char, vector bool char); 14170vector signed char vec_xor (vector signed char, vector bool char); 14171vector signed char vec_xor (vector signed char, vector signed char); 14172vector unsigned char vec_xor (vector bool char, vector unsigned char); 14173vector unsigned char vec_xor (vector unsigned char, vector bool char); 14174vector unsigned char vec_xor (vector unsigned char, 14175 vector unsigned char); 14176 14177int vec_all_eq (vector signed char, vector bool char); 14178int vec_all_eq (vector signed char, vector signed char); 14179int vec_all_eq (vector unsigned char, vector bool char); 14180int vec_all_eq (vector unsigned char, vector unsigned char); 14181int vec_all_eq (vector bool char, vector bool char); 14182int vec_all_eq (vector bool char, vector unsigned char); 14183int vec_all_eq (vector bool char, vector signed char); 14184int vec_all_eq (vector signed short, vector bool short); 14185int vec_all_eq (vector signed short, vector signed short); 14186int vec_all_eq (vector unsigned short, vector bool short); 14187int vec_all_eq (vector unsigned short, vector unsigned short); 14188int vec_all_eq (vector bool short, vector bool short); 14189int vec_all_eq (vector bool short, vector unsigned short); 14190int vec_all_eq (vector bool short, vector signed short); 14191int vec_all_eq (vector pixel, vector pixel); 14192int vec_all_eq (vector signed int, vector bool int); 14193int vec_all_eq (vector signed int, vector signed int); 14194int vec_all_eq (vector unsigned int, vector bool int); 14195int vec_all_eq (vector unsigned int, vector unsigned int); 14196int vec_all_eq (vector bool int, vector bool int); 14197int vec_all_eq (vector bool int, vector unsigned int); 14198int vec_all_eq (vector bool int, vector signed int); 14199int vec_all_eq (vector float, vector float); 14200 14201int vec_all_ge (vector bool char, vector unsigned char); 14202int vec_all_ge (vector unsigned char, vector bool char); 14203int vec_all_ge (vector unsigned char, vector unsigned char); 14204int vec_all_ge (vector bool char, vector signed char); 14205int vec_all_ge (vector signed char, vector bool char); 14206int vec_all_ge (vector signed char, vector signed char); 14207int vec_all_ge (vector bool short, vector unsigned short); 14208int vec_all_ge (vector unsigned short, vector bool short); 14209int vec_all_ge (vector unsigned short, vector unsigned short); 14210int vec_all_ge (vector signed short, vector signed short); 14211int vec_all_ge (vector bool short, vector signed short); 14212int vec_all_ge (vector signed short, vector bool short); 14213int vec_all_ge (vector bool int, vector unsigned int); 14214int vec_all_ge (vector unsigned int, vector bool int); 14215int vec_all_ge (vector unsigned int, vector unsigned int); 14216int vec_all_ge (vector bool int, vector signed int); 14217int vec_all_ge (vector signed int, vector bool int); 14218int vec_all_ge (vector signed int, vector signed int); 14219int vec_all_ge (vector float, vector float); 14220 14221int vec_all_gt (vector bool char, vector unsigned char); 14222int vec_all_gt (vector unsigned char, vector bool char); 14223int vec_all_gt (vector unsigned char, vector unsigned char); 14224int vec_all_gt (vector bool char, vector signed char); 14225int vec_all_gt (vector signed char, vector bool char); 14226int vec_all_gt (vector signed char, vector signed char); 14227int vec_all_gt (vector bool short, vector unsigned short); 14228int vec_all_gt (vector unsigned short, vector bool short); 14229int vec_all_gt (vector unsigned short, vector unsigned short); 14230int vec_all_gt (vector bool short, vector signed short); 14231int vec_all_gt (vector signed short, vector bool short); 14232int vec_all_gt (vector signed short, vector signed short); 14233int vec_all_gt (vector bool int, vector unsigned int); 14234int vec_all_gt (vector unsigned int, vector bool int); 14235int vec_all_gt (vector unsigned int, vector unsigned int); 14236int vec_all_gt (vector bool int, vector signed int); 14237int vec_all_gt (vector signed int, vector bool int); 14238int vec_all_gt (vector signed int, vector signed int); 14239int vec_all_gt (vector float, vector float); 14240 14241int vec_all_in (vector float, vector float); 14242 14243int vec_all_le (vector bool char, vector unsigned char); 14244int vec_all_le (vector unsigned char, vector bool char); 14245int vec_all_le (vector unsigned char, vector unsigned char); 14246int vec_all_le (vector bool char, vector signed char); 14247int vec_all_le (vector signed char, vector bool char); 14248int vec_all_le (vector signed char, vector signed char); 14249int vec_all_le (vector bool short, vector unsigned short); 14250int vec_all_le (vector unsigned short, vector bool short); 14251int vec_all_le (vector unsigned short, vector unsigned short); 14252int vec_all_le (vector bool short, vector signed short); 14253int vec_all_le (vector signed short, vector bool short); 14254int vec_all_le (vector signed short, vector signed short); 14255int vec_all_le (vector bool int, vector unsigned int); 14256int vec_all_le (vector unsigned int, vector bool int); 14257int vec_all_le (vector unsigned int, vector unsigned int); 14258int vec_all_le (vector bool int, vector signed int); 14259int vec_all_le (vector signed int, vector bool int); 14260int vec_all_le (vector signed int, vector signed int); 14261int vec_all_le (vector float, vector float); 14262 14263int vec_all_lt (vector bool char, vector unsigned char); 14264int vec_all_lt (vector unsigned char, vector bool char); 14265int vec_all_lt (vector unsigned char, vector unsigned char); 14266int vec_all_lt (vector bool char, vector signed char); 14267int vec_all_lt (vector signed char, vector bool char); 14268int vec_all_lt (vector signed char, vector signed char); 14269int vec_all_lt (vector bool short, vector unsigned short); 14270int vec_all_lt (vector unsigned short, vector bool short); 14271int vec_all_lt (vector unsigned short, vector unsigned short); 14272int vec_all_lt (vector bool short, vector signed short); 14273int vec_all_lt (vector signed short, vector bool short); 14274int vec_all_lt (vector signed short, vector signed short); 14275int vec_all_lt (vector bool int, vector unsigned int); 14276int vec_all_lt (vector unsigned int, vector bool int); 14277int vec_all_lt (vector unsigned int, vector unsigned int); 14278int vec_all_lt (vector bool int, vector signed int); 14279int vec_all_lt (vector signed int, vector bool int); 14280int vec_all_lt (vector signed int, vector signed int); 14281int vec_all_lt (vector float, vector float); 14282 14283int vec_all_nan (vector float); 14284 14285int vec_all_ne (vector signed char, vector bool char); 14286int vec_all_ne (vector signed char, vector signed char); 14287int vec_all_ne (vector unsigned char, vector bool char); 14288int vec_all_ne (vector unsigned char, vector unsigned char); 14289int vec_all_ne (vector bool char, vector bool char); 14290int vec_all_ne (vector bool char, vector unsigned char); 14291int vec_all_ne (vector bool char, vector signed char); 14292int vec_all_ne (vector signed short, vector bool short); 14293int vec_all_ne (vector signed short, vector signed short); 14294int vec_all_ne (vector unsigned short, vector bool short); 14295int vec_all_ne (vector unsigned short, vector unsigned short); 14296int vec_all_ne (vector bool short, vector bool short); 14297int vec_all_ne (vector bool short, vector unsigned short); 14298int vec_all_ne (vector bool short, vector signed short); 14299int vec_all_ne (vector pixel, vector pixel); 14300int vec_all_ne (vector signed int, vector bool int); 14301int vec_all_ne (vector signed int, vector signed int); 14302int vec_all_ne (vector unsigned int, vector bool int); 14303int vec_all_ne (vector unsigned int, vector unsigned int); 14304int vec_all_ne (vector bool int, vector bool int); 14305int vec_all_ne (vector bool int, vector unsigned int); 14306int vec_all_ne (vector bool int, vector signed int); 14307int vec_all_ne (vector float, vector float); 14308 14309int vec_all_nge (vector float, vector float); 14310 14311int vec_all_ngt (vector float, vector float); 14312 14313int vec_all_nle (vector float, vector float); 14314 14315int vec_all_nlt (vector float, vector float); 14316 14317int vec_all_numeric (vector float); 14318 14319int vec_any_eq (vector signed char, vector bool char); 14320int vec_any_eq (vector signed char, vector signed char); 14321int vec_any_eq (vector unsigned char, vector bool char); 14322int vec_any_eq (vector unsigned char, vector unsigned char); 14323int vec_any_eq (vector bool char, vector bool char); 14324int vec_any_eq (vector bool char, vector unsigned char); 14325int vec_any_eq (vector bool char, vector signed char); 14326int vec_any_eq (vector signed short, vector bool short); 14327int vec_any_eq (vector signed short, vector signed short); 14328int vec_any_eq (vector unsigned short, vector bool short); 14329int vec_any_eq (vector unsigned short, vector unsigned short); 14330int vec_any_eq (vector bool short, vector bool short); 14331int vec_any_eq (vector bool short, vector unsigned short); 14332int vec_any_eq (vector bool short, vector signed short); 14333int vec_any_eq (vector pixel, vector pixel); 14334int vec_any_eq (vector signed int, vector bool int); 14335int vec_any_eq (vector signed int, vector signed int); 14336int vec_any_eq (vector unsigned int, vector bool int); 14337int vec_any_eq (vector unsigned int, vector unsigned int); 14338int vec_any_eq (vector bool int, vector bool int); 14339int vec_any_eq (vector bool int, vector unsigned int); 14340int vec_any_eq (vector bool int, vector signed int); 14341int vec_any_eq (vector float, vector float); 14342 14343int vec_any_ge (vector signed char, vector bool char); 14344int vec_any_ge (vector unsigned char, vector bool char); 14345int vec_any_ge (vector unsigned char, vector unsigned char); 14346int vec_any_ge (vector signed char, vector signed char); 14347int vec_any_ge (vector bool char, vector unsigned char); 14348int vec_any_ge (vector bool char, vector signed char); 14349int vec_any_ge (vector unsigned short, vector bool short); 14350int vec_any_ge (vector unsigned short, vector unsigned short); 14351int vec_any_ge (vector signed short, vector signed short); 14352int vec_any_ge (vector signed short, vector bool short); 14353int vec_any_ge (vector bool short, vector unsigned short); 14354int vec_any_ge (vector bool short, vector signed short); 14355int vec_any_ge (vector signed int, vector bool int); 14356int vec_any_ge (vector unsigned int, vector bool int); 14357int vec_any_ge (vector unsigned int, vector unsigned int); 14358int vec_any_ge (vector signed int, vector signed int); 14359int vec_any_ge (vector bool int, vector unsigned int); 14360int vec_any_ge (vector bool int, vector signed int); 14361int vec_any_ge (vector float, vector float); 14362 14363int vec_any_gt (vector bool char, vector unsigned char); 14364int vec_any_gt (vector unsigned char, vector bool char); 14365int vec_any_gt (vector unsigned char, vector unsigned char); 14366int vec_any_gt (vector bool char, vector signed char); 14367int vec_any_gt (vector signed char, vector bool char); 14368int vec_any_gt (vector signed char, vector signed char); 14369int vec_any_gt (vector bool short, vector unsigned short); 14370int vec_any_gt (vector unsigned short, vector bool short); 14371int vec_any_gt (vector unsigned short, vector unsigned short); 14372int vec_any_gt (vector bool short, vector signed short); 14373int vec_any_gt (vector signed short, vector bool short); 14374int vec_any_gt (vector signed short, vector signed short); 14375int vec_any_gt (vector bool int, vector unsigned int); 14376int vec_any_gt (vector unsigned int, vector bool int); 14377int vec_any_gt (vector unsigned int, vector unsigned int); 14378int vec_any_gt (vector bool int, vector signed int); 14379int vec_any_gt (vector signed int, vector bool int); 14380int vec_any_gt (vector signed int, vector signed int); 14381int vec_any_gt (vector float, vector float); 14382 14383int vec_any_le (vector bool char, vector unsigned char); 14384int vec_any_le (vector unsigned char, vector bool char); 14385int vec_any_le (vector unsigned char, vector unsigned char); 14386int vec_any_le (vector bool char, vector signed char); 14387int vec_any_le (vector signed char, vector bool char); 14388int vec_any_le (vector signed char, vector signed char); 14389int vec_any_le (vector bool short, vector unsigned short); 14390int vec_any_le (vector unsigned short, vector bool short); 14391int vec_any_le (vector unsigned short, vector unsigned short); 14392int vec_any_le (vector bool short, vector signed short); 14393int vec_any_le (vector signed short, vector bool short); 14394int vec_any_le (vector signed short, vector signed short); 14395int vec_any_le (vector bool int, vector unsigned int); 14396int vec_any_le (vector unsigned int, vector bool int); 14397int vec_any_le (vector unsigned int, vector unsigned int); 14398int vec_any_le (vector bool int, vector signed int); 14399int vec_any_le (vector signed int, vector bool int); 14400int vec_any_le (vector signed int, vector signed int); 14401int vec_any_le (vector float, vector float); 14402 14403int vec_any_lt (vector bool char, vector unsigned char); 14404int vec_any_lt (vector unsigned char, vector bool char); 14405int vec_any_lt (vector unsigned char, vector unsigned char); 14406int vec_any_lt (vector bool char, vector signed char); 14407int vec_any_lt (vector signed char, vector bool char); 14408int vec_any_lt (vector signed char, vector signed char); 14409int vec_any_lt (vector bool short, vector unsigned short); 14410int vec_any_lt (vector unsigned short, vector bool short); 14411int vec_any_lt (vector unsigned short, vector unsigned short); 14412int vec_any_lt (vector bool short, vector signed short); 14413int vec_any_lt (vector signed short, vector bool short); 14414int vec_any_lt (vector signed short, vector signed short); 14415int vec_any_lt (vector bool int, vector unsigned int); 14416int vec_any_lt (vector unsigned int, vector bool int); 14417int vec_any_lt (vector unsigned int, vector unsigned int); 14418int vec_any_lt (vector bool int, vector signed int); 14419int vec_any_lt (vector signed int, vector bool int); 14420int vec_any_lt (vector signed int, vector signed int); 14421int vec_any_lt (vector float, vector float); 14422 14423int vec_any_nan (vector float); 14424 14425int vec_any_ne (vector signed char, vector bool char); 14426int vec_any_ne (vector signed char, vector signed char); 14427int vec_any_ne (vector unsigned char, vector bool char); 14428int vec_any_ne (vector unsigned char, vector unsigned char); 14429int vec_any_ne (vector bool char, vector bool char); 14430int vec_any_ne (vector bool char, vector unsigned char); 14431int vec_any_ne (vector bool char, vector signed char); 14432int vec_any_ne (vector signed short, vector bool short); 14433int vec_any_ne (vector signed short, vector signed short); 14434int vec_any_ne (vector unsigned short, vector bool short); 14435int vec_any_ne (vector unsigned short, vector unsigned short); 14436int vec_any_ne (vector bool short, vector bool short); 14437int vec_any_ne (vector bool short, vector unsigned short); 14438int vec_any_ne (vector bool short, vector signed short); 14439int vec_any_ne (vector pixel, vector pixel); 14440int vec_any_ne (vector signed int, vector bool int); 14441int vec_any_ne (vector signed int, vector signed int); 14442int vec_any_ne (vector unsigned int, vector bool int); 14443int vec_any_ne (vector unsigned int, vector unsigned int); 14444int vec_any_ne (vector bool int, vector bool int); 14445int vec_any_ne (vector bool int, vector unsigned int); 14446int vec_any_ne (vector bool int, vector signed int); 14447int vec_any_ne (vector float, vector float); 14448 14449int vec_any_nge (vector float, vector float); 14450 14451int vec_any_ngt (vector float, vector float); 14452 14453int vec_any_nle (vector float, vector float); 14454 14455int vec_any_nlt (vector float, vector float); 14456 14457int vec_any_numeric (vector float); 14458 14459int vec_any_out (vector float, vector float); 14460@end smallexample 14461 14462If the vector/scalar (VSX) instruction set is available, the following 14463additional functions are available: 14464 14465@smallexample 14466vector double vec_abs (vector double); 14467vector double vec_add (vector double, vector double); 14468vector double vec_and (vector double, vector double); 14469vector double vec_and (vector double, vector bool long); 14470vector double vec_and (vector bool long, vector double); 14471vector long vec_and (vector long, vector long); 14472vector long vec_and (vector long, vector bool long); 14473vector long vec_and (vector bool long, vector long); 14474vector unsigned long vec_and (vector unsigned long, vector unsigned long); 14475vector unsigned long vec_and (vector unsigned long, vector bool long); 14476vector unsigned long vec_and (vector bool long, vector unsigned long); 14477vector double vec_andc (vector double, vector double); 14478vector double vec_andc (vector double, vector bool long); 14479vector double vec_andc (vector bool long, vector double); 14480vector long vec_andc (vector long, vector long); 14481vector long vec_andc (vector long, vector bool long); 14482vector long vec_andc (vector bool long, vector long); 14483vector unsigned long vec_andc (vector unsigned long, vector unsigned long); 14484vector unsigned long vec_andc (vector unsigned long, vector bool long); 14485vector unsigned long vec_andc (vector bool long, vector unsigned long); 14486vector double vec_ceil (vector double); 14487vector bool long vec_cmpeq (vector double, vector double); 14488vector bool long vec_cmpge (vector double, vector double); 14489vector bool long vec_cmpgt (vector double, vector double); 14490vector bool long vec_cmple (vector double, vector double); 14491vector bool long vec_cmplt (vector double, vector double); 14492vector double vec_cpsgn (vector double, vector double); 14493vector float vec_div (vector float, vector float); 14494vector double vec_div (vector double, vector double); 14495vector long vec_div (vector long, vector long); 14496vector unsigned long vec_div (vector unsigned long, vector unsigned long); 14497vector double vec_floor (vector double); 14498vector double vec_ld (int, const vector double *); 14499vector double vec_ld (int, const double *); 14500vector double vec_ldl (int, const vector double *); 14501vector double vec_ldl (int, const double *); 14502vector unsigned char vec_lvsl (int, const volatile double *); 14503vector unsigned char vec_lvsr (int, const volatile double *); 14504vector double vec_madd (vector double, vector double, vector double); 14505vector double vec_max (vector double, vector double); 14506vector signed long vec_mergeh (vector signed long, vector signed long); 14507vector signed long vec_mergeh (vector signed long, vector bool long); 14508vector signed long vec_mergeh (vector bool long, vector signed long); 14509vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long); 14510vector unsigned long vec_mergeh (vector unsigned long, vector bool long); 14511vector unsigned long vec_mergeh (vector bool long, vector unsigned long); 14512vector signed long vec_mergel (vector signed long, vector signed long); 14513vector signed long vec_mergel (vector signed long, vector bool long); 14514vector signed long vec_mergel (vector bool long, vector signed long); 14515vector unsigned long vec_mergel (vector unsigned long, vector unsigned long); 14516vector unsigned long vec_mergel (vector unsigned long, vector bool long); 14517vector unsigned long vec_mergel (vector bool long, vector unsigned long); 14518vector double vec_min (vector double, vector double); 14519vector float vec_msub (vector float, vector float, vector float); 14520vector double vec_msub (vector double, vector double, vector double); 14521vector float vec_mul (vector float, vector float); 14522vector double vec_mul (vector double, vector double); 14523vector long vec_mul (vector long, vector long); 14524vector unsigned long vec_mul (vector unsigned long, vector unsigned long); 14525vector float vec_nearbyint (vector float); 14526vector double vec_nearbyint (vector double); 14527vector float vec_nmadd (vector float, vector float, vector float); 14528vector double vec_nmadd (vector double, vector double, vector double); 14529vector double vec_nmsub (vector double, vector double, vector double); 14530vector double vec_nor (vector double, vector double); 14531vector long vec_nor (vector long, vector long); 14532vector long vec_nor (vector long, vector bool long); 14533vector long vec_nor (vector bool long, vector long); 14534vector unsigned long vec_nor (vector unsigned long, vector unsigned long); 14535vector unsigned long vec_nor (vector unsigned long, vector bool long); 14536vector unsigned long vec_nor (vector bool long, vector unsigned long); 14537vector double vec_or (vector double, vector double); 14538vector double vec_or (vector double, vector bool long); 14539vector double vec_or (vector bool long, vector double); 14540vector long vec_or (vector long, vector long); 14541vector long vec_or (vector long, vector bool long); 14542vector long vec_or (vector bool long, vector long); 14543vector unsigned long vec_or (vector unsigned long, vector unsigned long); 14544vector unsigned long vec_or (vector unsigned long, vector bool long); 14545vector unsigned long vec_or (vector bool long, vector unsigned long); 14546vector double vec_perm (vector double, vector double, vector unsigned char); 14547vector long vec_perm (vector long, vector long, vector unsigned char); 14548vector unsigned long vec_perm (vector unsigned long, vector unsigned long, 14549 vector unsigned char); 14550vector double vec_rint (vector double); 14551vector double vec_recip (vector double, vector double); 14552vector double vec_rsqrt (vector double); 14553vector double vec_rsqrte (vector double); 14554vector double vec_sel (vector double, vector double, vector bool long); 14555vector double vec_sel (vector double, vector double, vector unsigned long); 14556vector long vec_sel (vector long, vector long, vector long); 14557vector long vec_sel (vector long, vector long, vector unsigned long); 14558vector long vec_sel (vector long, vector long, vector bool long); 14559vector unsigned long vec_sel (vector unsigned long, vector unsigned long, 14560 vector long); 14561vector unsigned long vec_sel (vector unsigned long, vector unsigned long, 14562 vector unsigned long); 14563vector unsigned long vec_sel (vector unsigned long, vector unsigned long, 14564 vector bool long); 14565vector double vec_splats (double); 14566vector signed long vec_splats (signed long); 14567vector unsigned long vec_splats (unsigned long); 14568vector float vec_sqrt (vector float); 14569vector double vec_sqrt (vector double); 14570void vec_st (vector double, int, vector double *); 14571void vec_st (vector double, int, double *); 14572vector double vec_sub (vector double, vector double); 14573vector double vec_trunc (vector double); 14574vector double vec_xor (vector double, vector double); 14575vector double vec_xor (vector double, vector bool long); 14576vector double vec_xor (vector bool long, vector double); 14577vector long vec_xor (vector long, vector long); 14578vector long vec_xor (vector long, vector bool long); 14579vector long vec_xor (vector bool long, vector long); 14580vector unsigned long vec_xor (vector unsigned long, vector unsigned long); 14581vector unsigned long vec_xor (vector unsigned long, vector bool long); 14582vector unsigned long vec_xor (vector bool long, vector unsigned long); 14583int vec_all_eq (vector double, vector double); 14584int vec_all_ge (vector double, vector double); 14585int vec_all_gt (vector double, vector double); 14586int vec_all_le (vector double, vector double); 14587int vec_all_lt (vector double, vector double); 14588int vec_all_nan (vector double); 14589int vec_all_ne (vector double, vector double); 14590int vec_all_nge (vector double, vector double); 14591int vec_all_ngt (vector double, vector double); 14592int vec_all_nle (vector double, vector double); 14593int vec_all_nlt (vector double, vector double); 14594int vec_all_numeric (vector double); 14595int vec_any_eq (vector double, vector double); 14596int vec_any_ge (vector double, vector double); 14597int vec_any_gt (vector double, vector double); 14598int vec_any_le (vector double, vector double); 14599int vec_any_lt (vector double, vector double); 14600int vec_any_nan (vector double); 14601int vec_any_ne (vector double, vector double); 14602int vec_any_nge (vector double, vector double); 14603int vec_any_ngt (vector double, vector double); 14604int vec_any_nle (vector double, vector double); 14605int vec_any_nlt (vector double, vector double); 14606int vec_any_numeric (vector double); 14607 14608vector double vec_vsx_ld (int, const vector double *); 14609vector double vec_vsx_ld (int, const double *); 14610vector float vec_vsx_ld (int, const vector float *); 14611vector float vec_vsx_ld (int, const float *); 14612vector bool int vec_vsx_ld (int, const vector bool int *); 14613vector signed int vec_vsx_ld (int, const vector signed int *); 14614vector signed int vec_vsx_ld (int, const int *); 14615vector signed int vec_vsx_ld (int, const long *); 14616vector unsigned int vec_vsx_ld (int, const vector unsigned int *); 14617vector unsigned int vec_vsx_ld (int, const unsigned int *); 14618vector unsigned int vec_vsx_ld (int, const unsigned long *); 14619vector bool short vec_vsx_ld (int, const vector bool short *); 14620vector pixel vec_vsx_ld (int, const vector pixel *); 14621vector signed short vec_vsx_ld (int, const vector signed short *); 14622vector signed short vec_vsx_ld (int, const short *); 14623vector unsigned short vec_vsx_ld (int, const vector unsigned short *); 14624vector unsigned short vec_vsx_ld (int, const unsigned short *); 14625vector bool char vec_vsx_ld (int, const vector bool char *); 14626vector signed char vec_vsx_ld (int, const vector signed char *); 14627vector signed char vec_vsx_ld (int, const signed char *); 14628vector unsigned char vec_vsx_ld (int, const vector unsigned char *); 14629vector unsigned char vec_vsx_ld (int, const unsigned char *); 14630 14631void vec_vsx_st (vector double, int, vector double *); 14632void vec_vsx_st (vector double, int, double *); 14633void vec_vsx_st (vector float, int, vector float *); 14634void vec_vsx_st (vector float, int, float *); 14635void vec_vsx_st (vector signed int, int, vector signed int *); 14636void vec_vsx_st (vector signed int, int, int *); 14637void vec_vsx_st (vector unsigned int, int, vector unsigned int *); 14638void vec_vsx_st (vector unsigned int, int, unsigned int *); 14639void vec_vsx_st (vector bool int, int, vector bool int *); 14640void vec_vsx_st (vector bool int, int, unsigned int *); 14641void vec_vsx_st (vector bool int, int, int *); 14642void vec_vsx_st (vector signed short, int, vector signed short *); 14643void vec_vsx_st (vector signed short, int, short *); 14644void vec_vsx_st (vector unsigned short, int, vector unsigned short *); 14645void vec_vsx_st (vector unsigned short, int, unsigned short *); 14646void vec_vsx_st (vector bool short, int, vector bool short *); 14647void vec_vsx_st (vector bool short, int, unsigned short *); 14648void vec_vsx_st (vector pixel, int, vector pixel *); 14649void vec_vsx_st (vector pixel, int, unsigned short *); 14650void vec_vsx_st (vector pixel, int, short *); 14651void vec_vsx_st (vector bool short, int, short *); 14652void vec_vsx_st (vector signed char, int, vector signed char *); 14653void vec_vsx_st (vector signed char, int, signed char *); 14654void vec_vsx_st (vector unsigned char, int, vector unsigned char *); 14655void vec_vsx_st (vector unsigned char, int, unsigned char *); 14656void vec_vsx_st (vector bool char, int, vector bool char *); 14657void vec_vsx_st (vector bool char, int, unsigned char *); 14658void vec_vsx_st (vector bool char, int, signed char *); 14659 14660vector double vec_xxpermdi (vector double, vector double, const int); 14661vector float vec_xxpermdi (vector float, vector float, const int); 14662vector long long vec_xxpermdi (vector long long, vector long long, const int); 14663vector unsigned long long vec_xxpermdi (vector unsigned long long, 14664 vector unsigned long long, const int); 14665vector int vec_xxpermdi (vector int, vector int, const int); 14666vector unsigned int vec_xxpermdi (vector unsigned int, 14667 vector unsigned int, const int); 14668vector short vec_xxpermdi (vector short, vector short, const int); 14669vector unsigned short vec_xxpermdi (vector unsigned short, 14670 vector unsigned short, const int); 14671vector signed char vec_xxpermdi (vector signed char, vector signed char, 14672 const int); 14673vector unsigned char vec_xxpermdi (vector unsigned char, 14674 vector unsigned char, const int); 14675 14676vector double vec_xxsldi (vector double, vector double, int); 14677vector float vec_xxsldi (vector float, vector float, int); 14678vector long long vec_xxsldi (vector long long, vector long long, int); 14679vector unsigned long long vec_xxsldi (vector unsigned long long, 14680 vector unsigned long long, int); 14681vector int vec_xxsldi (vector int, vector int, int); 14682vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int); 14683vector short vec_xxsldi (vector short, vector short, int); 14684vector unsigned short vec_xxsldi (vector unsigned short, 14685 vector unsigned short, int); 14686vector signed char vec_xxsldi (vector signed char, vector signed char, int); 14687vector unsigned char vec_xxsldi (vector unsigned char, 14688 vector unsigned char, int); 14689@end smallexample 14690 14691Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always 14692generate the AltiVec @samp{LVX} and @samp{STVX} instructions even 14693if the VSX instruction set is available. The @samp{vec_vsx_ld} and 14694@samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X}, 14695@samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions. 14696 14697If the ISA 2.07 additions to the vector/scalar (power8-vector) 14698instruction set is available, the following additional functions are 14699available for both 32-bit and 64-bit targets. For 64-bit targets, you 14700can use @var{vector long} instead of @var{vector long long}, 14701@var{vector bool long} instead of @var{vector bool long long}, and 14702@var{vector unsigned long} instead of @var{vector unsigned long long}. 14703 14704@smallexample 14705vector long long vec_abs (vector long long); 14706 14707vector long long vec_add (vector long long, vector long long); 14708vector unsigned long long vec_add (vector unsigned long long, 14709 vector unsigned long long); 14710 14711int vec_all_eq (vector long long, vector long long); 14712int vec_all_eq (vector unsigned long long, vector unsigned long long); 14713int vec_all_ge (vector long long, vector long long); 14714int vec_all_ge (vector unsigned long long, vector unsigned long long); 14715int vec_all_gt (vector long long, vector long long); 14716int vec_all_gt (vector unsigned long long, vector unsigned long long); 14717int vec_all_le (vector long long, vector long long); 14718int vec_all_le (vector unsigned long long, vector unsigned long long); 14719int vec_all_lt (vector long long, vector long long); 14720int vec_all_lt (vector unsigned long long, vector unsigned long long); 14721int vec_all_ne (vector long long, vector long long); 14722int vec_all_ne (vector unsigned long long, vector unsigned long long); 14723 14724int vec_any_eq (vector long long, vector long long); 14725int vec_any_eq (vector unsigned long long, vector unsigned long long); 14726int vec_any_ge (vector long long, vector long long); 14727int vec_any_ge (vector unsigned long long, vector unsigned long long); 14728int vec_any_gt (vector long long, vector long long); 14729int vec_any_gt (vector unsigned long long, vector unsigned long long); 14730int vec_any_le (vector long long, vector long long); 14731int vec_any_le (vector unsigned long long, vector unsigned long long); 14732int vec_any_lt (vector long long, vector long long); 14733int vec_any_lt (vector unsigned long long, vector unsigned long long); 14734int vec_any_ne (vector long long, vector long long); 14735int vec_any_ne (vector unsigned long long, vector unsigned long long); 14736 14737vector long long vec_eqv (vector long long, vector long long); 14738vector long long vec_eqv (vector bool long long, vector long long); 14739vector long long vec_eqv (vector long long, vector bool long long); 14740vector unsigned long long vec_eqv (vector unsigned long long, 14741 vector unsigned long long); 14742vector unsigned long long vec_eqv (vector bool long long, 14743 vector unsigned long long); 14744vector unsigned long long vec_eqv (vector unsigned long long, 14745 vector bool long long); 14746vector int vec_eqv (vector int, vector int); 14747vector int vec_eqv (vector bool int, vector int); 14748vector int vec_eqv (vector int, vector bool int); 14749vector unsigned int vec_eqv (vector unsigned int, vector unsigned int); 14750vector unsigned int vec_eqv (vector bool unsigned int, 14751 vector unsigned int); 14752vector unsigned int vec_eqv (vector unsigned int, 14753 vector bool unsigned int); 14754vector short vec_eqv (vector short, vector short); 14755vector short vec_eqv (vector bool short, vector short); 14756vector short vec_eqv (vector short, vector bool short); 14757vector unsigned short vec_eqv (vector unsigned short, vector unsigned short); 14758vector unsigned short vec_eqv (vector bool unsigned short, 14759 vector unsigned short); 14760vector unsigned short vec_eqv (vector unsigned short, 14761 vector bool unsigned short); 14762vector signed char vec_eqv (vector signed char, vector signed char); 14763vector signed char vec_eqv (vector bool signed char, vector signed char); 14764vector signed char vec_eqv (vector signed char, vector bool signed char); 14765vector unsigned char vec_eqv (vector unsigned char, vector unsigned char); 14766vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char); 14767vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char); 14768 14769vector long long vec_max (vector long long, vector long long); 14770vector unsigned long long vec_max (vector unsigned long long, 14771 vector unsigned long long); 14772 14773vector signed int vec_mergee (vector signed int, vector signed int); 14774vector unsigned int vec_mergee (vector unsigned int, vector unsigned int); 14775vector bool int vec_mergee (vector bool int, vector bool int); 14776 14777vector signed int vec_mergeo (vector signed int, vector signed int); 14778vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int); 14779vector bool int vec_mergeo (vector bool int, vector bool int); 14780 14781vector long long vec_min (vector long long, vector long long); 14782vector unsigned long long vec_min (vector unsigned long long, 14783 vector unsigned long long); 14784 14785vector long long vec_nand (vector long long, vector long long); 14786vector long long vec_nand (vector bool long long, vector long long); 14787vector long long vec_nand (vector long long, vector bool long long); 14788vector unsigned long long vec_nand (vector unsigned long long, 14789 vector unsigned long long); 14790vector unsigned long long vec_nand (vector bool long long, 14791 vector unsigned long long); 14792vector unsigned long long vec_nand (vector unsigned long long, 14793 vector bool long long); 14794vector int vec_nand (vector int, vector int); 14795vector int vec_nand (vector bool int, vector int); 14796vector int vec_nand (vector int, vector bool int); 14797vector unsigned int vec_nand (vector unsigned int, vector unsigned int); 14798vector unsigned int vec_nand (vector bool unsigned int, 14799 vector unsigned int); 14800vector unsigned int vec_nand (vector unsigned int, 14801 vector bool unsigned int); 14802vector short vec_nand (vector short, vector short); 14803vector short vec_nand (vector bool short, vector short); 14804vector short vec_nand (vector short, vector bool short); 14805vector unsigned short vec_nand (vector unsigned short, vector unsigned short); 14806vector unsigned short vec_nand (vector bool unsigned short, 14807 vector unsigned short); 14808vector unsigned short vec_nand (vector unsigned short, 14809 vector bool unsigned short); 14810vector signed char vec_nand (vector signed char, vector signed char); 14811vector signed char vec_nand (vector bool signed char, vector signed char); 14812vector signed char vec_nand (vector signed char, vector bool signed char); 14813vector unsigned char vec_nand (vector unsigned char, vector unsigned char); 14814vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char); 14815vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char); 14816 14817vector long long vec_orc (vector long long, vector long long); 14818vector long long vec_orc (vector bool long long, vector long long); 14819vector long long vec_orc (vector long long, vector bool long long); 14820vector unsigned long long vec_orc (vector unsigned long long, 14821 vector unsigned long long); 14822vector unsigned long long vec_orc (vector bool long long, 14823 vector unsigned long long); 14824vector unsigned long long vec_orc (vector unsigned long long, 14825 vector bool long long); 14826vector int vec_orc (vector int, vector int); 14827vector int vec_orc (vector bool int, vector int); 14828vector int vec_orc (vector int, vector bool int); 14829vector unsigned int vec_orc (vector unsigned int, vector unsigned int); 14830vector unsigned int vec_orc (vector bool unsigned int, 14831 vector unsigned int); 14832vector unsigned int vec_orc (vector unsigned int, 14833 vector bool unsigned int); 14834vector short vec_orc (vector short, vector short); 14835vector short vec_orc (vector bool short, vector short); 14836vector short vec_orc (vector short, vector bool short); 14837vector unsigned short vec_orc (vector unsigned short, vector unsigned short); 14838vector unsigned short vec_orc (vector bool unsigned short, 14839 vector unsigned short); 14840vector unsigned short vec_orc (vector unsigned short, 14841 vector bool unsigned short); 14842vector signed char vec_orc (vector signed char, vector signed char); 14843vector signed char vec_orc (vector bool signed char, vector signed char); 14844vector signed char vec_orc (vector signed char, vector bool signed char); 14845vector unsigned char vec_orc (vector unsigned char, vector unsigned char); 14846vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char); 14847vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char); 14848 14849vector int vec_pack (vector long long, vector long long); 14850vector unsigned int vec_pack (vector unsigned long long, 14851 vector unsigned long long); 14852vector bool int vec_pack (vector bool long long, vector bool long long); 14853 14854vector int vec_packs (vector long long, vector long long); 14855vector unsigned int vec_packs (vector unsigned long long, 14856 vector unsigned long long); 14857 14858vector unsigned int vec_packsu (vector long long, vector long long); 14859vector unsigned int vec_packsu (vector unsigned long long, 14860 vector unsigned long long); 14861 14862vector long long vec_rl (vector long long, 14863 vector unsigned long long); 14864vector long long vec_rl (vector unsigned long long, 14865 vector unsigned long long); 14866 14867vector long long vec_sl (vector long long, vector unsigned long long); 14868vector long long vec_sl (vector unsigned long long, 14869 vector unsigned long long); 14870 14871vector long long vec_sr (vector long long, vector unsigned long long); 14872vector unsigned long long char vec_sr (vector unsigned long long, 14873 vector unsigned long long); 14874 14875vector long long vec_sra (vector long long, vector unsigned long long); 14876vector unsigned long long vec_sra (vector unsigned long long, 14877 vector unsigned long long); 14878 14879vector long long vec_sub (vector long long, vector long long); 14880vector unsigned long long vec_sub (vector unsigned long long, 14881 vector unsigned long long); 14882 14883vector long long vec_unpackh (vector int); 14884vector unsigned long long vec_unpackh (vector unsigned int); 14885 14886vector long long vec_unpackl (vector int); 14887vector unsigned long long vec_unpackl (vector unsigned int); 14888 14889vector long long vec_vaddudm (vector long long, vector long long); 14890vector long long vec_vaddudm (vector bool long long, vector long long); 14891vector long long vec_vaddudm (vector long long, vector bool long long); 14892vector unsigned long long vec_vaddudm (vector unsigned long long, 14893 vector unsigned long long); 14894vector unsigned long long vec_vaddudm (vector bool unsigned long long, 14895 vector unsigned long long); 14896vector unsigned long long vec_vaddudm (vector unsigned long long, 14897 vector bool unsigned long long); 14898 14899vector long long vec_vbpermq (vector signed char, vector signed char); 14900vector long long vec_vbpermq (vector unsigned char, vector unsigned char); 14901 14902vector long long vec_cntlz (vector long long); 14903vector unsigned long long vec_cntlz (vector unsigned long long); 14904vector int vec_cntlz (vector int); 14905vector unsigned int vec_cntlz (vector int); 14906vector short vec_cntlz (vector short); 14907vector unsigned short vec_cntlz (vector unsigned short); 14908vector signed char vec_cntlz (vector signed char); 14909vector unsigned char vec_cntlz (vector unsigned char); 14910 14911vector long long vec_vclz (vector long long); 14912vector unsigned long long vec_vclz (vector unsigned long long); 14913vector int vec_vclz (vector int); 14914vector unsigned int vec_vclz (vector int); 14915vector short vec_vclz (vector short); 14916vector unsigned short vec_vclz (vector unsigned short); 14917vector signed char vec_vclz (vector signed char); 14918vector unsigned char vec_vclz (vector unsigned char); 14919 14920vector signed char vec_vclzb (vector signed char); 14921vector unsigned char vec_vclzb (vector unsigned char); 14922 14923vector long long vec_vclzd (vector long long); 14924vector unsigned long long vec_vclzd (vector unsigned long long); 14925 14926vector short vec_vclzh (vector short); 14927vector unsigned short vec_vclzh (vector unsigned short); 14928 14929vector int vec_vclzw (vector int); 14930vector unsigned int vec_vclzw (vector int); 14931 14932vector signed char vec_vgbbd (vector signed char); 14933vector unsigned char vec_vgbbd (vector unsigned char); 14934 14935vector long long vec_vmaxsd (vector long long, vector long long); 14936 14937vector unsigned long long vec_vmaxud (vector unsigned long long, 14938 unsigned vector long long); 14939 14940vector long long vec_vminsd (vector long long, vector long long); 14941 14942vector unsigned long long vec_vminud (vector long long, 14943 vector long long); 14944 14945vector int vec_vpksdss (vector long long, vector long long); 14946vector unsigned int vec_vpksdss (vector long long, vector long long); 14947 14948vector unsigned int vec_vpkudus (vector unsigned long long, 14949 vector unsigned long long); 14950 14951vector int vec_vpkudum (vector long long, vector long long); 14952vector unsigned int vec_vpkudum (vector unsigned long long, 14953 vector unsigned long long); 14954vector bool int vec_vpkudum (vector bool long long, vector bool long long); 14955 14956vector long long vec_vpopcnt (vector long long); 14957vector unsigned long long vec_vpopcnt (vector unsigned long long); 14958vector int vec_vpopcnt (vector int); 14959vector unsigned int vec_vpopcnt (vector int); 14960vector short vec_vpopcnt (vector short); 14961vector unsigned short vec_vpopcnt (vector unsigned short); 14962vector signed char vec_vpopcnt (vector signed char); 14963vector unsigned char vec_vpopcnt (vector unsigned char); 14964 14965vector signed char vec_vpopcntb (vector signed char); 14966vector unsigned char vec_vpopcntb (vector unsigned char); 14967 14968vector long long vec_vpopcntd (vector long long); 14969vector unsigned long long vec_vpopcntd (vector unsigned long long); 14970 14971vector short vec_vpopcnth (vector short); 14972vector unsigned short vec_vpopcnth (vector unsigned short); 14973 14974vector int vec_vpopcntw (vector int); 14975vector unsigned int vec_vpopcntw (vector int); 14976 14977vector long long vec_vrld (vector long long, vector unsigned long long); 14978vector unsigned long long vec_vrld (vector unsigned long long, 14979 vector unsigned long long); 14980 14981vector long long vec_vsld (vector long long, vector unsigned long long); 14982vector long long vec_vsld (vector unsigned long long, 14983 vector unsigned long long); 14984 14985vector long long vec_vsrad (vector long long, vector unsigned long long); 14986vector unsigned long long vec_vsrad (vector unsigned long long, 14987 vector unsigned long long); 14988 14989vector long long vec_vsrd (vector long long, vector unsigned long long); 14990vector unsigned long long char vec_vsrd (vector unsigned long long, 14991 vector unsigned long long); 14992 14993vector long long vec_vsubudm (vector long long, vector long long); 14994vector long long vec_vsubudm (vector bool long long, vector long long); 14995vector long long vec_vsubudm (vector long long, vector bool long long); 14996vector unsigned long long vec_vsubudm (vector unsigned long long, 14997 vector unsigned long long); 14998vector unsigned long long vec_vsubudm (vector bool long long, 14999 vector unsigned long long); 15000vector unsigned long long vec_vsubudm (vector unsigned long long, 15001 vector bool long long); 15002 15003vector long long vec_vupkhsw (vector int); 15004vector unsigned long long vec_vupkhsw (vector unsigned int); 15005 15006vector long long vec_vupklsw (vector int); 15007vector unsigned long long vec_vupklsw (vector int); 15008@end smallexample 15009 15010If the ISA 2.07 additions to the vector/scalar (power8-vector) 15011instruction set is available, the following additional functions are 15012available for 64-bit targets. New vector types 15013(@var{vector __int128_t} and @var{vector __uint128_t}) are available 15014to hold the @var{__int128_t} and @var{__uint128_t} types to use these 15015builtins. 15016 15017The normal vector extract, and set operations work on 15018@var{vector __int128_t} and @var{vector __uint128_t} types, 15019but the index value must be 0. 15020 15021@smallexample 15022vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t); 15023vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t); 15024 15025vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t); 15026vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t); 15027 15028vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t, 15029 vector __int128_t); 15030vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t, 15031 vector __uint128_t); 15032 15033vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t, 15034 vector __int128_t); 15035vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t, 15036 vector __uint128_t); 15037 15038vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t, 15039 vector __int128_t); 15040vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t, 15041 vector __uint128_t); 15042 15043vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t, 15044 vector __int128_t); 15045vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t, 15046 vector __uint128_t); 15047 15048vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t); 15049vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t); 15050 15051__int128_t vec_vsubuqm (__int128_t, __int128_t); 15052__uint128_t vec_vsubuqm (__uint128_t, __uint128_t); 15053 15054vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t); 15055int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t); 15056int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t); 15057int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t); 15058int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t); 15059vector __int128_t bcdsub (vector __int128_t, vector__int128_t); 15060int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t); 15061int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t); 15062int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t); 15063int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t); 15064@end smallexample 15065 15066If the cryptographic instructions are enabled (@option{-mcrypto} or 15067@option{-mcpu=power8}), the following builtins are enabled. 15068 15069@smallexample 15070vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long); 15071 15072vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long, 15073 vector unsigned long long); 15074 15075vector unsigned long long __builtin_crypto_vcipherlast 15076 (vector unsigned long long, 15077 vector unsigned long long); 15078 15079vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long, 15080 vector unsigned long long); 15081 15082vector unsigned long long __builtin_crypto_vncipherlast 15083 (vector unsigned long long, 15084 vector unsigned long long); 15085 15086vector unsigned char __builtin_crypto_vpermxor (vector unsigned char, 15087 vector unsigned char, 15088 vector unsigned char); 15089 15090vector unsigned short __builtin_crypto_vpermxor (vector unsigned short, 15091 vector unsigned short, 15092 vector unsigned short); 15093 15094vector unsigned int __builtin_crypto_vpermxor (vector unsigned int, 15095 vector unsigned int, 15096 vector unsigned int); 15097 15098vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long, 15099 vector unsigned long long, 15100 vector unsigned long long); 15101 15102vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char, 15103 vector unsigned char); 15104 15105vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short, 15106 vector unsigned short); 15107 15108vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int, 15109 vector unsigned int); 15110 15111vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long, 15112 vector unsigned long long); 15113 15114vector unsigned long long __builtin_crypto_vshasigmad 15115 (vector unsigned long long, int, int); 15116 15117vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int, 15118 int, int); 15119@end smallexample 15120 15121The second argument to the @var{__builtin_crypto_vshasigmad} and 15122@var{__builtin_crypto_vshasigmaw} builtin functions must be a constant 15123integer that is 0 or 1. The third argument to these builtin functions 15124must be a constant integer in the range of 0 to 15. 15125 15126@node PowerPC Hardware Transactional Memory Built-in Functions 15127@subsection PowerPC Hardware Transactional Memory Built-in Functions 15128GCC provides two interfaces for accessing the Hardware Transactional 15129Memory (HTM) instructions available on some of the PowerPC family 15130of processors (eg, POWER8). The two interfaces come in a low level 15131interface, consisting of built-in functions specific to PowerPC and a 15132higher level interface consisting of inline functions that are common 15133between PowerPC and S/390. 15134 15135@subsubsection PowerPC HTM Low Level Built-in Functions 15136 15137The following low level built-in functions are available with 15138@option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later. 15139They all generate the machine instruction that is part of the name. 15140 15141The HTM builtins (with the exception of @code{__builtin_tbegin}) return 15142the full 4-bit condition register value set by their associated hardware 15143instruction. The header file @code{htmintrin.h} defines some macros that can 15144be used to decipher the return value. The @code{__builtin_tbegin} builtin 15145returns a simple true or false value depending on whether a transaction was 15146successfully started or not. The arguments of the builtins match exactly the 15147type and order of the associated hardware instruction's operands, except for 15148the @code{__builtin_tcheck} builtin, which does not take any input arguments. 15149Refer to the ISA manual for a description of each instruction's operands. 15150 15151@smallexample 15152unsigned int __builtin_tbegin (unsigned int) 15153unsigned int __builtin_tend (unsigned int) 15154 15155unsigned int __builtin_tabort (unsigned int) 15156unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int) 15157unsigned int __builtin_tabortdci (unsigned int, unsigned int, int) 15158unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int) 15159unsigned int __builtin_tabortwci (unsigned int, unsigned int, int) 15160 15161unsigned int __builtin_tcheck (void) 15162unsigned int __builtin_treclaim (unsigned int) 15163unsigned int __builtin_trechkpt (void) 15164unsigned int __builtin_tsr (unsigned int) 15165@end smallexample 15166 15167In addition to the above HTM built-ins, we have added built-ins for 15168some common extended mnemonics of the HTM instructions: 15169 15170@smallexample 15171unsigned int __builtin_tendall (void) 15172unsigned int __builtin_tresume (void) 15173unsigned int __builtin_tsuspend (void) 15174@end smallexample 15175 15176Note that the semantics of the above HTM builtins are required to mimic 15177the locking semantics used for critical sections. Builtins that are used 15178to create a new transaction or restart a suspended transaction must have 15179lock acquisition like semantics while those builtins that end or suspend a 15180transaction must have lock release like semantics. Specifically, this must 15181mimic lock semantics as specified by C++11, for example: Lock acquisition is 15182as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE) 15183that returns 0, and lock release is as-if an execution of 15184__atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an 15185implicit implementation-defined lock used for all transactions. The HTM 15186instructions associated with with the builtins inherently provide the 15187correct acquisition and release hardware barriers required. However, 15188the compiler must also be prohibited from moving loads and stores across 15189the builtins in a way that would violate their semantics. This has been 15190accomplished by adding memory barriers to the associated HTM instructions 15191(which is a conservative approach to provide acquire and release semantics). 15192Earlier versions of the compiler did not treat the HTM instructions as 15193memory barriers. A @code{__TM_FENCE__} macro has been added, which can 15194be used to determine whether the current compiler treats HTM instructions 15195as memory barriers or not. This allows the user to explicitly add memory 15196barriers to their code when using an older version of the compiler. 15197 15198The following set of built-in functions are available to gain access 15199to the HTM specific special purpose registers. 15200 15201@smallexample 15202unsigned long __builtin_get_texasr (void) 15203unsigned long __builtin_get_texasru (void) 15204unsigned long __builtin_get_tfhar (void) 15205unsigned long __builtin_get_tfiar (void) 15206 15207void __builtin_set_texasr (unsigned long); 15208void __builtin_set_texasru (unsigned long); 15209void __builtin_set_tfhar (unsigned long); 15210void __builtin_set_tfiar (unsigned long); 15211@end smallexample 15212 15213Example usage of these low level built-in functions may look like: 15214 15215@smallexample 15216#include <htmintrin.h> 15217 15218int num_retries = 10; 15219 15220while (1) 15221 @{ 15222 if (__builtin_tbegin (0)) 15223 @{ 15224 /* Transaction State Initiated. */ 15225 if (is_locked (lock)) 15226 __builtin_tabort (0); 15227 ... transaction code... 15228 __builtin_tend (0); 15229 break; 15230 @} 15231 else 15232 @{ 15233 /* Transaction State Failed. Use locks if the transaction 15234 failure is "persistent" or we've tried too many times. */ 15235 if (num_retries-- <= 0 15236 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ())) 15237 @{ 15238 acquire_lock (lock); 15239 ... non transactional fallback path... 15240 release_lock (lock); 15241 break; 15242 @} 15243 @} 15244 @} 15245@end smallexample 15246 15247One final built-in function has been added that returns the value of 15248the 2-bit Transaction State field of the Machine Status Register (MSR) 15249as stored in @code{CR0}. 15250 15251@smallexample 15252unsigned long __builtin_ttest (void) 15253@end smallexample 15254 15255This built-in can be used to determine the current transaction state 15256using the following code example: 15257 15258@smallexample 15259#include <htmintrin.h> 15260 15261unsigned char tx_state = _HTM_STATE (__builtin_ttest ()); 15262 15263if (tx_state == _HTM_TRANSACTIONAL) 15264 @{ 15265 /* Code to use in transactional state. */ 15266 @} 15267else if (tx_state == _HTM_NONTRANSACTIONAL) 15268 @{ 15269 /* Code to use in non-transactional state. */ 15270 @} 15271else if (tx_state == _HTM_SUSPENDED) 15272 @{ 15273 /* Code to use in transaction suspended state. */ 15274 @} 15275@end smallexample 15276 15277@subsubsection PowerPC HTM High Level Inline Functions 15278 15279The following high level HTM interface is made available by including 15280@code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU} 15281where CPU is `power8' or later. This interface is common between PowerPC 15282and S/390, allowing users to write one HTM source implementation that 15283can be compiled and executed on either system. 15284 15285@smallexample 15286long __TM_simple_begin (void) 15287long __TM_begin (void* const TM_buff) 15288long __TM_end (void) 15289void __TM_abort (void) 15290void __TM_named_abort (unsigned char const code) 15291void __TM_resume (void) 15292void __TM_suspend (void) 15293 15294long __TM_is_user_abort (void* const TM_buff) 15295long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code) 15296long __TM_is_illegal (void* const TM_buff) 15297long __TM_is_footprint_exceeded (void* const TM_buff) 15298long __TM_nesting_depth (void* const TM_buff) 15299long __TM_is_nested_too_deep(void* const TM_buff) 15300long __TM_is_conflict(void* const TM_buff) 15301long __TM_is_failure_persistent(void* const TM_buff) 15302long __TM_failure_address(void* const TM_buff) 15303long long __TM_failure_code(void* const TM_buff) 15304@end smallexample 15305 15306Using these common set of HTM inline functions, we can create 15307a more portable version of the HTM example in the previous 15308section that will work on either PowerPC or S/390: 15309 15310@smallexample 15311#include <htmxlintrin.h> 15312 15313int num_retries = 10; 15314TM_buff_type TM_buff; 15315 15316while (1) 15317 @{ 15318 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED) 15319 @{ 15320 /* Transaction State Initiated. */ 15321 if (is_locked (lock)) 15322 __TM_abort (); 15323 ... transaction code... 15324 __TM_end (); 15325 break; 15326 @} 15327 else 15328 @{ 15329 /* Transaction State Failed. Use locks if the transaction 15330 failure is "persistent" or we've tried too many times. */ 15331 if (num_retries-- <= 0 15332 || __TM_is_failure_persistent (TM_buff)) 15333 @{ 15334 acquire_lock (lock); 15335 ... non transactional fallback path... 15336 release_lock (lock); 15337 break; 15338 @} 15339 @} 15340 @} 15341@end smallexample 15342 15343@node RX Built-in Functions 15344@subsection RX Built-in Functions 15345GCC supports some of the RX instructions which cannot be expressed in 15346the C programming language via the use of built-in functions. The 15347following functions are supported: 15348 15349@deftypefn {Built-in Function} void __builtin_rx_brk (void) 15350Generates the @code{brk} machine instruction. 15351@end deftypefn 15352 15353@deftypefn {Built-in Function} void __builtin_rx_clrpsw (int) 15354Generates the @code{clrpsw} machine instruction to clear the specified 15355bit in the processor status word. 15356@end deftypefn 15357 15358@deftypefn {Built-in Function} void __builtin_rx_int (int) 15359Generates the @code{int} machine instruction to generate an interrupt 15360with the specified value. 15361@end deftypefn 15362 15363@deftypefn {Built-in Function} void __builtin_rx_machi (int, int) 15364Generates the @code{machi} machine instruction to add the result of 15365multiplying the top 16 bits of the two arguments into the 15366accumulator. 15367@end deftypefn 15368 15369@deftypefn {Built-in Function} void __builtin_rx_maclo (int, int) 15370Generates the @code{maclo} machine instruction to add the result of 15371multiplying the bottom 16 bits of the two arguments into the 15372accumulator. 15373@end deftypefn 15374 15375@deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int) 15376Generates the @code{mulhi} machine instruction to place the result of 15377multiplying the top 16 bits of the two arguments into the 15378accumulator. 15379@end deftypefn 15380 15381@deftypefn {Built-in Function} void __builtin_rx_mullo (int, int) 15382Generates the @code{mullo} machine instruction to place the result of 15383multiplying the bottom 16 bits of the two arguments into the 15384accumulator. 15385@end deftypefn 15386 15387@deftypefn {Built-in Function} int __builtin_rx_mvfachi (void) 15388Generates the @code{mvfachi} machine instruction to read the top 1538932 bits of the accumulator. 15390@end deftypefn 15391 15392@deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void) 15393Generates the @code{mvfacmi} machine instruction to read the middle 1539432 bits of the accumulator. 15395@end deftypefn 15396 15397@deftypefn {Built-in Function} int __builtin_rx_mvfc (int) 15398Generates the @code{mvfc} machine instruction which reads the control 15399register specified in its argument and returns its value. 15400@end deftypefn 15401 15402@deftypefn {Built-in Function} void __builtin_rx_mvtachi (int) 15403Generates the @code{mvtachi} machine instruction to set the top 1540432 bits of the accumulator. 15405@end deftypefn 15406 15407@deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int) 15408Generates the @code{mvtaclo} machine instruction to set the bottom 1540932 bits of the accumulator. 15410@end deftypefn 15411 15412@deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val) 15413Generates the @code{mvtc} machine instruction which sets control 15414register number @code{reg} to @code{val}. 15415@end deftypefn 15416 15417@deftypefn {Built-in Function} void __builtin_rx_mvtipl (int) 15418Generates the @code{mvtipl} machine instruction set the interrupt 15419priority level. 15420@end deftypefn 15421 15422@deftypefn {Built-in Function} void __builtin_rx_racw (int) 15423Generates the @code{racw} machine instruction to round the accumulator 15424according to the specified mode. 15425@end deftypefn 15426 15427@deftypefn {Built-in Function} int __builtin_rx_revw (int) 15428Generates the @code{revw} machine instruction which swaps the bytes in 15429the argument so that bits 0--7 now occupy bits 8--15 and vice versa, 15430and also bits 16--23 occupy bits 24--31 and vice versa. 15431@end deftypefn 15432 15433@deftypefn {Built-in Function} void __builtin_rx_rmpa (void) 15434Generates the @code{rmpa} machine instruction which initiates a 15435repeated multiply and accumulate sequence. 15436@end deftypefn 15437 15438@deftypefn {Built-in Function} void __builtin_rx_round (float) 15439Generates the @code{round} machine instruction which returns the 15440floating-point argument rounded according to the current rounding mode 15441set in the floating-point status word register. 15442@end deftypefn 15443 15444@deftypefn {Built-in Function} int __builtin_rx_sat (int) 15445Generates the @code{sat} machine instruction which returns the 15446saturated value of the argument. 15447@end deftypefn 15448 15449@deftypefn {Built-in Function} void __builtin_rx_setpsw (int) 15450Generates the @code{setpsw} machine instruction to set the specified 15451bit in the processor status word. 15452@end deftypefn 15453 15454@deftypefn {Built-in Function} void __builtin_rx_wait (void) 15455Generates the @code{wait} machine instruction. 15456@end deftypefn 15457 15458@node S/390 System z Built-in Functions 15459@subsection S/390 System z Built-in Functions 15460@deftypefn {Built-in Function} int __builtin_tbegin (void*) 15461Generates the @code{tbegin} machine instruction starting a 15462non-constraint hardware transaction. If the parameter is non-NULL the 15463memory area is used to store the transaction diagnostic buffer and 15464will be passed as first operand to @code{tbegin}. This buffer can be 15465defined using the @code{struct __htm_tdb} C struct defined in 15466@code{htmintrin.h} and must reside on a double-word boundary. The 15467second tbegin operand is set to @code{0xff0c}. This enables 15468save/restore of all GPRs and disables aborts for FPR and AR 15469manipulations inside the transaction body. The condition code set by 15470the tbegin instruction is returned as integer value. The tbegin 15471instruction by definition overwrites the content of all FPRs. The 15472compiler will generate code which saves and restores the FPRs. For 15473soft-float code it is recommended to used the @code{*_nofloat} 15474variant. In order to prevent a TDB from being written it is required 15475to pass an constant zero value as parameter. Passing the zero value 15476through a variable is not sufficient. Although modifications of 15477access registers inside the transaction will not trigger an 15478transaction abort it is not supported to actually modify them. Access 15479registers do not get saved when entering a transaction. They will have 15480undefined state when reaching the abort code. 15481@end deftypefn 15482 15483Macros for the possible return codes of tbegin are defined in the 15484@code{htmintrin.h} header file: 15485 15486@table @code 15487@item _HTM_TBEGIN_STARTED 15488@code{tbegin} has been executed as part of normal processing. The 15489transaction body is supposed to be executed. 15490@item _HTM_TBEGIN_INDETERMINATE 15491The transaction was aborted due to an indeterminate condition which 15492might be persistent. 15493@item _HTM_TBEGIN_TRANSIENT 15494The transaction aborted due to a transient failure. The transaction 15495should be re-executed in that case. 15496@item _HTM_TBEGIN_PERSISTENT 15497The transaction aborted due to a persistent failure. Re-execution 15498under same circumstances will not be productive. 15499@end table 15500 15501@defmac _HTM_FIRST_USER_ABORT_CODE 15502The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h} 15503specifies the first abort code which can be used for 15504@code{__builtin_tabort}. Values below this threshold are reserved for 15505machine use. 15506@end defmac 15507 15508@deftp {Data type} {struct __htm_tdb} 15509The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes 15510the structure of the transaction diagnostic block as specified in the 15511Principles of Operation manual chapter 5-91. 15512@end deftp 15513 15514@deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*) 15515Same as @code{__builtin_tbegin} but without FPR saves and restores. 15516Using this variant in code making use of FPRs will leave the FPRs in 15517undefined state when entering the transaction abort handler code. 15518@end deftypefn 15519 15520@deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int) 15521In addition to @code{__builtin_tbegin} a loop for transient failures 15522is generated. If tbegin returns a condition code of 2 the transaction 15523will be retried as often as specified in the second argument. The 15524perform processor assist instruction is used to tell the CPU about the 15525number of fails so far. 15526@end deftypefn 15527 15528@deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int) 15529Same as @code{__builtin_tbegin_retry} but without FPR saves and 15530restores. Using this variant in code making use of FPRs will leave 15531the FPRs in undefined state when entering the transaction abort 15532handler code. 15533@end deftypefn 15534 15535@deftypefn {Built-in Function} void __builtin_tbeginc (void) 15536Generates the @code{tbeginc} machine instruction starting a constraint 15537hardware transaction. The second operand is set to @code{0xff08}. 15538@end deftypefn 15539 15540@deftypefn {Built-in Function} int __builtin_tend (void) 15541Generates the @code{tend} machine instruction finishing a transaction 15542and making the changes visible to other threads. The condition code 15543generated by tend is returned as integer value. 15544@end deftypefn 15545 15546@deftypefn {Built-in Function} void __builtin_tabort (int) 15547Generates the @code{tabort} machine instruction with the specified 15548abort code. Abort codes from 0 through 255 are reserved and will 15549result in an error message. 15550@end deftypefn 15551 15552@deftypefn {Built-in Function} void __builtin_tx_assist (int) 15553Generates the @code{ppa rX,rY,1} machine instruction. Where the 15554integer parameter is loaded into rX and a value of zero is loaded into 15555rY. The integer parameter specifies the number of times the 15556transaction repeatedly aborted. 15557@end deftypefn 15558 15559@deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void) 15560Generates the @code{etnd} machine instruction. The current nesting 15561depth is returned as integer value. For a nesting depth of 0 the code 15562is not executed as part of an transaction. 15563@end deftypefn 15564 15565@deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t) 15566 15567Generates the @code{ntstg} machine instruction. The second argument 15568is written to the first arguments location. The store operation will 15569not be rolled-back in case of an transaction abort. 15570@end deftypefn 15571 15572@node SH Built-in Functions 15573@subsection SH Built-in Functions 15574The following built-in functions are supported on the SH1, SH2, SH3 and SH4 15575families of processors: 15576 15577@deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr}) 15578Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually 15579used by system code that manages threads and execution contexts. The compiler 15580normally does not generate code that modifies the contents of @samp{GBR} and 15581thus the value is preserved across function calls. Changing the @samp{GBR} 15582value in user code must be done with caution, since the compiler might use 15583@samp{GBR} in order to access thread local variables. 15584 15585@end deftypefn 15586 15587@deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void) 15588Returns the value that is currently set in the @samp{GBR} register. 15589Memory loads and stores that use the thread pointer as a base address are 15590turned into @samp{GBR} based displacement loads and stores, if possible. 15591For example: 15592@smallexample 15593struct my_tcb 15594@{ 15595 int a, b, c, d, e; 15596@}; 15597 15598int get_tcb_value (void) 15599@{ 15600 // Generate @samp{mov.l @@(8,gbr),r0} instruction 15601 return ((my_tcb*)__builtin_thread_pointer ())->c; 15602@} 15603 15604@end smallexample 15605@end deftypefn 15606 15607@deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void) 15608Returns the value that is currently set in the @samp{FPSCR} register. 15609@end deftypefn 15610 15611@deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val}) 15612Sets the @samp{FPSCR} register to the specified value @var{val}, while 15613preserving the current values of the FR, SZ and PR bits. 15614@end deftypefn 15615 15616@node SPARC VIS Built-in Functions 15617@subsection SPARC VIS Built-in Functions 15618 15619GCC supports SIMD operations on the SPARC using both the generic vector 15620extensions (@pxref{Vector Extensions}) as well as built-in functions for 15621the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis} 15622switch, the VIS extension is exposed as the following built-in functions: 15623 15624@smallexample 15625typedef int v1si __attribute__ ((vector_size (4))); 15626typedef int v2si __attribute__ ((vector_size (8))); 15627typedef short v4hi __attribute__ ((vector_size (8))); 15628typedef short v2hi __attribute__ ((vector_size (4))); 15629typedef unsigned char v8qi __attribute__ ((vector_size (8))); 15630typedef unsigned char v4qi __attribute__ ((vector_size (4))); 15631 15632void __builtin_vis_write_gsr (int64_t); 15633int64_t __builtin_vis_read_gsr (void); 15634 15635void * __builtin_vis_alignaddr (void *, long); 15636void * __builtin_vis_alignaddrl (void *, long); 15637int64_t __builtin_vis_faligndatadi (int64_t, int64_t); 15638v2si __builtin_vis_faligndatav2si (v2si, v2si); 15639v4hi __builtin_vis_faligndatav4hi (v4si, v4si); 15640v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi); 15641 15642v4hi __builtin_vis_fexpand (v4qi); 15643 15644v4hi __builtin_vis_fmul8x16 (v4qi, v4hi); 15645v4hi __builtin_vis_fmul8x16au (v4qi, v2hi); 15646v4hi __builtin_vis_fmul8x16al (v4qi, v2hi); 15647v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi); 15648v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi); 15649v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi); 15650v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi); 15651 15652v4qi __builtin_vis_fpack16 (v4hi); 15653v8qi __builtin_vis_fpack32 (v2si, v8qi); 15654v2hi __builtin_vis_fpackfix (v2si); 15655v8qi __builtin_vis_fpmerge (v4qi, v4qi); 15656 15657int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t); 15658 15659long __builtin_vis_edge8 (void *, void *); 15660long __builtin_vis_edge8l (void *, void *); 15661long __builtin_vis_edge16 (void *, void *); 15662long __builtin_vis_edge16l (void *, void *); 15663long __builtin_vis_edge32 (void *, void *); 15664long __builtin_vis_edge32l (void *, void *); 15665 15666long __builtin_vis_fcmple16 (v4hi, v4hi); 15667long __builtin_vis_fcmple32 (v2si, v2si); 15668long __builtin_vis_fcmpne16 (v4hi, v4hi); 15669long __builtin_vis_fcmpne32 (v2si, v2si); 15670long __builtin_vis_fcmpgt16 (v4hi, v4hi); 15671long __builtin_vis_fcmpgt32 (v2si, v2si); 15672long __builtin_vis_fcmpeq16 (v4hi, v4hi); 15673long __builtin_vis_fcmpeq32 (v2si, v2si); 15674 15675v4hi __builtin_vis_fpadd16 (v4hi, v4hi); 15676v2hi __builtin_vis_fpadd16s (v2hi, v2hi); 15677v2si __builtin_vis_fpadd32 (v2si, v2si); 15678v1si __builtin_vis_fpadd32s (v1si, v1si); 15679v4hi __builtin_vis_fpsub16 (v4hi, v4hi); 15680v2hi __builtin_vis_fpsub16s (v2hi, v2hi); 15681v2si __builtin_vis_fpsub32 (v2si, v2si); 15682v1si __builtin_vis_fpsub32s (v1si, v1si); 15683 15684long __builtin_vis_array8 (long, long); 15685long __builtin_vis_array16 (long, long); 15686long __builtin_vis_array32 (long, long); 15687@end smallexample 15688 15689When you use the @option{-mvis2} switch, the VIS version 2.0 built-in 15690functions also become available: 15691 15692@smallexample 15693long __builtin_vis_bmask (long, long); 15694int64_t __builtin_vis_bshuffledi (int64_t, int64_t); 15695v2si __builtin_vis_bshufflev2si (v2si, v2si); 15696v4hi __builtin_vis_bshufflev2si (v4hi, v4hi); 15697v8qi __builtin_vis_bshufflev2si (v8qi, v8qi); 15698 15699long __builtin_vis_edge8n (void *, void *); 15700long __builtin_vis_edge8ln (void *, void *); 15701long __builtin_vis_edge16n (void *, void *); 15702long __builtin_vis_edge16ln (void *, void *); 15703long __builtin_vis_edge32n (void *, void *); 15704long __builtin_vis_edge32ln (void *, void *); 15705@end smallexample 15706 15707When you use the @option{-mvis3} switch, the VIS version 3.0 built-in 15708functions also become available: 15709 15710@smallexample 15711void __builtin_vis_cmask8 (long); 15712void __builtin_vis_cmask16 (long); 15713void __builtin_vis_cmask32 (long); 15714 15715v4hi __builtin_vis_fchksm16 (v4hi, v4hi); 15716 15717v4hi __builtin_vis_fsll16 (v4hi, v4hi); 15718v4hi __builtin_vis_fslas16 (v4hi, v4hi); 15719v4hi __builtin_vis_fsrl16 (v4hi, v4hi); 15720v4hi __builtin_vis_fsra16 (v4hi, v4hi); 15721v2si __builtin_vis_fsll16 (v2si, v2si); 15722v2si __builtin_vis_fslas16 (v2si, v2si); 15723v2si __builtin_vis_fsrl16 (v2si, v2si); 15724v2si __builtin_vis_fsra16 (v2si, v2si); 15725 15726long __builtin_vis_pdistn (v8qi, v8qi); 15727 15728v4hi __builtin_vis_fmean16 (v4hi, v4hi); 15729 15730int64_t __builtin_vis_fpadd64 (int64_t, int64_t); 15731int64_t __builtin_vis_fpsub64 (int64_t, int64_t); 15732 15733v4hi __builtin_vis_fpadds16 (v4hi, v4hi); 15734v2hi __builtin_vis_fpadds16s (v2hi, v2hi); 15735v4hi __builtin_vis_fpsubs16 (v4hi, v4hi); 15736v2hi __builtin_vis_fpsubs16s (v2hi, v2hi); 15737v2si __builtin_vis_fpadds32 (v2si, v2si); 15738v1si __builtin_vis_fpadds32s (v1si, v1si); 15739v2si __builtin_vis_fpsubs32 (v2si, v2si); 15740v1si __builtin_vis_fpsubs32s (v1si, v1si); 15741 15742long __builtin_vis_fucmple8 (v8qi, v8qi); 15743long __builtin_vis_fucmpne8 (v8qi, v8qi); 15744long __builtin_vis_fucmpgt8 (v8qi, v8qi); 15745long __builtin_vis_fucmpeq8 (v8qi, v8qi); 15746 15747float __builtin_vis_fhadds (float, float); 15748double __builtin_vis_fhaddd (double, double); 15749float __builtin_vis_fhsubs (float, float); 15750double __builtin_vis_fhsubd (double, double); 15751float __builtin_vis_fnhadds (float, float); 15752double __builtin_vis_fnhaddd (double, double); 15753 15754int64_t __builtin_vis_umulxhi (int64_t, int64_t); 15755int64_t __builtin_vis_xmulx (int64_t, int64_t); 15756int64_t __builtin_vis_xmulxhi (int64_t, int64_t); 15757@end smallexample 15758 15759@node SPU Built-in Functions 15760@subsection SPU Built-in Functions 15761 15762GCC provides extensions for the SPU processor as described in the 15763Sony/Toshiba/IBM SPU Language Extensions Specification, which can be 15764found at @uref{http://cell.scei.co.jp/} or 15765@uref{http://www.ibm.com/developerworks/power/cell/}. GCC's 15766implementation differs in several ways. 15767 15768@itemize @bullet 15769 15770@item 15771The optional extension of specifying vector constants in parentheses is 15772not supported. 15773 15774@item 15775A vector initializer requires no cast if the vector constant is of the 15776same type as the variable it is initializing. 15777 15778@item 15779If @code{signed} or @code{unsigned} is omitted, the signedness of the 15780vector type is the default signedness of the base type. The default 15781varies depending on the operating system, so a portable program should 15782always specify the signedness. 15783 15784@item 15785By default, the keyword @code{__vector} is added. The macro 15786@code{vector} is defined in @code{<spu_intrinsics.h>} and can be 15787undefined. 15788 15789@item 15790GCC allows using a @code{typedef} name as the type specifier for a 15791vector type. 15792 15793@item 15794For C, overloaded functions are implemented with macros so the following 15795does not work: 15796 15797@smallexample 15798 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo); 15799@end smallexample 15800 15801@noindent 15802Since @code{spu_add} is a macro, the vector constant in the example 15803is treated as four separate arguments. Wrap the entire argument in 15804parentheses for this to work. 15805 15806@item 15807The extended version of @code{__builtin_expect} is not supported. 15808 15809@end itemize 15810 15811@emph{Note:} Only the interface described in the aforementioned 15812specification is supported. Internally, GCC uses built-in functions to 15813implement the required functionality, but these are not supported and 15814are subject to change without notice. 15815 15816@node TI C6X Built-in Functions 15817@subsection TI C6X Built-in Functions 15818 15819GCC provides intrinsics to access certain instructions of the TI C6X 15820processors. These intrinsics, listed below, are available after 15821inclusion of the @code{c6x_intrinsics.h} header file. They map directly 15822to C6X instructions. 15823 15824@smallexample 15825 15826int _sadd (int, int) 15827int _ssub (int, int) 15828int _sadd2 (int, int) 15829int _ssub2 (int, int) 15830long long _mpy2 (int, int) 15831long long _smpy2 (int, int) 15832int _add4 (int, int) 15833int _sub4 (int, int) 15834int _saddu4 (int, int) 15835 15836int _smpy (int, int) 15837int _smpyh (int, int) 15838int _smpyhl (int, int) 15839int _smpylh (int, int) 15840 15841int _sshl (int, int) 15842int _subc (int, int) 15843 15844int _avg2 (int, int) 15845int _avgu4 (int, int) 15846 15847int _clrr (int, int) 15848int _extr (int, int) 15849int _extru (int, int) 15850int _abs (int) 15851int _abs2 (int) 15852 15853@end smallexample 15854 15855@node TILE-Gx Built-in Functions 15856@subsection TILE-Gx Built-in Functions 15857 15858GCC provides intrinsics to access every instruction of the TILE-Gx 15859processor. The intrinsics are of the form: 15860 15861@smallexample 15862 15863unsigned long long __insn_@var{op} (...) 15864 15865@end smallexample 15866 15867Where @var{op} is the name of the instruction. Refer to the ISA manual 15868for the complete list of instructions. 15869 15870GCC also provides intrinsics to directly access the network registers. 15871The intrinsics are: 15872 15873@smallexample 15874 15875unsigned long long __tile_idn0_receive (void) 15876unsigned long long __tile_idn1_receive (void) 15877unsigned long long __tile_udn0_receive (void) 15878unsigned long long __tile_udn1_receive (void) 15879unsigned long long __tile_udn2_receive (void) 15880unsigned long long __tile_udn3_receive (void) 15881void __tile_idn_send (unsigned long long) 15882void __tile_udn_send (unsigned long long) 15883 15884@end smallexample 15885 15886The intrinsic @code{void __tile_network_barrier (void)} is used to 15887guarantee that no network operations before it are reordered with 15888those after it. 15889 15890@node TILEPro Built-in Functions 15891@subsection TILEPro Built-in Functions 15892 15893GCC provides intrinsics to access every instruction of the TILEPro 15894processor. The intrinsics are of the form: 15895 15896@smallexample 15897 15898unsigned __insn_@var{op} (...) 15899 15900@end smallexample 15901 15902@noindent 15903where @var{op} is the name of the instruction. Refer to the ISA manual 15904for the complete list of instructions. 15905 15906GCC also provides intrinsics to directly access the network registers. 15907The intrinsics are: 15908 15909@smallexample 15910 15911unsigned __tile_idn0_receive (void) 15912unsigned __tile_idn1_receive (void) 15913unsigned __tile_sn_receive (void) 15914unsigned __tile_udn0_receive (void) 15915unsigned __tile_udn1_receive (void) 15916unsigned __tile_udn2_receive (void) 15917unsigned __tile_udn3_receive (void) 15918void __tile_idn_send (unsigned) 15919void __tile_sn_send (unsigned) 15920void __tile_udn_send (unsigned) 15921 15922@end smallexample 15923 15924The intrinsic @code{void __tile_network_barrier (void)} is used to 15925guarantee that no network operations before it are reordered with 15926those after it. 15927 15928@node x86 Built-in Functions 15929@subsection x86 Built-in Functions 15930 15931These built-in functions are available for the x86-32 and x86-64 family 15932of computers, depending on the command-line switches used. 15933 15934If you specify command-line switches such as @option{-msse}, 15935the compiler could use the extended instruction sets even if the built-ins 15936are not used explicitly in the program. For this reason, applications 15937that perform run-time CPU detection must compile separate files for each 15938supported architecture, using the appropriate flags. In particular, 15939the file containing the CPU detection code should be compiled without 15940these options. 15941 15942The following machine modes are available for use with MMX built-in functions 15943(@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers, 15944@code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a 15945vector of eight 8-bit integers. Some of the built-in functions operate on 15946MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode. 15947 15948If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector 15949of two 32-bit floating-point values. 15950 15951If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit 15952floating-point values. Some instructions use a vector of four 32-bit 15953integers, these use @code{V4SI}. Finally, some instructions operate on an 15954entire vector register, interpreting it as a 128-bit integer, these use mode 15955@code{TI}. 15956 15957In 64-bit mode, the x86-64 family of processors uses additional built-in 15958functions for efficient use of @code{TF} (@code{__float128}) 128-bit 15959floating point and @code{TC} 128-bit complex floating-point values. 15960 15961The following floating-point built-in functions are available in 64-bit 15962mode. All of them implement the function that is part of the name. 15963 15964@smallexample 15965__float128 __builtin_fabsq (__float128) 15966__float128 __builtin_copysignq (__float128, __float128) 15967@end smallexample 15968 15969The following built-in function is always available. 15970 15971@table @code 15972@item void __builtin_ia32_pause (void) 15973Generates the @code{pause} machine instruction with a compiler memory 15974barrier. 15975@end table 15976 15977The following floating-point built-in functions are made available in the 1597864-bit mode. 15979 15980@table @code 15981@item __float128 __builtin_infq (void) 15982Similar to @code{__builtin_inf}, except the return type is @code{__float128}. 15983@findex __builtin_infq 15984 15985@item __float128 __builtin_huge_valq (void) 15986Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}. 15987@findex __builtin_huge_valq 15988@end table 15989 15990The following built-in functions are always available and can be used to 15991check the target platform type. 15992 15993@deftypefn {Built-in Function} void __builtin_cpu_init (void) 15994This function runs the CPU detection code to check the type of CPU and the 15995features supported. This built-in function needs to be invoked along with the built-in functions 15996to check CPU type and features, @code{__builtin_cpu_is} and 15997@code{__builtin_cpu_supports}, only when used in a function that is 15998executed before any constructors are called. The CPU detection code is 15999automatically executed in a very high priority constructor. 16000 16001For example, this function has to be used in @code{ifunc} resolvers that 16002check for CPU type using the built-in functions @code{__builtin_cpu_is} 16003and @code{__builtin_cpu_supports}, or in constructors on targets that 16004don't support constructor priority. 16005@smallexample 16006 16007static void (*resolve_memcpy (void)) (void) 16008@{ 16009 // ifunc resolvers fire before constructors, explicitly call the init 16010 // function. 16011 __builtin_cpu_init (); 16012 if (__builtin_cpu_supports ("ssse3")) 16013 return ssse3_memcpy; // super fast memcpy with ssse3 instructions. 16014 else 16015 return default_memcpy; 16016@} 16017 16018void *memcpy (void *, const void *, size_t) 16019 __attribute__ ((ifunc ("resolve_memcpy"))); 16020@end smallexample 16021 16022@end deftypefn 16023 16024@deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname}) 16025This function returns a positive integer if the run-time CPU 16026is of type @var{cpuname} 16027and returns @code{0} otherwise. The following CPU names can be detected: 16028 16029@table @samp 16030@item intel 16031Intel CPU. 16032 16033@item atom 16034Intel Atom CPU. 16035 16036@item core2 16037Intel Core 2 CPU. 16038 16039@item corei7 16040Intel Core i7 CPU. 16041 16042@item nehalem 16043Intel Core i7 Nehalem CPU. 16044 16045@item westmere 16046Intel Core i7 Westmere CPU. 16047 16048@item sandybridge 16049Intel Core i7 Sandy Bridge CPU. 16050 16051@item amd 16052AMD CPU. 16053 16054@item amdfam10h 16055AMD Family 10h CPU. 16056 16057@item barcelona 16058AMD Family 10h Barcelona CPU. 16059 16060@item shanghai 16061AMD Family 10h Shanghai CPU. 16062 16063@item istanbul 16064AMD Family 10h Istanbul CPU. 16065 16066@item btver1 16067AMD Family 14h CPU. 16068 16069@item amdfam15h 16070AMD Family 15h CPU. 16071 16072@item bdver1 16073AMD Family 15h Bulldozer version 1. 16074 16075@item bdver2 16076AMD Family 15h Bulldozer version 2. 16077 16078@item bdver3 16079AMD Family 15h Bulldozer version 3. 16080 16081@item bdver4 16082AMD Family 15h Bulldozer version 4. 16083 16084@item btver2 16085AMD Family 16h CPU. 16086@end table 16087 16088Here is an example: 16089@smallexample 16090if (__builtin_cpu_is ("corei7")) 16091 @{ 16092 do_corei7 (); // Core i7 specific implementation. 16093 @} 16094else 16095 @{ 16096 do_generic (); // Generic implementation. 16097 @} 16098@end smallexample 16099@end deftypefn 16100 16101@deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature}) 16102This function returns a positive integer if the run-time CPU 16103supports @var{feature} 16104and returns @code{0} otherwise. The following features can be detected: 16105 16106@table @samp 16107@item cmov 16108CMOV instruction. 16109@item mmx 16110MMX instructions. 16111@item popcnt 16112POPCNT instruction. 16113@item sse 16114SSE instructions. 16115@item sse2 16116SSE2 instructions. 16117@item sse3 16118SSE3 instructions. 16119@item ssse3 16120SSSE3 instructions. 16121@item sse4.1 16122SSE4.1 instructions. 16123@item sse4.2 16124SSE4.2 instructions. 16125@item avx 16126AVX instructions. 16127@item avx2 16128AVX2 instructions. 16129@item avx512f 16130AVX512F instructions. 16131@end table 16132 16133Here is an example: 16134@smallexample 16135if (__builtin_cpu_supports ("popcnt")) 16136 @{ 16137 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc"); 16138 @} 16139else 16140 @{ 16141 count = generic_countbits (n); //generic implementation. 16142 @} 16143@end smallexample 16144@end deftypefn 16145 16146 16147The following built-in functions are made available by @option{-mmmx}. 16148All of them generate the machine instruction that is part of the name. 16149 16150@smallexample 16151v8qi __builtin_ia32_paddb (v8qi, v8qi) 16152v4hi __builtin_ia32_paddw (v4hi, v4hi) 16153v2si __builtin_ia32_paddd (v2si, v2si) 16154v8qi __builtin_ia32_psubb (v8qi, v8qi) 16155v4hi __builtin_ia32_psubw (v4hi, v4hi) 16156v2si __builtin_ia32_psubd (v2si, v2si) 16157v8qi __builtin_ia32_paddsb (v8qi, v8qi) 16158v4hi __builtin_ia32_paddsw (v4hi, v4hi) 16159v8qi __builtin_ia32_psubsb (v8qi, v8qi) 16160v4hi __builtin_ia32_psubsw (v4hi, v4hi) 16161v8qi __builtin_ia32_paddusb (v8qi, v8qi) 16162v4hi __builtin_ia32_paddusw (v4hi, v4hi) 16163v8qi __builtin_ia32_psubusb (v8qi, v8qi) 16164v4hi __builtin_ia32_psubusw (v4hi, v4hi) 16165v4hi __builtin_ia32_pmullw (v4hi, v4hi) 16166v4hi __builtin_ia32_pmulhw (v4hi, v4hi) 16167di __builtin_ia32_pand (di, di) 16168di __builtin_ia32_pandn (di,di) 16169di __builtin_ia32_por (di, di) 16170di __builtin_ia32_pxor (di, di) 16171v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi) 16172v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi) 16173v2si __builtin_ia32_pcmpeqd (v2si, v2si) 16174v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi) 16175v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi) 16176v2si __builtin_ia32_pcmpgtd (v2si, v2si) 16177v8qi __builtin_ia32_punpckhbw (v8qi, v8qi) 16178v4hi __builtin_ia32_punpckhwd (v4hi, v4hi) 16179v2si __builtin_ia32_punpckhdq (v2si, v2si) 16180v8qi __builtin_ia32_punpcklbw (v8qi, v8qi) 16181v4hi __builtin_ia32_punpcklwd (v4hi, v4hi) 16182v2si __builtin_ia32_punpckldq (v2si, v2si) 16183v8qi __builtin_ia32_packsswb (v4hi, v4hi) 16184v4hi __builtin_ia32_packssdw (v2si, v2si) 16185v8qi __builtin_ia32_packuswb (v4hi, v4hi) 16186 16187v4hi __builtin_ia32_psllw (v4hi, v4hi) 16188v2si __builtin_ia32_pslld (v2si, v2si) 16189v1di __builtin_ia32_psllq (v1di, v1di) 16190v4hi __builtin_ia32_psrlw (v4hi, v4hi) 16191v2si __builtin_ia32_psrld (v2si, v2si) 16192v1di __builtin_ia32_psrlq (v1di, v1di) 16193v4hi __builtin_ia32_psraw (v4hi, v4hi) 16194v2si __builtin_ia32_psrad (v2si, v2si) 16195v4hi __builtin_ia32_psllwi (v4hi, int) 16196v2si __builtin_ia32_pslldi (v2si, int) 16197v1di __builtin_ia32_psllqi (v1di, int) 16198v4hi __builtin_ia32_psrlwi (v4hi, int) 16199v2si __builtin_ia32_psrldi (v2si, int) 16200v1di __builtin_ia32_psrlqi (v1di, int) 16201v4hi __builtin_ia32_psrawi (v4hi, int) 16202v2si __builtin_ia32_psradi (v2si, int) 16203 16204@end smallexample 16205 16206The following built-in functions are made available either with 16207@option{-msse}, or with a combination of @option{-m3dnow} and 16208@option{-march=athlon}. All of them generate the machine 16209instruction that is part of the name. 16210 16211@smallexample 16212v4hi __builtin_ia32_pmulhuw (v4hi, v4hi) 16213v8qi __builtin_ia32_pavgb (v8qi, v8qi) 16214v4hi __builtin_ia32_pavgw (v4hi, v4hi) 16215v1di __builtin_ia32_psadbw (v8qi, v8qi) 16216v8qi __builtin_ia32_pmaxub (v8qi, v8qi) 16217v4hi __builtin_ia32_pmaxsw (v4hi, v4hi) 16218v8qi __builtin_ia32_pminub (v8qi, v8qi) 16219v4hi __builtin_ia32_pminsw (v4hi, v4hi) 16220int __builtin_ia32_pmovmskb (v8qi) 16221void __builtin_ia32_maskmovq (v8qi, v8qi, char *) 16222void __builtin_ia32_movntq (di *, di) 16223void __builtin_ia32_sfence (void) 16224@end smallexample 16225 16226The following built-in functions are available when @option{-msse} is used. 16227All of them generate the machine instruction that is part of the name. 16228 16229@smallexample 16230int __builtin_ia32_comieq (v4sf, v4sf) 16231int __builtin_ia32_comineq (v4sf, v4sf) 16232int __builtin_ia32_comilt (v4sf, v4sf) 16233int __builtin_ia32_comile (v4sf, v4sf) 16234int __builtin_ia32_comigt (v4sf, v4sf) 16235int __builtin_ia32_comige (v4sf, v4sf) 16236int __builtin_ia32_ucomieq (v4sf, v4sf) 16237int __builtin_ia32_ucomineq (v4sf, v4sf) 16238int __builtin_ia32_ucomilt (v4sf, v4sf) 16239int __builtin_ia32_ucomile (v4sf, v4sf) 16240int __builtin_ia32_ucomigt (v4sf, v4sf) 16241int __builtin_ia32_ucomige (v4sf, v4sf) 16242v4sf __builtin_ia32_addps (v4sf, v4sf) 16243v4sf __builtin_ia32_subps (v4sf, v4sf) 16244v4sf __builtin_ia32_mulps (v4sf, v4sf) 16245v4sf __builtin_ia32_divps (v4sf, v4sf) 16246v4sf __builtin_ia32_addss (v4sf, v4sf) 16247v4sf __builtin_ia32_subss (v4sf, v4sf) 16248v4sf __builtin_ia32_mulss (v4sf, v4sf) 16249v4sf __builtin_ia32_divss (v4sf, v4sf) 16250v4sf __builtin_ia32_cmpeqps (v4sf, v4sf) 16251v4sf __builtin_ia32_cmpltps (v4sf, v4sf) 16252v4sf __builtin_ia32_cmpleps (v4sf, v4sf) 16253v4sf __builtin_ia32_cmpgtps (v4sf, v4sf) 16254v4sf __builtin_ia32_cmpgeps (v4sf, v4sf) 16255v4sf __builtin_ia32_cmpunordps (v4sf, v4sf) 16256v4sf __builtin_ia32_cmpneqps (v4sf, v4sf) 16257v4sf __builtin_ia32_cmpnltps (v4sf, v4sf) 16258v4sf __builtin_ia32_cmpnleps (v4sf, v4sf) 16259v4sf __builtin_ia32_cmpngtps (v4sf, v4sf) 16260v4sf __builtin_ia32_cmpngeps (v4sf, v4sf) 16261v4sf __builtin_ia32_cmpordps (v4sf, v4sf) 16262v4sf __builtin_ia32_cmpeqss (v4sf, v4sf) 16263v4sf __builtin_ia32_cmpltss (v4sf, v4sf) 16264v4sf __builtin_ia32_cmpless (v4sf, v4sf) 16265v4sf __builtin_ia32_cmpunordss (v4sf, v4sf) 16266v4sf __builtin_ia32_cmpneqss (v4sf, v4sf) 16267v4sf __builtin_ia32_cmpnltss (v4sf, v4sf) 16268v4sf __builtin_ia32_cmpnless (v4sf, v4sf) 16269v4sf __builtin_ia32_cmpordss (v4sf, v4sf) 16270v4sf __builtin_ia32_maxps (v4sf, v4sf) 16271v4sf __builtin_ia32_maxss (v4sf, v4sf) 16272v4sf __builtin_ia32_minps (v4sf, v4sf) 16273v4sf __builtin_ia32_minss (v4sf, v4sf) 16274v4sf __builtin_ia32_andps (v4sf, v4sf) 16275v4sf __builtin_ia32_andnps (v4sf, v4sf) 16276v4sf __builtin_ia32_orps (v4sf, v4sf) 16277v4sf __builtin_ia32_xorps (v4sf, v4sf) 16278v4sf __builtin_ia32_movss (v4sf, v4sf) 16279v4sf __builtin_ia32_movhlps (v4sf, v4sf) 16280v4sf __builtin_ia32_movlhps (v4sf, v4sf) 16281v4sf __builtin_ia32_unpckhps (v4sf, v4sf) 16282v4sf __builtin_ia32_unpcklps (v4sf, v4sf) 16283v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si) 16284v4sf __builtin_ia32_cvtsi2ss (v4sf, int) 16285v2si __builtin_ia32_cvtps2pi (v4sf) 16286int __builtin_ia32_cvtss2si (v4sf) 16287v2si __builtin_ia32_cvttps2pi (v4sf) 16288int __builtin_ia32_cvttss2si (v4sf) 16289v4sf __builtin_ia32_rcpps (v4sf) 16290v4sf __builtin_ia32_rsqrtps (v4sf) 16291v4sf __builtin_ia32_sqrtps (v4sf) 16292v4sf __builtin_ia32_rcpss (v4sf) 16293v4sf __builtin_ia32_rsqrtss (v4sf) 16294v4sf __builtin_ia32_sqrtss (v4sf) 16295v4sf __builtin_ia32_shufps (v4sf, v4sf, int) 16296void __builtin_ia32_movntps (float *, v4sf) 16297int __builtin_ia32_movmskps (v4sf) 16298@end smallexample 16299 16300The following built-in functions are available when @option{-msse} is used. 16301 16302@table @code 16303@item v4sf __builtin_ia32_loadups (float *) 16304Generates the @code{movups} machine instruction as a load from memory. 16305@item void __builtin_ia32_storeups (float *, v4sf) 16306Generates the @code{movups} machine instruction as a store to memory. 16307@item v4sf __builtin_ia32_loadss (float *) 16308Generates the @code{movss} machine instruction as a load from memory. 16309@item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *) 16310Generates the @code{movhps} machine instruction as a load from memory. 16311@item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *) 16312Generates the @code{movlps} machine instruction as a load from memory 16313@item void __builtin_ia32_storehps (v2sf *, v4sf) 16314Generates the @code{movhps} machine instruction as a store to memory. 16315@item void __builtin_ia32_storelps (v2sf *, v4sf) 16316Generates the @code{movlps} machine instruction as a store to memory. 16317@end table 16318 16319The following built-in functions are available when @option{-msse2} is used. 16320All of them generate the machine instruction that is part of the name. 16321 16322@smallexample 16323int __builtin_ia32_comisdeq (v2df, v2df) 16324int __builtin_ia32_comisdlt (v2df, v2df) 16325int __builtin_ia32_comisdle (v2df, v2df) 16326int __builtin_ia32_comisdgt (v2df, v2df) 16327int __builtin_ia32_comisdge (v2df, v2df) 16328int __builtin_ia32_comisdneq (v2df, v2df) 16329int __builtin_ia32_ucomisdeq (v2df, v2df) 16330int __builtin_ia32_ucomisdlt (v2df, v2df) 16331int __builtin_ia32_ucomisdle (v2df, v2df) 16332int __builtin_ia32_ucomisdgt (v2df, v2df) 16333int __builtin_ia32_ucomisdge (v2df, v2df) 16334int __builtin_ia32_ucomisdneq (v2df, v2df) 16335v2df __builtin_ia32_cmpeqpd (v2df, v2df) 16336v2df __builtin_ia32_cmpltpd (v2df, v2df) 16337v2df __builtin_ia32_cmplepd (v2df, v2df) 16338v2df __builtin_ia32_cmpgtpd (v2df, v2df) 16339v2df __builtin_ia32_cmpgepd (v2df, v2df) 16340v2df __builtin_ia32_cmpunordpd (v2df, v2df) 16341v2df __builtin_ia32_cmpneqpd (v2df, v2df) 16342v2df __builtin_ia32_cmpnltpd (v2df, v2df) 16343v2df __builtin_ia32_cmpnlepd (v2df, v2df) 16344v2df __builtin_ia32_cmpngtpd (v2df, v2df) 16345v2df __builtin_ia32_cmpngepd (v2df, v2df) 16346v2df __builtin_ia32_cmpordpd (v2df, v2df) 16347v2df __builtin_ia32_cmpeqsd (v2df, v2df) 16348v2df __builtin_ia32_cmpltsd (v2df, v2df) 16349v2df __builtin_ia32_cmplesd (v2df, v2df) 16350v2df __builtin_ia32_cmpunordsd (v2df, v2df) 16351v2df __builtin_ia32_cmpneqsd (v2df, v2df) 16352v2df __builtin_ia32_cmpnltsd (v2df, v2df) 16353v2df __builtin_ia32_cmpnlesd (v2df, v2df) 16354v2df __builtin_ia32_cmpordsd (v2df, v2df) 16355v2di __builtin_ia32_paddq (v2di, v2di) 16356v2di __builtin_ia32_psubq (v2di, v2di) 16357v2df __builtin_ia32_addpd (v2df, v2df) 16358v2df __builtin_ia32_subpd (v2df, v2df) 16359v2df __builtin_ia32_mulpd (v2df, v2df) 16360v2df __builtin_ia32_divpd (v2df, v2df) 16361v2df __builtin_ia32_addsd (v2df, v2df) 16362v2df __builtin_ia32_subsd (v2df, v2df) 16363v2df __builtin_ia32_mulsd (v2df, v2df) 16364v2df __builtin_ia32_divsd (v2df, v2df) 16365v2df __builtin_ia32_minpd (v2df, v2df) 16366v2df __builtin_ia32_maxpd (v2df, v2df) 16367v2df __builtin_ia32_minsd (v2df, v2df) 16368v2df __builtin_ia32_maxsd (v2df, v2df) 16369v2df __builtin_ia32_andpd (v2df, v2df) 16370v2df __builtin_ia32_andnpd (v2df, v2df) 16371v2df __builtin_ia32_orpd (v2df, v2df) 16372v2df __builtin_ia32_xorpd (v2df, v2df) 16373v2df __builtin_ia32_movsd (v2df, v2df) 16374v2df __builtin_ia32_unpckhpd (v2df, v2df) 16375v2df __builtin_ia32_unpcklpd (v2df, v2df) 16376v16qi __builtin_ia32_paddb128 (v16qi, v16qi) 16377v8hi __builtin_ia32_paddw128 (v8hi, v8hi) 16378v4si __builtin_ia32_paddd128 (v4si, v4si) 16379v2di __builtin_ia32_paddq128 (v2di, v2di) 16380v16qi __builtin_ia32_psubb128 (v16qi, v16qi) 16381v8hi __builtin_ia32_psubw128 (v8hi, v8hi) 16382v4si __builtin_ia32_psubd128 (v4si, v4si) 16383v2di __builtin_ia32_psubq128 (v2di, v2di) 16384v8hi __builtin_ia32_pmullw128 (v8hi, v8hi) 16385v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi) 16386v2di __builtin_ia32_pand128 (v2di, v2di) 16387v2di __builtin_ia32_pandn128 (v2di, v2di) 16388v2di __builtin_ia32_por128 (v2di, v2di) 16389v2di __builtin_ia32_pxor128 (v2di, v2di) 16390v16qi __builtin_ia32_pavgb128 (v16qi, v16qi) 16391v8hi __builtin_ia32_pavgw128 (v8hi, v8hi) 16392v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi) 16393v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi) 16394v4si __builtin_ia32_pcmpeqd128 (v4si, v4si) 16395v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi) 16396v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi) 16397v4si __builtin_ia32_pcmpgtd128 (v4si, v4si) 16398v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi) 16399v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi) 16400v16qi __builtin_ia32_pminub128 (v16qi, v16qi) 16401v8hi __builtin_ia32_pminsw128 (v8hi, v8hi) 16402v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi) 16403v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi) 16404v4si __builtin_ia32_punpckhdq128 (v4si, v4si) 16405v2di __builtin_ia32_punpckhqdq128 (v2di, v2di) 16406v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi) 16407v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi) 16408v4si __builtin_ia32_punpckldq128 (v4si, v4si) 16409v2di __builtin_ia32_punpcklqdq128 (v2di, v2di) 16410v16qi __builtin_ia32_packsswb128 (v8hi, v8hi) 16411v8hi __builtin_ia32_packssdw128 (v4si, v4si) 16412v16qi __builtin_ia32_packuswb128 (v8hi, v8hi) 16413v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi) 16414void __builtin_ia32_maskmovdqu (v16qi, v16qi) 16415v2df __builtin_ia32_loadupd (double *) 16416void __builtin_ia32_storeupd (double *, v2df) 16417v2df __builtin_ia32_loadhpd (v2df, double const *) 16418v2df __builtin_ia32_loadlpd (v2df, double const *) 16419int __builtin_ia32_movmskpd (v2df) 16420int __builtin_ia32_pmovmskb128 (v16qi) 16421void __builtin_ia32_movnti (int *, int) 16422void __builtin_ia32_movnti64 (long long int *, long long int) 16423void __builtin_ia32_movntpd (double *, v2df) 16424void __builtin_ia32_movntdq (v2df *, v2df) 16425v4si __builtin_ia32_pshufd (v4si, int) 16426v8hi __builtin_ia32_pshuflw (v8hi, int) 16427v8hi __builtin_ia32_pshufhw (v8hi, int) 16428v2di __builtin_ia32_psadbw128 (v16qi, v16qi) 16429v2df __builtin_ia32_sqrtpd (v2df) 16430v2df __builtin_ia32_sqrtsd (v2df) 16431v2df __builtin_ia32_shufpd (v2df, v2df, int) 16432v2df __builtin_ia32_cvtdq2pd (v4si) 16433v4sf __builtin_ia32_cvtdq2ps (v4si) 16434v4si __builtin_ia32_cvtpd2dq (v2df) 16435v2si __builtin_ia32_cvtpd2pi (v2df) 16436v4sf __builtin_ia32_cvtpd2ps (v2df) 16437v4si __builtin_ia32_cvttpd2dq (v2df) 16438v2si __builtin_ia32_cvttpd2pi (v2df) 16439v2df __builtin_ia32_cvtpi2pd (v2si) 16440int __builtin_ia32_cvtsd2si (v2df) 16441int __builtin_ia32_cvttsd2si (v2df) 16442long long __builtin_ia32_cvtsd2si64 (v2df) 16443long long __builtin_ia32_cvttsd2si64 (v2df) 16444v4si __builtin_ia32_cvtps2dq (v4sf) 16445v2df __builtin_ia32_cvtps2pd (v4sf) 16446v4si __builtin_ia32_cvttps2dq (v4sf) 16447v2df __builtin_ia32_cvtsi2sd (v2df, int) 16448v2df __builtin_ia32_cvtsi642sd (v2df, long long) 16449v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df) 16450v2df __builtin_ia32_cvtss2sd (v2df, v4sf) 16451void __builtin_ia32_clflush (const void *) 16452void __builtin_ia32_lfence (void) 16453void __builtin_ia32_mfence (void) 16454v16qi __builtin_ia32_loaddqu (const char *) 16455void __builtin_ia32_storedqu (char *, v16qi) 16456v1di __builtin_ia32_pmuludq (v2si, v2si) 16457v2di __builtin_ia32_pmuludq128 (v4si, v4si) 16458v8hi __builtin_ia32_psllw128 (v8hi, v8hi) 16459v4si __builtin_ia32_pslld128 (v4si, v4si) 16460v2di __builtin_ia32_psllq128 (v2di, v2di) 16461v8hi __builtin_ia32_psrlw128 (v8hi, v8hi) 16462v4si __builtin_ia32_psrld128 (v4si, v4si) 16463v2di __builtin_ia32_psrlq128 (v2di, v2di) 16464v8hi __builtin_ia32_psraw128 (v8hi, v8hi) 16465v4si __builtin_ia32_psrad128 (v4si, v4si) 16466v2di __builtin_ia32_pslldqi128 (v2di, int) 16467v8hi __builtin_ia32_psllwi128 (v8hi, int) 16468v4si __builtin_ia32_pslldi128 (v4si, int) 16469v2di __builtin_ia32_psllqi128 (v2di, int) 16470v2di __builtin_ia32_psrldqi128 (v2di, int) 16471v8hi __builtin_ia32_psrlwi128 (v8hi, int) 16472v4si __builtin_ia32_psrldi128 (v4si, int) 16473v2di __builtin_ia32_psrlqi128 (v2di, int) 16474v8hi __builtin_ia32_psrawi128 (v8hi, int) 16475v4si __builtin_ia32_psradi128 (v4si, int) 16476v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi) 16477v2di __builtin_ia32_movq128 (v2di) 16478@end smallexample 16479 16480The following built-in functions are available when @option{-msse3} is used. 16481All of them generate the machine instruction that is part of the name. 16482 16483@smallexample 16484v2df __builtin_ia32_addsubpd (v2df, v2df) 16485v4sf __builtin_ia32_addsubps (v4sf, v4sf) 16486v2df __builtin_ia32_haddpd (v2df, v2df) 16487v4sf __builtin_ia32_haddps (v4sf, v4sf) 16488v2df __builtin_ia32_hsubpd (v2df, v2df) 16489v4sf __builtin_ia32_hsubps (v4sf, v4sf) 16490v16qi __builtin_ia32_lddqu (char const *) 16491void __builtin_ia32_monitor (void *, unsigned int, unsigned int) 16492v4sf __builtin_ia32_movshdup (v4sf) 16493v4sf __builtin_ia32_movsldup (v4sf) 16494void __builtin_ia32_mwait (unsigned int, unsigned int) 16495@end smallexample 16496 16497The following built-in functions are available when @option{-mssse3} is used. 16498All of them generate the machine instruction that is part of the name. 16499 16500@smallexample 16501v2si __builtin_ia32_phaddd (v2si, v2si) 16502v4hi __builtin_ia32_phaddw (v4hi, v4hi) 16503v4hi __builtin_ia32_phaddsw (v4hi, v4hi) 16504v2si __builtin_ia32_phsubd (v2si, v2si) 16505v4hi __builtin_ia32_phsubw (v4hi, v4hi) 16506v4hi __builtin_ia32_phsubsw (v4hi, v4hi) 16507v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi) 16508v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi) 16509v8qi __builtin_ia32_pshufb (v8qi, v8qi) 16510v8qi __builtin_ia32_psignb (v8qi, v8qi) 16511v2si __builtin_ia32_psignd (v2si, v2si) 16512v4hi __builtin_ia32_psignw (v4hi, v4hi) 16513v1di __builtin_ia32_palignr (v1di, v1di, int) 16514v8qi __builtin_ia32_pabsb (v8qi) 16515v2si __builtin_ia32_pabsd (v2si) 16516v4hi __builtin_ia32_pabsw (v4hi) 16517@end smallexample 16518 16519The following built-in functions are available when @option{-mssse3} is used. 16520All of them generate the machine instruction that is part of the name. 16521 16522@smallexample 16523v4si __builtin_ia32_phaddd128 (v4si, v4si) 16524v8hi __builtin_ia32_phaddw128 (v8hi, v8hi) 16525v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi) 16526v4si __builtin_ia32_phsubd128 (v4si, v4si) 16527v8hi __builtin_ia32_phsubw128 (v8hi, v8hi) 16528v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi) 16529v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi) 16530v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi) 16531v16qi __builtin_ia32_pshufb128 (v16qi, v16qi) 16532v16qi __builtin_ia32_psignb128 (v16qi, v16qi) 16533v4si __builtin_ia32_psignd128 (v4si, v4si) 16534v8hi __builtin_ia32_psignw128 (v8hi, v8hi) 16535v2di __builtin_ia32_palignr128 (v2di, v2di, int) 16536v16qi __builtin_ia32_pabsb128 (v16qi) 16537v4si __builtin_ia32_pabsd128 (v4si) 16538v8hi __builtin_ia32_pabsw128 (v8hi) 16539@end smallexample 16540 16541The following built-in functions are available when @option{-msse4.1} is 16542used. All of them generate the machine instruction that is part of the 16543name. 16544 16545@smallexample 16546v2df __builtin_ia32_blendpd (v2df, v2df, const int) 16547v4sf __builtin_ia32_blendps (v4sf, v4sf, const int) 16548v2df __builtin_ia32_blendvpd (v2df, v2df, v2df) 16549v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf) 16550v2df __builtin_ia32_dppd (v2df, v2df, const int) 16551v4sf __builtin_ia32_dpps (v4sf, v4sf, const int) 16552v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int) 16553v2di __builtin_ia32_movntdqa (v2di *); 16554v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int) 16555v8hi __builtin_ia32_packusdw128 (v4si, v4si) 16556v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi) 16557v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int) 16558v2di __builtin_ia32_pcmpeqq (v2di, v2di) 16559v8hi __builtin_ia32_phminposuw128 (v8hi) 16560v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi) 16561v4si __builtin_ia32_pmaxsd128 (v4si, v4si) 16562v4si __builtin_ia32_pmaxud128 (v4si, v4si) 16563v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi) 16564v16qi __builtin_ia32_pminsb128 (v16qi, v16qi) 16565v4si __builtin_ia32_pminsd128 (v4si, v4si) 16566v4si __builtin_ia32_pminud128 (v4si, v4si) 16567v8hi __builtin_ia32_pminuw128 (v8hi, v8hi) 16568v4si __builtin_ia32_pmovsxbd128 (v16qi) 16569v2di __builtin_ia32_pmovsxbq128 (v16qi) 16570v8hi __builtin_ia32_pmovsxbw128 (v16qi) 16571v2di __builtin_ia32_pmovsxdq128 (v4si) 16572v4si __builtin_ia32_pmovsxwd128 (v8hi) 16573v2di __builtin_ia32_pmovsxwq128 (v8hi) 16574v4si __builtin_ia32_pmovzxbd128 (v16qi) 16575v2di __builtin_ia32_pmovzxbq128 (v16qi) 16576v8hi __builtin_ia32_pmovzxbw128 (v16qi) 16577v2di __builtin_ia32_pmovzxdq128 (v4si) 16578v4si __builtin_ia32_pmovzxwd128 (v8hi) 16579v2di __builtin_ia32_pmovzxwq128 (v8hi) 16580v2di __builtin_ia32_pmuldq128 (v4si, v4si) 16581v4si __builtin_ia32_pmulld128 (v4si, v4si) 16582int __builtin_ia32_ptestc128 (v2di, v2di) 16583int __builtin_ia32_ptestnzc128 (v2di, v2di) 16584int __builtin_ia32_ptestz128 (v2di, v2di) 16585v2df __builtin_ia32_roundpd (v2df, const int) 16586v4sf __builtin_ia32_roundps (v4sf, const int) 16587v2df __builtin_ia32_roundsd (v2df, v2df, const int) 16588v4sf __builtin_ia32_roundss (v4sf, v4sf, const int) 16589@end smallexample 16590 16591The following built-in functions are available when @option{-msse4.1} is 16592used. 16593 16594@table @code 16595@item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int) 16596Generates the @code{insertps} machine instruction. 16597@item int __builtin_ia32_vec_ext_v16qi (v16qi, const int) 16598Generates the @code{pextrb} machine instruction. 16599@item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int) 16600Generates the @code{pinsrb} machine instruction. 16601@item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int) 16602Generates the @code{pinsrd} machine instruction. 16603@item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int) 16604Generates the @code{pinsrq} machine instruction in 64bit mode. 16605@end table 16606 16607The following built-in functions are changed to generate new SSE4.1 16608instructions when @option{-msse4.1} is used. 16609 16610@table @code 16611@item float __builtin_ia32_vec_ext_v4sf (v4sf, const int) 16612Generates the @code{extractps} machine instruction. 16613@item int __builtin_ia32_vec_ext_v4si (v4si, const int) 16614Generates the @code{pextrd} machine instruction. 16615@item long long __builtin_ia32_vec_ext_v2di (v2di, const int) 16616Generates the @code{pextrq} machine instruction in 64bit mode. 16617@end table 16618 16619The following built-in functions are available when @option{-msse4.2} is 16620used. All of them generate the machine instruction that is part of the 16621name. 16622 16623@smallexample 16624v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int) 16625int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int) 16626int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int) 16627int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int) 16628int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int) 16629int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int) 16630int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int) 16631v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int) 16632int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int) 16633int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int) 16634int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int) 16635int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int) 16636int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int) 16637int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int) 16638v2di __builtin_ia32_pcmpgtq (v2di, v2di) 16639@end smallexample 16640 16641The following built-in functions are available when @option{-msse4.2} is 16642used. 16643 16644@table @code 16645@item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char) 16646Generates the @code{crc32b} machine instruction. 16647@item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short) 16648Generates the @code{crc32w} machine instruction. 16649@item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int) 16650Generates the @code{crc32l} machine instruction. 16651@item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long) 16652Generates the @code{crc32q} machine instruction. 16653@end table 16654 16655The following built-in functions are changed to generate new SSE4.2 16656instructions when @option{-msse4.2} is used. 16657 16658@table @code 16659@item int __builtin_popcount (unsigned int) 16660Generates the @code{popcntl} machine instruction. 16661@item int __builtin_popcountl (unsigned long) 16662Generates the @code{popcntl} or @code{popcntq} machine instruction, 16663depending on the size of @code{unsigned long}. 16664@item int __builtin_popcountll (unsigned long long) 16665Generates the @code{popcntq} machine instruction. 16666@end table 16667 16668The following built-in functions are available when @option{-mavx} is 16669used. All of them generate the machine instruction that is part of the 16670name. 16671 16672@smallexample 16673v4df __builtin_ia32_addpd256 (v4df,v4df) 16674v8sf __builtin_ia32_addps256 (v8sf,v8sf) 16675v4df __builtin_ia32_addsubpd256 (v4df,v4df) 16676v8sf __builtin_ia32_addsubps256 (v8sf,v8sf) 16677v4df __builtin_ia32_andnpd256 (v4df,v4df) 16678v8sf __builtin_ia32_andnps256 (v8sf,v8sf) 16679v4df __builtin_ia32_andpd256 (v4df,v4df) 16680v8sf __builtin_ia32_andps256 (v8sf,v8sf) 16681v4df __builtin_ia32_blendpd256 (v4df,v4df,int) 16682v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int) 16683v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df) 16684v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf) 16685v2df __builtin_ia32_cmppd (v2df,v2df,int) 16686v4df __builtin_ia32_cmppd256 (v4df,v4df,int) 16687v4sf __builtin_ia32_cmpps (v4sf,v4sf,int) 16688v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int) 16689v2df __builtin_ia32_cmpsd (v2df,v2df,int) 16690v4sf __builtin_ia32_cmpss (v4sf,v4sf,int) 16691v4df __builtin_ia32_cvtdq2pd256 (v4si) 16692v8sf __builtin_ia32_cvtdq2ps256 (v8si) 16693v4si __builtin_ia32_cvtpd2dq256 (v4df) 16694v4sf __builtin_ia32_cvtpd2ps256 (v4df) 16695v8si __builtin_ia32_cvtps2dq256 (v8sf) 16696v4df __builtin_ia32_cvtps2pd256 (v4sf) 16697v4si __builtin_ia32_cvttpd2dq256 (v4df) 16698v8si __builtin_ia32_cvttps2dq256 (v8sf) 16699v4df __builtin_ia32_divpd256 (v4df,v4df) 16700v8sf __builtin_ia32_divps256 (v8sf,v8sf) 16701v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int) 16702v4df __builtin_ia32_haddpd256 (v4df,v4df) 16703v8sf __builtin_ia32_haddps256 (v8sf,v8sf) 16704v4df __builtin_ia32_hsubpd256 (v4df,v4df) 16705v8sf __builtin_ia32_hsubps256 (v8sf,v8sf) 16706v32qi __builtin_ia32_lddqu256 (pcchar) 16707v32qi __builtin_ia32_loaddqu256 (pcchar) 16708v4df __builtin_ia32_loadupd256 (pcdouble) 16709v8sf __builtin_ia32_loadups256 (pcfloat) 16710v2df __builtin_ia32_maskloadpd (pcv2df,v2df) 16711v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df) 16712v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf) 16713v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf) 16714void __builtin_ia32_maskstorepd (pv2df,v2df,v2df) 16715void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df) 16716void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf) 16717void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf) 16718v4df __builtin_ia32_maxpd256 (v4df,v4df) 16719v8sf __builtin_ia32_maxps256 (v8sf,v8sf) 16720v4df __builtin_ia32_minpd256 (v4df,v4df) 16721v8sf __builtin_ia32_minps256 (v8sf,v8sf) 16722v4df __builtin_ia32_movddup256 (v4df) 16723int __builtin_ia32_movmskpd256 (v4df) 16724int __builtin_ia32_movmskps256 (v8sf) 16725v8sf __builtin_ia32_movshdup256 (v8sf) 16726v8sf __builtin_ia32_movsldup256 (v8sf) 16727v4df __builtin_ia32_mulpd256 (v4df,v4df) 16728v8sf __builtin_ia32_mulps256 (v8sf,v8sf) 16729v4df __builtin_ia32_orpd256 (v4df,v4df) 16730v8sf __builtin_ia32_orps256 (v8sf,v8sf) 16731v2df __builtin_ia32_pd_pd256 (v4df) 16732v4df __builtin_ia32_pd256_pd (v2df) 16733v4sf __builtin_ia32_ps_ps256 (v8sf) 16734v8sf __builtin_ia32_ps256_ps (v4sf) 16735int __builtin_ia32_ptestc256 (v4di,v4di,ptest) 16736int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest) 16737int __builtin_ia32_ptestz256 (v4di,v4di,ptest) 16738v8sf __builtin_ia32_rcpps256 (v8sf) 16739v4df __builtin_ia32_roundpd256 (v4df,int) 16740v8sf __builtin_ia32_roundps256 (v8sf,int) 16741v8sf __builtin_ia32_rsqrtps_nr256 (v8sf) 16742v8sf __builtin_ia32_rsqrtps256 (v8sf) 16743v4df __builtin_ia32_shufpd256 (v4df,v4df,int) 16744v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int) 16745v4si __builtin_ia32_si_si256 (v8si) 16746v8si __builtin_ia32_si256_si (v4si) 16747v4df __builtin_ia32_sqrtpd256 (v4df) 16748v8sf __builtin_ia32_sqrtps_nr256 (v8sf) 16749v8sf __builtin_ia32_sqrtps256 (v8sf) 16750void __builtin_ia32_storedqu256 (pchar,v32qi) 16751void __builtin_ia32_storeupd256 (pdouble,v4df) 16752void __builtin_ia32_storeups256 (pfloat,v8sf) 16753v4df __builtin_ia32_subpd256 (v4df,v4df) 16754v8sf __builtin_ia32_subps256 (v8sf,v8sf) 16755v4df __builtin_ia32_unpckhpd256 (v4df,v4df) 16756v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf) 16757v4df __builtin_ia32_unpcklpd256 (v4df,v4df) 16758v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf) 16759v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df) 16760v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf) 16761v4df __builtin_ia32_vbroadcastsd256 (pcdouble) 16762v4sf __builtin_ia32_vbroadcastss (pcfloat) 16763v8sf __builtin_ia32_vbroadcastss256 (pcfloat) 16764v2df __builtin_ia32_vextractf128_pd256 (v4df,int) 16765v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int) 16766v4si __builtin_ia32_vextractf128_si256 (v8si,int) 16767v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int) 16768v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int) 16769v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int) 16770v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int) 16771v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int) 16772v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int) 16773v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int) 16774v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int) 16775v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int) 16776v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int) 16777v2df __builtin_ia32_vpermilpd (v2df,int) 16778v4df __builtin_ia32_vpermilpd256 (v4df,int) 16779v4sf __builtin_ia32_vpermilps (v4sf,int) 16780v8sf __builtin_ia32_vpermilps256 (v8sf,int) 16781v2df __builtin_ia32_vpermilvarpd (v2df,v2di) 16782v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di) 16783v4sf __builtin_ia32_vpermilvarps (v4sf,v4si) 16784v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si) 16785int __builtin_ia32_vtestcpd (v2df,v2df,ptest) 16786int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest) 16787int __builtin_ia32_vtestcps (v4sf,v4sf,ptest) 16788int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest) 16789int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest) 16790int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest) 16791int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest) 16792int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest) 16793int __builtin_ia32_vtestzpd (v2df,v2df,ptest) 16794int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest) 16795int __builtin_ia32_vtestzps (v4sf,v4sf,ptest) 16796int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest) 16797void __builtin_ia32_vzeroall (void) 16798void __builtin_ia32_vzeroupper (void) 16799v4df __builtin_ia32_xorpd256 (v4df,v4df) 16800v8sf __builtin_ia32_xorps256 (v8sf,v8sf) 16801@end smallexample 16802 16803The following built-in functions are available when @option{-mavx2} is 16804used. All of them generate the machine instruction that is part of the 16805name. 16806 16807@smallexample 16808v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int) 16809v32qi __builtin_ia32_pabsb256 (v32qi) 16810v16hi __builtin_ia32_pabsw256 (v16hi) 16811v8si __builtin_ia32_pabsd256 (v8si) 16812v16hi __builtin_ia32_packssdw256 (v8si,v8si) 16813v32qi __builtin_ia32_packsswb256 (v16hi,v16hi) 16814v16hi __builtin_ia32_packusdw256 (v8si,v8si) 16815v32qi __builtin_ia32_packuswb256 (v16hi,v16hi) 16816v32qi __builtin_ia32_paddb256 (v32qi,v32qi) 16817v16hi __builtin_ia32_paddw256 (v16hi,v16hi) 16818v8si __builtin_ia32_paddd256 (v8si,v8si) 16819v4di __builtin_ia32_paddq256 (v4di,v4di) 16820v32qi __builtin_ia32_paddsb256 (v32qi,v32qi) 16821v16hi __builtin_ia32_paddsw256 (v16hi,v16hi) 16822v32qi __builtin_ia32_paddusb256 (v32qi,v32qi) 16823v16hi __builtin_ia32_paddusw256 (v16hi,v16hi) 16824v4di __builtin_ia32_palignr256 (v4di,v4di,int) 16825v4di __builtin_ia32_andsi256 (v4di,v4di) 16826v4di __builtin_ia32_andnotsi256 (v4di,v4di) 16827v32qi __builtin_ia32_pavgb256 (v32qi,v32qi) 16828v16hi __builtin_ia32_pavgw256 (v16hi,v16hi) 16829v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi) 16830v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int) 16831v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi) 16832v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi) 16833v8si __builtin_ia32_pcmpeqd256 (c8si,v8si) 16834v4di __builtin_ia32_pcmpeqq256 (v4di,v4di) 16835v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi) 16836v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi) 16837v8si __builtin_ia32_pcmpgtd256 (v8si,v8si) 16838v4di __builtin_ia32_pcmpgtq256 (v4di,v4di) 16839v16hi __builtin_ia32_phaddw256 (v16hi,v16hi) 16840v8si __builtin_ia32_phaddd256 (v8si,v8si) 16841v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi) 16842v16hi __builtin_ia32_phsubw256 (v16hi,v16hi) 16843v8si __builtin_ia32_phsubd256 (v8si,v8si) 16844v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi) 16845v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi) 16846v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi) 16847v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi) 16848v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi) 16849v8si __builtin_ia32_pmaxsd256 (v8si,v8si) 16850v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi) 16851v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi) 16852v8si __builtin_ia32_pmaxud256 (v8si,v8si) 16853v32qi __builtin_ia32_pminsb256 (v32qi,v32qi) 16854v16hi __builtin_ia32_pminsw256 (v16hi,v16hi) 16855v8si __builtin_ia32_pminsd256 (v8si,v8si) 16856v32qi __builtin_ia32_pminub256 (v32qi,v32qi) 16857v16hi __builtin_ia32_pminuw256 (v16hi,v16hi) 16858v8si __builtin_ia32_pminud256 (v8si,v8si) 16859int __builtin_ia32_pmovmskb256 (v32qi) 16860v16hi __builtin_ia32_pmovsxbw256 (v16qi) 16861v8si __builtin_ia32_pmovsxbd256 (v16qi) 16862v4di __builtin_ia32_pmovsxbq256 (v16qi) 16863v8si __builtin_ia32_pmovsxwd256 (v8hi) 16864v4di __builtin_ia32_pmovsxwq256 (v8hi) 16865v4di __builtin_ia32_pmovsxdq256 (v4si) 16866v16hi __builtin_ia32_pmovzxbw256 (v16qi) 16867v8si __builtin_ia32_pmovzxbd256 (v16qi) 16868v4di __builtin_ia32_pmovzxbq256 (v16qi) 16869v8si __builtin_ia32_pmovzxwd256 (v8hi) 16870v4di __builtin_ia32_pmovzxwq256 (v8hi) 16871v4di __builtin_ia32_pmovzxdq256 (v4si) 16872v4di __builtin_ia32_pmuldq256 (v8si,v8si) 16873v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi) 16874v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi) 16875v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi) 16876v16hi __builtin_ia32_pmullw256 (v16hi,v16hi) 16877v8si __builtin_ia32_pmulld256 (v8si,v8si) 16878v4di __builtin_ia32_pmuludq256 (v8si,v8si) 16879v4di __builtin_ia32_por256 (v4di,v4di) 16880v16hi __builtin_ia32_psadbw256 (v32qi,v32qi) 16881v32qi __builtin_ia32_pshufb256 (v32qi,v32qi) 16882v8si __builtin_ia32_pshufd256 (v8si,int) 16883v16hi __builtin_ia32_pshufhw256 (v16hi,int) 16884v16hi __builtin_ia32_pshuflw256 (v16hi,int) 16885v32qi __builtin_ia32_psignb256 (v32qi,v32qi) 16886v16hi __builtin_ia32_psignw256 (v16hi,v16hi) 16887v8si __builtin_ia32_psignd256 (v8si,v8si) 16888v4di __builtin_ia32_pslldqi256 (v4di,int) 16889v16hi __builtin_ia32_psllwi256 (16hi,int) 16890v16hi __builtin_ia32_psllw256(v16hi,v8hi) 16891v8si __builtin_ia32_pslldi256 (v8si,int) 16892v8si __builtin_ia32_pslld256(v8si,v4si) 16893v4di __builtin_ia32_psllqi256 (v4di,int) 16894v4di __builtin_ia32_psllq256(v4di,v2di) 16895v16hi __builtin_ia32_psrawi256 (v16hi,int) 16896v16hi __builtin_ia32_psraw256 (v16hi,v8hi) 16897v8si __builtin_ia32_psradi256 (v8si,int) 16898v8si __builtin_ia32_psrad256 (v8si,v4si) 16899v4di __builtin_ia32_psrldqi256 (v4di, int) 16900v16hi __builtin_ia32_psrlwi256 (v16hi,int) 16901v16hi __builtin_ia32_psrlw256 (v16hi,v8hi) 16902v8si __builtin_ia32_psrldi256 (v8si,int) 16903v8si __builtin_ia32_psrld256 (v8si,v4si) 16904v4di __builtin_ia32_psrlqi256 (v4di,int) 16905v4di __builtin_ia32_psrlq256(v4di,v2di) 16906v32qi __builtin_ia32_psubb256 (v32qi,v32qi) 16907v32hi __builtin_ia32_psubw256 (v16hi,v16hi) 16908v8si __builtin_ia32_psubd256 (v8si,v8si) 16909v4di __builtin_ia32_psubq256 (v4di,v4di) 16910v32qi __builtin_ia32_psubsb256 (v32qi,v32qi) 16911v16hi __builtin_ia32_psubsw256 (v16hi,v16hi) 16912v32qi __builtin_ia32_psubusb256 (v32qi,v32qi) 16913v16hi __builtin_ia32_psubusw256 (v16hi,v16hi) 16914v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi) 16915v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi) 16916v8si __builtin_ia32_punpckhdq256 (v8si,v8si) 16917v4di __builtin_ia32_punpckhqdq256 (v4di,v4di) 16918v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi) 16919v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi) 16920v8si __builtin_ia32_punpckldq256 (v8si,v8si) 16921v4di __builtin_ia32_punpcklqdq256 (v4di,v4di) 16922v4di __builtin_ia32_pxor256 (v4di,v4di) 16923v4di __builtin_ia32_movntdqa256 (pv4di) 16924v4sf __builtin_ia32_vbroadcastss_ps (v4sf) 16925v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf) 16926v4df __builtin_ia32_vbroadcastsd_pd256 (v2df) 16927v4di __builtin_ia32_vbroadcastsi256 (v2di) 16928v4si __builtin_ia32_pblendd128 (v4si,v4si) 16929v8si __builtin_ia32_pblendd256 (v8si,v8si) 16930v32qi __builtin_ia32_pbroadcastb256 (v16qi) 16931v16hi __builtin_ia32_pbroadcastw256 (v8hi) 16932v8si __builtin_ia32_pbroadcastd256 (v4si) 16933v4di __builtin_ia32_pbroadcastq256 (v2di) 16934v16qi __builtin_ia32_pbroadcastb128 (v16qi) 16935v8hi __builtin_ia32_pbroadcastw128 (v8hi) 16936v4si __builtin_ia32_pbroadcastd128 (v4si) 16937v2di __builtin_ia32_pbroadcastq128 (v2di) 16938v8si __builtin_ia32_permvarsi256 (v8si,v8si) 16939v4df __builtin_ia32_permdf256 (v4df,int) 16940v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf) 16941v4di __builtin_ia32_permdi256 (v4di,int) 16942v4di __builtin_ia32_permti256 (v4di,v4di,int) 16943v4di __builtin_ia32_extract128i256 (v4di,int) 16944v4di __builtin_ia32_insert128i256 (v4di,v2di,int) 16945v8si __builtin_ia32_maskloadd256 (pcv8si,v8si) 16946v4di __builtin_ia32_maskloadq256 (pcv4di,v4di) 16947v4si __builtin_ia32_maskloadd (pcv4si,v4si) 16948v2di __builtin_ia32_maskloadq (pcv2di,v2di) 16949void __builtin_ia32_maskstored256 (pv8si,v8si,v8si) 16950void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di) 16951void __builtin_ia32_maskstored (pv4si,v4si,v4si) 16952void __builtin_ia32_maskstoreq (pv2di,v2di,v2di) 16953v8si __builtin_ia32_psllv8si (v8si,v8si) 16954v4si __builtin_ia32_psllv4si (v4si,v4si) 16955v4di __builtin_ia32_psllv4di (v4di,v4di) 16956v2di __builtin_ia32_psllv2di (v2di,v2di) 16957v8si __builtin_ia32_psrav8si (v8si,v8si) 16958v4si __builtin_ia32_psrav4si (v4si,v4si) 16959v8si __builtin_ia32_psrlv8si (v8si,v8si) 16960v4si __builtin_ia32_psrlv4si (v4si,v4si) 16961v4di __builtin_ia32_psrlv4di (v4di,v4di) 16962v2di __builtin_ia32_psrlv2di (v2di,v2di) 16963v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int) 16964v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int) 16965v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int) 16966v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int) 16967v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int) 16968v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int) 16969v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int) 16970v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int) 16971v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int) 16972v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int) 16973v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int) 16974v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int) 16975v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int) 16976v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int) 16977v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int) 16978v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int) 16979@end smallexample 16980 16981The following built-in functions are available when @option{-maes} is 16982used. All of them generate the machine instruction that is part of the 16983name. 16984 16985@smallexample 16986v2di __builtin_ia32_aesenc128 (v2di, v2di) 16987v2di __builtin_ia32_aesenclast128 (v2di, v2di) 16988v2di __builtin_ia32_aesdec128 (v2di, v2di) 16989v2di __builtin_ia32_aesdeclast128 (v2di, v2di) 16990v2di __builtin_ia32_aeskeygenassist128 (v2di, const int) 16991v2di __builtin_ia32_aesimc128 (v2di) 16992@end smallexample 16993 16994The following built-in function is available when @option{-mpclmul} is 16995used. 16996 16997@table @code 16998@item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int) 16999Generates the @code{pclmulqdq} machine instruction. 17000@end table 17001 17002The following built-in function is available when @option{-mfsgsbase} is 17003used. All of them generate the machine instruction that is part of the 17004name. 17005 17006@smallexample 17007unsigned int __builtin_ia32_rdfsbase32 (void) 17008unsigned long long __builtin_ia32_rdfsbase64 (void) 17009unsigned int __builtin_ia32_rdgsbase32 (void) 17010unsigned long long __builtin_ia32_rdgsbase64 (void) 17011void _writefsbase_u32 (unsigned int) 17012void _writefsbase_u64 (unsigned long long) 17013void _writegsbase_u32 (unsigned int) 17014void _writegsbase_u64 (unsigned long long) 17015@end smallexample 17016 17017The following built-in function is available when @option{-mrdrnd} is 17018used. All of them generate the machine instruction that is part of the 17019name. 17020 17021@smallexample 17022unsigned int __builtin_ia32_rdrand16_step (unsigned short *) 17023unsigned int __builtin_ia32_rdrand32_step (unsigned int *) 17024unsigned int __builtin_ia32_rdrand64_step (unsigned long long *) 17025@end smallexample 17026 17027The following built-in functions are available when @option{-msse4a} is used. 17028All of them generate the machine instruction that is part of the name. 17029 17030@smallexample 17031void __builtin_ia32_movntsd (double *, v2df) 17032void __builtin_ia32_movntss (float *, v4sf) 17033v2di __builtin_ia32_extrq (v2di, v16qi) 17034v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int) 17035v2di __builtin_ia32_insertq (v2di, v2di) 17036v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int) 17037@end smallexample 17038 17039The following built-in functions are available when @option{-mxop} is used. 17040@smallexample 17041v2df __builtin_ia32_vfrczpd (v2df) 17042v4sf __builtin_ia32_vfrczps (v4sf) 17043v2df __builtin_ia32_vfrczsd (v2df) 17044v4sf __builtin_ia32_vfrczss (v4sf) 17045v4df __builtin_ia32_vfrczpd256 (v4df) 17046v8sf __builtin_ia32_vfrczps256 (v8sf) 17047v2di __builtin_ia32_vpcmov (v2di, v2di, v2di) 17048v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di) 17049v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si) 17050v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi) 17051v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi) 17052v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df) 17053v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf) 17054v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di) 17055v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si) 17056v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi) 17057v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi) 17058v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df) 17059v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf) 17060v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi) 17061v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi) 17062v4si __builtin_ia32_vpcomeqd (v4si, v4si) 17063v2di __builtin_ia32_vpcomeqq (v2di, v2di) 17064v16qi __builtin_ia32_vpcomequb (v16qi, v16qi) 17065v4si __builtin_ia32_vpcomequd (v4si, v4si) 17066v2di __builtin_ia32_vpcomequq (v2di, v2di) 17067v8hi __builtin_ia32_vpcomequw (v8hi, v8hi) 17068v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi) 17069v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi) 17070v4si __builtin_ia32_vpcomfalsed (v4si, v4si) 17071v2di __builtin_ia32_vpcomfalseq (v2di, v2di) 17072v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi) 17073v4si __builtin_ia32_vpcomfalseud (v4si, v4si) 17074v2di __builtin_ia32_vpcomfalseuq (v2di, v2di) 17075v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi) 17076v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi) 17077v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi) 17078v4si __builtin_ia32_vpcomged (v4si, v4si) 17079v2di __builtin_ia32_vpcomgeq (v2di, v2di) 17080v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi) 17081v4si __builtin_ia32_vpcomgeud (v4si, v4si) 17082v2di __builtin_ia32_vpcomgeuq (v2di, v2di) 17083v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi) 17084v8hi __builtin_ia32_vpcomgew (v8hi, v8hi) 17085v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi) 17086v4si __builtin_ia32_vpcomgtd (v4si, v4si) 17087v2di __builtin_ia32_vpcomgtq (v2di, v2di) 17088v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi) 17089v4si __builtin_ia32_vpcomgtud (v4si, v4si) 17090v2di __builtin_ia32_vpcomgtuq (v2di, v2di) 17091v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi) 17092v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi) 17093v16qi __builtin_ia32_vpcomleb (v16qi, v16qi) 17094v4si __builtin_ia32_vpcomled (v4si, v4si) 17095v2di __builtin_ia32_vpcomleq (v2di, v2di) 17096v16qi __builtin_ia32_vpcomleub (v16qi, v16qi) 17097v4si __builtin_ia32_vpcomleud (v4si, v4si) 17098v2di __builtin_ia32_vpcomleuq (v2di, v2di) 17099v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi) 17100v8hi __builtin_ia32_vpcomlew (v8hi, v8hi) 17101v16qi __builtin_ia32_vpcomltb (v16qi, v16qi) 17102v4si __builtin_ia32_vpcomltd (v4si, v4si) 17103v2di __builtin_ia32_vpcomltq (v2di, v2di) 17104v16qi __builtin_ia32_vpcomltub (v16qi, v16qi) 17105v4si __builtin_ia32_vpcomltud (v4si, v4si) 17106v2di __builtin_ia32_vpcomltuq (v2di, v2di) 17107v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi) 17108v8hi __builtin_ia32_vpcomltw (v8hi, v8hi) 17109v16qi __builtin_ia32_vpcomneb (v16qi, v16qi) 17110v4si __builtin_ia32_vpcomned (v4si, v4si) 17111v2di __builtin_ia32_vpcomneq (v2di, v2di) 17112v16qi __builtin_ia32_vpcomneub (v16qi, v16qi) 17113v4si __builtin_ia32_vpcomneud (v4si, v4si) 17114v2di __builtin_ia32_vpcomneuq (v2di, v2di) 17115v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi) 17116v8hi __builtin_ia32_vpcomnew (v8hi, v8hi) 17117v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi) 17118v4si __builtin_ia32_vpcomtrued (v4si, v4si) 17119v2di __builtin_ia32_vpcomtrueq (v2di, v2di) 17120v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi) 17121v4si __builtin_ia32_vpcomtrueud (v4si, v4si) 17122v2di __builtin_ia32_vpcomtrueuq (v2di, v2di) 17123v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi) 17124v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi) 17125v4si __builtin_ia32_vphaddbd (v16qi) 17126v2di __builtin_ia32_vphaddbq (v16qi) 17127v8hi __builtin_ia32_vphaddbw (v16qi) 17128v2di __builtin_ia32_vphadddq (v4si) 17129v4si __builtin_ia32_vphaddubd (v16qi) 17130v2di __builtin_ia32_vphaddubq (v16qi) 17131v8hi __builtin_ia32_vphaddubw (v16qi) 17132v2di __builtin_ia32_vphaddudq (v4si) 17133v4si __builtin_ia32_vphadduwd (v8hi) 17134v2di __builtin_ia32_vphadduwq (v8hi) 17135v4si __builtin_ia32_vphaddwd (v8hi) 17136v2di __builtin_ia32_vphaddwq (v8hi) 17137v8hi __builtin_ia32_vphsubbw (v16qi) 17138v2di __builtin_ia32_vphsubdq (v4si) 17139v4si __builtin_ia32_vphsubwd (v8hi) 17140v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si) 17141v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di) 17142v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di) 17143v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si) 17144v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di) 17145v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di) 17146v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si) 17147v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi) 17148v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si) 17149v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi) 17150v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si) 17151v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si) 17152v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi) 17153v16qi __builtin_ia32_vprotb (v16qi, v16qi) 17154v4si __builtin_ia32_vprotd (v4si, v4si) 17155v2di __builtin_ia32_vprotq (v2di, v2di) 17156v8hi __builtin_ia32_vprotw (v8hi, v8hi) 17157v16qi __builtin_ia32_vpshab (v16qi, v16qi) 17158v4si __builtin_ia32_vpshad (v4si, v4si) 17159v2di __builtin_ia32_vpshaq (v2di, v2di) 17160v8hi __builtin_ia32_vpshaw (v8hi, v8hi) 17161v16qi __builtin_ia32_vpshlb (v16qi, v16qi) 17162v4si __builtin_ia32_vpshld (v4si, v4si) 17163v2di __builtin_ia32_vpshlq (v2di, v2di) 17164v8hi __builtin_ia32_vpshlw (v8hi, v8hi) 17165@end smallexample 17166 17167The following built-in functions are available when @option{-mfma4} is used. 17168All of them generate the machine instruction that is part of the name. 17169 17170@smallexample 17171v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df) 17172v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf) 17173v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df) 17174v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf) 17175v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df) 17176v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf) 17177v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df) 17178v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf) 17179v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df) 17180v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf) 17181v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df) 17182v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf) 17183v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df) 17184v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf) 17185v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df) 17186v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf) 17187v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df) 17188v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf) 17189v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df) 17190v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf) 17191v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df) 17192v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf) 17193v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df) 17194v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf) 17195v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df) 17196v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf) 17197v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df) 17198v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf) 17199v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df) 17200v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf) 17201v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df) 17202v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf) 17203 17204@end smallexample 17205 17206The following built-in functions are available when @option{-mlwp} is used. 17207 17208@smallexample 17209void __builtin_ia32_llwpcb16 (void *); 17210void __builtin_ia32_llwpcb32 (void *); 17211void __builtin_ia32_llwpcb64 (void *); 17212void * __builtin_ia32_llwpcb16 (void); 17213void * __builtin_ia32_llwpcb32 (void); 17214void * __builtin_ia32_llwpcb64 (void); 17215void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short) 17216void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int) 17217void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int) 17218unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short) 17219unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int) 17220unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int) 17221@end smallexample 17222 17223The following built-in functions are available when @option{-mbmi} is used. 17224All of them generate the machine instruction that is part of the name. 17225@smallexample 17226unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int); 17227unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long); 17228@end smallexample 17229 17230The following built-in functions are available when @option{-mbmi2} is used. 17231All of them generate the machine instruction that is part of the name. 17232@smallexample 17233unsigned int _bzhi_u32 (unsigned int, unsigned int) 17234unsigned int _pdep_u32 (unsigned int, unsigned int) 17235unsigned int _pext_u32 (unsigned int, unsigned int) 17236unsigned long long _bzhi_u64 (unsigned long long, unsigned long long) 17237unsigned long long _pdep_u64 (unsigned long long, unsigned long long) 17238unsigned long long _pext_u64 (unsigned long long, unsigned long long) 17239@end smallexample 17240 17241The following built-in functions are available when @option{-mlzcnt} is used. 17242All of them generate the machine instruction that is part of the name. 17243@smallexample 17244unsigned short __builtin_ia32_lzcnt_u16(unsigned short); 17245unsigned int __builtin_ia32_lzcnt_u32(unsigned int); 17246unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long); 17247@end smallexample 17248 17249The following built-in functions are available when @option{-mfxsr} is used. 17250All of them generate the machine instruction that is part of the name. 17251@smallexample 17252void __builtin_ia32_fxsave (void *) 17253void __builtin_ia32_fxrstor (void *) 17254void __builtin_ia32_fxsave64 (void *) 17255void __builtin_ia32_fxrstor64 (void *) 17256@end smallexample 17257 17258The following built-in functions are available when @option{-mxsave} is used. 17259All of them generate the machine instruction that is part of the name. 17260@smallexample 17261void __builtin_ia32_xsave (void *, long long) 17262void __builtin_ia32_xrstor (void *, long long) 17263void __builtin_ia32_xsave64 (void *, long long) 17264void __builtin_ia32_xrstor64 (void *, long long) 17265@end smallexample 17266 17267The following built-in functions are available when @option{-mxsaveopt} is used. 17268All of them generate the machine instruction that is part of the name. 17269@smallexample 17270void __builtin_ia32_xsaveopt (void *, long long) 17271void __builtin_ia32_xsaveopt64 (void *, long long) 17272@end smallexample 17273 17274The following built-in functions are available when @option{-mtbm} is used. 17275Both of them generate the immediate form of the bextr machine instruction. 17276@smallexample 17277unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int); 17278unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long); 17279@end smallexample 17280 17281 17282The following built-in functions are available when @option{-m3dnow} is used. 17283All of them generate the machine instruction that is part of the name. 17284 17285@smallexample 17286void __builtin_ia32_femms (void) 17287v8qi __builtin_ia32_pavgusb (v8qi, v8qi) 17288v2si __builtin_ia32_pf2id (v2sf) 17289v2sf __builtin_ia32_pfacc (v2sf, v2sf) 17290v2sf __builtin_ia32_pfadd (v2sf, v2sf) 17291v2si __builtin_ia32_pfcmpeq (v2sf, v2sf) 17292v2si __builtin_ia32_pfcmpge (v2sf, v2sf) 17293v2si __builtin_ia32_pfcmpgt (v2sf, v2sf) 17294v2sf __builtin_ia32_pfmax (v2sf, v2sf) 17295v2sf __builtin_ia32_pfmin (v2sf, v2sf) 17296v2sf __builtin_ia32_pfmul (v2sf, v2sf) 17297v2sf __builtin_ia32_pfrcp (v2sf) 17298v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf) 17299v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf) 17300v2sf __builtin_ia32_pfrsqrt (v2sf) 17301v2sf __builtin_ia32_pfsub (v2sf, v2sf) 17302v2sf __builtin_ia32_pfsubr (v2sf, v2sf) 17303v2sf __builtin_ia32_pi2fd (v2si) 17304v4hi __builtin_ia32_pmulhrw (v4hi, v4hi) 17305@end smallexample 17306 17307The following built-in functions are available when both @option{-m3dnow} 17308and @option{-march=athlon} are used. All of them generate the machine 17309instruction that is part of the name. 17310 17311@smallexample 17312v2si __builtin_ia32_pf2iw (v2sf) 17313v2sf __builtin_ia32_pfnacc (v2sf, v2sf) 17314v2sf __builtin_ia32_pfpnacc (v2sf, v2sf) 17315v2sf __builtin_ia32_pi2fw (v2si) 17316v2sf __builtin_ia32_pswapdsf (v2sf) 17317v2si __builtin_ia32_pswapdsi (v2si) 17318@end smallexample 17319 17320The following built-in functions are available when @option{-mrtm} is used 17321They are used for restricted transactional memory. These are the internal 17322low level functions. Normally the functions in 17323@ref{x86 transactional memory intrinsics} should be used instead. 17324 17325@smallexample 17326int __builtin_ia32_xbegin () 17327void __builtin_ia32_xend () 17328void __builtin_ia32_xabort (status) 17329int __builtin_ia32_xtest () 17330@end smallexample 17331 17332The following built-in functions are available when @option{-mmwaitx} is used. 17333All of them generate the machine instruction that is part of the name. 17334@smallexample 17335void __builtin_ia32_monitorx (void *, unsigned int, unsigned int) 17336void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int) 17337@end smallexample 17338 17339@node x86 transactional memory intrinsics 17340@subsection x86 Transactional Memory Intrinsics 17341 17342These hardware transactional memory intrinsics for x86 allow you to use 17343memory transactions with RTM (Restricted Transactional Memory). 17344This support is enabled with the @option{-mrtm} option. 17345For using HLE (Hardware Lock Elision) see 17346@ref{x86 specific memory model extensions for transactional memory} instead. 17347 17348A memory transaction commits all changes to memory in an atomic way, 17349as visible to other threads. If the transaction fails it is rolled back 17350and all side effects discarded. 17351 17352Generally there is no guarantee that a memory transaction ever succeeds 17353and suitable fallback code always needs to be supplied. 17354 17355@deftypefn {RTM Function} {unsigned} _xbegin () 17356Start a RTM (Restricted Transactional Memory) transaction. 17357Returns @code{_XBEGIN_STARTED} when the transaction 17358started successfully (note this is not 0, so the constant has to be 17359explicitly tested). 17360 17361If the transaction aborts, all side-effects 17362are undone and an abort code encoded as a bit mask is returned. 17363The following macros are defined: 17364 17365@table @code 17366@item _XABORT_EXPLICIT 17367Transaction was explicitly aborted with @code{_xabort}. The parameter passed 17368to @code{_xabort} is available with @code{_XABORT_CODE(status)}. 17369@item _XABORT_RETRY 17370Transaction retry is possible. 17371@item _XABORT_CONFLICT 17372Transaction abort due to a memory conflict with another thread. 17373@item _XABORT_CAPACITY 17374Transaction abort due to the transaction using too much memory. 17375@item _XABORT_DEBUG 17376Transaction abort due to a debug trap. 17377@item _XABORT_NESTED 17378Transaction abort in an inner nested transaction. 17379@end table 17380 17381There is no guarantee 17382any transaction ever succeeds, so there always needs to be a valid 17383fallback path. 17384@end deftypefn 17385 17386@deftypefn {RTM Function} {void} _xend () 17387Commit the current transaction. When no transaction is active this faults. 17388All memory side-effects of the transaction become visible 17389to other threads in an atomic manner. 17390@end deftypefn 17391 17392@deftypefn {RTM Function} {int} _xtest () 17393Return a nonzero value if a transaction is currently active, otherwise 0. 17394@end deftypefn 17395 17396@deftypefn {RTM Function} {void} _xabort (status) 17397Abort the current transaction. When no transaction is active this is a no-op. 17398The @var{status} is an 8-bit constant; its value is encoded in the return 17399value from @code{_xbegin}. 17400@end deftypefn 17401 17402Here is an example showing handling for @code{_XABORT_RETRY} 17403and a fallback path for other failures: 17404 17405@smallexample 17406#include <immintrin.h> 17407 17408int n_tries, max_tries; 17409unsigned status = _XABORT_EXPLICIT; 17410... 17411 17412for (n_tries = 0; n_tries < max_tries; n_tries++) 17413 @{ 17414 status = _xbegin (); 17415 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY)) 17416 break; 17417 @} 17418if (status == _XBEGIN_STARTED) 17419 @{ 17420 ... transaction code... 17421 _xend (); 17422 @} 17423else 17424 @{ 17425 ... non-transactional fallback path... 17426 @} 17427@end smallexample 17428 17429@noindent 17430Note that, in most cases, the transactional and non-transactional code 17431must synchronize together to ensure consistency. 17432 17433@node Target Format Checks 17434@section Format Checks Specific to Particular Target Machines 17435 17436For some target machines, GCC supports additional options to the 17437format attribute 17438(@pxref{Function Attributes,,Declaring Attributes of Functions}). 17439 17440@menu 17441* Solaris Format Checks:: 17442* Darwin Format Checks:: 17443@end menu 17444 17445@node Solaris Format Checks 17446@subsection Solaris Format Checks 17447 17448Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format 17449check. @code{cmn_err} accepts a subset of the standard @code{printf} 17450conversions, and the two-argument @code{%b} conversion for displaying 17451bit-fields. See the Solaris man page for @code{cmn_err} for more information. 17452 17453@node Darwin Format Checks 17454@subsection Darwin Format Checks 17455 17456Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format 17457attribute context. Declarations made with such attribution are parsed for correct syntax 17458and format argument types. However, parsing of the format string itself is currently undefined 17459and is not carried out by this version of the compiler. 17460 17461Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may 17462also be used as format arguments. Note that the relevant headers are only likely to be 17463available on Darwin (OSX) installations. On such installations, the XCode and system 17464documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and 17465associated functions. 17466 17467@node Pragmas 17468@section Pragmas Accepted by GCC 17469@cindex pragmas 17470@cindex @code{#pragma} 17471 17472GCC supports several types of pragmas, primarily in order to compile 17473code originally written for other compilers. Note that in general 17474we do not recommend the use of pragmas; @xref{Function Attributes}, 17475for further explanation. 17476 17477@menu 17478* ARM Pragmas:: 17479* M32C Pragmas:: 17480* MeP Pragmas:: 17481* RS/6000 and PowerPC Pragmas:: 17482* Darwin Pragmas:: 17483* Solaris Pragmas:: 17484* Symbol-Renaming Pragmas:: 17485* Structure-Packing Pragmas:: 17486* Weak Pragmas:: 17487* Diagnostic Pragmas:: 17488* Visibility Pragmas:: 17489* Push/Pop Macro Pragmas:: 17490* Function Specific Option Pragmas:: 17491* Loop-Specific Pragmas:: 17492@end menu 17493 17494@node ARM Pragmas 17495@subsection ARM Pragmas 17496 17497The ARM target defines pragmas for controlling the default addition of 17498@code{long_call} and @code{short_call} attributes to functions. 17499@xref{Function Attributes}, for information about the effects of these 17500attributes. 17501 17502@table @code 17503@item long_calls 17504@cindex pragma, long_calls 17505Set all subsequent functions to have the @code{long_call} attribute. 17506 17507@item no_long_calls 17508@cindex pragma, no_long_calls 17509Set all subsequent functions to have the @code{short_call} attribute. 17510 17511@item long_calls_off 17512@cindex pragma, long_calls_off 17513Do not affect the @code{long_call} or @code{short_call} attributes of 17514subsequent functions. 17515@end table 17516 17517@node M32C Pragmas 17518@subsection M32C Pragmas 17519 17520@table @code 17521@item GCC memregs @var{number} 17522@cindex pragma, memregs 17523Overrides the command-line option @code{-memregs=} for the current 17524file. Use with care! This pragma must be before any function in the 17525file, and mixing different memregs values in different objects may 17526make them incompatible. This pragma is useful when a 17527performance-critical function uses a memreg for temporary values, 17528as it may allow you to reduce the number of memregs used. 17529 17530@item ADDRESS @var{name} @var{address} 17531@cindex pragma, address 17532For any declared symbols matching @var{name}, this does three things 17533to that symbol: it forces the symbol to be located at the given 17534address (a number), it forces the symbol to be volatile, and it 17535changes the symbol's scope to be static. This pragma exists for 17536compatibility with other compilers, but note that the common 17537@code{1234H} numeric syntax is not supported (use @code{0x1234} 17538instead). Example: 17539 17540@smallexample 17541#pragma ADDRESS port3 0x103 17542char port3; 17543@end smallexample 17544 17545@end table 17546 17547@node MeP Pragmas 17548@subsection MeP Pragmas 17549 17550@table @code 17551 17552@item custom io_volatile (on|off) 17553@cindex pragma, custom io_volatile 17554Overrides the command-line option @code{-mio-volatile} for the current 17555file. Note that for compatibility with future GCC releases, this 17556option should only be used once before any @code{io} variables in each 17557file. 17558 17559@item GCC coprocessor available @var{registers} 17560@cindex pragma, coprocessor available 17561Specifies which coprocessor registers are available to the register 17562allocator. @var{registers} may be a single register, register range 17563separated by ellipses, or comma-separated list of those. Example: 17564 17565@smallexample 17566#pragma GCC coprocessor available $c0...$c10, $c28 17567@end smallexample 17568 17569@item GCC coprocessor call_saved @var{registers} 17570@cindex pragma, coprocessor call_saved 17571Specifies which coprocessor registers are to be saved and restored by 17572any function using them. @var{registers} may be a single register, 17573register range separated by ellipses, or comma-separated list of 17574those. Example: 17575 17576@smallexample 17577#pragma GCC coprocessor call_saved $c4...$c6, $c31 17578@end smallexample 17579 17580@item GCC coprocessor subclass '(A|B|C|D)' = @var{registers} 17581@cindex pragma, coprocessor subclass 17582Creates and defines a register class. These register classes can be 17583used by inline @code{asm} constructs. @var{registers} may be a single 17584register, register range separated by ellipses, or comma-separated 17585list of those. Example: 17586 17587@smallexample 17588#pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6 17589 17590asm ("cpfoo %0" : "=B" (x)); 17591@end smallexample 17592 17593@item GCC disinterrupt @var{name} , @var{name} @dots{} 17594@cindex pragma, disinterrupt 17595For the named functions, the compiler adds code to disable interrupts 17596for the duration of those functions. If any functions so named 17597are not encountered in the source, a warning is emitted that the pragma is 17598not used. Examples: 17599 17600@smallexample 17601#pragma disinterrupt foo 17602#pragma disinterrupt bar, grill 17603int foo () @{ @dots{} @} 17604@end smallexample 17605 17606@item GCC call @var{name} , @var{name} @dots{} 17607@cindex pragma, call 17608For the named functions, the compiler always uses a register-indirect 17609call model when calling the named functions. Examples: 17610 17611@smallexample 17612extern int foo (); 17613#pragma call foo 17614@end smallexample 17615 17616@end table 17617 17618@node RS/6000 and PowerPC Pragmas 17619@subsection RS/6000 and PowerPC Pragmas 17620 17621The RS/6000 and PowerPC targets define one pragma for controlling 17622whether or not the @code{longcall} attribute is added to function 17623declarations by default. This pragma overrides the @option{-mlongcall} 17624option, but not the @code{longcall} and @code{shortcall} attributes. 17625@xref{RS/6000 and PowerPC Options}, for more information about when long 17626calls are and are not necessary. 17627 17628@table @code 17629@item longcall (1) 17630@cindex pragma, longcall 17631Apply the @code{longcall} attribute to all subsequent function 17632declarations. 17633 17634@item longcall (0) 17635Do not apply the @code{longcall} attribute to subsequent function 17636declarations. 17637@end table 17638 17639@c Describe h8300 pragmas here. 17640@c Describe sh pragmas here. 17641@c Describe v850 pragmas here. 17642 17643@node Darwin Pragmas 17644@subsection Darwin Pragmas 17645 17646The following pragmas are available for all architectures running the 17647Darwin operating system. These are useful for compatibility with other 17648Mac OS compilers. 17649 17650@table @code 17651@item mark @var{tokens}@dots{} 17652@cindex pragma, mark 17653This pragma is accepted, but has no effect. 17654 17655@item options align=@var{alignment} 17656@cindex pragma, options align 17657This pragma sets the alignment of fields in structures. The values of 17658@var{alignment} may be @code{mac68k}, to emulate m68k alignment, or 17659@code{power}, to emulate PowerPC alignment. Uses of this pragma nest 17660properly; to restore the previous setting, use @code{reset} for the 17661@var{alignment}. 17662 17663@item segment @var{tokens}@dots{} 17664@cindex pragma, segment 17665This pragma is accepted, but has no effect. 17666 17667@item unused (@var{var} [, @var{var}]@dots{}) 17668@cindex pragma, unused 17669This pragma declares variables to be possibly unused. GCC does not 17670produce warnings for the listed variables. The effect is similar to 17671that of the @code{unused} attribute, except that this pragma may appear 17672anywhere within the variables' scopes. 17673@end table 17674 17675@node Solaris Pragmas 17676@subsection Solaris Pragmas 17677 17678The Solaris target supports @code{#pragma redefine_extname} 17679(@pxref{Symbol-Renaming Pragmas}). It also supports additional 17680@code{#pragma} directives for compatibility with the system compiler. 17681 17682@table @code 17683@item align @var{alignment} (@var{variable} [, @var{variable}]...) 17684@cindex pragma, align 17685 17686Increase the minimum alignment of each @var{variable} to @var{alignment}. 17687This is the same as GCC's @code{aligned} attribute @pxref{Variable 17688Attributes}). Macro expansion occurs on the arguments to this pragma 17689when compiling C and Objective-C@. It does not currently occur when 17690compiling C++, but this is a bug which may be fixed in a future 17691release. 17692 17693@item fini (@var{function} [, @var{function}]...) 17694@cindex pragma, fini 17695 17696This pragma causes each listed @var{function} to be called after 17697main, or during shared module unloading, by adding a call to the 17698@code{.fini} section. 17699 17700@item init (@var{function} [, @var{function}]...) 17701@cindex pragma, init 17702 17703This pragma causes each listed @var{function} to be called during 17704initialization (before @code{main}) or during shared module loading, by 17705adding a call to the @code{.init} section. 17706 17707@end table 17708 17709@node Symbol-Renaming Pragmas 17710@subsection Symbol-Renaming Pragmas 17711 17712GCC supports a @code{#pragma} directive that changes the name used in 17713assembly for a given declaration. While this pragma is supported on all 17714platforms, it is intended primarily to provide compatibility with the 17715Solaris system headers. This effect can also be achieved using the asm 17716labels extension (@pxref{Asm Labels}). 17717 17718@table @code 17719@item redefine_extname @var{oldname} @var{newname} 17720@cindex pragma, redefine_extname 17721 17722This pragma gives the C function @var{oldname} the assembly symbol 17723@var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME} 17724is defined if this pragma is available (currently on all platforms). 17725@end table 17726 17727This pragma and the asm labels extension interact in a complicated 17728manner. Here are some corner cases you may want to be aware of: 17729 17730@enumerate 17731@item This pragma silently applies only to declarations with external 17732linkage. Asm labels do not have this restriction. 17733 17734@item In C++, this pragma silently applies only to declarations with 17735``C'' linkage. Again, asm labels do not have this restriction. 17736 17737@item If either of the ways of changing the assembly name of a 17738declaration are applied to a declaration whose assembly name has 17739already been determined (either by a previous use of one of these 17740features, or because the compiler needed the assembly name in order to 17741generate code), and the new name is different, a warning issues and 17742the name does not change. 17743 17744@item The @var{oldname} used by @code{#pragma redefine_extname} is 17745always the C-language name. 17746@end enumerate 17747 17748@node Structure-Packing Pragmas 17749@subsection Structure-Packing Pragmas 17750 17751For compatibility with Microsoft Windows compilers, GCC supports a 17752set of @code{#pragma} directives that change the maximum alignment of 17753members of structures (other than zero-width bit-fields), unions, and 17754classes subsequently defined. The @var{n} value below always is required 17755to be a small power of two and specifies the new alignment in bytes. 17756 17757@enumerate 17758@item @code{#pragma pack(@var{n})} simply sets the new alignment. 17759@item @code{#pragma pack()} sets the alignment to the one that was in 17760effect when compilation started (see also command-line option 17761@option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}). 17762@item @code{#pragma pack(push[,@var{n}])} pushes the current alignment 17763setting on an internal stack and then optionally sets the new alignment. 17764@item @code{#pragma pack(pop)} restores the alignment setting to the one 17765saved at the top of the internal stack (and removes that stack entry). 17766Note that @code{#pragma pack([@var{n}])} does not influence this internal 17767stack; thus it is possible to have @code{#pragma pack(push)} followed by 17768multiple @code{#pragma pack(@var{n})} instances and finalized by a single 17769@code{#pragma pack(pop)}. 17770@end enumerate 17771 17772Some targets, e.g.@: x86 and PowerPC, support the @code{ms_struct} 17773@code{#pragma} which lays out a structure as the documented 17774@code{__attribute__ ((ms_struct))}. 17775@enumerate 17776@item @code{#pragma ms_struct on} turns on the layout for structures 17777declared. 17778@item @code{#pragma ms_struct off} turns off the layout for structures 17779declared. 17780@item @code{#pragma ms_struct reset} goes back to the default layout. 17781@end enumerate 17782 17783@node Weak Pragmas 17784@subsection Weak Pragmas 17785 17786For compatibility with SVR4, GCC supports a set of @code{#pragma} 17787directives for declaring symbols to be weak, and defining weak 17788aliases. 17789 17790@table @code 17791@item #pragma weak @var{symbol} 17792@cindex pragma, weak 17793This pragma declares @var{symbol} to be weak, as if the declaration 17794had the attribute of the same name. The pragma may appear before 17795or after the declaration of @var{symbol}. It is not an error for 17796@var{symbol} to never be defined at all. 17797 17798@item #pragma weak @var{symbol1} = @var{symbol2} 17799This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}. 17800It is an error if @var{symbol2} is not defined in the current 17801translation unit. 17802@end table 17803 17804@node Diagnostic Pragmas 17805@subsection Diagnostic Pragmas 17806 17807GCC allows the user to selectively enable or disable certain types of 17808diagnostics, and change the kind of the diagnostic. For example, a 17809project's policy might require that all sources compile with 17810@option{-Werror} but certain files might have exceptions allowing 17811specific types of warnings. Or, a project might selectively enable 17812diagnostics and treat them as errors depending on which preprocessor 17813macros are defined. 17814 17815@table @code 17816@item #pragma GCC diagnostic @var{kind} @var{option} 17817@cindex pragma, diagnostic 17818 17819Modifies the disposition of a diagnostic. Note that not all 17820diagnostics are modifiable; at the moment only warnings (normally 17821controlled by @samp{-W@dots{}}) can be controlled, and not all of them. 17822Use @option{-fdiagnostics-show-option} to determine which diagnostics 17823are controllable and which option controls them. 17824 17825@var{kind} is @samp{error} to treat this diagnostic as an error, 17826@samp{warning} to treat it like a warning (even if @option{-Werror} is 17827in effect), or @samp{ignored} if the diagnostic is to be ignored. 17828@var{option} is a double quoted string that matches the command-line 17829option. 17830 17831@smallexample 17832#pragma GCC diagnostic warning "-Wformat" 17833#pragma GCC diagnostic error "-Wformat" 17834#pragma GCC diagnostic ignored "-Wformat" 17835@end smallexample 17836 17837Note that these pragmas override any command-line options. GCC keeps 17838track of the location of each pragma, and issues diagnostics according 17839to the state as of that point in the source file. Thus, pragmas occurring 17840after a line do not affect diagnostics caused by that line. 17841 17842@item #pragma GCC diagnostic push 17843@itemx #pragma GCC diagnostic pop 17844 17845Causes GCC to remember the state of the diagnostics as of each 17846@code{push}, and restore to that point at each @code{pop}. If a 17847@code{pop} has no matching @code{push}, the command-line options are 17848restored. 17849 17850@smallexample 17851#pragma GCC diagnostic error "-Wuninitialized" 17852 foo(a); /* error is given for this one */ 17853#pragma GCC diagnostic push 17854#pragma GCC diagnostic ignored "-Wuninitialized" 17855 foo(b); /* no diagnostic for this one */ 17856#pragma GCC diagnostic pop 17857 foo(c); /* error is given for this one */ 17858#pragma GCC diagnostic pop 17859 foo(d); /* depends on command-line options */ 17860@end smallexample 17861 17862@end table 17863 17864GCC also offers a simple mechanism for printing messages during 17865compilation. 17866 17867@table @code 17868@item #pragma message @var{string} 17869@cindex pragma, diagnostic 17870 17871Prints @var{string} as a compiler message on compilation. The message 17872is informational only, and is neither a compilation warning nor an error. 17873 17874@smallexample 17875#pragma message "Compiling " __FILE__ "..." 17876@end smallexample 17877 17878@var{string} may be parenthesized, and is printed with location 17879information. For example, 17880 17881@smallexample 17882#define DO_PRAGMA(x) _Pragma (#x) 17883#define TODO(x) DO_PRAGMA(message ("TODO - " #x)) 17884 17885TODO(Remember to fix this) 17886@end smallexample 17887 17888@noindent 17889prints @samp{/tmp/file.c:4: note: #pragma message: 17890TODO - Remember to fix this}. 17891 17892@end table 17893 17894@node Visibility Pragmas 17895@subsection Visibility Pragmas 17896 17897@table @code 17898@item #pragma GCC visibility push(@var{visibility}) 17899@itemx #pragma GCC visibility pop 17900@cindex pragma, visibility 17901 17902This pragma allows the user to set the visibility for multiple 17903declarations without having to give each a visibility attribute 17904(@pxref{Function Attributes}). 17905 17906In C++, @samp{#pragma GCC visibility} affects only namespace-scope 17907declarations. Class members and template specializations are not 17908affected; if you want to override the visibility for a particular 17909member or instantiation, you must use an attribute. 17910 17911@end table 17912 17913 17914@node Push/Pop Macro Pragmas 17915@subsection Push/Pop Macro Pragmas 17916 17917For compatibility with Microsoft Windows compilers, GCC supports 17918@samp{#pragma push_macro(@var{"macro_name"})} 17919and @samp{#pragma pop_macro(@var{"macro_name"})}. 17920 17921@table @code 17922@item #pragma push_macro(@var{"macro_name"}) 17923@cindex pragma, push_macro 17924This pragma saves the value of the macro named as @var{macro_name} to 17925the top of the stack for this macro. 17926 17927@item #pragma pop_macro(@var{"macro_name"}) 17928@cindex pragma, pop_macro 17929This pragma sets the value of the macro named as @var{macro_name} to 17930the value on top of the stack for this macro. If the stack for 17931@var{macro_name} is empty, the value of the macro remains unchanged. 17932@end table 17933 17934For example: 17935 17936@smallexample 17937#define X 1 17938#pragma push_macro("X") 17939#undef X 17940#define X -1 17941#pragma pop_macro("X") 17942int x [X]; 17943@end smallexample 17944 17945@noindent 17946In this example, the definition of X as 1 is saved by @code{#pragma 17947push_macro} and restored by @code{#pragma pop_macro}. 17948 17949@node Function Specific Option Pragmas 17950@subsection Function Specific Option Pragmas 17951 17952@table @code 17953@item #pragma GCC target (@var{"string"}...) 17954@cindex pragma GCC target 17955 17956This pragma allows you to set target specific options for functions 17957defined later in the source file. One or more strings can be 17958specified. Each function that is defined after this point is as 17959if @code{attribute((target("STRING")))} was specified for that 17960function. The parenthesis around the options is optional. 17961@xref{Function Attributes}, for more information about the 17962@code{target} attribute and the attribute syntax. 17963 17964The @code{#pragma GCC target} pragma is presently implemented for 17965x86, PowerPC, and Nios II targets only. 17966@end table 17967 17968@table @code 17969@item #pragma GCC optimize (@var{"string"}...) 17970@cindex pragma GCC optimize 17971 17972This pragma allows you to set global optimization options for functions 17973defined later in the source file. One or more strings can be 17974specified. Each function that is defined after this point is as 17975if @code{attribute((optimize("STRING")))} was specified for that 17976function. The parenthesis around the options is optional. 17977@xref{Function Attributes}, for more information about the 17978@code{optimize} attribute and the attribute syntax. 17979@end table 17980 17981@table @code 17982@item #pragma GCC push_options 17983@itemx #pragma GCC pop_options 17984@cindex pragma GCC push_options 17985@cindex pragma GCC pop_options 17986 17987These pragmas maintain a stack of the current target and optimization 17988options. It is intended for include files where you temporarily want 17989to switch to using a different @samp{#pragma GCC target} or 17990@samp{#pragma GCC optimize} and then to pop back to the previous 17991options. 17992@end table 17993 17994@table @code 17995@item #pragma GCC reset_options 17996@cindex pragma GCC reset_options 17997 17998This pragma clears the current @code{#pragma GCC target} and 17999@code{#pragma GCC optimize} to use the default switches as specified 18000on the command line. 18001@end table 18002 18003@node Loop-Specific Pragmas 18004@subsection Loop-Specific Pragmas 18005 18006@table @code 18007@item #pragma GCC ivdep 18008@cindex pragma GCC ivdep 18009@end table 18010 18011With this pragma, the programmer asserts that there are no loop-carried 18012dependencies which would prevent consecutive iterations of 18013the following loop from executing concurrently with SIMD 18014(single instruction multiple data) instructions. 18015 18016For example, the compiler can only unconditionally vectorize the following 18017loop with the pragma: 18018 18019@smallexample 18020void foo (int n, int *a, int *b, int *c) 18021@{ 18022 int i, j; 18023#pragma GCC ivdep 18024 for (i = 0; i < n; ++i) 18025 a[i] = b[i] + c[i]; 18026@} 18027@end smallexample 18028 18029@noindent 18030In this example, using the @code{restrict} qualifier had the same 18031effect. In the following example, that would not be possible. Assume 18032@math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows 18033that it can unconditionally vectorize the following loop: 18034 18035@smallexample 18036void ignore_vec_dep (int *a, int k, int c, int m) 18037@{ 18038#pragma GCC ivdep 18039 for (int i = 0; i < m; i++) 18040 a[i] = a[i + k] * c; 18041@} 18042@end smallexample 18043 18044 18045@node Unnamed Fields 18046@section Unnamed Structure and Union Fields 18047@cindex @code{struct} 18048@cindex @code{union} 18049 18050As permitted by ISO C11 and for compatibility with other compilers, 18051GCC allows you to define 18052a structure or union that contains, as fields, structures and unions 18053without names. For example: 18054 18055@smallexample 18056struct @{ 18057 int a; 18058 union @{ 18059 int b; 18060 float c; 18061 @}; 18062 int d; 18063@} foo; 18064@end smallexample 18065 18066@noindent 18067In this example, you are able to access members of the unnamed 18068union with code like @samp{foo.b}. Note that only unnamed structs and 18069unions are allowed, you may not have, for example, an unnamed 18070@code{int}. 18071 18072You must never create such structures that cause ambiguous field definitions. 18073For example, in this structure: 18074 18075@smallexample 18076struct @{ 18077 int a; 18078 struct @{ 18079 int a; 18080 @}; 18081@} foo; 18082@end smallexample 18083 18084@noindent 18085it is ambiguous which @code{a} is being referred to with @samp{foo.a}. 18086The compiler gives errors for such constructs. 18087 18088@opindex fms-extensions 18089Unless @option{-fms-extensions} is used, the unnamed field must be a 18090structure or union definition without a tag (for example, @samp{struct 18091@{ int a; @};}). If @option{-fms-extensions} is used, the field may 18092also be a definition with a tag such as @samp{struct foo @{ int a; 18093@};}, a reference to a previously defined structure or union such as 18094@samp{struct foo;}, or a reference to a @code{typedef} name for a 18095previously defined structure or union type. 18096 18097@opindex fplan9-extensions 18098The option @option{-fplan9-extensions} enables 18099@option{-fms-extensions} as well as two other extensions. First, a 18100pointer to a structure is automatically converted to a pointer to an 18101anonymous field for assignments and function calls. For example: 18102 18103@smallexample 18104struct s1 @{ int a; @}; 18105struct s2 @{ struct s1; @}; 18106extern void f1 (struct s1 *); 18107void f2 (struct s2 *p) @{ f1 (p); @} 18108@end smallexample 18109 18110@noindent 18111In the call to @code{f1} inside @code{f2}, the pointer @code{p} is 18112converted into a pointer to the anonymous field. 18113 18114Second, when the type of an anonymous field is a @code{typedef} for a 18115@code{struct} or @code{union}, code may refer to the field using the 18116name of the @code{typedef}. 18117 18118@smallexample 18119typedef struct @{ int a; @} s1; 18120struct s2 @{ s1; @}; 18121s1 f1 (struct s2 *p) @{ return p->s1; @} 18122@end smallexample 18123 18124These usages are only permitted when they are not ambiguous. 18125 18126@node Thread-Local 18127@section Thread-Local Storage 18128@cindex Thread-Local Storage 18129@cindex @acronym{TLS} 18130@cindex @code{__thread} 18131 18132Thread-local storage (@acronym{TLS}) is a mechanism by which variables 18133are allocated such that there is one instance of the variable per extant 18134thread. The runtime model GCC uses to implement this originates 18135in the IA-64 processor-specific ABI, but has since been migrated 18136to other processors as well. It requires significant support from 18137the linker (@command{ld}), dynamic linker (@command{ld.so}), and 18138system libraries (@file{libc.so} and @file{libpthread.so}), so it 18139is not available everywhere. 18140 18141At the user level, the extension is visible with a new storage 18142class keyword: @code{__thread}. For example: 18143 18144@smallexample 18145__thread int i; 18146extern __thread struct state s; 18147static __thread char *p; 18148@end smallexample 18149 18150The @code{__thread} specifier may be used alone, with the @code{extern} 18151or @code{static} specifiers, but with no other storage class specifier. 18152When used with @code{extern} or @code{static}, @code{__thread} must appear 18153immediately after the other storage class specifier. 18154 18155The @code{__thread} specifier may be applied to any global, file-scoped 18156static, function-scoped static, or static data member of a class. It may 18157not be applied to block-scoped automatic or non-static data member. 18158 18159When the address-of operator is applied to a thread-local variable, it is 18160evaluated at run time and returns the address of the current thread's 18161instance of that variable. An address so obtained may be used by any 18162thread. When a thread terminates, any pointers to thread-local variables 18163in that thread become invalid. 18164 18165No static initialization may refer to the address of a thread-local variable. 18166 18167In C++, if an initializer is present for a thread-local variable, it must 18168be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++ 18169standard. 18170 18171See @uref{http://www.akkadia.org/drepper/tls.pdf, 18172ELF Handling For Thread-Local Storage} for a detailed explanation of 18173the four thread-local storage addressing models, and how the runtime 18174is expected to function. 18175 18176@menu 18177* C99 Thread-Local Edits:: 18178* C++98 Thread-Local Edits:: 18179@end menu 18180 18181@node C99 Thread-Local Edits 18182@subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage 18183 18184The following are a set of changes to ISO/IEC 9899:1999 (aka C99) 18185that document the exact semantics of the language extension. 18186 18187@itemize @bullet 18188@item 18189@cite{5.1.2 Execution environments} 18190 18191Add new text after paragraph 1 18192 18193@quotation 18194Within either execution environment, a @dfn{thread} is a flow of 18195control within a program. It is implementation defined whether 18196or not there may be more than one thread associated with a program. 18197It is implementation defined how threads beyond the first are 18198created, the name and type of the function called at thread 18199startup, and how threads may be terminated. However, objects 18200with thread storage duration shall be initialized before thread 18201startup. 18202@end quotation 18203 18204@item 18205@cite{6.2.4 Storage durations of objects} 18206 18207Add new text before paragraph 3 18208 18209@quotation 18210An object whose identifier is declared with the storage-class 18211specifier @w{@code{__thread}} has @dfn{thread storage duration}. 18212Its lifetime is the entire execution of the thread, and its 18213stored value is initialized only once, prior to thread startup. 18214@end quotation 18215 18216@item 18217@cite{6.4.1 Keywords} 18218 18219Add @code{__thread}. 18220 18221@item 18222@cite{6.7.1 Storage-class specifiers} 18223 18224Add @code{__thread} to the list of storage class specifiers in 18225paragraph 1. 18226 18227Change paragraph 2 to 18228 18229@quotation 18230With the exception of @code{__thread}, at most one storage-class 18231specifier may be given [@dots{}]. The @code{__thread} specifier may 18232be used alone, or immediately following @code{extern} or 18233@code{static}. 18234@end quotation 18235 18236Add new text after paragraph 6 18237 18238@quotation 18239The declaration of an identifier for a variable that has 18240block scope that specifies @code{__thread} shall also 18241specify either @code{extern} or @code{static}. 18242 18243The @code{__thread} specifier shall be used only with 18244variables. 18245@end quotation 18246@end itemize 18247 18248@node C++98 Thread-Local Edits 18249@subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage 18250 18251The following are a set of changes to ISO/IEC 14882:1998 (aka C++98) 18252that document the exact semantics of the language extension. 18253 18254@itemize @bullet 18255@item 18256@b{[intro.execution]} 18257 18258New text after paragraph 4 18259 18260@quotation 18261A @dfn{thread} is a flow of control within the abstract machine. 18262It is implementation defined whether or not there may be more than 18263one thread. 18264@end quotation 18265 18266New text after paragraph 7 18267 18268@quotation 18269It is unspecified whether additional action must be taken to 18270ensure when and whether side effects are visible to other threads. 18271@end quotation 18272 18273@item 18274@b{[lex.key]} 18275 18276Add @code{__thread}. 18277 18278@item 18279@b{[basic.start.main]} 18280 18281Add after paragraph 5 18282 18283@quotation 18284The thread that begins execution at the @code{main} function is called 18285the @dfn{main thread}. It is implementation defined how functions 18286beginning threads other than the main thread are designated or typed. 18287A function so designated, as well as the @code{main} function, is called 18288a @dfn{thread startup function}. It is implementation defined what 18289happens if a thread startup function returns. It is implementation 18290defined what happens to other threads when any thread calls @code{exit}. 18291@end quotation 18292 18293@item 18294@b{[basic.start.init]} 18295 18296Add after paragraph 4 18297 18298@quotation 18299The storage for an object of thread storage duration shall be 18300statically initialized before the first statement of the thread startup 18301function. An object of thread storage duration shall not require 18302dynamic initialization. 18303@end quotation 18304 18305@item 18306@b{[basic.start.term]} 18307 18308Add after paragraph 3 18309 18310@quotation 18311The type of an object with thread storage duration shall not have a 18312non-trivial destructor, nor shall it be an array type whose elements 18313(directly or indirectly) have non-trivial destructors. 18314@end quotation 18315 18316@item 18317@b{[basic.stc]} 18318 18319Add ``thread storage duration'' to the list in paragraph 1. 18320 18321Change paragraph 2 18322 18323@quotation 18324Thread, static, and automatic storage durations are associated with 18325objects introduced by declarations [@dots{}]. 18326@end quotation 18327 18328Add @code{__thread} to the list of specifiers in paragraph 3. 18329 18330@item 18331@b{[basic.stc.thread]} 18332 18333New section before @b{[basic.stc.static]} 18334 18335@quotation 18336The keyword @code{__thread} applied to a non-local object gives the 18337object thread storage duration. 18338 18339A local variable or class data member declared both @code{static} 18340and @code{__thread} gives the variable or member thread storage 18341duration. 18342@end quotation 18343 18344@item 18345@b{[basic.stc.static]} 18346 18347Change paragraph 1 18348 18349@quotation 18350All objects that have neither thread storage duration, dynamic 18351storage duration nor are local [@dots{}]. 18352@end quotation 18353 18354@item 18355@b{[dcl.stc]} 18356 18357Add @code{__thread} to the list in paragraph 1. 18358 18359Change paragraph 1 18360 18361@quotation 18362With the exception of @code{__thread}, at most one 18363@var{storage-class-specifier} shall appear in a given 18364@var{decl-specifier-seq}. The @code{__thread} specifier may 18365be used alone, or immediately following the @code{extern} or 18366@code{static} specifiers. [@dots{}] 18367@end quotation 18368 18369Add after paragraph 5 18370 18371@quotation 18372The @code{__thread} specifier can be applied only to the names of objects 18373and to anonymous unions. 18374@end quotation 18375 18376@item 18377@b{[class.mem]} 18378 18379Add after paragraph 6 18380 18381@quotation 18382Non-@code{static} members shall not be @code{__thread}. 18383@end quotation 18384@end itemize 18385 18386@node Binary constants 18387@section Binary Constants using the @samp{0b} Prefix 18388@cindex Binary constants using the @samp{0b} prefix 18389 18390Integer constants can be written as binary constants, consisting of a 18391sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or 18392@samp{0B}. This is particularly useful in environments that operate a 18393lot on the bit level (like microcontrollers). 18394 18395The following statements are identical: 18396 18397@smallexample 18398i = 42; 18399i = 0x2a; 18400i = 052; 18401i = 0b101010; 18402@end smallexample 18403 18404The type of these constants follows the same rules as for octal or 18405hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL} 18406can be applied. 18407 18408@node C++ Extensions 18409@chapter Extensions to the C++ Language 18410@cindex extensions, C++ language 18411@cindex C++ language extensions 18412 18413The GNU compiler provides these extensions to the C++ language (and you 18414can also use most of the C language extensions in your C++ programs). If you 18415want to write code that checks whether these features are available, you can 18416test for the GNU compiler the same way as for C programs: check for a 18417predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to 18418test specifically for GNU C++ (@pxref{Common Predefined Macros,, 18419Predefined Macros,cpp,The GNU C Preprocessor}). 18420 18421@menu 18422* C++ Volatiles:: What constitutes an access to a volatile object. 18423* Restricted Pointers:: C99 restricted pointers and references. 18424* Vague Linkage:: Where G++ puts inlines, vtables and such. 18425* C++ Interface:: You can use a single C++ header file for both 18426 declarations and definitions. 18427* Template Instantiation:: Methods for ensuring that exactly one copy of 18428 each needed template instantiation is emitted. 18429* Bound member functions:: You can extract a function pointer to the 18430 method denoted by a @samp{->*} or @samp{.*} expression. 18431* C++ Attributes:: Variable, function, and type attributes for C++ only. 18432* Function Multiversioning:: Declaring multiple function versions. 18433* Namespace Association:: Strong using-directives for namespace association. 18434* Type Traits:: Compiler support for type traits 18435* Java Exceptions:: Tweaking exception handling to work with Java. 18436* Deprecated Features:: Things will disappear from G++. 18437* Backwards Compatibility:: Compatibilities with earlier definitions of C++. 18438@end menu 18439 18440@node C++ Volatiles 18441@section When is a Volatile C++ Object Accessed? 18442@cindex accessing volatiles 18443@cindex volatile read 18444@cindex volatile write 18445@cindex volatile access 18446 18447The C++ standard differs from the C standard in its treatment of 18448volatile objects. It fails to specify what constitutes a volatile 18449access, except to say that C++ should behave in a similar manner to C 18450with respect to volatiles, where possible. However, the different 18451lvalueness of expressions between C and C++ complicate the behavior. 18452G++ behaves the same as GCC for volatile access, @xref{C 18453Extensions,,Volatiles}, for a description of GCC's behavior. 18454 18455The C and C++ language specifications differ when an object is 18456accessed in a void context: 18457 18458@smallexample 18459volatile int *src = @var{somevalue}; 18460*src; 18461@end smallexample 18462 18463The C++ standard specifies that such expressions do not undergo lvalue 18464to rvalue conversion, and that the type of the dereferenced object may 18465be incomplete. The C++ standard does not specify explicitly that it 18466is lvalue to rvalue conversion that is responsible for causing an 18467access. There is reason to believe that it is, because otherwise 18468certain simple expressions become undefined. However, because it 18469would surprise most programmers, G++ treats dereferencing a pointer to 18470volatile object of complete type as GCC would do for an equivalent 18471type in C@. When the object has incomplete type, G++ issues a 18472warning; if you wish to force an error, you must force a conversion to 18473rvalue with, for instance, a static cast. 18474 18475When using a reference to volatile, G++ does not treat equivalent 18476expressions as accesses to volatiles, but instead issues a warning that 18477no volatile is accessed. The rationale for this is that otherwise it 18478becomes difficult to determine where volatile access occur, and not 18479possible to ignore the return value from functions returning volatile 18480references. Again, if you wish to force a read, cast the reference to 18481an rvalue. 18482 18483G++ implements the same behavior as GCC does when assigning to a 18484volatile object---there is no reread of the assigned-to object, the 18485assigned rvalue is reused. Note that in C++ assignment expressions 18486are lvalues, and if used as an lvalue, the volatile object is 18487referred to. For instance, @var{vref} refers to @var{vobj}, as 18488expected, in the following example: 18489 18490@smallexample 18491volatile int vobj; 18492volatile int &vref = vobj = @var{something}; 18493@end smallexample 18494 18495@node Restricted Pointers 18496@section Restricting Pointer Aliasing 18497@cindex restricted pointers 18498@cindex restricted references 18499@cindex restricted this pointer 18500 18501As with the C front end, G++ understands the C99 feature of restricted pointers, 18502specified with the @code{__restrict__}, or @code{__restrict} type 18503qualifier. Because you cannot compile C++ by specifying the @option{-std=c99} 18504language flag, @code{restrict} is not a keyword in C++. 18505 18506In addition to allowing restricted pointers, you can specify restricted 18507references, which indicate that the reference is not aliased in the local 18508context. 18509 18510@smallexample 18511void fn (int *__restrict__ rptr, int &__restrict__ rref) 18512@{ 18513 /* @r{@dots{}} */ 18514@} 18515@end smallexample 18516 18517@noindent 18518In the body of @code{fn}, @var{rptr} points to an unaliased integer and 18519@var{rref} refers to a (different) unaliased integer. 18520 18521You may also specify whether a member function's @var{this} pointer is 18522unaliased by using @code{__restrict__} as a member function qualifier. 18523 18524@smallexample 18525void T::fn () __restrict__ 18526@{ 18527 /* @r{@dots{}} */ 18528@} 18529@end smallexample 18530 18531@noindent 18532Within the body of @code{T::fn}, @var{this} has the effective 18533definition @code{T *__restrict__ const this}. Notice that the 18534interpretation of a @code{__restrict__} member function qualifier is 18535different to that of @code{const} or @code{volatile} qualifier, in that it 18536is applied to the pointer rather than the object. This is consistent with 18537other compilers that implement restricted pointers. 18538 18539As with all outermost parameter qualifiers, @code{__restrict__} is 18540ignored in function definition matching. This means you only need to 18541specify @code{__restrict__} in a function definition, rather than 18542in a function prototype as well. 18543 18544@node Vague Linkage 18545@section Vague Linkage 18546@cindex vague linkage 18547 18548There are several constructs in C++ that require space in the object 18549file but are not clearly tied to a single translation unit. We say that 18550these constructs have ``vague linkage''. Typically such constructs are 18551emitted wherever they are needed, though sometimes we can be more 18552clever. 18553 18554@table @asis 18555@item Inline Functions 18556Inline functions are typically defined in a header file which can be 18557included in many different compilations. Hopefully they can usually be 18558inlined, but sometimes an out-of-line copy is necessary, if the address 18559of the function is taken or if inlining fails. In general, we emit an 18560out-of-line copy in all translation units where one is needed. As an 18561exception, we only emit inline virtual functions with the vtable, since 18562it always requires a copy. 18563 18564Local static variables and string constants used in an inline function 18565are also considered to have vague linkage, since they must be shared 18566between all inlined and out-of-line instances of the function. 18567 18568@item VTables 18569@cindex vtable 18570C++ virtual functions are implemented in most compilers using a lookup 18571table, known as a vtable. The vtable contains pointers to the virtual 18572functions provided by a class, and each object of the class contains a 18573pointer to its vtable (or vtables, in some multiple-inheritance 18574situations). If the class declares any non-inline, non-pure virtual 18575functions, the first one is chosen as the ``key method'' for the class, 18576and the vtable is only emitted in the translation unit where the key 18577method is defined. 18578 18579@emph{Note:} If the chosen key method is later defined as inline, the 18580vtable is still emitted in every translation unit that defines it. 18581Make sure that any inline virtuals are declared inline in the class 18582body, even if they are not defined there. 18583 18584@item @code{type_info} objects 18585@cindex @code{type_info} 18586@cindex RTTI 18587C++ requires information about types to be written out in order to 18588implement @samp{dynamic_cast}, @samp{typeid} and exception handling. 18589For polymorphic classes (classes with virtual functions), the @samp{type_info} 18590object is written out along with the vtable so that @samp{dynamic_cast} 18591can determine the dynamic type of a class object at run time. For all 18592other types, we write out the @samp{type_info} object when it is used: when 18593applying @samp{typeid} to an expression, throwing an object, or 18594referring to a type in a catch clause or exception specification. 18595 18596@item Template Instantiations 18597Most everything in this section also applies to template instantiations, 18598but there are other options as well. 18599@xref{Template Instantiation,,Where's the Template?}. 18600 18601@end table 18602 18603When used with GNU ld version 2.8 or later on an ELF system such as 18604GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of 18605these constructs will be discarded at link time. This is known as 18606COMDAT support. 18607 18608On targets that don't support COMDAT, but do support weak symbols, GCC 18609uses them. This way one copy overrides all the others, but 18610the unused copies still take up space in the executable. 18611 18612For targets that do not support either COMDAT or weak symbols, 18613most entities with vague linkage are emitted as local symbols to 18614avoid duplicate definition errors from the linker. This does not happen 18615for local statics in inlines, however, as having multiple copies 18616almost certainly breaks things. 18617 18618@xref{C++ Interface,,Declarations and Definitions in One Header}, for 18619another way to control placement of these constructs. 18620 18621@node C++ Interface 18622@section C++ Interface and Implementation Pragmas 18623 18624@cindex interface and implementation headers, C++ 18625@cindex C++ interface and implementation headers 18626@cindex pragmas, interface and implementation 18627 18628@code{#pragma interface} and @code{#pragma implementation} provide the 18629user with a way of explicitly directing the compiler to emit entities 18630with vague linkage (and debugging information) in a particular 18631translation unit. 18632 18633@emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2 18634by COMDAT support and the ``key method'' heuristic 18635mentioned in @ref{Vague Linkage}. Using them can actually cause your 18636program to grow due to unnecessary out-of-line copies of inline 18637functions. 18638 18639@table @code 18640@item #pragma interface 18641@itemx #pragma interface "@var{subdir}/@var{objects}.h" 18642@kindex #pragma interface 18643Use this directive in @emph{header files} that define object classes, to save 18644space in most of the object files that use those classes. Normally, 18645local copies of certain information (backup copies of inline member 18646functions, debugging information, and the internal tables that implement 18647virtual functions) must be kept in each object file that includes class 18648definitions. You can use this pragma to avoid such duplication. When a 18649header file containing @samp{#pragma interface} is included in a 18650compilation, this auxiliary information is not generated (unless 18651the main input source file itself uses @samp{#pragma implementation}). 18652Instead, the object files contain references to be resolved at link 18653time. 18654 18655The second form of this directive is useful for the case where you have 18656multiple headers with the same name in different directories. If you 18657use this form, you must specify the same string to @samp{#pragma 18658implementation}. 18659 18660@item #pragma implementation 18661@itemx #pragma implementation "@var{objects}.h" 18662@kindex #pragma implementation 18663Use this pragma in a @emph{main input file}, when you want full output from 18664included header files to be generated (and made globally visible). The 18665included header file, in turn, should use @samp{#pragma interface}. 18666Backup copies of inline member functions, debugging information, and the 18667internal tables used to implement virtual functions are all generated in 18668implementation files. 18669 18670@cindex implied @code{#pragma implementation} 18671@cindex @code{#pragma implementation}, implied 18672@cindex naming convention, implementation headers 18673If you use @samp{#pragma implementation} with no argument, it applies to 18674an include file with the same basename@footnote{A file's @dfn{basename} 18675is the name stripped of all leading path information and of trailing 18676suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source 18677file. For example, in @file{allclass.cc}, giving just 18678@samp{#pragma implementation} 18679by itself is equivalent to @samp{#pragma implementation "allclass.h"}. 18680 18681Use the string argument if you want a single implementation file to 18682include code from multiple header files. (You must also use 18683@samp{#include} to include the header file; @samp{#pragma 18684implementation} only specifies how to use the file---it doesn't actually 18685include it.) 18686 18687There is no way to split up the contents of a single header file into 18688multiple implementation files. 18689@end table 18690 18691@cindex inlining and C++ pragmas 18692@cindex C++ pragmas, effect on inlining 18693@cindex pragmas in C++, effect on inlining 18694@samp{#pragma implementation} and @samp{#pragma interface} also have an 18695effect on function inlining. 18696 18697If you define a class in a header file marked with @samp{#pragma 18698interface}, the effect on an inline function defined in that class is 18699similar to an explicit @code{extern} declaration---the compiler emits 18700no code at all to define an independent version of the function. Its 18701definition is used only for inlining with its callers. 18702 18703@opindex fno-implement-inlines 18704Conversely, when you include the same header file in a main source file 18705that declares it as @samp{#pragma implementation}, the compiler emits 18706code for the function itself; this defines a version of the function 18707that can be found via pointers (or by callers compiled without 18708inlining). If all calls to the function can be inlined, you can avoid 18709emitting the function by compiling with @option{-fno-implement-inlines}. 18710If any calls are not inlined, you will get linker errors. 18711 18712@node Template Instantiation 18713@section Where's the Template? 18714@cindex template instantiation 18715 18716C++ templates are the first language feature to require more 18717intelligence from the environment than one usually finds on a UNIX 18718system. Somehow the compiler and linker have to make sure that each 18719template instance occurs exactly once in the executable if it is needed, 18720and not at all otherwise. There are two basic approaches to this 18721problem, which are referred to as the Borland model and the Cfront model. 18722 18723@table @asis 18724@item Borland model 18725Borland C++ solved the template instantiation problem by adding the code 18726equivalent of common blocks to their linker; the compiler emits template 18727instances in each translation unit that uses them, and the linker 18728collapses them together. The advantage of this model is that the linker 18729only has to consider the object files themselves; there is no external 18730complexity to worry about. This disadvantage is that compilation time 18731is increased because the template code is being compiled repeatedly. 18732Code written for this model tends to include definitions of all 18733templates in the header file, since they must be seen to be 18734instantiated. 18735 18736@item Cfront model 18737The AT&T C++ translator, Cfront, solved the template instantiation 18738problem by creating the notion of a template repository, an 18739automatically maintained place where template instances are stored. A 18740more modern version of the repository works as follows: As individual 18741object files are built, the compiler places any template definitions and 18742instantiations encountered in the repository. At link time, the link 18743wrapper adds in the objects in the repository and compiles any needed 18744instances that were not previously emitted. The advantages of this 18745model are more optimal compilation speed and the ability to use the 18746system linker; to implement the Borland model a compiler vendor also 18747needs to replace the linker. The disadvantages are vastly increased 18748complexity, and thus potential for error; for some code this can be 18749just as transparent, but in practice it can been very difficult to build 18750multiple programs in one directory and one program in multiple 18751directories. Code written for this model tends to separate definitions 18752of non-inline member templates into a separate file, which should be 18753compiled separately. 18754@end table 18755 18756When used with GNU ld version 2.8 or later on an ELF system such as 18757GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the 18758Borland model. On other systems, G++ implements neither automatic 18759model. 18760 18761You have the following options for dealing with template instantiations: 18762 18763@enumerate 18764@item 18765@opindex frepo 18766Compile your template-using code with @option{-frepo}. The compiler 18767generates files with the extension @samp{.rpo} listing all of the 18768template instantiations used in the corresponding object files that 18769could be instantiated there; the link wrapper, @samp{collect2}, 18770then updates the @samp{.rpo} files to tell the compiler where to place 18771those instantiations and rebuild any affected object files. The 18772link-time overhead is negligible after the first pass, as the compiler 18773continues to place the instantiations in the same files. 18774 18775This is your best option for application code written for the Borland 18776model, as it just works. Code written for the Cfront model 18777needs to be modified so that the template definitions are available at 18778one or more points of instantiation; usually this is as simple as adding 18779@code{#include <tmethods.cc>} to the end of each template header. 18780 18781For library code, if you want the library to provide all of the template 18782instantiations it needs, just try to link all of its object files 18783together; the link will fail, but cause the instantiations to be 18784generated as a side effect. Be warned, however, that this may cause 18785conflicts if multiple libraries try to provide the same instantiations. 18786For greater control, use explicit instantiation as described in the next 18787option. 18788 18789@item 18790@opindex fno-implicit-templates 18791Compile your code with @option{-fno-implicit-templates} to disable the 18792implicit generation of template instances, and explicitly instantiate 18793all the ones you use. This approach requires more knowledge of exactly 18794which instances you need than do the others, but it's less 18795mysterious and allows greater control. You can scatter the explicit 18796instantiations throughout your program, perhaps putting them in the 18797translation units where the instances are used or the translation units 18798that define the templates themselves; you can put all of the explicit 18799instantiations you need into one big file; or you can create small files 18800like 18801 18802@smallexample 18803#include "Foo.h" 18804#include "Foo.cc" 18805 18806template class Foo<int>; 18807template ostream& operator << 18808 (ostream&, const Foo<int>&); 18809@end smallexample 18810 18811@noindent 18812for each of the instances you need, and create a template instantiation 18813library from those. 18814 18815If you are using Cfront-model code, you can probably get away with not 18816using @option{-fno-implicit-templates} when compiling files that don't 18817@samp{#include} the member template definitions. 18818 18819If you use one big file to do the instantiations, you may want to 18820compile it without @option{-fno-implicit-templates} so you get all of the 18821instances required by your explicit instantiations (but not by any 18822other files) without having to specify them as well. 18823 18824The ISO C++ 2011 standard allows forward declaration of explicit 18825instantiations (with @code{extern}). G++ supports explicit instantiation 18826declarations in C++98 mode and has extended the template instantiation 18827syntax to support instantiation of the compiler support data for a 18828template class (i.e.@: the vtable) without instantiating any of its 18829members (with @code{inline}), and instantiation of only the static data 18830members of a template class, without the support data or member 18831functions (with @code{static}): 18832 18833@smallexample 18834extern template int max (int, int); 18835inline template class Foo<int>; 18836static template class Foo<int>; 18837@end smallexample 18838 18839@item 18840Do nothing. Pretend G++ does implement automatic instantiation 18841management. Code written for the Borland model works fine, but 18842each translation unit contains instances of each of the templates it 18843uses. In a large program, this can lead to an unacceptable amount of code 18844duplication. 18845@end enumerate 18846 18847@node Bound member functions 18848@section Extracting the Function Pointer from a Bound Pointer to Member Function 18849@cindex pmf 18850@cindex pointer to member function 18851@cindex bound pointer to member function 18852 18853In C++, pointer to member functions (PMFs) are implemented using a wide 18854pointer of sorts to handle all the possible call mechanisms; the PMF 18855needs to store information about how to adjust the @samp{this} pointer, 18856and if the function pointed to is virtual, where to find the vtable, and 18857where in the vtable to look for the member function. If you are using 18858PMFs in an inner loop, you should really reconsider that decision. If 18859that is not an option, you can extract the pointer to the function that 18860would be called for a given object/PMF pair and call it directly inside 18861the inner loop, to save a bit of time. 18862 18863Note that you still pay the penalty for the call through a 18864function pointer; on most modern architectures, such a call defeats the 18865branch prediction features of the CPU@. This is also true of normal 18866virtual function calls. 18867 18868The syntax for this extension is 18869 18870@smallexample 18871extern A a; 18872extern int (A::*fp)(); 18873typedef int (*fptr)(A *); 18874 18875fptr p = (fptr)(a.*fp); 18876@end smallexample 18877 18878For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}), 18879no object is needed to obtain the address of the function. They can be 18880converted to function pointers directly: 18881 18882@smallexample 18883fptr p1 = (fptr)(&A::foo); 18884@end smallexample 18885 18886@opindex Wno-pmf-conversions 18887You must specify @option{-Wno-pmf-conversions} to use this extension. 18888 18889@node C++ Attributes 18890@section C++-Specific Variable, Function, and Type Attributes 18891 18892Some attributes only make sense for C++ programs. 18893 18894@table @code 18895@item abi_tag ("@var{tag}", ...) 18896@cindex @code{abi_tag} function attribute 18897@cindex @code{abi_tag} variable attribute 18898@cindex @code{abi_tag} type attribute 18899The @code{abi_tag} attribute can be applied to a function, variable, or class 18900declaration. It modifies the mangled name of the entity to 18901incorporate the tag name, in order to distinguish the function or 18902class from an earlier version with a different ABI; perhaps the class 18903has changed size, or the function has a different return type that is 18904not encoded in the mangled name. 18905 18906The attribute can also be applied to an inline namespace, but does not 18907affect the mangled name of the namespace; in this case it is only used 18908for @option{-Wabi-tag} warnings and automatic tagging of functions and 18909variables. Tagging inline namespaces is generally preferable to 18910tagging individual declarations, but the latter is sometimes 18911necessary, such as when only certain members of a class need to be 18912tagged. 18913 18914The argument can be a list of strings of arbitrary length. The 18915strings are sorted on output, so the order of the list is 18916unimportant. 18917 18918A redeclaration of an entity must not add new ABI tags, 18919since doing so would change the mangled name. 18920 18921The ABI tags apply to a name, so all instantiations and 18922specializations of a template have the same tags. The attribute will 18923be ignored if applied to an explicit specialization or instantiation. 18924 18925The @option{-Wabi-tag} flag enables a warning about a class which does 18926not have all the ABI tags used by its subobjects and virtual functions; for users with code 18927that needs to coexist with an earlier ABI, using this option can help 18928to find all affected types that need to be tagged. 18929 18930When a type involving an ABI tag is used as the type of a variable or 18931return type of a function where that tag is not already present in the 18932signature of the function, the tag is automatically applied to the 18933variable or function. @option{-Wabi-tag} also warns about this 18934situation; this warning can be avoided by explicitly tagging the 18935variable or function or moving it into a tagged inline namespace. 18936 18937@item init_priority (@var{priority}) 18938@cindex @code{init_priority} variable attribute 18939 18940In Standard C++, objects defined at namespace scope are guaranteed to be 18941initialized in an order in strict accordance with that of their definitions 18942@emph{in a given translation unit}. No guarantee is made for initializations 18943across translation units. However, GNU C++ allows users to control the 18944order of initialization of objects defined at namespace scope with the 18945@code{init_priority} attribute by specifying a relative @var{priority}, 18946a constant integral expression currently bounded between 101 and 65535 18947inclusive. Lower numbers indicate a higher priority. 18948 18949In the following example, @code{A} would normally be created before 18950@code{B}, but the @code{init_priority} attribute reverses that order: 18951 18952@smallexample 18953Some_Class A __attribute__ ((init_priority (2000))); 18954Some_Class B __attribute__ ((init_priority (543))); 18955@end smallexample 18956 18957@noindent 18958Note that the particular values of @var{priority} do not matter; only their 18959relative ordering. 18960 18961@item java_interface 18962@cindex @code{java_interface} type attribute 18963 18964This type attribute informs C++ that the class is a Java interface. It may 18965only be applied to classes declared within an @code{extern "Java"} block. 18966Calls to methods declared in this interface are dispatched using GCJ's 18967interface table mechanism, instead of regular virtual table dispatch. 18968 18969@item warn_unused 18970@cindex @code{warn_unused} type attribute 18971 18972For C++ types with non-trivial constructors and/or destructors it is 18973impossible for the compiler to determine whether a variable of this 18974type is truly unused if it is not referenced. This type attribute 18975informs the compiler that variables of this type should be warned 18976about if they appear to be unused, just like variables of fundamental 18977types. 18978 18979This attribute is appropriate for types which just represent a value, 18980such as @code{std::string}; it is not appropriate for types which 18981control a resource, such as @code{std::mutex}. 18982 18983This attribute is also accepted in C, but it is unnecessary because C 18984does not have constructors or destructors. 18985 18986@end table 18987 18988See also @ref{Namespace Association}. 18989 18990@node Function Multiversioning 18991@section Function Multiversioning 18992@cindex function versions 18993 18994With the GNU C++ front end, for x86 targets, you may specify multiple 18995versions of a function, where each function is specialized for a 18996specific target feature. At runtime, the appropriate version of the 18997function is automatically executed depending on the characteristics of 18998the execution platform. Here is an example. 18999 19000@smallexample 19001__attribute__ ((target ("default"))) 19002int foo () 19003@{ 19004 // The default version of foo. 19005 return 0; 19006@} 19007 19008__attribute__ ((target ("sse4.2"))) 19009int foo () 19010@{ 19011 // foo version for SSE4.2 19012 return 1; 19013@} 19014 19015__attribute__ ((target ("arch=atom"))) 19016int foo () 19017@{ 19018 // foo version for the Intel ATOM processor 19019 return 2; 19020@} 19021 19022__attribute__ ((target ("arch=amdfam10"))) 19023int foo () 19024@{ 19025 // foo version for the AMD Family 0x10 processors. 19026 return 3; 19027@} 19028 19029int main () 19030@{ 19031 int (*p)() = &foo; 19032 assert ((*p) () == foo ()); 19033 return 0; 19034@} 19035@end smallexample 19036 19037In the above example, four versions of function foo are created. The 19038first version of foo with the target attribute "default" is the default 19039version. This version gets executed when no other target specific 19040version qualifies for execution on a particular platform. A new version 19041of foo is created by using the same function signature but with a 19042different target string. Function foo is called or a pointer to it is 19043taken just like a regular function. GCC takes care of doing the 19044dispatching to call the right version at runtime. Refer to the 19045@uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on 19046Function Multiversioning} for more details. 19047 19048@node Namespace Association 19049@section Namespace Association 19050 19051@strong{Caution:} The semantics of this extension are equivalent 19052to C++ 2011 inline namespaces. Users should use inline namespaces 19053instead as this extension will be removed in future versions of G++. 19054 19055A using-directive with @code{__attribute ((strong))} is stronger 19056than a normal using-directive in two ways: 19057 19058@itemize @bullet 19059@item 19060Templates from the used namespace can be specialized and explicitly 19061instantiated as though they were members of the using namespace. 19062 19063@item 19064The using namespace is considered an associated namespace of all 19065templates in the used namespace for purposes of argument-dependent 19066name lookup. 19067@end itemize 19068 19069The used namespace must be nested within the using namespace so that 19070normal unqualified lookup works properly. 19071 19072This is useful for composing a namespace transparently from 19073implementation namespaces. For example: 19074 19075@smallexample 19076namespace std @{ 19077 namespace debug @{ 19078 template <class T> struct A @{ @}; 19079 @} 19080 using namespace debug __attribute ((__strong__)); 19081 template <> struct A<int> @{ @}; // @r{OK to specialize} 19082 19083 template <class T> void f (A<T>); 19084@} 19085 19086int main() 19087@{ 19088 f (std::A<float>()); // @r{lookup finds} std::f 19089 f (std::A<int>()); 19090@} 19091@end smallexample 19092 19093@node Type Traits 19094@section Type Traits 19095 19096The C++ front end implements syntactic extensions that allow 19097compile-time determination of 19098various characteristics of a type (or of a 19099pair of types). 19100 19101@table @code 19102@item __has_nothrow_assign (type) 19103If @code{type} is const qualified or is a reference type then the trait is 19104false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait 19105is true, else if @code{type} is a cv class or union type with copy assignment 19106operators that are known not to throw an exception then the trait is true, 19107else it is false. Requires: @code{type} shall be a complete type, 19108(possibly cv-qualified) @code{void}, or an array of unknown bound. 19109 19110@item __has_nothrow_copy (type) 19111If @code{__has_trivial_copy (type)} is true then the trait is true, else if 19112@code{type} is a cv class or union type with copy constructors that 19113are known not to throw an exception then the trait is true, else it is false. 19114Requires: @code{type} shall be a complete type, (possibly cv-qualified) 19115@code{void}, or an array of unknown bound. 19116 19117@item __has_nothrow_constructor (type) 19118If @code{__has_trivial_constructor (type)} is true then the trait is 19119true, else if @code{type} is a cv class or union type (or array 19120thereof) with a default constructor that is known not to throw an 19121exception then the trait is true, else it is false. Requires: 19122@code{type} shall be a complete type, (possibly cv-qualified) 19123@code{void}, or an array of unknown bound. 19124 19125@item __has_trivial_assign (type) 19126If @code{type} is const qualified or is a reference type then the trait is 19127false. Otherwise if @code{__is_pod (type)} is true then the trait is 19128true, else if @code{type} is a cv class or union type with a trivial 19129copy assignment ([class.copy]) then the trait is true, else it is 19130false. Requires: @code{type} shall be a complete type, (possibly 19131cv-qualified) @code{void}, or an array of unknown bound. 19132 19133@item __has_trivial_copy (type) 19134If @code{__is_pod (type)} is true or @code{type} is a reference type 19135then the trait is true, else if @code{type} is a cv class or union type 19136with a trivial copy constructor ([class.copy]) then the trait 19137is true, else it is false. Requires: @code{type} shall be a complete 19138type, (possibly cv-qualified) @code{void}, or an array of unknown bound. 19139 19140@item __has_trivial_constructor (type) 19141If @code{__is_pod (type)} is true then the trait is true, else if 19142@code{type} is a cv class or union type (or array thereof) with a 19143trivial default constructor ([class.ctor]) then the trait is true, 19144else it is false. Requires: @code{type} shall be a complete 19145type, (possibly cv-qualified) @code{void}, or an array of unknown bound. 19146 19147@item __has_trivial_destructor (type) 19148If @code{__is_pod (type)} is true or @code{type} is a reference type then 19149the trait is true, else if @code{type} is a cv class or union type (or 19150array thereof) with a trivial destructor ([class.dtor]) then the trait 19151is true, else it is false. Requires: @code{type} shall be a complete 19152type, (possibly cv-qualified) @code{void}, or an array of unknown bound. 19153 19154@item __has_virtual_destructor (type) 19155If @code{type} is a class type with a virtual destructor 19156([class.dtor]) then the trait is true, else it is false. Requires: 19157@code{type} shall be a complete type, (possibly cv-qualified) 19158@code{void}, or an array of unknown bound. 19159 19160@item __is_abstract (type) 19161If @code{type} is an abstract class ([class.abstract]) then the trait 19162is true, else it is false. Requires: @code{type} shall be a complete 19163type, (possibly cv-qualified) @code{void}, or an array of unknown bound. 19164 19165@item __is_base_of (base_type, derived_type) 19166If @code{base_type} is a base class of @code{derived_type} 19167([class.derived]) then the trait is true, otherwise it is false. 19168Top-level cv qualifications of @code{base_type} and 19169@code{derived_type} are ignored. For the purposes of this trait, a 19170class type is considered is own base. Requires: if @code{__is_class 19171(base_type)} and @code{__is_class (derived_type)} are true and 19172@code{base_type} and @code{derived_type} are not the same type 19173(disregarding cv-qualifiers), @code{derived_type} shall be a complete 19174type. Diagnostic is produced if this requirement is not met. 19175 19176@item __is_class (type) 19177If @code{type} is a cv class type, and not a union type 19178([basic.compound]) the trait is true, else it is false. 19179 19180@item __is_empty (type) 19181If @code{__is_class (type)} is false then the trait is false. 19182Otherwise @code{type} is considered empty if and only if: @code{type} 19183has no non-static data members, or all non-static data members, if 19184any, are bit-fields of length 0, and @code{type} has no virtual 19185members, and @code{type} has no virtual base classes, and @code{type} 19186has no base classes @code{base_type} for which 19187@code{__is_empty (base_type)} is false. Requires: @code{type} shall 19188be a complete type, (possibly cv-qualified) @code{void}, or an array 19189of unknown bound. 19190 19191@item __is_enum (type) 19192If @code{type} is a cv enumeration type ([basic.compound]) the trait is 19193true, else it is false. 19194 19195@item __is_literal_type (type) 19196If @code{type} is a literal type ([basic.types]) the trait is 19197true, else it is false. Requires: @code{type} shall be a complete type, 19198(possibly cv-qualified) @code{void}, or an array of unknown bound. 19199 19200@item __is_pod (type) 19201If @code{type} is a cv POD type ([basic.types]) then the trait is true, 19202else it is false. Requires: @code{type} shall be a complete type, 19203(possibly cv-qualified) @code{void}, or an array of unknown bound. 19204 19205@item __is_polymorphic (type) 19206If @code{type} is a polymorphic class ([class.virtual]) then the trait 19207is true, else it is false. Requires: @code{type} shall be a complete 19208type, (possibly cv-qualified) @code{void}, or an array of unknown bound. 19209 19210@item __is_standard_layout (type) 19211If @code{type} is a standard-layout type ([basic.types]) the trait is 19212true, else it is false. Requires: @code{type} shall be a complete 19213type, (possibly cv-qualified) @code{void}, or an array of unknown bound. 19214 19215@item __is_trivial (type) 19216If @code{type} is a trivial type ([basic.types]) the trait is 19217true, else it is false. Requires: @code{type} shall be a complete 19218type, (possibly cv-qualified) @code{void}, or an array of unknown bound. 19219 19220@item __is_union (type) 19221If @code{type} is a cv union type ([basic.compound]) the trait is 19222true, else it is false. 19223 19224@item __underlying_type (type) 19225The underlying type of @code{type}. Requires: @code{type} shall be 19226an enumeration type ([dcl.enum]). 19227 19228@end table 19229 19230@node Java Exceptions 19231@section Java Exceptions 19232 19233The Java language uses a slightly different exception handling model 19234from C++. Normally, GNU C++ automatically detects when you are 19235writing C++ code that uses Java exceptions, and handle them 19236appropriately. However, if C++ code only needs to execute destructors 19237when Java exceptions are thrown through it, GCC guesses incorrectly. 19238Sample problematic code is: 19239 19240@smallexample 19241 struct S @{ ~S(); @}; 19242 extern void bar(); // @r{is written in Java, and may throw exceptions} 19243 void foo() 19244 @{ 19245 S s; 19246 bar(); 19247 @} 19248@end smallexample 19249 19250@noindent 19251The usual effect of an incorrect guess is a link failure, complaining of 19252a missing routine called @samp{__gxx_personality_v0}. 19253 19254You can inform the compiler that Java exceptions are to be used in a 19255translation unit, irrespective of what it might think, by writing 19256@samp{@w{#pragma GCC java_exceptions}} at the head of the file. This 19257@samp{#pragma} must appear before any functions that throw or catch 19258exceptions, or run destructors when exceptions are thrown through them. 19259 19260You cannot mix Java and C++ exceptions in the same translation unit. It 19261is believed to be safe to throw a C++ exception from one file through 19262another file compiled for the Java exception model, or vice versa, but 19263there may be bugs in this area. 19264 19265@node Deprecated Features 19266@section Deprecated Features 19267 19268In the past, the GNU C++ compiler was extended to experiment with new 19269features, at a time when the C++ language was still evolving. Now that 19270the C++ standard is complete, some of those features are superseded by 19271superior alternatives. Using the old features might cause a warning in 19272some cases that the feature will be dropped in the future. In other 19273cases, the feature might be gone already. 19274 19275While the list below is not exhaustive, it documents some of the options 19276that are now deprecated: 19277 19278@table @code 19279@item -fexternal-templates 19280@itemx -falt-external-templates 19281These are two of the many ways for G++ to implement template 19282instantiation. @xref{Template Instantiation}. The C++ standard clearly 19283defines how template definitions have to be organized across 19284implementation units. G++ has an implicit instantiation mechanism that 19285should work just fine for standard-conforming code. 19286 19287@item -fstrict-prototype 19288@itemx -fno-strict-prototype 19289Previously it was possible to use an empty prototype parameter list to 19290indicate an unspecified number of parameters (like C), rather than no 19291parameters, as C++ demands. This feature has been removed, except where 19292it is required for backwards compatibility. @xref{Backwards Compatibility}. 19293@end table 19294 19295G++ allows a virtual function returning @samp{void *} to be overridden 19296by one returning a different pointer type. This extension to the 19297covariant return type rules is now deprecated and will be removed from a 19298future version. 19299 19300The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and 19301their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated 19302and are now removed from G++. Code using these operators should be 19303modified to use @code{std::min} and @code{std::max} instead. 19304 19305The named return value extension has been deprecated, and is now 19306removed from G++. 19307 19308The use of initializer lists with new expressions has been deprecated, 19309and is now removed from G++. 19310 19311Floating and complex non-type template parameters have been deprecated, 19312and are now removed from G++. 19313 19314The implicit typename extension has been deprecated and is now 19315removed from G++. 19316 19317The use of default arguments in function pointers, function typedefs 19318and other places where they are not permitted by the standard is 19319deprecated and will be removed from a future version of G++. 19320 19321G++ allows floating-point literals to appear in integral constant expressions, 19322e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} } 19323This extension is deprecated and will be removed from a future version. 19324 19325G++ allows static data members of const floating-point type to be declared 19326with an initializer in a class definition. The standard only allows 19327initializers for static members of const integral types and const 19328enumeration types so this extension has been deprecated and will be removed 19329from a future version. 19330 19331@node Backwards Compatibility 19332@section Backwards Compatibility 19333@cindex Backwards Compatibility 19334@cindex ARM [Annotated C++ Reference Manual] 19335 19336Now that there is a definitive ISO standard C++, G++ has a specification 19337to adhere to. The C++ language evolved over time, and features that 19338used to be acceptable in previous drafts of the standard, such as the ARM 19339[Annotated C++ Reference Manual], are no longer accepted. In order to allow 19340compilation of C++ written to such drafts, G++ contains some backwards 19341compatibilities. @emph{All such backwards compatibility features are 19342liable to disappear in future versions of G++.} They should be considered 19343deprecated. @xref{Deprecated Features}. 19344 19345@table @code 19346@item For scope 19347If a variable is declared at for scope, it used to remain in scope until 19348the end of the scope that contained the for statement (rather than just 19349within the for scope). G++ retains this, but issues a warning, if such a 19350variable is accessed outside the for scope. 19351 19352@item Implicit C language 19353Old C system header files did not contain an @code{extern "C" @{@dots{}@}} 19354scope to set the language. On such systems, all header files are 19355implicitly scoped inside a C language scope. Also, an empty prototype 19356@code{()} is treated as an unspecified number of arguments, rather 19357than no arguments, as C++ demands. 19358@end table 19359 19360@c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd 19361@c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr 19362