]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: define GOPPC64_{cpu} for PPC64 targets
authorPaul E. Murphy <murp@ibm.com>
Thu, 10 Mar 2022 17:51:00 +0000 (11:51 -0600)
committerPaul Murphy <murp@ibm.com>
Thu, 10 Nov 2022 20:13:00 +0000 (20:13 +0000)
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 <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/dist/build.go
src/cmd/go/internal/work/gc.go

index dfa67290fa68421296206c9cd3c784704272ecd9..47b25bc9436b5903e1b35b851926863ddd746106 100644 (file)
@@ -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")
index 036a1880275f57d9413bc603fffdb9734b8f07d2..494da022e98d140431a4ad816ffa9f37066a5f47 100644 (file)
@@ -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
 }