Skip to content

Commit 1ce1c64

Browse files
committedNov 13, 2021
Rewrite Arm transmutes, reading std::arch closer
1 parent 6ddf7ad commit 1ce1c64

File tree

2 files changed

+59
-38
lines changed

2 files changed

+59
-38
lines changed
 

‎crates/core_simd/src/vendor.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@ macro_rules! from_transmute {
1515
};
1616
}
1717

18+
/// Conversions to x86's SIMD types.
1819
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
1920
mod x86;
2021

2122
#[cfg(any(target_arch = "wasm32"))]
2223
mod wasm32;
2324

24-
#[cfg(any(
25-
target_arch = "aarch64",
26-
all(target_arch = "arm", target_feature = "v7")
27-
))]
25+
#[cfg(any(target_arch = "aarch64", target_arch = "arm",))]
2826
mod arm;
2927

3028
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]

‎crates/core_simd/src/vendor/arm.rs

+57-34
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,76 @@
1+
#![allow(unused)]
12
use crate::simd::*;
23

3-
#[cfg(all(target_arch = "arm", target_feature = "v7"))]
4+
#[cfg(target_arch = "arm")]
45
use core::arch::arm::*;
56

67
#[cfg(target_arch = "aarch64")]
78
use core::arch::aarch64::*;
89

9-
from_transmute! { unsafe f32x2 => float32x2_t }
10-
from_transmute! { unsafe f32x4 => float32x4_t }
11-
12-
from_transmute! { unsafe u8x8 => uint8x8_t }
13-
from_transmute! { unsafe u8x16 => uint8x16_t }
14-
from_transmute! { unsafe i8x8 => int8x8_t }
15-
from_transmute! { unsafe i8x16 => int8x16_t }
16-
from_transmute! { unsafe u8x8 => poly8x8_t }
17-
from_transmute! { unsafe u8x16 => poly8x16_t }
18-
19-
from_transmute! { unsafe u16x4 => uint16x4_t }
20-
from_transmute! { unsafe u16x8 => uint16x8_t }
21-
from_transmute! { unsafe i16x4 => int16x4_t }
22-
from_transmute! { unsafe i16x8 => int16x8_t }
23-
from_transmute! { unsafe u16x4 => poly16x4_t }
24-
from_transmute! { unsafe u16x8 => poly16x8_t }
25-
26-
from_transmute! { unsafe u32x2 => uint32x2_t }
27-
from_transmute! { unsafe u32x4 => uint32x4_t }
28-
from_transmute! { unsafe i32x2 => int32x2_t }
29-
from_transmute! { unsafe i32x4 => int32x4_t }
30-
31-
from_transmute! { unsafe Simd<u64, 1> => uint64x1_t }
32-
from_transmute! { unsafe u64x2 => uint64x2_t }
33-
from_transmute! { unsafe Simd<i64, 1> => int64x1_t }
34-
from_transmute! { unsafe i64x2 => int64x2_t }
35-
from_transmute! { unsafe Simd<u64, 1> => poly64x1_t }
36-
from_transmute! { unsafe u64x2 => poly64x2_t }
37-
38-
#[cfg(all(target_arch = "arm", target_feature = "v7"))]
39-
mod arm {
10+
#[cfg(any(
11+
target_arch = "aarch64",
12+
all(target_arch = "arm", target_feature = "v7"),
13+
))]
14+
mod neon {
15+
use super::*;
16+
17+
from_transmute! { unsafe f32x2 => float32x2_t }
18+
from_transmute! { unsafe f32x4 => float32x4_t }
19+
20+
from_transmute! { unsafe u8x8 => uint8x8_t }
21+
from_transmute! { unsafe u8x16 => uint8x16_t }
22+
from_transmute! { unsafe i8x8 => int8x8_t }
23+
from_transmute! { unsafe i8x16 => int8x16_t }
24+
from_transmute! { unsafe u8x8 => poly8x8_t }
25+
from_transmute! { unsafe u8x16 => poly8x16_t }
26+
27+
from_transmute! { unsafe u16x4 => uint16x4_t }
28+
from_transmute! { unsafe u16x8 => uint16x8_t }
29+
from_transmute! { unsafe i16x4 => int16x4_t }
30+
from_transmute! { unsafe i16x8 => int16x8_t }
31+
from_transmute! { unsafe u16x4 => poly16x4_t }
32+
from_transmute! { unsafe u16x8 => poly16x8_t }
33+
34+
from_transmute! { unsafe u32x2 => uint32x2_t }
35+
from_transmute! { unsafe u32x4 => uint32x4_t }
36+
from_transmute! { unsafe i32x2 => int32x2_t }
37+
from_transmute! { unsafe i32x4 => int32x4_t }
38+
39+
from_transmute! { unsafe Simd<u64, 1> => uint64x1_t }
40+
from_transmute! { unsafe u64x2 => uint64x2_t }
41+
from_transmute! { unsafe Simd<i64, 1> => int64x1_t }
42+
from_transmute! { unsafe i64x2 => int64x2_t }
43+
from_transmute! { unsafe Simd<u64, 1> => poly64x1_t }
44+
from_transmute! { unsafe u64x2 => poly64x2_t }
45+
}
46+
47+
#[cfg(any(
48+
all(target_feature = "v5te", not(target_feature = "mclass")),
49+
all(target_feature = "mclass", target_feature = "dsp"),
50+
))]
51+
mod dsp {
4052
use super::*;
41-
from_transmute! { unsafe Simd<u8, 4> => uint8x4_t }
42-
from_transmute! { unsafe Simd<i8, 4> => int8x4_t }
4353

4454
from_transmute! { unsafe Simd<u16, 2> => uint16x2_t }
4555
from_transmute! { unsafe Simd<i16, 2> => int16x2_t }
4656
}
4757

58+
#[cfg(any(
59+
all(target_feature = "v6", not(target_feature = "mclass")),
60+
all(target_feature = "mclass", target_feature = "dsp"),
61+
))]
62+
mod simd32 {
63+
use super::*;
64+
65+
from_transmute! { unsafe Simd<u8, 4> => uint8x4_t }
66+
from_transmute! { unsafe Simd<i8, 4> => int8x4_t }
67+
}
68+
4869
#[cfg(target_arch = "aarch64")]
4970
mod aarch64 {
71+
use super::neon::*;
5072
use super::*;
73+
5174
from_transmute! { unsafe Simd<f64, 1> => float64x1_t }
5275
from_transmute! { unsafe f64x2 => float64x2_t }
5376
}

0 commit comments

Comments
 (0)
Please sign in to comment.