You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The *`instruction_set`[attribute]*may be applied to a function to control which instruction set the function will be generated for.
640
+
r[attributes.codegen.instruction_set.intro]
641
+
The *`instruction_set`[attribute]*specifies the instruction set that a function will use during code generation. This allows mixing more than one instruction set in a single program.
642
642
643
-
r[attributes.codegen.instruction_set.behavior]
644
-
This allows mixing more than one instruction set in a single program on CPU architectures that support it.
643
+
> [!EXAMPLE]
644
+
> <!-- ignore: arm-only -->
645
+
> ```rust,ignore
646
+
> #[instruction_set(arm::a32)]
647
+
> fn foo_arm_code() {}
648
+
>
649
+
> #[instruction_set(arm::t32)]
650
+
> fn bar_thumb_code() {}
651
+
> ```
645
652
646
653
r[attributes.codegen.instruction_set.syntax]
647
-
It uses the [MetaListPaths] syntax, and a path comprised of the architecture family name and instruction set name.
654
+
The `instruction_set` attribute uses the [MetaListPaths] syntax, and a path comprised of the architecture family name and instruction set name.
It is a compilation error to use the `instruction_set` attribute on a target that does not support it.
672
+
The `instruction_set` attribute may only be used with a target that supports the given value.
651
673
652
674
r[attributes.codegen.instruction_set.arm]
653
-
### On ARM
675
+
### `instruction_set` on ARM
654
676
655
677
For the `ARMv4T` and `ARMv5te` architectures, the following are supported:
656
678
* `arm::a32` --- Generate the function as A32 "ARM" code.
657
679
* `arm::t32` --- Generate the function as T32 "Thumb" code.
658
680
659
-
<!-- ignore: arm-only -->
660
-
```rust,ignore
661
-
#[instruction_set(arm::a32)]
662
-
fn foo_arm_code() {}
663
-
664
-
#[instruction_set(arm::t32)]
665
-
fn bar_thumb_code() {}
666
-
```
667
-
668
681
Using the `instruction_set` attribute has the following effects:
669
682
670
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.
0 commit comments