qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 13/28] tcg/mips: Support bswap flags in tcg_out_bswap16


From: Richard Henderson
Subject: Re: [PATCH 13/28] tcg/mips: Support bswap flags in tcg_out_bswap16
Date: Tue, 22 Jun 2021 06:54:40 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

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~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]