[Libre-soc-bugs] [Bug 980] Implement C-based Power ISA pseudocode compiler

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Mon May 29 22:04:55 BST 2023


Jacob Lifshay <programmerjake at gmail.com> changed:

           What    |Removed                     |Added
                 CC|                            |programmerjake at gmail.com

--- Comment #3 from Jacob Lifshay <programmerjake at gmail.com> ---
i recommend using memcpy instead of *(uint16_t)addr, since it avoids C language
UB and generally gets compiled to a single load/store, not a function call:

#include <stdint.h>
#include <string.h>

uint16_t load(uint8_t *mem, uint64_t EA) {
    uint16_t retval;
    memcpy(&retval, &mem[EA], 2);
    return retval;

load:                                   # @load
        lhzx 3, 3, 4
        .long   0
        .quad   0

You are receiving this mail because:
You are on the CC list for the bug.

More information about the libre-soc-bugs mailing list