Skip to content

Commit

Permalink
add neon to/from bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
franziskuskiefer committed Sep 27, 2024
1 parent 8a92adc commit 88d06f0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions libcrux-ml-kem/src/vector/neon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ impl Operations for SIMD128Vector {
to_i16_array(x)
}

fn to_bytes(x: Self, out: &mut [u8]) {
libcrux_intrinsics::arm64::_vst1q_u8(
out,
libcrux_intrinsics::arm64::_vreinterpretq_u8_s16(x.high),
);
libcrux_intrinsics::arm64::_vst1q_u8(
&mut out[16..],
libcrux_intrinsics::arm64::_vreinterpretq_u8_s16(x.low),
);
}

fn from_bytes(bytes: &[u8]) -> Self {
Self {
low: libcrux_intrinsics::arm64::_vreinterpretq_s16_u8(
libcrux_intrinsics::arm64::_vld1q_u8(&bytes[16..]),
),
high: libcrux_intrinsics::arm64::_vreinterpretq_s16_u8(
libcrux_intrinsics::arm64::_vld1q_u8(bytes),
),
}
}

fn add(lhs: Self, rhs: &Self) -> Self {
add(lhs, rhs)
}
Expand Down

0 comments on commit 88d06f0

Please sign in to comment.