-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DRAFT] intrinsics for all architectures appear in rustdoc #1104
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Amanieu (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking back at #1055, I now realize that we don't need to add any doc(cfg)
at all. What we need to do is reorganize the arm/aarch64 code so that:
acle
contains code shared between ARM and AArch64.arm
contains ARM-specific code.aarch64
contains AArch64-specific code. It also needs to only re-exportacle
instead of all ofarm
.
This shouldn't be too difficult to do:
- The
neon
,crc
andcrypto
submodules ofarm
need to be moved toacle
. - The
sat
,dsp
andsimd32
submodules ofacle
need to be moved toarm
. - Some functions in
neon/mod.rs
are marked with#[cfg(target_arch = "arm")]
, these should be moved to aneon
module underarm
. - Don't worry about the
v6
,v7
andarmclang
modules for now: I'm actually considering deleting them since they aren't in the ARM spec.
Once this reorganization is done, we still need to add doc
to any cfg
blocks that match on target_feature
or target_arch
otherwise these functions will be excluded from docs generated from x86.
crates/core_arch/src/acle/hints.rs
Outdated
#[cfg(any(target_feature = "v6", target_arch = "aarch64", doc))] | ||
#[doc(cfg(target_arch = "arm"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding doc
to the cfg is correct: we want this function to be included in the documentation even if we aren't compiling for arm/aarch64 (e.g. the current target is x86).
However the doc(cfg)
is not needed here. We don't need to mark this function as ARM-only (which is incorrect: this function is available on both ARM and AArch64). We already have a blanket doc(cfg)
over the entire arm
and aarch64
top level modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I correct in understanding that aarch64
and arm
will each re-export all of acle
, so all the available intrinsics for a given target will get rendered together?
I'm not sure if there is known rationale for this, so please excuse my ignorance, but the naming of acle
is a little awkward; it usually stands for "Arm C Language Extension", which would be fine if it were simple bindings, but it looks like a subset. Does a name like arm_shared
make more sense here?
Out of curiosity, why does the same approach not work for v6
and the like? When you say that they "aren't in the ARM spec", which specification are you referring to? There are definitely intrinsics available at v7
, but not v6
, for example. One argument for keeping them all is so that run-time feature detection (std::detect
) can be used to guard intrinsics not available in target_feature
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, arm_shared
would make more sense here. Let's rename acle
to that.
I actually misread the ACLE spec, the v6
and v7
modules can stay in arm
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks for the hint, I found the blanket doc(cfg)
and hope to slowly get the idea :). Should be fixed with 8c6fdc5 .
Thanks a lot, I will make the changes accordingly, in small steps with about a step per day. This should help to change course early while remaining fast to review. |
Suggested by rust-lang#1104 (comment) The blanket inclusions mentioned in the comment are here: https://github.com/rust-lang/stdarch/blob/8a5da46643f27f14059891e6ef8e91598dc78247/crates/core_arch/src/mod.rs#L52:L52
I pushed the first tiny step towards moving modules to |
crates/core_arch/src/acle/mod.rs
Outdated
@@ -119,6 +119,9 @@ mod simd32; | |||
))] | |||
pub use self::simd32::*; | |||
|
|||
#[cfg(any(target_arch = "aarch64", target_feature = "v7"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to enable doc
here.
crates/core_arch/src/arm/mod.rs
Outdated
mod crc; | ||
#[cfg(any(target_arch = "aarch64", target_feature = "v7"))] | ||
pub use self::crc::*; | ||
pub use crate::core_arch::acle::crc::*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be needed, there is already a blanket re-export of acle
below.
crates/core_arch/src/acle/mod.rs
Outdated
@@ -119,6 +119,9 @@ mod simd32; | |||
))] | |||
pub use self::simd32::*; | |||
|
|||
#[cfg(any(target_arch = "aarch64", target_feature = "v7"))] | |||
pub mod crc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a pub use
here to re-export the contents of the module and make the module private.
When moving acle/(arm|simd32) I encountered test failures as arm seems to be governed by an auto-test suite. For now I thought it was best to teach it to skip the newly added functions. |
I was just about to move on to the last point when I noticed that there is a 135 of functions that are qualified with exactly Tomorrow is tackling bullet point number three and finally renaming |
That's correct for now. These intrinsics were only implemented for arm, and still need to be ported to aarch64. But this should be done in a separate PR. |
I have started with…
… and would still have to remove now unused /// Unsigned Add and Accumulate Long Pairwise.
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vpadal.u32))]
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(uadalp))]
pub unsafe fn vpadal_u32(a: uint64x1_t, b: uint32x2_t) -> uint64x1_t {
#[cfg(target_arch = "arm")]
{
vpadal_u32_(a, b)
}
#[cfg(target_arch = "aarch64")]
{
simd_add(vpaddl_u32_(b), a)
}
} Do I assume correctly that these would rather stay in ACLE/ARM_shared? Furthermore, the version you see here is just to 'make it work' and I would very much welcome any feedback to drive the impending improvements. Thanks a lot :)! PS: It looks like I have truly added some breakage this time which unfortunately I can't see locally - any suggestions on how to see these issues on my machine would be welcome, too. |
These functions are implemented for both arm and aarch64 and therefore should stay in arm_shared. You can run the same tests as CI by using the scripts: Refer to |
Thanks a lot for your help! Now that CI seems to be well, all that's left on my list is to rename I suggest to look into f14ce23 particularly - it maybe partially fixed thanks to your suggestions, but it's definitely where I might have committed crimes to the source code to somehow make CI happy (I was desperate). |
I will squash the commits, so I'm mainly using the overall diff to review rather than individual commits. Please go ahead and rename |
Alright, I believe to have addressed the change requests and renamed |
A few last minute issues, then I think we can merge:
|
|
…ually I thought it would/should have worked to put it on the top of the module then, at least the target_arch one
I have addressed the following:
Even though it appears CI points out an issue with __dbg that I couldn't solve with two attempts of adjusting cfg's. @Amanieu Maybe you could take a stab at the __dbg move yourself assuming CI is clear now. Whatever I was doing wasn't it. |
/// `VAL` is a compile-time constant integer in range `[0, 65535]`. | ||
/// | ||
/// The breakpoint instruction inserted is `BRK` on A64. | ||
#[cfg(all(target_arch = "aarch64", not(doc)))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cfg is no longer needed.
static_assert_imm16!(VAL); | ||
asm!("brk {}", const VAL); | ||
} | ||
|
||
/// Inserts a breakpoint instruction. | ||
/// | ||
/// `VAL` is a compile-time constant integer in range `[0, 255]`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the cfg
below.
#[cfg(target_feature = "aarch64")] | ||
#[cfg(any( | ||
all(target_feature = "v6k", not(target_feature = "mclass")), // excludes v6-M | ||
all(target_feature = "v7", target_feature = "mclass"), // v7-M | ||
doc | ||
))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[cfg(target_feature = "aarch64")] | |
#[cfg(any( | |
all(target_feature = "v6k", not(target_feature = "mclass")), // excludes v6-M | |
all(target_feature = "v7", target_feature = "mclass"), // v7-M | |
doc | |
))] | |
#[cfg(any( | |
target_feature = "aarch64", | |
all(target_feature = "v6k", not(target_feature = "mclass")), // excludes v6-M | |
all(target_feature = "v7", target_feature = "mclass"), // v7-M | |
doc | |
))] |
Same with the others below.
For #[link_name = "llvm.arm.dbg"]
fn dbg(_: i32); Make sure to remove the |
Actually, don't worry about it. I can see you're having trouble running the tests so I'll finish cleaning up this PR and merge it. |
Thanks so much, this is awesome! |
Note that actually shipping the updated stdarch with rustc is currently still blocked on rust-lang/rust#83278 getting resolved. |
I will keep pushing changes until all files mentioned in #1055 have been adjusted, and would be glad if you could let me know early if I generally get it right 😅.
This PR starts out with a sample on how I would go about this.
Thanks for your help.