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.
</p>
</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>
<p>
......
......@@ -33,6 +33,7 @@ var (
go386 string
gomips string
gomips64 string
goppc64 string
goroot string
goroot_final string
goextlinkenabled string
......@@ -159,6 +160,12 @@ func xinit() {
}
gomips64 = b
b = os.Getenv("GOPPC64")
if b == "" {
b = "power8"
}
goppc64 = b
if p := pathf("%s/src/all.bash", goroot); !isfile(p) {
fatalf("$GOROOT is not set correctly or not exported\n"+
"\tGOROOT=%s\n"+
......@@ -219,6 +226,7 @@ func xinit() {
os.Setenv("GOOS", goos)
os.Setenv("GOMIPS", gomips)
os.Setenv("GOMIPS64", gomips64)
os.Setenv("GOPPC64", goppc64)
os.Setenv("GOROOT", goroot)
os.Setenv("GOROOT_FINAL", goroot_final)
......@@ -1117,6 +1125,9 @@ func cmdenv() {
if goarch == "mips64" || goarch == "mips64le" {
xprintf(format, "GOMIPS64", gomips64)
}
if goarch == "ppc64" || goarch == "ppc64le" {
xprintf(format, "GOPPC64", goppc64)
}
if *path {
sep := ":"
......
......@@ -45,6 +45,7 @@ func mkzversion(dir, file string) {
// const defaultGOARM = <goarm>
// const defaultGOMIPS = <gomips>
// const defaultGOMIPS64 = <gomips64>
// const defaultGOPPC64 = <goppc64>
// const defaultGOOS = runtime.GOOS
// const defaultGOARCH = runtime.GOARCH
// const defaultGO_EXTLINK_ENABLED = <goextlinkenabled>
......@@ -73,6 +74,7 @@ func mkzbootstrap(file string) {
fmt.Fprintf(&buf, "const defaultGOARM = `%s`\n", goarm)
fmt.Fprintf(&buf, "const defaultGOMIPS = `%s`\n", gomips)
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 defaultGOARCH = runtime.GOARCH\n")
fmt.Fprintf(&buf, "const defaultGO_EXTLINK_ENABLED = `%s`\n", goextlinkenabled)
......
......@@ -104,6 +104,7 @@ var (
GO386 = objabi.GO386
GOMIPS = objabi.GOMIPS
GOMIPS64 = objabi.GOMIPS64
GOPPC64 = fmt.Sprintf("%s%d", "power", objabi.GOPPC64)
)
// Update build context to use our computed GOROOT.
......
......@@ -81,6 +81,8 @@ func MkEnv() []cfg.EnvVar {
env = append(env, cfg.EnvVar{Name: "GOMIPS", Value: cfg.GOMIPS})
case "mips64", "mips64le":
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)
......
......@@ -28,6 +28,7 @@ var (
GOARM = goarm()
GOMIPS = gomips()
GOMIPS64 = gomips64()
GOPPC64 = goppc64()
GO_LDSO = defaultGO_LDSO
Version = version
)
......@@ -64,6 +65,17 @@ func gomips64() string {
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 {
return envOr("GO_EXTLINK_ENABLED", defaultGO_EXTLINK_ENABLED)
}
......
......@@ -1382,8 +1382,8 @@ var (
"arm64": {},
"mips": {"GOMIPS", "hardfloat", "softfloat"},
"mips64": {"GOMIPS64", "hardfloat", "softfloat"},
"ppc64": {},
"ppc64le": {},
"ppc64": {"GOPPC64", "power8", "power9"},
"ppc64le": {"GOPPC64", "power8", "power9"},
"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