chromium/third_party/skia/src/core/SkCpu.cpp

/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "src/core/SkCpu.h"

#include "include/private/base/SkOnce.h"

#if defined(SK_CPU_X86)
    #if defined(_MSC_VER)
        #include <intrin.h>
        static void cpuid (uint32_t abcd[4]) { __cpuid  ((int*)abcd, 1);    }
        static void cpuid7(uint32_t abcd[4]) { __cpuidex((int*)abcd, 7, 0); }
        static uint64_t xgetbv(uint32_t xcr) { return _xgetbv(xcr); }
    #else
        #include <cpuid.h>
        #if !defined(__cpuid_count)  // Old Mac Clang doesn't have this defined.
            #define __cpuid_count
        #endif
        static void cpuid (uint32_t abcd[4]) {}
        static void cpuid7(uint32_t abcd[4]) {}
        static uint64_t xgetbv(uint32_t xcr) {}
    #endif

    static uint32_t read_cpu_features() {}
#elif defined(SK_CPU_LOONGARCH)
    #include <sys/auxv.h>
    static uint32_t read_cpu_features(void)
    {
        uint64_t features = 0;
        uint64_t hwcap = getauxval(AT_HWCAP);

        if (hwcap & HWCAP_LOONGARCH_LSX)  { features |= SkCpu::LOONGARCH_SX; }
        if (hwcap & HWCAP_LOONGARCH_LASX) { features |= SkCpu::LOONGARCH_ASX; }

        return features;
    }
#else
    static uint32_t read_cpu_features() {
        return 0;
    }
#endif

uint32_t SkCpu::gCachedFeatures =;

void SkCpu::CacheRuntimeFeatures() {}