Commit 4ba69a9a authored by Carlos Eduardo Seo's avatar Carlos Eduardo Seo Committed by Lynn Boger

cmd/compile: add processor level selection support to ppc64{,le}

ppc64{,le} processor level selection allows the compiler to generate instructions
targeting newer processors and processor-specific optimizations without breaking
compatibility with our current baseline. This feature introduces a new environment
variable, GOPPC64.

GOPPC64 is a GOARCH=ppc64{,le} specific option, for a choice between different
processor levels (i.e. Instruction Set Architecture versions) for which the
compiler will target. The default is 'power8'.

Change-Id: Ic152e283ae1c47084ece4346fa002a3eabb3bb9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/163758
Run-TryBot: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarDavid Chase <drchase@google.com>
parent 82af9e67
...@@ -627,6 +627,17 @@ contains further details regarding Go's ARM support. ...@@ -627,6 +627,17 @@ contains further details regarding Go's ARM support.
</p> </p>
</li> </li>
<li><code>$GOPPC64</code> (for <code>ppc64</code> and <code>ppc64le</code> only)
<p>
This variable sets the processor level (i.e. Instruction Set Architecture version)
for which the compiler will target. The default is <code>power8</code>.
</p>
<ul>
<li><code>GOPPC64=power8</code>: generate ISA v2.07 instructions</li>
<li><code>GOPPC64=power9</code>: generate ISA v3.00 instructions</li>
</ul>
</li>
</ul> </ul>
<p> <p>
......
...@@ -33,6 +33,7 @@ var ( ...@@ -33,6 +33,7 @@ var (
go386 string go386 string
gomips string gomips string
gomips64 string gomips64 string
goppc64 string
goroot string goroot string
goroot_final string goroot_final string
goextlinkenabled string goextlinkenabled string
...@@ -159,6 +160,12 @@ func xinit() { ...@@ -159,6 +160,12 @@ func xinit() {
} }
gomips64 = b gomips64 = b
b = os.Getenv("GOPPC64")
if b == "" {
b = "power8"
}
goppc64 = b
if p := pathf("%s/src/all.bash", goroot); !isfile(p) { if p := pathf("%s/src/all.bash", goroot); !isfile(p) {
fatalf("$GOROOT is not set correctly or not exported\n"+ fatalf("$GOROOT is not set correctly or not exported\n"+
"\tGOROOT=%s\n"+ "\tGOROOT=%s\n"+
...@@ -219,6 +226,7 @@ func xinit() { ...@@ -219,6 +226,7 @@ func xinit() {
os.Setenv("GOOS", goos) os.Setenv("GOOS", goos)
os.Setenv("GOMIPS", gomips) os.Setenv("GOMIPS", gomips)
os.Setenv("GOMIPS64", gomips64) os.Setenv("GOMIPS64", gomips64)
os.Setenv("GOPPC64", goppc64)
os.Setenv("GOROOT", goroot) os.Setenv("GOROOT", goroot)
os.Setenv("GOROOT_FINAL", goroot_final) os.Setenv("GOROOT_FINAL", goroot_final)
...@@ -1117,6 +1125,9 @@ func cmdenv() { ...@@ -1117,6 +1125,9 @@ func cmdenv() {
if goarch == "mips64" || goarch == "mips64le" { if goarch == "mips64" || goarch == "mips64le" {
xprintf(format, "GOMIPS64", gomips64) xprintf(format, "GOMIPS64", gomips64)
} }
if goarch == "ppc64" || goarch == "ppc64le" {
xprintf(format, "GOPPC64", goppc64)
}
if *path { if *path {
sep := ":" sep := ":"
......
...@@ -45,6 +45,7 @@ func mkzversion(dir, file string) { ...@@ -45,6 +45,7 @@ func mkzversion(dir, file string) {
// const defaultGOARM = <goarm> // const defaultGOARM = <goarm>
// const defaultGOMIPS = <gomips> // const defaultGOMIPS = <gomips>
// const defaultGOMIPS64 = <gomips64> // const defaultGOMIPS64 = <gomips64>
// const defaultGOPPC64 = <goppc64>
// const defaultGOOS = runtime.GOOS // const defaultGOOS = runtime.GOOS
// const defaultGOARCH = runtime.GOARCH // const defaultGOARCH = runtime.GOARCH
// const defaultGO_EXTLINK_ENABLED = <goextlinkenabled> // const defaultGO_EXTLINK_ENABLED = <goextlinkenabled>
...@@ -73,6 +74,7 @@ func mkzbootstrap(file string) { ...@@ -73,6 +74,7 @@ func mkzbootstrap(file string) {
fmt.Fprintf(&buf, "const defaultGOARM = `%s`\n", goarm) fmt.Fprintf(&buf, "const defaultGOARM = `%s`\n", goarm)
fmt.Fprintf(&buf, "const defaultGOMIPS = `%s`\n", gomips) fmt.Fprintf(&buf, "const defaultGOMIPS = `%s`\n", gomips)
fmt.Fprintf(&buf, "const defaultGOMIPS64 = `%s`\n", gomips64) fmt.Fprintf(&buf, "const defaultGOMIPS64 = `%s`\n", gomips64)
fmt.Fprintf(&buf, "const defaultGOPPC64 = `%s`\n", goppc64)
fmt.Fprintf(&buf, "const defaultGOOS = runtime.GOOS\n") fmt.Fprintf(&buf, "const defaultGOOS = runtime.GOOS\n")
fmt.Fprintf(&buf, "const defaultGOARCH = runtime.GOARCH\n") fmt.Fprintf(&buf, "const defaultGOARCH = runtime.GOARCH\n")
fmt.Fprintf(&buf, "const defaultGO_EXTLINK_ENABLED = `%s`\n", goextlinkenabled) fmt.Fprintf(&buf, "const defaultGO_EXTLINK_ENABLED = `%s`\n", goextlinkenabled)
......
...@@ -104,6 +104,7 @@ var ( ...@@ -104,6 +104,7 @@ var (
GO386 = objabi.GO386 GO386 = objabi.GO386
GOMIPS = objabi.GOMIPS GOMIPS = objabi.GOMIPS
GOMIPS64 = objabi.GOMIPS64 GOMIPS64 = objabi.GOMIPS64
GOPPC64 = fmt.Sprintf("%s%d", "power", objabi.GOPPC64)
) )
// Update build context to use our computed GOROOT. // Update build context to use our computed GOROOT.
......
...@@ -81,6 +81,8 @@ func MkEnv() []cfg.EnvVar { ...@@ -81,6 +81,8 @@ func MkEnv() []cfg.EnvVar {
env = append(env, cfg.EnvVar{Name: "GOMIPS", Value: cfg.GOMIPS}) env = append(env, cfg.EnvVar{Name: "GOMIPS", Value: cfg.GOMIPS})
case "mips64", "mips64le": case "mips64", "mips64le":
env = append(env, cfg.EnvVar{Name: "GOMIPS64", Value: cfg.GOMIPS64}) env = append(env, cfg.EnvVar{Name: "GOMIPS64", Value: cfg.GOMIPS64})
case "ppc64", "ppc64le":
env = append(env, cfg.EnvVar{Name: "GOPPC64", Value: cfg.GOPPC64})
} }
cc := cfg.DefaultCC(cfg.Goos, cfg.Goarch) cc := cfg.DefaultCC(cfg.Goos, cfg.Goarch)
......
...@@ -28,6 +28,7 @@ var ( ...@@ -28,6 +28,7 @@ var (
GOARM = goarm() GOARM = goarm()
GOMIPS = gomips() GOMIPS = gomips()
GOMIPS64 = gomips64() GOMIPS64 = gomips64()
GOPPC64 = goppc64()
GO_LDSO = defaultGO_LDSO GO_LDSO = defaultGO_LDSO
Version = version Version = version
) )
...@@ -64,6 +65,17 @@ func gomips64() string { ...@@ -64,6 +65,17 @@ func gomips64() string {
panic("unreachable") panic("unreachable")
} }
func goppc64() int {
switch v := envOr("GOPPC64", defaultGOPPC64); v {
case "power8":
return 8
case "power9":
return 9
}
log.Fatalf("Invalid GOPPC64 value. Must be power8 or power9.")
panic("unreachable")
}
func Getgoextlinkenabled() string { func Getgoextlinkenabled() string {
return envOr("GO_EXTLINK_ENABLED", defaultGO_EXTLINK_ENABLED) return envOr("GO_EXTLINK_ENABLED", defaultGO_EXTLINK_ENABLED)
} }
......
...@@ -1382,8 +1382,8 @@ var ( ...@@ -1382,8 +1382,8 @@ var (
"arm64": {}, "arm64": {},
"mips": {"GOMIPS", "hardfloat", "softfloat"}, "mips": {"GOMIPS", "hardfloat", "softfloat"},
"mips64": {"GOMIPS64", "hardfloat", "softfloat"}, "mips64": {"GOMIPS64", "hardfloat", "softfloat"},
"ppc64": {}, "ppc64": {"GOPPC64", "power8", "power9"},
"ppc64le": {}, "ppc64le": {"GOPPC64", "power8", "power9"},
"s390x": {}, "s390x": {},
} }
) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment