From 068450d4feb43afd97dfa95e2e3ebd2f9a64116e Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 20 Dec 2019 21:11:07 +0300 Subject: [PATCH] CPUTranslator: detect FMA feature --- Utilities/JIT.cpp | 8 ++++++-- rpcs3/Emu/CPU/CPUTranslator.cpp | 27 +++++++++++++++++++++++++-- rpcs3/Emu/CPU/CPUTranslator.h | 5 ++++- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Utilities/JIT.cpp b/Utilities/JIT.cpp index e8ebed49cb..105cc0995c 100644 --- a/Utilities/JIT.cpp +++ b/Utilities/JIT.cpp @@ -958,10 +958,12 @@ std::string jit_compiler::cpu(const std::string& _cpu) m_cpu == "skylake" || m_cpu == "skylake-avx512" || m_cpu == "cascadelake" || + m_cpu == "cooperlake" || m_cpu == "cannonlake" || m_cpu == "icelake" || m_cpu == "icelake-client" || - m_cpu == "icelake-server") + m_cpu == "icelake-server" || + m_cpu == "tigerlake") { // Downgrade if AVX is not supported by some chips if (!utils::has_avx()) @@ -972,10 +974,12 @@ std::string jit_compiler::cpu(const std::string& _cpu) if (m_cpu == "skylake-avx512" || m_cpu == "cascadelake" || + m_cpu == "cooperlake" || m_cpu == "cannonlake" || m_cpu == "icelake" || m_cpu == "icelake-client" || - m_cpu == "icelake-server") + m_cpu == "icelake-server" || + m_cpu == "tigerlake") { // Downgrade if AVX-512 is disabled or not supported if (!utils::has_512()) diff --git a/rpcs3/Emu/CPU/CPUTranslator.cpp b/rpcs3/Emu/CPU/CPUTranslator.cpp index d0b7741270..550c9b6cd3 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.cpp +++ b/rpcs3/Emu/CPU/CPUTranslator.cpp @@ -18,8 +18,6 @@ void cpu_translator::initialize(llvm::LLVMContext& context, llvm::ExecutionEngin const auto cpu = m_engine->getTargetMachine()->getTargetCPU(); - m_use_ssse3 = true; - // Test SSSE3 feature (TODO) if (cpu == "generic" || cpu == "k8" || @@ -34,6 +32,31 @@ void cpu_translator::initialize(llvm::LLVMContext& context, llvm::ExecutionEngin { m_use_ssse3 = false; } + + // Test FMA feature (TODO) + if (cpu == "haswell" || + cpu == "broadwell" || + cpu == "skylake" || + cpu == "bdver2" || + cpu == "bdver3" || + cpu == "bdver4" || + cpu.substr(0, 5) == "znver") + { + m_use_fma = true; + } + + // Test AVX-512 feature (TODO) + if (cpu == "skylake-avx512" || + cpu == "cascadelake" || + cpu == "cannonlake" || + cpu == "cooperlake" || + cpu == "icelake" || + cpu == "icelake-client" || + cpu == "icelake-server" || + cpu == "tigerlake") + { + m_use_fma = true; + } } llvm::Value* cpu_translator::bitcast(llvm::Value* val, llvm::Type* type) diff --git a/rpcs3/Emu/CPU/CPUTranslator.h b/rpcs3/Emu/CPU/CPUTranslator.h index 2b7c43d179..614a6a8694 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.h +++ b/rpcs3/Emu/CPU/CPUTranslator.h @@ -2404,7 +2404,10 @@ protected: bool m_is_be; // Allow PSHUFB intrinsic - bool m_use_ssse3; + bool m_use_ssse3 = true; + + // Allow FMA + bool m_use_fma = false; // IR builder llvm::IRBuilder<>* m_ir;