Skip to content

Commit

Permalink
Generator supports creating neon instructions from YAML
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamesbarford committed Dec 18, 2024
1 parent 51a4042 commit d8cdd29
Show file tree
Hide file tree
Showing 14 changed files with 77,149 additions and 60,096 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ members = [
"crates/std_detect",
"crates/stdarch-gen-arm",
"crates/stdarch-gen-loongarch",
"crates/stdarch-gen",
"crates/stdarch-gen2",
"crates/intrinsic-test",
"examples/"
Expand Down
38,112 changes: 15,891 additions & 22,221 deletions crates/core_arch/src/aarch64/neon/generated.rs

Large diffs are not rendered by default.

78,508 changes: 40,729 additions & 37,779 deletions crates/core_arch/src/arm_shared/neon/generated.rs

Large diffs are not rendered by default.

218 changes: 218 additions & 0 deletions crates/core_arch/src/arm_shared/neon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,142 @@ use crate::{core_arch::simd::*, hint::unreachable_unchecked, intrinsics::simd::*
#[cfg(test)]
use stdarch_test::assert_instr;

#[cfg_attr(
not(target_arch = "arm"),
stable(feature = "neon_intrinsics", since = "1.59.0")
)]
#[cfg_attr(
target_arch = "arm",
unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")
)]
pub trait AsUnsigned {
#[cfg_attr(
not(target_arch = "arm"),
stable(feature = "neon_intrinsics", since = "1.59.0")
)]
#[cfg_attr(
target_arch = "arm",
unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")
)]
type Unsigned: ?Sized;

#[cfg_attr(
not(target_arch = "arm"),
stable(feature = "neon_intrinsics", since = "1.59.0")
)]
#[cfg_attr(
target_arch = "arm",
unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")
)]
unsafe fn as_unsigned(self) -> Self::Unsigned;
}

#[cfg_attr(
not(target_arch = "arm"),
stable(feature = "neon_intrinsics", since = "1.59.0")
)]
#[cfg_attr(
target_arch = "arm",
unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")
)]
pub trait AsSigned {
#[cfg_attr(
not(target_arch = "arm"),
stable(feature = "neon_intrinsics", since = "1.59.0")
)]
#[cfg_attr(
target_arch = "arm",
unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")
)]
type Signed: ?Sized;

#[cfg_attr(
not(target_arch = "arm"),
stable(feature = "neon_intrinsics", since = "1.59.0")
)]
#[cfg_attr(
target_arch = "arm",
unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")
)]
unsafe fn as_signed(self) -> Self::Signed;
}

macro_rules! impl_sign_conversions {
($(($signed:ty, $unsigned:ty))*) => ($(
#[cfg_attr(
not(target_arch = "arm"),
stable(feature = "neon_intrinsics", since = "1.59.0")
)]
#[cfg_attr(
target_arch = "arm",
unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")
)]
impl AsUnsigned for $signed {
type Unsigned = $unsigned;

#[inline]
unsafe fn as_unsigned(self) -> $unsigned {
crate::mem::transmute(self)
}
}

#[cfg_attr(
not(target_arch = "arm"),
stable(feature = "neon_intrinsics", since = "1.59.0")
)]
#[cfg_attr(
target_arch = "arm",
unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")
)]
impl AsSigned for $unsigned {
type Signed = $signed;

#[inline]
unsafe fn as_signed(self) -> $signed {
crate::mem::transmute(self)
}
}
)*)
}

macro_rules! impl_sign_conversions_neon {
($(($signed:ty, $unsigned:ty))*) => ($(
#[cfg_attr(
not(target_arch = "arm"),
stable(feature = "neon_intrinsics", since = "1.59.0")
)]
#[cfg_attr(
target_arch = "arm",
unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")
)]
impl AsUnsigned for $signed {
type Unsigned = $unsigned;

#[inline]
unsafe fn as_unsigned(self) -> $unsigned {
crate::mem::transmute(self)
}
}

#[cfg_attr(
not(target_arch = "arm"),
stable(feature = "neon_intrinsics", since = "1.59.0")
)]
#[cfg_attr(
target_arch = "arm",
unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800")
)]
impl AsSigned for $unsigned {
type Signed = $signed;

#[inline]
unsafe fn as_signed(self) -> $signed {
crate::mem::transmute(self)
}
}
)*)
}

pub(crate) type p8 = u8;
pub(crate) type p16 = u16;
pub(crate) type p64 = u64;
Expand Down Expand Up @@ -1033,6 +1169,88 @@ pub struct poly64x2x4_t(
pub poly64x2_t,
);

impl_sign_conversions! {
(i8, u8)
(i16, u16)
(i32, u32)
(i64, u64)
(*const i8, *const u8)
(*const i16, *const u16)
(*const i32, *const u32)
(*const i64, *const u64)
(*mut i8, *mut u8)
(*mut i16, *mut u16)
(*mut i32, *mut u32)
(*mut i64, *mut u64)
(int16x4_t, uint16x4_t)
(int16x8_t, uint16x8_t)
(int32x2_t, uint32x2_t)
(int32x4_t, uint32x4_t)
(int64x1_t, uint64x1_t)
(int64x2_t, uint64x2_t)
(int8x16_t, uint8x16_t)
(int8x8_t, uint8x8_t)
(uint16x4_t, int16x4_t)
(uint16x8_t, int16x8_t)
(uint32x2_t, int32x2_t)
(uint32x4_t, int32x4_t)
(uint64x1_t, int64x1_t)
(uint64x2_t, int64x2_t)
(uint8x16_t, int8x16_t)
(uint8x8_t, int8x8_t)
}

impl_sign_conversions_neon! {
(int16x4x2_t, uint16x4x2_t)
(int16x4x3_t, uint16x4x3_t)
(int16x4x4_t, uint16x4x4_t)
(int16x8x2_t, uint16x8x2_t)
(int16x8x3_t, uint16x8x3_t)
(int16x8x4_t, uint16x8x4_t)
(int32x2x2_t, uint32x2x2_t)
(int32x2x3_t, uint32x2x3_t)
(int32x2x4_t, uint32x2x4_t)
(int32x4x2_t, uint32x4x2_t)
(int32x4x3_t, uint32x4x3_t)
(int32x4x4_t, uint32x4x4_t)
(int64x1x2_t, uint64x1x2_t)
(int64x1x3_t, uint64x1x3_t)
(int64x1x4_t, uint64x1x4_t)
(int64x2x2_t, uint64x2x2_t)
(int64x2x3_t, uint64x2x3_t)
(int64x2x4_t, uint64x2x4_t)
(int8x16x2_t, uint8x16x2_t)
(int8x16x3_t, uint8x16x3_t)
(int8x16x4_t, uint8x16x4_t)
(int8x8x2_t, uint8x8x2_t)
(int8x8x3_t, uint8x8x3_t)
(int8x8x4_t, uint8x8x4_t)
(uint16x4x2_t, int16x4x2_t)
(uint16x4x3_t, int16x4x3_t)
(uint16x4x4_t, int16x4x4_t)
(uint16x8x2_t, int16x8x2_t)
(uint16x8x3_t, int16x8x3_t)
(uint16x8x4_t, int16x8x4_t)
(uint32x2x2_t, int32x2x2_t)
(uint32x2x3_t, int32x2x3_t)
(uint32x2x4_t, int32x2x4_t)
(uint32x4x2_t, int32x4x2_t)
(uint32x4x3_t, int32x4x3_t)
(uint32x4x4_t, int32x4x4_t)
(uint64x1x2_t, int64x1x2_t)
(uint64x1x3_t, int64x1x3_t)
(uint64x1x4_t, int64x1x4_t)
(uint64x2x2_t, int64x2x2_t)
(uint64x2x3_t, int64x2x3_t)
(uint64x2x4_t, int64x2x4_t)
(uint8x16x2_t, int8x16x2_t)
(uint8x16x3_t, int8x16x3_t)
(uint8x16x4_t, int8x16x4_t)
(uint8x8x2_t, int8x8x2_t)
(uint8x8x3_t, int8x8x3_t)
(uint8x8x4_t, int8x8x4_t)
}

#[allow(improper_ctypes)]
extern "unadjusted" {
// absolute value (64-bit)
Expand Down
Loading

0 comments on commit d8cdd29

Please sign in to comment.