]> Cypherpunks repositories - gostls13.git/commit
cmd/asm: Fix encoding error of register offset shifted by 0 on arm64
authoreric fang <eric.fang@arm.com>
Tue, 18 Jul 2023 06:50:49 +0000 (06:50 +0000)
committerEric Fang <eric.fang@arm.com>
Mon, 24 Jul 2023 01:11:41 +0000 (01:11 +0000)
commit02482a546fd7d626427ce336a4622b90d82c14d1
treee66a844160936a93f48dc7ed917d837fcc77dae8
parent2eca0b1e1663d826893b6b1fd8bd89da98e65d1e
cmd/asm: Fix encoding error of register offset shifted by 0 on arm64

The following instruction is wrongly encoded on arm64:
MOVD (R2)(R3<<0), R1
It's incorrectly encoded as
MOVD (R2)(R3<<3), R1

The reason for the error is that we hard-coded the shift encoding to 6,
which is correct for the MOVB and MOVBU instructions because it only
allows a shift amount of 0, but it is wrong for the MOVD instruction
because it also allows other shift values.

For instructions MOVB, MOVBU and FMOVB, the extension amount must be 0,
encoded in "S" as 0 if omitted, or as 1 if present. But in Go, we don't
distinguish between Rn.<EXT> and Rn.<EXT><<0, so we encode it as that
does not present. This makes no difference to the function of the
instruction.

Change-Id: I2afe3498392cc9b2ecd524c7744f28b9d6d107b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/510995
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/asm/internal/asm/testdata/arm64.s
src/cmd/asm/internal/asm/testdata/arm64enc.s
src/cmd/internal/obj/arm64/asm7.go