Commit 8516ecd0 authored by Alberto Donizetti's avatar Alberto Donizetti

test/codegen: port math/bits.ReverseBytes tests to codegen

And remove them from ssa_test.

Change-Id: If767af662801219774d1bdb787c77edfa6067770
Reviewed-on: https://go-review.googlesource.com/98976
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarGiovanni Bajo <rasky@develer.com>
parent 05962561
...@@ -224,7 +224,7 @@ var allAsmTests = []*asmTests{ ...@@ -224,7 +224,7 @@ var allAsmTests = []*asmTests{
{ {
arch: "amd64", arch: "amd64",
os: "linux", os: "linux",
imports: []string{"math/bits", "unsafe", "runtime"}, imports: []string{"unsafe", "runtime"},
tests: linuxAMD64Tests, tests: linuxAMD64Tests,
}, },
{ {
...@@ -233,10 +233,9 @@ var allAsmTests = []*asmTests{ ...@@ -233,10 +233,9 @@ var allAsmTests = []*asmTests{
tests: linux386Tests, tests: linux386Tests,
}, },
{ {
arch: "s390x", arch: "s390x",
os: "linux", os: "linux",
imports: []string{"math/bits"}, tests: linuxS390XTests,
tests: linuxS390XTests,
}, },
{ {
arch: "arm", arch: "arm",
...@@ -245,10 +244,9 @@ var allAsmTests = []*asmTests{ ...@@ -245,10 +244,9 @@ var allAsmTests = []*asmTests{
tests: linuxARMTests, tests: linuxARMTests,
}, },
{ {
arch: "arm64", arch: "arm64",
os: "linux", os: "linux",
imports: []string{"math/bits"}, tests: linuxARM64Tests,
tests: linuxARM64Tests,
}, },
{ {
arch: "mips", arch: "mips",
...@@ -522,31 +520,6 @@ var linuxAMD64Tests = []*asmTest{ ...@@ -522,31 +520,6 @@ var linuxAMD64Tests = []*asmTest{
`, `,
pos: []string{"\tBTQ\t\\$60"}, pos: []string{"\tBTQ\t\\$60"},
}, },
// Intrinsic tests for math/bits
{
fn: `
func f45(a uint64) uint64 {
return bits.ReverseBytes64(a)
}
`,
pos: []string{"\tBSWAPQ\t"},
},
{
fn: `
func f46(a uint32) uint32 {
return bits.ReverseBytes32(a)
}
`,
pos: []string{"\tBSWAPL\t"},
},
{
fn: `
func f47(a uint16) uint16 {
return bits.ReverseBytes16(a)
}
`,
pos: []string{"\tROLW\t\\$8,"},
},
// multiplication merging tests // multiplication merging tests
{ {
fn: ` fn: `
...@@ -1169,23 +1142,6 @@ var linuxS390XTests = []*asmTest{ ...@@ -1169,23 +1142,6 @@ var linuxS390XTests = []*asmTest{
`, `,
pos: []string{"\tFMSUBS\t"}, pos: []string{"\tFMSUBS\t"},
}, },
// Intrinsic tests for math/bits
{
fn: `
func f22(a uint64) uint64 {
return bits.ReverseBytes64(a)
}
`,
pos: []string{"\tMOVDBR\t"},
},
{
fn: `
func f23(a uint32) uint32 {
return bits.ReverseBytes32(a)
}
`,
pos: []string{"\tMOVWBR\t"},
},
{ {
// check that stack store is optimized away // check that stack store is optimized away
fn: ` fn: `
...@@ -1361,22 +1317,6 @@ var linuxARM64Tests = []*asmTest{ ...@@ -1361,22 +1317,6 @@ var linuxARM64Tests = []*asmTest{
pos: []string{"\tORN\t"}, pos: []string{"\tORN\t"},
neg: []string{"\tORR\t"}, neg: []string{"\tORR\t"},
}, },
{
fn: `
func f22(a uint64) uint64 {
return bits.ReverseBytes64(a)
}
`,
pos: []string{"\tREV\t"},
},
{
fn: `
func f23(a uint32) uint32 {
return bits.ReverseBytes32(a)
}
`,
pos: []string{"\tREVW\t"},
},
{ {
fn: ` fn: `
func f34(a uint64) uint64 { func f34(a uint64) uint64 {
......
...@@ -124,6 +124,36 @@ func OnesCount16(n uint16) int { ...@@ -124,6 +124,36 @@ func OnesCount16(n uint16) int {
return bits.OnesCount16(n) return bits.OnesCount16(n)
} }
// ----------------------- //
// bits.ReverseBytes //
// ----------------------- //
func ReverseBytes(n uint) uint {
//amd64:"BSWAPQ"
//s390x:"MOVDBR"
//arm64:"REV"
return bits.ReverseBytes(n)
}
func ReverseBytes64(n uint64) uint64 {
//amd64:"BSWAPQ"
//s390x:"MOVDBR"
//arm64:"REV"
return bits.ReverseBytes64(n)
}
func ReverseBytes32(n uint32) uint32 {
//amd64:"BSWAPL"
//s390x:"MOVWBR"
//arm64:"REVW"
return bits.ReverseBytes32(n)
}
func ReverseBytes16(n uint16) uint16 {
//amd64:"ROLW"
return bits.ReverseBytes16(n)
}
// ------------------------ // // ------------------------ //
// bits.TrailingZeros // // bits.TrailingZeros //
// ------------------------ // // ------------------------ //
......
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