Skip to content

Commit

Permalink
Single alias for FastFirst scan mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroMemes committed Dec 14, 2022
1 parent e9409e6 commit 17f90f1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
17 changes: 10 additions & 7 deletions include/libhat/Scanner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ namespace hat {
namespace detail {

enum class scan_mode {
Auto,
Search,
FastFirst,
AVX2,
AVX512,
Neon
Auto, // Automatically choose the mode to use
Search, // std::search
FastFirst, // std::find + std::equal
AVX2, // x86 AVX2
AVX512, // x86 AVX512
Neon, // ARM Neon

// Fallback mode to use for SIMD remaining bytes
Single = FastFirst
};

template<scan_mode>
Expand Down Expand Up @@ -121,7 +124,7 @@ namespace hat {
signature_view signature
) {
if LIBHAT_IF_CONSTEVAL {
return detail::find_pattern<detail::scan_mode::FastFirst>(begin, end, signature);
return detail::find_pattern<detail::scan_mode::Single>(begin, end, signature);
} else {
return detail::find_pattern<detail::scan_mode::Auto>(begin, end, signature);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@ namespace hat::detail {
}
#endif
// If none of the vectorized implementations are available/supported, then fallback to scanning per-byte
return find_pattern<scan_mode::FastFirst>(begin, end, signature);
return find_pattern<scan_mode::Single>(begin, end, signature);
}
}
2 changes: 1 addition & 1 deletion src/arch/arm/Neon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace hat::detail {
}
}

return find_pattern<scan_mode::FastFirst>(begin, end, signature);
return find_pattern<scan_mode::Single>(begin, end, signature);
}
}
#endif
2 changes: 1 addition & 1 deletion src/arch/x86/AVX2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace hat::detail {

// Look in remaining bytes that couldn't be grouped into 256 bits
begin = reinterpret_cast<std::byte*>(vec);
return find_pattern<scan_mode::FastFirst>(begin, end, signature);
return find_pattern<scan_mode::Single>(begin, end, signature);
}
}
#endif
2 changes: 1 addition & 1 deletion src/arch/x86/AVX512.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace hat::detail {

// Look in remaining bytes that couldn't be grouped into 512 bits
begin = reinterpret_cast<std::byte*>(vec);
return find_pattern<scan_mode::FastFirst>(begin, end, signature);
return find_pattern<scan_mode::Single>(begin, end, signature);
}
}
#endif

0 comments on commit 17f90f1

Please sign in to comment.