On October 21, 2022 6:42:58 AM GMT+08:00, Richard Henderson
<richard.hender...@linaro.org> wrote:
>Fixed a minor nit:
>
>> +void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx,
>> + uintptr_t jmp_rw, uintptr_t addr)
>> +{
>> + tcg_insn_unit i1, i2;
>> + ptrdiff_t upper, lower;
>> + ptrdiff_t offset = (ptrdiff_t)(addr - jmp_rx) >> 2;
>> +
>> + if (offset == sextreg(offset, 0, 26)) {
>> + i1 = encode_sd10k16_insn(OPC_B, offset);
>> + i2 = NOP;
>> + } else {
>> + tcg_debug_assert(offset == sextreg(offset, 0, 36));
>
>This assert is smaller...
>
>> +/*
>> + * PCADDU18I + JIRL sequence can give 20 + 16 + 2 = 38 bits
>> + * signed offset, which is +/- 128 GiB.
>> + */
>> +#define MAX_CODE_GEN_BUFFER_SIZE (128 * GiB)
>
>... than the correct calculation here.
Actually no... the offset above is pre-shifted so 36 is exactly 20 (pcaddu18i)
+ 16 (jirl). The LoongArch assembly gotchas hit hard...