[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 09/30] tcg/loongarch64: Implement tcg_out_mov and tcg_out_
From: |
Richard Henderson |
Subject: |
Re: [PATCH v3 09/30] tcg/loongarch64: Implement tcg_out_mov and tcg_out_movi |
Date: |
Fri, 24 Sep 2021 11:53:05 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 |
On 9/24/21 11:08 AM, WANG Xuerui wrote:
Oops, for some reason I only received this at about 8 pm...
That was my fault. I wrote a bunch of stuff off-line yesterday while traveling, and the
mail queue only flushed this morning.
I'll note there's a bug in my example code wrt initializing rd with addi, then overwriting
with cu32i.d.
I like your v4 version of movi, with the high-bit-set predicate. The only case I can
think of that you miss is e.g. 0x7fffffffffffffff, which can be
addi.w rd, zero, -1
cu52i.d rd, rd, 0x7ff
One possibility is to extract a subroutine:
static void tcg_out_movi_i32(TCGContext *s, TCGReg rd, int32_t val)
{
/* Single instruction cases */
/* else lu12i.w + ori */
}
static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd,
tcg_target_long val)
{
if (type == TCG_TYPE_I32 || val == (int32_t)val) {
tcg_out_movi_i32(s, rd, val);
return;
}
/* PC-relative cases */
if (ctz64(val) >= 52) {
tcg_out_opc_cu52i_d(s, rd, TCG_REG_ZERO, val >> 52);
return;
}
/* Slow path. Initialize the low 32-bits, then concat high bits. */
tcg_out_movi_i32(s, rd, val);
rd_high_bits_are_ones = (int32_t)val < 0);
/* Your imm_part_needs_loading checks; rd is always written. */
}
r~
- Re: [PATCH v3 04/30] tcg/loongarch64: Add generated instruction opcodes and encoding helpers, (continued)
[PATCH v3 07/30] tcg/loongarch64: Implement necessary relocation operations, WANG Xuerui, 2021/09/22
[PATCH v3 05/30] tcg/loongarch64: Add register names, allocation order and input/output sets, WANG Xuerui, 2021/09/22
[PATCH v3 10/30] tcg/loongarch64: Implement goto_ptr, WANG Xuerui, 2021/09/22
[PATCH v3 13/30] tcg/loongarch64: Implement deposit/extract ops, WANG Xuerui, 2021/09/22
[PATCH v3 17/30] tcg/loongarch64: Implement add/sub ops, WANG Xuerui, 2021/09/22
[PATCH v3 19/30] tcg/loongarch64: Implement br/brcond ops, WANG Xuerui, 2021/09/22
[PATCH v3 11/30] tcg/loongarch64: Implement sign-/zero-extension ops, WANG Xuerui, 2021/09/22