2 * Copyright (c) 2021 Loongson Technology Corporation Limited
3 * Contributed by Jin Bo <jinbo@loongson.cn>
4 * Contributed by Lu Wang <wanglu@loongson.cn>
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.
13 #include "./vpx_config.h"
14 #include "vpx_ports/loongarch.h"
16 #define LOONGARCH_CFG2 0x02
17 #define LOONGARCH_CFG2_LSX (1 << 6)
18 #define LOONGARCH_CFG2_LASX (1 << 7)
20 #if CONFIG_RUNTIME_CPU_DETECT
21 #if defined(__loongarch__) && defined(__linux__)
22 int loongarch_cpu_caps(void) {
26 __asm__ volatile("cpucfg %0, %1 \n\t" : "+&r"(reg) : "r"(LOONGARCH_CFG2));
27 if (reg & LOONGARCH_CFG2_LSX) flag |= HAS_LSX;
29 if (reg & LOONGARCH_CFG2_LASX) flag |= HAS_LASX;
33 #else /* end __loongarch__ && __linux__ */
35 "--enable-runtime-cpu-detect selected, but no CPU detection method " \
36 "available for your platform. Reconfigure with --disable-runtime-cpu-detect."
38 #else /* end CONFIG_RUNTIME_CPU_DETECT */
39 int loongarch_cpu_caps(void) { return 0; }