From 8fda26b2aa4c24d6902d283badd0a75ae51d487e Mon Sep 17 00:00:00 2001 From: xd009642 Date: Tue, 16 Aug 2022 21:47:56 +0100 Subject: [PATCH 1/9] Initial stab at docs for RFC2867 --- src/attributes/codegen.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/attributes/codegen.md b/src/attributes/codegen.md index 4ebabaccf..e18c8679d 100644 --- a/src/attributes/codegen.md +++ b/src/attributes/codegen.md @@ -352,3 +352,18 @@ trait object whose methods are attributed. [`core::intrinsics::caller_location`]: ../../core/intrinsics/fn.caller_location.html [`core::panic::Location::caller`]: ../../core/panic/struct.Location.html#method.caller [`Location`]: ../../core/panic/struct.Location.html + +## The `instruction_set` attribute + +The `instruction_set` attribute may be applied to a function to enable code generation for a specific +instruction set supported by the target architecture. Currently, this is only available for `ARMv4T` +devices where the architecture has "ARM code" and "Thumb code" available and a single program may +utilise both of these. If not specified the default instruction set for the target will be used. + +```rust +#[instruction_set(arm::a32)] +fn foo_arm_code() {} + +#[instruction_set(arm::t32)] +fn bar_thumb_code() {} +``` From ef7036576c03bf56748892a0ebd151946f6dfc9f Mon Sep 17 00:00:00 2001 From: xd009642 Date: Tue, 16 Aug 2022 21:50:47 +0100 Subject: [PATCH 2/9] Move to US spelling --- src/attributes/codegen.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/attributes/codegen.md b/src/attributes/codegen.md index e18c8679d..ff38f3d98 100644 --- a/src/attributes/codegen.md +++ b/src/attributes/codegen.md @@ -358,7 +358,7 @@ trait object whose methods are attributed. The `instruction_set` attribute may be applied to a function to enable code generation for a specific instruction set supported by the target architecture. Currently, this is only available for `ARMv4T` devices where the architecture has "ARM code" and "Thumb code" available and a single program may -utilise both of these. If not specified the default instruction set for the target will be used. +utilize both of these. If not specified the default instruction set for the target will be used. ```rust #[instruction_set(arm::a32)] From e389abd88300e4ac3131e8761779e20c45b8b665 Mon Sep 17 00:00:00 2001 From: xd009642 Date: Tue, 16 Aug 2022 23:13:41 +0100 Subject: [PATCH 3/9] Apply feedback --- src/attributes.md | 1 + src/attributes/codegen.md | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/attributes.md b/src/attributes.md index 857cd7d72..194261c6f 100644 --- a/src/attributes.md +++ b/src/attributes.md @@ -246,6 +246,7 @@ The following is an index of all built-in attributes. - [`no_builtins`] — Disables use of certain built-in functions. - [`target_feature`] — Configure platform-specific code generation. - [`track_caller`] - Pass the parent call location to `std::panic::Location::caller()`. + - [`instruction_set`] - Specify the instruction set used to generate a functions code - Documentation - `doc` — Specifies documentation. See [The Rustdoc Book] for more information. [Doc comments] are transformed into `doc` attributes. diff --git a/src/attributes/codegen.md b/src/attributes/codegen.md index ff38f3d98..f75129dda 100644 --- a/src/attributes/codegen.md +++ b/src/attributes/codegen.md @@ -355,11 +355,17 @@ trait object whose methods are attributed. ## The `instruction_set` attribute -The `instruction_set` attribute may be applied to a function to enable code generation for a specific -instruction set supported by the target architecture. Currently, this is only available for `ARMv4T` -devices where the architecture has "ARM code" and "Thumb code" available and a single program may -utilize both of these. If not specified the default instruction set for the target will be used. +The *`instruction_set` attribute* may be applied to a function to enable code generation for a specific +instruction set supported by the target architecture. It uses the [_MetaListPath_] syntax and a path +comprised of the architecture and instruction set to specify how to generate the code for +architectures where a single program may utilize multiple instruction sets. +The following values are available on targets for the `ARMv4` architecture: + +* `arm::a32` - Uses ARM code. +* `arm::t32` - Uses Thumb code. + + ```rust #[instruction_set(arm::a32)] fn foo_arm_code() {} @@ -367,3 +373,5 @@ fn foo_arm_code() {} #[instruction_set(arm::t32)] fn bar_thumb_code() {} ``` + +[_MetaListPath_]: ../attributes.md#meta-item-attribute-syntax From 8919fc1bddcb09ddd06253b12c8495207e892e38 Mon Sep 17 00:00:00 2001 From: xd009642 Date: Wed, 17 Aug 2022 08:16:50 +0100 Subject: [PATCH 4/9] Mention ARMv5te --- src/attributes/codegen.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/attributes/codegen.md b/src/attributes/codegen.md index f75129dda..925b9ded2 100644 --- a/src/attributes/codegen.md +++ b/src/attributes/codegen.md @@ -360,7 +360,7 @@ instruction set supported by the target architecture. It uses the [_MetaListPath comprised of the architecture and instruction set to specify how to generate the code for architectures where a single program may utilize multiple instruction sets. -The following values are available on targets for the `ARMv4` architecture: +The following values are available on targets for the `ARMv4` and ARMv5te` architectures: * `arm::a32` - Uses ARM code. * `arm::t32` - Uses Thumb code. From 3315bbc80f763e087aeb196da8a7c616b6116ed9 Mon Sep 17 00:00:00 2001 From: xd009642 Date: Fri, 19 Aug 2022 08:48:36 +0100 Subject: [PATCH 5/9] Add link reference --- src/attributes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/attributes.md b/src/attributes.md index 194261c6f..7da42388d 100644 --- a/src/attributes.md +++ b/src/attributes.md @@ -297,6 +297,7 @@ The following is an index of all built-in attributes. [`global_allocator`]: runtime.md#the-global_allocator-attribute [`ignore`]: attributes/testing.md#the-ignore-attribute [`inline`]: attributes/codegen.md#the-inline-attribute +[`instruction_set`]: attributes/codegen.md#the-instruction-set-attribute [`link_name`]: items/external-blocks.md#the-link_name-attribute [`link_section`]: abi.md#the-link_section-attribute [`link`]: items/external-blocks.md#the-link-attribute From 33e327187495101b120b300fa55b8939c97eb250 Mon Sep 17 00:00:00 2001 From: xd009642 Date: Fri, 19 Aug 2022 08:49:34 +0100 Subject: [PATCH 6/9] Apply ignore --- src/attributes/codegen.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/attributes/codegen.md b/src/attributes/codegen.md index 925b9ded2..60f924d60 100644 --- a/src/attributes/codegen.md +++ b/src/attributes/codegen.md @@ -366,7 +366,7 @@ The following values are available on targets for the `ARMv4` and ARMv5te` archi * `arm::t32` - Uses Thumb code. -```rust +```rust,ignore #[instruction_set(arm::a32)] fn foo_arm_code() {} From d27f43f4e235e03394c6999566026ce9bc2d3e9e Mon Sep 17 00:00:00 2001 From: xd009642 Date: Fri, 19 Aug 2022 09:01:48 +0100 Subject: [PATCH 7/9] Remove spaces at end of lines --- src/attributes/codegen.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/attributes/codegen.md b/src/attributes/codegen.md index 60f924d60..57c1d5a18 100644 --- a/src/attributes/codegen.md +++ b/src/attributes/codegen.md @@ -358,7 +358,7 @@ trait object whose methods are attributed. The *`instruction_set` attribute* may be applied to a function to enable code generation for a specific instruction set supported by the target architecture. It uses the [_MetaListPath_] syntax and a path comprised of the architecture and instruction set to specify how to generate the code for -architectures where a single program may utilize multiple instruction sets. +architectures where a single program may utilize multiple instruction sets. The following values are available on targets for the `ARMv4` and ARMv5te` architectures: From dbb8e2a834fc0f1e16ed08128f24595af7e243b7 Mon Sep 17 00:00:00 2001 From: xd009642 Date: Fri, 19 Aug 2022 09:26:53 +0100 Subject: [PATCH 8/9] hopefully fix link --- src/attributes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/attributes.md b/src/attributes.md index 7da42388d..7da406bb3 100644 --- a/src/attributes.md +++ b/src/attributes.md @@ -297,7 +297,7 @@ The following is an index of all built-in attributes. [`global_allocator`]: runtime.md#the-global_allocator-attribute [`ignore`]: attributes/testing.md#the-ignore-attribute [`inline`]: attributes/codegen.md#the-inline-attribute -[`instruction_set`]: attributes/codegen.md#the-instruction-set-attribute +[`instruction_set`]: attributes/codegen.md#the-instruction_set-attribute [`link_name`]: items/external-blocks.md#the-link_name-attribute [`link_section`]: abi.md#the-link_section-attribute [`link`]: items/external-blocks.md#the-link-attribute From c47e316d9647d54540f046aa458ad0a902c6f171 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 16 Nov 2022 17:44:56 -0800 Subject: [PATCH 9/9] Fix backtick --- src/attributes/codegen.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/attributes/codegen.md b/src/attributes/codegen.md index 57c1d5a18..56840c439 100644 --- a/src/attributes/codegen.md +++ b/src/attributes/codegen.md @@ -360,7 +360,7 @@ instruction set supported by the target architecture. It uses the [_MetaListPath comprised of the architecture and instruction set to specify how to generate the code for architectures where a single program may utilize multiple instruction sets. -The following values are available on targets for the `ARMv4` and ARMv5te` architectures: +The following values are available on targets for the `ARMv4` and `ARMv5te` architectures: * `arm::a32` - Uses ARM code. * `arm::t32` - Uses Thumb code.