Commit e00a38c8 authored by Ben Shi's avatar Ben Shi Committed by Cherry Zhang

cmd/internal/obj/arm: fix setting U bit in shifted register offset of MOVBS

"MOVBS.U R0<<0(R1), R2" is assembled to 0xe19120d0 (ldrsb r2, [r1, r0]),
but it is expected to be 0xe11120d0 (ldrsb r2, [r1, -r0]).

This patch fixes it and adds more encoding tests.

fixes #20701

Change-Id: Ic1fb46438d71a978dbef06d97494a70c95fcbf3a
Reviewed-on: https://go-review.googlesource.com/45996
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
parent 856fd8f5
This diff is collapsed.
......@@ -23,5 +23,80 @@ TEXT errors(SB),$0
MOVM.DA 4(R1), [R0-R4] // ERROR "offset must be zero"
MOVM.IB 4(R1), [R0-R4] // ERROR "offset must be zero"
MOVM.DB 4(R1), [R0-R4] // ERROR "offset must be zero"
MOVM.IA [R0-R4], 4(R1) // ERROR "offset must be zero"
MOVM.DA [R0-R4], 4(R1) // ERROR "offset must be zero"
MOVM.IB [R0-R4], 4(R1) // ERROR "offset must be zero"
MOVM.DB [R0-R4], 4(R1) // ERROR "offset must be zero"
MOVW CPSR, FPSR // ERROR "illegal combination"
MOVW FPSR, CPSR // ERROR "illegal combination"
MOVW CPSR, errors(SB) // ERROR "illegal combination"
MOVW errors(SB), CPSR // ERROR "illegal combination"
MOVW FPSR, errors(SB) // ERROR "illegal combination"
MOVW errors(SB), FPSR // ERROR "illegal combination"
MOVW F0, errors(SB) // ERROR "illegal combination"
MOVW errors(SB), F0 // ERROR "illegal combination"
MOVW $20, errors(SB) // ERROR "illegal combination"
MOVW errors(SB), $20 // ERROR "illegal combination"
MOVB $245, R1 // ERROR "illegal combination"
MOVH $245, R1 // ERROR "illegal combination"
MOVB $0xff000000, R1 // ERROR "illegal combination"
MOVH $0xff000000, R1 // ERROR "illegal combination"
MOVB $0x00ffffff, R1 // ERROR "illegal combination"
MOVH $0x00ffffff, R1 // ERROR "illegal combination"
MOVB FPSR, g // ERROR "illegal combination"
MOVH FPSR, g // ERROR "illegal combination"
MOVB g, FPSR // ERROR "illegal combination"
MOVH g, FPSR // ERROR "illegal combination"
MOVB CPSR, g // ERROR "illegal combination"
MOVH CPSR, g // ERROR "illegal combination"
MOVB g, CPSR // ERROR "illegal combination"
MOVH g, CPSR // ERROR "illegal combination"
MOVB $0xff000000, CPSR // ERROR "illegal combination"
MOVH $0xff000000, CPSR // ERROR "illegal combination"
MOVB $0xff000000, FPSR // ERROR "illegal combination"
MOVH $0xff000000, FPSR // ERROR "illegal combination"
MOVB $0xffffff00, CPSR // ERROR "illegal combination"
MOVH $0xffffff00, CPSR // ERROR "illegal combination"
MOVB $0xfffffff0, FPSR // ERROR "illegal combination"
MOVH $0xfffffff0, FPSR // ERROR "illegal combination"
MOVB.IA 4(R1), [R0-R4] // ERROR "illegal combination"
MOVB.DA 4(R1), [R0-R4] // ERROR "illegal combination"
MOVH.IA 4(R1), [R0-R4] // ERROR "illegal combination"
MOVH.DA 4(R1), [R0-R4] // ERROR "illegal combination"
MOVB $0xff(R0), R1 // ERROR "illegal combination"
MOVH $0xff(R0), R1 // ERROR "illegal combination"
MOVB $errors(SB), R2 // ERROR "illegal combination"
MOVH $errors(SB), R2 // ERROR "illegal combination"
MOVB F0, R0 // ERROR "illegal combination"
MOVH F0, R0 // ERROR "illegal combination"
MOVB R0, F0 // ERROR "illegal combination"
MOVH R0, F0 // ERROR "illegal combination"
MOVB R0>>0(R1), R2 // ERROR "bad shift"
MOVB R0->0(R1), R2 // ERROR "bad shift"
MOVB R0@>0(R1), R2 // ERROR "bad shift"
MOVBS R0>>0(R1), R2 // ERROR "bad shift"
MOVBS R0->0(R1), R2 // ERROR "bad shift"
MOVBS R0@>0(R1), R2 // ERROR "bad shift"
MOVF CPSR, F1 // ERROR "illegal combination"
MOVD R1, CPSR // ERROR "illegal combination"
MOVW F1, F2 // ERROR "illegal combination"
MOVB F1, F2 // ERROR "illegal combination"
MOVH F1, F2 // ERROR "illegal combination"
MOVF R1, F2 // ERROR "illegal combination"
MOVD R1, F2 // ERROR "illegal combination"
MOVF R1, R1 // ERROR "illegal combination"
MOVD R1, R2 // ERROR "illegal combination"
MOVFW R1, R2 // ERROR "illegal combination"
MOVDW R1, R2 // ERROR "illegal combination"
MOVWF R1, R2 // ERROR "illegal combination"
MOVWD R1, R2 // ERROR "illegal combination"
MOVWD CPSR, R2 // ERROR "illegal combination"
MOVWF CPSR, R2 // ERROR "illegal combination"
MOVWD R1, CPSR // ERROR "illegal combination"
MOVWF R1, CPSR // ERROR "illegal combination"
MOVDW CPSR, R2 // ERROR "illegal combination"
MOVFW CPSR, R2 // ERROR "illegal combination"
MOVDW R1, CPSR // ERROR "illegal combination"
MOVFW R1, CPSR // ERROR "illegal combination"
END
......@@ -44,4 +44,47 @@ TEXT foo(SB), DUPOK|NOSPLIT, $0
MOVW R4, F8 // 104b08ee
MOVW F4, R8 // 108b14ee
MOVF (R4), F9 // 009a94ed
MOVD.EQ (R4), F9 // 009b940d
MOVF.NE (g), F3 // 003a9a1d
MOVD (g), F3 // 003b9aed
MOVF 0x20(R3), F9 // MOVF 32(R3), F9 // 089a93ed
MOVD.EQ 0x20(R4), F9 // MOVD.EQ 32(R4), F9 // 089b940d
MOVF.NE -0x20(g), F3 // MOVF.NE -32(g), F3 // 083a1a1d
MOVD -0x20(g), F3 // MOVD -32(g), F3 // 083b1aed
MOVF F9, (R4) // 009a84ed
MOVD.EQ F9, (R4) // 009b840d
MOVF.NE F3, (g) // 003a8a1d
MOVD F3, (g) // 003b8aed
MOVF F9, 0x20(R3) // MOVF F9, 32(R3) // 089a83ed
MOVD.EQ F9, 0x20(R4) // MOVD.EQ F9, 32(R4) // 089b840d
MOVF.NE F3, -0x20(g) // MOVF.NE F3, -32(g) // 083a0a1d
MOVD F3, -0x20(g) // MOVD F3, -32(g) // 083b0aed
MOVF 0x00ffffff(R2), F1 // MOVF 16777215(R2), F1
MOVD 0x00ffffff(R2), F1 // MOVD 16777215(R2), F1
MOVF F2, 0x00ffffff(R2) // MOVF F2, 16777215(R2)
MOVD F2, 0x00ffffff(R2) // MOVD F2, 16777215(R2)
MOVF F0, math·Exp(SB) // MOVF F0, math.Exp(SB)
MOVF math·Exp(SB), F0 // MOVF math.Exp(SB), F0
MOVD F0, math·Exp(SB) // MOVD F0, math.Exp(SB)
MOVD math·Exp(SB), F0 // MOVD math.Exp(SB), F0
MOVF F4, F5 // 445ab0ee
MOVD F6, F7 // 467bb0ee
MOVFW F6, F8 // c68abdee
MOVFW F6, R8 // c6fabdee108b1fee
MOVFW.U F6, F8 // c68abcee
MOVFW.U F6, R8 // c6fabcee108b1fee
MOVDW F6, F8 // c68bbdee
MOVDW F6, R8 // c6fbbdee108b1fee
MOVDW.U F6, F8 // c68bbcee
MOVDW.U F6, R8 // c6fbbcee108b1fee
MOVWF F6, F8 // c68ab8ee
MOVWF R6, F8 // 106b0feecf8ab8ee
MOVWF.U F6, F8 // 468ab8ee
MOVWF.U R6, F8 // 106b0fee4f8ab8ee
MOVWD F6, F8 // c68bb8ee
MOVWD R6, F8 // 106b0feecf8bb8ee
MOVWD.U F6, F8 // 468bb8ee
MOVWD.U R6, F8 // 106b0fee4f8bb8ee
END
......@@ -2249,10 +2249,13 @@ func (c *ctxt5) asmout(p *obj.Prog, o *Optab, out []uint32) {
}
if p.From.Offset&(^0xf) != 0 {
c.ctxt.Diag("bad shift in LDRSB")
c.ctxt.Diag("bad shift: %v", p)
}
o1 = c.olhrr(int(p.From.Offset), int(p.From.Reg), int(p.To.Reg), int(p.Scond))
o1 ^= 1<<5 | 1<<6
if p.Scond&C_UBIT != 0 {
o1 &^= 1 << 23
}
case 61: /* movw/b/bu R,R<<[IR](R) -> str indexed */
if p.To.Reg == 0 {
......
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