Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions src/hashing/blake2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ mod reference;

pub use common::LastBlock;

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(all(
any(target_arch = "x86", target_arch = "x86_64"),
target_feature = "avx"
))]
mod avx;

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(all(
any(target_arch = "x86", target_arch = "x86_64"),
target_feature = "avx2"
))]
mod avx2;

use common::{b, s};
Expand Down Expand Up @@ -59,8 +65,11 @@ impl EngineS {
#[cfg(not(target_feature = "avx"))]
const HAS_AVX: bool = false;

if HAS_AVX {
return avx::compress_s(&mut self.h, &mut self.t, buf, last);
#[cfg(target_feature = "avx")]
{
if HAS_AVX {
return avx::compress_s(&mut self.h, &mut self.t, buf, last);
}
}
}
reference::compress_s(&mut self.h, &mut self.t, buf, last)
Expand Down Expand Up @@ -115,11 +124,18 @@ impl EngineB {
#[cfg(not(target_feature = "avx2"))]
const HAS_AVX2: bool = false;

if HAS_AVX2 {
return avx2::compress_b(&mut self.h, &mut self.t, buf, last);
#[cfg(target_feature = "avx2")]
{
if HAS_AVX2 {
return avx2::compress_b(&mut self.h, &mut self.t, buf, last);
}
}
if HAS_AVX {
return avx::compress_b(&mut self.h, &mut self.t, buf, last);

#[cfg(target_feature = "avx")]
{
if HAS_AVX {
return avx::compress_b(&mut self.h, &mut self.t, buf, last);
}
}
}
reference::compress_b(&mut self.h, &mut self.t, buf, last)
Expand Down
27 changes: 21 additions & 6 deletions src/hashing/sha2/impl256/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@

#[cfg(all(target_arch = "aarch64", feature = "use-stdsimd"))]
mod aarch64;
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]

#[cfg(all(
any(target_arch = "x86", target_arch = "x86_64"),
target_feature = "avx"
))]
mod avx;
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]

#[cfg(all(
any(target_arch = "x86", target_arch = "x86_64"),
target_feature = "sse4.1"
))]
mod sse41;
//TODO not finished yet
//#[cfg(all(target_arch = "x86_64", target_feature = "sha"))]
Expand All @@ -35,11 +43,18 @@ pub(crate) fn digest_block(state: &mut [u32; 8], block: &[u8]) {
#[cfg(not(target_feature = "sse4.1"))]
const HAS_SSE41: bool = false;

if HAS_AVX {
return avx::digest_block(state, block);
#[cfg(target_feature = "avx")]
{
if HAS_AVX {
return avx::digest_block(state, block);
}
}
if HAS_SSE41 {
return sse41::digest_block(state, block);

#[cfg(target_feature = "sse4.1")]
{
if HAS_SSE41 {
return sse41::digest_block(state, block);
}
}
}
#[cfg(target_arch = "aarch64")]
Expand Down