aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Donizetti <alb.donizetti@gmail.com>2018-03-02 15:16:27 +0100
committerAlberto Donizetti <alb.donizetti@gmail.com>2018-03-05 18:01:19 +0000
commitc1806906d89ecc65136be4bbdfb9020c797be46c (patch)
tree60b513607d53d3e421163ab1525f00cb46a1b844
parent63bcabed498a53a24da51ca1264b338c1149be07 (diff)
downloadgo-c1806906d89ecc65136be4bbdfb9020c797be46c.tar.xz
test: port bits.Len intrinsics tests to the new codegen harness
This change move bits.Len* intrinsification tests to the new codegen test harness, removing them from the old ssa_test file. Five different test functions (one for each bit.Len function tested) was used, to avoid possible unwanted interactions between multiple calls inside one function. Change-Id: Iffd5be55b58e88597fa30a562a28dacb01236d8b Reviewed-on: https://go-review.googlesource.com/98156 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Giovanni Bajo <rasky@develer.com>
-rw-r--r--src/cmd/compile/internal/gc/asm_test.go202
-rw-r--r--test/codegen/mathbits.go53
2 files changed, 53 insertions, 202 deletions
diff --git a/src/cmd/compile/internal/gc/asm_test.go b/src/cmd/compile/internal/gc/asm_test.go
index 88c8df2c77..025fa2b45c 100644
--- a/src/cmd/compile/internal/gc/asm_test.go
+++ b/src/cmd/compile/internal/gc/asm_test.go
@@ -582,48 +582,6 @@ var linuxAMD64Tests = []*asmTest{
},
{
fn: `
- func f48(a uint64) int {
- return bits.Len64(a)
- }
- `,
- pos: []string{"\tBSRQ\t"},
- },
- {
- fn: `
- func f49(a uint32) int {
- return bits.Len32(a)
- }
- `,
- pos: []string{"\tBSRQ\t"},
- },
- {
- fn: `
- func f50(a uint16) int {
- return bits.Len16(a)
- }
- `,
- pos: []string{"\tBSRQ\t"},
- },
- /* see ssa.go
- {
- fn:`
- func f51(a uint8) int {
- return bits.Len8(a)
- }
- `,
- pos:[]string{"\tBSRQ\t"},
- },
- */
- {
- fn: `
- func f52(a uint) int {
- return bits.Len(a)
- }
- `,
- pos: []string{"\tBSRQ\t"},
- },
- {
- fn: `
func f53(a uint64) int {
return bits.LeadingZeros64(a)
}
@@ -1366,46 +1324,6 @@ var linuxS390XTests = []*asmTest{
},
{
fn: `
- func f24(a uint64) int {
- return bits.Len64(a)
- }
- `,
- pos: []string{"\tFLOGR\t"},
- },
- {
- fn: `
- func f25(a uint32) int {
- return bits.Len32(a)
- }
- `,
- pos: []string{"\tFLOGR\t"},
- },
- {
- fn: `
- func f26(a uint16) int {
- return bits.Len16(a)
- }
- `,
- pos: []string{"\tFLOGR\t"},
- },
- {
- fn: `
- func f27(a uint8) int {
- return bits.Len8(a)
- }
- `,
- pos: []string{"\tFLOGR\t"},
- },
- {
- fn: `
- func f28(a uint) int {
- return bits.Len(a)
- }
- `,
- pos: []string{"\tFLOGR\t"},
- },
- {
- fn: `
func f29(a uint64) int {
return bits.LeadingZeros64(a)
}
@@ -1503,46 +1421,6 @@ var linuxARMTests = []*asmTest{
},
{
fn: `
- func f3(a uint64) int {
- return bits.Len64(a)
- }
- `,
- pos: []string{"\tCLZ\t"},
- },
- {
- fn: `
- func f4(a uint32) int {
- return bits.Len32(a)
- }
- `,
- pos: []string{"\tCLZ\t"},
- },
- {
- fn: `
- func f5(a uint16) int {
- return bits.Len16(a)
- }
- `,
- pos: []string{"\tCLZ\t"},
- },
- {
- fn: `
- func f6(a uint8) int {
- return bits.Len8(a)
- }
- `,
- pos: []string{"\tCLZ\t"},
- },
- {
- fn: `
- func f7(a uint) int {
- return bits.Len(a)
- }
- `,
- pos: []string{"\tCLZ\t"},
- },
- {
- fn: `
func f8(a uint64) int {
return bits.LeadingZeros64(a)
}
@@ -1717,46 +1595,6 @@ var linuxARM64Tests = []*asmTest{
},
{
fn: `
- func f24(a uint64) int {
- return bits.Len64(a)
- }
- `,
- pos: []string{"\tCLZ\t"},
- },
- {
- fn: `
- func f25(a uint32) int {
- return bits.Len32(a)
- }
- `,
- pos: []string{"\tCLZ\t"},
- },
- {
- fn: `
- func f26(a uint16) int {
- return bits.Len16(a)
- }
- `,
- pos: []string{"\tCLZ\t"},
- },
- {
- fn: `
- func f27(a uint8) int {
- return bits.Len8(a)
- }
- `,
- pos: []string{"\tCLZ\t"},
- },
- {
- fn: `
- func f28(a uint) int {
- return bits.Len(a)
- }
- `,
- pos: []string{"\tCLZ\t"},
- },
- {
- fn: `
func f29(a uint64) int {
return bits.LeadingZeros64(a)
}
@@ -2179,46 +2017,6 @@ var linuxMIPSTests = []*asmTest{
// Intrinsic tests for math/bits
{
fn: `
- func f0(a uint64) int {
- return bits.Len64(a)
- }
- `,
- pos: []string{"\tCLZ\t"},
- },
- {
- fn: `
- func f1(a uint32) int {
- return bits.Len32(a)
- }
- `,
- pos: []string{"\tCLZ\t"},
- },
- {
- fn: `
- func f2(a uint16) int {
- return bits.Len16(a)
- }
- `,
- pos: []string{"\tCLZ\t"},
- },
- {
- fn: `
- func f3(a uint8) int {
- return bits.Len8(a)
- }
- `,
- pos: []string{"\tCLZ\t"},
- },
- {
- fn: `
- func f4(a uint) int {
- return bits.Len(a)
- }
- `,
- pos: []string{"\tCLZ\t"},
- },
- {
- fn: `
func f5(a uint64) int {
return bits.LeadingZeros64(a)
}
diff --git a/test/codegen/mathbits.go b/test/codegen/mathbits.go
new file mode 100644
index 0000000000..02552e1fdb
--- /dev/null
+++ b/test/codegen/mathbits.go
@@ -0,0 +1,53 @@
+// asmcheck
+
+// Copyright 2018 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.
+
+package codegen
+
+import "math/bits"
+
+// --------------- //
+// bits.Len* //
+// --------------- //
+
+func Len(n uint) int {
+ //amd64:"BSRQ"
+ //s390x:"FLOGR"
+ //arm:"CLZ" arm64:"CLZ"
+ //mips:"CLZ"
+ return bits.Len(n)
+}
+
+func Len64(n uint64) int {
+ //amd64:"BSRQ"
+ //s390x:"FLOGR"
+ //arm:"CLZ" arm64:"CLZ"
+ //mips:"CLZ"
+ return bits.Len64(n)
+}
+
+func Len32(n uint32) int {
+ //amd64:"BSRQ"
+ //s390x:"FLOGR"
+ //arm:"CLZ" arm64:"CLZ"
+ //mips:"CLZ"
+ return bits.Len32(n)
+}
+
+func Len16(n uint16) int {
+ //amd64:"BSRQ"
+ //s390x:"FLOGR"
+ //arm:"CLZ" arm64:"CLZ"
+ //mips:"CLZ"
+ return bits.Len16(n)
+}
+
+func Len8(n uint8) int {
+ //amd64 Len8 not intrisified
+ //s390x:"FLOGR"
+ //arm:"CLZ" arm64:"CLZ"
+ //mips:"CLZ"
+ return bits.Len8(n)
+}