On 6/21/21 11:36 PM, Philippe Mathieu-Daudé wrote:
/* src = abcd
efgh */
if (use_mips32r2_instructions) {
tcg_out_opc_reg(s, OPC_WSBH, ret, 0, arg); /* ret = cdab
ghef */
badc -- bytes swapped in halfwords. Also, this is a 32-bit insn, so 4 bytes is
sufficient.
if (flags & TCG_BSWAP_OS) {
tcg_out_opc_reg(s, OPC_SEH, ret, 0, ret); /* ret = ssss
ghef */
(ssss)ssdc
Again, 32-bit insn, but implicitly sign-extending to 64-bits as per standard
mips convention.
} else if ((flags & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) ==
TCG_BSWAP_OZ) {
tcg_out_opc_imm(s, OPC_ANDI, ret, ret, 0xffff);
/* ret = 0000
ghef */
(0000)00dc.
tcg_out_opc_sa(s, OPC_SRL, TCG_TMP0, arg, 8); /* t0 = ssab
cdef */
if (!(flags & TCG_BSWAP_IZ)) { /* t0 = 0000
00ef */
tcg_out_opc_imm(s, OPC_ANDI, TCG_TMP0, TCG_TMP0, 0x00ff);
}
if (flags & TCG_BSWAP_OS) {
tcg_out_opc_sa(s, OPC_SLL, ret, arg, 24); /* ret = gh..
.... */
tcg_out_opc_sa(s, OPC_SRA, ret, ret, 16); /* ret = ssss
gh.. */
} else {
tcg_out_opc_sa(s, OPC_SLL, ret, arg, 8); /* ret = cdef
gh.. */
if (flags & TCG_BSWAP_OZ) { /* ret = 0000
gh.. */
tcg_out_opc_imm(s, OPC_ANDI, ret, ret, 0xff00);
}
}
tcg_out_opc_reg(s, OPC_OR, ret, ret, TCG_TMP0); /* OZ: ret = 0000
ghef */
/* OS: ret = ssss
ghef */
Something like that, yes. I'll fix it up.
r~