Skip to content

[DRAFT] intrinsics for all architectures appear in rustdoc #1104

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

Merged
merged 45 commits into from
Apr 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
21b4259
Start working on architectures appear in Rustdoc
Byron Apr 1, 2021
8c6fdc5
Don't limit cargo doc unnecessarily
Byron Apr 2, 2021
f91d45f
Move arm/crc module to acle/crc as it is shared between ARM and AArch64
Byron Apr 2, 2021
dbc0820
Conform moved CRC module to existing conventions; make it appear in docs
Byron Apr 3, 2021
d589823
Move arm/crypto to acle/arm_shared
Byron Apr 3, 2021
553e32d
Move acle/sat to arm/ as it is only available there
Byron Apr 3, 2021
75792de
Make 'sat' show up in docs all the time.
Byron Apr 3, 2021
7463267
Move acle/dsp to arm; fix tests by skipping dsp arm functions
Byron Apr 3, 2021
00a0bbd
Make arm/dsp functions show up in docs
Byron Apr 3, 2021
0610bef
Fix use of 'dsp' module within simd32 (it was moved to /arm)
Byron Apr 3, 2021
4a101b8
Move acle/simd32 to arm/simd32; fix tests suite
Byron Apr 3, 2021
3263581
Move arm/neon to acle/neon (soon arm_shared)
Byron Apr 4, 2021
4ae11b3
The code generator now places output in acle.
Byron Apr 4, 2021
a63b0d4
Merge remote-tracking branch 'origin/master'
Byron Apr 7, 2021
02de848
Move ARM specific neon functions in acle/neon/… moved to arm/neon.rs
Byron Apr 7, 2021
2a698b1
Merge remote-tracking branch 'origin/master'
Byron Apr 9, 2021
2c48570
Move aarch64/arm neon functions to acle/arm_shared
Byron Apr 9, 2021
e22224d
Fix build errors
Byron Apr 9, 2021
306c600
Merge remote-tracking branch 'origin/master'
Byron Apr 9, 2021
df00775
pub(crate) fields to allow arm/neon to access types declared in acle…
Byron Apr 9, 2021
3b3caba
Add missing use statements for types
Byron Apr 9, 2021
f14ce23
Fix build on ARM
Byron Apr 9, 2021
6be7f85
Merge remote-tracking branch 'origin/master'
Byron Apr 12, 2021
f866c0a
Merge remote-tracking branch 'origin/master'
Byron Apr 13, 2021
ed04262
Merge remote-tracking branch 'origin/master'
Byron Apr 15, 2021
b17be0f
Merge remote-tracking branch 'origin/master'
Byron Apr 16, 2021
ff89355
Apply cargo fmt
Byron Apr 16, 2021
e201bf4
Apply suggestions from code review
Byron Apr 16, 2021
0f186e3
Apply review suggestions
Byron Apr 16, 2021
e8956b7
Merge remote-tracking branch 'origin/master'
Byron Apr 17, 2021
bd42df8
move arm::test_support to acle::test_support
Byron Apr 17, 2021
f141aa6
Don't ignore unused imports anymore
Byron Apr 17, 2021
f2c4eac
Remove all `#[cfg(target_arch = "arm")]` as it's redundant
Byron Apr 17, 2021
8794cae
rename 'acle' to 'arm_shared'
Byron Apr 17, 2021
213aaa9
Move __dbg intrinsic to 'arm' (from arm_shared)
Byron Apr 17, 2021
bb176aa
Add target_arch = "aarch64" and doc configs for each function individ…
Byron Apr 17, 2021
230f0be
Fix build?
Byron Apr 17, 2021
dc373ed
Split aarch64 parts in arm/armclang.rs into aarch64/armclang.rs
Byron Apr 17, 2021
52eaa8e
Revert "Move __dbg intrinsic to 'arm' (from arm_shared)"
Byron Apr 17, 2021
58ced63
Fix build
Byron Apr 17, 2021
90ccef5
More fixes
Amanieu Apr 17, 2021
e1b4810
More fixes
Amanieu Apr 17, 2021
749ee37
Ignore some intrinsic tests
Amanieu Apr 17, 2021
de7ce7f
More fixes
Amanieu Apr 17, 2021
7abb5d9
More fixes
Amanieu Apr 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions crates/core_arch/src/aarch64/armclang.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//! ARM compiler specific intrinsics
//!
//! # References
//!
//! - [ARM Compiler v 6.10 - armclang Reference Guide][arm_comp_ref]
//!
//! [arm_comp_ref]: https://developer.arm.com/docs/100067/0610

#[cfg(test)]
use stdarch_test::assert_instr;

/// Inserts a breakpoint instruction.
///
/// `VAL` is a compile-time constant integer in range `[0, 65535]`.
///
/// The breakpoint instruction inserted is `BRK` on A64.
#[cfg_attr(test, assert_instr(brk, VAL = 0))]
#[inline(always)]
#[rustc_legacy_const_generics(0)]
pub unsafe fn __breakpoint<const VAL: i32>() {
static_assert_imm16!(VAL);
asm!("brk {}", const VAL);
}
6 changes: 5 additions & 1 deletion crates/core_arch/src/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ pub use self::crc::*;
mod prefetch;
pub use self::prefetch::*;

pub use super::acle::*;
pub use super::arm_shared::*;

mod armclang;

pub use self::armclang::*;

#[cfg(test)]
use stdarch_test::assert_instr;
Expand Down
10 changes: 5 additions & 5 deletions crates/core_arch/src/aarch64/neon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub use self::generated::*;
// FIXME: replace neon with asimd

use crate::{
core_arch::{arm::*, simd::*, simd_llvm::*},
core_arch::{arm_shared::*, simd::*, simd_llvm::*},
hint::unreachable_unchecked,
mem::{transmute, zeroed},
};
Expand Down Expand Up @@ -2812,7 +2812,7 @@ pub unsafe fn vsriq_n_p16<const N: i32>(a: poly16x8_t, b: poly16x8_t) -> poly16x
#[cfg(test)]
mod tests {
use crate::core_arch::aarch64::test_support::*;
use crate::core_arch::arm::test_support::*;
use crate::core_arch::arm_shared::test_support::*;
use crate::core_arch::{aarch64::neon::*, aarch64::*, simd::*};
use std::mem::transmute;
use stdarch_test::simd_test;
Expand Down Expand Up @@ -4261,13 +4261,13 @@ mod tests {

#[cfg(test)]
#[cfg(target_endian = "little")]
#[path = "../../arm/neon/table_lookup_tests.rs"]
#[path = "../../arm_shared/neon/table_lookup_tests.rs"]
mod table_lookup_tests;

#[cfg(test)]
#[path = "../../arm/neon/shift_and_insert_tests.rs"]
#[path = "../../arm_shared/neon/shift_and_insert_tests.rs"]
mod shift_and_insert_tests;

#[cfg(test)]
#[path = "../../arm/neon/load_tests.rs"]
#[path = "../../arm_shared/neon/load_tests.rs"]
mod load_tests;
2 changes: 1 addition & 1 deletion crates/core_arch/src/aarch64/test_support.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::core_arch::{aarch64::neon::*, arm::*, simd::*};
use crate::core_arch::{aarch64::neon::*, arm_shared::*, simd::*};
use std::{i16, i32, i8, mem::transmute, u16, u32, u8, vec::Vec};

macro_rules! V_u64 {
Expand Down
16 changes: 0 additions & 16 deletions crates/core_arch/src/arm/armclang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,6 @@
#[cfg(test)]
use stdarch_test::assert_instr;

/// Inserts a breakpoint instruction.
///
/// `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)))]
#[cfg_attr(test, assert_instr(brk, VAL = 0))]
#[inline(always)]
#[rustc_legacy_const_generics(0)]
pub unsafe fn __breakpoint<const VAL: i32>() {
static_assert_imm16!(VAL);
asm!("brk {}", const VAL);
}

/// Inserts a breakpoint instruction.
///
/// `VAL` is a compile-time constant integer in range `[0, 255]`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the cfg below.

Expand All @@ -40,8 +26,6 @@ pub unsafe fn __breakpoint<const VAL: i32>() {
/// The current implementation only accepts values in range `[0, 255]`.
///
/// [arm_docs]: https://developer.arm.com/docs/100067/latest/compiler-specific-intrinsics/__breakpoint-intrinsic
#[cfg(any(target_arch = "arm", doc))]
#[doc(cfg(target_arch = "arm"))]
#[cfg_attr(test, assert_instr(bkpt, VAL = 0))]
#[inline(always)]
#[rustc_legacy_const_generics(0)]
Expand Down
File renamed without changes.
24 changes: 16 additions & 8 deletions crates/core_arch/src/acle/ex.rs → crates/core_arch/src/arm/ex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#[cfg(any(
all(target_feature = "v6k", not(target_feature = "mclass")), // excludes v6-M
all(target_feature = "v7", target_feature = "mclass"), // v7-M
doc
))]
pub unsafe fn __clrex() {
extern "C" {
Expand All @@ -21,9 +22,10 @@ pub unsafe fn __clrex() {
/// Executes a exclusive LDR instruction for 8 bit value.
// Supported: v6K, v7-M, v7-A, v7-R
// Not supported: v5, v6, v6-M
#[cfg(
#[cfg(any(
target_feature = "v6k", // includes v7-M but excludes v6-M
)]
doc
))]
pub unsafe fn __ldrexb(p: *const u8) -> u8 {
extern "C" {
#[link_name = "llvm.arm.ldrex.p0i8"]
Expand All @@ -36,9 +38,10 @@ pub unsafe fn __ldrexb(p: *const u8) -> u8 {
/// Executes a exclusive LDR instruction for 16 bit value.
// Supported: v6K, v7-M, v7-A, v7-R, v8
// Not supported: v5, v6, v6-M
#[cfg(
#[cfg(any(
target_feature = "v6k", // includes v7-M but excludes v6-M
)]
doc
))]
pub unsafe fn __ldrexh(p: *const u16) -> u16 {
extern "C" {
#[link_name = "llvm.arm.ldrex.p0i16"]
Expand All @@ -54,6 +57,7 @@ pub unsafe fn __ldrexh(p: *const u16) -> u16 {
#[cfg(any(
all(target_feature = "v6", not(target_feature = "mclass")), // excludes v6-M
all(target_feature = "v7", target_feature = "mclass"), // v7-M
doc
))]
pub unsafe fn __ldrex(p: *const u32) -> u32 {
extern "C" {
Expand All @@ -69,9 +73,10 @@ pub unsafe fn __ldrex(p: *const u32) -> u32 {
/// Returns `0` if the operation succeeded, or `1` if it failed
// supported: v6K, v7-M, v7-A, v7-R
// Not supported: v5, v6, v6-M
#[cfg(
#[cfg(any(
target_feature = "v6k", // includes v7-M but excludes v6-M
)]
doc
))]
pub unsafe fn __strexb(value: u32, addr: *mut u8) -> u32 {
extern "C" {
#[link_name = "llvm.arm.strex.p0i8"]
Expand All @@ -86,9 +91,11 @@ pub unsafe fn __strexb(value: u32, addr: *mut u8) -> u32 {
/// Returns `0` if the operation succeeded, or `1` if it failed
// Supported: v6K, v7-M, v7-A, v7-R, v8
// Not supported: v5, v6, v6-M
#[cfg(
#[cfg(target_feature = "aarch64")]
#[cfg(any(
target_feature = "v6k", // includes v7-M but excludes v6-M
)]
doc
))]
pub unsafe fn __strexh(value: u16, addr: *mut u16) -> u32 {
extern "C" {
#[link_name = "llvm.arm.strex.p0i16"]
Expand All @@ -106,6 +113,7 @@ pub unsafe fn __strexh(value: u16, addr: *mut u16) -> u32 {
#[cfg(any(
all(target_feature = "v6", not(target_feature = "mclass")), // excludes v6-M
all(target_feature = "v7", target_feature = "mclass"), // v7-M
doc
))]
pub unsafe fn __strex(value: u32, addr: *mut u32) -> u32 {
extern "C" {
Expand Down
105 changes: 83 additions & 22 deletions crates/core_arch/src/arm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,81 @@
//!
//! [arm_ref]: http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf
//! [arm_dat]: https://developer.arm.com/technologies/neon/intrinsics
#![allow(non_camel_case_types)]

mod armclang;

pub use self::armclang::*;

mod v6;
pub use self::v6::*;

#[cfg(any(target_arch = "aarch64", target_feature = "v7"))]
mod v7;
#[cfg(any(target_arch = "aarch64", target_feature = "v7"))]
pub use self::v7::*;
// Supported arches: 6, 7-M. See Section 10.1 of ACLE (e.g. SSAT)
#[cfg(any(target_feature = "v6", doc))]
mod sat;

#[cfg(any(target_feature = "v6", doc))]
pub use self::sat::*;

// Supported arches: 5TE, 7E-M. See Section 10.1 of ACLE (e.g. QADD)
// We also include the A profile even though DSP is deprecated on that profile as of ACLE 2.0 (see
// section 5.4.7)
// Here we workaround the difference between LLVM's +dsp and ACLE's __ARM_FEATURE_DSP by gating on
// '+v5te' rather than on '+dsp'
#[cfg(any(
// >= v5TE but excludes v7-M
all(target_feature = "v5te", not(target_feature = "mclass")),
// v7E-M
all(target_feature = "mclass", target_feature = "dsp"),
doc,
))]
pub mod dsp;

#[cfg(any(
// >= v5TE but excludes v7-M
all(target_feature = "v5te", not(target_feature = "mclass")),
// v7E-M
all(target_feature = "mclass", target_feature = "dsp"),
doc,
))]
pub use self::dsp::*;

// Deprecated in ACLE 2.0 for the A profile but fully supported on the M and R profiles, says
// Section 5.4.9 of ACLE. We'll expose these for the A profile even if deprecated
#[cfg(any(
// v7-A, v7-R
all(target_feature = "v6", not(target_feature = "mclass")),
// v7E-M
all(target_feature = "mclass", target_feature = "dsp"),
doc,
))]
mod simd32;

#[cfg(any(target_arch = "aarch64", target_feature = "v7", doc))]
mod neon;
#[cfg(any(target_arch = "aarch64", target_feature = "v7", doc))]
pub use self::neon::*;
#[cfg(any(
// v7-A, v7-R
all(target_feature = "v6", not(target_feature = "mclass")),
// v7E-M
all(target_feature = "mclass", target_feature = "dsp"),
doc,
))]
pub use self::simd32::*;

#[cfg(any(target_arch = "aarch64", target_feature = "v7"))]
mod crc;
#[cfg(any(target_arch = "aarch64", target_feature = "v7"))]
pub use self::crc::*;
#[cfg(any(target_feature = "v7", doc))]
mod v7;
#[cfg(any(target_feature = "v7", doc))]
pub use self::v7::*;

#[cfg(any(target_arch = "aarch64", target_feature = "v7"))]
mod crypto;
#[cfg(any(target_arch = "aarch64", target_feature = "v7"))]
pub use self::crypto::*;
mod ex;
pub use self::ex::*;

pub use crate::core_arch::acle::*;
pub use crate::core_arch::arm_shared::*;

#[cfg(test)]
use stdarch_test::assert_instr;

#[cfg(any(target_feature = "v7", doc))]
pub(crate) mod neon;
#[cfg(any(target_feature = "v7", doc))]
pub use neon::*;

/// Generates the trap instruction `UDF`
#[cfg(target_arch = "arm")]
#[cfg_attr(test, assert_instr(udf))]
Expand All @@ -47,6 +88,26 @@ pub unsafe fn udf() -> ! {
crate::intrinsics::abort()
}

#[cfg(test)]
#[cfg(any(target_arch = "aarch64", target_feature = "v7"))]
pub(crate) mod test_support;
/// Generates a DBG instruction.
///
/// This provides a hint to debugging and related systems. The argument must be
/// a constant integer from 0 to 15 inclusive. See implementation documentation
/// for the effect (if any) of this instruction and the meaning of the
/// argument. This is available only when compliling for AArch32.
// Section 10.1 of ACLE says that the supported arches are: 7, 7-M
// "The DBG hint instruction is added in ARMv7. It is UNDEFINED in the ARMv6 base architecture, and
// executes as a NOP instruction in ARMv6K and ARMv6T2." - ARM Architecture Reference Manual ARMv7-A
// and ARMv7-R edition (ARM DDI 0406C.c) sections D12.4.1 "ARM instruction set support" and D12.4.2
// "Thumb instruction set support"
#[cfg(any(target_feature = "v7", doc))]
#[inline(always)]
#[rustc_legacy_const_generics(0)]
pub unsafe fn __dbg<const IMM4: i32>() {
static_assert_imm4!(IMM4);
dbg(IMM4);
}

extern "C" {
#[link_name = "llvm.arm.dbg"]
fn dbg(_: i32);
}
Loading