Commit ba8a146a authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

[dev.ssa] cmd/compile/ssa: print reg names in generated code

Change-Id: I6c6196449dd3d5e036d420fa7ae90feb0cf8d417
Reviewed-on: https://go-review.googlesource.com/10928Reviewed-by: 's avatarKeith Randall <khr@golang.org>
parent e707fbe1
......@@ -175,5 +175,5 @@ func init() {
{name: "UGE"},
}
archs = append(archs, arch{"AMD64", AMD64ops, AMD64blocks})
archs = append(archs, arch{"AMD64", AMD64ops, AMD64blocks, regNamesAMD64})
}
......@@ -100,5 +100,5 @@ var genericBlocks = []blockData{
}
func init() {
archs = append(archs, arch{"generic", genericOps, genericBlocks})
archs = append(archs, arch{"generic", genericOps, genericBlocks, nil})
}
......@@ -19,6 +19,7 @@ type arch struct {
name string
ops []opData
blocks []blockData
regnames []string
}
type opData struct {
......@@ -38,6 +39,21 @@ type regInfo struct {
type regMask uint64
func (a arch) regMaskComment(r regMask) string {
var buf bytes.Buffer
for i := uint64(0); r != 0; i++ {
if r&1 != 0 {
if buf.Len() == 0 {
buf.WriteString(" //")
}
buf.WriteString(" ")
buf.WriteString(a.regnames[i])
}
r >>= 1
}
return buf.String()
}
var archs []arch
func main() {
......@@ -95,13 +111,13 @@ func genOp() {
fmt.Fprintln(w, "reg:regInfo{")
fmt.Fprintln(w, "inputs: []regMask{")
for _, r := range v.reg.inputs {
fmt.Fprintf(w, "%d,\n", r)
fmt.Fprintf(w, "%d,%s\n", r, a.regMaskComment(r))
}
fmt.Fprintln(w, "},")
fmt.Fprintf(w, "clobbers: %d,\n", v.reg.clobbers)
fmt.Fprintf(w, "clobbers: %d,%s\n", v.reg.clobbers, a.regMaskComment(v.reg.clobbers))
fmt.Fprintln(w, "outputs: []regMask{")
for _, r := range v.reg.outputs {
fmt.Fprintf(w, "%d,\n", r)
fmt.Fprintf(w, "%d,%s\n", r, a.regMaskComment(r))
}
fmt.Fprintln(w, "},")
fmt.Fprintln(w, "},")
......
This diff is collapsed.
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