mirror of
https://github.com/golang/go
synced 2024-11-07 20:06:21 -07:00
cmd/internal/obj/arm64: fix incorrect rejection of legal instructions
"BFI $0, R1, $7, R2" is expected to copy bit 0~6 from R1 to R2, and left R2's other bits unchanged. But the assembler rejects it with error "illegal bit number", and BFIW/SBFIZ/SBFIZW/UBFIZ/UBFIZW have the same problem. This CL fixes that issue and adds corresponding test cases. fixes #26736 Change-Id: Ie0090a0faa38a49dd9b096a0f435987849800b76 Reviewed-on: https://go-review.googlesource.com/127159 Run-TryBot: Ben Shi <powerman1st@163.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
ac6d156479
commit
9594ba4fe5
8
src/cmd/asm/internal/asm/testdata/arm64.s
vendored
8
src/cmd/asm/internal/asm/testdata/arm64.s
vendored
@ -716,6 +716,14 @@ again:
|
||||
STPW (R3, R4), x(SB)
|
||||
STPW (R3, R4), x+8(SB)
|
||||
|
||||
// bit field operation
|
||||
BFI $0, R1, $1, R2 // 220040b3
|
||||
BFIW $0, R1, $1, R2 // 22000033
|
||||
SBFIZ $0, R1, $1, R2 // 22004093
|
||||
SBFIZW $0, R1, $1, R2 // 22000013
|
||||
UBFIZ $0, R1, $1, R2 // 220040d3
|
||||
UBFIZW $0, R1, $1, R2 // 22000053
|
||||
|
||||
// END
|
||||
//
|
||||
// LTYPEE comma
|
||||
|
@ -3264,10 +3264,16 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
|
||||
}
|
||||
switch p.As {
|
||||
case ABFI:
|
||||
o1 = c.opbfm(p, ABFM, 64-r, s-1, rf, rt)
|
||||
if r != 0 {
|
||||
r = 64 - r
|
||||
}
|
||||
o1 = c.opbfm(p, ABFM, r, s-1, rf, rt)
|
||||
|
||||
case ABFIW:
|
||||
o1 = c.opbfm(p, ABFMW, 32-r, s-1, rf, rt)
|
||||
if r != 0 {
|
||||
r = 32 - r
|
||||
}
|
||||
o1 = c.opbfm(p, ABFMW, r, s-1, rf, rt)
|
||||
|
||||
case ABFXIL:
|
||||
o1 = c.opbfm(p, ABFM, r, r+s-1, rf, rt)
|
||||
@ -3276,10 +3282,16 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
|
||||
o1 = c.opbfm(p, ABFMW, r, r+s-1, rf, rt)
|
||||
|
||||
case ASBFIZ:
|
||||
o1 = c.opbfm(p, ASBFM, 64-r, s-1, rf, rt)
|
||||
if r != 0 {
|
||||
r = 64 - r
|
||||
}
|
||||
o1 = c.opbfm(p, ASBFM, r, s-1, rf, rt)
|
||||
|
||||
case ASBFIZW:
|
||||
o1 = c.opbfm(p, ASBFMW, 32-r, s-1, rf, rt)
|
||||
if r != 0 {
|
||||
r = 32 - r
|
||||
}
|
||||
o1 = c.opbfm(p, ASBFMW, r, s-1, rf, rt)
|
||||
|
||||
case ASBFX:
|
||||
o1 = c.opbfm(p, ASBFM, r, r+s-1, rf, rt)
|
||||
@ -3288,10 +3300,16 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
|
||||
o1 = c.opbfm(p, ASBFMW, r, r+s-1, rf, rt)
|
||||
|
||||
case AUBFIZ:
|
||||
o1 = c.opbfm(p, AUBFM, 64-r, s-1, rf, rt)
|
||||
if r != 0 {
|
||||
r = 64 - r
|
||||
}
|
||||
o1 = c.opbfm(p, AUBFM, r, s-1, rf, rt)
|
||||
|
||||
case AUBFIZW:
|
||||
o1 = c.opbfm(p, AUBFMW, 32-r, s-1, rf, rt)
|
||||
if r != 0 {
|
||||
r = 32 - r
|
||||
}
|
||||
o1 = c.opbfm(p, AUBFMW, r, s-1, rf, rt)
|
||||
|
||||
case AUBFX:
|
||||
o1 = c.opbfm(p, AUBFM, r, r+s-1, rf, rt)
|
||||
|
Loading…
Reference in New Issue
Block a user