[go] cmd/dist: define GOPPC64_{cpu} for PPC64 targets

25 views
Skip to first unread message

Paul Murphy (Gerrit)

unread,
Nov 10, 2022, 3:13:06 PM11/10/22
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Michael Knyszek, Lynn Boger, Gopher Robot, Cherry Mui, golang-co...@googlegroups.com

Paul Murphy submitted this change.

View Change


Approvals: Michael Knyszek: Looks good to me, but someone else must approve Lynn Boger: Looks good to me, approved Cherry Mui: Looks good to me, but someone else must approve; Run TryBots Gopher Robot: TryBots succeeded
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 <cher...@google.com>
TryBot-Result: Gopher Robot <go...@golang.org>
Reviewed-by: Michael Knyszek <mkny...@google.com>
Reviewed-by: Lynn Boger <lab...@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cher...@google.com>
---
M src/cmd/dist/build.go
M src/cmd/go/internal/work/gc.go
2 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
index dfa6729..47b25bc 100644
--- a/src/cmd/dist/build.go
+++ b/src/cmd/dist/build.go
@@ -831,6 +831,19 @@
// 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 036a188..494da02 100644
--- a/src/cmd/go/internal/work/gc.go
+++ b/src/cmd/go/internal/work/gc.go
@@ -392,6 +392,21 @@
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
}


To view, visit change 449115. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4331037d57b128137280aa7904d08d362391f81e
Gerrit-Change-Number: 449115
Gerrit-PatchSet: 2
Gerrit-Owner: Paul Murphy <mu...@ibm.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Lynn Boger <lab...@linux.vnet.ibm.com>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Reviewer: Paul Murphy <mu...@ibm.com>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages