1
0
mirror of https://github.com/golang/go synced 2024-11-19 22:44:45 -07:00

cmd/compile/internal/ssa: use *obj.LSym in ExternSymbol

Change-Id: I713120f90fd1d2df6698c40622ccac6eae907919
Reviewed-on: https://go-review.googlesource.com/36423
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
Matthew Dempsky 2017-02-06 18:18:49 -08:00
parent 1a7582f5e9
commit 8cf1766930
3 changed files with 10 additions and 17 deletions

View File

@ -660,7 +660,6 @@ var knownFormats = map[string]string{
"float64 %.3f": "", "float64 %.3f": "",
"float64 %.6g": "", "float64 %.6g": "",
"float64 %g": "", "float64 %g": "",
"fmt.Stringer %T": "",
"int %-12d": "", "int %-12d": "",
"int %-6d": "", "int %-6d": "",
"int %-8o": "", "int %-8o": "",

View File

@ -1433,12 +1433,12 @@ func (s *state) expr(n *Node) *ssa.Value {
len := s.newValue1(ssa.OpStringLen, Types[TINT], str) len := s.newValue1(ssa.OpStringLen, Types[TINT], str)
return s.newValue3(ssa.OpSliceMake, n.Type, ptr, len, len) return s.newValue3(ssa.OpSliceMake, n.Type, ptr, len, len)
case OCFUNC: case OCFUNC:
aux := s.lookupSymbol(n, &ssa.ExternSymbol{Typ: n.Type, Sym: n.Left.Sym}) aux := s.lookupSymbol(n, &ssa.ExternSymbol{Typ: n.Type, Sym: Linksym(n.Left.Sym)})
return s.entryNewValue1A(ssa.OpAddr, n.Type, aux, s.sb) return s.entryNewValue1A(ssa.OpAddr, n.Type, aux, s.sb)
case ONAME: case ONAME:
if n.Class == PFUNC { if n.Class == PFUNC {
// "value" of a function is the address of the function's closure // "value" of a function is the address of the function's closure
sym := funcsym(n.Sym) sym := Linksym(funcsym(n.Sym))
aux := &ssa.ExternSymbol{Typ: n.Type, Sym: sym} aux := &ssa.ExternSymbol{Typ: n.Type, Sym: sym}
return s.entryNewValue1A(ssa.OpAddr, ptrto(n.Type), aux, s.sb) return s.entryNewValue1A(ssa.OpAddr, ptrto(n.Type), aux, s.sb)
} }
@ -2187,7 +2187,7 @@ func (s *state) append(n *Node, inplace bool) *ssa.Value {
// Call growslice // Call growslice
s.startBlock(grow) s.startBlock(grow)
taddr := s.newValue1A(ssa.OpAddr, Types[TUINTPTR], &ssa.ExternSymbol{Typ: Types[TUINTPTR], Sym: typenamesym(n.Type.Elem())}, s.sb) taddr := s.newValue1A(ssa.OpAddr, Types[TUINTPTR], &ssa.ExternSymbol{Typ: Types[TUINTPTR], Sym: Linksym(typenamesym(n.Type.Elem()))}, s.sb)
r := s.rtcall(growslice, true, []*Type{pt, Types[TINT], Types[TINT]}, taddr, p, l, c, nl) r := s.rtcall(growslice, true, []*Type{pt, Types[TINT], Types[TINT]}, taddr, p, l, c, nl)
@ -3071,7 +3071,7 @@ func (s *state) addr(n *Node, bounded bool) (*ssa.Value, bool) {
switch n.Class { switch n.Class {
case PEXTERN: case PEXTERN:
// global variable // global variable
aux := s.lookupSymbol(n, &ssa.ExternSymbol{Typ: n.Type, Sym: n.Sym}) aux := s.lookupSymbol(n, &ssa.ExternSymbol{Typ: n.Type, Sym: Linksym(n.Sym)})
v := s.entryNewValue1A(ssa.OpAddr, t, aux, s.sb) v := s.entryNewValue1A(ssa.OpAddr, t, aux, s.sb)
// TODO: Make OpAddr use AuxInt as well as Aux. // TODO: Make OpAddr use AuxInt as well as Aux.
if n.Xoffset != 0 { if n.Xoffset != 0 {
@ -3427,7 +3427,7 @@ func (s *state) insertWBmove(t *Type, left, right *ssa.Value, line src.XPos, rig
} }
val = s.newValue3I(op, ssa.TypeMem, sizeAlignAuxInt(t), left, right, s.mem()) val = s.newValue3I(op, ssa.TypeMem, sizeAlignAuxInt(t), left, right, s.mem())
} }
val.Aux = &ssa.ExternSymbol{Typ: Types[TUINTPTR], Sym: typenamesym(t)} val.Aux = &ssa.ExternSymbol{Typ: Types[TUINTPTR], Sym: Linksym(typenamesym(t))}
s.vars[&memVar] = val s.vars[&memVar] = val
// WB ops will be expanded to branches at writebarrier phase. // WB ops will be expanded to branches at writebarrier phase.
@ -4168,7 +4168,7 @@ func (s *state) dottype(n *Node, commaok bool) (res, resok *ssa.Value) {
if !commaok { if !commaok {
// on failure, panic by calling panicdottype // on failure, panic by calling panicdottype
s.startBlock(bFail) s.startBlock(bFail)
taddr := s.newValue1A(ssa.OpAddr, byteptr, &ssa.ExternSymbol{Typ: byteptr, Sym: typenamesym(n.Left.Type)}, s.sb) taddr := s.newValue1A(ssa.OpAddr, byteptr, &ssa.ExternSymbol{Typ: byteptr, Sym: Linksym(typenamesym(n.Left.Type))}, s.sb)
s.rtcall(panicdottype, false, nil, typ, target, taddr) s.rtcall(panicdottype, false, nil, typ, target, taddr)
// on success, return data from interface // on success, return data from interface
@ -4569,14 +4569,7 @@ func AddAux2(a *obj.Addr, v *ssa.Value, offset int64) {
switch sym := v.Aux.(type) { switch sym := v.Aux.(type) {
case *ssa.ExternSymbol: case *ssa.ExternSymbol:
a.Name = obj.NAME_EXTERN a.Name = obj.NAME_EXTERN
switch s := sym.Sym.(type) { a.Sym = sym.Sym
case *Sym:
a.Sym = Linksym(s)
case *obj.LSym:
a.Sym = s
default:
v.Fatalf("ExternSymbol.Sym is %T", s)
}
case *ssa.ArgSymbol: case *ssa.ArgSymbol:
n := sym.Node.(*Node) n := sym.Node.(*Node)
a.Name = obj.NAME_PARAM a.Name = obj.NAME_PARAM

View File

@ -5,6 +5,7 @@
package ssa package ssa
import ( import (
"cmd/internal/obj"
"cmd/internal/src" "cmd/internal/src"
"fmt" "fmt"
"math" "math"
@ -244,8 +245,8 @@ func (v *Value) isGenericIntConst() bool {
// ExternSymbol is an aux value that encodes a variable's // ExternSymbol is an aux value that encodes a variable's
// constant offset from the static base pointer. // constant offset from the static base pointer.
type ExternSymbol struct { type ExternSymbol struct {
Typ Type // Go type Typ Type // Go type
Sym fmt.Stringer // A *gc.Sym referring to a global variable Sym *obj.LSym
// Note: the offset for an external symbol is not // Note: the offset for an external symbol is not
// calculated until link time. // calculated until link time.
} }