2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
6 .. _x86-function-attributes:
8 x86 Function Attributes
9 ^^^^^^^^^^^^^^^^^^^^^^^
11 These function attributes are supported by the x86 back end:
13 .. index:: cdecl function attribute, x86-32, functions that pop the argument stack on x86-32
17 On the x86-32 targets, the ``cdecl`` attribute causes the compiler to
18 assume that the calling function pops off the stack space used to
19 pass arguments. This is
20 useful to override the effects of the :option:`-mrtd` switch.
22 .. index:: fastcall function attribute, x86-32, functions that pop the argument stack on x86-32
24 .. x86-fn-attr:: fastcall
26 On x86-32 targets, the :x86-fn-attr:`fastcall` attribute causes the compiler to
27 pass the first argument (if of integral type) in the register ECX and
28 the second argument (if of integral type) in the register EDX. Subsequent
29 and other typed arguments are passed on the stack. The called function
30 pops the arguments off the stack. If the number of arguments is variable all
31 arguments are pushed on the stack.
33 .. index:: thiscall function attribute, x86-32, functions that pop the argument stack on x86-32
35 .. x86-fn-attr:: thiscall
37 On x86-32 targets, the :x86-fn-attr:`thiscall` attribute causes the compiler to
38 pass the first argument (if of integral type) in the register ECX.
39 Subsequent and other typed arguments are passed on the stack. The called
40 function pops the arguments off the stack.
41 If the number of arguments is variable all arguments are pushed on the
43 The :x86-fn-attr:`thiscall` attribute is intended for C++ non-static member functions.
44 As a GCC extension, this calling convention can be used for C functions
45 and for static member methods.
47 .. index:: ms_abi function attribute, x86, sysv_abi function attribute, x86
49 .. x86-fn-attr:: ms_abi, sysv_abi
51 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
52 to indicate which calling convention should be used for a function. The
53 :x86-fn-attr:`ms_abi` attribute tells the compiler to use the Microsoft ABI,
54 while the ``sysv_abi`` attribute tells the compiler to use the System V
55 ELF ABI, which is used on GNU/Linux and other systems. The default is to use
56 the Microsoft ABI when targeting Windows. On all other systems, the default
57 is the System V ELF ABI.
59 Note, the :x86-fn-attr:`ms_abi` attribute for Microsoft Windows 64-bit targets currently
60 requires the :option:`-maccumulate-outgoing-args` option.
62 .. index:: callee_pop_aggregate_return function attribute, x86
64 .. x86-fn-attr:: callee_pop_aggregate_return (number)
66 On x86-32 targets, you can use this attribute to control how
67 aggregates are returned in memory. If the caller is responsible for
68 popping the hidden pointer together with the rest of the arguments, specify
69 :samp:`{number}` equal to zero. If callee is responsible for popping the
70 hidden pointer, specify :samp:`{number}` equal to one.
72 The default x86-32 ABI assumes that the callee pops the
73 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
74 the compiler assumes that the
75 caller pops the stack for hidden pointer.
77 .. index:: ms_hook_prologue function attribute, x86
79 .. x86-fn-attr:: ms_hook_prologue
81 On 32-bit and 64-bit x86 targets, you can use
82 this function attribute to make GCC generate the 'hot-patching' function
83 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
86 .. index:: naked function attribute, x86
88 .. x86-fn-attr:: naked
90 This attribute allows the compiler to construct the
91 requisite function declaration, while allowing the body of the
92 function to be assembly code. The specified function will not have
93 prologue/epilogue sequences generated by the compiler. Only basic
94 ``asm`` statements can safely be included in naked functions
95 (see :ref:`basic-asm`). While using extended ``asm`` or a mixture of
96 basic ``asm`` and C code may appear to work, they cannot be
97 depended upon to work reliably and are not supported.
99 .. index:: regparm function attribute, x86, functions that are passed arguments in registers on x86-32
101 .. x86-fn-attr:: regparm (number)
103 On x86-32 targets, the ``regparm`` attribute causes the compiler to
104 pass arguments number one to :samp:`{number}` if they are of integral type
105 in registers EAX, EDX, and ECX instead of on the stack. Functions that
106 take a variable number of arguments continue to be passed all of their
107 arguments on the stack.
109 Beware that on some ELF systems this attribute is unsuitable for
110 global functions in shared libraries with lazy binding (which is the
111 default). Lazy binding sends the first call via resolving code in
112 the loader, which might assume EAX, EDX and ECX can be clobbered, as
113 per the standard calling conventions. Solaris 8 is affected by this.
114 Systems with the GNU C Library version 2.1 or higher
115 and FreeBSD are believed to be
116 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
117 disabled with the linker or the loader if desired, to avoid the
120 .. index:: sseregparm function attribute, x86
122 .. x86-fn-attr:: sseregparm
124 On x86-32 targets with SSE support, the :x86-fn-attr:`sseregparm` attribute
125 causes the compiler to pass up to 3 floating-point arguments in
126 SSE registers instead of on the stack. Functions that take a
127 variable number of arguments continue to pass all of their
128 floating-point arguments on the stack.
130 .. index:: force_align_arg_pointer function attribute, x86
132 .. x86-fn-attr:: force_align_arg_pointer
134 On x86 targets, the :x86-fn-attr:`force_align_arg_pointer` attribute may be
135 applied to individual function definitions, generating an alternate
136 prologue and epilogue that realigns the run-time stack if necessary.
137 This supports mixing legacy codes that run with a 4-byte aligned stack
138 with modern codes that keep a 16-byte stack for SSE compatibility.
140 .. index:: stdcall function attribute, x86-32, functions that pop the argument stack on x86-32
142 .. x86-fn-attr:: stdcall
144 On x86-32 targets, the :x86-fn-attr:`stdcall` attribute causes the compiler to
145 assume that the called function pops off the stack space used to
146 pass arguments, unless it takes a variable number of arguments.
148 .. index:: no_caller_saved_registers function attribute, x86
150 .. x86-fn-attr:: no_caller_saved_registers
152 Use this attribute to indicate that the specified function has no
153 caller-saved registers. That is, all registers are callee-saved. For
154 example, this attribute can be used for a function called from an
155 interrupt handler. The compiler generates proper function entry and
156 exit sequences to save and restore any modified registers, except for
157 the EFLAGS register. Since GCC doesn't preserve SSE, MMX nor x87
158 states, the GCC option :option:`-mgeneral-regs-only` should be used to
159 compile functions with :x86-fn-attr:`no_caller_saved_registers` attribute.
161 .. index:: interrupt function attribute, x86
163 .. x86-fn-attr:: interrupt
165 Use this attribute to indicate that the specified function is an
166 interrupt handler or an exception handler (depending on parameters passed
167 to the function, explained further). The compiler generates function
168 entry and exit sequences suitable for use in an interrupt handler when
169 this attribute is present. The ``IRET`` instruction, instead of the
170 ``RET`` instruction, is used to return from interrupt handlers. All
171 registers, except for the EFLAGS register which is restored by the
172 ``IRET`` instruction, are preserved by the compiler. Since GCC
173 doesn't preserve SSE, MMX nor x87 states, the GCC option
174 :option:`-mgeneral-regs-only` should be used to compile interrupt and
177 Any interruptible-without-stack-switch code must be compiled with
178 :option:`-mno-red-zone` since interrupt handlers can and will, because
179 of the hardware design, touch the red zone.
181 An interrupt handler must be declared with a mandatory pointer
186 struct interrupt_frame;
188 __attribute__ ((interrupt))
190 f (struct interrupt_frame *frame)
194 and you must define ``struct interrupt_frame`` as described in the
197 Exception handlers differ from interrupt handlers because the system
198 pushes an error code on the stack. An exception handler declaration is
199 similar to that for an interrupt handler, but with a different mandatory
200 function signature. The compiler arranges to pop the error code off the
201 stack before the ``IRET`` instruction.
206 typedef unsigned long long int uword_t;
208 typedef unsigned int uword_t;
211 struct interrupt_frame;
213 __attribute__ ((interrupt))
215 f (struct interrupt_frame *frame, uword_t error_code)
220 Exception handlers should only be used for exceptions that push an error
221 code; you should use an interrupt handler in other cases. The system
222 will crash if the wrong kind of handler is used.
224 .. index:: target function attribute
226 .. x86-fn-attr:: target (options)
228 As discussed in :ref:`common-function-attributes`, this attribute
229 allows specification of target-specific compilation options.
231 On the x86, the following options are allowed:
233 :samp:`3dnow` :samp:`no-3dnow`
235 .. index:: target("3dnow") function attribute, x86
237 Enable/disable the generation of the 3DNow! instructions.
239 :samp:`3dnowa` :samp:`no-3dnowa`
241 .. index:: target("3dnowa") function attribute, x86
243 Enable/disable the generation of the enhanced 3DNow! instructions.
245 :samp:`abm` :samp:`no-abm`
247 .. index:: target("abm") function attribute, x86
249 Enable/disable the generation of the advanced bit instructions.
251 :samp:`adx` :samp:`no-adx`
253 .. index:: target("adx") function attribute, x86
255 Enable/disable the generation of the ADX instructions.
257 :samp:`aes` :samp:`no-aes`
259 .. index:: target("aes") function attribute, x86
261 Enable/disable the generation of the AES instructions.
263 :samp:`avx` :samp:`no-avx`
265 .. index:: target("avx") function attribute, x86
267 Enable/disable the generation of the AVX instructions.
269 :samp:`avx2` :samp:`no-avx2`
271 .. index:: target("avx2") function attribute, x86
273 Enable/disable the generation of the AVX2 instructions.
275 :samp:`avx5124fmaps` :samp:`no-avx5124fmaps`
277 .. index:: target("avx5124fmaps") function attribute, x86
279 Enable/disable the generation of the AVX5124FMAPS instructions.
281 :samp:`avx5124vnniw` :samp:`no-avx5124vnniw`
283 .. index:: target("avx5124vnniw") function attribute, x86
285 Enable/disable the generation of the AVX5124VNNIW instructions.
287 :samp:`avx512bitalg` :samp:`no-avx512bitalg`
289 .. index:: target("avx512bitalg") function attribute, x86
291 Enable/disable the generation of the AVX512BITALG instructions.
293 :samp:`avx512bw` :samp:`no-avx512bw`
295 .. index:: target("avx512bw") function attribute, x86
297 Enable/disable the generation of the AVX512BW instructions.
299 :samp:`avx512cd` :samp:`no-avx512cd`
301 .. index:: target("avx512cd") function attribute, x86
303 Enable/disable the generation of the AVX512CD instructions.
305 :samp:`avx512dq` :samp:`no-avx512dq`
307 .. index:: target("avx512dq") function attribute, x86
309 Enable/disable the generation of the AVX512DQ instructions.
311 :samp:`avx512er` :samp:`no-avx512er`
313 .. index:: target("avx512er") function attribute, x86
315 Enable/disable the generation of the AVX512ER instructions.
317 :samp:`avx512f` :samp:`no-avx512f`
319 .. index:: target("avx512f") function attribute, x86
321 Enable/disable the generation of the AVX512F instructions.
323 :samp:`avx512ifma` :samp:`no-avx512ifma`
325 .. index:: target("avx512ifma") function attribute, x86
327 Enable/disable the generation of the AVX512IFMA instructions.
329 :samp:`avx512pf` :samp:`no-avx512pf`
331 .. index:: target("avx512pf") function attribute, x86
333 Enable/disable the generation of the AVX512PF instructions.
335 :samp:`avx512vbmi` :samp:`no-avx512vbmi`
337 .. index:: target("avx512vbmi") function attribute, x86
339 Enable/disable the generation of the AVX512VBMI instructions.
341 :samp:`avx512vbmi2` :samp:`no-avx512vbmi2`
343 .. index:: target("avx512vbmi2") function attribute, x86
345 Enable/disable the generation of the AVX512VBMI2 instructions.
347 :samp:`avx512vl` :samp:`no-avx512vl`
349 .. index:: target("avx512vl") function attribute, x86
351 Enable/disable the generation of the AVX512VL instructions.
353 :samp:`avx512vnni` :samp:`no-avx512vnni`
355 .. index:: target("avx512vnni") function attribute, x86
357 Enable/disable the generation of the AVX512VNNI instructions.
359 :samp:`avx512vpopcntdq` :samp:`no-avx512vpopcntdq`
361 .. index:: target("avx512vpopcntdq") function attribute, x86
363 Enable/disable the generation of the AVX512VPOPCNTDQ instructions.
365 :samp:`bmi` :samp:`no-bmi`
367 .. index:: target("bmi") function attribute, x86
369 Enable/disable the generation of the BMI instructions.
371 :samp:`bmi2` :samp:`no-bmi2`
373 .. index:: target("bmi2") function attribute, x86
375 Enable/disable the generation of the BMI2 instructions.
377 :samp:`cldemote` :samp:`no-cldemote`
379 .. index:: target("cldemote") function attribute, x86
381 Enable/disable the generation of the CLDEMOTE instructions.
383 :samp:`clflushopt` :samp:`no-clflushopt`
385 .. index:: target("clflushopt") function attribute, x86
387 Enable/disable the generation of the CLFLUSHOPT instructions.
389 :samp:`clwb` :samp:`no-clwb`
391 .. index:: target("clwb") function attribute, x86
393 Enable/disable the generation of the CLWB instructions.
395 :samp:`clzero` :samp:`no-clzero`
397 .. index:: target("clzero") function attribute, x86
399 Enable/disable the generation of the CLZERO instructions.
401 :samp:`crc32` :samp:`no-crc32`
403 .. index:: target("crc32") function attribute, x86
405 Enable/disable the generation of the CRC32 instructions.
407 :samp:`cx16` :samp:`no-cx16`
409 .. index:: target("cx16") function attribute, x86
411 Enable/disable the generation of the CMPXCHG16B instructions.
415 .. index:: target("default") function attribute, x86
417 See :ref:`function-multiversioning`, where it is used to specify the
418 default function version.
420 :samp:`f16c` :samp:`no-f16c`
422 .. index:: target("f16c") function attribute, x86
424 Enable/disable the generation of the F16C instructions.
426 :samp:`fma` :samp:`no-fma`
428 .. index:: target("fma") function attribute, x86
430 Enable/disable the generation of the FMA instructions.
432 :samp:`fma4` :samp:`no-fma4`
434 .. index:: target("fma4") function attribute, x86
436 Enable/disable the generation of the FMA4 instructions.
438 :samp:`fsgsbase` :samp:`no-fsgsbase`
440 .. index:: target("fsgsbase") function attribute, x86
442 Enable/disable the generation of the FSGSBASE instructions.
444 :samp:`fxsr` :samp:`no-fxsr`
446 .. index:: target("fxsr") function attribute, x86
448 Enable/disable the generation of the FXSR instructions.
450 :samp:`gfni` :samp:`no-gfni`
452 .. index:: target("gfni") function attribute, x86
454 Enable/disable the generation of the GFNI instructions.
456 :samp:`hle` :samp:`no-hle`
458 .. index:: target("hle") function attribute, x86
460 Enable/disable the generation of the HLE instruction prefixes.
462 :samp:`lwp` :samp:`no-lwp`
464 .. index:: target("lwp") function attribute, x86
466 Enable/disable the generation of the LWP instructions.
468 :samp:`lzcnt` :samp:`no-lzcnt`
470 .. index:: target("lzcnt") function attribute, x86
472 Enable/disable the generation of the LZCNT instructions.
474 :samp:`mmx` :samp:`no-mmx`
476 .. index:: target("mmx") function attribute, x86
478 Enable/disable the generation of the MMX instructions.
480 :samp:`movbe` :samp:`no-movbe`
482 .. index:: target("movbe") function attribute, x86
484 Enable/disable the generation of the MOVBE instructions.
486 :samp:`movdir64b` :samp:`no-movdir64b`
488 .. index:: target("movdir64b") function attribute, x86
490 Enable/disable the generation of the MOVDIR64B instructions.
492 :samp:`movdiri` :samp:`no-movdiri`
494 .. index:: target("movdiri") function attribute, x86
496 Enable/disable the generation of the MOVDIRI instructions.
498 :samp:`mwait` :samp:`no-mwait`
500 .. index:: target("mwait") function attribute, x86
502 Enable/disable the generation of the MWAIT and MONITOR instructions.
504 :samp:`mwaitx` :samp:`no-mwaitx`
506 .. index:: target("mwaitx") function attribute, x86
508 Enable/disable the generation of the MWAITX instructions.
510 :samp:`pclmul` :samp:`no-pclmul`
512 .. index:: target("pclmul") function attribute, x86
514 Enable/disable the generation of the PCLMUL instructions.
516 :samp:`pconfig` :samp:`no-pconfig`
518 .. index:: target("pconfig") function attribute, x86
520 Enable/disable the generation of the PCONFIG instructions.
522 :samp:`pku` :samp:`no-pku`
524 .. index:: target("pku") function attribute, x86
526 Enable/disable the generation of the PKU instructions.
528 :samp:`popcnt` :samp:`no-popcnt`
530 .. index:: target("popcnt") function attribute, x86
532 Enable/disable the generation of the POPCNT instruction.
534 :samp:`prefetchwt1` :samp:`no-prefetchwt1`
536 .. index:: target("prefetchwt1") function attribute, x86
538 Enable/disable the generation of the PREFETCHWT1 instructions.
540 :samp:`prfchw` :samp:`no-prfchw`
542 .. index:: target("prfchw") function attribute, x86
544 Enable/disable the generation of the PREFETCHW instruction.
546 :samp:`ptwrite` :samp:`no-ptwrite`
548 .. index:: target("ptwrite") function attribute, x86
550 Enable/disable the generation of the PTWRITE instructions.
552 :samp:`rdpid` :samp:`no-rdpid`
554 .. index:: target("rdpid") function attribute, x86
556 Enable/disable the generation of the RDPID instructions.
558 :samp:`rdrnd` :samp:`no-rdrnd`
560 .. index:: target("rdrnd") function attribute, x86
562 Enable/disable the generation of the RDRND instructions.
564 :samp:`rdseed` :samp:`no-rdseed`
566 .. index:: target("rdseed") function attribute, x86
568 Enable/disable the generation of the RDSEED instructions.
570 :samp:`rtm` :samp:`no-rtm`
572 .. index:: target("rtm") function attribute, x86
574 Enable/disable the generation of the RTM instructions.
576 :samp:`sahf` :samp:`no-sahf`
578 .. index:: target("sahf") function attribute, x86
580 Enable/disable the generation of the SAHF instructions.
582 :samp:`sgx` :samp:`no-sgx`
584 .. index:: target("sgx") function attribute, x86
586 Enable/disable the generation of the SGX instructions.
588 :samp:`sha` :samp:`no-sha`
590 .. index:: target("sha") function attribute, x86
592 Enable/disable the generation of the SHA instructions.
594 :samp:`shstk` :samp:`no-shstk`
596 .. index:: target("shstk") function attribute, x86
598 Enable/disable the shadow stack built-in functions from CET.
600 :samp:`sse` :samp:`no-sse`
602 .. index:: target("sse") function attribute, x86
604 Enable/disable the generation of the SSE instructions.
606 :samp:`sse2` :samp:`no-sse2`
608 .. index:: target("sse2") function attribute, x86
610 Enable/disable the generation of the SSE2 instructions.
612 :samp:`sse3` :samp:`no-sse3`
614 .. index:: target("sse3") function attribute, x86
616 Enable/disable the generation of the SSE3 instructions.
618 :samp:`sse4` :samp:`no-sse4`
620 .. index:: target("sse4") function attribute, x86
622 Enable/disable the generation of the SSE4 instructions (both SSE4.1
625 :samp:`sse4.1` :samp:`no-sse4.1`
627 .. index:: target("sse4.1") function attribute, x86
629 Enable/disable the generation of the SSE4.1 instructions.
631 :samp:`sse4.2` :samp:`no-sse4.2`
633 .. index:: target("sse4.2") function attribute, x86
635 Enable/disable the generation of the SSE4.2 instructions.
637 :samp:`sse4a` :samp:`no-sse4a`
639 .. index:: target("sse4a") function attribute, x86
641 Enable/disable the generation of the SSE4A instructions.
643 :samp:`ssse3` :samp:`no-ssse3`
645 .. index:: target("ssse3") function attribute, x86
647 Enable/disable the generation of the SSSE3 instructions.
649 :samp:`tbm` :samp:`no-tbm`
651 .. index:: target("tbm") function attribute, x86
653 Enable/disable the generation of the TBM instructions.
655 :samp:`vaes` :samp:`no-vaes`
657 .. index:: target("vaes") function attribute, x86
659 Enable/disable the generation of the VAES instructions.
661 :samp:`vpclmulqdq` :samp:`no-vpclmulqdq`
663 .. index:: target("vpclmulqdq") function attribute, x86
665 Enable/disable the generation of the VPCLMULQDQ instructions.
667 :samp:`waitpkg` :samp:`no-waitpkg`
669 .. index:: target("waitpkg") function attribute, x86
671 Enable/disable the generation of the WAITPKG instructions.
673 :samp:`wbnoinvd` :samp:`no-wbnoinvd`
675 .. index:: target("wbnoinvd") function attribute, x86
677 Enable/disable the generation of the WBNOINVD instructions.
679 :samp:`xop` :samp:`no-xop`
681 .. index:: target("xop") function attribute, x86
683 Enable/disable the generation of the XOP instructions.
685 :samp:`xsave` :samp:`no-xsave`
687 .. index:: target("xsave") function attribute, x86
689 Enable/disable the generation of the XSAVE instructions.
691 :samp:`xsavec` :samp:`no-xsavec`
693 .. index:: target("xsavec") function attribute, x86
695 Enable/disable the generation of the XSAVEC instructions.
697 :samp:`xsaveopt` :samp:`no-xsaveopt`
699 .. index:: target("xsaveopt") function attribute, x86
701 Enable/disable the generation of the XSAVEOPT instructions.
703 :samp:`xsaves` :samp:`no-xsaves`
705 .. index:: target("xsaves") function attribute, x86
707 Enable/disable the generation of the XSAVES instructions.
709 :samp:`amx-tile` :samp:`no-amx-tile`
711 .. index:: target("amx-tile") function attribute, x86
713 Enable/disable the generation of the AMX-TILE instructions.
715 :samp:`amx-int8` :samp:`no-amx-int8`
717 .. index:: target("amx-int8") function attribute, x86
719 Enable/disable the generation of the AMX-INT8 instructions.
721 :samp:`amx-bf16` :samp:`no-amx-bf16`
723 .. index:: target("amx-bf16") function attribute, x86
725 Enable/disable the generation of the AMX-BF16 instructions.
727 :samp:`uintr` :samp:`no-uintr`
729 .. index:: target("uintr") function attribute, x86
731 Enable/disable the generation of the UINTR instructions.
733 :samp:`hreset` :samp:`no-hreset`
735 .. index:: target("hreset") function attribute, x86
737 Enable/disable the generation of the HRESET instruction.
739 :samp:`kl` :samp:`no-kl`
741 .. index:: target("kl") function attribute, x86
743 Enable/disable the generation of the KEYLOCKER instructions.
745 :samp:`widekl` :samp:`no-widekl`
747 .. index:: target("widekl") function attribute, x86
749 Enable/disable the generation of the WIDEKL instructions.
751 :samp:`avxvnni` :samp:`no-avxvnni`
753 .. index:: target("avxvnni") function attribute, x86
755 Enable/disable the generation of the AVXVNNI instructions.
757 :samp:`avxifma` :samp:`no-avxifma`
759 .. index:: target("avxifma") function attribute, x86
761 Enable/disable the generation of the AVXIFMA instructions.
763 :samp:`avxvnniint8` :samp:`no-avxvnniint8`
765 .. index:: target("avxvnniint8") function attribute, x86
767 Enable/disable the generation of the AVXVNNIINT8 instructions.
769 :samp:`avxneconvert` :samp:`no-avxneconvert`
771 .. index:: target("avxneconvert") function attribute, x86
773 Enable/disable the generation of the AVXNECONVERT instructions.
775 :samp:`cmpccxadd` :samp:`no-cmpccxadd`
777 .. index:: target("cmpccxadd") function attribute, x86
779 Enable/disable the generation of the CMPccXADD instructions.
781 :samp:`amx-fp16` :samp:`no-amx-fp16`
783 .. index:: target("amx-fp16") function attribute, x86
785 Enable/disable the generation of the AMX-FP16 instructions.
787 :samp:`prefetchi` :samp:`no-prefetchi`
789 .. index:: target("prefetchi") function attribute, x86
791 Enable/disable the generation of the PREFETCHI instructions.
793 :samp:`raoint` :samp:`no-raoint`
795 .. index:: target("raoint") function attribute, x86
797 Enable/disable the generation of the RAOINT instructions.
799 :samp:`cld` :samp:`no-cld`
801 .. index:: target("cld") function attribute, x86
803 Enable/disable the generation of the CLD before string moves.
805 :samp:`fancy-math-387` :samp:`no-fancy-math-387`
807 .. index:: target("fancy-math-387") function attribute, x86
809 Enable/disable the generation of the ``sin``, ``cos``, and
810 ``sqrt`` instructions on the 387 floating-point unit.
812 :samp:`ieee-fp` :samp:`no-ieee-fp`
814 .. index:: target("ieee-fp") function attribute, x86
816 Enable/disable the generation of floating point that depends on IEEE arithmetic.
818 :samp:`inline-all-stringops` :samp:`no-inline-all-stringops`
820 .. index:: target("inline-all-stringops") function attribute, x86
822 Enable/disable inlining of string operations.
824 :samp:`inline-stringops-dynamically` :samp:`no-inline-stringops-dynamically`
826 .. index:: target("inline-stringops-dynamically") function attribute, x86
828 Enable/disable the generation of the inline code to do small string
829 operations and calling the library routines for large operations.
831 :samp:`align-stringops` :samp:`no-align-stringops`
833 .. index:: target("align-stringops") function attribute, x86
835 Do/do not align destination of inlined string operations.
837 :samp:`recip` :samp:`no-recip`
839 .. index:: target("recip") function attribute, x86
841 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
842 instructions followed an additional Newton-Raphson step instead of
843 doing a floating-point division.
845 :samp:`general-regs-only`
847 .. index:: target("general-regs-only") function attribute, x86
849 Generate code which uses only the general registers.
853 .. index:: target("arch=ARCH") function attribute, x86
855 Specify the architecture to generate code for in compiling the function.
859 .. index:: target("tune=TUNE") function attribute, x86
861 Specify the architecture to tune for in compiling the function.
863 :samp:`fpmath={FPMATH}`
865 .. index:: target("fpmath=FPMATH") function attribute, x86
867 Specify which floating-point unit to use. You must specify the
868 ``target("fpmath=sse,387")`` option as
869 ``target("fpmath=sse+387")`` because the comma would separate
872 :samp:`prefer-vector-width={OPT}`
874 .. index:: prefer-vector-width function attribute, x86
876 On x86 targets, the ``prefer-vector-width`` attribute informs the
877 compiler to use :samp:`{OPT}` -bit vector width in instructions
878 instead of the default on the selected platform.
880 Valid :samp:`{OPT}` values are:
883 No extra limitations applied to GCC other than defined by the selected platform.
886 Prefer 128-bit vector width for instructions.
889 Prefer 256-bit vector width for instructions.
892 Prefer 512-bit vector width for instructions.
894 On the x86, the inliner does not inline a
895 function that has different target options than the caller, unless the
896 callee has a subset of the target options of the caller. For example
897 a function declared with ``target("sse3")`` can inline a function
898 with ``target("sse2")``, since ``-msse3`` implies ``-msse2``.
900 .. index:: indirect_branch function attribute, x86
902 .. x86-fn-attr:: indirect_branch("choice")
904 On x86 targets, the ``indirect_branch`` attribute causes the compiler
905 to convert indirect call and jump with :samp:`{choice}`. :samp:`keep`
906 keeps indirect call and jump unmodified. :samp:`thunk` converts indirect
907 call and jump to call and return thunk. :samp:`thunk-inline` converts
908 indirect call and jump to inlined call and return thunk.
909 :samp:`thunk-extern` converts indirect call and jump to external call
910 and return thunk provided in a separate object file.
912 .. index:: function_return function attribute, x86
914 .. x86-fn-attr:: function_return("choice")
916 On x86 targets, the ``function_return`` attribute causes the compiler
917 to convert function return with :samp:`{choice}`. :samp:`keep` keeps function
918 return unmodified. :samp:`thunk` converts function return to call and
919 return thunk. :samp:`thunk-inline` converts function return to inlined
920 call and return thunk. :samp:`thunk-extern` converts function return to
921 external call and return thunk provided in a separate object file.
923 .. index:: nocf_check function attribute
925 .. x86-fn-attr:: nocf_check
927 The :x86-fn-attr:`nocf_check` attribute on a function is used to inform the
928 compiler that the function's prologue should not be instrumented when
929 compiled with the :option:`-fcf-protection=branch` option. The
930 compiler assumes that the function's address is a valid target for a
931 control-flow transfer.
933 The :x86-fn-attr:`nocf_check` attribute on a type of pointer to function is
934 used to inform the compiler that a call through the pointer should
935 not be instrumented when compiled with the
936 :option:`-fcf-protection=branch` option. The compiler assumes
937 that the function's address from the pointer is a valid target for
938 a control-flow transfer. A direct function call through a function
939 name is assumed to be a safe call thus direct calls are not
940 instrumented by the compiler.
942 The :x86-fn-attr:`nocf_check` attribute is applied to an object's type.
943 In case of assignment of a function address or a function pointer to
944 another pointer, the attribute is not carried over from the right-hand
945 object's type; the type of left-hand object stays unchanged. The
946 compiler checks for :x86-fn-attr:`nocf_check` attribute mismatch and reports
947 a warning in case of mismatch.
952 int foo (void) __attribute__(nocf_check);
953 void (*foo1)(void) __attribute__(nocf_check);
956 /* foo's address is assumed to be valid. */
960 /* This call site is not checked for control-flow
964 /* A warning is issued about attribute mismatch. */
967 /* This call site is still not checked. */
970 /* This call site is checked. */
973 /* A warning is issued about attribute mismatch. */
976 /* This call site is still checked. */
982 .. index:: cf_check function attribute, x86
984 .. x86-fn-attr:: cf_check
986 The :x86-fn-attr:`cf_check` attribute on a function is used to inform the
987 compiler that ENDBR instruction should be placed at the function
988 entry when :option:`-fcf-protection=branch` is enabled.
990 .. index:: indirect_return function attribute, x86
992 .. x86-fn-attr:: indirect_return
994 The :x86-fn-attr:`indirect_return` attribute can be applied to a function,
995 as well as variable or type of function pointer to inform the
996 compiler that the function may return via indirect branch.
998 .. index:: fentry_name function attribute, x86
1000 .. x86-fn-attr:: fentry_name("name")
1002 On x86 targets, the ``fentry_name`` attribute sets the function to
1003 call on function entry when function instrumentation is enabled
1004 with :option:`-pg -mfentry`. When :samp:`{name}` is nop then a 5 byte
1005 nop sequence is generated.
1007 .. index:: fentry_section function attribute, x86
1009 .. x86-fn-attr:: fentry_section("name")
1011 On x86 targets, the ``fentry_section`` attribute sets the name
1012 of the section to record function entry instrumentation calls in when
1013 enabled with :option:`-pg -mrecord-mcount`
1015 .. index:: nodirect_extern_access function attribute
1017 .. option:: nodirect_extern_access
1019 This attribute, attached to a global variable or function, is the
1020 counterpart to option :option:`-mno-direct-extern-access`.