[PATCH] D105528: [RuntimeDyldChecker] Support offset in decode_operand expr
luxufan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 13 23:56:24 PDT 2021
StephenFan added inline comments.
================
Comment at: llvm/test/ExecutionEngine/JITLink/RISCV/ELF_pc_indirect.s:22
# jitlink-check: decode_operand(test_pcrel32, 1) = ((named_data - test_pcrel32) + 0x800) >> 12
+# jitlink-check: decode_operand(test_pcrel32+4, 2) = (named_data - test_pcrel32) - (((named_data - test_pcrel32 + 0x800) & 0xfffff000))
.globl test_pcrel32
----------------
jrtc27 wrote:
> This is just `(named_data - test_pcrel32) & 0xfff` sign-extended from 12 to 64 bits. The + 0x800 for the HI is to compensate for the sign extension for the LO, feeding it back into the LO calculation is backwards and results in circular reasoning.
> This is just `(named_data - test_pcrel32) & 0xfff` sign-extended from 12 to 64 bits. The + 0x800 for the HI is to compensate for the sign extension for the LO, feeding it back into the LO calculation is backwards and results in circular reasoning.
@jrtc27 Thank you for reminding me! You're right! By thinking again, here is my understanding:
If the pc relative value is 0x00001fff, if don't add 0x800, then the value will be split to high 20bits(`0x00001`) and low 12bits(`0xfff`). However, the low 12bits will be considered as a signed number. so the MSB of 0xfff which originally represent `2^11` now changed to `-2^11`. The difference is `2^12`. So we need to add `0x800` to compensate the difference. Are there any errors in my understanding?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105528/new/
https://reviews.llvm.org/D105528
More information about the llvm-commits
mailing list