mirror of
https://github.com/golang/go
synced 2024-11-26 15:46:54 -07:00
[dev.regabi] cmd/compile: replace ir.Node with *ir.Name in Order
Passes buildall w/ toolstash -cmp. Updates #42982 Change-Id: I7121c37f72ccbc141a7dd17fba1753f2c6289908 Reviewed-on: https://go-review.googlesource.com/c/go/+/275353 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
b75f51c645
commit
46b6e70e3b
@ -45,8 +45,8 @@ import (
|
|||||||
// Order holds state during the ordering process.
|
// Order holds state during the ordering process.
|
||||||
type Order struct {
|
type Order struct {
|
||||||
out []ir.Node // list of generated statements
|
out []ir.Node // list of generated statements
|
||||||
temp []ir.Node // stack of temporary variables
|
temp []*ir.Name // stack of temporary variables
|
||||||
free map[string][]ir.Node // free list of unused temporaries, by type.LongString().
|
free map[string][]*ir.Name // free list of unused temporaries, by type.LongString().
|
||||||
}
|
}
|
||||||
|
|
||||||
// Order rewrites fn.Nbody to apply the ordering constraints
|
// Order rewrites fn.Nbody to apply the ordering constraints
|
||||||
@ -57,14 +57,14 @@ func order(fn *ir.Func) {
|
|||||||
ir.DumpList(s, fn.Body())
|
ir.DumpList(s, fn.Body())
|
||||||
}
|
}
|
||||||
|
|
||||||
orderBlock(fn.PtrBody(), map[string][]ir.Node{})
|
orderBlock(fn.PtrBody(), map[string][]*ir.Name{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// newTemp allocates a new temporary with the given type,
|
// newTemp allocates a new temporary with the given type,
|
||||||
// pushes it onto the temp stack, and returns it.
|
// pushes it onto the temp stack, and returns it.
|
||||||
// If clear is true, newTemp emits code to zero the temporary.
|
// If clear is true, newTemp emits code to zero the temporary.
|
||||||
func (o *Order) newTemp(t *types.Type, clear bool) ir.Node {
|
func (o *Order) newTemp(t *types.Type, clear bool) ir.Node {
|
||||||
var v ir.Node
|
var v *ir.Name
|
||||||
// Note: LongString is close to the type equality we want,
|
// Note: LongString is close to the type equality we want,
|
||||||
// but not exactly. We still need to double-check with types.Identical.
|
// but not exactly. We still need to double-check with types.Identical.
|
||||||
key := t.LongString()
|
key := t.LongString()
|
||||||
@ -415,7 +415,7 @@ func (o *Order) edge() {
|
|||||||
// orderBlock orders the block of statements in n into a new slice,
|
// orderBlock orders the block of statements in n into a new slice,
|
||||||
// and then replaces the old slice in n with the new slice.
|
// and then replaces the old slice in n with the new slice.
|
||||||
// free is a map that can be used to obtain temporary variables by type.
|
// free is a map that can be used to obtain temporary variables by type.
|
||||||
func orderBlock(n *ir.Nodes, free map[string][]ir.Node) {
|
func orderBlock(n *ir.Nodes, free map[string][]*ir.Name) {
|
||||||
var order Order
|
var order Order
|
||||||
order.free = free
|
order.free = free
|
||||||
mark := order.markTemp()
|
mark := order.markTemp()
|
||||||
@ -446,7 +446,7 @@ func (o *Order) exprInPlace(n ir.Node) ir.Node {
|
|||||||
// The result of orderStmtInPlace MUST be assigned back to n, e.g.
|
// The result of orderStmtInPlace MUST be assigned back to n, e.g.
|
||||||
// n.Left = orderStmtInPlace(n.Left)
|
// n.Left = orderStmtInPlace(n.Left)
|
||||||
// free is a map that can be used to obtain temporary variables by type.
|
// free is a map that can be used to obtain temporary variables by type.
|
||||||
func orderStmtInPlace(n ir.Node, free map[string][]ir.Node) ir.Node {
|
func orderStmtInPlace(n ir.Node, free map[string][]*ir.Name) ir.Node {
|
||||||
var order Order
|
var order Order
|
||||||
order.free = free
|
order.free = free
|
||||||
mark := order.markTemp()
|
mark := order.markTemp()
|
||||||
|
@ -579,7 +579,7 @@ func fixedlit(ctxt initContext, kind initKind, n ir.Node, var_ ir.Node, init *ir
|
|||||||
case initKindStatic:
|
case initKindStatic:
|
||||||
genAsStatic(a)
|
genAsStatic(a)
|
||||||
case initKindDynamic, initKindLocalCode:
|
case initKindDynamic, initKindLocalCode:
|
||||||
a = orderStmtInPlace(a, map[string][]ir.Node{})
|
a = orderStmtInPlace(a, map[string][]*ir.Name{})
|
||||||
a = walkstmt(a)
|
a = walkstmt(a)
|
||||||
init.Append(a)
|
init.Append(a)
|
||||||
default:
|
default:
|
||||||
@ -747,7 +747,7 @@ func slicelit(ctxt initContext, n ir.Node, var_ ir.Node, init *ir.Nodes) {
|
|||||||
a = ir.Nod(ir.OAS, a, value)
|
a = ir.Nod(ir.OAS, a, value)
|
||||||
|
|
||||||
a = typecheck(a, ctxStmt)
|
a = typecheck(a, ctxStmt)
|
||||||
a = orderStmtInPlace(a, map[string][]ir.Node{})
|
a = orderStmtInPlace(a, map[string][]*ir.Name{})
|
||||||
a = walkstmt(a)
|
a = walkstmt(a)
|
||||||
init.Append(a)
|
init.Append(a)
|
||||||
}
|
}
|
||||||
@ -756,7 +756,7 @@ func slicelit(ctxt initContext, n ir.Node, var_ ir.Node, init *ir.Nodes) {
|
|||||||
a = ir.Nod(ir.OAS, var_, ir.Nod(ir.OSLICE, vauto, nil))
|
a = ir.Nod(ir.OAS, var_, ir.Nod(ir.OSLICE, vauto, nil))
|
||||||
|
|
||||||
a = typecheck(a, ctxStmt)
|
a = typecheck(a, ctxStmt)
|
||||||
a = orderStmtInPlace(a, map[string][]ir.Node{})
|
a = orderStmtInPlace(a, map[string][]*ir.Name{})
|
||||||
a = walkstmt(a)
|
a = walkstmt(a)
|
||||||
init.Append(a)
|
init.Append(a)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user