1
0
mirror of https://github.com/golang/go synced 2024-11-24 04:00:13 -07:00
go/test/codegen/rotate.go
Giovanni Bajo 879a1ff1e4 test: improve asmcheck syntax
asmcheck comments now support a compact form of specifying
multiple checks for each platform, using the following syntax:

   amd64:"SHL\t[$]4","SHR\t[$]4"

Negative checks are also parsed using the following syntax:

   amd64:-"ROR"

though they are still not working.

Moreover, out-of-line comments have been implemented. This
allows to specify asmchecks on comment-only lines, that will
be matched on the first subsequent non-comment non-empty line.

    // amd64:"XOR"
    // arm:"EOR"

    x ^= 1

Change-Id: I110c7462fc6a5c70fd4af0d42f516016ae7f2760
Reviewed-on: https://go-review.googlesource.com/97816
Reviewed-by: Keith Randall <khr@golang.org>
2018-03-01 18:10:48 +00:00

28 lines
619 B
Go

// asmcheck
package codegen
import "math"
func rot32(x uint32) uint32 {
var a uint32
a += x<<7 | x>>25 // amd64:"ROLL.*[$]7" arm:"MOVW.*@>25"
a += x<<8 + x>>24 // amd64:`ROLL.*\$8` arm:"MOVW.*@>24"
a += x<<9 ^ x>>23 // amd64:"ROLL.*\\$9" arm:"MOVW.*@>23"
return a
}
func rot64(x uint64) uint64 {
var a uint64
a += x<<7 | x>>57 // amd64:"ROL"
a += x<<8 + x>>56 // amd64:"ROL"
a += x<<9 ^ x>>55 // amd64:"ROL"
return a
}
func copysign(a, b float64) float64 {
// amd64:"SHLQ\t[$]1","SHRQ\t[$]1","SHRQ\t[$]63","SHLQ\t[$]63","ORQ"
// ppc64le:"FCPSGN" s390x:"CPSDR",-"MOVD"
return math.Copysign(a, b)
}