mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
Move the printing of types.Type and types.Sym out of ir into package types, where it properly belongs. This wasn't done originally (when the code was in gc) because the Type and Sym printing was a bit tangled up with the Node printing. But now they are untangled and can move into the correct package. This CL is automatically generated. A followup CL will clean up a little bit more by hand. Passes buildall w/ toolstash -cmp. [git-generate] cd src/cmd/compile/internal/ir rf ' mv FmtMode fmtMode mv FErr fmtGo mv FDbg fmtDebug mv FTypeId fmtTypeID mv FTypeIdName fmtTypeIDName mv methodSymName SymMethodName mv BuiltinPkg LocalPkg BlankSym OrigSym NumImport \ fmtMode fmtGo symFormat sconv sconv2 symfmt SymMethodName \ BasicTypeNames fmtBufferPool InstallTypeFormats typeFormat tconv tconv2 fldconv FmtConst \ typefmt.go mv typefmt.go cmd/compile/internal/types ' cd ../types mv typefmt.go fmt.go Change-Id: I6f3fd818323733ab8446f00594937c1628760b27 Reviewed-on: https://go-review.googlesource.com/c/go/+/275779 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
89 lines
2.4 KiB
Go
89 lines
2.4 KiB
Go
// Copyright 2009 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package gc
|
|
|
|
import (
|
|
"cmd/compile/internal/base"
|
|
"cmd/compile/internal/ir"
|
|
"cmd/compile/internal/types"
|
|
"cmd/internal/obj"
|
|
"cmd/internal/src"
|
|
"strconv"
|
|
)
|
|
|
|
// sysfunc looks up Go function name in package runtime. This function
|
|
// must follow the internal calling convention.
|
|
func sysfunc(name string) *obj.LSym {
|
|
s := Runtimepkg.Lookup(name)
|
|
s.SetFunc(true)
|
|
return s.Linksym()
|
|
}
|
|
|
|
// sysvar looks up a variable (or assembly function) name in package
|
|
// runtime. If this is a function, it may have a special calling
|
|
// convention.
|
|
func sysvar(name string) *obj.LSym {
|
|
return Runtimepkg.Lookup(name).Linksym()
|
|
}
|
|
|
|
// isParamStackCopy reports whether this is the on-stack copy of a
|
|
// function parameter that moved to the heap.
|
|
func isParamStackCopy(n ir.Node) bool {
|
|
return n.Op() == ir.ONAME && (n.Class() == ir.PPARAM || n.Class() == ir.PPARAMOUT) && n.Name().Heapaddr != nil
|
|
}
|
|
|
|
// isParamHeapCopy reports whether this is the on-heap copy of
|
|
// a function parameter that moved to the heap.
|
|
func isParamHeapCopy(n ir.Node) bool {
|
|
return n.Op() == ir.ONAME && n.Class() == ir.PAUTOHEAP && n.Name().Stackcopy != nil
|
|
}
|
|
|
|
// autotmpname returns the name for an autotmp variable numbered n.
|
|
func autotmpname(n int) string {
|
|
// Give each tmp a different name so that they can be registerized.
|
|
// Add a preceding . to avoid clashing with legal names.
|
|
const prefix = ".autotmp_"
|
|
// Start with a buffer big enough to hold a large n.
|
|
b := []byte(prefix + " ")[:len(prefix)]
|
|
b = strconv.AppendInt(b, int64(n), 10)
|
|
return types.InternString(b)
|
|
}
|
|
|
|
// make a new Node off the books
|
|
func tempAt(pos src.XPos, curfn *ir.Func, t *types.Type) *ir.Name {
|
|
if curfn == nil {
|
|
base.Fatalf("no curfn for tempAt")
|
|
}
|
|
if curfn.Op() == ir.OCLOSURE {
|
|
ir.Dump("tempAt", curfn)
|
|
base.Fatalf("adding tempAt to wrong closure function")
|
|
}
|
|
if t == nil {
|
|
base.Fatalf("tempAt called with nil type")
|
|
}
|
|
|
|
s := &types.Sym{
|
|
Name: autotmpname(len(curfn.Dcl)),
|
|
Pkg: types.LocalPkg,
|
|
}
|
|
n := ir.NewNameAt(pos, s)
|
|
s.Def = n
|
|
n.SetType(t)
|
|
n.SetClass(ir.PAUTO)
|
|
n.SetEsc(EscNever)
|
|
n.Curfn = curfn
|
|
n.SetUsed(true)
|
|
n.SetAutoTemp(true)
|
|
curfn.Dcl = append(curfn.Dcl, n)
|
|
|
|
dowidth(t)
|
|
|
|
return n
|
|
}
|
|
|
|
func temp(t *types.Type) *ir.Name {
|
|
return tempAt(base.Pos, Curfn, t)
|
|
}
|