[dev.regabi] cmd/compile: remove uses of dummy

Per https://developers.google.com/style/inclusive-documentation,
since we are editing some of this code anyway and it is easier
to put the cleanup in a separate CL.

Change-Id: Ib6b851f43f9cc0a57676564477d4ff22abb1cee5
Reviewed-on: https://go-review.googlesource.com/c/go/+/273106
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Russ Cox 2020-11-24 22:09:57 -05:00
parent 4a6b4fd139
commit 9e0e43d84d
15 changed files with 100 additions and 101 deletions

View file

@ -36,10 +36,10 @@ func testConfigArch(tb testing.TB, arch string) *Conf {
tb.Fatalf("unknown arch %s", arch)
}
if ctxt.Arch.PtrSize != 8 {
tb.Fatal("dummyTypes is 64-bit only")
tb.Fatal("testTypes is 64-bit only")
}
c := &Conf{
config: NewConfig(arch, dummyTypes, ctxt, true),
config: NewConfig(arch, testTypes, ctxt, true),
tb: tb,
}
return c
@ -53,108 +53,108 @@ type Conf struct {
func (c *Conf) Frontend() Frontend {
if c.fe == nil {
c.fe = DummyFrontend{t: c.tb, ctxt: c.config.ctxt}
c.fe = TestFrontend{t: c.tb, ctxt: c.config.ctxt}
}
return c.fe
}
// DummyFrontend is a test-only frontend.
// TestFrontend is a test-only frontend.
// It assumes 64 bit integers and pointers.
type DummyFrontend struct {
type TestFrontend struct {
t testing.TB
ctxt *obj.Link
}
type DummyAuto struct {
type TestAuto struct {
t *types.Type
s string
}
func (d *DummyAuto) Typ() *types.Type {
func (d *TestAuto) Typ() *types.Type {
return d.t
}
func (d *DummyAuto) String() string {
func (d *TestAuto) String() string {
return d.s
}
func (d *DummyAuto) StorageClass() StorageClass {
func (d *TestAuto) StorageClass() StorageClass {
return ClassAuto
}
func (d *DummyAuto) IsSynthetic() bool {
func (d *TestAuto) IsSynthetic() bool {
return false
}
func (d *DummyAuto) IsAutoTmp() bool {
func (d *TestAuto) IsAutoTmp() bool {
return true
}
func (DummyFrontend) StringData(s string) *obj.LSym {
func (TestFrontend) StringData(s string) *obj.LSym {
return nil
}
func (DummyFrontend) Auto(pos src.XPos, t *types.Type) GCNode {
return &DummyAuto{t: t, s: "aDummyAuto"}
func (TestFrontend) Auto(pos src.XPos, t *types.Type) GCNode {
return &TestAuto{t: t, s: "aTestAuto"}
}
func (d DummyFrontend) SplitString(s LocalSlot) (LocalSlot, LocalSlot) {
return LocalSlot{N: s.N, Type: dummyTypes.BytePtr, Off: s.Off}, LocalSlot{N: s.N, Type: dummyTypes.Int, Off: s.Off + 8}
func (d TestFrontend) SplitString(s LocalSlot) (LocalSlot, LocalSlot) {
return LocalSlot{N: s.N, Type: testTypes.BytePtr, Off: s.Off}, LocalSlot{N: s.N, Type: testTypes.Int, Off: s.Off + 8}
}
func (d DummyFrontend) SplitInterface(s LocalSlot) (LocalSlot, LocalSlot) {
return LocalSlot{N: s.N, Type: dummyTypes.BytePtr, Off: s.Off}, LocalSlot{N: s.N, Type: dummyTypes.BytePtr, Off: s.Off + 8}
func (d TestFrontend) SplitInterface(s LocalSlot) (LocalSlot, LocalSlot) {
return LocalSlot{N: s.N, Type: testTypes.BytePtr, Off: s.Off}, LocalSlot{N: s.N, Type: testTypes.BytePtr, Off: s.Off + 8}
}
func (d DummyFrontend) SplitSlice(s LocalSlot) (LocalSlot, LocalSlot, LocalSlot) {
func (d TestFrontend) SplitSlice(s LocalSlot) (LocalSlot, LocalSlot, LocalSlot) {
return LocalSlot{N: s.N, Type: s.Type.Elem().PtrTo(), Off: s.Off},
LocalSlot{N: s.N, Type: dummyTypes.Int, Off: s.Off + 8},
LocalSlot{N: s.N, Type: dummyTypes.Int, Off: s.Off + 16}
LocalSlot{N: s.N, Type: testTypes.Int, Off: s.Off + 8},
LocalSlot{N: s.N, Type: testTypes.Int, Off: s.Off + 16}
}
func (d DummyFrontend) SplitComplex(s LocalSlot) (LocalSlot, LocalSlot) {
func (d TestFrontend) SplitComplex(s LocalSlot) (LocalSlot, LocalSlot) {
if s.Type.Size() == 16 {
return LocalSlot{N: s.N, Type: dummyTypes.Float64, Off: s.Off}, LocalSlot{N: s.N, Type: dummyTypes.Float64, Off: s.Off + 8}
return LocalSlot{N: s.N, Type: testTypes.Float64, Off: s.Off}, LocalSlot{N: s.N, Type: testTypes.Float64, Off: s.Off + 8}
}
return LocalSlot{N: s.N, Type: dummyTypes.Float32, Off: s.Off}, LocalSlot{N: s.N, Type: dummyTypes.Float32, Off: s.Off + 4}
return LocalSlot{N: s.N, Type: testTypes.Float32, Off: s.Off}, LocalSlot{N: s.N, Type: testTypes.Float32, Off: s.Off + 4}
}
func (d DummyFrontend) SplitInt64(s LocalSlot) (LocalSlot, LocalSlot) {
func (d TestFrontend) SplitInt64(s LocalSlot) (LocalSlot, LocalSlot) {
if s.Type.IsSigned() {
return LocalSlot{N: s.N, Type: dummyTypes.Int32, Off: s.Off + 4}, LocalSlot{N: s.N, Type: dummyTypes.UInt32, Off: s.Off}
return LocalSlot{N: s.N, Type: testTypes.Int32, Off: s.Off + 4}, LocalSlot{N: s.N, Type: testTypes.UInt32, Off: s.Off}
}
return LocalSlot{N: s.N, Type: dummyTypes.UInt32, Off: s.Off + 4}, LocalSlot{N: s.N, Type: dummyTypes.UInt32, Off: s.Off}
return LocalSlot{N: s.N, Type: testTypes.UInt32, Off: s.Off + 4}, LocalSlot{N: s.N, Type: testTypes.UInt32, Off: s.Off}
}
func (d DummyFrontend) SplitStruct(s LocalSlot, i int) LocalSlot {
func (d TestFrontend) SplitStruct(s LocalSlot, i int) LocalSlot {
return LocalSlot{N: s.N, Type: s.Type.FieldType(i), Off: s.Off + s.Type.FieldOff(i)}
}
func (d DummyFrontend) SplitArray(s LocalSlot) LocalSlot {
func (d TestFrontend) SplitArray(s LocalSlot) LocalSlot {
return LocalSlot{N: s.N, Type: s.Type.Elem(), Off: s.Off}
}
func (d DummyFrontend) SplitSlot(parent *LocalSlot, suffix string, offset int64, t *types.Type) LocalSlot {
func (d TestFrontend) SplitSlot(parent *LocalSlot, suffix string, offset int64, t *types.Type) LocalSlot {
return LocalSlot{N: parent.N, Type: t, Off: offset}
}
func (DummyFrontend) Line(_ src.XPos) string {
func (TestFrontend) Line(_ src.XPos) string {
return "unknown.go:0"
}
func (DummyFrontend) AllocFrame(f *Func) {
func (TestFrontend) AllocFrame(f *Func) {
}
func (d DummyFrontend) Syslook(s string) *obj.LSym {
func (d TestFrontend) Syslook(s string) *obj.LSym {
return d.ctxt.Lookup(s)
}
func (DummyFrontend) UseWriteBarrier() bool {
func (TestFrontend) UseWriteBarrier() bool {
return true // only writebarrier_test cares
}
func (DummyFrontend) SetWBPos(pos src.XPos) {
func (TestFrontend) SetWBPos(pos src.XPos) {
}
func (d DummyFrontend) Logf(msg string, args ...interface{}) { d.t.Logf(msg, args...) }
func (d DummyFrontend) Log() bool { return true }
func (d TestFrontend) Logf(msg string, args ...interface{}) { d.t.Logf(msg, args...) }
func (d TestFrontend) Log() bool { return true }
func (d DummyFrontend) Fatalf(_ src.XPos, msg string, args ...interface{}) { d.t.Fatalf(msg, args...) }
func (d DummyFrontend) Warnl(_ src.XPos, msg string, args ...interface{}) { d.t.Logf(msg, args...) }
func (d DummyFrontend) Debug_checknil() bool { return false }
func (d TestFrontend) Fatalf(_ src.XPos, msg string, args ...interface{}) { d.t.Fatalf(msg, args...) }
func (d TestFrontend) Warnl(_ src.XPos, msg string, args ...interface{}) { d.t.Logf(msg, args...) }
func (d TestFrontend) Debug_checknil() bool { return false }
func (d DummyFrontend) MyImportPath() string {
func (d TestFrontend) MyImportPath() string {
return "my/import/path"
}
var dummyTypes Types
var testTypes Types
func init() {
// Initialize just enough of the universe and the types package to make our tests function.
@ -198,12 +198,12 @@ func init() {
t.Align = uint8(typ.width)
types.Types[typ.et] = t
}
dummyTypes.SetTypPtrs()
testTypes.SetTypPtrs()
}
func (d DummyFrontend) DerefItab(sym *obj.LSym, off int64) *obj.LSym { return nil }
func (d TestFrontend) DerefItab(sym *obj.LSym, off int64) *obj.LSym { return nil }
func (d DummyFrontend) CanSSA(t *types.Type) bool {
// There are no un-SSAable types in dummy land.
func (d TestFrontend) CanSSA(t *types.Type) bool {
// There are no un-SSAable types in test land.
return true
}