go/test/codegen/rotate.go
Giovanni Bajo c9438cb198 test: add support for code generation tests (asmcheck)
The top-level test harness is modified to support a new kind
of test: "asmcheck". This is meant to replace asm_test.go
as an easier and more readable way to test code generation.

I've added a couple of codegen tests to get initial feedback
on the syntax. I've created them under a common "codegen"
subdirectory, so that it's easier to run them all with
"go run run.go -v codegen".

The asmcheck syntax allows to insert line comments that
can specify a regular expression to match in the assembly code,
for multiple architectures (the testsuite will automatically
build each testfile multiple times, one per mentioned architecture).

Negative matches are unsupported for now, so this cannot fully
replace asm_test yet.

Change-Id: Ifdbba389f01d55e63e73c99e5f5449e642101d55
Reviewed-on: https://go-review.googlesource.com/97355
Run-TryBot: Giovanni Bajo <rasky@develer.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
2018-03-01 07:59:54 +00:00

26 lines
506 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 {
return math.Copysign(a, b)
}