1
0
mirror of https://github.com/golang/go synced 2024-11-18 08:04:40 -07:00

cmd/asm/internal/asm: fix a bug in ARM assembly encoding test

It is expected to test assembly code for ARMv5, ARMv6 and ARMv7
in cmd/asm/internal/asm/endtoend_test.go. But actually the loop
in "func TestARMEndToEnd(t *testing.T)" runs three times all
for ARMv5.

This patch fixes that bug and adds a new armv6.s which is only tested
with GOARM=6.

fixes #20465

Change-Id: I5dbf00809a47ace2c195335e2c9bdd768479aada
Reviewed-on: https://go-review.googlesource.com/43930
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Ben Shi 2017-05-23 10:12:36 +00:00 committed by Brad Fitzpatrick
parent b8a4eb4bd8
commit ffab6ab877
2 changed files with 56 additions and 10 deletions

View File

@ -19,6 +19,7 @@ import (
"cmd/asm/internal/lex"
"cmd/internal/obj"
"cmd/internal/objabi"
)
// An end-to-end test for the assembler: Do we print what we parse?
@ -352,22 +353,23 @@ func testErrors(t *testing.T, goarch, file string) {
}
func Test386EndToEnd(t *testing.T) {
defer os.Setenv("GO386", os.Getenv("GO386"))
for _, go386 := range []string{"387", "sse"} {
os.Setenv("GO386", go386)
t.Logf("GO386=%v", os.Getenv("GO386"))
defer func(old string) { objabi.GO386 = old }(objabi.GO386)
for _, go386 := range []string{"387", "sse2"} {
t.Logf("GO386=%v", go386)
objabi.GO386 = go386
testEndToEnd(t, "386", "386")
}
}
func TestARMEndToEnd(t *testing.T) {
defer os.Setenv("GOARM", os.Getenv("GOARM"))
for _, goarm := range []string{"5", "6", "7"} {
os.Setenv("GOARM", goarm)
t.Logf("GOARM=%v", os.Getenv("GOARM"))
defer func(old int) { objabi.GOARM = old }(objabi.GOARM)
for _, goarm := range []int{5, 6, 7} {
t.Logf("GOARM=%d", goarm)
objabi.GOARM = goarm
testEndToEnd(t, "arm", "arm")
if goarm == 6 {
testEndToEnd(t, "arm", "armv6")
}
}
}

View File

@ -0,0 +1,44 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "../../../../../runtime/textflag.h"
TEXT foo(SB), DUPOK|NOSPLIT, $0
ADDF F0, F1, F2 // 002a31ee
ADDD.EQ F3, F4, F5 // 035b340e
ADDF.NE F0, F2 // 002a321e
ADDD F3, F5 // 035b35ee
SUBF F0, F1, F2 // 402a31ee
SUBD.EQ F3, F4, F5 // 435b340e
SUBF.NE F0, F2 // 402a321e
SUBD F3, F5 // 435b35ee
MULF F0, F1, F2 // 002a21ee
MULD.EQ F3, F4, F5 // 035b240e
MULF.NE F0, F2 // 002a221e
MULD F3, F5 // 035b25ee
DIVF F0, F1, F2 // 002a81ee
DIVD.EQ F3, F4, F5 // 035b840e
DIVF.NE F0, F2 // 002a821e
DIVD F3, F5 // 035b85ee
NEGF F0, F1 // 401ab1ee
NEGD F4, F5 // 445bb1ee
ABSF F0, F1 // c01ab0ee
ABSD F4, F5 // c45bb0ee
SQRTF F0, F1 // c01ab1ee
SQRTD F4, F5 // c45bb1ee
MOVFD F0, F1 // c01ab7ee
MOVDF F4, F5 // c45bb7ee
LDREX (R8), R9 // 9f9f98e1
LDREXD (R11), R12 // 9fcfbbe1
STREX R3, (R4), R5 // STREX (R4), R3, R5 // 935f84e1
STREXD R8, (R9), g // STREXD (R9), R8, g // 98afa9e1
CMPF F8, F9 // c89ab4ee10faf1ee
CMPD.CS F4, F5 // c45bb42e10faf12e
CMPF.VS F7 // c07ab56e10faf16e
CMPD F6 // c06bb5ee10faf1ee
END