Commit 3b0efa68 authored by Keith Randall's avatar Keith Randall

cmd/compile: a rule's line number is at its ->

Let's define the line number of a multiline rule as the line
number on which the -> appears.  This helps make the rule
cover analysis look a bit nicer.

Change-Id: I4ac4c09f2240285976590ecfd416bc4c05e78946
Reviewed-on: https://go-review.googlesource.com/22473Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
parent 8d075bee
......@@ -91,6 +91,7 @@ func genRules(arch arch) {
scanner := bufio.NewScanner(text)
rule := ""
var lineno int
var ruleLineno int // line number of "->"
for scanner.Scan() {
lineno++
line := scanner.Text()
......@@ -107,6 +108,9 @@ func genRules(arch arch) {
if !strings.Contains(rule, "->") {
continue
}
if ruleLineno == 0 {
ruleLineno = lineno
}
if strings.HasSuffix(rule, "->") {
continue
}
......@@ -117,13 +121,14 @@ func genRules(arch arch) {
if op[len(op)-1] == ')' {
op = op[:len(op)-1] // rule has only opcode, e.g. (ConstNil) -> ...
}
loc := fmt.Sprintf("%s.rules:%d", arch.name, lineno)
loc := fmt.Sprintf("%s.rules:%d", arch.name, ruleLineno)
if isBlock(op, arch) {
blockrules[op] = append(blockrules[op], Rule{rule: rule, loc: loc})
} else {
oprules[op] = append(oprules[op], Rule{rule: rule, loc: loc})
}
rule = ""
ruleLineno = 0
}
if err := scanner.Err(); err != nil {
log.Fatalf("scanner failed: %v\n", err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment