1
+ r[ attributes.codegen]
1
2
# Code generation attributes
2
3
3
- r[ attributes.codegen]
4
4
5
5
The following [ attributes] are used for controlling code generation.
6
6
7
- ## Optimization hints
8
-
9
7
r[ attributes.codegen.hint]
8
+ ## Optimization hints
10
9
11
10
r[ attributes.codegen.hint.cold-inline]
12
11
The ` cold ` and ` inline ` [ attributes] give suggestions to generate code in a
@@ -19,9 +18,8 @@ Both attributes can be used on [functions]. When applied to a function in a
19
18
a trait implementation and not to all trait implementations. The attributes
20
19
have no effect on a trait function without a body.
21
20
22
- ### The ` inline ` attribute
23
-
24
21
r[ attributes.codegen.inline]
22
+ ### The ` inline ` attribute
25
23
26
24
r[ attributes.codegen.inline.intro]
27
25
The * ` inline ` [ attribute] * suggests that a copy of the attributed function
@@ -44,24 +42,23 @@ There are three ways to use the inline attribute:
44
42
> *** Note*** : ` #[inline] ` in every form is a hint, with no * requirements*
45
43
> on the language to place a copy of the attributed function in the caller.
46
44
45
+ r[ attributes.codegen.cold]
47
46
### The ` cold ` attribute
48
47
49
- r[ attributes.codegen.cold]
50
48
51
49
The * ` cold ` [ attribute] * suggests that the attributed function is unlikely to
52
50
be called.
53
51
52
+ r[ attributes.codegen.no_builtins]
54
53
## The ` no_builtins ` attribute
55
54
56
- r[ attributes.codegen.no_builtins]
57
55
58
56
The * ` no_builtins ` [ attribute] * may be applied at the crate level to disable
59
57
optimizing certain code patterns to invocations of library functions that are
60
58
assumed to exist.
61
59
62
- ## The ` target_feature ` attribute
63
-
64
60
r[ attributes.codegen.target_feature]
61
+ ## The ` target_feature ` attribute
65
62
66
63
r[ attributes.codegen.target_feature.intro]
67
64
The * ` target_feature ` [ attribute] * may be applied to a function to
@@ -90,15 +87,15 @@ Functions marked with `target_feature` are not inlined into a context that
90
87
does not support the given features. The ` #[inline(always)] ` attribute may not
91
88
be used with a ` target_feature ` attribute.
92
89
90
+ r[ attributes.codegen.target_feature.availability]
93
91
### Available features
94
92
95
- r[ attributes.codegen.target_feature.availability]
96
93
97
94
The following is a list of the available feature names.
98
95
96
+ r[ attributes.codegen.target_feature.x86]
99
97
#### ` x86 ` or ` x86_64 `
100
98
101
- r[ attributes.codegen.target_feature.x86]
102
99
103
100
Executing code with unsupported features is undefined behavior on this platform.
104
101
Hence this platform requires that ` #[target_feature] ` is only applied to [ ` unsafe `
@@ -165,9 +162,9 @@ Feature | Implicitly Enables | Description
165
162
[ `xsaveopt` ] : https://www.felixcloutier.com/x86/xsaveopt
166
163
[ `xsaves` ] : https://www.felixcloutier.com/x86/xsaves
167
164
165
+ r[ attributes.codegen.target_feature.aarch64]
168
166
#### ` aarch64 `
169
167
170
- r[ attributes.codegen.target_feature.aarch64]
171
168
172
169
This platform requires that ` #[target_feature] ` is only applied to [ ` unsafe `
173
170
functions] [ unsafe function ] .
@@ -230,9 +227,9 @@ Feature | Implicitly Enables | Feature Name
230
227
` tme ` | | FEAT_TME --- Transactional Memory Extension
231
228
` vh ` | | FEAT_VHE --- Virtualization Host Extensions
232
229
230
+ r[ attributes.codegen.target_feature.riscv]
233
231
#### ` riscv32 ` or ` riscv64 `
234
232
235
- r[ attributes.codegen.target_feature.riscv]
236
233
237
234
This platform requires that ` #[target_feature] ` is only applied to [ ` unsafe `
238
235
functions] [ unsafe function ] .
@@ -292,9 +289,9 @@ Feature | Implicitly Enables | Description
292
289
[ rv-zksh ] : https://github.com/riscv/riscv-crypto/blob/e2dd7d98b7f34d477e38cb5fd7a3af4379525189/doc/scalar/riscv-crypto-scalar-zksh.adoc
293
290
[ rv-zkt ] : https://github.com/riscv/riscv-crypto/blob/e2dd7d98b7f34d477e38cb5fd7a3af4379525189/doc/scalar/riscv-crypto-scalar-zkt.adoc
294
291
292
+ r[ attributes.codegen.target_feature.wasm]
295
293
#### ` wasm32 ` or ` wasm64 `
296
294
297
- r[ attributes.codegen.target_feature.wasm]
298
295
299
296
` #[target_feature] ` may be used with both safe and
300
297
[ ` unsafe ` functions] [ unsafe function ] on Wasm platforms. It is impossible to
@@ -327,9 +324,8 @@ Feature | Implicitly Enables | Description
327
324
[ tail-call ] : https://github.com/webassembly/tail-call
328
325
[ multivalue ] : https://github.com/webassembly/multi-value
329
326
330
- ### Additional information
331
-
332
327
r[ attributes.codegen.target_feature.info]
328
+ ### Additional information
333
329
334
330
r[ attributes.codegen.target_feature.remark-cfg]
335
331
See the [ ` target_feature ` conditional compilation option] for selectively
@@ -346,9 +342,8 @@ in the standard library for runtime feature detection on these platforms.
346
342
> may be enabled or disabled for an entire crate with the
347
343
> [ ` -C target-feature ` ] flag.
348
344
349
- ## The ` track_caller ` attribute
350
-
351
345
r[ attributes.codegen.track_caller]
346
+ ## The ` track_caller ` attribute
352
347
353
348
r[ attributes.codegen.track_caller.allowed-positions]
354
349
The ` track_caller ` attribute may be applied to any function with [ ` "Rust" ` ABI] [ rust-abi ]
@@ -364,9 +359,9 @@ implementations, otherwise undefined behavior results. When applied to a functio
364
359
available to an ` extern ` block, the declaration in the ` extern ` block must also have the attribute,
365
360
otherwise undefined behavior results.
366
361
362
+ r[ attributes.codegen.track_caller.behavior]
367
363
### Behavior
368
364
369
- r[ attributes.codegen.track_caller.behavior]
370
365
Applying the attribute to a function ` f ` allows code within ` f ` to get a hint of the [ ` Location ` ] of
371
366
the "topmost" tracked call that led to ` f ` 's invocation. At the point of observation, an
372
367
implementation behaves as if it walks up the stack from ` f ` 's frame to find the nearest frame of an
@@ -444,9 +439,8 @@ fn calls_h() {
444
439
445
440
And so on.
446
441
447
- ### Limitations
448
-
449
442
r[ attributes.codegen.track_caller.limits]
443
+ ### Limitations
450
444
451
445
r[ attributes.codegen.track_caller.hint]
452
446
This information is a hint and implementations are not required to preserve it.
@@ -480,9 +474,8 @@ trait object whose methods are attributed.
480
474
[ rust-abi ] : ../items/external-blocks.md#abi
481
475
[ `Location` ] : core::panic::Location
482
476
483
- ## The ` instruction_set ` attribute
484
-
485
477
r[ attributes.codegen.instruction_set]
478
+ ## The ` instruction_set ` attribute
486
479
487
480
r[ attributes.codegen.instruction_set.allowed-positions]
488
481
The * ` instruction_set ` [ attribute] * may be applied to a function to control which instruction set the function will be generated for.
@@ -498,9 +491,9 @@ It uses the [_MetaListPath_] syntax, and a path comprised of the architecture fa
498
491
r[ attributes.codegen.instruction_set.target-limits]
499
492
It is a compilation error to use the ` instruction_set ` attribute on a target that does not support it.
500
493
494
+ r[ attributes.codegen.instruction_set.arm]
501
495
### On ARM
502
496
503
- r[ attributes.codegen.instruction_set.arm]
504
497
505
498
For the ` ARMv4T ` and ` ARMv5te ` architectures, the following are supported:
506
499
* ` arm::a32 ` --- Generate the function as A32 "ARM" code.
0 commit comments