mirror of
https://github.com/golang/go
synced 2024-10-05 20:31:20 -06:00
[dev.ssa] cmd/compile/internal/gc: Implement ODOT and ODOTPTR in addr.
Change-Id: If8a9d5901fa2141d16b1c8d001761ea62bc23207 Reviewed-on: https://go-review.googlesource.com/12141 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
b06961b4f0
commit
c3c84a2544
@ -673,6 +673,7 @@ func (s *state) assign(op uint8, left *Node, right *Node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// addr converts the address of the expression n to SSA, adds it to s and returns the SSA result.
|
// addr converts the address of the expression n to SSA, adds it to s and returns the SSA result.
|
||||||
|
// The value that the returned Value represents is guaranteed to be non-nil.
|
||||||
func (s *state) addr(n *Node) *ssa.Value {
|
func (s *state) addr(n *Node) *ssa.Value {
|
||||||
switch n.Op {
|
switch n.Op {
|
||||||
case ONAME:
|
case ONAME:
|
||||||
@ -716,6 +717,13 @@ func (s *state) addr(n *Node) *ssa.Value {
|
|||||||
s.boundsCheck(i, len)
|
s.boundsCheck(i, len)
|
||||||
return s.newValue2(ssa.OpPtrIndex, Ptrto(n.Left.Type.Type), a, i)
|
return s.newValue2(ssa.OpPtrIndex, Ptrto(n.Left.Type.Type), a, i)
|
||||||
}
|
}
|
||||||
|
case ODOT:
|
||||||
|
p := s.addr(n.Left)
|
||||||
|
return s.newValue2(ssa.OpAdd, p.Type, p, s.constInt(s.config.Uintptr, n.Xoffset))
|
||||||
|
case ODOTPTR:
|
||||||
|
p := s.expr(n.Left)
|
||||||
|
s.nilCheck(p)
|
||||||
|
return s.newValue2(ssa.OpAdd, p.Type, p, s.constInt(s.config.Uintptr, n.Xoffset))
|
||||||
default:
|
default:
|
||||||
s.Unimplementedf("addr: bad op %v", Oconv(int(n.Op), 0))
|
s.Unimplementedf("addr: bad op %v", Oconv(int(n.Op), 0))
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user