[RFC PATCH 11.0 1/2]
RFC PATCH 1/2 [RFC PATCH 11.0 1/2]
TCGOutOpBinary passes (output, value, count), but MIPS variable shift instructions encode (rd, rt, rs), where rt is the value and rs is the count. tcg_out_opc_reg() takes its register fields in (rd, rs, rt) order, so passing (a0, a1, a2) encodes the value as the count and the count as the value.
Swap a1 and a2 at the four variable shift emitters. This covers the I32 and I64 forms of SHL, SHR, SAR, and ROTR.
A freestanding AArch64 test forces each operation into a separate translation block and records one failure bit per form. With QEMU 11.0.3 in a pre-R6 MIPS64EL execution environment:
unpatched: exit status 0xff
patched: exit status 0x00
For example, the DSRAV host instruction changes from:
dsrav s0,s0,s1
to:
dsrav s0,s1,s0
where s1 contains the value and s0 contains the count at that point.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4103
---
tcg/mips64/tcg-target.c.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tcg/mips64/tcg-target.c.inc +0 -0
@@ -1836,7 +1836,7 @@ static void tgen_rotr(TCGContext *s, TCGType type,
TCGReg a0, TCGReg a1, TCGReg a2) {
MIPSInsn insn = type == TCG_TYPE_I32 ? OPC_ROTRV : OPC_DROTRV;
- tcg_out_opc_reg(s, insn, a0, a1, a2);
+ tcg_out_opc_reg(s, insn, a0, a2, a1);
}
static void tgen_rotri(TCGContext *s, TCGType type,
@@ -1860,7 +1860,7 @@ static void tgen_sar(TCGContext *s, TCGType type,
TCGReg a0, TCGReg a1, TCGReg a2) {
MIPSInsn insn = type == TCG_TYPE_I32 ? OPC_SRAV : OPC_DSRAV;
- tcg_out_opc_reg(s, insn, a0, a1, a2);
+ tcg_out_opc_reg(s, insn, a0, a2, a1);
}
static void tgen_sari(TCGContext *s, TCGType type,
@@ -1883,7 +1883,7 @@ static void tgen_shl(TCGContext *s, TCGType type,
TCGReg a0, TCGReg a1, TCGReg a2) {
MIPSInsn insn = type == TCG_TYPE_I32 ? OPC_SLLV : OPC_DSLLV;
- tcg_out_opc_reg(s, insn, a0, a1, a2);
+ tcg_out_opc_reg(s, insn, a0, a2, a1);
}
static void tgen_shli(TCGContext *s, TCGType type,
@@ -1906,7 +1906,7 @@ static void tgen_shr(TCGContext *s, TCGType type,
TCGReg a0, TCGReg a1, TCGReg a2) {
MIPSInsn insn = type == TCG_TYPE_I32 ? OPC_SRLV : OPC_DSRLV;
- tcg_out_opc_reg(s, insn, a0, a1, a2);
+ tcg_out_opc_reg(s, insn, a0, a2, a1);
}
static void tgen_shri(TCGContext *s, TCGType type,
--
2.43.0