Skip to content

Commit 2a8068e

Browse files
authored
Merge pull request #1307 from Lokathor/patch-1
Clearly specify the `instruction_set` effects
2 parents 9cd5c5a + 188499d commit 2a8068e

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/attributes/codegen.md

+16-8
Original file line numberDiff line numberDiff line change
@@ -361,15 +361,20 @@ trait object whose methods are attributed.
361361

362362
## The `instruction_set` attribute
363363

364-
The *`instruction_set` attribute* may be applied to a function to enable code generation for a specific
365-
instruction set supported by the target architecture. It uses the [_MetaListPath_] syntax and a path
366-
comprised of the architecture and instruction set to specify how to generate the code for
367-
architectures where a single program may utilize multiple instruction sets.
364+
The *`instruction_set` [attribute]* may be applied to a function to control which instruction set the function will be generated for.
365+
This allows mixing more than one instruction set in a single program on CPU architectures that support it.
366+
It uses the [_MetaListPath_] syntax, and a path comprised of the architecture family name and instruction set name.
368367

369-
The following values are available on targets for the `ARMv4` and `ARMv5te` architectures:
368+
[_MetaListPath_]: ../attributes.md#meta-item-attribute-syntax
369+
370+
It is a compilation error to use the `instruction_set` attribute on a target that does not support it.
371+
372+
### On ARM
370373

371-
* `arm::a32` - Uses ARM code.
372-
* `arm::t32` - Uses Thumb code.
374+
For the `ARMv4T` and `ARMv5te` architectures, the following are supported:
375+
376+
* `arm::a32` - Generate the function as A32 "ARM" code.
377+
* `arm::t32` - Generate the function as T32 "Thumb" code.
373378

374379
<!-- ignore: arm-only -->
375380
```rust,ignore
@@ -380,4 +385,7 @@ fn foo_arm_code() {}
380385
fn bar_thumb_code() {}
381386
```
382387

383-
[_MetaListPath_]: ../attributes.md#meta-item-attribute-syntax
388+
Using the `instruction_set` attribute has the following effects:
389+
390+
* 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.
391+
* Any inline assembly in the function must use the specified instruction set instead of the target default.

0 commit comments

Comments
 (0)