Skip to content

A64 LDRA decode scales the immediate by wrong amount

The decode for the A64 LDRA insn does this to extract the immediate:

%ldra_imm       22:s1 12:9 !function=times_2

But the Arm ARM pseudocode does:

bits(10) S10 = S:imm9;
bits(64) offset = LSL(SignExtend(S10, 64), 3);

which is to say that it scales it by 8, not 2.

Looks like I broke this in commit be23a049 in the decodetree conversion; the old code was:

    /* Form the 10-bit signed, scaled offset.  */
    offset = (extract32(insn, 22, 1) << 9) | extract32(insn, 12, 9);
    offset = sextract32(offset << size, 0, 10 + size);

where we know that size is 3.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information