@@ -1708,12 +1708,13 @@ VendorSignatures getVendorSignature(unsigned *MaxLeaf) {
17081708
17091709#if defined(__i386__) || defined(_M_IX86) || \
17101710 defined (__x86_64__) || defined(_M_X64)
1711- bool sys::getHostCPUFeatures(StringMap< bool > &Features ) {
1711+ const StringMap< bool> sys::getHostCPUFeatures() {
17121712 unsigned EAX = 0 , EBX = 0 , ECX = 0 , EDX = 0 ;
17131713 unsigned MaxLevel;
1714+ StringMap<bool > Features;
17141715
17151716 if (getX86CpuIDAndInfo (0 , &MaxLevel, &EBX, &ECX, &EDX) || MaxLevel < 1 )
1716- return false ;
1717+ return Features ;
17171718
17181719 getX86CpuIDAndInfo (1 , &EAX, &EBX, &ECX, &EDX);
17191720
@@ -1901,13 +1902,14 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features) {
19011902 Features[" avx10.1-512" ] =
19021903 Features[" avx10.1-256" ] && HasLeaf24 && ((EBX >> 18 ) & 1 );
19031904
1904- return true ;
1905+ return Features ;
19051906}
19061907#elif defined(__linux__) && (defined(__arm__) || defined(__aarch64__))
1907- bool sys::getHostCPUFeatures (StringMap<bool > &Features) {
1908+ const StringMap<bool > sys::getHostCPUFeatures () {
1909+ StringMap<bool > Features;
19081910 std::unique_ptr<llvm::MemoryBuffer> P = getProcCpuinfoContent ();
19091911 if (!P)
1910- return false ;
1912+ return Features ;
19111913
19121914 SmallVector<StringRef, 32 > Lines;
19131915 P->getBuffer ().split (Lines, " \n " );
@@ -1970,38 +1972,42 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features) {
19701972 Features[" crypto" ] = true ;
19711973#endif
19721974
1973- return true ;
1975+ return Features ;
19741976}
19751977#elif defined(_WIN32) && (defined(__aarch64__) || defined(_M_ARM64))
1976- bool sys::getHostCPUFeatures (StringMap<bool > &Features) {
1978+ const StringMap<bool > sys::getHostCPUFeatures () {
1979+ StringMap<bool > Features;
1980+
19771981 if (IsProcessorFeaturePresent (PF_ARM_NEON_INSTRUCTIONS_AVAILABLE))
19781982 Features[" neon" ] = true ;
19791983 if (IsProcessorFeaturePresent (PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE))
19801984 Features[" crc" ] = true ;
19811985 if (IsProcessorFeaturePresent (PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE))
19821986 Features[" crypto" ] = true ;
19831987
1984- return true ;
1988+ return Features ;
19851989}
19861990#elif defined(__linux__) && defined(__loongarch__)
19871991#include < sys/auxv.h>
1988- bool sys::getHostCPUFeatures (StringMap< bool > &Features ) {
1992+ const StringMap< bool > sys::getHostCPUFeatures () {
19891993 unsigned long hwcap = getauxval (AT_HWCAP);
19901994 bool HasFPU = hwcap & (1UL << 3 ); // HWCAP_LOONGARCH_FPU
19911995 uint32_t cpucfg2 = 0x2 ;
19921996 __asm__ (" cpucfg %[cpucfg2], %[cpucfg2]\n\t " : [cpucfg2] " +r" (cpucfg2));
19931997
1998+ StringMap<bool > Features;
1999+
19942000 Features[" f" ] = HasFPU && (cpucfg2 & (1U << 1 )); // CPUCFG.2.FP_SP
19952001 Features[" d" ] = HasFPU && (cpucfg2 & (1U << 2 )); // CPUCFG.2.FP_DP
19962002
19972003 Features[" lsx" ] = hwcap & (1UL << 4 ); // HWCAP_LOONGARCH_LSX
19982004 Features[" lasx" ] = hwcap & (1UL << 5 ); // HWCAP_LOONGARCH_LASX
19992005 Features[" lvz" ] = hwcap & (1UL << 9 ); // HWCAP_LOONGARCH_LVZ
20002006
2001- return true ;
2007+ return Features ;
20022008}
20032009#else
2004- bool sys::getHostCPUFeatures (StringMap< bool > &Features ) { return false ; }
2010+ const StringMap< bool > sys::getHostCPUFeatures () { return {} ; }
20052011#endif
20062012
20072013#if __APPLE__
0 commit comments