]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/arm64: fix two issues in the assembler
authorBen Shi <powerman1st@163.com>
Sat, 26 May 2018 12:43:16 +0000 (12:43 +0000)
committerCherry Zhang <cherryyz@google.com>
Fri, 1 Jun 2018 15:24:42 +0000 (15:24 +0000)
There are two issues in the arm64 assembler.

1. "CMPW $0x22220000, RSP" is encoded to 5b44a4d2ff031b6b, which
   is the combination of "MOVD $0x22220000, Rtmp" and
   "NEGSW Rtmp, ZR".
   The right encoding should be a combination of
   "MOVD $0x22220000, Rtmp" and "CMPW Rtmp, RSP".

2. "AND $0x22220000, R2, RSP" is encoded to 5b44a4d25f601b00,
   which is the combination of "MOVD $0x22220000, Rtmp" and
   an illegal instruction.
   The right behavior should be an error report of
   "illegal combination", since "AND Rtmp, RSP, RSP" is invalid
   in armv8.

This CL fixes the above 2 issues and adds more test cases.

fixes #25557

Change-Id: Ia510be26b58a229f5dfe8a5fa0b35569b2d566e7
Reviewed-on: https://go-review.googlesource.com/114796
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/asm/internal/asm/testdata/arm64.s
src/cmd/asm/internal/asm/testdata/arm64error.s
src/cmd/internal/obj/arm64/asm7.go

index ce6282f0ddb9af39c2bbf05bfdc8ee2326c82aaf..54be761c543ce820a409fdff2706e975f1b2b092 100644 (file)
@@ -190,6 +190,15 @@ TEXT       foo(SB), DUPOK|NOSPLIT, $-8
        EOR     $(1<<63), R1   // EOR   $-9223372036854775808, R1 // 210041d2
        EOR     $(1<<63-1), R1 // EOR   $9223372036854775807, R1  // 21f840d2
 
+       AND     $0x22220000, R3, R4   // AND $572653568, R3, R4   // 5b44a4d264001b8a
+       ORR     $0x22220000, R3, R4   // ORR $572653568, R3, R4   // 5b44a4d264001baa
+       EOR     $0x22220000, R3, R4   // EOR $572653568, R3, R4   // 5b44a4d264001bca
+       BIC     $0x22220000, R3, R4   // BIC $572653568, R3, R4   // 5b44a4d264003b8a
+       ORN     $0x22220000, R3, R4   // ORN $572653568, R3, R4   // 5b44a4d264003baa
+       EON     $0x22220000, R3, R4   // EON $572653568, R3, R4   // 5b44a4d264003bca
+       ANDS    $0x22220000, R3, R4   // ANDS $572653568, R3, R4  // 5b44a4d264001bea
+       BICS    $0x22220000, R3, R4   // BICS $572653568, R3, R4  // 5b44a4d264003bea
+
        AND     $8, R0, RSP // 1f007d92
        ORR     $8, R0, RSP // 1f007db2
        EOR     $8, R0, RSP // 1f007dd2
@@ -390,6 +399,18 @@ TEXT       foo(SB), DUPOK|NOSPLIT, $-8
        CMP     R1>>22, R2
        CMP     R1<<33, R2
        CMP     R22.SXTX, RSP // ffe336eb
+
+       CMP     $0x22220000, RSP  // CMP $572653568, RSP   // 5b44a4d2ff633beb
+       CMPW    $0x22220000, RSP  // CMPW $572653568, RSP  // 5b44a4d2ff633b6b
+
+// TST
+       TST     $15, R2                               // 5f0c40f2
+       TST     R1, R2                                // 5f0001ea
+       TST     R1->11, R2                            // 5f2c81ea
+       TST     R1>>22, R2                            // 5f5841ea
+       TST     R1<<33, R2                            // 5f8401ea
+       TST     $0x22220000, R3 // TST $572653568, R3 // 5b44a4d27f001bea
+
 //
 // CBZ
 //
index 36829686f62313f76ea1bdd911fc192b2750159f..be2251e442e0c6794542f06a1534af181702acf0 100644 (file)
@@ -87,4 +87,6 @@ TEXT errors(SB),$0
        MADD    R1, R2, R3                                       // ERROR "illegal combination"
        CINC    CS, R2, R3, R4                                   // ERROR "illegal combination"
        CSEL    LT, R1, R2                                       // ERROR "illegal combination"
+       AND     $0x22220000, R2, RSP                             // ERROR "illegal combination"
+       ANDS    $0x22220000, R2, RSP                             // ERROR "illegal combination"
        RET
index bf96bb58a6abb8d15419998505286f478b80f9e5..e7271437573efd2218d8b85a517ec8d3e6591fac 100644 (file)
@@ -245,12 +245,12 @@ var optab = []Optab{
        {AANDS, C_BITCON, C_REG, C_NONE, C_REG, 53, 4, 0, 0, 0},
        {AANDS, C_BITCON, C_NONE, C_NONE, C_REG, 53, 4, 0, 0, 0},
        {ATST, C_BITCON, C_REG, C_NONE, C_NONE, 53, 4, 0, 0, 0},
-       {AAND, C_MOVCON, C_REG, C_NONE, C_RSP, 62, 8, 0, 0, 0},
+       {AAND, C_MOVCON, C_REG, C_NONE, C_REG, 62, 8, 0, 0, 0},
        {AAND, C_MOVCON, C_NONE, C_NONE, C_REG, 62, 8, 0, 0, 0},
        {AANDS, C_MOVCON, C_REG, C_NONE, C_REG, 62, 8, 0, 0, 0},
        {AANDS, C_MOVCON, C_NONE, C_NONE, C_REG, 62, 8, 0, 0, 0},
        {ATST, C_MOVCON, C_REG, C_NONE, C_NONE, 62, 8, 0, 0, 0},
-       {AAND, C_VCON, C_REG, C_NONE, C_RSP, 28, 8, 0, LFROM, 0},
+       {AAND, C_VCON, C_REG, C_NONE, C_REG, 28, 8, 0, LFROM, 0},
        {AAND, C_VCON, C_NONE, C_NONE, C_REG, 28, 8, 0, LFROM, 0},
        {AANDS, C_VCON, C_REG, C_NONE, C_REG, 28, 8, 0, LFROM, 0},
        {AANDS, C_VCON, C_NONE, C_NONE, C_REG, 28, 8, 0, LFROM, 0},
@@ -3548,7 +3548,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
                if r == 0 {
                        r = rt
                }
-               if p.To.Type != obj.TYPE_NONE && (p.To.Reg == REGSP || r == REGSP) {
+               if p.To.Reg == REGSP || r == REGSP {
                        o2 = c.opxrrr(p, p.As, false)
                        o2 |= REGTMP & 31 << 16
                        o2 |= LSL0_64