Skip to content

Commit 8ada24a

Browse files
authored
Add support for Hexagon HVX (#509)
* Add support for Hexagon HVX Add vendor module and tests for Qualcomm Hexagon HVX (Hexagon Vector eXtension) SIMD support. HVX provides wide vector operations in either 64-byte (512-bit) or 128-byte (1024-bit) mode. Note: u8x128/i8x128 types are not included because portable-simd currently limits lane count to 64 (bitmask operations use u64). In 128-byte HVX mode, u8x64 maps to a half-vector (512-bit). * fixup! Add support for Hexagon HVX fixup! Add support for Hexagon HVX Address reviewer feedback: - Remove hexagon_hvx test file (existing tests suffice with -C flags) - Move HvxVector imports into their respective cfg modules - Change u8x128/i8x128 comment to FIXME for discoverability
1 parent 0c17257 commit 8ada24a

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

crates/core_simd/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
any(target_arch = "powerpc", target_arch = "powerpc64"),
3030
feature(stdarch_powerpc)
3131
)]
32+
#![cfg_attr(target_arch = "hexagon", feature(stdarch_hexagon))]
3233
#![warn(missing_docs, clippy::missing_inline_in_public_items)] // basically all items, really
3334
#![deny(
3435
unsafe_op_in_unsafe_fn,

crates/core_simd/src/vendor.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ mod powerpc;
3232

3333
#[cfg(target_arch = "loongarch64")]
3434
mod loongarch64;
35+
36+
#[cfg(target_arch = "hexagon")]
37+
mod hexagon;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//! Conversions to Hexagon HVX SIMD types.
2+
3+
use crate::simd::*;
4+
5+
// HVX 128-byte mode (1024-bit vectors)
6+
// Enable with: -C target-feature=+hvx-length128b
7+
#[cfg(target_feature = "hvx-length128b")]
8+
mod hvx_128b {
9+
use super::*;
10+
use core::arch::hexagon::v128::HvxVector;
11+
12+
// Full vectors (1024-bit) map to HvxVector
13+
from_transmute! { unsafe u16x64 => HvxVector }
14+
from_transmute! { unsafe i16x64 => HvxVector }
15+
from_transmute! { unsafe u32x32 => HvxVector }
16+
from_transmute! { unsafe i32x32 => HvxVector }
17+
from_transmute! { unsafe u64x16 => HvxVector }
18+
from_transmute! { unsafe i64x16 => HvxVector }
19+
20+
// FIXME: u8x128/i8x128 don't exist in portable-simd (max lane count is 64)
21+
// u8x64/i8x64 are only 512-bit (half of HvxVector in 128B mode)
22+
}
23+
24+
// HVX 64-byte mode (512-bit vectors)
25+
// Default when hvx-length128b is not specified
26+
#[cfg(not(target_feature = "hvx-length128b"))]
27+
mod hvx_64b {
28+
use super::*;
29+
use core::arch::hexagon::v64::HvxVector;
30+
31+
// Full vectors (512-bit) map to HvxVector
32+
from_transmute! { unsafe u8x64 => HvxVector }
33+
from_transmute! { unsafe i8x64 => HvxVector }
34+
from_transmute! { unsafe u16x32 => HvxVector }
35+
from_transmute! { unsafe i16x32 => HvxVector }
36+
from_transmute! { unsafe u32x16 => HvxVector }
37+
from_transmute! { unsafe i32x16 => HvxVector }
38+
from_transmute! { unsafe u64x8 => HvxVector }
39+
from_transmute! { unsafe i64x8 => HvxVector }
40+
}

0 commit comments

Comments
 (0)