Commit 87c475c2 authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile/internal/ssa: use obj.LSym instead of gc.Sym

Gc's Sym type represents a package-qualified identifier, which is a
frontend concept and doesn't belong in SSA. Bonus: we can replace some
interface{} types with *obj.LSym.

Passes toolstash -cmp.

Change-Id: I456eb9957207d80f99f6eb9b8eab4a1f3263e9ed
Reviewed-on: https://go-review.googlesource.com/36415
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
parent c2bc727f
......@@ -737,7 +737,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
q.To.Reg = r
}
case ssa.OpAMD64CALLstatic:
if v.Aux.(*gc.Sym) == gc.Deferreturn.Sym {
if v.Aux.(*obj.LSym) == gc.Linksym(gc.Deferreturn.Sym) {
// Deferred calls will appear to be returning to
// the CALL deferreturn(SB) that we are about to emit.
// However, the stack trace code will show the line
......@@ -751,7 +751,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p := gc.Prog(obj.ACALL)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(v.Aux.(*gc.Sym))
p.To.Sym = v.Aux.(*obj.LSym)
if gc.Maxarg < v.AuxInt {
gc.Maxarg = v.AuxInt
}
......@@ -996,7 +996,7 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
p := gc.Prog(obj.AJMP)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(b.Aux.(*gc.Sym))
p.To.Sym = b.Aux.(*obj.LSym)
case ssa.BlockAMD64EQF:
gc.SSAGenFPJump(s, b, next, &eqfJumps)
......
......@@ -635,7 +635,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p.To.Type = obj.TYPE_REG
p.To.Reg = v.Reg()
case ssa.OpARMCALLstatic:
if v.Aux.(*gc.Sym) == gc.Deferreturn.Sym {
if v.Aux.(*obj.LSym) == gc.Linksym(gc.Deferreturn.Sym) {
// Deferred calls will appear to be returning to
// the CALL deferreturn(SB) that we are about to emit.
// However, the stack trace code will show the line
......@@ -649,7 +649,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p := gc.Prog(obj.ACALL)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(v.Aux.(*gc.Sym))
p.To.Sym = v.Aux.(*obj.LSym)
if gc.Maxarg < v.AuxInt {
gc.Maxarg = v.AuxInt
}
......@@ -898,7 +898,7 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
p := gc.Prog(obj.ARET)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(b.Aux.(*gc.Sym))
p.To.Sym = b.Aux.(*obj.LSym)
case ssa.BlockARMEQ, ssa.BlockARMNE,
ssa.BlockARMLT, ssa.BlockARMGE,
......
......@@ -632,7 +632,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p4.To.Type = obj.TYPE_BRANCH
gc.Patch(p4, p)
case ssa.OpARM64CALLstatic:
if v.Aux.(*gc.Sym) == gc.Deferreturn.Sym {
if v.Aux.(*obj.LSym) == gc.Linksym(gc.Deferreturn.Sym) {
// Deferred calls will appear to be returning to
// the CALL deferreturn(SB) that we are about to emit.
// However, the stack trace code will show the line
......@@ -646,7 +646,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p := gc.Prog(obj.ACALL)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(v.Aux.(*gc.Sym))
p.To.Sym = v.Aux.(*obj.LSym)
if gc.Maxarg < v.AuxInt {
gc.Maxarg = v.AuxInt
}
......@@ -805,7 +805,7 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
p := gc.Prog(obj.ARET)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(b.Aux.(*gc.Sym))
p.To.Sym = b.Aux.(*obj.LSym)
case ssa.BlockARM64EQ, ssa.BlockARM64NE,
ssa.BlockARM64LT, ssa.BlockARM64GE,
......
......@@ -794,7 +794,7 @@ func (s *state) stmt(n *Node) {
s.stmtList(n.List)
b := s.exit()
b.Kind = ssa.BlockRetJmp // override BlockRet
b.Aux = n.Left.Sym
b.Aux = Linksym(n.Left.Sym)
case OCONTINUE, OBREAK:
var op string
......@@ -3004,7 +3004,7 @@ func (s *state) call(n *Node, k callKind) *ssa.Value {
case codeptr != nil:
call = s.newValue2(ssa.OpInterCall, ssa.TypeMem, codeptr, s.mem())
case sym != nil:
call = s.newValue1A(ssa.OpStaticCall, ssa.TypeMem, sym, s.mem())
call = s.newValue1A(ssa.OpStaticCall, ssa.TypeMem, Linksym(sym), s.mem())
default:
Fatalf("bad call type %v %v", n.Op, n)
}
......@@ -3365,7 +3365,7 @@ func (s *state) rtcall(fn *Node, returns bool, results []*Type, args ...*ssa.Val
}
// Issue call
call := s.newValue1A(ssa.OpStaticCall, ssa.TypeMem, fn.Sym, s.mem())
call := s.newValue1A(ssa.OpStaticCall, ssa.TypeMem, Linksym(fn.Sym), s.mem())
s.vars[&memVar] = call
if !returns {
......@@ -4981,8 +4981,8 @@ func (e *ssaExport) Debug_wb() bool {
return Debug_wb != 0
}
func (e *ssaExport) Syslook(name string) interface{} {
return syslook(name).Sym
func (e *ssaExport) Syslook(name string) *obj.LSym {
return Linksym(syslook(name).Sym)
}
func (n *Node) Typ() ssa.Type {
......
......@@ -487,7 +487,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p6.To.Type = obj.TYPE_BRANCH
gc.Patch(p6, p2)
case ssa.OpMIPSCALLstatic:
if v.Aux.(*gc.Sym) == gc.Deferreturn.Sym {
if v.Aux.(*obj.LSym) == gc.Linksym(gc.Deferreturn.Sym) {
// Deferred calls will appear to be returning to
// the CALL deferreturn(SB) that we are about to emit.
// However, the stack trace code will show the line
......@@ -501,7 +501,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p := gc.Prog(obj.ACALL)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(v.Aux.(*gc.Sym))
p.To.Sym = v.Aux.(*obj.LSym)
if gc.Maxarg < v.AuxInt {
gc.Maxarg = v.AuxInt
}
......@@ -873,7 +873,7 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
p := gc.Prog(obj.ARET)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(b.Aux.(*gc.Sym))
p.To.Sym = b.Aux.(*obj.LSym)
case ssa.BlockMIPSEQ, ssa.BlockMIPSNE,
ssa.BlockMIPSLTZ, ssa.BlockMIPSGEZ,
ssa.BlockMIPSLEZ, ssa.BlockMIPSGTZ,
......
......@@ -490,7 +490,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p6.To.Type = obj.TYPE_BRANCH
gc.Patch(p6, p2)
case ssa.OpMIPS64CALLstatic:
if v.Aux.(*gc.Sym) == gc.Deferreturn.Sym {
if v.Aux.(*obj.LSym) == gc.Linksym(gc.Deferreturn.Sym) {
// Deferred calls will appear to be returning to
// the CALL deferreturn(SB) that we are about to emit.
// However, the stack trace code will show the line
......@@ -504,7 +504,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p := gc.Prog(obj.ACALL)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(v.Aux.(*gc.Sym))
p.To.Sym = v.Aux.(*obj.LSym)
if gc.Maxarg < v.AuxInt {
gc.Maxarg = v.AuxInt
}
......@@ -638,7 +638,7 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
p := gc.Prog(obj.ARET)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(b.Aux.(*gc.Sym))
p.To.Sym = b.Aux.(*obj.LSym)
case ssa.BlockMIPS64EQ, ssa.BlockMIPS64NE,
ssa.BlockMIPS64LTZ, ssa.BlockMIPS64GEZ,
ssa.BlockMIPS64LEZ, ssa.BlockMIPS64GTZ,
......
......@@ -687,7 +687,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
gc.Patch(p4, p)
case ssa.OpPPC64CALLstatic:
if v.Aux.(*gc.Sym) == gc.Deferreturn.Sym {
if v.Aux.(*obj.LSym) == gc.Linksym(gc.Deferreturn.Sym) {
// Deferred calls will appear to be returning to
// the CALL deferreturn(SB) that we are about to emit.
// However, the stack trace code will show the line
......@@ -722,7 +722,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p := gc.Prog(obj.ACALL)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(v.Aux.(*gc.Sym))
p.To.Sym = v.Aux.(*obj.LSym)
if gc.Maxarg < v.AuxInt {
gc.Maxarg = v.AuxInt
}
......@@ -874,7 +874,7 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
p := gc.Prog(obj.AJMP)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(b.Aux.(*gc.Sym))
p.To.Sym = b.Aux.(*obj.LSym)
case ssa.BlockPPC64EQ, ssa.BlockPPC64NE,
ssa.BlockPPC64LT, ssa.BlockPPC64GE,
......
......@@ -473,7 +473,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p.To.Type = obj.TYPE_REG
p.To.Reg = r
case ssa.OpS390XCALLstatic:
if v.Aux.(*gc.Sym) == gc.Deferreturn.Sym {
if v.Aux.(*obj.LSym) == gc.Linksym(gc.Deferreturn.Sym) {
// Deferred calls will appear to be returning to
// the CALL deferreturn(SB) that we are about to emit.
// However, the stack trace code will show the line
......@@ -487,7 +487,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p := gc.Prog(obj.ACALL)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(v.Aux.(*gc.Sym))
p.To.Sym = v.Aux.(*obj.LSym)
if gc.Maxarg < v.AuxInt {
gc.Maxarg = v.AuxInt
}
......@@ -835,7 +835,7 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
p := gc.Prog(s390x.ABR)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(b.Aux.(*gc.Sym))
p.To.Sym = b.Aux.(*obj.LSym)
case ssa.BlockS390XEQ, ssa.BlockS390XNE,
ssa.BlockS390XLT, ssa.BlockS390XGE,
ssa.BlockS390XLE, ssa.BlockS390XGT,
......
......@@ -129,7 +129,7 @@ type Frontend interface {
// Syslook returns a symbol of the runtime function/variable with the
// given name.
Syslook(string) interface{} // returns *gc.Sym
Syslook(string) *obj.LSym
}
// interface used to hold *gc.Node. We'd use *gc.Node directly but
......
......@@ -16,10 +16,10 @@ var PrintFunc = printFunc
var Opt = opt
var Deadcode = deadcode
var Copyelim = copyelim
var TestCtxt = obj.Linknew(&x86.Linkamd64)
func testConfig(t testing.TB) *Config {
testCtxt := &obj.Link{Arch: &x86.Linkamd64}
return NewConfig("amd64", DummyFrontend{t}, testCtxt, true)
return NewConfig("amd64", DummyFrontend{t}, TestCtxt, true)
}
// DummyFrontend is a test-only frontend.
......@@ -68,8 +68,8 @@ func (DummyFrontend) Line(_ src.XPos) string {
}
func (DummyFrontend) AllocFrame(f *Func) {
}
func (DummyFrontend) Syslook(s string) interface{} {
return DummySym(s)
func (DummyFrontend) Syslook(s string) *obj.LSym {
return obj.Linklookup(TestCtxt, s, 0)
}
func (d DummyFrontend) Logf(msg string, args ...interface{}) { d.t.Logf(msg, args...) }
......@@ -100,7 +100,3 @@ func (d DummyFrontend) CanSSA(t Type) bool {
// There are no un-SSAable types in dummy land.
return true
}
type DummySym string
func (s DummySym) String() string { return string(s) }
......@@ -5,8 +5,8 @@
package ssa
import (
"cmd/internal/obj"
"cmd/internal/src"
"fmt"
)
// writebarrier expands write barrier ops (StoreWB, MoveWB, etc.) into
......@@ -31,7 +31,7 @@ import (
// number of blocks as fuse merges blocks introduced in this phase.
func writebarrier(f *Func) {
var sb, sp, wbaddr *Value
var writebarrierptr, typedmemmove, typedmemclr interface{} // *gc.Sym
var writebarrierptr, typedmemmove, typedmemclr *obj.LSym
var storeWBs, others []*Value
var wbs *sparseSet
for _, b := range f.Blocks { // range loop is safe since the blocks we added contain no WB stores
......@@ -71,7 +71,7 @@ func writebarrier(f *Func) {
if sp == nil {
sp = f.Entry.NewValue0(initln, OpSP, f.Config.fe.TypeUintptr())
}
wbsym := &ExternSymbol{Typ: f.Config.fe.TypeBool(), Sym: f.Config.fe.Syslook("writeBarrier").(fmt.Stringer)}
wbsym := &ExternSymbol{Typ: f.Config.fe.TypeBool(), Sym: f.Config.fe.Syslook("writeBarrier")}
wbaddr = f.Entry.NewValue1A(initln, OpAddr, f.Config.fe.TypeUInt32().PtrTo(), wbsym, sb)
writebarrierptr = f.Config.fe.Syslook("writebarrierptr")
typedmemmove = f.Config.fe.Syslook("typedmemmove")
......@@ -162,7 +162,7 @@ func writebarrier(f *Func) {
typ := w.Aux // only non-nil for MoveWB, MoveWBVolatile, ZeroWB
var op Op
var fn interface{} // *gc.Sym
var fn *obj.LSym
switch w.Op {
case OpStoreWB:
op = OpStore
......@@ -240,7 +240,7 @@ func writebarrier(f *Func) {
// wbcall emits write barrier runtime call in b, returns memory.
// if valIsVolatile, it moves val into temp space before making the call.
func wbcall(pos src.XPos, b *Block, fn interface{}, typ interface{}, ptr, val, mem, sp, sb *Value, valIsVolatile bool) *Value {
func wbcall(pos src.XPos, b *Block, fn *obj.LSym, typ interface{}, ptr, val, mem, sp, sb *Value, valIsVolatile bool) *Value {
config := b.Func.Config
var tmp GCNode
......
......@@ -660,7 +660,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
q.To.Reg = r
}
case ssa.Op386CALLstatic:
if v.Aux.(*gc.Sym) == gc.Deferreturn.Sym {
if v.Aux.(*obj.LSym) == gc.Linksym(gc.Deferreturn.Sym) {
// Deferred calls will appear to be returning to
// the CALL deferreturn(SB) that we are about to emit.
// However, the stack trace code will show the line
......@@ -674,7 +674,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p := gc.Prog(obj.ACALL)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(v.Aux.(*gc.Sym))
p.To.Sym = v.Aux.(*obj.LSym)
if gc.Maxarg < v.AuxInt {
gc.Maxarg = v.AuxInt
}
......@@ -864,7 +864,7 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
p := gc.Prog(obj.AJMP)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = gc.Linksym(b.Aux.(*gc.Sym))
p.To.Sym = b.Aux.(*obj.LSym)
case ssa.Block386EQF:
gc.SSAGenFPJump(s, b, next, &eqfJumps)
......
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