]> git.ipfire.org Git - thirdparty/gcc.git/blob
b1a1861c6e0906094eac368c614466effa205d55
[thirdparty/gcc.git] /
1 ..
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.
5
6 .. _x86-function-attributes:
7
8 x86 Function Attributes
9 ^^^^^^^^^^^^^^^^^^^^^^^
10
11 These function attributes are supported by the x86 back end:
12
13 .. index:: cdecl function attribute, x86-32, functions that pop the argument stack on x86-32
14
15 .. option:: cdecl
16
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.
21
22 .. index:: fastcall function attribute, x86-32, functions that pop the argument stack on x86-32
23
24 .. x86-fn-attr:: fastcall
25
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.
32
33 .. index:: thiscall function attribute, x86-32, functions that pop the argument stack on x86-32
34
35 .. x86-fn-attr:: thiscall
36
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
42 stack.
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.
46
47 .. index:: ms_abi function attribute, x86, sysv_abi function attribute, x86
48
49 .. x86-fn-attr:: ms_abi, sysv_abi
50
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.
58
59 Note, the :x86-fn-attr:`ms_abi` attribute for Microsoft Windows 64-bit targets currently
60 requires the :option:`-maccumulate-outgoing-args` option.
61
62 .. index:: callee_pop_aggregate_return function attribute, x86
63
64 .. x86-fn-attr:: callee_pop_aggregate_return (number)
65
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.
71
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.
76
77 .. index:: ms_hook_prologue function attribute, x86
78
79 .. x86-fn-attr:: ms_hook_prologue
80
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
84 and newer.
85
86 .. index:: naked function attribute, x86
87
88 .. x86-fn-attr:: naked
89
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.
98
99 .. index:: regparm function attribute, x86, functions that are passed arguments in registers on x86-32
100
101 .. x86-fn-attr:: regparm (number)
102
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.
108
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
118 problem.)
119
120 .. index:: sseregparm function attribute, x86
121
122 .. x86-fn-attr:: sseregparm
123
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.
129
130 .. index:: force_align_arg_pointer function attribute, x86
131
132 .. x86-fn-attr:: force_align_arg_pointer
133
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.
139
140 .. index:: stdcall function attribute, x86-32, functions that pop the argument stack on x86-32
141
142 .. x86-fn-attr:: stdcall
143
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.
147
148 .. index:: no_caller_saved_registers function attribute, x86
149
150 .. x86-fn-attr:: no_caller_saved_registers
151
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.
160
161 .. index:: interrupt function attribute, x86
162
163 .. x86-fn-attr:: interrupt
164
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
175 exception handlers.
176
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.
180
181 An interrupt handler must be declared with a mandatory pointer
182 argument:
183
184 .. code-block:: c++
185
186 struct interrupt_frame;
187
188 __attribute__ ((interrupt))
189 void
190 f (struct interrupt_frame *frame)
191 {
192 }
193
194 and you must define ``struct interrupt_frame`` as described in the
195 processor's manual.
196
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.
202
203 .. code-block:: c++
204
205 #ifdef __x86_64__
206 typedef unsigned long long int uword_t;
207 #else
208 typedef unsigned int uword_t;
209 #endif
210
211 struct interrupt_frame;
212
213 __attribute__ ((interrupt))
214 void
215 f (struct interrupt_frame *frame, uword_t error_code)
216 {
217 ...
218 }
219
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.
223
224 .. index:: target function attribute
225
226 .. x86-fn-attr:: target (options)
227
228 As discussed in :ref:`common-function-attributes`, this attribute
229 allows specification of target-specific compilation options.
230
231 On the x86, the following options are allowed:
232
233 :samp:`3dnow` :samp:`no-3dnow`
234
235 .. index:: target("3dnow") function attribute, x86
236
237 Enable/disable the generation of the 3DNow! instructions.
238
239 :samp:`3dnowa` :samp:`no-3dnowa`
240
241 .. index:: target("3dnowa") function attribute, x86
242
243 Enable/disable the generation of the enhanced 3DNow! instructions.
244
245 :samp:`abm` :samp:`no-abm`
246
247 .. index:: target("abm") function attribute, x86
248
249 Enable/disable the generation of the advanced bit instructions.
250
251 :samp:`adx` :samp:`no-adx`
252
253 .. index:: target("adx") function attribute, x86
254
255 Enable/disable the generation of the ADX instructions.
256
257 :samp:`aes` :samp:`no-aes`
258
259 .. index:: target("aes") function attribute, x86
260
261 Enable/disable the generation of the AES instructions.
262
263 :samp:`avx` :samp:`no-avx`
264
265 .. index:: target("avx") function attribute, x86
266
267 Enable/disable the generation of the AVX instructions.
268
269 :samp:`avx2` :samp:`no-avx2`
270
271 .. index:: target("avx2") function attribute, x86
272
273 Enable/disable the generation of the AVX2 instructions.
274
275 :samp:`avx5124fmaps` :samp:`no-avx5124fmaps`
276
277 .. index:: target("avx5124fmaps") function attribute, x86
278
279 Enable/disable the generation of the AVX5124FMAPS instructions.
280
281 :samp:`avx5124vnniw` :samp:`no-avx5124vnniw`
282
283 .. index:: target("avx5124vnniw") function attribute, x86
284
285 Enable/disable the generation of the AVX5124VNNIW instructions.
286
287 :samp:`avx512bitalg` :samp:`no-avx512bitalg`
288
289 .. index:: target("avx512bitalg") function attribute, x86
290
291 Enable/disable the generation of the AVX512BITALG instructions.
292
293 :samp:`avx512bw` :samp:`no-avx512bw`
294
295 .. index:: target("avx512bw") function attribute, x86
296
297 Enable/disable the generation of the AVX512BW instructions.
298
299 :samp:`avx512cd` :samp:`no-avx512cd`
300
301 .. index:: target("avx512cd") function attribute, x86
302
303 Enable/disable the generation of the AVX512CD instructions.
304
305 :samp:`avx512dq` :samp:`no-avx512dq`
306
307 .. index:: target("avx512dq") function attribute, x86
308
309 Enable/disable the generation of the AVX512DQ instructions.
310
311 :samp:`avx512er` :samp:`no-avx512er`
312
313 .. index:: target("avx512er") function attribute, x86
314
315 Enable/disable the generation of the AVX512ER instructions.
316
317 :samp:`avx512f` :samp:`no-avx512f`
318
319 .. index:: target("avx512f") function attribute, x86
320
321 Enable/disable the generation of the AVX512F instructions.
322
323 :samp:`avx512ifma` :samp:`no-avx512ifma`
324
325 .. index:: target("avx512ifma") function attribute, x86
326
327 Enable/disable the generation of the AVX512IFMA instructions.
328
329 :samp:`avx512pf` :samp:`no-avx512pf`
330
331 .. index:: target("avx512pf") function attribute, x86
332
333 Enable/disable the generation of the AVX512PF instructions.
334
335 :samp:`avx512vbmi` :samp:`no-avx512vbmi`
336
337 .. index:: target("avx512vbmi") function attribute, x86
338
339 Enable/disable the generation of the AVX512VBMI instructions.
340
341 :samp:`avx512vbmi2` :samp:`no-avx512vbmi2`
342
343 .. index:: target("avx512vbmi2") function attribute, x86
344
345 Enable/disable the generation of the AVX512VBMI2 instructions.
346
347 :samp:`avx512vl` :samp:`no-avx512vl`
348
349 .. index:: target("avx512vl") function attribute, x86
350
351 Enable/disable the generation of the AVX512VL instructions.
352
353 :samp:`avx512vnni` :samp:`no-avx512vnni`
354
355 .. index:: target("avx512vnni") function attribute, x86
356
357 Enable/disable the generation of the AVX512VNNI instructions.
358
359 :samp:`avx512vpopcntdq` :samp:`no-avx512vpopcntdq`
360
361 .. index:: target("avx512vpopcntdq") function attribute, x86
362
363 Enable/disable the generation of the AVX512VPOPCNTDQ instructions.
364
365 :samp:`bmi` :samp:`no-bmi`
366
367 .. index:: target("bmi") function attribute, x86
368
369 Enable/disable the generation of the BMI instructions.
370
371 :samp:`bmi2` :samp:`no-bmi2`
372
373 .. index:: target("bmi2") function attribute, x86
374
375 Enable/disable the generation of the BMI2 instructions.
376
377 :samp:`cldemote` :samp:`no-cldemote`
378
379 .. index:: target("cldemote") function attribute, x86
380
381 Enable/disable the generation of the CLDEMOTE instructions.
382
383 :samp:`clflushopt` :samp:`no-clflushopt`
384
385 .. index:: target("clflushopt") function attribute, x86
386
387 Enable/disable the generation of the CLFLUSHOPT instructions.
388
389 :samp:`clwb` :samp:`no-clwb`
390
391 .. index:: target("clwb") function attribute, x86
392
393 Enable/disable the generation of the CLWB instructions.
394
395 :samp:`clzero` :samp:`no-clzero`
396
397 .. index:: target("clzero") function attribute, x86
398
399 Enable/disable the generation of the CLZERO instructions.
400
401 :samp:`crc32` :samp:`no-crc32`
402
403 .. index:: target("crc32") function attribute, x86
404
405 Enable/disable the generation of the CRC32 instructions.
406
407 :samp:`cx16` :samp:`no-cx16`
408
409 .. index:: target("cx16") function attribute, x86
410
411 Enable/disable the generation of the CMPXCHG16B instructions.
412
413 :samp:`default`
414
415 .. index:: target("default") function attribute, x86
416
417 See :ref:`function-multiversioning`, where it is used to specify the
418 default function version.
419
420 :samp:`f16c` :samp:`no-f16c`
421
422 .. index:: target("f16c") function attribute, x86
423
424 Enable/disable the generation of the F16C instructions.
425
426 :samp:`fma` :samp:`no-fma`
427
428 .. index:: target("fma") function attribute, x86
429
430 Enable/disable the generation of the FMA instructions.
431
432 :samp:`fma4` :samp:`no-fma4`
433
434 .. index:: target("fma4") function attribute, x86
435
436 Enable/disable the generation of the FMA4 instructions.
437
438 :samp:`fsgsbase` :samp:`no-fsgsbase`
439
440 .. index:: target("fsgsbase") function attribute, x86
441
442 Enable/disable the generation of the FSGSBASE instructions.
443
444 :samp:`fxsr` :samp:`no-fxsr`
445
446 .. index:: target("fxsr") function attribute, x86
447
448 Enable/disable the generation of the FXSR instructions.
449
450 :samp:`gfni` :samp:`no-gfni`
451
452 .. index:: target("gfni") function attribute, x86
453
454 Enable/disable the generation of the GFNI instructions.
455
456 :samp:`hle` :samp:`no-hle`
457
458 .. index:: target("hle") function attribute, x86
459
460 Enable/disable the generation of the HLE instruction prefixes.
461
462 :samp:`lwp` :samp:`no-lwp`
463
464 .. index:: target("lwp") function attribute, x86
465
466 Enable/disable the generation of the LWP instructions.
467
468 :samp:`lzcnt` :samp:`no-lzcnt`
469
470 .. index:: target("lzcnt") function attribute, x86
471
472 Enable/disable the generation of the LZCNT instructions.
473
474 :samp:`mmx` :samp:`no-mmx`
475
476 .. index:: target("mmx") function attribute, x86
477
478 Enable/disable the generation of the MMX instructions.
479
480 :samp:`movbe` :samp:`no-movbe`
481
482 .. index:: target("movbe") function attribute, x86
483
484 Enable/disable the generation of the MOVBE instructions.
485
486 :samp:`movdir64b` :samp:`no-movdir64b`
487
488 .. index:: target("movdir64b") function attribute, x86
489
490 Enable/disable the generation of the MOVDIR64B instructions.
491
492 :samp:`movdiri` :samp:`no-movdiri`
493
494 .. index:: target("movdiri") function attribute, x86
495
496 Enable/disable the generation of the MOVDIRI instructions.
497
498 :samp:`mwait` :samp:`no-mwait`
499
500 .. index:: target("mwait") function attribute, x86
501
502 Enable/disable the generation of the MWAIT and MONITOR instructions.
503
504 :samp:`mwaitx` :samp:`no-mwaitx`
505
506 .. index:: target("mwaitx") function attribute, x86
507
508 Enable/disable the generation of the MWAITX instructions.
509
510 :samp:`pclmul` :samp:`no-pclmul`
511
512 .. index:: target("pclmul") function attribute, x86
513
514 Enable/disable the generation of the PCLMUL instructions.
515
516 :samp:`pconfig` :samp:`no-pconfig`
517
518 .. index:: target("pconfig") function attribute, x86
519
520 Enable/disable the generation of the PCONFIG instructions.
521
522 :samp:`pku` :samp:`no-pku`
523
524 .. index:: target("pku") function attribute, x86
525
526 Enable/disable the generation of the PKU instructions.
527
528 :samp:`popcnt` :samp:`no-popcnt`
529
530 .. index:: target("popcnt") function attribute, x86
531
532 Enable/disable the generation of the POPCNT instruction.
533
534 :samp:`prefetchwt1` :samp:`no-prefetchwt1`
535
536 .. index:: target("prefetchwt1") function attribute, x86
537
538 Enable/disable the generation of the PREFETCHWT1 instructions.
539
540 :samp:`prfchw` :samp:`no-prfchw`
541
542 .. index:: target("prfchw") function attribute, x86
543
544 Enable/disable the generation of the PREFETCHW instruction.
545
546 :samp:`ptwrite` :samp:`no-ptwrite`
547
548 .. index:: target("ptwrite") function attribute, x86
549
550 Enable/disable the generation of the PTWRITE instructions.
551
552 :samp:`rdpid` :samp:`no-rdpid`
553
554 .. index:: target("rdpid") function attribute, x86
555
556 Enable/disable the generation of the RDPID instructions.
557
558 :samp:`rdrnd` :samp:`no-rdrnd`
559
560 .. index:: target("rdrnd") function attribute, x86
561
562 Enable/disable the generation of the RDRND instructions.
563
564 :samp:`rdseed` :samp:`no-rdseed`
565
566 .. index:: target("rdseed") function attribute, x86
567
568 Enable/disable the generation of the RDSEED instructions.
569
570 :samp:`rtm` :samp:`no-rtm`
571
572 .. index:: target("rtm") function attribute, x86
573
574 Enable/disable the generation of the RTM instructions.
575
576 :samp:`sahf` :samp:`no-sahf`
577
578 .. index:: target("sahf") function attribute, x86
579
580 Enable/disable the generation of the SAHF instructions.
581
582 :samp:`sgx` :samp:`no-sgx`
583
584 .. index:: target("sgx") function attribute, x86
585
586 Enable/disable the generation of the SGX instructions.
587
588 :samp:`sha` :samp:`no-sha`
589
590 .. index:: target("sha") function attribute, x86
591
592 Enable/disable the generation of the SHA instructions.
593
594 :samp:`shstk` :samp:`no-shstk`
595
596 .. index:: target("shstk") function attribute, x86
597
598 Enable/disable the shadow stack built-in functions from CET.
599
600 :samp:`sse` :samp:`no-sse`
601
602 .. index:: target("sse") function attribute, x86
603
604 Enable/disable the generation of the SSE instructions.
605
606 :samp:`sse2` :samp:`no-sse2`
607
608 .. index:: target("sse2") function attribute, x86
609
610 Enable/disable the generation of the SSE2 instructions.
611
612 :samp:`sse3` :samp:`no-sse3`
613
614 .. index:: target("sse3") function attribute, x86
615
616 Enable/disable the generation of the SSE3 instructions.
617
618 :samp:`sse4` :samp:`no-sse4`
619
620 .. index:: target("sse4") function attribute, x86
621
622 Enable/disable the generation of the SSE4 instructions (both SSE4.1
623 and SSE4.2).
624
625 :samp:`sse4.1` :samp:`no-sse4.1`
626
627 .. index:: target("sse4.1") function attribute, x86
628
629 Enable/disable the generation of the SSE4.1 instructions.
630
631 :samp:`sse4.2` :samp:`no-sse4.2`
632
633 .. index:: target("sse4.2") function attribute, x86
634
635 Enable/disable the generation of the SSE4.2 instructions.
636
637 :samp:`sse4a` :samp:`no-sse4a`
638
639 .. index:: target("sse4a") function attribute, x86
640
641 Enable/disable the generation of the SSE4A instructions.
642
643 :samp:`ssse3` :samp:`no-ssse3`
644
645 .. index:: target("ssse3") function attribute, x86
646
647 Enable/disable the generation of the SSSE3 instructions.
648
649 :samp:`tbm` :samp:`no-tbm`
650
651 .. index:: target("tbm") function attribute, x86
652
653 Enable/disable the generation of the TBM instructions.
654
655 :samp:`vaes` :samp:`no-vaes`
656
657 .. index:: target("vaes") function attribute, x86
658
659 Enable/disable the generation of the VAES instructions.
660
661 :samp:`vpclmulqdq` :samp:`no-vpclmulqdq`
662
663 .. index:: target("vpclmulqdq") function attribute, x86
664
665 Enable/disable the generation of the VPCLMULQDQ instructions.
666
667 :samp:`waitpkg` :samp:`no-waitpkg`
668
669 .. index:: target("waitpkg") function attribute, x86
670
671 Enable/disable the generation of the WAITPKG instructions.
672
673 :samp:`wbnoinvd` :samp:`no-wbnoinvd`
674
675 .. index:: target("wbnoinvd") function attribute, x86
676
677 Enable/disable the generation of the WBNOINVD instructions.
678
679 :samp:`xop` :samp:`no-xop`
680
681 .. index:: target("xop") function attribute, x86
682
683 Enable/disable the generation of the XOP instructions.
684
685 :samp:`xsave` :samp:`no-xsave`
686
687 .. index:: target("xsave") function attribute, x86
688
689 Enable/disable the generation of the XSAVE instructions.
690
691 :samp:`xsavec` :samp:`no-xsavec`
692
693 .. index:: target("xsavec") function attribute, x86
694
695 Enable/disable the generation of the XSAVEC instructions.
696
697 :samp:`xsaveopt` :samp:`no-xsaveopt`
698
699 .. index:: target("xsaveopt") function attribute, x86
700
701 Enable/disable the generation of the XSAVEOPT instructions.
702
703 :samp:`xsaves` :samp:`no-xsaves`
704
705 .. index:: target("xsaves") function attribute, x86
706
707 Enable/disable the generation of the XSAVES instructions.
708
709 :samp:`amx-tile` :samp:`no-amx-tile`
710
711 .. index:: target("amx-tile") function attribute, x86
712
713 Enable/disable the generation of the AMX-TILE instructions.
714
715 :samp:`amx-int8` :samp:`no-amx-int8`
716
717 .. index:: target("amx-int8") function attribute, x86
718
719 Enable/disable the generation of the AMX-INT8 instructions.
720
721 :samp:`amx-bf16` :samp:`no-amx-bf16`
722
723 .. index:: target("amx-bf16") function attribute, x86
724
725 Enable/disable the generation of the AMX-BF16 instructions.
726
727 :samp:`uintr` :samp:`no-uintr`
728
729 .. index:: target("uintr") function attribute, x86
730
731 Enable/disable the generation of the UINTR instructions.
732
733 :samp:`hreset` :samp:`no-hreset`
734
735 .. index:: target("hreset") function attribute, x86
736
737 Enable/disable the generation of the HRESET instruction.
738
739 :samp:`kl` :samp:`no-kl`
740
741 .. index:: target("kl") function attribute, x86
742
743 Enable/disable the generation of the KEYLOCKER instructions.
744
745 :samp:`widekl` :samp:`no-widekl`
746
747 .. index:: target("widekl") function attribute, x86
748
749 Enable/disable the generation of the WIDEKL instructions.
750
751 :samp:`avxvnni` :samp:`no-avxvnni`
752
753 .. index:: target("avxvnni") function attribute, x86
754
755 Enable/disable the generation of the AVXVNNI instructions.
756
757 :samp:`avxifma` :samp:`no-avxifma`
758
759 .. index:: target("avxifma") function attribute, x86
760
761 Enable/disable the generation of the AVXIFMA instructions.
762
763 :samp:`avxvnniint8` :samp:`no-avxvnniint8`
764
765 .. index:: target("avxvnniint8") function attribute, x86
766
767 Enable/disable the generation of the AVXVNNIINT8 instructions.
768
769 :samp:`avxneconvert` :samp:`no-avxneconvert`
770
771 .. index:: target("avxneconvert") function attribute, x86
772
773 Enable/disable the generation of the AVXNECONVERT instructions.
774
775 :samp:`cmpccxadd` :samp:`no-cmpccxadd`
776
777 .. index:: target("cmpccxadd") function attribute, x86
778
779 Enable/disable the generation of the CMPccXADD instructions.
780
781 :samp:`amx-fp16` :samp:`no-amx-fp16`
782
783 .. index:: target("amx-fp16") function attribute, x86
784
785 Enable/disable the generation of the AMX-FP16 instructions.
786
787 :samp:`prefetchi` :samp:`no-prefetchi`
788
789 .. index:: target("prefetchi") function attribute, x86
790
791 Enable/disable the generation of the PREFETCHI instructions.
792
793 :samp:`raoint` :samp:`no-raoint`
794
795 .. index:: target("raoint") function attribute, x86
796
797 Enable/disable the generation of the RAOINT instructions.
798
799 :samp:`cld` :samp:`no-cld`
800
801 .. index:: target("cld") function attribute, x86
802
803 Enable/disable the generation of the CLD before string moves.
804
805 :samp:`fancy-math-387` :samp:`no-fancy-math-387`
806
807 .. index:: target("fancy-math-387") function attribute, x86
808
809 Enable/disable the generation of the ``sin``, ``cos``, and
810 ``sqrt`` instructions on the 387 floating-point unit.
811
812 :samp:`ieee-fp` :samp:`no-ieee-fp`
813
814 .. index:: target("ieee-fp") function attribute, x86
815
816 Enable/disable the generation of floating point that depends on IEEE arithmetic.
817
818 :samp:`inline-all-stringops` :samp:`no-inline-all-stringops`
819
820 .. index:: target("inline-all-stringops") function attribute, x86
821
822 Enable/disable inlining of string operations.
823
824 :samp:`inline-stringops-dynamically` :samp:`no-inline-stringops-dynamically`
825
826 .. index:: target("inline-stringops-dynamically") function attribute, x86
827
828 Enable/disable the generation of the inline code to do small string
829 operations and calling the library routines for large operations.
830
831 :samp:`align-stringops` :samp:`no-align-stringops`
832
833 .. index:: target("align-stringops") function attribute, x86
834
835 Do/do not align destination of inlined string operations.
836
837 :samp:`recip` :samp:`no-recip`
838
839 .. index:: target("recip") function attribute, x86
840
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.
844
845 :samp:`general-regs-only`
846
847 .. index:: target("general-regs-only") function attribute, x86
848
849 Generate code which uses only the general registers.
850
851 :samp:`arch={ARCH}`
852
853 .. index:: target("arch=ARCH") function attribute, x86
854
855 Specify the architecture to generate code for in compiling the function.
856
857 :samp:`tune={TUNE}`
858
859 .. index:: target("tune=TUNE") function attribute, x86
860
861 Specify the architecture to tune for in compiling the function.
862
863 :samp:`fpmath={FPMATH}`
864
865 .. index:: target("fpmath=FPMATH") function attribute, x86
866
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
870 different options.
871
872 :samp:`prefer-vector-width={OPT}`
873
874 .. index:: prefer-vector-width function attribute, x86
875
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.
879
880 Valid :samp:`{OPT}` values are:
881
882 :samp:`none`
883 No extra limitations applied to GCC other than defined by the selected platform.
884
885 :samp:`128`
886 Prefer 128-bit vector width for instructions.
887
888 :samp:`256`
889 Prefer 256-bit vector width for instructions.
890
891 :samp:`512`
892 Prefer 512-bit vector width for instructions.
893
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``.
899
900 .. index:: indirect_branch function attribute, x86
901
902 .. x86-fn-attr:: indirect_branch("choice")
903
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.
911
912 .. index:: function_return function attribute, x86
913
914 .. x86-fn-attr:: function_return("choice")
915
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.
922
923 .. index:: nocf_check function attribute
924
925 .. x86-fn-attr:: nocf_check
926
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.
932
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.
941
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.
948
949 .. code-block:: c++
950
951 {
952 int foo (void) __attribute__(nocf_check);
953 void (*foo1)(void) __attribute__(nocf_check);
954 void (*foo2)(void);
955
956 /* foo's address is assumed to be valid. */
957 int
958 foo (void)
959
960 /* This call site is not checked for control-flow
961 validity. */
962 (*foo1)();
963
964 /* A warning is issued about attribute mismatch. */
965 foo1 = foo2;
966
967 /* This call site is still not checked. */
968 (*foo1)();
969
970 /* This call site is checked. */
971 (*foo2)();
972
973 /* A warning is issued about attribute mismatch. */
974 foo2 = foo1;
975
976 /* This call site is still checked. */
977 (*foo2)();
978
979 return 0;
980 }
981
982 .. index:: cf_check function attribute, x86
983
984 .. x86-fn-attr:: cf_check
985
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.
989
990 .. index:: indirect_return function attribute, x86
991
992 .. x86-fn-attr:: indirect_return
993
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.
997
998 .. index:: fentry_name function attribute, x86
999
1000 .. x86-fn-attr:: fentry_name("name")
1001
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.
1006
1007 .. index:: fentry_section function attribute, x86
1008
1009 .. x86-fn-attr:: fentry_section("name")
1010
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`
1014
1015 .. index:: nodirect_extern_access function attribute
1016
1017 .. option:: nodirect_extern_access
1018
1019 This attribute, attached to a global variable or function, is the
1020 counterpart to option :option:`-mno-direct-extern-access`.