mirror of
https://github.com/golang/go
synced 2024-11-19 07:14:45 -07:00
cmd/compile: pull ssa OAPPEND expression handing into its own function
Pure code movement. Change-Id: Ia07ee0b0041c931b08adf090f262a6f74a6fdb01 Reviewed-on: https://go-review.googlesource.com/21546 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
7735dfb67c
commit
5e1b7bdecf
@ -2066,6 +2066,16 @@ func (s *state) expr(n *Node) *ssa.Value {
|
|||||||
return s.newValue1(ssa.OpGetG, n.Type, s.mem())
|
return s.newValue1(ssa.OpGetG, n.Type, s.mem())
|
||||||
|
|
||||||
case OAPPEND:
|
case OAPPEND:
|
||||||
|
return s.exprAppend(n)
|
||||||
|
|
||||||
|
default:
|
||||||
|
s.Unimplementedf("unhandled expr %s", opnames[n.Op])
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// exprAppend converts an OAPPEND node n to an ssa.Value, adds it to s, and returns the Value.
|
||||||
|
func (s *state) exprAppend(n *Node) *ssa.Value {
|
||||||
// append(s, e1, e2, e3). Compile like:
|
// append(s, e1, e2, e3). Compile like:
|
||||||
// ptr,len,cap := s
|
// ptr,len,cap := s
|
||||||
// newlen := len + 3
|
// newlen := len + 3
|
||||||
@ -2158,11 +2168,6 @@ func (s *state) expr(n *Node) *ssa.Value {
|
|||||||
delete(s.vars, &ptrVar)
|
delete(s.vars, &ptrVar)
|
||||||
delete(s.vars, &capVar)
|
delete(s.vars, &capVar)
|
||||||
return s.newValue3(ssa.OpSliceMake, n.Type, p, nl, c)
|
return s.newValue3(ssa.OpSliceMake, n.Type, p, nl, c)
|
||||||
|
|
||||||
default:
|
|
||||||
s.Unimplementedf("unhandled expr %s", opnames[n.Op])
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// condBranch evaluates the boolean expression cond and branches to yes
|
// condBranch evaluates the boolean expression cond and branches to yes
|
||||||
|
Loading…
Reference in New Issue
Block a user