]> Cypherpunks.ru repositories - gostls13.git/commitdiff
test/codegen: port math/bits.Leadingzero tests to codegen
authorAlberto Donizetti <alb.donizetti@gmail.com>
Mon, 5 Mar 2018 18:46:18 +0000 (19:46 +0100)
committerAlberto Donizetti <alb.donizetti@gmail.com>
Mon, 5 Mar 2018 19:52:04 +0000 (19:52 +0000)
Change-Id: Ic21d25db5d56ce77516c53082dfbc010e5875b81
Reviewed-on: https://go-review.googlesource.com/98655
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/asm_test.go
test/codegen/mathbits.go

index 025fa2b45c6c3887775beabf258cb22b5cdc7dd4..1e9bd20548fddc0d0ea675f1f3adcb0bb9578a12 100644 (file)
@@ -241,7 +241,7 @@ var allAsmTests = []*asmTests{
        {
                arch:    "arm",
                os:      "linux",
-               imports: []string{"math/bits", "runtime"},
+               imports: []string{"runtime"},
                tests:   linuxARMTests,
        },
        {
@@ -251,10 +251,9 @@ var allAsmTests = []*asmTests{
                tests:   linuxARM64Tests,
        },
        {
-               arch:    "mips",
-               os:      "linux",
-               imports: []string{"math/bits"},
-               tests:   linuxMIPSTests,
+               arch:  "mips",
+               os:    "linux",
+               tests: linuxMIPSTests,
        },
        {
                arch:  "mips64",
@@ -580,48 +579,6 @@ var linuxAMD64Tests = []*asmTest{
                `,
                pos: []string{"\tROLW\t\\$8,"},
        },
-       {
-               fn: `
-               func f53(a uint64) int {
-                       return bits.LeadingZeros64(a)
-               }
-               `,
-               pos: []string{"\tBSRQ\t"},
-       },
-       {
-               fn: `
-               func f54(a uint32) int {
-                       return bits.LeadingZeros32(a)
-               }
-               `,
-               pos: []string{"\tBSRQ\t"},
-       },
-       {
-               fn: `
-               func f55(a uint16) int {
-                       return bits.LeadingZeros16(a)
-               }
-               `,
-               pos: []string{"\tBSRQ\t"},
-       },
-       /* see ssa.go
-       {
-               fn:`
-               func f56(a uint8) int {
-                       return bits.LeadingZeros8(a)
-               }
-               `,
-               pos:[]string{"\tBSRQ\t"},
-       },
-       */
-       {
-               fn: `
-               func f57(a uint) int {
-                       return bits.LeadingZeros(a)
-               }
-               `,
-               pos: []string{"\tBSRQ\t"},
-       },
        {
                fn: `
                func pop1(x uint64) int {
@@ -1322,46 +1279,6 @@ var linuxS390XTests = []*asmTest{
                `,
                pos: []string{"\tMOVWBR\t"},
        },
-       {
-               fn: `
-               func f29(a uint64) int {
-                       return bits.LeadingZeros64(a)
-               }
-               `,
-               pos: []string{"\tFLOGR\t"},
-       },
-       {
-               fn: `
-               func f30(a uint32) int {
-                       return bits.LeadingZeros32(a)
-               }
-               `,
-               pos: []string{"\tFLOGR\t"},
-       },
-       {
-               fn: `
-               func f31(a uint16) int {
-                       return bits.LeadingZeros16(a)
-               }
-               `,
-               pos: []string{"\tFLOGR\t"},
-       },
-       {
-               fn: `
-               func f32(a uint8) int {
-                       return bits.LeadingZeros8(a)
-               }
-               `,
-               pos: []string{"\tFLOGR\t"},
-       },
-       {
-               fn: `
-               func f33(a uint) int {
-                       return bits.LeadingZeros(a)
-               }
-               `,
-               pos: []string{"\tFLOGR\t"},
-       },
        {
                // check that stack store is optimized away
                fn: `
@@ -1419,46 +1336,6 @@ var linuxARMTests = []*asmTest{
                `,
                pos: []string{"\tMOVW\tR[0-9]+@>25,"},
        },
-       {
-               fn: `
-               func f8(a uint64) int {
-                       return bits.LeadingZeros64(a)
-               }
-               `,
-               pos: []string{"\tCLZ\t"},
-       },
-       {
-               fn: `
-               func f9(a uint32) int {
-                       return bits.LeadingZeros32(a)
-               }
-               `,
-               pos: []string{"\tCLZ\t"},
-       },
-       {
-               fn: `
-               func f10(a uint16) int {
-                       return bits.LeadingZeros16(a)
-               }
-               `,
-               pos: []string{"\tCLZ\t"},
-       },
-       {
-               fn: `
-               func f11(a uint8) int {
-                       return bits.LeadingZeros8(a)
-               }
-               `,
-               pos: []string{"\tCLZ\t"},
-       },
-       {
-               fn: `
-               func f12(a uint) int {
-                       return bits.LeadingZeros(a)
-               }
-               `,
-               pos: []string{"\tCLZ\t"},
-       },
        {
                // make sure assembly output has matching offset and base register.
                fn: `
@@ -1593,46 +1470,6 @@ var linuxARM64Tests = []*asmTest{
                `,
                pos: []string{"\tREVW\t"},
        },
-       {
-               fn: `
-               func f29(a uint64) int {
-                       return bits.LeadingZeros64(a)
-               }
-               `,
-               pos: []string{"\tCLZ\t"},
-       },
-       {
-               fn: `
-               func f30(a uint32) int {
-                       return bits.LeadingZeros32(a)
-               }
-               `,
-               pos: []string{"\tCLZ\t"},
-       },
-       {
-               fn: `
-               func f31(a uint16) int {
-                       return bits.LeadingZeros16(a)
-               }
-               `,
-               pos: []string{"\tCLZ\t"},
-       },
-       {
-               fn: `
-               func f32(a uint8) int {
-                       return bits.LeadingZeros8(a)
-               }
-               `,
-               pos: []string{"\tCLZ\t"},
-       },
-       {
-               fn: `
-               func f33(a uint) int {
-                       return bits.LeadingZeros(a)
-               }
-               `,
-               pos: []string{"\tCLZ\t"},
-       },
        {
                fn: `
                func f34(a uint64) uint64 {
@@ -2014,47 +1851,6 @@ var linuxARM64Tests = []*asmTest{
 }
 
 var linuxMIPSTests = []*asmTest{
-       // Intrinsic tests for math/bits
-       {
-               fn: `
-               func f5(a uint64) int {
-                       return bits.LeadingZeros64(a)
-               }
-               `,
-               pos: []string{"\tCLZ\t"},
-       },
-       {
-               fn: `
-               func f6(a uint32) int {
-                       return bits.LeadingZeros32(a)
-               }
-               `,
-               pos: []string{"\tCLZ\t"},
-       },
-       {
-               fn: `
-               func f7(a uint16) int {
-                       return bits.LeadingZeros16(a)
-               }
-               `,
-               pos: []string{"\tCLZ\t"},
-       },
-       {
-               fn: `
-               func f8(a uint8) int {
-                       return bits.LeadingZeros8(a)
-               }
-               `,
-               pos: []string{"\tCLZ\t"},
-       },
-       {
-               fn: `
-               func f9(a uint) int {
-                       return bits.LeadingZeros(a)
-               }
-               `,
-               pos: []string{"\tCLZ\t"},
-       },
        {
                // check that stack store is optimized away
                fn: `
index 02552e1fdb1ea590d8b20e82edbc1dc74b736c85..98ee8f2a0b34f35e21de833f35e2502a517b22fe 100644 (file)
@@ -8,6 +8,50 @@ package codegen
 
 import "math/bits"
 
+// ----------------------- //
+//    bits.LeadingZeros    //
+// ----------------------- //
+
+func LeadingZeros(n uint) int {
+       //amd64:"BSRQ"
+       //s390x:"FLOGR"
+       //arm:"CLZ" arm64:"CLZ"
+       //mips:"CLZ"
+       return bits.LeadingZeros(n)
+}
+
+func LeadingZeros64(n uint64) int {
+       //amd64:"BSRQ"
+       //s390x:"FLOGR"
+       //arm:"CLZ" arm64:"CLZ"
+       //mips:"CLZ"
+       return bits.LeadingZeros64(n)
+}
+
+func LeadingZeros32(n uint32) int {
+       //amd64:"BSRQ"
+       //s390x:"FLOGR"
+       //arm:"CLZ" arm64:"CLZ"
+       //mips:"CLZ"
+       return bits.LeadingZeros32(n)
+}
+
+func LeadingZeros16(n uint16) int {
+       //amd64:"BSRQ"
+       //s390x:"FLOGR"
+       //arm:"CLZ" arm64:"CLZ"
+       //mips:"CLZ"
+       return bits.LeadingZeros16(n)
+}
+
+func LeadingZeros8(n uint8) int {
+       //amd64 LeadingZeros8 not intrinsified (see ssa.go)
+       //s390x:"FLOGR"
+       //arm:"CLZ" arm64:"CLZ"
+       //mips:"CLZ"
+       return bits.LeadingZeros8(n)
+}
+
 // --------------- //
 //    bits.Len*    //
 // --------------- //
@@ -45,7 +89,7 @@ func Len16(n uint16) int {
 }
 
 func Len8(n uint8) int {
-       //amd64 Len8 not intrisified
+       //amd64 Len8 not intrisified (see ssa.go)
        //s390x:"FLOGR"
        //arm:"CLZ" arm64:"CLZ"
        //mips:"CLZ"