mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.regabi] cmd/compile: clean up in preparation for expression Nodes
Using expression nodes restricts the set of valid SetOp operations, because you can't SetOp across representation. Rewrite various code to avoid crossing those as-yet-unintroduced boundaries. This also includes choosing a single representation for any given Op. For example, OCLOSE starts out as an OCALL, so it starts with a List of one node and then moves that node to Left. That's no good with real data structures, so the code picks a single canonical implementation and prepares it during the conversion from one Op to the next. In this case, the conversion of an OCALL to an OCLOSE now creates a new node with Left initialized from the start. This pattern repeats. Passes buildall w/ toolstash -cmp. Change-Id: I55a0872c614d883cac9d64976c46aeeaa639e25d Reviewed-on: https://go-review.googlesource.com/c/go/+/274107 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
5fc192af56
commit
b7f67b75d2
4 changed files with 85 additions and 117 deletions
|
|
@ -686,8 +686,7 @@ func slicelit(ctxt initContext, n ir.Node, var_ ir.Node, init *ir.Nodes) {
|
|||
|
||||
a = ir.Nod(ir.OADDR, a, nil)
|
||||
} else {
|
||||
a = ir.Nod(ir.ONEW, nil, nil)
|
||||
a.PtrList().Set1(ir.TypeNode(t))
|
||||
a = ir.Nod(ir.ONEW, ir.TypeNode(t), nil)
|
||||
}
|
||||
|
||||
a = ir.Nod(ir.OAS, vauto, a)
|
||||
|
|
@ -889,9 +888,8 @@ func anylit(n ir.Node, var_ ir.Node, init *ir.Nodes) {
|
|||
r = ir.Nod(ir.OADDR, n.Right(), nil)
|
||||
r = typecheck(r, ctxExpr)
|
||||
} else {
|
||||
r = ir.Nod(ir.ONEW, nil, nil)
|
||||
r.SetTypecheck(1)
|
||||
r.SetType(t)
|
||||
r = ir.Nod(ir.ONEW, ir.TypeNode(n.Left().Type()), nil)
|
||||
r = typecheck(r, ctxExpr)
|
||||
r.SetEsc(n.Esc())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue