From cc86e94cd5636b1b83fde08a6a82842d182684d7 Mon Sep 17 00:00:00 2001 From: Yang Liu Date: Tue, 5 Mar 2024 00:49:57 +0800 Subject: [LA64] Detect the existence of LBT extension (#1325) --- src/main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 5e14b677..fdf4edcd 100644 --- a/src/main.c +++ b/src/main.c @@ -445,11 +445,14 @@ HWCAP2_ECV if(arm64_afp) printf_log(LOG_INFO, " AFP"); #elif defined(LA64) - printf_log(LOG_INFO, "Dynarec for LoongArch"); - char *p = getenv("BOX64_DYNAREC_LA64NOEXT"); + printf_log(LOG_INFO, "Dynarec for LoongArch "); + char* p = getenv("BOX64_DYNAREC_LA64NOEXT"); if(p == NULL || p[0] == '0') { - // We don't bother to detect it, it's there. - la64_lbt = 1; + uint32_t cpucfg2 = 0, idx = 2; + // there are other extensions, but we don't care. + asm volatile("cpucfg %0, %1" : "=r"(cpucfg2) : "r"(idx)); + if (la64_lbt = (cpucfg2 >> 18) & 0b1) + printf_log(LOG_INFO, "with extension LBT_X86"); } #elif defined(RV64) void RV64_Detect_Function(); -- cgit 1.4.1