mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: remove more dead code and data structures
Remove more now-redundant code, methods, and types associated with transition to register ABI. Repaired some broken comments. Tested on link-register architectures (arm64, ppc64le) Updates #40724. Change-Id: Ie8433f6d38ec4a1d9705f22dcb596f267d81f203 Reviewed-on: https://go-review.googlesource.com/c/go/+/304189 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
14ef2d8c01
commit
4357f71ca7
4 changed files with 4 additions and 70 deletions
|
|
@ -225,27 +225,16 @@ func appendParamOffsets(offsets []int64, at int64, t *types.Type) ([]int64, int6
|
||||||
return offsets, at
|
return offsets, at
|
||||||
}
|
}
|
||||||
|
|
||||||
// SpillOffset returns the offset *within the spill area* for the parameter that "a" describes.
|
|
||||||
// Registers will be spilled here; if a memory home is needed (for a pointer method e.g.)
|
|
||||||
// then that will be the address.
|
|
||||||
// This will panic if "a" describes a stack-allocated parameter.
|
|
||||||
func (a *ABIParamAssignment) SpillOffset() int32 {
|
|
||||||
if len(a.Registers) == 0 {
|
|
||||||
panic("Stack-allocated parameters have no spill offset")
|
|
||||||
}
|
|
||||||
return a.offset
|
|
||||||
}
|
|
||||||
|
|
||||||
// FrameOffset returns the frame-pointer-relative location that a function
|
// FrameOffset returns the frame-pointer-relative location that a function
|
||||||
// would spill its input or output parameter to, if such a spill slot exists.
|
// would spill its input or output parameter to, if such a spill slot exists.
|
||||||
|
// If there is none defined (e.g., register-allocated outputs) it panics.
|
||||||
// For register-allocated inputs that is their spill offset reserved for morestack;
|
// For register-allocated inputs that is their spill offset reserved for morestack;
|
||||||
// for stack-allocated inputs and outputs, that is their location on the stack.
|
// for stack-allocated inputs and outputs, that is their location on the stack.
|
||||||
// For register-allocated outputs, there is no defined spill area, so return -1.
|
|
||||||
// (In a future version of the ABI, register-resident inputs may lose their defined
|
// (In a future version of the ABI, register-resident inputs may lose their defined
|
||||||
// spill area to help reduce stack sizes.)
|
// spill area to help reduce stack sizes.)
|
||||||
func (a *ABIParamAssignment) FrameOffset(i *ABIParamResultInfo) int64 {
|
func (a *ABIParamAssignment) FrameOffset(i *ABIParamResultInfo) int64 {
|
||||||
if a.offset == -1 {
|
if a.offset == -1 {
|
||||||
return -1
|
panic("Function parameter has no ABI-defined frame-pointer offset")
|
||||||
}
|
}
|
||||||
if len(a.Registers) == 0 { // passed on stack
|
if len(a.Registers) == 0 { // passed on stack
|
||||||
return int64(a.offset) - i.config.LocalsOffset()
|
return int64(a.offset) - i.config.LocalsOffset()
|
||||||
|
|
|
||||||
|
|
@ -92,13 +92,6 @@ func (r *regInfo) String() string {
|
||||||
|
|
||||||
type auxType int8
|
type auxType int8
|
||||||
|
|
||||||
type Param struct {
|
|
||||||
Type *types.Type
|
|
||||||
Offset int32 // Offset of Param if not in a register, spill offset if it is in a register input, types.BADWIDTH if it is a register output.
|
|
||||||
Reg []abi.RegIndex
|
|
||||||
Name *ir.Name // For OwnAux, need to prepend stores with Vardefs
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuxNameOffset struct {
|
type AuxNameOffset struct {
|
||||||
Name *ir.Name
|
Name *ir.Name
|
||||||
Offset int64
|
Offset int64
|
||||||
|
|
@ -198,7 +191,7 @@ func (a *AuxCall) ArgWidth() int64 {
|
||||||
return a.abiInfo.ArgWidth()
|
return a.abiInfo.ArgWidth()
|
||||||
}
|
}
|
||||||
|
|
||||||
// OffsetOfResult returns the SP offset of result which (indexed 0, 1, etc).
|
// ParamAssignmentForResult returns the ABI Parameter assignment for result which (indexed 0, 1, etc).
|
||||||
func (a *AuxCall) ParamAssignmentForResult(which int64) *abi.ABIParamAssignment {
|
func (a *AuxCall) ParamAssignmentForResult(which int64) *abi.ABIParamAssignment {
|
||||||
return a.abiInfo.OutParam(int(which))
|
return a.abiInfo.OutParam(int(which))
|
||||||
}
|
}
|
||||||
|
|
@ -292,16 +285,6 @@ func (a *AuxCall) String() string {
|
||||||
return fn + "}"
|
return fn + "}"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ACParamsToTypes translates a slice of Param into a slice of *types.Type
|
|
||||||
// This is a helper call for ssagen/ssa.go.
|
|
||||||
// TODO remove this, as part of replacing fields of AuxCall with abi.ABIParamResultInfo.
|
|
||||||
func ACParamsToTypes(ps []Param) (ts []*types.Type) {
|
|
||||||
for _, p := range ps {
|
|
||||||
ts = append(ts, p.Type)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// StaticAuxCall returns an AuxCall for a static call.
|
// StaticAuxCall returns an AuxCall for a static call.
|
||||||
func StaticAuxCall(sym *obj.LSym, paramResultInfo *abi.ABIParamResultInfo) *AuxCall {
|
func StaticAuxCall(sym *obj.LSym, paramResultInfo *abi.ABIParamResultInfo) *AuxCall {
|
||||||
if paramResultInfo == nil {
|
if paramResultInfo == nil {
|
||||||
|
|
|
||||||
|
|
@ -486,14 +486,12 @@ func wbcall(pos src.XPos, b *Block, fn, typ *obj.LSym, ptr, val, mem, sp, sb *Va
|
||||||
// put arguments on stack
|
// put arguments on stack
|
||||||
off := config.ctxt.FixedFrameSize()
|
off := config.ctxt.FixedFrameSize()
|
||||||
|
|
||||||
var ACArgs []Param
|
|
||||||
var argTypes []*types.Type
|
var argTypes []*types.Type
|
||||||
if typ != nil { // for typedmemmove
|
if typ != nil { // for typedmemmove
|
||||||
taddr := b.NewValue1A(pos, OpAddr, b.Func.Config.Types.Uintptr, typ, sb)
|
taddr := b.NewValue1A(pos, OpAddr, b.Func.Config.Types.Uintptr, typ, sb)
|
||||||
off = round(off, taddr.Type.Alignment())
|
off = round(off, taddr.Type.Alignment())
|
||||||
arg := b.NewValue1I(pos, OpOffPtr, taddr.Type.PtrTo(), off, sp)
|
arg := b.NewValue1I(pos, OpOffPtr, taddr.Type.PtrTo(), off, sp)
|
||||||
mem = b.NewValue3A(pos, OpStore, types.TypeMem, ptr.Type, arg, taddr, mem)
|
mem = b.NewValue3A(pos, OpStore, types.TypeMem, ptr.Type, arg, taddr, mem)
|
||||||
ACArgs = append(ACArgs, Param{Type: b.Func.Config.Types.Uintptr, Offset: int32(off)})
|
|
||||||
argTypes = append(argTypes, b.Func.Config.Types.Uintptr)
|
argTypes = append(argTypes, b.Func.Config.Types.Uintptr)
|
||||||
off += taddr.Type.Size()
|
off += taddr.Type.Size()
|
||||||
}
|
}
|
||||||
|
|
@ -501,7 +499,6 @@ func wbcall(pos src.XPos, b *Block, fn, typ *obj.LSym, ptr, val, mem, sp, sb *Va
|
||||||
off = round(off, ptr.Type.Alignment())
|
off = round(off, ptr.Type.Alignment())
|
||||||
arg := b.NewValue1I(pos, OpOffPtr, ptr.Type.PtrTo(), off, sp)
|
arg := b.NewValue1I(pos, OpOffPtr, ptr.Type.PtrTo(), off, sp)
|
||||||
mem = b.NewValue3A(pos, OpStore, types.TypeMem, ptr.Type, arg, ptr, mem)
|
mem = b.NewValue3A(pos, OpStore, types.TypeMem, ptr.Type, arg, ptr, mem)
|
||||||
ACArgs = append(ACArgs, Param{Type: ptr.Type, Offset: int32(off)})
|
|
||||||
argTypes = append(argTypes, ptr.Type)
|
argTypes = append(argTypes, ptr.Type)
|
||||||
off += ptr.Type.Size()
|
off += ptr.Type.Size()
|
||||||
|
|
||||||
|
|
@ -509,7 +506,6 @@ func wbcall(pos src.XPos, b *Block, fn, typ *obj.LSym, ptr, val, mem, sp, sb *Va
|
||||||
off = round(off, val.Type.Alignment())
|
off = round(off, val.Type.Alignment())
|
||||||
arg = b.NewValue1I(pos, OpOffPtr, val.Type.PtrTo(), off, sp)
|
arg = b.NewValue1I(pos, OpOffPtr, val.Type.PtrTo(), off, sp)
|
||||||
mem = b.NewValue3A(pos, OpStore, types.TypeMem, val.Type, arg, val, mem)
|
mem = b.NewValue3A(pos, OpStore, types.TypeMem, val.Type, arg, val, mem)
|
||||||
ACArgs = append(ACArgs, Param{Type: val.Type, Offset: int32(off)})
|
|
||||||
argTypes = append(argTypes, val.Type)
|
argTypes = append(argTypes, val.Type)
|
||||||
off += val.Type.Size()
|
off += val.Type.Size()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -521,7 +521,6 @@ func buildssa(fn *ir.Func, worker int) *ssa.Func {
|
||||||
|
|
||||||
// Generate addresses of local declarations
|
// Generate addresses of local declarations
|
||||||
s.decladdrs = map[*ir.Name]*ssa.Value{}
|
s.decladdrs = map[*ir.Name]*ssa.Value{}
|
||||||
var results []ssa.Param
|
|
||||||
for _, n := range fn.Dcl {
|
for _, n := range fn.Dcl {
|
||||||
switch n.Class {
|
switch n.Class {
|
||||||
case ir.PPARAM:
|
case ir.PPARAM:
|
||||||
|
|
@ -529,7 +528,6 @@ func buildssa(fn *ir.Func, worker int) *ssa.Func {
|
||||||
s.decladdrs[n] = s.entryNewValue2A(ssa.OpLocalAddr, types.NewPtr(n.Type()), n, s.sp, s.startmem)
|
s.decladdrs[n] = s.entryNewValue2A(ssa.OpLocalAddr, types.NewPtr(n.Type()), n, s.sp, s.startmem)
|
||||||
case ir.PPARAMOUT:
|
case ir.PPARAMOUT:
|
||||||
s.decladdrs[n] = s.entryNewValue2A(ssa.OpLocalAddr, types.NewPtr(n.Type()), n, s.sp, s.startmem)
|
s.decladdrs[n] = s.entryNewValue2A(ssa.OpLocalAddr, types.NewPtr(n.Type()), n, s.sp, s.startmem)
|
||||||
results = append(results, ssa.Param{Name: n})
|
|
||||||
case ir.PAUTO:
|
case ir.PAUTO:
|
||||||
// processed at each use, to prevent Addr coming
|
// processed at each use, to prevent Addr coming
|
||||||
// before the decl.
|
// before the decl.
|
||||||
|
|
@ -538,34 +536,6 @@ func buildssa(fn *ir.Func, worker int) *ssa.Func {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: figure out why base.Ctxt.FixedFrameSize() is not added to these offsets here (compare to calls).
|
|
||||||
// The input half is ignored unless a register ABI is used.
|
|
||||||
var args []ssa.Param
|
|
||||||
for _, p := range params.InParams() {
|
|
||||||
r := p.Registers
|
|
||||||
var o int32
|
|
||||||
if len(r) == 0 {
|
|
||||||
o = p.Offset()
|
|
||||||
} else {
|
|
||||||
o = p.SpillOffset() + int32(params.SpillAreaOffset())
|
|
||||||
}
|
|
||||||
args = append(args, ssa.Param{Type: p.Type, Offset: o, Reg: r})
|
|
||||||
}
|
|
||||||
|
|
||||||
// For now, need the ir.Name attached to these, so update those already created.
|
|
||||||
for i, p := range params.OutParams() {
|
|
||||||
r := p.Registers
|
|
||||||
var o int32
|
|
||||||
if len(r) == 0 {
|
|
||||||
o = p.Offset()
|
|
||||||
} else {
|
|
||||||
o = types.BADWIDTH
|
|
||||||
}
|
|
||||||
results[i].Type = p.Type
|
|
||||||
results[i].Offset = o
|
|
||||||
results[i].Reg = r
|
|
||||||
}
|
|
||||||
|
|
||||||
s.f.OwnAux = ssa.OwnAuxCall(fn.LSym, params)
|
s.f.OwnAux = ssa.OwnAuxCall(fn.LSym, params)
|
||||||
|
|
||||||
// Populate SSAable arguments.
|
// Populate SSAable arguments.
|
||||||
|
|
@ -5497,8 +5467,6 @@ func (s *state) rtcall(fn *obj.LSym, returns bool, results []*types.Type, args .
|
||||||
s.prevCall = nil
|
s.prevCall = nil
|
||||||
// Write args to the stack
|
// Write args to the stack
|
||||||
off := base.Ctxt.FixedFrameSize()
|
off := base.Ctxt.FixedFrameSize()
|
||||||
var ACArgs []ssa.Param
|
|
||||||
var ACResults []ssa.Param
|
|
||||||
var callArgs []*ssa.Value
|
var callArgs []*ssa.Value
|
||||||
var callArgTypes []*types.Type
|
var callArgTypes []*types.Type
|
||||||
|
|
||||||
|
|
@ -5506,7 +5474,6 @@ func (s *state) rtcall(fn *obj.LSym, returns bool, results []*types.Type, args .
|
||||||
t := arg.Type
|
t := arg.Type
|
||||||
off = types.Rnd(off, t.Alignment())
|
off = types.Rnd(off, t.Alignment())
|
||||||
size := t.Size()
|
size := t.Size()
|
||||||
ACArgs = append(ACArgs, ssa.Param{Type: t, Offset: int32(off)})
|
|
||||||
callArgs = append(callArgs, arg)
|
callArgs = append(callArgs, arg)
|
||||||
callArgTypes = append(callArgTypes, t)
|
callArgTypes = append(callArgTypes, t)
|
||||||
off += size
|
off += size
|
||||||
|
|
@ -5517,7 +5484,6 @@ func (s *state) rtcall(fn *obj.LSym, returns bool, results []*types.Type, args .
|
||||||
offR := off
|
offR := off
|
||||||
for _, t := range results {
|
for _, t := range results {
|
||||||
offR = types.Rnd(offR, t.Alignment())
|
offR = types.Rnd(offR, t.Alignment())
|
||||||
ACResults = append(ACResults, ssa.Param{Type: t, Offset: int32(offR)})
|
|
||||||
offR += t.Size()
|
offR += t.Size()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5527,7 +5493,7 @@ func (s *state) rtcall(fn *obj.LSym, returns bool, results []*types.Type, args .
|
||||||
callArgs = append(callArgs, s.mem())
|
callArgs = append(callArgs, s.mem())
|
||||||
call = s.newValue0A(ssa.OpStaticLECall, aux.LateExpansionResultType(), aux)
|
call = s.newValue0A(ssa.OpStaticLECall, aux.LateExpansionResultType(), aux)
|
||||||
call.AddArgs(callArgs...)
|
call.AddArgs(callArgs...)
|
||||||
s.vars[memVar] = s.newValue1I(ssa.OpSelectN, types.TypeMem, int64(len(ACResults)), call)
|
s.vars[memVar] = s.newValue1I(ssa.OpSelectN, types.TypeMem, int64(len(results)), call)
|
||||||
|
|
||||||
if !returns {
|
if !returns {
|
||||||
// Finish block
|
// Finish block
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue