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
Copy file name to clipboardExpand all lines: src/attributes/codegen.md
+29-16Lines changed: 29 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -614,34 +614,47 @@ trait object whose methods are attributed.
614
614
r[attributes.codegen.instruction_set]
615
615
## The `instruction_set` attribute
616
616
617
+
r[attributes.codegen.instruction_set.intro]
618
+
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.
619
+
620
+
> [!EXAMPLE]
621
+
> <!-- ignore: arm-only -->
622
+
> ```rust,ignore
623
+
> #[instruction_set(arm::a32)]
624
+
> fn foo_arm_code() {}
625
+
>
626
+
> #[instruction_set(arm::t32)]
627
+
> fn bar_thumb_code() {}
628
+
> ```
629
+
630
+
r[attributes.codegen.instruction_set.syntax]
631
+
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.
649
+
The `instruction_set` attribute may only be used with a target that supports the given value.
628
650
629
651
r[attributes.codegen.instruction_set.arm]
630
-
### On ARM
652
+
### `instruction_set` on ARM
631
653
632
654
For the `ARMv4T` and `ARMv5te` architectures, the following are supported:
633
655
* `arm::a32` --- Generate the function as A32 "ARM" code.
634
656
* `arm::t32` --- Generate the function as T32 "Thumb" code.
635
657
636
-
<!-- ignore: arm-only -->
637
-
```rust,ignore
638
-
#[instruction_set(arm::a32)]
639
-
fn foo_arm_code() {}
640
-
641
-
#[instruction_set(arm::t32)]
642
-
fn bar_thumb_code() {}
643
-
```
644
-
645
658
Using the `instruction_set` attribute has the following effects:
646
659
647
660
* 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