cmd/8g, cmd/internal/gc: fix GO386=387 build
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 <aram@mgk.ro>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
diff --git a/src/cmd/internal/gc/go.go b/src/cmd/internal/gc/go.go
index 6dd17c1..a6e525a 100644
--- a/src/cmd/internal/gc/go.go
+++ b/src/cmd/internal/gc/go.go
@@ -632,7 +632,7 @@
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 05642d6..4a9f895 100644
--- a/src/cmd/internal/gc/gsubr.go
+++ b/src/cmd/internal/gc/gsubr.go
@@ -692,6 +692,10 @@
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 9c09770..0d715cf 100644
--- a/src/cmd/internal/gc/lex.go
+++ b/src/cmd/internal/gc/lex.go
@@ -278,13 +278,13 @@
}
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)
}
}