diff options
author | Josh Bleecher Snyder <josharian@gmail.com> | 2017-03-17 16:04:46 -0700 |
---|---|---|
committer | Josh Bleecher Snyder <josharian@gmail.com> | 2017-03-19 00:21:23 +0000 |
commit | aea3aff66911e31cba9eddd93c02eb591ae483bf (patch) | |
tree | 62e215c0d47ab16717a8d8512f1d2a36425f9fe2 /src/cmd/compile/internal/ssa/export_test.go | |
parent | 2c397c7a753963494ce5dd5d7eda471354074698 (diff) | |
download | go-aea3aff66911e31cba9eddd93c02eb591ae483bf.tar.gz go-aea3aff66911e31cba9eddd93c02eb591ae483bf.zip |
cmd/compile: separate ssa.Frontend and ssa.TypeSource
Prior to this CL, the ssa.Frontend field was responsible
for providing types to the backend during compilation.
However, the types needed by the backend are few and static.
It makes more sense to use a struct for them
and to hang that struct off the ssa.Config,
which is the correct home for readonly data.
Now that Types is a struct, we can clean up the names a bit as well.
This has the added benefit of allowing early construction
of all types needed by the backend.
This will be useful for concurrent backend compilation.
Passes toolstash-check -all. No compiler performance change.
Updates #15756
Change-Id: I021658c8cf2836d6a22bbc20cc828ac38c7da08a
Reviewed-on: https://go-review.googlesource.com/38336
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/export_test.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/export_test.go | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/src/cmd/compile/internal/ssa/export_test.go b/src/cmd/compile/internal/ssa/export_test.go index eeb1fceb7a..b04702d279 100644 --- a/src/cmd/compile/internal/ssa/export_test.go +++ b/src/cmd/compile/internal/ssa/export_test.go @@ -19,11 +19,11 @@ var Copyelim = copyelim var TestCtxt = obj.Linknew(&x86.Linkamd64) func testConfig(t testing.TB) *Config { - return NewConfig("amd64", TestCtxt, true) + return NewConfig("amd64", dummyTypes, TestCtxt, true) } func testConfigS390X(t testing.TB) *Config { - return NewConfig("s390x", obj.Linknew(&s390x.Links390x), true) + return NewConfig("s390x", dummyTypes, obj.Linknew(&s390x.Links390x), true) } // DummyFrontend is a test-only frontend. @@ -52,27 +52,27 @@ func (DummyFrontend) Auto(t Type) GCNode { return &DummyAuto{t: t, s: "aDummyAuto"} } func (d DummyFrontend) SplitString(s LocalSlot) (LocalSlot, LocalSlot) { - return LocalSlot{s.N, d.TypeBytePtr(), s.Off}, LocalSlot{s.N, d.TypeInt(), s.Off + 8} + return LocalSlot{s.N, dummyTypes.BytePtr, s.Off}, LocalSlot{s.N, dummyTypes.Int, s.Off + 8} } func (d DummyFrontend) SplitInterface(s LocalSlot) (LocalSlot, LocalSlot) { - return LocalSlot{s.N, d.TypeBytePtr(), s.Off}, LocalSlot{s.N, d.TypeBytePtr(), s.Off + 8} + return LocalSlot{s.N, dummyTypes.BytePtr, s.Off}, LocalSlot{s.N, dummyTypes.BytePtr, s.Off + 8} } func (d DummyFrontend) SplitSlice(s LocalSlot) (LocalSlot, LocalSlot, LocalSlot) { return LocalSlot{s.N, s.Type.ElemType().PtrTo(), s.Off}, - LocalSlot{s.N, d.TypeInt(), s.Off + 8}, - LocalSlot{s.N, d.TypeInt(), s.Off + 16} + LocalSlot{s.N, dummyTypes.Int, s.Off + 8}, + LocalSlot{s.N, dummyTypes.Int, s.Off + 16} } func (d DummyFrontend) SplitComplex(s LocalSlot) (LocalSlot, LocalSlot) { if s.Type.Size() == 16 { - return LocalSlot{s.N, d.TypeFloat64(), s.Off}, LocalSlot{s.N, d.TypeFloat64(), s.Off + 8} + return LocalSlot{s.N, dummyTypes.Float64, s.Off}, LocalSlot{s.N, dummyTypes.Float64, s.Off + 8} } - return LocalSlot{s.N, d.TypeFloat32(), s.Off}, LocalSlot{s.N, d.TypeFloat32(), s.Off + 4} + return LocalSlot{s.N, dummyTypes.Float32, s.Off}, LocalSlot{s.N, dummyTypes.Float32, s.Off + 4} } func (d DummyFrontend) SplitInt64(s LocalSlot) (LocalSlot, LocalSlot) { if s.Type.IsSigned() { - return LocalSlot{s.N, d.TypeInt32(), s.Off + 4}, LocalSlot{s.N, d.TypeUInt32(), s.Off} + return LocalSlot{s.N, dummyTypes.Int32, s.Off + 4}, LocalSlot{s.N, dummyTypes.UInt32, s.Off} } - return LocalSlot{s.N, d.TypeUInt32(), s.Off + 4}, LocalSlot{s.N, d.TypeUInt32(), s.Off} + return LocalSlot{s.N, dummyTypes.UInt32, s.Off + 4}, LocalSlot{s.N, dummyTypes.UInt32, s.Off} } func (d DummyFrontend) SplitStruct(s LocalSlot, i int) LocalSlot { return LocalSlot{s.N, s.Type.FieldType(i), s.Off + s.Type.FieldOff(i)} @@ -101,21 +101,24 @@ func (d DummyFrontend) Warnl(_ src.XPos, msg string, args ...interface{}) { d.t func (d DummyFrontend) Debug_checknil() bool { return false } func (d DummyFrontend) Debug_wb() bool { return false } -func (d DummyFrontend) TypeBool() Type { return TypeBool } -func (d DummyFrontend) TypeInt8() Type { return TypeInt8 } -func (d DummyFrontend) TypeInt16() Type { return TypeInt16 } -func (d DummyFrontend) TypeInt32() Type { return TypeInt32 } -func (d DummyFrontend) TypeInt64() Type { return TypeInt64 } -func (d DummyFrontend) TypeUInt8() Type { return TypeUInt8 } -func (d DummyFrontend) TypeUInt16() Type { return TypeUInt16 } -func (d DummyFrontend) TypeUInt32() Type { return TypeUInt32 } -func (d DummyFrontend) TypeUInt64() Type { return TypeUInt64 } -func (d DummyFrontend) TypeFloat32() Type { return TypeFloat32 } -func (d DummyFrontend) TypeFloat64() Type { return TypeFloat64 } -func (d DummyFrontend) TypeInt() Type { return TypeInt64 } -func (d DummyFrontend) TypeUintptr() Type { return TypeUInt64 } -func (d DummyFrontend) TypeString() Type { panic("unimplemented") } -func (d DummyFrontend) TypeBytePtr() Type { return TypeBytePtr } +var dummyTypes = Types{ + Bool: TypeBool, + Int8: TypeInt8, + Int16: TypeInt16, + Int32: TypeInt32, + Int64: TypeInt64, + UInt8: TypeUInt8, + UInt16: TypeUInt16, + UInt32: TypeUInt32, + UInt64: TypeUInt64, + Float32: TypeFloat32, + Float64: TypeFloat64, + Int: TypeInt64, + Uintptr: TypeUInt64, + String: nil, + BytePtr: TypeBytePtr, +} + func (d DummyFrontend) DerefItab(sym *obj.LSym, off int64) *obj.LSym { return nil } func (d DummyFrontend) CanSSA(t Type) bool { |