[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 09/30] tcg/loongarch64: Implement tcg_out_mov and tcg_out_
From: |
Richard Henderson |
Subject: |
Re: [PATCH v5 09/30] tcg/loongarch64: Implement tcg_out_mov and tcg_out_movi |
Date: |
Sat, 25 Sep 2021 10:04:30 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 |
On 9/25/21 5:54 AM, Philippe Mathieu-Daudé wrote:
+ /* High bits must be set; load with lu12i.w + optional ori. */
+ tcg_target_long hi12 = sextreg(val, 12, 20);
Please declare variables in function prologue.
Ah, true. Officially, that's qemu coding style. I tend to overlook it because I don't
like the rule.
+ tcg_out_opc_lu12i_w(s, rd, hi12);
+ if (lo != 0) {
+ tcg_out_opc_ori(s, rd, rd, lo & 0xfff);
Isn't lo already 12-bit? Why the mask?
lo was extracted signed, for addi; ori wants the value unsigned.
The value range asserts in tcg_out_opc_* will notice the difference.
+ /* Slow path. Initialize the low 32 bits, then concat high bits. */
+ tcg_out_movi_i32(s, rd, val);
+
+ bool rd_high_bits_are_ones = (int32_t)val < 0;
Declare in prologue, however this is hard to read. KISS:
If anything was to change here, I think I'd simply re-use "lo":
lo = (int32_t)val;
and then check lo < 0 rather than rd_high_bits_are_ones as a boolean.
+ rd_high_bits_are_ones = hi32 < 0;
Again KISS:
if (hi32 < 0) {
rd_high_bits_are_ones = true;
}
This is certainly not KISS, and also wrong. We would want an unconditional write to
rd_high_bits_are_ones. Although if there were any change,
lo = hi32.
so that, again, we test lo < 0 for hi52.
r~
- Re: [PATCH v5 04/30] tcg/loongarch64: Add generated instruction opcodes and encoding helpers, (continued)
- [PATCH v5 05/30] tcg/loongarch64: Add register names, allocation order and input/output sets, WANG Xuerui, 2021/09/24
- [PATCH v5 07/30] tcg/loongarch64: Implement necessary relocation operations, WANG Xuerui, 2021/09/24
- [PATCH v5 06/30] tcg/loongarch64: Define the operand constraints, WANG Xuerui, 2021/09/24
- [PATCH v5 08/30] tcg/loongarch64: Implement the memory barrier op, WANG Xuerui, 2021/09/24
- [PATCH v5 09/30] tcg/loongarch64: Implement tcg_out_mov and tcg_out_movi, WANG Xuerui, 2021/09/24
- [PATCH v5 10/30] tcg/loongarch64: Implement goto_ptr, WANG Xuerui, 2021/09/24
- [PATCH v5 12/30] tcg/loongarch64: Implement not/and/or/xor/nor/andc/orc ops, WANG Xuerui, 2021/09/24
- [PATCH v5 13/30] tcg/loongarch64: Implement deposit/extract ops, WANG Xuerui, 2021/09/24
- [PATCH v5 14/30] tcg/loongarch64: Implement bswap{16,32,64} ops, WANG Xuerui, 2021/09/24
- [PATCH v5 15/30] tcg/loongarch64: Implement clz/ctz ops, WANG Xuerui, 2021/09/24
- [PATCH v5 11/30] tcg/loongarch64: Implement sign-/zero-extension ops, WANG Xuerui, 2021/09/24