]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: add processor level selection support to ppc64{,le}
authorCarlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Fri, 11 Jan 2019 19:16:28 +0000 (17:16 -0200)
committerLynn Boger <laboger@linux.vnet.ibm.com>
Wed, 13 Mar 2019 14:44:02 +0000 (14:44 +0000)
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: David Chase <drchase@google.com>
doc/install-source.html
src/cmd/dist/build.go
src/cmd/dist/buildruntime.go
src/cmd/go/internal/cfg/cfg.go
src/cmd/go/internal/envcmd/env.go
src/cmd/internal/objabi/util.go
test/run.go

index bbe7cdfd0095cbac9d8208db465794a307e05dbe..c11151be64154f8daefa40365e74cb0d2dae305f 100644 (file)
@@ -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>
index 87739a510da60f833b93cbf86ec761db1f708bd4..539227232ab5e227d3250c18c6025201a5b67201 100644 (file)
@@ -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 := ":"
index d5462792f827b8fe3a055e122a8eab8d813345ca..27449515976b36449ecd7a92c3341d3a98fbb832 100644 (file)
@@ -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)
index 31c1fb84ef2d8c0ca12e313e052663a47d4e59e7..80a154b066d5f1e27ba09c0b1bbfa3d9e88347e1 100644 (file)
@@ -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.
index ae98d3999a1fa429c8105aa0968b00d3a2812545..08291dfb14c769ea513309462595ee407b702230 100644 (file)
@@ -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)
index 907f75cb4f8f675bc092244b2752c3a56a27743a..665c8b3be60ff9db50ce5d75267e65a20cb1dd1f 100644 (file)
@@ -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)
 }
index ad38d420c9bbc8ff5abb724a7a3c56e89b2a7981..7a764d5f8d4130bec35f7335aac79a5af4254bb3 100644 (file)
@@ -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":   {},
        }
 )