1 /* 2 * Copyright (c) 2021 Loongson Technology Corporation Limited 3 * Contributed by Jin Bo <[email protected]> 4 * Contributed by Lu Wang <[email protected]> 5 * 6 * Use of this source code is governed by a BSD-style license 7 * that can be found in the LICENSE file in the root of the source 8 * tree. An additional intellectual property rights grant can be found 9 * in the file PATENTS. All contributing project authors may 10 * be found in the AUTHORS file in the root of the source tree. 11 */ 12 13 #include "./vpx_config.h" 14 #include "vpx_ports/loongarch.h" 15 16 #define LOONGARCH_CFG2 0x02 17 #define LOONGARCH_CFG2_LSX (1 << 6) 18 #define LOONGARCH_CFG2_LASX (1 << 7) 19 20 #if CONFIG_RUNTIME_CPU_DETECT 21 #if defined(__loongarch__) && defined(__linux__) loongarch_cpu_caps(void)22int loongarch_cpu_caps(void) { 23 int reg = 0; 24 int flag = 0; 25 26 __asm__ volatile("cpucfg %0, %1 \n\t" : "+&r"(reg) : "r"(LOONGARCH_CFG2)); 27 if (reg & LOONGARCH_CFG2_LSX) flag |= HAS_LSX; 28 29 if (reg & LOONGARCH_CFG2_LASX) flag |= HAS_LASX; 30 31 return flag; 32 } 33 #else /* end __loongarch__ && __linux__ */ 34 #error \ 35 "--enable-runtime-cpu-detect selected, but no CPU detection method " \ 36 "available for your platform. Reconfigure with --disable-runtime-cpu-detect." 37 #endif 38 #else /* end CONFIG_RUNTIME_CPU_DETECT */ loongarch_cpu_caps(void)39int loongarch_cpu_caps(void) { return 0; } 40 #endif 41