diff --git a/Common/ArmCPUDetect.cpp b/Common/ArmCPUDetect.cpp index 437bd3158e..3a0fc60e8b 100644 --- a/Common/ArmCPUDetect.cpp +++ b/Common/ArmCPUDetect.cpp @@ -339,29 +339,51 @@ void CPUInfo::Detect() #endif } +std::vector CPUInfo::Features() { + std::vector features; + + struct Flag { + bool &flag; + const char *str; + }; + const Flag list[] = { + { bSwp, "SWP" }, + { bHalf, "Half" }, + { bThumb, "Thumb" }, + { bFastMult, "FastMult" }, + { bEDSP, "EDSP" }, + { bThumbEE, "ThumbEE" }, + { bTLS, "TLS" }, + { bVFP, "VFP" }, + { bVFPv3, "VFPv3" }, + { bVFPv4, "VFPv4" }, + { bNEON, "NEON" }, + { bIDIVa, "IDIVa" }, + { bIDIVt, "IDIVt" }, + { CPU64bit, "64-bit" }, + }; + + for (auto &item : list) { + if (item.flag) { + features.push_back(item.str); + } + } + + return features; +} + // Turn the cpu info into a string we can show -std::string CPUInfo::Summarize() -{ +std::string CPUInfo::Summarize() { std::string sum; if (num_cores == 1) sum = StringFromFormat("%s, %d core", cpu_string, num_cores); else sum = StringFromFormat("%s, %d cores", cpu_string, num_cores); - if (bSwp) sum += ", SWP"; - if (bHalf) sum += ", Half"; - if (bThumb) sum += ", Thumb"; - if (bFastMult) sum += ", FastMult"; - if (bEDSP) sum += ", EDSP"; - if (bThumbEE) sum += ", ThumbEE"; - if (bTLS) sum += ", TLS"; - if (bVFP) sum += ", VFP"; - if (bVFPv3) sum += ", VFPv3"; - if (bVFPv4) sum += ", VFPv4"; - if (bNEON) sum += ", NEON"; - if (bIDIVa) sum += ", IDIVa"; - if (bIDIVt) sum += ", IDIVt"; - if (CPU64bit) sum += ", 64-bit"; + auto features = Features(); + for (std::string &feature : features) { + sum += ", " + feature; + } return sum; } diff --git a/Common/CPUDetect.cpp b/Common/CPUDetect.cpp index c80b32d5b1..aa43930ead 100644 --- a/Common/CPUDetect.cpp +++ b/Common/CPUDetect.cpp @@ -481,39 +481,63 @@ void CPUInfo::Detect() { logical_cpu_count = 1; } -// Turn the cpu info into a string we can show -std::string CPUInfo::Summarize() -{ - std::string sum; - if (num_cores == 1) - sum = StringFromFormat("%s, %d core", cpu_string, num_cores); - else - { - sum = StringFromFormat("%s, %d cores", cpu_string, num_cores); - if (HTT) sum += StringFromFormat(" (%i logical threads per physical core)", logical_cpu_count); +std::vector CPUInfo::Features() { + std::vector features; + + struct Flag { + bool &flag; + const char *str; + }; + const Flag list[] = { + { bSSE, "SSE" }, + { bSSE2, "SSE2" }, + { bSSE3, "SSE3" }, + { bSSSE3, "SSSE3" }, + { bSSE4_1, "SSE4.1" }, + { bSSE4_2, "SSE4.2" }, + { bSSE4A, "SSE4A" }, + { HTT, "HTT" }, + { bAVX, "AVX" }, + { bAVX2, "AVX2" }, + { bFMA3, "FMA3" }, + { bFMA4, "FMA4" }, + { bAES, "AES" }, + { bSHA, "SHA" }, + { bXOP, "XOP" }, + { bRTM, "TSX" }, + { bF16C, "F16C" }, + { bBMI1, "BMI1" }, + { bBMI2, "BMI2" }, + { bPOPCNT, "POPCNT" }, + { bMOVBE, "MOVBE" }, + { bLZCNT, "LZCNT" }, + { bLongMode, "64-bit support" }, + }; + + for (auto &item : list) { + if (item.flag) { + features.push_back(item.str); + } + } + + return features; +} + +// Turn the cpu info into a string we can show +std::string CPUInfo::Summarize() { + std::string sum; + if (num_cores == 1) { + sum = StringFromFormat("%s, %d core", cpu_string, num_cores); + } else { + sum = StringFromFormat("%s, %d cores", cpu_string, num_cores); + if (HTT) + sum += StringFromFormat(" (%i logical threads per physical core)", logical_cpu_count); + } + + auto features = Features(); + for (std::string &feature : features) { + sum += ", " + feature; } - if (bSSE) sum += ", SSE"; - if (bSSE2) sum += ", SSE2"; - if (bSSE3) sum += ", SSE3"; - if (bSSSE3) sum += ", SSSE3"; - if (bSSE4_1) sum += ", SSE4.1"; - if (bSSE4_2) sum += ", SSE4.2"; - if (bSSE4A) sum += ", SSE4A"; - if (HTT) sum += ", HTT"; - if (bAVX) sum += ", AVX"; - if (bAVX2) sum += ", AVX2"; - if (bFMA3) sum += ", FMA3"; - if (bFMA4) sum += ", FMA4"; - if (bAES) sum += ", AES"; - if (bSHA) sum += ", SHA"; - if (bXOP) sum += ", XOP"; - if (bRTM) sum += ", TSX"; - if (bF16C) sum += ", F16C"; - if (bBMI1) sum += ", BMI1"; - if (bPOPCNT) sum += ", POPCNT"; - if (bMOVBE) sum += ", MOVBE"; - if (bLZCNT) sum += ", LZCNT"; - if (bLongMode) sum += ", 64-bit support"; return sum; } diff --git a/Common/CPUDetect.h b/Common/CPUDetect.h index 417cd48e5b..c50b546387 100644 --- a/Common/CPUDetect.h +++ b/Common/CPUDetect.h @@ -20,6 +20,7 @@ #include "ppsspp_config.h" #include +#include enum CPUVendor { VENDOR_INTEL = 0, @@ -121,6 +122,7 @@ struct CPUInfo { explicit CPUInfo(); // Turn the cpu info into a string we can show + std::vector Features(); std::string Summarize(); private: diff --git a/Common/FakeCPUDetect.cpp b/Common/FakeCPUDetect.cpp index 5845f29ae6..e04ed356ed 100644 --- a/Common/FakeCPUDetect.cpp +++ b/Common/FakeCPUDetect.cpp @@ -53,11 +53,20 @@ void CPUInfo::Detect() logical_cpu_count = 2; } +std::vector CPUInfo::Features() { + std::vector features; + return features; +} + // Turn the cpu info into a string we can show -std::string CPUInfo::Summarize() -{ +std::string CPUInfo::Summarize() { std::string sum; sum = StringFromFormat("%s, %i core", cpu_string, num_cores); + + auto features = Features(); + for (std::string &feature : features) { + sum += ", " + feature; + } return sum; } #endif diff --git a/Common/MipsCPUDetect.cpp b/Common/MipsCPUDetect.cpp index 1fd93e29b1..c569d15d94 100644 --- a/Common/MipsCPUDetect.cpp +++ b/Common/MipsCPUDetect.cpp @@ -197,6 +197,28 @@ void CPUInfo::Detect() #endif } +std::vector CPUInfo::Features() { + std::vector features; + + struct Flag { + bool &flag; + const char *str; + }; + const Flag list[] = { + { bXBurst1, "XBurst1" }, + { bXBurst2, "XBurst2" }, + { CPU64bit, "64-bit" }, + }; + + for (auto &item : list) { + if (item.flag) { + features.push_back(item.str); + } + } + + return features; +} + // Turn the cpu info into a string we can show std::string CPUInfo::Summarize() { @@ -205,10 +227,11 @@ std::string CPUInfo::Summarize() sum = StringFromFormat("%s, %i core", cpu_string, num_cores); else sum = StringFromFormat("%s, %i cores", cpu_string, num_cores); - if (bXBurst1) sum += ", XBurst1"; - if (bXBurst2) sum += ", XBurst2"; - if (CPU64bit) sum += ", 64-bit"; + auto features = Features(); + for (std::string &feature : features) { + sum += ", " + feature; + } return sum; } diff --git a/Common/RiscVCPUDetect.cpp b/Common/RiscVCPUDetect.cpp index 912c4f3e49..3ed013d2d5 100644 --- a/Common/RiscVCPUDetect.cpp +++ b/Common/RiscVCPUDetect.cpp @@ -176,18 +176,45 @@ void CPUInfo::Detect() RiscV_B = ExtensionSupported(hwcap, 'B'); } +std::vector CPUInfo::Features() { + std::vector features; + + struct Flag { + bool &flag; + const char *str; + }; + const Flag list[] = { + { RiscV_M, "Muldiv" }, + { RiscV_A, "Atomic" }, + { RiscV_F, "Float" }, + { RiscV_D, "Double" }, + { RiscV_C, "Compressed" }, + { RiscV_V, "Vector" }, + { RiscV_B, "Bitmanip" }, + { CPU64bit, "64-bit" }, + }; + + for (auto &item : list) { + if (item.flag) { + features.push_back(item.str); + } + } + + return features; +} + // Turn the cpu info into a string we can show -std::string CPUInfo::Summarize() -{ +std::string CPUInfo::Summarize() { std::string sum; if (num_cores == 1) sum = StringFromFormat("%s, %i core", cpu_string, num_cores); else sum = StringFromFormat("%s, %i cores", cpu_string, num_cores); - if (CPU64bit) sum += ", 64-bit"; - - //TODO: parse "isa : rv64imafdc" from /proc/cpuinfo + auto features = Features(); + for (std::string &feature : features) { + sum += ", " + feature; + } return sum; } diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index e54c1a76f6..d9fc09d7de 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -704,10 +704,9 @@ void SystemInfoScreen::CreateViews() { tabHolder->AddTab(si->T("CPU Extensions"), cpuExtensionsScroll); cpuExtensions->Add(new ItemHeader(si->T("CPU Extensions"))); - std::vector exts; - SplitString(cpu_info.Summarize(), ',', exts); - for (size_t i = 2; i < exts.size(); i++) { - cpuExtensions->Add(new TextView(exts[i], new LayoutParams(FILL_PARENT, WRAP_CONTENT)))->SetFocusable(true); + std::vector exts = cpu_info.Features(); + for (std::string &ext : exts) { + cpuExtensions->Add(new TextView(ext, new LayoutParams(FILL_PARENT, WRAP_CONTENT)))->SetFocusable(true); } ViewGroup *driverBugsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));