Commit 4d59b144 authored by fanzha02's avatar fanzha02 Committed by Cherry Zhang

cmd/internal/obj/arm64: fix the bug of incorrect handling negative offset of LDP/STP/LDPW/STPW

The current assembler will report error when the negative offset is in
the range of [-256, 0) and is not the multiples of 4/8.

The fix introduces C_NSAUTO_8, C_NSAUTO_4 and C_NAUTO4K. C_NPAUTO
includes C_NSAUTO_8 instead of C_NSAUTO, C_NAUTO4K includes C_NSAUTO_8,
C_NSAUTO_4 and C_NSAUTO. So that assembler will encode the negative offset
that is greater than -4095 and is not the multiples of 4/8 as two instructions.

Add the test cases.

Fixed #24471

Change-Id: I42f34e3b8a9fc52c9e8b41504294271aafade639
Reviewed-on: https://go-review.googlesource.com/102635
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
parent 5a91c83c
...@@ -540,8 +540,12 @@ again: ...@@ -540,8 +540,12 @@ again:
LDP 1024(RSP), (R1, R2) // fb031091610b40a9 LDP 1024(RSP), (R1, R2) // fb031091610b40a9
LDP.W 8(RSP), (R1, R2) // e18bc0a9 LDP.W 8(RSP), (R1, R2) // e18bc0a9
LDP.P 8(RSP), (R1, R2) // e18bc0a8 LDP.P 8(RSP), (R1, R2) // e18bc0a8
LDP -31(R0), (R1, R2) // 1b7c00d1610b40a9
LDP -4(R0), (R1, R2) // 1b1000d1610b40a9
LDP -8(R0), (R1, R2) // 01887fa9
LDP x(SB), (R1, R2) LDP x(SB), (R1, R2)
LDP x+8(SB), (R1, R2) LDP x+8(SB), (R1, R2)
LDPW -5(R0), (R1, R2) // 1b1400d1610b4029
LDPW (R0), (R1, R2) // 01084029 LDPW (R0), (R1, R2) // 01084029
LDPW 4(R0), (R1, R2) // 01884029 LDPW 4(R0), (R1, R2) // 01884029
LDPW -4(R0), (R1, R2) // 01887f29 LDPW -4(R0), (R1, R2) // 01887f29
...@@ -579,6 +583,7 @@ again: ...@@ -579,6 +583,7 @@ again:
STP.W (R3, R4), 8(R5) // a39080a9 STP.W (R3, R4), 8(R5) // a39080a9
STP.P (R3, R4), 8(R5) // a39080a8 STP.P (R3, R4), 8(R5) // a39080a8
STP (R3, R4), -8(R5) // a3903fa9 STP (R3, R4), -8(R5) // a3903fa9
STP (R3, R4), -4(R5) // bb1000d1631300a9
STP (R3, R4), 11(R0) // 1b2c0091631300a9 STP (R3, R4), 11(R0) // 1b2c0091631300a9
STP (R3, R4), 1024(R0) // 1b001091631300a9 STP (R3, R4), 1024(R0) // 1b001091631300a9
STP (R3, R4), (RSP) // e31300a9 STP (R3, R4), (RSP) // e31300a9
...@@ -595,6 +600,7 @@ again: ...@@ -595,6 +600,7 @@ again:
STPW.W (R3, R4), 4(R5) // a3908029 STPW.W (R3, R4), 4(R5) // a3908029
STPW.P (R3, R4), 4(R5) // a3908028 STPW.P (R3, R4), 4(R5) // a3908028
STPW (R3, R4), -4(R5) // a3903f29 STPW (R3, R4), -4(R5) // a3903f29
STPW (R3, R4), -5(R5) // bb1400d163130029
STPW (R3, R4), 11(R0) // 1b2c009163130029 STPW (R3, R4), 11(R0) // 1b2c009163130029
STPW (R3, R4), 1024(R0) // 1b00109163130029 STPW (R3, R4), 1024(R0) // 1b00109163130029
STPW (R3, R4), (RSP) // e3130029 STPW (R3, R4), (RSP) // e3130029
......
...@@ -425,8 +425,11 @@ const ( ...@@ -425,8 +425,11 @@ const (
C_LBRA C_LBRA
C_ZAUTO // 0(RSP) C_ZAUTO // 0(RSP)
C_NPAUTO // -512 <= x < 0, 0 mod 8 C_NSAUTO_8 // -256 <= x < 0, 0 mod 8
C_NSAUTO_4 // -256 <= x < 0, 0 mod 4
C_NSAUTO // -256 <= x < 0 C_NSAUTO // -256 <= x < 0
C_NPAUTO // -512 <= x < 0, 0 mod 8
C_NAUTO4K // -4095 <= x < 0
C_PSAUTO_8 // 0 to 255, 0 mod 8 C_PSAUTO_8 // 0 to 255, 0 mod 8
C_PSAUTO_4 // 0 to 255, 0 mod 4 C_PSAUTO_4 // 0 to 255, 0 mod 4
C_PSAUTO // 0 to 255 C_PSAUTO // 0 to 255
...@@ -451,8 +454,11 @@ const ( ...@@ -451,8 +454,11 @@ const (
C_LEXT C_LEXT
C_ZOREG // 0(R) C_ZOREG // 0(R)
C_NPOREG // must mirror NPAUTO, etc C_NSOREG_8 // must mirror C_NSAUTO_8, etc
C_NSOREG_4
C_NSOREG C_NSOREG
C_NPOREG
C_NOREG4K
C_PSOREG_8 C_PSOREG_8
C_PSOREG_4 C_PSOREG_4
C_PSOREG C_PSOREG
......
...@@ -37,8 +37,11 @@ var cnames7 = []string{ ...@@ -37,8 +37,11 @@ var cnames7 = []string{
"SBRA", "SBRA",
"LBRA", "LBRA",
"ZAUTO", "ZAUTO",
"NPAUTO", "NSAUTO_8",
"NSAUTO_4",
"NSAUTO", "NSAUTO",
"NPAUTO",
"NAUTO4K",
"PSAUTO_8", "PSAUTO_8",
"PSAUTO_4", "PSAUTO_4",
"PSAUTO", "PSAUTO",
...@@ -61,8 +64,11 @@ var cnames7 = []string{ ...@@ -61,8 +64,11 @@ var cnames7 = []string{
"SEXT16", "SEXT16",
"LEXT", "LEXT",
"ZOREG", "ZOREG",
"NPOREG", "NSOREG_8",
"NSOREG_4",
"NSOREG", "NSOREG",
"NPOREG",
"NOREG4K",
"PSOREG_8", "PSOREG_8",
"PSOREG_4", "PSOREG_4",
"PSOREG", "PSOREG",
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment