diff options
author | Matthew Dempsky <mdempsky@google.com> | 2017-03-17 13:35:31 -0700 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2017-03-17 22:10:53 +0000 |
commit | 3e2f980e2721c05eb4a324b1e26080e082568f88 (patch) | |
tree | 8c7c239ed1251826459575fd13d5a0ef31cf7a2a /src/cmd/compile/main.go | |
parent | aea44109cf23946332319ba51a4a373a9de432e6 (diff) | |
download | go-3e2f980e2721c05eb4a324b1e26080e082568f88.tar.gz go-3e2f980e2721c05eb4a324b1e26080e082568f88.zip |
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>
Diffstat (limited to 'src/cmd/compile/main.go')
-rw-r--r-- | src/cmd/compile/main.go | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/cmd/compile/main.go b/src/cmd/compile/main.go index c3c0b6a068..e67e862dd5 100644 --- a/src/cmd/compile/main.go +++ b/src/cmd/compile/main.go @@ -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) } |