Skip to content

Commit

Permalink
Check for BMI instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
SChernykh committed May 30, 2024
1 parent 121f6dd commit 7ee603a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

namespace randomx {

Cpu::Cpu() : aes_(false), ssse3_(false), avx2_(false) {
Cpu::Cpu() : aes_(false), ssse3_(false), bmi_(false), avx2_(false) {
#ifdef HAVE_CPUID
int info[4];
cpuid(info, 0);
Expand All @@ -67,6 +67,7 @@ namespace randomx {
}
if (nIds >= 0x00000007) {
cpuid(info, 0x00000007);
bmi_ = (info[1] & (1 << 3)) != 0;
avx2_ = (info[1] & (1 << 5)) != 0;
}
#elif defined(__aarch64__)
Expand Down
5 changes: 4 additions & 1 deletion src/cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ namespace randomx {
bool hasSsse3() const {
return ssse3_;
}
bool hasBmi() const {
return bmi_;
}
bool hasAvx2() const {
return avx2_;
}
Expand All @@ -63,7 +66,7 @@ namespace randomx {
}

private:
bool aes_, ssse3_, avx2_;
bool aes_, ssse3_, bmi_, avx2_;
int manufacturer_string[4];
union
{
Expand Down

0 comments on commit 7ee603a

Please sign in to comment.