biscuit icon indicating copy to clipboard operation
biscuit copied to clipboard

No way to do PC literal loadstores

Open Sonicadvance1 opened this issue 2 years ago • 2 comments

A PC relative loadstore in RISCV is useful for large 64-bit values that would otherwise take quite a few instructions to encode.

Vixl allows something like the following to encode a literal:

Literal l_CTX {reinterpret_cast<uintptr_t>(CTX)};
ldr(x0, &l_CTX);
place(&l_CTX);

From this code it lets you store the 64-bit constant in the Literal object, then place will put the 64-bit constant in that location in memory, fixing up and loadstores that were bound to it in the process.

For RISCV you need two instructions to do a PC relative offset loadstore like this

.LCPI0_0:
        .quad   4702394921427289928             # 0x4142434445464748
Constant():                           # @Constant()
        lui     a0, %hi(.LCPI0_0)
        ld      a0, %lo(.LCPI0_0)(a0)

Not sure exactly how the semantics should be in biscuit to handle this case.

Sonicadvance1 avatar Mar 26 '22 01:03 Sonicadvance1