[dev.regabi] cmd/compile: introduce cmd/compile/internal/base [generated]

Move Flag, Debug, Ctxt, Exit, and error messages to
new package cmd/compile/internal/base.

These are the core functionality that everything in gc uses
and which otherwise prevent splitting any other code
out of gc into different packages.

A minor milestone: the compiler source code
no longer contains the string "yy".

[git-generate]
cd src/cmd/compile/internal/gc
rf '
        mv atExit AtExit
        mv Ctxt atExitFuncs AtExit Exit base.go

        mv lineno Pos
        mv linestr FmtPos
        mv flusherrors FlushErrors
        mv yyerror Errorf
        mv yyerrorl ErrorfAt
        mv yyerrorv ErrorfVers
        mv noder.yyerrorpos noder.errorAt
        mv Warnl WarnfAt
        mv errorexit ErrorExit

        mv base.go debug.go flag.go print.go cmd/compile/internal/base
'

: # update comments
sed -i '' 's/yyerrorl/ErrorfAt/g; s/yyerror/Errorf/g' *.go

: # bootstrap.go is not built by default so invisible to rf
sed -i '' 's/Fatalf/base.Fatalf/' bootstrap.go
goimports -w bootstrap.go

: # update cmd/dist to add internal/base
cd ../../../dist
sed -i '' '/internal.amd64/a\
	"cmd/compile/internal/base",
' buildtool.go
gofmt -w buildtool.go

Change-Id: I59903c7084222d6eaee38823fd222159ba24a31a
Reviewed-on: https://go-review.googlesource.com/c/go/+/272250
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Russ Cox 2020-11-19 20:49:23 -05:00
parent eb3086e5a8
commit 26b66fd60b
67 changed files with 1626 additions and 1542 deletions

View file

@ -7,6 +7,7 @@
package gc
import (
"cmd/compile/internal/base"
"cmd/compile/internal/ssa"
"cmd/compile/internal/types"
"cmd/internal/obj"
@ -106,7 +107,7 @@ func (n *Node) SubOp() Op {
switch n.Op {
case OASOP, ONAME:
default:
Fatalf("unexpected op: %v", n.Op)
base.Fatalf("unexpected op: %v", n.Op)
}
return Op(n.aux)
}
@ -115,21 +116,21 @@ func (n *Node) SetSubOp(op Op) {
switch n.Op {
case OASOP, ONAME:
default:
Fatalf("unexpected op: %v", n.Op)
base.Fatalf("unexpected op: %v", n.Op)
}
n.aux = uint8(op)
}
func (n *Node) IndexMapLValue() bool {
if n.Op != OINDEXMAP {
Fatalf("unexpected op: %v", n.Op)
base.Fatalf("unexpected op: %v", n.Op)
}
return n.aux != 0
}
func (n *Node) SetIndexMapLValue(b bool) {
if n.Op != OINDEXMAP {
Fatalf("unexpected op: %v", n.Op)
base.Fatalf("unexpected op: %v", n.Op)
}
if b {
n.aux = 1
@ -140,14 +141,14 @@ func (n *Node) SetIndexMapLValue(b bool) {
func (n *Node) TChanDir() types.ChanDir {
if n.Op != OTCHAN {
Fatalf("unexpected op: %v", n.Op)
base.Fatalf("unexpected op: %v", n.Op)
}
return types.ChanDir(n.aux)
}
func (n *Node) SetTChanDir(dir types.ChanDir) {
if n.Op != OTCHAN {
Fatalf("unexpected op: %v", n.Op)
base.Fatalf("unexpected op: %v", n.Op)
}
n.aux = uint8(dir)
}
@ -236,7 +237,7 @@ func (n *Node) SetEmbedded(b bool) { n.flags.set(nodeEmbedded, b) }
// inserted before dereferencing. See state.exprPtr.
func (n *Node) MarkNonNil() {
if !n.Type.IsPtr() && !n.Type.IsUnsafePtr() {
Fatalf("MarkNonNil(%v), type %v", n, n.Type)
base.Fatalf("MarkNonNil(%v), type %v", n, n.Type)
}
n.flags.set(nodeNonNil, true)
}
@ -255,7 +256,7 @@ func (n *Node) SetBounded(b bool) {
// No length and cap checks needed
// since new slice and copied over slice data have same length.
default:
Fatalf("SetBounded(%v)", n)
base.Fatalf("SetBounded(%v)", n)
}
n.flags.set(nodeBounded, b)
}
@ -263,7 +264,7 @@ func (n *Node) SetBounded(b bool) {
// MarkReadonly indicates that n is an ONAME with readonly contents.
func (n *Node) MarkReadonly() {
if n.Op != ONAME {
Fatalf("Node.MarkReadonly %v", n.Op)
base.Fatalf("Node.MarkReadonly %v", n.Op)
}
n.Name.SetReadonly(true)
// Mark the linksym as readonly immediately
@ -284,9 +285,9 @@ func (n *Node) Val() constant.Value {
// which must not have been used with SetOpt.
func (n *Node) SetVal(v constant.Value) {
if n.HasOpt() {
Flag.LowerH = 1
base.Flag.LowerH = 1
Dump("have Opt", n)
Fatalf("have Opt")
base.Fatalf("have Opt")
}
if n.Op == OLITERAL {
assertRepresents(n.Type, v)
@ -314,9 +315,9 @@ func (n *Node) SetOpt(x interface{}) {
return
}
if n.HasVal() {
Flag.LowerH = 1
base.Flag.LowerH = 1
Dump("have Val", n)
Fatalf("have Val")
base.Fatalf("have Val")
}
n.SetHasOpt(true)
n.E = x
@ -367,7 +368,7 @@ func (n *Node) pkgFuncName() string {
}
pkg := s.Pkg
p := Ctxt.Pkgpath
p := base.Ctxt.Pkgpath
if pkg != nil && pkg.Path != "" {
p = pkg.Path
}
@ -764,8 +765,8 @@ func (f *Func) SetInstrumentBody(b bool) { f.flags.set(funcInstrumentB
func (f *Func) SetOpenCodedDeferDisallowed(b bool) { f.flags.set(funcOpenCodedDeferDisallowed, b) }
func (f *Func) setWBPos(pos src.XPos) {
if Debug.WB != 0 {
Warnl(pos, "write barrier")
if base.Debug.WB != 0 {
base.WarnfAt(pos, "write barrier")
}
if !f.WBPos.IsKnown() {
f.WBPos = pos