mirror of
https://github.com/golang/go
synced 2024-11-24 14:00:15 -07:00
0301c6c351
Use a small python script to consolidate duplicate ppc64/ppc64le tests into a single ppc64x codegen test. This makes small assumption that anytime two tests with for different arch/variant combos exists, those tests can be combined into a single ppc64x test. E.x: // ppc64le: foo // ppc64le/power9: foo into // ppc64x: foo or // ppc64: foo // ppc64le: foo into // ppc64x: foo import glob import re files = glob.glob("codegen/*.go") for file in files: with open(file) as f: text = [l for l in f] i = 0 while i < len(text): first = re.match("\s*// ?ppc64(le)?(/power[89])?:(.*)", text[i]) if first: j = i+1 while j < len(text): second = re.match("\s*// ?ppc64(le)?(/power[89])?:(.*)", text[j]) if not second: break if (not first.group(2) or first.group(2) == second.group(2)) and first.group(3) == second.group(3): text[i] = re.sub(" ?ppc64(le|x)?"," ppc64x",text[i]) text=text[:j] + (text[j+1:]) else: j += 1 i+=1 with open(file, 'w') as f: f.write("".join(text)) Change-Id: Ic6b009b54eacaadc5a23db9c5a3bf7331b595821 Reviewed-on: https://go-review.googlesource.com/c/go/+/463220 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Paul Murphy <murp@ibm.com> TryBot-Result: Gopher Robot <gobot@golang.org>
188 lines
3.7 KiB
Go
188 lines
3.7 KiB
Go
// asmcheck
|
|
|
|
// Copyright 2018 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package codegen
|
|
|
|
var sval64 [8]int64
|
|
var sval32 [8]int32
|
|
var sval16 [8]int16
|
|
var sval8 [8]int8
|
|
var val64 [8]uint64
|
|
var val32 [8]uint32
|
|
var val16 [8]uint16
|
|
var val8 [8]uint8
|
|
|
|
// Avoid zero/sign extensions following a load
|
|
// which has extended the value correctly.
|
|
// Note: No tests are done for int8 since
|
|
// an extra extension is usually needed due to
|
|
// no signed byte load.
|
|
|
|
func set16(x8 int8, u8 *uint8, y8 int8, z8 uint8) {
|
|
// Truncate not needed, load does sign/zero extend
|
|
|
|
// ppc64x:-"MOVBZ\tR\\d+,\\sR\\d+"
|
|
val16[0] = uint16(*u8)
|
|
|
|
// AND not needed due to size
|
|
// ppc64x:-"ANDCC"
|
|
sval16[1] = 255 & int16(x8+y8)
|
|
|
|
// ppc64x:-"ANDCC"
|
|
val16[1] = 255 & uint16(*u8+z8)
|
|
|
|
}
|
|
func shiftidx(u8 *uint8, x16 *int16, u16 *uint16) {
|
|
|
|
// ppc64x:-"MOVBZ\tR\\d+,\\sR\\d+"
|
|
val16[0] = uint16(sval16[*u8>>2])
|
|
|
|
// ppc64x:-"MOVH\tR\\d+,\\sR\\d+"
|
|
sval16[1] = int16(val16[*x16>>1])
|
|
|
|
// ppc64x:-"MOVHZ\tR\\d+,\\sR\\d+"
|
|
val16[1] = uint16(sval16[*u16>>2])
|
|
|
|
}
|
|
|
|
func setnox(x8 int8, u8 *uint8, y8 *int8, z8 *uint8, x16 *int16, u16 *uint16, x32 *int32, u32 *uint32) {
|
|
|
|
// ppc64x:-"MOVBZ\tR\\d+,\\sR\\d+"
|
|
val16[0] = uint16(*u8)
|
|
|
|
// AND not needed due to size
|
|
// ppc64x:-"ANDCC"
|
|
sval16[1] = 255 & int16(x8+*y8)
|
|
|
|
// ppc64x:-"ANDCC"
|
|
val16[1] = 255 & uint16(*u8+*z8)
|
|
|
|
// ppc64x:-"MOVH\tR\\d+,\\sR\\d+"
|
|
sval32[1] = int32(*x16)
|
|
|
|
// ppc64x:-"MOVBZ\tR\\d+,\\sR\\d+"
|
|
val32[0] = uint32(*u8)
|
|
|
|
// ppc64x:-"MOVHZ\tR\\d+,\\sR\\d+"
|
|
val32[1] = uint32(*u16)
|
|
|
|
// ppc64x:-"MOVH\tR\\d+,\\sR\\d+"
|
|
sval64[1] = int64(*x16)
|
|
|
|
// ppc64x:-"MOVW\tR\\d+,\\sR\\d+"
|
|
sval64[2] = int64(*x32)
|
|
|
|
// ppc64x:-"MOVBZ\tR\\d+,\\sR\\d+"
|
|
val64[0] = uint64(*u8)
|
|
|
|
// ppc64x:-"MOVHZ\tR\\d+,\\sR\\d+"
|
|
val64[1] = uint64(*u16)
|
|
|
|
// ppc64x:-"MOVWZ\tR\\d+,\\sR\\d+"
|
|
val64[2] = uint64(*u32)
|
|
}
|
|
|
|
func cmp16(u8 *uint8, x32 *int32, u32 *uint32, x64 *int64, u64 *uint64) bool {
|
|
|
|
// ppc64x:-"MOVBZ\tR\\d+,\\sR\\d+"
|
|
if uint16(*u8) == val16[0] {
|
|
return true
|
|
}
|
|
|
|
// ppc64x:-"MOVHZ\tR\\d+,\\sR\\d+"
|
|
if uint16(*u32>>16) == val16[0] {
|
|
return true
|
|
}
|
|
|
|
// ppc64x:-"MOVHZ\tR\\d+,\\sR\\d+"
|
|
if uint16(*u64>>48) == val16[0] {
|
|
return true
|
|
}
|
|
|
|
// Verify the truncates are using the correct sign.
|
|
// ppc64x:-"MOVHZ\tR\\d+,\\sR\\d+"
|
|
if int16(*x32) == sval16[0] {
|
|
return true
|
|
}
|
|
|
|
// ppc64x:-"MOVH\tR\\d+,\\sR\\d+"
|
|
if uint16(*u32) == val16[0] {
|
|
return true
|
|
}
|
|
|
|
// ppc64x:-"MOVHZ\tR\\d+,\\sR\\d+"
|
|
if int16(*x64) == sval16[0] {
|
|
return true
|
|
}
|
|
|
|
// ppc64x:-"MOVH\tR\\d+,\\sR\\d+"
|
|
if uint16(*u64) == val16[0] {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func cmp32(u8 *uint8, x16 *int16, u16 *uint16, x64 *int64, u64 *uint64) bool {
|
|
|
|
// ppc64x:-"MOVBZ\tR\\d+,\\sR\\d+"
|
|
if uint32(*u8) == val32[0] {
|
|
return true
|
|
}
|
|
|
|
// ppc64x:-"MOVH\tR\\d+,\\sR\\d+"
|
|
if int32(*x16) == sval32[0] {
|
|
return true
|
|
}
|
|
|
|
// ppc64x:-"MOVHZ\tR\\d+,\\sR\\d+"
|
|
if uint32(*u16) == val32[0] {
|
|
return true
|
|
}
|
|
|
|
// Verify the truncates are using the correct sign.
|
|
// ppc64x:-"MOVWZ\tR\\d+,\\sR\\d+"
|
|
if int32(*x64) == sval32[0] {
|
|
return true
|
|
}
|
|
|
|
// ppc64x:-"MOVW\tR\\d+,\\sR\\d+"
|
|
if uint32(*u64) == val32[0] {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func cmp64(u8 *uint8, x16 *int16, u16 *uint16, x32 *int32, u32 *uint32) bool {
|
|
|
|
// ppc64x:-"MOVBZ\tR\\d+,\\sR\\d+"
|
|
if uint64(*u8) == val64[0] {
|
|
return true
|
|
}
|
|
|
|
// ppc64x:-"MOVH\tR\\d+,\\sR\\d+"
|
|
if int64(*x16) == sval64[0] {
|
|
return true
|
|
}
|
|
|
|
// ppc64x:-"MOVHZ\tR\\d+,\\sR\\d+"
|
|
if uint64(*u16) == val64[0] {
|
|
return true
|
|
}
|
|
|
|
// ppc64x:-"MOVW\tR\\d+,\\sR\\d+"
|
|
if int64(*x32) == sval64[0] {
|
|
return true
|
|
}
|
|
|
|
// ppc64x:-"MOVWZ\tR\\d+,\\sR\\d+"
|
|
if uint64(*u32) == val64[0] {
|
|
return true
|
|
}
|
|
return false
|
|
}
|