Skip to content

Commit 915c183

Browse files
committed
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>
1 parent 32ee3f3 commit 915c183

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2035
-2032
lines changed

src/cmd/internal/testdir/testdir_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,7 @@ var (
14881488
// "\s*,\s*` matches " , "
14891489
// second reMatchCheck matches "`SUB`"
14901490
// ")*)" closes started groups; "*" means that there might be other elements in the comma-separated list
1491-
rxAsmPlatform = regexp.MustCompile(`(\w+)(/[\w.]+)?(/\w*)?\s*:\s*(` + reMatchCheck + `(?:\s*,\s*` + reMatchCheck + `)*)`)
1491+
rxAsmPlatform = regexp.MustCompile(`(\w+)(/[\w.]+)?(/\w*)?\s*:\s*(` + reMatchCheck + `(?:\s+` + reMatchCheck + `)*)`)
14921492

14931493
// Regexp to extract a single opcoded check
14941494
rxAsmCheck = regexp.MustCompile(reMatchCheck)
@@ -1701,6 +1701,9 @@ func (t test) asmCheck(outStr string, fn string, env buildEnv, fullops map[strin
17011701
}
17021702
srcFileLine, asm := matches[1], matches[2]
17031703

1704+
// Replace tabs with single spaces to make matches easier to write.
1705+
asm = strings.ReplaceAll(asm, "\t", " ")
1706+
17041707
// Associate the original file/line information to the current
17051708
// function in the output; it will be useful to dump it in case
17061709
// of error.
@@ -1752,11 +1755,11 @@ func (t test) asmCheck(outStr string, fn string, env buildEnv, fullops map[strin
17521755
}
17531756

17541757
if o.negative {
1755-
fmt.Fprintf(&errbuf, "%s:%d: %s: wrong opcode found: %q\n", t.goFileName(), o.line, env, o.opcode.String())
1758+
fmt.Fprintf(&errbuf, "%s:%d: %s: wrong opcode found: %#q\n", t.goFileName(), o.line, env, o.opcode.String())
17561759
} else if o.expected > 0 {
1757-
fmt.Fprintf(&errbuf, "%s:%d: %s: wrong number of opcodes: %q\n", t.goFileName(), o.line, env, o.opcode.String())
1760+
fmt.Fprintf(&errbuf, "%s:%d: %s: wrong number of opcodes: %#q\n", t.goFileName(), o.line, env, o.opcode.String())
17581761
} else {
1759-
fmt.Fprintf(&errbuf, "%s:%d: %s: opcode not found: %q\n", t.goFileName(), o.line, env, o.opcode.String())
1762+
fmt.Fprintf(&errbuf, "%s:%d: %s: opcode not found: %#q\n", t.goFileName(), o.line, env, o.opcode.String())
17601763
}
17611764
}
17621765
return errors.New(errbuf.String())

test/codegen/addrcalc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ package codegen
99
// Make sure we use ADDQ instead of LEAQ when we can.
1010

1111
func f(p *[4][2]int, x int) *int {
12-
// amd64:"ADDQ",-"LEAQ"
12+
// amd64:"ADDQ" -"LEAQ"
1313
return &p[x][0]
1414
}

test/codegen/alloc.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@
1010
package codegen
1111

1212
func zeroAllocNew1() *struct{} {
13-
// 386:-`CALL\truntime\.newobject`, `LEAL\truntime.zerobase`
14-
// amd64:-`CALL\truntime\.newobject`, `LEAQ\truntime.zerobase`
15-
// arm:-`CALL\truntime\.newobject`, `MOVW\t[$]runtime.zerobase`
16-
// arm64:-`CALL\truntime\.newobject`, `MOVD\t[$]runtime.zerobase`
17-
// riscv64:-`CALL\truntime\.newobject`, `MOV\t[$]runtime.zerobase`
13+
// 386:-`CALL runtime\.newobject`, `LEAL runtime.zerobase`
14+
// amd64:-`CALL runtime\.newobject`, `LEAQ runtime.zerobase`
15+
// arm:-`CALL runtime\.newobject`, `MOVW [$]runtime.zerobase`
16+
// arm64:-`CALL runtime\.newobject`, `MOVD [$]runtime.zerobase`
17+
// riscv64:-`CALL runtime\.newobject`, `MOV [$]runtime.zerobase`
1818
return new(struct{})
1919
}
2020

2121
func zeroAllocNew2() *[0]int {
22-
// 386:-`CALL\truntime\.newobject`, `LEAL\truntime.zerobase`
23-
// amd64:-`CALL\truntime\.newobject`, `LEAQ\truntime.zerobase`
24-
// arm:-`CALL\truntime\.newobject`, `MOVW\t[$]runtime.zerobase`
25-
// arm64:-`CALL\truntime\.newobject`, `MOVD\t[$]runtime.zerobase`
26-
// riscv64:-`CALL\truntime\.newobject`, `MOV\t[$]runtime.zerobase`
22+
// 386:-`CALL runtime\.newobject`, `LEAL runtime.zerobase`
23+
// amd64:-`CALL runtime\.newobject`, `LEAQ runtime.zerobase`
24+
// arm:-`CALL runtime\.newobject`, `MOVW [$]runtime.zerobase`
25+
// arm64:-`CALL runtime\.newobject`, `MOVD [$]runtime.zerobase`
26+
// riscv64:-`CALL runtime\.newobject`, `MOV [$]runtime.zerobase`
2727
return new([0]int)
2828
}
2929

3030
func zeroAllocSliceLit() []int {
31-
// 386:-`CALL\truntime\.newobject`, `LEAL\truntime.zerobase`
32-
// amd64:-`CALL\truntime\.newobject`, `LEAQ\truntime.zerobase`
33-
// arm:-`CALL\truntime\.newobject`, `MOVW\t[$]runtime.zerobase`
34-
// arm64:-`CALL\truntime\.newobject`, `MOVD\t[$]runtime.zerobase`
35-
// riscv64:-`CALL\truntime\.newobject`, `MOV\t[$]runtime.zerobase`
31+
// 386:-`CALL runtime\.newobject`, `LEAL runtime.zerobase`
32+
// amd64:-`CALL runtime\.newobject`, `LEAQ runtime.zerobase`
33+
// arm:-`CALL runtime\.newobject`, `MOVW [$]runtime.zerobase`
34+
// arm64:-`CALL runtime\.newobject`, `MOVD [$]runtime.zerobase`
35+
// riscv64:-`CALL runtime\.newobject`, `MOV [$]runtime.zerobase`
3636
return []int{}
3737
}

0 commit comments

Comments
 (0)