qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 21/30] tcg/loongarch: Implement tcg_out_call


From: WANG Xuerui
Subject: Re: [PATCH 21/30] tcg/loongarch: Implement tcg_out_call
Date: Tue, 21 Sep 2021 14:42:59 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:94.0) Gecko/20100101 Thunderbird/94.0a1

Hi Richard,

On 9/21/21 00:35, Richard Henderson wrote:
On 9/20/21 9:31 AM, Richard Henderson wrote:
On 9/20/21 1:04 AM, WANG Xuerui wrote:
+    } else if (TCG_TARGET_REG_BITS == 32 || offset == (int32_t)offset) {
+        /* long jump: +/- 2GiB */
+        tcg_out_opc_pcaddu12i(s, TCG_REG_TMP0, 0);
+        tcg_out_opc_jirl(s, link, TCG_REG_TMP0, 0);
+        ret = reloc_call(s->code_ptr - 2, arg);
+        tcg_debug_assert(ret == true);

Just inline reloc_call here, so that you can provide the correct offsets to the pcadd and jirl instructions directly.  The assert will vanish, because you've already done the range check with "offset == (int32_t)offset".

Actually, don't you want offset == sextract64(offset, 0, 34), and use pcaddu18i? Depending on the memory map of qemu, those extra bits could make the difference in directly reaching the main executable.

Whoa, silly me, I actually didn't realize a single expected use case of pcaddu18i until I read this, the low 2 bits are always clear so 18 is exactly the amount of shift needed when paired with jirl!

I'll of course rework this to use pcaddu18i+jirl instead.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]