================ @@ -93,6 +93,55 @@ DNBArchMachARM64::SoftwareBreakpointOpcode(nub_size_t byte_size) { uint32_t DNBArchMachARM64::GetCPUType() { return CPU_TYPE_ARM64; } +static std::once_flag g_cpu_has_sme_once; +bool DNBArchMachARM64::CPUHasSME() { + static bool g_has_sme = false; + std::call_once(g_cpu_has_sme_once, []() { + int ret = 0; + size_t size = sizeof(ret); + if (sysctlbyname("hw.optional.arm.FEAT_SME", &ret, &size, NULL, 0) != -1) + g_has_sme = ret == 1; + }); + return g_has_sme; +} + +static std::once_flag g_cpu_has_sme2_once; +bool DNBArchMachARM64::CPUHasSME2() { + static bool g_has_sme2 = false; + std::call_once(g_cpu_has_sme2_once, []() { + int ret = 0; + size_t size = sizeof(ret); + if (sysctlbyname("hw.optional.arm.FEAT_SME2", &ret, &size, NULL, 0) != -1) + g_has_sme2 = ret == 1; + }); + return g_has_sme2; +} + +static std::once_flag g_sme_max_svl_once; +unsigned int DNBArchMachARM64::GetSMEMaxSVL() { + static unsigned int g_sme_max_svl = 0; + std::call_once(g_sme_max_svl_once, []() { + if (CPUHasSME()) { + unsigned int ret = 0; + size_t size = sizeof(ret); + if (sysctlbyname("hw.optional.arm.sme_max_svl_b", &ret, &size, NULL, 0) != + -1) + g_sme_max_svl = ret; + else + g_sme_max_svl = get_svl_bytes(); + } + }); + return g_sme_max_svl; +} + +// This function can only be called on systems with hw.optional.arm.FEAT_SME +// It will return the maximum SVL length for this process. +uint16_t __attribute__((target("sme"))) DNBArchMachARM64::get_svl_bytes(void) { + uint64_t ret = 0; + asm volatile("rdsvl %[ret], #1" : [ret] "=r"(ret)); ---------------- DavidSpickett wrote:
Are you sure this is the maximum not the current? https://developer.arm.com/documentation/ddi0602/2024-09/SME-Instructions/RDSVL--Read-multiple-of-Streaming-SVE-vector-register-size-to-scalar-register- Though if the kernel doesn't have a way to change it, for Darwin, it will be the maximum value. But strictly speaking. https://github.com/llvm/llvm-project/pull/119171 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits