Skip to content

Commit 9fc4697

Browse files
authored
[LA64_DYNAREC] Added ROUNDSD and CVTDQ2PD opcodes (#2173)
* [LA64_DYNAREC] Added ROUNDSD and CVTDQ2PD opcodes * [LA64_DYNAREC] Added round_round * [LA64_DYNAREC] Remove redundant instruction * [LA64_DYNAREC] Remove useless assembler * [LA64_DYNAREC] Made round_round more readable
1 parent 8a37b12 commit 9fc4697

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/dynarec/la64/dynarec_la64_660f.c

+25
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ uintptr_t dynarec64_660F(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int
4949
MAYUSE(eb1);
5050
MAYUSE(eb2);
5151
MAYUSE(j64);
52+
#if STEP > 1
53+
static const int8_t round_round[] = {
54+
0xE, // round to nearest with ties to even
55+
0x2, // round toward minus infinity
56+
0x6, // round toward plus infinity
57+
0xA // round toward zero
58+
};
59+
#endif
60+
5261

5362
switch (opcode) {
5463
case 0x10:
@@ -528,6 +537,22 @@ uintptr_t dynarec64_660F(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int
528537
case 0x3A: // these are some more SSSE3+ opcodes
529538
opcode = F8;
530539
switch (opcode) {
540+
case 0x0B:
541+
INST_NAME("ROUNDSD Gx, Ex, Ib");
542+
nextop = F8;
543+
GETGX(q0, 1);
544+
GETEXSD(q1, 0, 1);
545+
u8 = F8;
546+
v1 = fpu_get_scratch(dyn);
547+
if (u8 & 4) {
548+
u8 = sse_setround(dyn, ninst, x1, x2);
549+
VFRINT_D(v1, q1);
550+
x87_restoreround(dyn, ninst, u8);
551+
} else {
552+
VFRINTRRD_D(v1, q1, round_round[u8 & 3]);
553+
}
554+
VEXTRINS_D(q0, v1, 0);
555+
break;
531556
case 0x0F:
532557
INST_NAME("PALIGNR Gx, Ex, Ib");
533558
nextop = F8;

src/dynarec/la64/dynarec_la64_f30f.c

+7
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,13 @@ uintptr_t dynarec64_F30F(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int
417417
MOVGR2FR_W(q1, x2);
418418
VEXTRINS_W(v0, q1, 0);
419419
break;
420+
case 0xE6:
421+
INST_NAME("CVTDQ2PD Gx, Ex");
422+
nextop = F8;
423+
GETEXSD(v1, 0, 0);
424+
GETGX_empty(v0);
425+
VFFINTL_D_W(v0, v1);
426+
break;
420427
default:
421428
DEFAULT;
422429
}

src/dynarec/la64/la64_emitter.h

+2
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,8 @@ LSX instruction starts with V, LASX instruction starts with XV.
18391839
#define VPICKVE2GR_HU(rd, vj, imm3) EMIT(type_2RI3(0b0111001011110011110, imm3, vj, rd))
18401840
#define VPICKVE2GR_WU(rd, vj, imm2) EMIT(type_2RI2(0b01110010111100111110, imm2, vj, rd))
18411841
#define VPICKVE2GR_DU(rd, vj, imm1) EMIT(type_2RI1(0b011100101111001111110, imm1, vj, rd))
1842+
#define VFRINT_D(vd, vj) EMIT(type_2R(0b0111001010011101001110, vj, vd))
1843+
#define VFRINTRRD_D(vd, vj, imm4) EMIT(type_2RI4(0b011100101001110101, imm4, vj, vd))
18421844

18431845
////////////////////////////////////////////////////////////////////////////////
18441846
// (undocumented) LBT extension instructions

0 commit comments

Comments
 (0)