Commit 5e1b7bde authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

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: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 7735dfb6
......@@ -2066,6 +2066,16 @@ func (s *state) expr(n *Node) *ssa.Value {
return s.newValue1(ssa.OpGetG, n.Type, s.mem())
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:
// ptr,len,cap := s
// newlen := len + 3
......@@ -2158,11 +2168,6 @@ func (s *state) expr(n *Node) *ssa.Value {
delete(s.vars, &ptrVar)
delete(s.vars, &capVar)
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
......
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