On 6/21/21 7:29 AM, Peter Maydell wrote:
+static void tcg_out_bswap16(TCGContext *s, TCGReg dst, TCGReg src)
+{
+    TCGReg tmp = dst == src ? TCG_REG_R0 : dst;
+
+                                                   /* src = abcd */
+    tcg_out_rlw(s, RLWINM, tmp, src, 24, 24, 31);  /* tmp = 000c */
+    tcg_out_rlw(s, RLWIMI, tmp, src, 8, 16, 23);   /* tmp = 00dc */
+    tcg_out_mov(s, TCG_TYPE_REG, dst, tmp);
+}

TCG_REG_R0 is implicitly available as a temp because it's not
listed in tcg_target_reg_alloc_order[], right?

Slightly better than that:

    tcg_regset_set_reg(s->reserved_regs, TCG_REG_R0); /* tcg temp */


(There's a comment
in the definition of that array that says V0 and V1 are reserved
as temporaries, but not a comment about R0.)

Yeah, tcg/ppc/ is due for a bit of cleanup.

Would be nice to keep these comments about what operations we think
the insns are doing, given that RLWINM and RLWIMI are pretty confusing.

Hmm, I guess.  I found them intrusive.


r~

Reply via email to