mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 09:55:55 +00:00
tcg/ppc: Support bswap flags
For INDEX_op_bswap32_i32, pass 0 for flags: input not zero-extended, output does not need extension within the host 64-bit register. Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
674ba58803
commit
26ce70051b
|
@ -789,7 +789,7 @@ static inline void tcg_out_sari64(TCGContext *s, TCGReg dst, TCGReg src, int c)
|
|||
tcg_out32(s, SRADI | RA(dst) | RS(src) | SH(c & 0x1f) | ((c >> 4) & 2));
|
||||
}
|
||||
|
||||
static void tcg_out_bswap16(TCGContext *s, TCGReg dst, TCGReg src)
|
||||
static void tcg_out_bswap16(TCGContext *s, TCGReg dst, TCGReg src, int flags)
|
||||
{
|
||||
TCGReg tmp = dst == src ? TCG_REG_R0 : dst;
|
||||
|
||||
|
@ -804,10 +804,14 @@ static void tcg_out_bswap16(TCGContext *s, TCGReg dst, TCGReg src)
|
|||
/* tmp = dep(tmp, rol32(src, 8), 0x0000ff00) = 000000dc */
|
||||
tcg_out_rlw(s, RLWIMI, tmp, src, 8, 16, 23);
|
||||
|
||||
tcg_out_mov(s, TCG_TYPE_REG, dst, tmp);
|
||||
if (flags & TCG_BSWAP_OS) {
|
||||
tcg_out_ext16s(s, dst, tmp);
|
||||
} else {
|
||||
tcg_out_mov(s, TCG_TYPE_REG, dst, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
static void tcg_out_bswap32(TCGContext *s, TCGReg dst, TCGReg src)
|
||||
static void tcg_out_bswap32(TCGContext *s, TCGReg dst, TCGReg src, int flags)
|
||||
{
|
||||
TCGReg tmp = dst == src ? TCG_REG_R0 : dst;
|
||||
|
||||
|
@ -825,7 +829,11 @@ static void tcg_out_bswap32(TCGContext *s, TCGReg dst, TCGReg src)
|
|||
/* tmp = dep(tmp, rol32(src, 24), 0x0000ff00) = 0000dcba */
|
||||
tcg_out_rlw(s, RLWIMI, tmp, src, 24, 16, 23);
|
||||
|
||||
tcg_out_mov(s, TCG_TYPE_REG, dst, tmp);
|
||||
if (flags & TCG_BSWAP_OS) {
|
||||
tcg_out_ext32s(s, dst, tmp);
|
||||
} else {
|
||||
tcg_out_mov(s, TCG_TYPE_REG, dst, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
static void tcg_out_bswap64(TCGContext *s, TCGReg dst, TCGReg src)
|
||||
|
@ -2851,11 +2859,13 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
|
|||
|
||||
case INDEX_op_bswap16_i32:
|
||||
case INDEX_op_bswap16_i64:
|
||||
tcg_out_bswap16(s, args[0], args[1]);
|
||||
tcg_out_bswap16(s, args[0], args[1], args[2]);
|
||||
break;
|
||||
case INDEX_op_bswap32_i32:
|
||||
tcg_out_bswap32(s, args[0], args[1], 0);
|
||||
break;
|
||||
case INDEX_op_bswap32_i64:
|
||||
tcg_out_bswap32(s, args[0], args[1]);
|
||||
tcg_out_bswap32(s, args[0], args[1], args[2]);
|
||||
break;
|
||||
case INDEX_op_bswap64_i64:
|
||||
tcg_out_bswap64(s, args[0], args[1]);
|
||||
|
|
Loading…
Reference in a new issue