|
From: | WANG Xuerui |
Subject: | Re: [PATCH 07/30] tcg/loongarch: Implement necessary relocation operations |
Date: | Tue, 21 Sep 2021 01:15:45 +0800 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:94.0) Gecko/20100101 Thunderbird/94.0a1 |
Hi Richard, On 9/20/21 22:36, Richard Henderson wrote:
Yes, you're right on this; on closer look at the riscv port they actually reused this logic once (the riscv port drops large constants to pool, hence need some PC-relative hackery). For LoongArch the only usage of this code is for generating calls, so I'll just merge this into the commit doing tcg_out_call, and inline if the resulting code is still readable.On 9/20/21 1:04 AM, WANG Xuerui wrote:+static bool reloc_call(tcg_insn_unit *src_rw, const tcg_insn_unit *target)+{ + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + intptr_t offset = (intptr_t)target - (intptr_t)src_rx; + int32_t lo = sextreg(offset, 0, 12); + int32_t hi = offset - lo; + + tcg_debug_assert((offset & 2) == 0); + if (offset == hi + lo) { + hi >>= 12; + src_rw[0] |= (hi << 5) & 0x1ffffe0; /* pcaddu12i's Sj20 imm */ + lo >>= 2; + src_rw[1] |= (lo << 10) & 0x3fffc00; /* jirl's Sk16 imm */ + return true; + } + + return false; +}This doesn't seem to belong as a "reloc".Certainly it doesn't seem like something that can simply be allowed to fail.
And it's 1 a.m. here in China, so I'll be processing the other review comments after getting some sleep. (Today's in the middle of the 3-day Mid-Autumn Festival holiday here, and that's why I can work on this hobby project like it's $DAY_JOB!) I'll send the v2 hopefully at afternoon local time (tomorrow in your timezone).
r~
[Prev in Thread] | Current Thread | [Next in Thread] |