tests: linuxARMTests,
},
{
- arch: "arm64",
- os: "linux",
- tests: linuxARM64Tests,
+ arch: "arm64",
+ os: "linux",
+ imports: []string{"math/bits"},
+ tests: linuxARM64Tests,
},
}
`,
[]string{"\tBSFQ\t", "\tORQ\t\\$256,"},
},
+ {
+ `
+ func f45(a uint64) uint64 {
+ return bits.ReverseBytes64(a)
+ }
+ `,
+ []string{"\tBSWAPQ\t"},
+ },
+ {
+ `
+ func f46(a uint32) uint32 {
+ return bits.ReverseBytes32(a)
+ }
+ `,
+ []string{"\tBSWAPL\t"},
+ },
+ {
+ `
+ func f47(a uint16) uint16 {
+ return bits.ReverseBytes16(a)
+ }
+ `,
+ []string{"\tROLW\t\\$8,"},
+ },
}
var linux386Tests = []*asmTest{
`,
[]string{"\tFLOGR\t", "\tOR\t\\$256,"},
},
+ // Intrinsic tests for math/bits
+ {
+ `
+ func f22(a uint64) uint64 {
+ return bits.ReverseBytes64(a)
+ }
+ `,
+ []string{"\tMOVDBR\t"},
+ },
+ {
+ `
+ func f23(a uint32) uint32 {
+ return bits.ReverseBytes32(a)
+ }
+ `,
+ []string{"\tMOVWBR\t"},
+ },
}
var linuxARMTests = []*asmTest{
`,
[]string{"\tRORW\t[$]25,"},
},
+ {
+ `
+ func f22(a uint64) uint64 {
+ return bits.ReverseBytes64(a)
+ }
+ `,
+ []string{"\tREV\t"},
+ },
+ {
+ `
+ func f23(a uint32) uint32 {
+ return bits.ReverseBytes32(a)
+ }
+ `,
+ []string{"\tREVW\t"},
+ },
}
// TestLineNumber checks to make sure the generated assembly has line numbers
return s.newValue1(ssa.OpCtz64, Types[TINT], y)
},
sys.AMD64, sys.ARM64, sys.S390X)
+ alias("math/bits", "ReverseBytes64", "runtime/internal/sys", "Bswap64", all...)
+ alias("math/bits", "ReverseBytes32", "runtime/internal/sys", "Bswap32", all...)
+ // ReverseBytes inlines correctly, no need to intrinsify it.
+ // ReverseBytes16 lowers to a rotate, no need for anything special here.
/******** sync/atomic ********/