Skip to content

Commit

Permalink
Rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
rubdos committed Aug 21, 2024
1 parent 2aa38c9 commit 701e9b5
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 135 deletions.
66 changes: 26 additions & 40 deletions curve25519-dalek/src/backend/vector/neon/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,23 @@ use core::arch::aarch64::vget_low_u32;
macro_rules! shuffle {
($vec:expr , $index:expr) => {
unsafe {
let v_n: [u32;8] = [
let v_n: [u32; 8] = [
$vec.extract::<0>(),
$vec.extract::<1>(),
$vec.extract::<2>(),
$vec.extract::<3>(),
$vec.extract::<4>(),
$vec.extract::<5>(),
$vec.extract::<6>(),
$vec.extract::<7>()
];
$vec.extract::<7>(),
];
#[rustfmt::skip]
u32x4x2::new(
core::mem::transmute::<[u32; 4], u32x4>(
[v_n[$index[0]], v_n[$index[1]], v_n[$index[2]], v_n[$index[3]]]),
core::mem::transmute::<[u32; 4], u32x4>(
[v_n[$index[4]], v_n[$index[5]], v_n[$index[6]], v_n[$index[7]]])
)
)
}
};
}
Expand All @@ -90,18 +91,22 @@ macro_rules! shuffle {
macro_rules! blend {
($vec0: expr, $vec1: expr, $index:expr) => {
unsafe {
let v_n: [u32;8] = [
let v_n: [u32; 8] = [
$vec0.extract::<0>(),
$vec0.extract::<1>(),
$vec0.extract::<2>(),
$vec0.extract::<3>(),
$vec1.extract::<0>(),
$vec1.extract::<1>(),
$vec1.extract::<2>(),
$vec1.extract::<3>()
];
core::mem::transmute::<[u32; 4], u32x4>(
[v_n[$index[0]], v_n[$index[1]], v_n[$index[2]], v_n[$index[3]]])
$vec1.extract::<3>(),
];
core::mem::transmute::<[u32; 4], u32x4>([
v_n[$index[0]],
v_n[$index[1]],
v_n[$index[2]],
v_n[$index[3]],
])
}
};
}
Expand All @@ -118,10 +123,10 @@ fn unpack_pair(src: u32x4x2) -> (u32x2x2, u32x2x2) {
let b0: u32x2;
let b1: u32x2;
unsafe {
a0 = vget_low_u32(src.0.0).into();
a1 = vget_low_u32(src.0.1).into();
b0 = vget_high_u32(src.0.0).into();
b1 = vget_high_u32(src.0.1).into();
a0 = vget_low_u32(src.0 .0).into();
a1 = vget_low_u32(src.0 .1).into();
b0 = vget_high_u32(src.0 .0).into();
b1 = vget_high_u32(src.0 .1).into();
}
return (u32x2x2::new(a0, a1), u32x2x2::new(b0, b1));
}
Expand Down Expand Up @@ -193,7 +198,7 @@ impl ConditionallySelectable for FieldElement2625x4 {
a.0[1] ^ (mask_vec & (a.0[1] ^ b.0[1])),
a.0[2] ^ (mask_vec & (a.0[2] ^ b.0[2])),
a.0[3] ^ (mask_vec & (a.0[3] ^ b.0[3])),
a.0[4] ^ (mask_vec & (a.0[4] ^ b.0[4]))
a.0[4] ^ (mask_vec & (a.0[4] ^ b.0[4])),
])
}

Expand Down Expand Up @@ -266,7 +271,6 @@ impl FieldElement2625x4 {
self.shuffle(Shuffle::BACD)
}


// Can probably be sped up using multiple vset/vget instead of table
#[inline]
pub fn blend(&self, other: FieldElement2625x4, control: Lanes) -> FieldElement2625x4 {
Expand Down Expand Up @@ -326,7 +330,7 @@ impl FieldElement2625x4 {

buf[i] = u32x4x2::new(
u32x4::new(a_2i, b_2i, a_2i_1, b_2i_1),
u32x4::new(c_2i, d_2i, c_2i_1, d_2i_1)
u32x4::new(c_2i, d_2i, c_2i_1, d_2i_1),
);
}
return FieldElement2625x4(buf).reduce();
Expand Down Expand Up @@ -368,20 +372,12 @@ impl FieldElement2625x4 {
use core::arch::aarch64::vqshlq_u32;

let c: u32x4x2 = u32x4x2::new(
vqshlq_u32(v.0.0, shifts.0.into()).into(),
vqshlq_u32(v.0.1, shifts.1.into()).into(),
vqshlq_u32(v.0 .0, shifts.0.into()).into(),
vqshlq_u32(v.0 .1, shifts.1.into()).into(),
);
u32x4x2::new(
vcombine_u32(
vget_high_u32(c.0.0),
vget_low_u32(c.0.0),
)
.into(),
vcombine_u32(
vget_high_u32(c.0.1),
vget_low_u32(c.0.1),
)
.into(),
vcombine_u32(vget_high_u32(c.0 .0), vget_low_u32(c.0 .0)).into(),
vcombine_u32(vget_high_u32(c.0 .1), vget_low_u32(c.0 .1)).into(),
)
}
};
Expand All @@ -390,16 +386,8 @@ impl FieldElement2625x4 {
unsafe {
use core::arch::aarch64::vcombine_u32;
u32x4x2::new(
vcombine_u32(
vget_low_u32(v_lo.0.0),
vget_high_u32(v_hi.0.0),
)
.into(),
vcombine_u32(
vget_low_u32(v_lo.0.1),
vget_high_u32(v_hi.0.1),
)
.into(),
vcombine_u32(vget_low_u32(v_lo.0 .0), vget_high_u32(v_hi.0 .0)).into(),
vcombine_u32(vget_low_u32(v_lo.0 .1), vget_high_u32(v_hi.0 .1)).into(),
)
}
};
Expand Down Expand Up @@ -874,5 +862,3 @@ mod test {
assert_eq!(x3, splits[3]);
}
}


Loading

0 comments on commit 701e9b5

Please sign in to comment.