mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: refactor static slice symbol creation
This change mostly moves code around to unify it. A subsequent change will simplify and improve slicesym. Passes toolstash-check. Change-Id: I84a877ea747febb2b571d4089ba6d905b51b27ec Reviewed-on: https://go-review.googlesource.com/c/go/+/227549 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
376472ddb7
commit
7096b1700d
2 changed files with 13 additions and 20 deletions
|
|
@ -417,6 +417,16 @@ func dsymptrWeakOff(s *obj.LSym, off int, x *obj.LSym) int {
|
|||
return off
|
||||
}
|
||||
|
||||
// slicesym writes a static slice symbol {&arr, lencap, lencap} to n.
|
||||
func slicesym(n, arr, lencap *Node) {
|
||||
base := n.Xoffset
|
||||
gdata(n, nod(OADDR, arr, nil), Widthptr)
|
||||
n.Xoffset = base + sliceLenOffset
|
||||
gdata(n, lencap, Widthptr)
|
||||
n.Xoffset = base + sliceCapOffset
|
||||
gdata(n, lencap, Widthptr)
|
||||
}
|
||||
|
||||
func gdata(nam *Node, nr *Node, wid int) {
|
||||
if nam.Op != ONAME {
|
||||
Fatalf("gdata nam op %v", nam.Op)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue