From: Paul E. Murphy Date: Thu, 10 Mar 2022 17:51:00 +0000 (-0600) Subject: cmd/dist: define GOPPC64_{cpu} for PPC64 targets X-Git-Tag: go1.20rc1~318 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e87e7997677b66b4afd2d4f23d35f561127dac02;p=gostls13.git cmd/dist: define GOPPC64_{cpu} for PPC64 targets This can be used to provide better instruction selection for assembly implementations without having to implement two variants and dynamic runtime selections when a newer GOPPC64 value is used. Change-Id: I4331037d57b128137280aa7904d08d362391f81e Reviewed-on: https://go-review.googlesource.com/c/go/+/449115 Run-TryBot: Cherry Mui TryBot-Result: Gopher Robot Reviewed-by: Michael Knyszek Reviewed-by: Lynn Boger Reviewed-by: Cherry Mui --- diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index dfa67290fa..47b25bc943 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -831,6 +831,19 @@ func runInstall(pkg string, ch chan struct{}) { // Define GOMIPS64_value from gomips64. asmArgs = append(asmArgs, "-D", "GOMIPS64_"+gomips64) } + if goarch == "ppc64" || goarch == "ppc64le" { + // We treat each powerpc version as a superset of functionality. + switch goppc64 { + case "power10": + asmArgs = append(asmArgs, "-D", "GOPPC64_power10") + fallthrough + case "power9": + asmArgs = append(asmArgs, "-D", "GOPPC64_power9") + fallthrough + default: // This should always be power8. + asmArgs = append(asmArgs, "-D", "GOPPC64_power8") + } + } goasmh := pathf("%s/go_asm.h", workdir) if IsRuntimePackagePath(pkg) { asmArgs = append(asmArgs, "-compiling-runtime") diff --git a/src/cmd/go/internal/work/gc.go b/src/cmd/go/internal/work/gc.go index 036a188027..494da022e9 100644 --- a/src/cmd/go/internal/work/gc.go +++ b/src/cmd/go/internal/work/gc.go @@ -392,6 +392,21 @@ func asmArgs(a *Action, p *load.Package) []any { args = append(args, "-D", "GOMIPS64_"+cfg.GOMIPS64) } + if cfg.Goarch == "ppc64" || cfg.Goarch == "ppc64le" { + // Define GOPPC64_power8..N from cfg.PPC64. + // We treat each powerpc version as a superset of functionality. + switch cfg.GOPPC64 { + case "power10": + args = append(args, "-D", "GOPPC64_power10") + fallthrough + case "power9": + args = append(args, "-D", "GOPPC64_power9") + fallthrough + default: // This should always be power8. + args = append(args, "-D", "GOPPC64_power8") + } + } + return args }