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 31, 2024
1 parent 121f6dd commit 1b1f6d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifdef _MSC_VER
#pragma warning(disable : 4514)
#endif

#include "cpu.hpp"

#if defined(_M_X64) || defined(__x86_64__)
Expand All @@ -48,7 +52,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 +71,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 1b1f6d2

Please sign in to comment.