Skip to content

Commit 71d7c2a

Browse files
committed
Revise instruction_set text
1 parent 5ffe310 commit 71d7c2a

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

src/attributes/codegen.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ trait object whose methods are attributed.
634634
> [!NOTE]
635635
> The aforementioned shim for function pointers is necessary because `rustc` implements `track_caller` in a codegen context by appending an implicit parameter to the function ABI, but this would be unsound for an indirect call because the parameter is not a part of the function's type and a given function pointer type may or may not refer to a function with the attribute. The creation of a shim hides the implicit parameter from callers of the function pointer, preserving soundness.
636636
637+
<!-- template:attributes -->
637638
r[attributes.codegen.instruction_set]
638639
## The `instruction_set` attribute
639640

@@ -644,44 +645,42 @@ The *`instruction_set` [attribute]* specifies the instruction set that a functio
644645
> <!-- ignore: arm-only -->
645646
> ```rust,ignore
646647
> #[instruction_set(arm::a32)]
647-
> fn foo_arm_code() {}
648+
> fn arm_code() {}
648649
>
649650
> #[instruction_set(arm::t32)]
650-
> fn bar_thumb_code() {}
651+
> fn thumb_code() {}
651652
> ```
652653
653654
r[attributes.codegen.instruction_set.syntax]
654-
The `instruction_set` attribute uses the [MetaListPaths] syntax, and a path comprised of the architecture family name and instruction set name.
655+
The `instruction_set` attribute uses the [MetaListPaths] syntax to specify a single path consisting of the architecture family name and instruction set name.
655656
656657
r[attributes.codegen.instruction_set.allowed-positions]
657-
The `instruction_set` attribute may only be applied to:
658-
659-
- [Free functions][items.fn]
660-
- [Inherent associated functions][items.associated.fn]
661-
- [Trait impl functions][items.impl.trait]
662-
- [Trait definition functions][items.traits] with a body
663-
- [Closures][expr.closure]
658+
The `instruction_set` attribute may only be applied to functions, including [closures][expr.closure], [free functions][items.fn], and associated functions defined (i.e. with a body) in [inherent impls][items.associated.fn], [trait impls][items.impl.trait], and [trait definitions][items.traits].
664659
665660
> [!NOTE]
666-
> `rustc` currently ignores `instruction_set` in other positions. This may change in the future.
661+
> `rustc` ignores use in other positions but lints against it. This may become an error in the future.
667662
668663
r[attributes.codegen.instruction_set.duplicates]
669-
The `instruction_set` attribute may only be specified once on an item.
664+
The `instruction_set` attribute may be used only once on a function.
670665
671666
r[attributes.codegen.instruction_set.target-limits]
672667
The `instruction_set` attribute may only be used with a target that supports the given value.
673668
669+
r[attributes.codegen.instruction_set.inline-asm]
670+
When the `instruction_set` attribute is used, any inline assembly in the function must use the specified instruction set instead of the target default.
671+
674672
r[attributes.codegen.instruction_set.arm]
675673
### `instruction_set` on ARM
676674
677-
For the `ARMv4T` and `ARMv5te` architectures, the following are supported:
678-
* `arm::a32` --- Generate the function as A32 "ARM" code.
679-
* `arm::t32` --- Generate the function as T32 "Thumb" code.
675+
When targeting the `ARMv4T` and `ARMv5te` architectures, the supported values for `instruction_set` are:
676+
677+
- `arm::a32` --- Generate the function as A32 "ARM" code.
678+
- `arm::t32` --- Generate the function as T32 "Thumb" code.
680679
681-
Using the `instruction_set` attribute has the following effects:
680+
If the address of the function is taken as a function pointer, the low bit of the address will depend on the selected instruction set:
682681
683-
* If the address of the function is taken as a function pointer, the low bit of the address will be set to 0 (arm) or 1 (thumb) depending on the instruction set.
684-
* Any inline assembly in the function must use the specified instruction set instead of the target default.
682+
- For `arm::a32` ("ARM"), it will be 0.
683+
- For `arm::t32` ("Thumb"), it will be 1.
685684
686685
[`-C target-cpu`]: ../../rustc/codegen-options/index.html#target-cpu
687686
[`-C target-feature`]: ../../rustc/codegen-options/index.html#target-feature

0 commit comments

Comments
 (0)