cmd/compile: eliminate direct uses of gc.Thearch in backends

This CL changes the GOARCH.Init functions to take gc.Thearch as a
parameter, which gc.Main supplies.

Additionally, the x86 backend is refactored to decide within Init
whether to use the 387 or SSE2 instruction generators, rather than for
each individual SSA Value/Block.

Passes toolstash-check -all.

Change-Id: Ie6305a6cd6f6ab4e89ecbb3cbbaf5ffd57057a24
Reviewed-on: https://go-review.googlesource.com/38301
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
Matthew Dempsky 2017-03-17 13:35:31 -07:00
parent aea44109cf
commit 3e2f980e27
20 changed files with 129 additions and 160 deletions

View file

@ -20,33 +20,32 @@ import (
"os"
)
var archInits = map[string]func(*gc.Arch){
"386": x86.Init,
"amd64": amd64.Init,
"amd64p32": amd64.Init,
"arm": arm.Init,
"arm64": arm64.Init,
"mips": mips.Init,
"mipsle": mips.Init,
"mips64": mips64.Init,
"mips64le": mips64.Init,
"ppc64": ppc64.Init,
"ppc64le": ppc64.Init,
"s390x": s390x.Init,
}
func main() {
// disable timestamps for reproducible output
log.SetFlags(0)
log.SetPrefix("compile: ")
switch obj.GOARCH {
default:
archInit, ok := archInits[obj.GOARCH]
if !ok {
fmt.Fprintf(os.Stderr, "compile: unknown architecture %q\n", obj.GOARCH)
os.Exit(2)
case "386":
x86.Init()
case "amd64", "amd64p32":
amd64.Init()
case "arm":
arm.Init()
case "arm64":
arm64.Init()
case "mips", "mipsle":
mips.Init()
case "mips64", "mips64le":
mips64.Init()
case "ppc64", "ppc64le":
ppc64.Init()
case "s390x":
s390x.Init()
}
gc.Main()
gc.Main(archInit)
gc.Exit(0)
}