{
arch: "amd64",
os: "linux",
- imports: []string{"math/bits", "unsafe", "runtime"},
+ imports: []string{"unsafe", "runtime"},
tests: linuxAMD64Tests,
},
{
tests: linux386Tests,
},
{
- arch: "s390x",
- os: "linux",
- imports: []string{"math/bits"},
- tests: linuxS390XTests,
+ arch: "s390x",
+ os: "linux",
+ tests: linuxS390XTests,
},
{
arch: "arm",
tests: linuxARMTests,
},
{
- arch: "arm64",
- os: "linux",
- imports: []string{"math/bits"},
- tests: linuxARM64Tests,
+ arch: "arm64",
+ os: "linux",
+ tests: linuxARM64Tests,
},
{
arch: "mips",
`,
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
{
fn: `
`,
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
fn: `
pos: []string{"\tORN\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: `
func f34(a uint64) uint64 {
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 //
// ------------------------ //