1 #include <array> 2 #include <utility> 3 4 #include <catch.hpp> 5 #include <fmt/format.h> 6 #include <xbyak_util.h> 7 8 TEST_CASE("Host CPU supports", "[a64]") { 9 Xbyak::util::Cpu cpu_info; 10 static constexpr std::array types{ 11 std::make_pair(Xbyak::util::Cpu::tMMX, "MMX"), 12 std::make_pair(Xbyak::util::Cpu::tMMX2, "MMX2"), 13 std::make_pair(Xbyak::util::Cpu::tCMOV, "CMOV"), 14 std::make_pair(Xbyak::util::Cpu::tSSE, "SSE"), 15 std::make_pair(Xbyak::util::Cpu::tSSE2, "SSE2"), 16 std::make_pair(Xbyak::util::Cpu::tSSE3, "SSE3"), 17 std::make_pair(Xbyak::util::Cpu::tSSSE3, "SSSE3"), 18 std::make_pair(Xbyak::util::Cpu::tSSE41, "SSE41"), 19 std::make_pair(Xbyak::util::Cpu::tSSE42, "SSE42"), 20 std::make_pair(Xbyak::util::Cpu::tPOPCNT, "POPCNT"), 21 std::make_pair(Xbyak::util::Cpu::tAESNI, "AESNI"), 22 std::make_pair(Xbyak::util::Cpu::tSSE5, "SSE5"), 23 std::make_pair(Xbyak::util::Cpu::tOSXSAVE, "OSXSAVE"), 24 std::make_pair(Xbyak::util::Cpu::tPCLMULQDQ, "PCLMULQDQ"), 25 std::make_pair(Xbyak::util::Cpu::tAVX, "AVX"), 26 std::make_pair(Xbyak::util::Cpu::tFMA, "FMA"), 27 std::make_pair(Xbyak::util::Cpu::t3DN, "3DN"), 28 std::make_pair(Xbyak::util::Cpu::tE3DN, "E3DN"), 29 std::make_pair(Xbyak::util::Cpu::tSSE4a, "SSE4a"), 30 std::make_pair(Xbyak::util::Cpu::tRDTSCP, "RDTSCP"), 31 std::make_pair(Xbyak::util::Cpu::tAVX2, "AVX2"), 32 std::make_pair(Xbyak::util::Cpu::tBMI1, "BMI1"), 33 std::make_pair(Xbyak::util::Cpu::tBMI2, "BMI2"), 34 std::make_pair(Xbyak::util::Cpu::tLZCNT, "LZCNT"), 35 std::make_pair(Xbyak::util::Cpu::tINTEL, "INTEL"), 36 std::make_pair(Xbyak::util::Cpu::tAMD, "AMD"), 37 std::make_pair(Xbyak::util::Cpu::tENHANCED_REP, "ENHANCED_REP"), 38 std::make_pair(Xbyak::util::Cpu::tRDRAND, "RDRAND"), 39 std::make_pair(Xbyak::util::Cpu::tADX, "ADX"), 40 std::make_pair(Xbyak::util::Cpu::tRDSEED, "RDSEED"), 41 std::make_pair(Xbyak::util::Cpu::tSMAP, "SMAP"), 42 std::make_pair(Xbyak::util::Cpu::tHLE, "HLE"), 43 std::make_pair(Xbyak::util::Cpu::tRTM, "RTM"), 44 std::make_pair(Xbyak::util::Cpu::tF16C, "F16C"), 45 std::make_pair(Xbyak::util::Cpu::tMOVBE, "MOVBE"), 46 std::make_pair(Xbyak::util::Cpu::tAVX512F, "AVX512F"), 47 std::make_pair(Xbyak::util::Cpu::tAVX512DQ, "AVX512DQ"), 48 std::make_pair(Xbyak::util::Cpu::tAVX512_IFMA, "AVX512_IFMA"), 49 std::make_pair(Xbyak::util::Cpu::tAVX512IFMA, "AVX512IFMA"), 50 std::make_pair(Xbyak::util::Cpu::tAVX512PF, "AVX512PF"), 51 std::make_pair(Xbyak::util::Cpu::tAVX512ER, "AVX512ER"), 52 std::make_pair(Xbyak::util::Cpu::tAVX512CD, "AVX512CD"), 53 std::make_pair(Xbyak::util::Cpu::tAVX512BW, "AVX512BW"), 54 std::make_pair(Xbyak::util::Cpu::tAVX512VL, "AVX512VL"), 55 std::make_pair(Xbyak::util::Cpu::tAVX512_VBMI, "AVX512_VBMI"), 56 std::make_pair(Xbyak::util::Cpu::tAVX512VBMI, "AVX512VBMI"), 57 std::make_pair(Xbyak::util::Cpu::tAVX512_4VNNIW, "AVX512_4VNNIW"), 58 std::make_pair(Xbyak::util::Cpu::tAVX512_4FMAPS, "AVX512_4FMAPS"), 59 std::make_pair(Xbyak::util::Cpu::tPREFETCHWT1, "PREFETCHWT1"), 60 std::make_pair(Xbyak::util::Cpu::tPREFETCHW, "PREFETCHW"), 61 std::make_pair(Xbyak::util::Cpu::tSHA, "SHA"), 62 std::make_pair(Xbyak::util::Cpu::tMPX, "MPX"), 63 std::make_pair(Xbyak::util::Cpu::tAVX512_VBMI2, "AVX512_VBMI2"), 64 std::make_pair(Xbyak::util::Cpu::tGFNI, "GFNI"), 65 std::make_pair(Xbyak::util::Cpu::tVAES, "VAES"), 66 std::make_pair(Xbyak::util::Cpu::tVPCLMULQDQ, "VPCLMULQDQ"), 67 std::make_pair(Xbyak::util::Cpu::tAVX512_VNNI, "AVX512_VNNI"), 68 std::make_pair(Xbyak::util::Cpu::tAVX512_BITALG, "AVX512_BITALG"), 69 std::make_pair(Xbyak::util::Cpu::tAVX512_VPOPCNTDQ, "AVX512_VPOPCNTDQ"), 70 }; 71 72 for (const auto& [type, name] : types) { 73 if (cpu_info.has(type)) { 74 fmt::print("CPU has {}\n", name); 75 } 76 } 77 } 78