Skip to content

Commit fe2cfb7

Browse files
committed
all: drop 387 support
My last 387 CL. So sad ... ... ... ... not! Fixes #40255 Change-Id: I8d4ddb744b234b8adc735db2f7c3c7b6d8bbdfa4 Reviewed-on: https://go-review.googlesource.com/c/go/+/258957 Trust: Keith Randall <[email protected]> Run-TryBot: Keith Randall <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]>
1 parent 41df0e2 commit fe2cfb7

36 files changed

+97
-796
lines changed

src/cmd/asm/internal/asm/endtoend_test.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,7 @@ func testErrors(t *testing.T, goarch, file string) {
353353
}
354354

355355
func Test386EndToEnd(t *testing.T) {
356-
defer func(old string) { objabi.GO386 = old }(objabi.GO386)
357-
for _, go386 := range []string{"387", "sse2"} {
358-
t.Logf("GO386=%v", go386)
359-
objabi.GO386 = go386
360-
testEndToEnd(t, "386", "386")
361-
}
356+
testEndToEnd(t, "386", "386")
362357
}
363358

364359
func TestARMEndToEnd(t *testing.T) {

src/cmd/compile/internal/gc/float_test.go

-19
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,9 @@ package gc
66

77
import (
88
"math"
9-
"os"
10-
"runtime"
119
"testing"
1210
)
1311

14-
// For GO386=387, make sure fucomi* opcodes are not used
15-
// for comparison operations.
16-
// Note that this test will fail only on a Pentium MMX
17-
// processor (with GOARCH=386 GO386=387), as it just runs
18-
// some code and looks for an unimplemented instruction fault.
19-
2012
//go:noinline
2113
func compare1(a, b float64) bool {
2214
return a < b
@@ -137,9 +129,6 @@ func TestFloatCompareFolded(t *testing.T) {
137129
}
138130
}
139131

140-
// For GO386=387, make sure fucomi* opcodes are not used
141-
// for float->int conversions.
142-
143132
//go:noinline
144133
func cvt1(a float64) uint64 {
145134
return uint64(a)
@@ -370,14 +359,6 @@ func TestFloat32StoreToLoadConstantFold(t *testing.T) {
370359
// are not converted to quiet NaN (qNaN) values during compilation.
371360
// See issue #27193 for more information.
372361

373-
// TODO: this method for detecting 387 won't work if the compiler has been
374-
// built using GOARCH=386 GO386=387 and either the target is a different
375-
// architecture or the GO386=387 environment variable is not set when the
376-
// test is run.
377-
if runtime.GOARCH == "386" && os.Getenv("GO386") == "387" {
378-
t.Skip("signaling NaNs are not propagated on 387 (issue #27516)")
379-
}
380-
381362
// signaling NaNs
382363
{
383364
const nan = uint32(0x7f800001) // sNaN

src/cmd/compile/internal/gc/go.go

-5
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ type Arch struct {
259259

260260
REGSP int
261261
MAXWIDTH int64
262-
Use387 bool // should 386 backend use 387 FP instructions instead of sse2.
263262
SoftFloat bool
264263

265264
PadFrame func(int64) int64
@@ -328,10 +327,6 @@ var (
328327
BoundsCheckFunc [ssa.BoundsKindCount]*obj.LSym
329328
ExtendCheckFunc [ssa.BoundsKindCount]*obj.LSym
330329

331-
// GO386=387
332-
ControlWord64trunc,
333-
ControlWord32 *obj.LSym
334-
335330
// Wasm
336331
WasmMove,
337332
WasmZero,

src/cmd/compile/internal/gc/ssa.go

+1-14
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ func initssaconfig() {
6262
_ = types.NewPtr(types.Errortype) // *error
6363
types.NewPtrCacheEnabled = false
6464
ssaConfig = ssa.NewConfig(thearch.LinkArch.Name, *types_, Ctxt, Debug['N'] == 0)
65-
if thearch.LinkArch.Name == "386" {
66-
ssaConfig.Set387(thearch.Use387)
67-
}
6865
ssaConfig.SoftFloat = thearch.SoftFloat
6966
ssaConfig.Race = flag_race
7067
ssaCaches = make([]ssa.Cache, nBackendWorkers)
@@ -175,10 +172,6 @@ func initssaconfig() {
175172
ExtendCheckFunc[ssa.BoundsSlice3CU] = sysvar("panicExtendSlice3CU")
176173
}
177174

178-
// GO386=387 runtime definitions
179-
ControlWord64trunc = sysvar("controlWord64trunc") // uint16
180-
ControlWord32 = sysvar("controlWord32") // uint16
181-
182175
// Wasm (all asm funcs with special ABIs)
183176
WasmMove = sysvar("wasmMove")
184177
WasmZero = sysvar("wasmZero")
@@ -5946,9 +5939,7 @@ type SSAGenState struct {
59465939
// bstart remembers where each block starts (indexed by block ID)
59475940
bstart []*obj.Prog
59485941

5949-
// 387 port: maps from SSE registers (REG_X?) to 387 registers (REG_F?)
5950-
SSEto387 map[int16]int16
5951-
// Some architectures require a 64-bit temporary for FP-related register shuffling. Examples include x86-387, PPC, and Sparc V8.
5942+
// Some architectures require a 64-bit temporary for FP-related register shuffling. Examples include PPC and Sparc V8.
59525943
ScratchFpMem *Node
59535944

59545945
maxarg int64 // largest frame size for arguments to calls made by the function
@@ -6115,10 +6106,6 @@ func genssa(f *ssa.Func, pp *Progs) {
61156106
progToBlock[s.pp.next] = f.Blocks[0]
61166107
}
61176108

6118-
if thearch.Use387 {
6119-
s.SSEto387 = map[int16]int16{}
6120-
}
6121-
61226109
s.ScratchFpMem = e.scratchFpMem
61236110

61246111
if Ctxt.Flag_locationlists {

src/cmd/compile/internal/ssa/config.go

-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ type Config struct {
3838
useSSE bool // Use SSE for non-float operations
3939
useAvg bool // Use optimizations that need Avg* operations
4040
useHmul bool // Use optimizations that need Hmul* operations
41-
use387 bool // GO386=387
4241
SoftFloat bool //
4342
Race bool // race detector enabled
4443
NeedsFpScratch bool // No direct move between GP and FP register sets
@@ -387,9 +386,4 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config
387386
return c
388387
}
389388

390-
func (c *Config) Set387(b bool) {
391-
c.NeedsFpScratch = b
392-
c.use387 = b
393-
}
394-
395389
func (c *Config) Ctxt() *obj.Link { return c.ctxt }

src/cmd/compile/internal/ssa/gen/386.rules

+4-6
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@
3838
(Xor(32|16|8) ...) => (XORL ...)
3939

4040
(Neg(32|16|8) ...) => (NEGL ...)
41-
(Neg32F x) && !config.use387 => (PXOR x (MOVSSconst <typ.Float32> [float32(math.Copysign(0, -1))]))
42-
(Neg64F x) && !config.use387 => (PXOR x (MOVSDconst <typ.Float64> [math.Copysign(0, -1)]))
43-
(Neg32F x) && config.use387 => (FCHS x)
44-
(Neg64F x) && config.use387 => (FCHS x)
41+
(Neg32F x) => (PXOR x (MOVSSconst <typ.Float32> [float32(math.Copysign(0, -1))]))
42+
(Neg64F x) => (PXOR x (MOVSDconst <typ.Float64> [math.Copysign(0, -1)]))
4543

4644
(Com(32|16|8) ...) => (NOTL ...)
4745

@@ -670,8 +668,8 @@
670668

671669
// Merge load/store to op
672670
((ADD|AND|OR|XOR|SUB|MUL)L x l:(MOVLload [off] {sym} ptr mem)) && canMergeLoadClobber(v, l, x) && clobber(l) => ((ADD|AND|OR|XOR|SUB|MUL)Lload x [off] {sym} ptr mem)
673-
((ADD|SUB|MUL|DIV)SD x l:(MOVSDload [off] {sym} ptr mem)) && canMergeLoadClobber(v, l, x) && !config.use387 && clobber(l) => ((ADD|SUB|MUL|DIV)SDload x [off] {sym} ptr mem)
674-
((ADD|SUB|MUL|DIV)SS x l:(MOVSSload [off] {sym} ptr mem)) && canMergeLoadClobber(v, l, x) && !config.use387 && clobber(l) => ((ADD|SUB|MUL|DIV)SSload x [off] {sym} ptr mem)
671+
((ADD|SUB|MUL|DIV)SD x l:(MOVSDload [off] {sym} ptr mem)) && canMergeLoadClobber(v, l, x) && clobber(l) => ((ADD|SUB|MUL|DIV)SDload x [off] {sym} ptr mem)
672+
((ADD|SUB|MUL|DIV)SS x l:(MOVSSload [off] {sym} ptr mem)) && canMergeLoadClobber(v, l, x) && clobber(l) => ((ADD|SUB|MUL|DIV)SSload x [off] {sym} ptr mem)
675673
(MOVLstore {sym} [off] ptr y:((ADD|AND|OR|XOR)Lload x [off] {sym} ptr mem) mem) && y.Uses==1 && clobber(y) => ((ADD|AND|OR|XOR)Lmodify [off] {sym} ptr x mem)
676674
(MOVLstore {sym} [off] ptr y:((ADD|SUB|AND|OR|XOR)L l:(MOVLload [off] {sym} ptr mem) x) mem) && y.Uses==1 && l.Uses==1 && clobber(y, l) =>
677675
((ADD|SUB|AND|OR|XOR)Lmodify [off] {sym} ptr x mem)

src/cmd/compile/internal/ssa/gen/386Ops.go

-14
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,6 @@ var regNames386 = []string{
5151
"SB",
5252
}
5353

54-
// Notes on 387 support.
55-
// - The 387 has a weird stack-register setup for floating-point registers.
56-
// We use these registers when SSE registers are not available (when GO386=387).
57-
// - We use the same register names (X0-X7) but they refer to the 387
58-
// floating-point registers. That way, most of the SSA backend is unchanged.
59-
// - The instruction generation pass maintains an SSE->387 register mapping.
60-
// This mapping is updated whenever the FP stack is pushed or popped so that
61-
// we can always find a given SSE register even when the TOS pointer has changed.
62-
// - To facilitate the mapping from SSE to 387, we enforce that
63-
// every basic block starts and ends with an empty floating-point stack.
64-
6554
func init() {
6655
// Make map from reg names to reg integers.
6756
if len(regNames386) > 64 {
@@ -552,9 +541,6 @@ func init() {
552541
{name: "FlagGT_UGT"}, // signed > and unsigned <
553542
{name: "FlagGT_ULT"}, // signed > and unsigned >
554543

555-
// Special op for -x on 387
556-
{name: "FCHS", argLength: 1, reg: fp11},
557-
558544
// Special ops for PIC floating-point constants.
559545
// MOVSXconst1 loads the address of the constant-pool entry into a register.
560546
// MOVSXconst2 loads the constant from that address.

src/cmd/compile/internal/ssa/opGen.go

-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/compile/internal/ssa/regalloc.go

-14
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,6 @@ func (s *regAllocState) init(f *Func) {
625625
s.f.fe.Fatalf(src.NoXPos, "arch %s not implemented", s.f.Config.arch)
626626
}
627627
}
628-
if s.f.Config.use387 {
629-
s.allocatable &^= 1 << 15 // X7 disallowed (one 387 register is used as scratch space during SSE->387 generation in ../x86/387.go)
630-
}
631628

632629
// Linear scan register allocation can be influenced by the order in which blocks appear.
633630
// Decouple the register allocation order from the generated block order.
@@ -1024,9 +1021,6 @@ func (s *regAllocState) regalloc(f *Func) {
10241021
if phiRegs[i] != noRegister {
10251022
continue
10261023
}
1027-
if s.f.Config.use387 && v.Type.IsFloat() {
1028-
continue // 387 can't handle floats in registers between blocks
1029-
}
10301024
m := s.compatRegs(v.Type) &^ phiUsed &^ s.used
10311025
if m != 0 {
10321026
r := pickReg(m)
@@ -1528,11 +1522,6 @@ func (s *regAllocState) regalloc(f *Func) {
15281522
s.freeUseRecords = u
15291523
}
15301524

1531-
// Spill any values that can't live across basic block boundaries.
1532-
if s.f.Config.use387 {
1533-
s.freeRegs(s.f.Config.fpRegMask)
1534-
}
1535-
15361525
// If we are approaching a merge point and we are the primary
15371526
// predecessor of it, find live values that we use soon after
15381527
// the merge point and promote them to registers now.
@@ -1562,9 +1551,6 @@ func (s *regAllocState) regalloc(f *Func) {
15621551
continue
15631552
}
15641553
v := s.orig[vid]
1565-
if s.f.Config.use387 && v.Type.IsFloat() {
1566-
continue // 387 can't handle floats in registers between blocks
1567-
}
15681554
m := s.compatRegs(v.Type) &^ s.used
15691555
if m&^desired.avoid != 0 {
15701556
m &^= desired.avoid

0 commit comments

Comments
 (0)