Commit 47193dcc authored by Ben Shi's avatar Ben Shi Committed by Cherry Zhang

cmd/internal/obj/arm: better solution of .S/.P/.U/.W suffix check

Current suffix check is based on instruction, which is not very
accurate. For example, "MOVW.S R1, R2" is valid, but
"MOVW.S $0xaaaaaaaa, R1" and "MOVW.P CPSR, R9" are not.

This patch fixes the above kinds of issues by checking suffix
based on []optab. And also more test cases are added.

fixes #20509

Change-Id: Ibad91be72c78eefa719412a83b4d44370d2202a8
Reviewed-on: https://go-review.googlesource.com/70910
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
parent f4faca60
...@@ -57,7 +57,7 @@ TEXT foo(SB), DUPOK|NOSPLIT, $0 ...@@ -57,7 +57,7 @@ TEXT foo(SB), DUPOK|NOSPLIT, $0
// outcode($1, $2, &$3, 0, &$5); // outcode($1, $2, &$3, 0, &$5);
// } // }
MOVW.S R1, R2 MOVW.S R1, R2
MOVW.S $1, R2 MOVW $1, R2
MOVW.S R1<<R2, R3 MOVW.S R1<<R2, R3
// //
...@@ -1116,8 +1116,6 @@ jmp_label_3: ...@@ -1116,8 +1116,6 @@ jmp_label_3:
// MVN // MVN
MVN $0xff, R1 // MVN $255, R1 // ff10e0e3 MVN $0xff, R1 // MVN $255, R1 // ff10e0e3
MVN $0xff000000, R1 // MVN $4278190080, R1 // ff14e0e3 MVN $0xff000000, R1 // MVN $4278190080, R1 // ff14e0e3
MVN.S $0xff, R1 // MVN.S $255, R1 // ff10f0e3
MVN.S $0xff000000, R1 // MVN.S $4278190080, R1 // ff14f0e3
MVN R9<<30, R7 // 097fe0e1 MVN R9<<30, R7 // 097fe0e1
MVN R9>>30, R7 // 297fe0e1 MVN R9>>30, R7 // 297fe0e1
MVN R9->30, R7 // 497fe0e1 MVN R9->30, R7 // 497fe0e1
...@@ -1135,7 +1133,6 @@ jmp_label_3: ...@@ -1135,7 +1133,6 @@ jmp_label_3:
MVN.S R9->R8, R7 // 5978f0e1 MVN.S R9->R8, R7 // 5978f0e1
MVN.S R9@>R8, R7 // 7978f0e1 MVN.S R9@>R8, R7 // 7978f0e1
MVN $0xffffffbe, R5 // MVN $4294967230, R5 // 4150a0e3 MVN $0xffffffbe, R5 // MVN $4294967230, R5 // 4150a0e3
MVN.S $0xffffffbf, R5 // MVN.S $4294967231, R5 // 4050b0e3
// MOVM // MOVM
MOVM.IA [R0,R2,R4,R6], (R1) // MOVM.U [R0,R2,R4,R6], (R1) // 550081e8 MOVM.IA [R0,R2,R4,R6], (R1) // MOVM.U [R0,R2,R4,R6], (R1) // 550081e8
...@@ -1173,15 +1170,23 @@ jmp_label_3: ...@@ -1173,15 +1170,23 @@ jmp_label_3:
// MOVW // MOVW
MOVW R3, R4 // 0340a0e1 MOVW R3, R4 // 0340a0e1
MOVW.S R3, R4 // 0340b0e1
MOVW R9, R2 // 0920a0e1 MOVW R9, R2 // 0920a0e1
MOVW.S R9, R2 // 0920b0e1
MOVW R5>>1, R2 // a520a0e1 MOVW R5>>1, R2 // a520a0e1
MOVW.S R5>>1, R2 // a520b0e1
MOVW R5<<1, R2 // 8520a0e1 MOVW R5<<1, R2 // 8520a0e1
MOVW.S R5<<1, R2 // 8520b0e1
MOVW R5->1, R2 // c520a0e1 MOVW R5->1, R2 // c520a0e1
MOVW.S R5->1, R2 // c520b0e1
MOVW R5@>1, R2 // e520a0e1 MOVW R5@>1, R2 // e520a0e1
MOVW.S R5@>1, R2 // e520b0e1
MOVW $0xff, R9 // MOVW $255, R9 // ff90a0e3 MOVW $0xff, R9 // MOVW $255, R9 // ff90a0e3
MOVW $0xff000000, R9 // MOVW $4278190080, R9 // ff94a0e3 MOVW $0xff000000, R9 // MOVW $4278190080, R9 // ff94a0e3
MOVW $0xff(R0), R1 // MOVW $255(R0), R1 // ff1080e2 MOVW $0xff(R0), R1 // MOVW $255(R0), R1 // ff1080e2
MOVW.S $0xff(R0), R1 // MOVW.S $255(R0), R1 // ff1090e2
MOVW $-0xff(R0), R1 // MOVW $-255(R0), R1 // ff1040e2 MOVW $-0xff(R0), R1 // MOVW $-255(R0), R1 // ff1040e2
MOVW.S $-0xff(R0), R1 // MOVW.S $-255(R0), R1 // ff1050e2
MOVW $0xffffffae, R1 // MOVW $4294967214, R1 // 5110e0e3 MOVW $0xffffffae, R1 // MOVW $4294967214, R1 // 5110e0e3
MOVW $0xaaaaaaaa, R1 // MOVW $2863311530, R1 MOVW $0xaaaaaaaa, R1 // MOVW $2863311530, R1
MOVW R1, (R2) // 001082e5 MOVW R1, (R2) // 001082e5
......
...@@ -79,6 +79,8 @@ TEXT errors(SB),$0 ...@@ -79,6 +79,8 @@ TEXT errors(SB),$0
MOVW errors(SB), F0 // ERROR "illegal combination" MOVW errors(SB), F0 // ERROR "illegal combination"
MOVW $20, errors(SB) // ERROR "illegal combination" MOVW $20, errors(SB) // ERROR "illegal combination"
MOVW errors(SB), $20 // ERROR "illegal combination" MOVW errors(SB), $20 // ERROR "illegal combination"
MOVW (R1), [R0-R4] // ERROR "illegal combination"
MOVW [R0-R4], (R1) // ERROR "illegal combination"
MOVB $245, R1 // ERROR "illegal combination" MOVB $245, R1 // ERROR "illegal combination"
MOVH $245, R1 // ERROR "illegal combination" MOVH $245, R1 // ERROR "illegal combination"
MOVB $0xff000000, R1 // ERROR "illegal combination" MOVB $0xff000000, R1 // ERROR "illegal combination"
...@@ -101,10 +103,10 @@ TEXT errors(SB),$0 ...@@ -101,10 +103,10 @@ TEXT errors(SB),$0
MOVH $0xffffff00, CPSR // ERROR "illegal combination" MOVH $0xffffff00, CPSR // ERROR "illegal combination"
MOVB $0xfffffff0, FPSR // ERROR "illegal combination" MOVB $0xfffffff0, FPSR // ERROR "illegal combination"
MOVH $0xfffffff0, FPSR // ERROR "illegal combination" MOVH $0xfffffff0, FPSR // ERROR "illegal combination"
MOVB.IA 4(R1), [R0-R4] // ERROR "illegal combination" MOVB (R1), [R0-R4] // ERROR "illegal combination"
MOVB.DA 4(R1), [R0-R4] // ERROR "illegal combination" MOVB [R0-R4], (R1) // ERROR "illegal combination"
MOVH.IA 4(R1), [R0-R4] // ERROR "illegal combination" MOVH (R1), [R0-R4] // ERROR "illegal combination"
MOVH.DA 4(R1), [R0-R4] // ERROR "illegal combination" MOVH [R0-R4], (R1) // ERROR "illegal combination"
MOVB $0xff(R0), R1 // ERROR "illegal combination" MOVB $0xff(R0), R1 // ERROR "illegal combination"
MOVH $0xff(R0), R1 // ERROR "illegal combination" MOVH $0xff(R0), R1 // ERROR "illegal combination"
MOVB $errors(SB), R2 // ERROR "illegal combination" MOVB $errors(SB), R2 // ERROR "illegal combination"
...@@ -161,6 +163,93 @@ TEXT errors(SB),$0 ...@@ -161,6 +163,93 @@ TEXT errors(SB),$0
XTAH R0<<16, R5, R2 // ERROR "illegal shift" XTAH R0<<16, R5, R2 // ERROR "illegal shift"
XTABU R0->24, R5, R2 // ERROR "illegal shift" XTABU R0->24, R5, R2 // ERROR "illegal shift"
XTAHU R0@>1, R5, R2 // ERROR "illegal shift" XTAHU R0@>1, R5, R2 // ERROR "illegal shift"
AND.W R0, R1 // ERROR "invalid .W suffix"
ORR.P R2, R3, R4 // ERROR "invalid .P suffix"
CMP.S R1, R2 // ERROR "invalid .S suffix"
BIC.P $124, R1, R2 // ERROR "invalid .P suffix"
MOVW.S $124, R1 // ERROR "invalid .S suffix"
MVN.S $123, g // ERROR "invalid .S suffix"
RSB.U $0, R9 // ERROR "invalid .U suffix"
CMP.S $29, g // ERROR "invalid .S suffix"
ADD.W R1<<R2, R3 // ERROR "invalid .W suffix"
SUB.U R1<<R2, R3, R9 // ERROR "invalid .U suffix"
CMN.S R5->R2, R1 // ERROR "invalid .S suffix"
SLL.P R1, R2, R3 // ERROR "invalid .P suffix"
SRA.U R2, R8 // ERROR "invalid .U suffix"
SWI.S // ERROR "invalid .S suffix"
SWI.P $0 // ERROR "invalid .P suffix"
MOVW.S $0xaaaaaaaa, R7 // ERROR "invalid .S suffix"
MOVW.P $0xffffff44, R1 // ERROR "invalid .P suffix"
MOVW.S $0xffffff77, R1 // ERROR "invalid .S suffix"
MVN.S $0xffffffaa, R8 // ERROR "invalid .S suffix"
MVN.S $0xaaaaaaaa, R8 // ERROR "invalid .S suffix"
ADD.U $0xaaaaaaaa, R4 // ERROR "invalid .U suffix"
ORR.P $0x555555, R7, R3 // ERROR "invalid .P suffix"
TST.S $0xabcd1234, R2 // ERROR "invalid .S suffix"
MOVB.S R1, R2 // ERROR "invalid .S suffix"
MOVBU.P R1, R2 // ERROR "invalid .P suffix"
MOVBS.U R1, R2 // ERROR "invalid .U suffix"
MOVH.S R1, R2 // ERROR "invalid .S suffix"
MOVHU.P R1, R2 // ERROR "invalid .P suffix"
MOVHS.U R1, R2 // ERROR "invalid .U suffix"
MUL.P R0, R1, R2 // ERROR "invalid .P suffix"
MULU.W R1, R2 // ERROR "invalid .W suffix"
DIVHW.S R0, R1, R2 // ERROR "invalid .S suffix"
DIVHW.W R1, R2 // ERROR "invalid .W suffix"
MULL.W R2, R0, (R5, R8) // ERROR "invalid .W suffix"
MULLU.U R2, R0, (R5, R8) // ERROR "invalid .U suffix"
BFX.S $2, $4, R3 // ERROR "invalid .S suffix"
BFXU.W $2, $4, R3, R0 // ERROR "invalid .W suffix"
MOVB.S R1, 4(R2) // ERROR "invalid .S suffix"
MOVHU.S R1, 4(R2) // ERROR "invalid .S suffix"
MOVW.S R1, 4(R2) // ERROR "invalid .S suffix"
MOVBU.S 4(R2), R3 // ERROR "invalid .S suffix"
MOVH.S 4(R2), R3 // ERROR "invalid .S suffix"
MOVW.S 4(R2), R3 // ERROR "invalid .S suffix"
XTAB.S R0@>0, R2 // ERROR "invalid .S suffix"
XTAB.W R0@>8, R2, R9 // ERROR "invalid .W suffix"
MOVBU.S R0@>24, R1 // ERROR "invalid .S suffix"
MOVHS.S R0@>16, R1 // ERROR "invalid .S suffix"
MOVB.S R1, 0xaaaa(R2) // ERROR "invalid .S suffix"
MOVHU.S R1, 0xaaaa(R2) // ERROR "invalid .S suffix"
MOVW.S R1, 0xaaaa(R2) // ERROR "invalid .S suffix"
MOVBU.S 0xaaaa(R2), R3 // ERROR "invalid .S suffix"
MOVH.S 0xaaaa(R2), R3 // ERROR "invalid .S suffix"
MOVW.S 0xaaaa(R2), R3 // ERROR "invalid .S suffix"
MOVW.S CPSR, R1 // ERROR "invalid .S suffix"
MOVW.S R3, CPSR // ERROR "invalid .S suffix"
MOVW.S $0, CPSR // ERROR "invalid .S suffix"
MOVM.S (R0), [R2-R4] // ERROR "invalid .S suffix"
MOVM.S [R1-R6], (R9) // ERROR "invalid .S suffix"
SWPW.S R1, (R2), R3 // ERROR "invalid .S suffix"
MOVF.S (R0), F1 // ERROR "invalid .S suffix"
MOVF.S F9, (R4) // ERROR "invalid .S suffix"
MOVF.S 0xfff0(R0), F1 // ERROR "invalid .S suffix"
MOVF.S F9, 0xfff0(R4) // ERROR "invalid .S suffix"
ADDF.S F1, F2, F3 // ERROR "invalid .S suffix"
SUBD.U F1, F2 // ERROR "invalid .U suffix"
NEGF.W F9, F10 // ERROR "invalid .W suffix"
ABSD.P F9, F10 // ERROR "invalid .P suffix"
MOVW.S FPSR, R0 // ERROR "invalid .S suffix"
MOVW.P g, FPSR // ERROR "invalid .P suffix"
MOVW.S R1->4(R6), R2 // ERROR "invalid .S suffix"
MOVB.S R9, R2<<8(R4) // ERROR "invalid .S suffix"
MOVHU.S R9, R2<<0(R4) // ERROR "invalid .S suffix"
STREX.S R0, (R1), R2 // ERROR "invalid .S suffix"
LDREX.S (R2), R8 // ERROR "invalid .S suffix"
MOVF.S $0.0, F3 // ERROR "invalid .S suffix"
CMPF.S F1, F2 // ERROR "invalid .S suffix"
MOVFW.S F0, F9 // ERROR "invalid .S suffix"
MOVWF.W F3, F1 // ERROR "invalid .W suffix"
MOVFW.P F0, R9 // ERROR "invalid .P suffix"
MOVWF.W R3, F1 // ERROR "invalid .W suffix"
MOVW.S F0, R9 // ERROR "invalid .S suffix"
MOVW.U R3, F1 // ERROR "invalid .U suffix"
PLD.S 4(R1) // ERROR "invalid .S suffix"
CLZ.S R1, R2 // ERROR "invalid .S suffix"
MULBB.S R0, R1, R2 // ERROR "invalid .S suffix"
MULA.W R9, R6, R1, g // ERROR "invalid .W suffix"
MULS.S R2, R3, R4, g // ERROR "invalid .S suffix"
STREX R1, (R0) // ERROR "illegal combination" STREX R1, (R0) // ERROR "illegal combination"
STREX (R1), R0 // ERROR "illegal combination" STREX (R1), R0 // ERROR "illegal combination"
......
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