tactcomplabs / rev

RISC-V SST CPU Component
Other
17 stars 21 forks source link

Handle load flags (e.g., sign/zero extension, NaN boxing) at the end of ReadMem() regardless of whether RevMem or MemH is used #287

Closed leekillough closed 4 months ago

leekillough commented 4 months ago

Handle load flags (e.g., sign/zero extension, NaN boxing) at the end of ReadMem() regardless of whether RevMem or MemH is used.

Previously, the integer/floating-point load execute functions performed the operation on the destination register regardless of whether RevMem or MemH was used, causing a garbage temporary result in the destination register if MemH was used.

Use memcpy() and separate 1/2/4-byte variables to make the code C++-compliant and independent of host machine's endianness. Previously, the code assumed a little-endian host and performed undefined behavior with pointer casting, which violates the C/C++ strict aliasing rule (it is undefined behavior to cast a pointer from one type to another and then dereference it, unless the second type is a char).

Add another pseudoinstruction: ra as destination register is implicit in jal instruction -- objdump and other disassemblers do not list ra as a destination register but make it implicit by leaving it out of the disassembly -- only non-ra destination registers are explicitly listed in disassembly.