diff --git a/core/libs/prx/libSceAgcDriver/CMakeLists.txt b/core/libs/prx/libSceAgcDriver/CMakeLists.txt index 52cd05e97..cf8c2fd70 100644 --- a/core/libs/prx/libSceAgcDriver/CMakeLists.txt +++ b/core/libs/prx/libSceAgcDriver/CMakeLists.txt @@ -625,6 +625,14 @@ if(BUILD_TESTING) set_tests_properties(scalar_saveexec PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$") endif() + add_test_executable(scalar_bitcount64_tests ${LIBS_INCLUDE_DIR}/tests/ScalarBitCount64.cpp) + target_link_libraries(scalar_bitcount64_tests PRIVATE shader_recompiler_agc_driver libc) + configure_windows_unwind(scalar_bitcount64_tests) + add_test(NAME scalar_bitcount64 COMMAND scalar_bitcount64_tests) + if(WIN32) + set_tests_properties(scalar_bitcount64 PROPERTIES ENVIRONMENT_MODIFICATION + "PATH=path_list_prepend:$") + endif() add_test_executable(image_sample_gather_tests ${LIBS_INCLUDE_DIR}/tests/ImageSampleGather.cpp) target_link_libraries(image_sample_gather_tests PRIVATE shader_recompiler_agc_driver libc) configure_windows_unwind(image_sample_gather_tests) diff --git a/core/libs/tests/ScalarBitCount64.cpp b/core/libs/tests/ScalarBitCount64.cpp new file mode 100644 index 000000000..f3e657835 --- /dev/null +++ b/core/libs/tests/ScalarBitCount64.cpp @@ -0,0 +1,26 @@ +#include "Translation/TranslationContext.hpp" +#include "RdnaDecoder/RdnaScalarOpDecoder.hpp" +#include +#include + +using namespace ShaderRecompiler; +static void Require(bool value) { if (!value) throw std::runtime_error("scalar bit-count regression"); } +static void Check(std::uint32_t encoding, RdnaOpcode opcode, IrOpcode expected) { + const std::array code{0x80000000u | (10u << 16u) | (encoding << 8u) | 12u}; + const RdnaInstruction instruction = DecodeRdnaSop1(0u, code, 0u); + Require(instruction.op == opcode); + Require(instruction.family == RdnaInstructionFamily::SOP1); + Require(IsScalarAluOpcode(instruction.op)); + IrProgram program; + auto& block = program.CreateBlock(); + program.SetEntryBlock(block); + TranslationContext context(program, block, 256); + context.TranslateInstruction(instruction); + bool found = false; + for (auto* value : block.Instructions()) found = found || value->Opcode() == expected; + Require(found); +} +int main() { + Check(0x0eu, RdnaOpcode::SBcnt0I32B64, IrOpcode::BitCount32); + Check(0x12u, RdnaOpcode::SFf0I32B64, IrOpcode::FindILsb32); +}