mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 18:44:58 -06:00
tcg: Introduce tcg_target_has_memory_bswap
Replace the unparameterized TCG_TARGET_HAS_MEMORY_BSWAP macro with a function with a memop argument. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
933b331b30
commit
7b88010719
22 changed files with 63 additions and 26 deletions
20
tcg/tcg-op.c
20
tcg/tcg-op.c
|
@ -2959,7 +2959,7 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop)
|
|||
oi = make_memop_idx(memop, idx);
|
||||
|
||||
orig_memop = memop;
|
||||
if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) {
|
||||
if ((memop & MO_BSWAP) && !tcg_target_has_memory_bswap(memop)) {
|
||||
memop &= ~MO_BSWAP;
|
||||
/* The bswap primitive benefits from zero-extended input. */
|
||||
if ((memop & MO_SSIZE) == MO_SW) {
|
||||
|
@ -2996,7 +2996,7 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop)
|
|||
memop = tcg_canonicalize_memop(memop, 0, 1);
|
||||
oi = make_memop_idx(memop, idx);
|
||||
|
||||
if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) {
|
||||
if ((memop & MO_BSWAP) && !tcg_target_has_memory_bswap(memop)) {
|
||||
swap = tcg_temp_ebb_new_i32();
|
||||
switch (memop & MO_SIZE) {
|
||||
case MO_16:
|
||||
|
@ -3045,7 +3045,7 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop)
|
|||
oi = make_memop_idx(memop, idx);
|
||||
|
||||
orig_memop = memop;
|
||||
if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) {
|
||||
if ((memop & MO_BSWAP) && !tcg_target_has_memory_bswap(memop)) {
|
||||
memop &= ~MO_BSWAP;
|
||||
/* The bswap primitive benefits from zero-extended input. */
|
||||
if ((memop & MO_SIGN) && (memop & MO_SIZE) < MO_64) {
|
||||
|
@ -3091,7 +3091,7 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop)
|
|||
memop = tcg_canonicalize_memop(memop, 1, 1);
|
||||
oi = make_memop_idx(memop, idx);
|
||||
|
||||
if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) {
|
||||
if ((memop & MO_BSWAP) && !tcg_target_has_memory_bswap(memop)) {
|
||||
swap = tcg_temp_ebb_new_i64();
|
||||
switch (memop & MO_SIZE) {
|
||||
case MO_16:
|
||||
|
@ -3157,11 +3157,6 @@ static void canonicalize_memop_i128_as_i64(MemOp ret[2], MemOp orig)
|
|||
tcg_debug_assert((orig & MO_SIZE) == MO_128);
|
||||
tcg_debug_assert((orig & MO_SIGN) == 0);
|
||||
|
||||
/* Use a memory ordering implemented by the host. */
|
||||
if (!TCG_TARGET_HAS_MEMORY_BSWAP && (orig & MO_BSWAP)) {
|
||||
mop_1 &= ~MO_BSWAP;
|
||||
}
|
||||
|
||||
/* Reduce the size to 64-bit. */
|
||||
mop_1 = (mop_1 & ~MO_SIZE) | MO_64;
|
||||
|
||||
|
@ -3191,6 +3186,13 @@ static void canonicalize_memop_i128_as_i64(MemOp ret[2], MemOp orig)
|
|||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
/* Use a memory ordering implemented by the host. */
|
||||
if ((orig & MO_BSWAP) && !tcg_target_has_memory_bswap(mop_1)) {
|
||||
mop_1 &= ~MO_BSWAP;
|
||||
mop_2 &= ~MO_BSWAP;
|
||||
}
|
||||
|
||||
ret[0] = mop_1;
|
||||
ret[1] = mop_2;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue