Skip to content
Open
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
10 changes: 10 additions & 0 deletions Utilities/JITLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

{
Expand Down
54 changes: 54 additions & 0 deletions rpcs3/util/sysinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#if defined(ARCH_ARM64)
#include "Emu/CPU/Backends/AArch64/AArch64Common.h"
#include <arm_sve.h>
#endif

#ifdef _WIN32
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions rpcs3/util/sysinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Loading