]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/asm: fix TBZ/TBNZ instructions on arm64
authorwei xiao <wei.xiao@arm.com>
Mon, 28 Nov 2016 02:35:12 +0000 (10:35 +0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 24 Mar 2017 05:26:06 +0000 (05:26 +0000)
Fixes #18069
Also added a test in: cmd/asm/internal/asm/testdata/arm64.s

Change-Id: Iee400bda4f30503ea3c1dc5bb8301568f19c92d1
Signed-off-by: Wei Xiao <wei.xiao@arm.com>
Reviewed-on: https://go-review.googlesource.com/33594
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/asm/internal/arch/arm64.go
src/cmd/asm/internal/asm/asm.go
src/cmd/asm/internal/asm/testdata/arm64.s

index ab64a05f2b3ee684f01b8914adfc1e7476a741f8..dd04719451e75f173dcc3572553b47ec6fe54fe2 100644 (file)
@@ -43,6 +43,8 @@ var arm64Jump = map[string]bool{
        "CBNZ":  true,
        "CBNZW": true,
        "JMP":   true,
+       "TBNZ":  true,
+       "TBZ":   true,
 }
 
 func jumpArm64(word string) bool {
index 350314d8247642aab98c94f08ebff7c399e37493..e83cd7286d2168bbe4f1d75f93f3e0b633cafb9e 100644 (file)
@@ -390,6 +390,18 @@ func (p *Parser) asmJump(op obj.As, cond string, a []obj.Addr) {
                        }
                        break
                }
+               if p.arch.Family == sys.ARM64 {
+                       // Special 3-operand jumps.
+                       // a[0] must be immediate constant; a[1] is a register.
+                       if a[0].Type != obj.TYPE_CONST {
+                               p.errorf("%s: expected immediate constant; found %s", op, obj.Dconv(prog, &a[0]))
+                               return
+                       }
+                       prog.From = a[0]
+                       prog.Reg = p.getRegister(prog, op, &a[1])
+                       target = &a[2]
+                       break
+               }
 
                fallthrough
        default:
index 8d501965e928e6ab907f405a6be42026fad3f059..39859d980a14f8a43f282ba13e7a9c725425c51c 100644 (file)
@@ -257,6 +257,8 @@ again:
        B       foo(SB) // JMP foo(SB)
        BL      foo(SB) // CALL foo(SB)
        BEQ     2(PC)
+       TBZ     $1, R1, 2(PC)
+       TBNZ    $2, R2, 2(PC)
        JMP     foo(SB)
        CALL    foo(SB)