From 8fc73a39efe152f45cdc377351547279d9e11a5b Mon Sep 17 00:00:00 2001 From: Dave Cheney Date: Tue, 24 Mar 2015 22:16:48 +1100 Subject: [PATCH] cmd/8g, cmd/internal/gc: fix GO386=387 build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adjust Thearch.FREG_MIN/MAX when using non sse2 mode in 8g. Also, gc.Use_sse is treated as a bool, so make it a bool. Change-Id: I840411605344bb31c32f492b3e6729166c084f0c Reviewed-on: https://go-review.googlesource.com/7993 Reviewed-by: Aram Hăvărneanu Reviewed-by: Rob Pike Reviewed-by: Dave Cheney Run-TryBot: Dave Cheney --- src/cmd/8g/galign.go | 12 ++++++++++-- src/cmd/8g/ggen.go | 4 ++-- src/cmd/8g/gsubr.go | 4 ++-- src/cmd/internal/gc/go.go | 2 +- src/cmd/internal/gc/gsubr.go | 4 ++++ src/cmd/internal/gc/lex.go | 14 +++++++------- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/cmd/8g/galign.go b/src/cmd/8g/galign.go index f5ff825e0c..e92802d0b5 100644 --- a/src/cmd/8g/galign.go +++ b/src/cmd/8g/galign.go @@ -50,8 +50,16 @@ func main() { gc.Thearch.REGRETURN = x86.REG_AX gc.Thearch.REGMIN = x86.REG_AX gc.Thearch.REGMAX = x86.REG_DI - gc.Thearch.FREGMIN = x86.REG_X0 - gc.Thearch.FREGMAX = x86.REG_X7 + switch v := obj.Getgo386(); v { + case "387": + gc.Thearch.FREGMIN = x86.REG_F0 + gc.Thearch.FREGMAX = x86.REG_F7 + case "sse2": + gc.Thearch.FREGMIN = x86.REG_X0 + gc.Thearch.FREGMAX = x86.REG_X7 + default: + gc.Fatal("unsupported setting GO386=%s", v) + } gc.Thearch.MAXWIDTH = MAXWIDTH gc.Thearch.ReservedRegs = resvd diff --git a/src/cmd/8g/ggen.go b/src/cmd/8g/ggen.go index 69c60288a2..a55c2d81b0 100644 --- a/src/cmd/8g/ggen.go +++ b/src/cmd/8g/ggen.go @@ -617,7 +617,7 @@ func cgen_float(n *gc.Node, res *gc.Node) { return } - if gc.Use_sse != 0 { + if gc.Use_sse { cgen_floatsse(n, res) } else { cgen_float387(n, res) @@ -761,7 +761,7 @@ func bgen_float(n *gc.Node, true_ int, likely int, to *obj.Prog) { var et int var n2 gc.Node var ax gc.Node - if gc.Use_sse != 0 { + if gc.Use_sse { if nl.Addable == 0 { var n1 gc.Node gc.Tempname(&n1, nl.Type) diff --git a/src/cmd/8g/gsubr.go b/src/cmd/8g/gsubr.go index fa28b6dac1..7ca4dacf91 100644 --- a/src/cmd/8g/gsubr.go +++ b/src/cmd/8g/gsubr.go @@ -402,7 +402,7 @@ func foptoas(op int, t *gc.Type, flg int) int { a := obj.AXXX et := int(gc.Simtype[t.Etype]) - if gc.Use_sse != 0 { + if gc.Use_sse { switch uint32(op)<<16 | uint32(et) { default: gc.Fatal("foptoas-sse: no entry %v-%v", gc.Oconv(int(op), 0), gc.Tconv(t, 0)) @@ -1036,7 +1036,7 @@ func floatmove(f *gc.Node, t *gc.Node) { switch uint32(ft)<<16 | uint32(tt) { default: - if gc.Use_sse != 0 { + if gc.Use_sse { floatmove_sse(f, t) } else { floatmove_387(f, t) diff --git a/src/cmd/internal/gc/go.go b/src/cmd/internal/gc/go.go index 6dd17c18bc..a6e525aba1 100644 --- a/src/cmd/internal/gc/go.go +++ b/src/cmd/internal/gc/go.go @@ -632,7 +632,7 @@ var typesw *Node var nblank *Node -var Use_sse int +var Use_sse bool // should we generate SSE2 instructions for 386 targets var hunk string diff --git a/src/cmd/internal/gc/gsubr.go b/src/cmd/internal/gc/gsubr.go index 05642d6bfd..4a9f895265 100644 --- a/src/cmd/internal/gc/gsubr.go +++ b/src/cmd/internal/gc/gsubr.go @@ -692,6 +692,10 @@ Switch: Fatal("out of fixed registers") case TFLOAT32, TFLOAT64: + if Thearch.Thechar == '8' && !Use_sse { + i = Thearch.FREGMIN // x86.REG_F0 + break Switch + } if o != nil && o.Op == OREGISTER { i = int(o.Val.U.Reg) if Thearch.FREGMIN <= i && i <= Thearch.FREGMAX { diff --git a/src/cmd/internal/gc/lex.go b/src/cmd/internal/gc/lex.go index 9c097706fb..0d715cf347 100644 --- a/src/cmd/internal/gc/lex.go +++ b/src/cmd/internal/gc/lex.go @@ -278,13 +278,13 @@ func Main() { } if Thearch.Thechar == '8' { - p := obj.Getgo386() - if p == "387" { - Use_sse = 0 - } else if p == "sse2" { - Use_sse = 1 - } else { - log.Fatalf("unsupported setting GO386=%s", p) + switch v := obj.Getgo386(); v { + case "387": + Use_sse = false + case "sse2": + Use_sse = true + default: + log.Fatalf("unsupported setting GO386=%s", v) } }