This commit is contained in:
Whatcookie 2026-03-25 02:33:03 -07:00 committed by GitHub
commit e9bcd2f8bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 70 additions and 0 deletions

View File

@ -710,6 +710,16 @@ jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, co
attributes.push_back("+sve2");
else
attributes.push_back("-sve2");
if (utils::has_lut())
attributes.push_back("+lut");
else
attributes.push_back("-lut");
if (utils::has_i8mm())
attributes.push_back("+i8mm");
else
attributes.push_back("-i8mm");
#endif
{

View File

@ -6,6 +6,7 @@
#if defined(ARCH_ARM64)
#include "Emu/CPU/Backends/AArch64/AArch64Common.h"
#include <arm_sve.h>
#endif
#ifdef _WIN32
@ -545,6 +546,59 @@ bool utils::has_sve2()
return g_value;
}
bool utils::has_lut()
{
static const bool g_value = []() -> bool
{
#if defined(__linux__)
return (getauxval(AT_HWCAP2) & HWCAP2_LUT) != 0;
#elif defined(__APPLE__)
int val = 0;
size_t len = sizeof(val);
sysctlbyname("hw.optional.arm.FEAT_LUT", &val, &len, nullptr, 0);
return val != 0;
#elif defined(_WIN32)
return 0;
#else
return 0;
#endif
}();
return g_value;
}
bool utils::has_i8mm()
{
static const bool g_value = []() -> bool
{
#if defined(__linux__)
return (getauxval(AT_HWCAP2) & HWCAP2_I8MM) != 0;
#elif defined(__APPLE__)
int val = 0;
size_t len = sizeof(val);
sysctlbyname("hw.optional.arm.FEAT_I8MM", &val, &len, nullptr, 0);
return val != 0;
#elif defined(_WIN32)
return IsProcessorFeaturePresent(PF_ARM_V86_I8MM_INSTRUCTIONS_AVAILABLE) != 0;
#else
return 0;
#endif
}();
return g_value;
}
#if defined(_MSC_VER)
#define sve_func
#else
#define sve_func __attribute__((__target__("+sve")))
#endif
// svcntb returns sve length in bytes, our function retuns length in bits
sve_func int utils::sve_length()
{
static const int g_value = static_cast<int>(svcntb() * 8);
return g_value;
}
#endif
std::string utils::get_cpu_brand()

View File

@ -64,6 +64,12 @@ namespace utils
bool has_sve();
bool has_sve2();
bool has_lut();
bool has_i8mm();
int sve_length();
#endif
std::string get_cpu_brand();