Skip to content

Commit 3d45616

Browse files
authored
Clearly specify the instruction_set inlining restrictions
1 parent 6a5431b commit 3d45616

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/attributes/codegen.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,16 @@ trait object whose methods are attributed.
355355

356356
## The `instruction_set` attribute
357357

358-
The *`instruction_set` attribute* may be applied to a function to enable code generation for a specific
359-
instruction set supported by the target architecture. It uses the [_MetaListPath_] syntax and a path
360-
comprised of the architecture and instruction set to specify how to generate the code for
361-
architectures where a single program may utilize multiple instruction sets.
358+
On some CPU architectures it is possible to mix more than one instruction set into a single program.
359+
The `instruction_set` attribute lets you control which instruction set a particular function will be generated for.
360+
It uses the [_MetaListPath_] syntax, and a path comprised of the architecture family name and instruction set name.
362361

363-
The following values are available on targets for the `ARMv4` and `ARMv5te` architectures:
362+
[_MetaListPath_]: ../attributes.md#meta-item-attribute-syntax
363+
364+
For the `ARMv4T` and `ARMv5te` architectures, the following are supported:
364365

365-
* `arm::a32` - Uses ARM code.
366-
* `arm::t32` - Uses Thumb code.
366+
* `arm::a32` - Generate the function as A32 "ARM" code.
367+
* `arm::t32` - Generate the function as T32 "Thumb" code.
367368

368369
<!-- ignore: arm-only -->
369370
```rust,ignore
@@ -374,4 +375,8 @@ fn foo_arm_code() {}
374375
fn bar_thumb_code() {}
375376
```
376377

377-
[_MetaListPath_]: ../attributes.md#meta-item-attribute-syntax
378+
The rules for inlining functions using the `instruction_set` attribute are slightly more strict than normal:
379+
380+
* If a function has an `instruction_set` attribute, then the function is assumed to require the given instruction set and it won't inline into a function of another instruction set.
381+
* If a function does not have an `instruction_set` attribute but *does* contain inline assembly, then the inline assembly is assumed to require the default instruction set of the build target and so inlining between instruction sets won't happen.
382+
* Otherwise, a function is assumed to not rely on a particular instruction set and the function *may* be inlined into any calling function (all other restrictions on inlining still apply).

0 commit comments

Comments
 (0)