Skip to content

Commit

Permalink
tcg: Add tcg_gen_{ld,st}_i128
Browse files Browse the repository at this point in the history
Do not require the translators to jump through concat and
extract of i64 in order to move values to and from env.

Tested-by: Song Gao <gaosong@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Oct 18, 2023
1 parent 58c28f5 commit cd7204c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/tcg/tcg-op-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,9 @@ void tcg_gen_mov_i128(TCGv_i128 dst, TCGv_i128 src);
void tcg_gen_extr_i128_i64(TCGv_i64 lo, TCGv_i64 hi, TCGv_i128 arg);
void tcg_gen_concat_i64_i128(TCGv_i128 ret, TCGv_i64 lo, TCGv_i64 hi);

void tcg_gen_ld_i128(TCGv_i128 ret, TCGv_ptr base, tcg_target_long offset);
void tcg_gen_st_i128(TCGv_i128 val, TCGv_ptr base, tcg_target_long offset);

static inline void tcg_gen_concat32_i64(TCGv_i64 ret, TCGv_i64 lo, TCGv_i64 hi)
{
tcg_gen_deposit_i64(ret, lo, hi, 32, 32);
Expand Down
22 changes: 22 additions & 0 deletions tcg/tcg-op.c
Original file line number Diff line number Diff line change
Expand Up @@ -2880,6 +2880,28 @@ void tcg_gen_mov_i128(TCGv_i128 dst, TCGv_i128 src)
}
}

void tcg_gen_ld_i128(TCGv_i128 ret, TCGv_ptr base, tcg_target_long offset)
{
if (HOST_BIG_ENDIAN) {
tcg_gen_ld_i64(TCGV128_HIGH(ret), base, offset);
tcg_gen_ld_i64(TCGV128_LOW(ret), base, offset + 8);
} else {
tcg_gen_ld_i64(TCGV128_LOW(ret), base, offset);
tcg_gen_ld_i64(TCGV128_HIGH(ret), base, offset + 8);
}
}

void tcg_gen_st_i128(TCGv_i128 val, TCGv_ptr base, tcg_target_long offset)
{
if (HOST_BIG_ENDIAN) {
tcg_gen_st_i64(TCGV128_HIGH(val), base, offset);
tcg_gen_st_i64(TCGV128_LOW(val), base, offset + 8);
} else {
tcg_gen_st_i64(TCGV128_LOW(val), base, offset);
tcg_gen_st_i64(TCGV128_HIGH(val), base, offset + 8);
}
}

/* QEMU specific operations. */

void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx)
Expand Down

0 comments on commit cd7204c

Please sign in to comment.