mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
test/codegen: simplify asmcheck pattern matching
Separate patterns in asmcheck by spaces instead of commas. Many patterns end in comma (like "MOV [$]123,") so separating patterns by comma is not great; they're already quoted, so spaces are fine. Also replace all tabs in the assembly lines with spaces before matching. Finally, replace \$ or \\$ with [$] as the matching idiom. The effect of all these is to make the patterns look like: // amd64:"BSFQ" "ORQ [$]256" instead of the old: // amd64:"BSFQ","ORQ\t\\$256" Update all tests as well. Change-Id: Ia39febe5d7f67ba115846422789e11b185d5c807 Reviewed-on: https://go-review.googlesource.com/c/go/+/716060 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
This commit is contained in:
parent
32ee3f3f73
commit
915c1839fe
48 changed files with 2035 additions and 2032 deletions
|
|
@ -13,15 +13,15 @@ import "math/bits"
|
|||
************************************/
|
||||
|
||||
func bitcheck64_constleft(a uint64) (n int) {
|
||||
// amd64:"BTQ\t[$]63"
|
||||
// amd64:"BTQ [$]63"
|
||||
if a&(1<<63) != 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTQ\t[$]60"
|
||||
// amd64:"BTQ [$]60"
|
||||
if a&(1<<60) != 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL\t[$]0"
|
||||
// amd64:"BTL [$]0"
|
||||
if a&(1<<0) != 0 {
|
||||
return 1
|
||||
}
|
||||
|
|
@ -29,31 +29,31 @@ func bitcheck64_constleft(a uint64) (n int) {
|
|||
}
|
||||
|
||||
func bitcheck64_constright(a [8]uint64) (n int) {
|
||||
// amd64:"BTQ\t[$]63"
|
||||
// amd64:"BTQ [$]63"
|
||||
if (a[0]>>63)&1 != 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTQ\t[$]63"
|
||||
// amd64:"BTQ [$]63"
|
||||
if a[1]>>63 != 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTQ\t[$]63"
|
||||
// amd64:"BTQ [$]63"
|
||||
if a[2]>>63 == 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTQ\t[$]60"
|
||||
// amd64:"BTQ [$]60"
|
||||
if (a[3]>>60)&1 == 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL\t[$]1"
|
||||
// amd64:"BTL [$]1"
|
||||
if (a[4]>>1)&1 == 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL\t[$]0"
|
||||
// amd64:"BTL [$]0"
|
||||
if (a[5]>>0)&1 == 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL\t[$]7"
|
||||
// amd64:"BTL [$]7"
|
||||
if (a[6]>>5)&4 == 0 {
|
||||
return 1
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ func bitcheck64_var(a, b uint64) (n int) {
|
|||
if a&(1<<(b&63)) != 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTQ",-"BT.\t[$]0"
|
||||
// amd64:"BTQ" -"BT. [$]0"
|
||||
if (b>>(a&63))&1 != 0 {
|
||||
return 1
|
||||
}
|
||||
|
|
@ -73,15 +73,15 @@ func bitcheck64_var(a, b uint64) (n int) {
|
|||
}
|
||||
|
||||
func bitcheck64_mask(a uint64) (n int) {
|
||||
// amd64:"BTQ\t[$]63"
|
||||
// amd64:"BTQ [$]63"
|
||||
if a&0x8000000000000000 != 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTQ\t[$]59"
|
||||
// amd64:"BTQ [$]59"
|
||||
if a&0x800000000000000 != 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL\t[$]0"
|
||||
// amd64:"BTL [$]0"
|
||||
if a&0x1 != 0 {
|
||||
return 1
|
||||
}
|
||||
|
|
@ -92,13 +92,13 @@ func biton64(a, b uint64) (n uint64) {
|
|||
// amd64:"BTSQ"
|
||||
n += b | (1 << (a & 63))
|
||||
|
||||
// amd64:"BTSQ\t[$]63"
|
||||
// amd64:"BTSQ [$]63"
|
||||
n += a | (1 << 63)
|
||||
|
||||
// amd64:"BTSQ\t[$]60"
|
||||
// amd64:"BTSQ [$]60"
|
||||
n += a | (1 << 60)
|
||||
|
||||
// amd64:"ORQ\t[$]1"
|
||||
// amd64:"ORQ [$]1"
|
||||
n += a | (1 << 0)
|
||||
|
||||
return n
|
||||
|
|
@ -108,23 +108,23 @@ func bitoff64(a, b uint64) (n uint64) {
|
|||
// amd64:"BTRQ"
|
||||
n += b &^ (1 << (a & 63))
|
||||
|
||||
// amd64:"BTRQ\t[$]63"
|
||||
// amd64:"BTRQ [$]63"
|
||||
n += a &^ (1 << 63)
|
||||
|
||||
// amd64:"BTRQ\t[$]60"
|
||||
// amd64:"BTRQ [$]60"
|
||||
n += a &^ (1 << 60)
|
||||
|
||||
// amd64:"ANDQ\t[$]-2"
|
||||
// amd64:"ANDQ [$]-2"
|
||||
n += a &^ (1 << 0)
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
func clearLastBit(x int64, y int32) (int64, int32) {
|
||||
// amd64:"ANDQ\t[$]-2"
|
||||
// amd64:"ANDQ [$]-2"
|
||||
a := (x >> 1) << 1
|
||||
|
||||
// amd64:"ANDL\t[$]-2"
|
||||
// amd64:"ANDL [$]-2"
|
||||
b := (y >> 1) << 1
|
||||
|
||||
return a, b
|
||||
|
|
@ -134,13 +134,13 @@ func bitcompl64(a, b uint64) (n uint64) {
|
|||
// amd64:"BTCQ"
|
||||
n += b ^ (1 << (a & 63))
|
||||
|
||||
// amd64:"BTCQ\t[$]63"
|
||||
// amd64:"BTCQ [$]63"
|
||||
n += a ^ (1 << 63)
|
||||
|
||||
// amd64:"BTCQ\t[$]60"
|
||||
// amd64:"BTCQ [$]60"
|
||||
n += a ^ (1 << 60)
|
||||
|
||||
// amd64:"XORQ\t[$]1"
|
||||
// amd64:"XORQ [$]1"
|
||||
n += a ^ (1 << 0)
|
||||
|
||||
return n
|
||||
|
|
@ -151,15 +151,15 @@ func bitcompl64(a, b uint64) (n uint64) {
|
|||
************************************/
|
||||
|
||||
func bitcheck32_constleft(a uint32) (n int) {
|
||||
// amd64:"BTL\t[$]31"
|
||||
// amd64:"BTL [$]31"
|
||||
if a&(1<<31) != 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL\t[$]28"
|
||||
// amd64:"BTL [$]28"
|
||||
if a&(1<<28) != 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL\t[$]0"
|
||||
// amd64:"BTL [$]0"
|
||||
if a&(1<<0) != 0 {
|
||||
return 1
|
||||
}
|
||||
|
|
@ -167,31 +167,31 @@ func bitcheck32_constleft(a uint32) (n int) {
|
|||
}
|
||||
|
||||
func bitcheck32_constright(a [8]uint32) (n int) {
|
||||
// amd64:"BTL\t[$]31"
|
||||
// amd64:"BTL [$]31"
|
||||
if (a[0]>>31)&1 != 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL\t[$]31"
|
||||
// amd64:"BTL [$]31"
|
||||
if a[1]>>31 != 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL\t[$]31"
|
||||
// amd64:"BTL [$]31"
|
||||
if a[2]>>31 == 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL\t[$]28"
|
||||
// amd64:"BTL [$]28"
|
||||
if (a[3]>>28)&1 == 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL\t[$]1"
|
||||
// amd64:"BTL [$]1"
|
||||
if (a[4]>>1)&1 == 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL\t[$]0"
|
||||
// amd64:"BTL [$]0"
|
||||
if (a[5]>>0)&1 == 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL\t[$]7"
|
||||
// amd64:"BTL [$]7"
|
||||
if (a[6]>>5)&4 == 0 {
|
||||
return 1
|
||||
}
|
||||
|
|
@ -203,7 +203,7 @@ func bitcheck32_var(a, b uint32) (n int) {
|
|||
if a&(1<<(b&31)) != 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL",-"BT.\t[$]0"
|
||||
// amd64:"BTL" -"BT. [$]0"
|
||||
if (b>>(a&31))&1 != 0 {
|
||||
return 1
|
||||
}
|
||||
|
|
@ -211,15 +211,15 @@ func bitcheck32_var(a, b uint32) (n int) {
|
|||
}
|
||||
|
||||
func bitcheck32_mask(a uint32) (n int) {
|
||||
// amd64:"BTL\t[$]31"
|
||||
// amd64:"BTL [$]31"
|
||||
if a&0x80000000 != 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL\t[$]27"
|
||||
// amd64:"BTL [$]27"
|
||||
if a&0x8000000 != 0 {
|
||||
return 1
|
||||
}
|
||||
// amd64:"BTL\t[$]0"
|
||||
// amd64:"BTL [$]0"
|
||||
if a&0x1 != 0 {
|
||||
return 1
|
||||
}
|
||||
|
|
@ -230,13 +230,13 @@ func biton32(a, b uint32) (n uint32) {
|
|||
// amd64:"BTSL"
|
||||
n += b | (1 << (a & 31))
|
||||
|
||||
// amd64:"ORL\t[$]-2147483648"
|
||||
// amd64:"ORL [$]-2147483648"
|
||||
n += a | (1 << 31)
|
||||
|
||||
// amd64:"ORL\t[$]268435456"
|
||||
// amd64:"ORL [$]268435456"
|
||||
n += a | (1 << 28)
|
||||
|
||||
// amd64:"ORL\t[$]1"
|
||||
// amd64:"ORL [$]1"
|
||||
n += a | (1 << 0)
|
||||
|
||||
return n
|
||||
|
|
@ -246,13 +246,13 @@ func bitoff32(a, b uint32) (n uint32) {
|
|||
// amd64:"BTRL"
|
||||
n += b &^ (1 << (a & 31))
|
||||
|
||||
// amd64:"ANDL\t[$]2147483647"
|
||||
// amd64:"ANDL [$]2147483647"
|
||||
n += a &^ (1 << 31)
|
||||
|
||||
// amd64:"ANDL\t[$]-268435457"
|
||||
// amd64:"ANDL [$]-268435457"
|
||||
n += a &^ (1 << 28)
|
||||
|
||||
// amd64:"ANDL\t[$]-2"
|
||||
// amd64:"ANDL [$]-2"
|
||||
n += a &^ (1 << 0)
|
||||
|
||||
return n
|
||||
|
|
@ -262,13 +262,13 @@ func bitcompl32(a, b uint32) (n uint32) {
|
|||
// amd64:"BTCL"
|
||||
n += b ^ (1 << (a & 31))
|
||||
|
||||
// amd64:"XORL\t[$]-2147483648"
|
||||
// amd64:"XORL [$]-2147483648"
|
||||
n += a ^ (1 << 31)
|
||||
|
||||
// amd64:"XORL\t[$]268435456"
|
||||
// amd64:"XORL [$]268435456"
|
||||
n += a ^ (1 << 28)
|
||||
|
||||
// amd64:"XORL\t[$]1"
|
||||
// amd64:"XORL [$]1"
|
||||
n += a ^ (1 << 0)
|
||||
|
||||
return n
|
||||
|
|
@ -292,12 +292,12 @@ func bitcheckMostNegative(b uint8) bool {
|
|||
// Check AND masking on arm64 (Issue #19857)
|
||||
|
||||
func and_mask_1(a uint64) uint64 {
|
||||
// arm64:`AND\t`
|
||||
// arm64:`AND `
|
||||
return a & ((1 << 63) - 1)
|
||||
}
|
||||
|
||||
func and_mask_2(a uint64) uint64 {
|
||||
// arm64:`AND\t`
|
||||
// arm64:`AND `
|
||||
return a & (1 << 63)
|
||||
}
|
||||
|
||||
|
|
@ -312,65 +312,65 @@ func and_mask_3(a, b uint32) (uint32, uint32) {
|
|||
// Check generation of arm64 BIC/EON/ORN instructions
|
||||
|
||||
func op_bic(x, y uint32) uint32 {
|
||||
// arm64:`BIC\t`,-`AND`
|
||||
// arm64:`BIC `,-`AND`
|
||||
return x &^ y
|
||||
}
|
||||
|
||||
func op_eon(x, y, z uint32, a []uint32, n, m uint64) uint64 {
|
||||
// arm64:`EON\t`,-`EOR`,-`MVN`
|
||||
// arm64:`EON `,-`EOR`,-`MVN`
|
||||
a[0] = x ^ (y ^ 0xffffffff)
|
||||
|
||||
// arm64:`EON\t`,-`EOR`,-`MVN`
|
||||
// arm64:`EON `,-`EOR`,-`MVN`
|
||||
a[1] = ^(y ^ z)
|
||||
|
||||
// arm64:`EON\t`,-`XOR`
|
||||
// arm64:`EON `,-`XOR`
|
||||
a[2] = x ^ ^z
|
||||
|
||||
// arm64:`EON\t`,-`EOR`,-`MVN`
|
||||
// arm64:`EON `,-`EOR`,-`MVN`
|
||||
return n ^ (m ^ 0xffffffffffffffff)
|
||||
}
|
||||
|
||||
func op_orn(x, y uint32) uint32 {
|
||||
// arm64:`ORN\t`,-`ORR`
|
||||
// loong64:"ORN"\t,-"OR\t"
|
||||
// arm64:`ORN `,-`ORR`
|
||||
// loong64:"ORN" ,-"OR "
|
||||
return x | ^y
|
||||
}
|
||||
|
||||
func op_nor(x int64, a []int64) {
|
||||
// loong64: "MOVV\t[$]0","NOR\tR"
|
||||
// loong64: "MOVV [$]0" "NOR R"
|
||||
a[0] = ^(0x1234 | x)
|
||||
// loong64:"NOR",-"XOR"
|
||||
// loong64:"NOR" -"XOR"
|
||||
a[1] = (-1) ^ x
|
||||
// loong64: "MOVV\t[$]-55",-"OR",-"NOR"
|
||||
// loong64: "MOVV [$]-55" -"OR" -"NOR"
|
||||
a[2] = ^(0x12 | 0x34)
|
||||
}
|
||||
|
||||
func op_andn(x, y uint32) uint32 {
|
||||
// loong64:"ANDN\t",-"AND\t"
|
||||
// loong64:"ANDN " -"AND "
|
||||
return x &^ y
|
||||
}
|
||||
|
||||
// check bitsets
|
||||
func bitSetPowerOf2Test(x int) bool {
|
||||
// amd64:"BTL\t[$]3"
|
||||
// amd64:"BTL [$]3"
|
||||
return x&8 == 8
|
||||
}
|
||||
|
||||
func bitSetTest(x int) bool {
|
||||
// amd64:"ANDL\t[$]9, AX"
|
||||
// amd64:"CMPQ\tAX, [$]9"
|
||||
// amd64:"ANDL [$]9, AX"
|
||||
// amd64:"CMPQ AX, [$]9"
|
||||
return x&9 == 9
|
||||
}
|
||||
|
||||
// mask contiguous one bits
|
||||
func cont1Mask64U(x uint64) uint64 {
|
||||
// s390x:"RISBGZ\t[$]16, [$]47, [$]0,"
|
||||
// s390x:"RISBGZ [$]16, [$]47, [$]0,"
|
||||
return x & 0x0000ffffffff0000
|
||||
}
|
||||
|
||||
// mask contiguous zero bits
|
||||
func cont0Mask64U(x uint64) uint64 {
|
||||
// s390x:"RISBGZ\t[$]48, [$]15, [$]0,"
|
||||
// s390x:"RISBGZ [$]48, [$]15, [$]0,"
|
||||
return x & 0xffff00000000ffff
|
||||
}
|
||||
|
||||
|
|
@ -390,60 +390,60 @@ func issue48467(x, y uint64) uint64 {
|
|||
}
|
||||
|
||||
func foldConst(x, y uint64) uint64 {
|
||||
// arm64: "ADDS\t[$]7",-"MOVD\t[$]7"
|
||||
// ppc64x: "ADDC\t[$]7,"
|
||||
// arm64: "ADDS [$]7" -"MOVD [$]7"
|
||||
// ppc64x: "ADDC [$]7,"
|
||||
d, b := bits.Add64(x, 7, 0)
|
||||
return b & d
|
||||
}
|
||||
|
||||
func foldConstOutOfRange(a uint64) uint64 {
|
||||
// arm64: "MOVD\t[$]19088744",-"ADD\t[$]19088744"
|
||||
// arm64: "MOVD [$]19088744" -"ADD [$]19088744"
|
||||
return a + 0x1234568
|
||||
}
|
||||
|
||||
// Verify sign-extended values are not zero-extended under a bit mask (#61297)
|
||||
func signextendAndMask8to64(a int8) (s, z uint64) {
|
||||
// ppc64x: "MOVB", "ANDCC\t[$]1015,"
|
||||
// ppc64x: "MOVB", "ANDCC [$]1015,"
|
||||
s = uint64(a) & 0x3F7
|
||||
// ppc64x: -"MOVB", "ANDCC\t[$]247,"
|
||||
// ppc64x: -"MOVB", "ANDCC [$]247,"
|
||||
z = uint64(uint8(a)) & 0x3F7
|
||||
return
|
||||
}
|
||||
|
||||
// Verify zero-extended values are not sign-extended under a bit mask (#61297)
|
||||
func zeroextendAndMask8to64(a int8, b int16) (x, y uint64) {
|
||||
// ppc64x: -"MOVB\t", -"ANDCC", "MOVBZ"
|
||||
// ppc64x: -"MOVB ", -"ANDCC", "MOVBZ"
|
||||
x = uint64(a) & 0xFF
|
||||
// ppc64x: -"MOVH\t", -"ANDCC", "MOVHZ"
|
||||
// ppc64x: -"MOVH ", -"ANDCC", "MOVHZ"
|
||||
y = uint64(b) & 0xFFFF
|
||||
return
|
||||
}
|
||||
|
||||
// Verify rotate and mask instructions, and further simplified instructions for small types
|
||||
func bitRotateAndMask(io64 [8]uint64, io32 [4]uint32, io16 [4]uint16, io8 [4]uint8) {
|
||||
// ppc64x: "RLDICR\t[$]0, R[0-9]*, [$]47, R"
|
||||
// ppc64x: "RLDICR [$]0, R[0-9]*, [$]47, R"
|
||||
io64[0] = io64[0] & 0xFFFFFFFFFFFF0000
|
||||
// ppc64x: "RLDICL\t[$]0, R[0-9]*, [$]16, R"
|
||||
// ppc64x: "RLDICL [$]0, R[0-9]*, [$]16, R"
|
||||
io64[1] = io64[1] & 0x0000FFFFFFFFFFFF
|
||||
// ppc64x: -"SRD", -"AND", "RLDICL\t[$]60, R[0-9]*, [$]16, R"
|
||||
// ppc64x: -"SRD", -"AND", "RLDICL [$]60, R[0-9]*, [$]16, R"
|
||||
io64[2] = (io64[2] >> 4) & 0x0000FFFFFFFFFFFF
|
||||
// ppc64x: -"SRD", -"AND", "RLDICL\t[$]36, R[0-9]*, [$]28, R"
|
||||
// ppc64x: -"SRD", -"AND", "RLDICL [$]36, R[0-9]*, [$]28, R"
|
||||
io64[3] = (io64[3] >> 28) & 0x0000FFFFFFFFFFFF
|
||||
|
||||
// ppc64x: "MOVWZ", "RLWNM\t[$]1, R[0-9]*, [$]28, [$]3, R"
|
||||
// ppc64x: "MOVWZ", "RLWNM [$]1, R[0-9]*, [$]28, [$]3, R"
|
||||
io64[4] = uint64(bits.RotateLeft32(io32[0], 1) & 0xF000000F)
|
||||
|
||||
// ppc64x: "RLWNM\t[$]0, R[0-9]*, [$]4, [$]19, R"
|
||||
// ppc64x: "RLWNM [$]0, R[0-9]*, [$]4, [$]19, R"
|
||||
io32[0] = io32[0] & 0x0FFFF000
|
||||
// ppc64x: "RLWNM\t[$]0, R[0-9]*, [$]20, [$]3, R"
|
||||
// ppc64x: "RLWNM [$]0, R[0-9]*, [$]20, [$]3, R"
|
||||
io32[1] = io32[1] & 0xF0000FFF
|
||||
// ppc64x: -"RLWNM", MOVD, AND
|
||||
io32[2] = io32[2] & 0xFFFF0002
|
||||
|
||||
var bigc uint32 = 0x12345678
|
||||
// ppc64x: "ANDCC\t[$]22136"
|
||||
// ppc64x: "ANDCC [$]22136"
|
||||
io16[0] = io16[0] & uint16(bigc)
|
||||
|
||||
// ppc64x: "ANDCC\t[$]120"
|
||||
// ppc64x: "ANDCC [$]120"
|
||||
io8[0] = io8[0] & uint8(bigc)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue