aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/gc/obj.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2020-12-23 00:39:45 -0500
committerRuss Cox <rsc@golang.org>2020-12-23 06:38:20 +0000
commitdac0de3748cc816352da56f516506f80c33db4a5 (patch)
treee5dfa879e57a37b96be0c8d96e67f94dee928015 /src/cmd/compile/internal/gc/obj.go
parent527a1895d675ec0384f564dd76e56b3631948dd4 (diff)
downloadgo-dac0de3748cc816352da56f516506f80c33db4a5.tar.gz
go-dac0de3748cc816352da56f516506f80c33db4a5.zip
[dev.regabi] cmd/compile: move type size calculations into package types [generated]
To break up package gc, we need to put these calculations somewhere lower in the import graph, either an existing or new package. Package types already needs this code and is using hacks to get it without an import cycle. We can remove the hacks and set up for the new package gc by moving the code into package types itself. [git-generate] cd src/cmd/compile/internal/gc rf ' # Remove old import cycle hacks in gc. rm TypecheckInit:/types.Widthptr =/-0,/types.Dowidth =/+0 \ ../ssa/export_test.go:/types.Dowidth =/-+ ex { import "cmd/compile/internal/types" types.Widthptr -> Widthptr types.Dowidth -> dowidth } # Disable CalcSize in tests instead of base.Fatalf sub dowidth:/base.Fatalf\("dowidth without betypeinit"\)/ \ // Assume this is a test. \ return # Move size calculation into cmd/compile/internal/types mv Widthptr PtrSize mv Widthreg RegSize mv slicePtrOffset SlicePtrOffset mv sliceLenOffset SliceLenOffset mv sliceCapOffset SliceCapOffset mv sizeofSlice SliceSize mv sizeofString StringSize mv skipDowidthForTracing SkipSizeForTracing mv dowidth CalcSize mv checkwidth CheckSize mv widstruct calcStructOffset mv sizeCalculationDisabled CalcSizeDisabled mv defercheckwidth DeferCheckSize mv resumecheckwidth ResumeCheckSize mv typeptrdata PtrDataSize mv \ PtrSize RegSize SlicePtrOffset SkipSizeForTracing typePos align.go PtrDataSize \ size.go mv size.go cmd/compile/internal/types ' : # Remove old import cycle hacks in types. cd ../types rf ' ex { Widthptr -> PtrSize Dowidth -> CalcSize } rm Widthptr Dowidth ' Change-Id: Ib96cdc6bda2617235480c29392ea5cfb20f60cd8 Reviewed-on: https://go-review.googlesource.com/c/go/+/279234 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/gc/obj.go')
-rw-r--r--src/cmd/compile/internal/gc/obj.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/cmd/compile/internal/gc/obj.go b/src/cmd/compile/internal/gc/obj.go
index e56e34a7a1..372277552f 100644
--- a/src/cmd/compile/internal/gc/obj.go
+++ b/src/cmd/compile/internal/gc/obj.go
@@ -234,7 +234,7 @@ func dumpGlobal(n *ir.Name) {
if n.Sym().Pkg != types.LocalPkg {
return
}
- dowidth(n.Type())
+ types.CalcSize(n.Type())
ggloblnod(n)
}
@@ -281,7 +281,7 @@ func dumpfuncsyms() {
for _, s := range funcsyms {
sf := s.Pkg.Lookup(ir.FuncSymName(s)).Linksym()
dsymptr(sf, 0, s.Linksym(), 0)
- ggloblsym(sf, int32(Widthptr), obj.DUPOK|obj.RODATA)
+ ggloblsym(sf, int32(types.PtrSize), obj.DUPOK|obj.RODATA)
}
}
@@ -332,7 +332,7 @@ func duint32(s *obj.LSym, off int, v uint32) int {
}
func duintptr(s *obj.LSym, off int, v uint64) int {
- return duintxx(s, off, v, Widthptr)
+ return duintxx(s, off, v, types.PtrSize)
}
func dbvec(s *obj.LSym, off int, bv bvec) int {
@@ -505,9 +505,9 @@ func dstringdata(s *obj.LSym, off int, t string, pos src.XPos, what string) int
}
func dsymptr(s *obj.LSym, off int, x *obj.LSym, xoff int) int {
- off = int(Rnd(int64(off), int64(Widthptr)))
- s.WriteAddr(base.Ctxt, int64(off), Widthptr, x, int64(xoff))
- off += Widthptr
+ off = int(types.Rnd(int64(off), int64(types.PtrSize)))
+ s.WriteAddr(base.Ctxt, int64(off), types.PtrSize, x, int64(xoff))
+ off += types.PtrSize
return off
}
@@ -530,9 +530,9 @@ func slicesym(n *ir.Name, noff int64, arr *ir.Name, lencap int64) {
if arr.Op() != ir.ONAME {
base.Fatalf("slicesym non-name arr %v", arr)
}
- s.WriteAddr(base.Ctxt, noff, Widthptr, arr.Sym().Linksym(), 0)
- s.WriteInt(base.Ctxt, noff+sliceLenOffset, Widthptr, lencap)
- s.WriteInt(base.Ctxt, noff+sliceCapOffset, Widthptr, lencap)
+ s.WriteAddr(base.Ctxt, noff, types.PtrSize, arr.Sym().Linksym(), 0)
+ s.WriteInt(base.Ctxt, noff+types.SliceLenOffset, types.PtrSize, lencap)
+ s.WriteInt(base.Ctxt, noff+types.SliceCapOffset, types.PtrSize, lencap)
}
// addrsym writes the static address of a to n. a must be an ONAME.
@@ -548,7 +548,7 @@ func addrsym(n *ir.Name, noff int64, a *ir.Name, aoff int64) {
base.Fatalf("addrsym a op %v", a.Op())
}
s := n.Sym().Linksym()
- s.WriteAddr(base.Ctxt, noff, Widthptr, a.Sym().Linksym(), aoff)
+ s.WriteAddr(base.Ctxt, noff, types.PtrSize, a.Sym().Linksym(), aoff)
}
// pfuncsym writes the static address of f to n. f must be a global function.
@@ -564,7 +564,7 @@ func pfuncsym(n *ir.Name, noff int64, f *ir.Name) {
base.Fatalf("pfuncsym class not PFUNC %d", f.Class_)
}
s := n.Sym().Linksym()
- s.WriteAddr(base.Ctxt, noff, Widthptr, funcsym(f.Sym()).Linksym(), 0)
+ s.WriteAddr(base.Ctxt, noff, types.PtrSize, funcsym(f.Sym()).Linksym(), 0)
}
// litsym writes the static literal c to n.
@@ -615,8 +615,8 @@ func litsym(n *ir.Name, noff int64, c ir.Node, wid int) {
case constant.String:
i := constant.StringVal(u)
symdata := stringsym(n.Pos(), i)
- s.WriteAddr(base.Ctxt, noff, Widthptr, symdata, 0)
- s.WriteInt(base.Ctxt, noff+int64(Widthptr), Widthptr, int64(len(i)))
+ s.WriteAddr(base.Ctxt, noff, types.PtrSize, symdata, 0)
+ s.WriteInt(base.Ctxt, noff+int64(types.PtrSize), types.PtrSize, int64(len(i)))
default:
base.Fatalf("litsym unhandled OLITERAL %v", c)