Skip to content

Commit 6a5431b

Browse files
authored
Merge pull request #1253 from xd009642/doc/rfc2867
Document RFC 2867: instruction_set attribute
2 parents 212b1c9 + c47e316 commit 6a5431b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/attributes.md

+2
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ The following is an index of all built-in attributes.
248248
- [`no_builtins`] — Disables use of certain built-in functions.
249249
- [`target_feature`] — Configure platform-specific code generation.
250250
- [`track_caller`] - Pass the parent call location to `std::panic::Location::caller()`.
251+
- [`instruction_set`] - Specify the instruction set used to generate a functions code
251252
- Documentation
252253
- `doc` — Specifies documentation. See [The Rustdoc Book] for more
253254
information. [Doc comments] are transformed into `doc` attributes.
@@ -298,6 +299,7 @@ The following is an index of all built-in attributes.
298299
[`global_allocator`]: runtime.md#the-global_allocator-attribute
299300
[`ignore`]: attributes/testing.md#the-ignore-attribute
300301
[`inline`]: attributes/codegen.md#the-inline-attribute
302+
[`instruction_set`]: attributes/codegen.md#the-instruction_set-attribute
301303
[`link_name`]: items/external-blocks.md#the-link_name-attribute
302304
[`link_ordinal`]: items/external-blocks.md#the-link_ordinal-attribute
303305
[`link_section`]: abi.md#the-link_section-attribute

src/attributes/codegen.md

+23
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,26 @@ trait object whose methods are attributed.
352352
[`core::intrinsics::caller_location`]: ../../core/intrinsics/fn.caller_location.html
353353
[`core::panic::Location::caller`]: ../../core/panic/struct.Location.html#method.caller
354354
[`Location`]: ../../core/panic/struct.Location.html
355+
356+
## The `instruction_set` attribute
357+
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.
362+
363+
The following values are available on targets for the `ARMv4` and `ARMv5te` architectures:
364+
365+
* `arm::a32` - Uses ARM code.
366+
* `arm::t32` - Uses Thumb code.
367+
368+
<!-- ignore: arm-only -->
369+
```rust,ignore
370+
#[instruction_set(arm::a32)]
371+
fn foo_arm_code() {}
372+
373+
#[instruction_set(arm::t32)]
374+
fn bar_thumb_code() {}
375+
```
376+
377+
[_MetaListPath_]: ../attributes.md#meta-item-attribute-syntax

0 commit comments

Comments
 (0)