[ARM64_DYNAREC] Fixed 0F 38 00 PSHUFB opcode (thanks @wannacu for the hint)

This commit is contained in:
ptitSeb 2023-09-04 09:29:55 +02:00
parent 6e1bcc03a6
commit 96025a1977
5 changed files with 39 additions and 5 deletions

View File

@ -945,19 +945,24 @@ add_test(irelative_reloc ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref20.txt
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
add_test(longjumpInSignals ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX64}
add_test(longjumpInSignals ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX64}
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test21 -D TEST_OUTPUT=tmpfile21.txt
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref21.txt
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
add_test(x87 ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX64}
add_test(x87 ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX64}
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test22 -D TEST_OUTPUT=tmpfile22.txt
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref22.txt
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
set_tests_properties(x87 PROPERTIES ENVIRONMENT "BOX64_DYNAREC_FASTROUND=0")
set_tests_properties(x87 PROPERTIES ENVIRONMENT "BOX64_DYNAREC_FASTROUND=0")
file(GLOB extension_tests "${CMAKE_SOURCE_DIR}/tests/extensions/*.c")
add_test(pshufb ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX64}
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test23 -D TEST_OUTPUT=tmpfile23.txt
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref23.txt
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
file(GLOB extension_tests "${CMAKE_SOURCE_DIR}/tests/extensions/*.c")
foreach(file ${extension_tests})
get_filename_component(testname "${file}" NAME_WE)
add_test(NAME "${testname}" COMMAND ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX64}

View File

@ -421,7 +421,7 @@ uintptr_t dynarec64_0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
GETGM(q0);
GETEM(q1, 0);
d0 = fpu_get_scratch(dyn);
MOVI_8(d0, 0b10001111);
MOVI_8(d0, 0b10000111);
VAND(d0, d0, q1); // mask the index
VTBL1_8(q0, q0, d0);
break;

1
tests/ref23.txt Normal file
View File

@ -0,0 +1 @@
Res = 0xefcd00ef

BIN
tests/test23 Executable file

Binary file not shown.

28
tests/test23.c Normal file
View File

@ -0,0 +1,28 @@
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <stdint.h>
// Build with `gcc -march=core2 -O2 test23.c -o test23`
uint64_t pshufb(uint64_t Gm, uint64_t Em) {
uint64_t Res;
asm(
"movq %[_Gm], %%mm0\n"
"movq %[_Em], %%mm1\n"
"pshufb %%mm1, %%mm0\n"
"movq %%mm0, %[_Res]\n"
: [_Res] "+r"(Res)
: [_Gm] "r"(Gm)
, [_Em] "r"(Em)
);
return Res;
}
int main() {
uint64_t Gm = 0x12345678abcdef00;
uint64_t Em = 0x8182888971727879;
uint64_t Res = pshufb(Gm, Em);
printf("Res = 0x%lx\n", Res);
//assert(Res == 0xefcd00ef);
return 0;
}