aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/internal/cpu
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-02-11 14:53:56 -0800
committerIan Lance Taylor <iant@golang.org>2022-02-11 15:01:19 -0800
commit8dc2499aa62f768c6395c9754b8cabc1ce25c494 (patch)
tree43d7fd2bbfd7ad8c9625a718a5e8718889351994 /libgo/go/internal/cpu
parent9a56779dbc4e2d9c15be8d31e36f2f59be7331a8 (diff)
downloadgcc-8dc2499aa62f768c6395c9754b8cabc1ce25c494.zip
gcc-8dc2499aa62f768c6395c9754b8cabc1ce25c494.tar.gz
gcc-8dc2499aa62f768c6395c9754b8cabc1ce25c494.tar.bz2
libgo: update to Go1.18beta2
gotools/ * Makefile.am (go_cmd_cgo_files): Add ast_go118.go (check-go-tool): Copy golang.org/x/tools directories. * Makefile.in: Regenerate. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/384695
Diffstat (limited to 'libgo/go/internal/cpu')
-rw-r--r--libgo/go/internal/cpu/cpu.go10
-rw-r--r--libgo/go/internal/cpu/cpu_386.go7
-rw-r--r--libgo/go/internal/cpu/cpu_amd64.go7
-rw-r--r--libgo/go/internal/cpu/cpu_amd64p32.go7
-rw-r--r--libgo/go/internal/cpu/cpu_arm64_android.go1
-rw-r--r--libgo/go/internal/cpu/cpu_arm64_darwin.go1
-rw-r--r--libgo/go/internal/cpu/cpu_arm64_freebsd.go1
-rw-r--r--libgo/go/internal/cpu/cpu_arm64_hwcap.go1
-rw-r--r--libgo/go/internal/cpu/cpu_arm64_linux.go1
-rw-r--r--libgo/go/internal/cpu/cpu_arm64_other.go5
-rw-r--r--libgo/go/internal/cpu/cpu_mips64x.go1
-rw-r--r--libgo/go/internal/cpu/cpu_no_name.go1
-rw-r--r--libgo/go/internal/cpu/cpu_ppc64x.go1
-rw-r--r--libgo/go/internal/cpu/cpu_ppc64x_aix.go1
-rw-r--r--libgo/go/internal/cpu/cpu_ppc64x_linux.go1
-rw-r--r--libgo/go/internal/cpu/cpu_test.go23
-rw-r--r--libgo/go/internal/cpu/cpu_x86.go21
-rw-r--r--libgo/go/internal/cpu/cpu_x86_test.go23
18 files changed, 22 insertions, 91 deletions
diff --git a/libgo/go/internal/cpu/cpu.go b/libgo/go/internal/cpu/cpu.go
index dab5d06..3074534 100644
--- a/libgo/go/internal/cpu/cpu.go
+++ b/libgo/go/internal/cpu/cpu.go
@@ -36,7 +36,7 @@ var X86 struct {
HasOSXSAVE bool
HasPCLMULQDQ bool
HasPOPCNT bool
- HasSSE2 bool
+ HasRDTSCP bool
HasSSE3 bool
HasSSSE3 bool
HasSSE41 bool
@@ -136,7 +136,6 @@ type option struct {
Feature *bool
Specified bool // whether feature value was specified in GODEBUG
Enable bool // whether feature should be enabled
- Required bool // whether feature is mandatory and can not be disabled
}
// processOptions enables or disables CPU feature values based on the parsed env string.
@@ -179,7 +178,7 @@ field:
if key == "all" {
for i := range options {
options[i].Specified = true
- options[i].Enable = enable || options[i].Required
+ options[i].Enable = enable
}
continue field
}
@@ -205,11 +204,6 @@ field:
continue
}
- if !o.Enable && o.Required {
- print("GODEBUG: can not disable \"", o.Name, "\", required CPU feature\n")
- continue
- }
-
*o.Feature = o.Enable
}
}
diff --git a/libgo/go/internal/cpu/cpu_386.go b/libgo/go/internal/cpu/cpu_386.go
deleted file mode 100644
index 561c81f..0000000
--- a/libgo/go/internal/cpu/cpu_386.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package cpu
-
-const GOARCH = "386"
diff --git a/libgo/go/internal/cpu/cpu_amd64.go b/libgo/go/internal/cpu/cpu_amd64.go
deleted file mode 100644
index 9b00153..0000000
--- a/libgo/go/internal/cpu/cpu_amd64.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package cpu
-
-const GOARCH = "amd64"
diff --git a/libgo/go/internal/cpu/cpu_amd64p32.go b/libgo/go/internal/cpu/cpu_amd64p32.go
deleted file mode 100644
index a6cff4f..0000000
--- a/libgo/go/internal/cpu/cpu_amd64p32.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright 2020 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package cpu
-
-const GOARCH = "amd64p32"
diff --git a/libgo/go/internal/cpu/cpu_arm64_android.go b/libgo/go/internal/cpu/cpu_arm64_android.go
index ac6eee5..fbdf7ba 100644
--- a/libgo/go/internal/cpu/cpu_arm64_android.go
+++ b/libgo/go/internal/cpu/cpu_arm64_android.go
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build arm64
-// +build arm64
package cpu
diff --git a/libgo/go/internal/cpu/cpu_arm64_darwin.go b/libgo/go/internal/cpu/cpu_arm64_darwin.go
index ce1b250..730e14c 100644
--- a/libgo/go/internal/cpu/cpu_arm64_darwin.go
+++ b/libgo/go/internal/cpu/cpu_arm64_darwin.go
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build arm64 && darwin && !ios
-// +build arm64,darwin,!ios
package cpu
diff --git a/libgo/go/internal/cpu/cpu_arm64_freebsd.go b/libgo/go/internal/cpu/cpu_arm64_freebsd.go
index 8c48137..c25e021 100644
--- a/libgo/go/internal/cpu/cpu_arm64_freebsd.go
+++ b/libgo/go/internal/cpu/cpu_arm64_freebsd.go
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build arm64
-// +build arm64
package cpu
diff --git a/libgo/go/internal/cpu/cpu_arm64_hwcap.go b/libgo/go/internal/cpu/cpu_arm64_hwcap.go
index 8ac04fd..0baa39f 100644
--- a/libgo/go/internal/cpu/cpu_arm64_hwcap.go
+++ b/libgo/go/internal/cpu/cpu_arm64_hwcap.go
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build arm64 && linux
-// +build arm64,linux
package cpu
diff --git a/libgo/go/internal/cpu/cpu_arm64_linux.go b/libgo/go/internal/cpu/cpu_arm64_linux.go
index c3a3f9a..d746bdb 100644
--- a/libgo/go/internal/cpu/cpu_arm64_linux.go
+++ b/libgo/go/internal/cpu/cpu_arm64_linux.go
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build arm64 && linux && !android
-// +build arm64,linux,!android
package cpu
diff --git a/libgo/go/internal/cpu/cpu_arm64_other.go b/libgo/go/internal/cpu/cpu_arm64_other.go
index e8b5d529..d313648 100644
--- a/libgo/go/internal/cpu/cpu_arm64_other.go
+++ b/libgo/go/internal/cpu/cpu_arm64_other.go
@@ -3,11 +3,6 @@
// license that can be found in the LICENSE file.
//go:build arm64 && !linux && !freebsd && !android && (!darwin || ios)
-// +build arm64
-// +build !linux
-// +build !freebsd
-// +build !android
-// +build !darwin ios
package cpu
diff --git a/libgo/go/internal/cpu/cpu_mips64x.go b/libgo/go/internal/cpu/cpu_mips64x.go
index c660403..9de918a 100644
--- a/libgo/go/internal/cpu/cpu_mips64x.go
+++ b/libgo/go/internal/cpu/cpu_mips64x.go
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build mips64 || mips64le
-// +build mips64 mips64le
package cpu
diff --git a/libgo/go/internal/cpu/cpu_no_name.go b/libgo/go/internal/cpu/cpu_no_name.go
index 8e636d5..38fd5d8 100644
--- a/libgo/go/internal/cpu/cpu_no_name.go
+++ b/libgo/go/internal/cpu/cpu_no_name.go
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build !386 && !amd64 && !amd64p32
-// +build !386,!amd64,!amd64p32
package cpu
diff --git a/libgo/go/internal/cpu/cpu_ppc64x.go b/libgo/go/internal/cpu/cpu_ppc64x.go
index 1c7c39f..1cce6a5 100644
--- a/libgo/go/internal/cpu/cpu_ppc64x.go
+++ b/libgo/go/internal/cpu/cpu_ppc64x.go
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build ppc || ppc64 || ppc64le
-// +build ppc ppc64 ppc64le
package cpu
diff --git a/libgo/go/internal/cpu/cpu_ppc64x_aix.go b/libgo/go/internal/cpu/cpu_ppc64x_aix.go
index c7e47b2..fab4482 100644
--- a/libgo/go/internal/cpu/cpu_ppc64x_aix.go
+++ b/libgo/go/internal/cpu/cpu_ppc64x_aix.go
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build ppc || ppc64 || ppc64le
-// +build ppc ppc64 ppc64le
package cpu
diff --git a/libgo/go/internal/cpu/cpu_ppc64x_linux.go b/libgo/go/internal/cpu/cpu_ppc64x_linux.go
index 0c89f3b..fc8b234 100644
--- a/libgo/go/internal/cpu/cpu_ppc64x_linux.go
+++ b/libgo/go/internal/cpu/cpu_ppc64x_linux.go
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build ppc || ppc64 || ppc64le
-// +build ppc ppc64 ppc64le
package cpu
diff --git a/libgo/go/internal/cpu/cpu_test.go b/libgo/go/internal/cpu/cpu_test.go
index 5a4c897..a606493 100644
--- a/libgo/go/internal/cpu/cpu_test.go
+++ b/libgo/go/internal/cpu/cpu_test.go
@@ -6,31 +6,14 @@ package cpu_test
import (
. "internal/cpu"
+ "internal/godebug"
"internal/testenv"
"os"
"os/exec"
- "runtime"
"strings"
"testing"
)
-func TestMinimalFeatures(t *testing.T) {
- // TODO: maybe do MustSupportFeatureDectection(t) ?
- if runtime.GOARCH == "arm64" {
- switch runtime.GOOS {
- case "linux", "android", "darwin":
- default:
- t.Skipf("%s/%s is not supported", runtime.GOOS, runtime.GOARCH)
- }
- }
-
- for _, o := range Options {
- if o.Required && !*o.Feature {
- t.Errorf("%v expected true, got false", o.Name)
- }
- }
-}
-
func MustHaveDebugOptionsSupport(t *testing.T) {
if !DebugOptions {
t.Skipf("skipping test: cpu feature options not supported by OS")
@@ -70,12 +53,12 @@ func TestDisableAllCapabilities(t *testing.T) {
func TestAllCapabilitiesDisabled(t *testing.T) {
MustHaveDebugOptionsSupport(t)
- if os.Getenv("GODEBUG") != "cpu.all=off" {
+ if godebug.Get("cpu.all") != "off" {
t.Skipf("skipping test: GODEBUG=cpu.all=off not set")
}
for _, o := range Options {
- want := o.Required
+ want := false
if got := *o.Feature; got != want {
t.Errorf("%v: expected %v, got %v", o.Name, want, got)
}
diff --git a/libgo/go/internal/cpu/cpu_x86.go b/libgo/go/internal/cpu/cpu_x86.go
index 6182532..66fd9f5 100644
--- a/libgo/go/internal/cpu/cpu_x86.go
+++ b/libgo/go/internal/cpu/cpu_x86.go
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build 386 || amd64 || amd64p32
-// +build 386 amd64 amd64p32
package cpu
@@ -37,6 +36,9 @@ const (
cpuid_BMI2 = 1 << 8
cpuid_ERMS = 1 << 9
cpuid_ADX = 1 << 19
+
+ // edx bits for CPUID 0x80000001
+ cpuid_RDTSCP = 1 << 27
)
var maxExtendedFunctionInformation uint32
@@ -53,13 +55,11 @@ func doinit() {
{Name: "fma", Feature: &X86.HasFMA},
{Name: "pclmulqdq", Feature: &X86.HasPCLMULQDQ},
{Name: "popcnt", Feature: &X86.HasPOPCNT},
+ {Name: "rdtscp", Feature: &X86.HasRDTSCP},
{Name: "sse3", Feature: &X86.HasSSE3},
{Name: "sse41", Feature: &X86.HasSSE41},
{Name: "sse42", Feature: &X86.HasSSE42},
{Name: "ssse3", Feature: &X86.HasSSSE3},
-
- // These capabilities should always be enabled on amd64:
- {Name: "sse2", Feature: &X86.HasSSE2, Required: GOARCH == "amd64" || GOARCH == "amd64p32"},
}
maxID, _, _, _ := cpuid(0, 0)
@@ -70,8 +70,7 @@ func doinit() {
maxExtendedFunctionInformation, _, _, _ = cpuid(0x80000000, 0)
- _, _, ecx1, edx1 := cpuid(1, 0)
- X86.HasSSE2 = isSet(edx1, cpuid_SSE2)
+ _, _, ecx1, _ := cpuid(1, 0)
X86.HasSSE3 = isSet(ecx1, cpuid_SSE3)
X86.HasPCLMULQDQ = isSet(ecx1, cpuid_PCLMULQDQ)
@@ -112,6 +111,16 @@ func doinit() {
X86.HasBMI2 = isSet(ebx7, cpuid_BMI2)
X86.HasERMS = isSet(ebx7, cpuid_ERMS)
X86.HasADX = isSet(ebx7, cpuid_ADX)
+
+ var maxExtendedInformation uint32
+ maxExtendedInformation, _, _, _ = cpuid(0x80000000, 0)
+
+ if maxExtendedInformation < 0x80000001 {
+ return
+ }
+
+ _, _, _, edxExt1 := cpuid(0x80000001, 0)
+ X86.HasRDTSCP = isSet(edxExt1, cpuid_RDTSCP)
}
func isSet(hwc uint32, value uint32) bool {
diff --git a/libgo/go/internal/cpu/cpu_x86_test.go b/libgo/go/internal/cpu/cpu_x86_test.go
index e3e16cc..c8be210 100644
--- a/libgo/go/internal/cpu/cpu_x86_test.go
+++ b/libgo/go/internal/cpu/cpu_x86_test.go
@@ -3,14 +3,12 @@
// license that can be found in the LICENSE file.
//go:build 386 || amd64
-// +build 386 amd64
package cpu_test
import (
. "internal/cpu"
- "os"
- "runtime"
+ "internal/godebug"
"testing"
)
@@ -20,23 +18,6 @@ func TestX86ifAVX2hasAVX(t *testing.T) {
}
}
-func TestDisableSSE2(t *testing.T) {
- runDebugOptionsTest(t, "TestSSE2DebugOption", "cpu.sse2=off")
-}
-
-func TestSSE2DebugOption(t *testing.T) {
- MustHaveDebugOptionsSupport(t)
-
- if os.Getenv("GODEBUG") != "cpu.sse2=off" {
- t.Skipf("skipping test: GODEBUG=cpu.sse2=off not set")
- }
-
- want := runtime.GOARCH != "386" // SSE2 can only be disabled on 386.
- if got := X86.HasSSE2; got != want {
- t.Errorf("X86.HasSSE2 on %s expected %v, got %v", runtime.GOARCH, want, got)
- }
-}
-
func TestDisableSSE3(t *testing.T) {
runDebugOptionsTest(t, "TestSSE3DebugOption", "cpu.sse3=off")
}
@@ -44,7 +25,7 @@ func TestDisableSSE3(t *testing.T) {
func TestSSE3DebugOption(t *testing.T) {
MustHaveDebugOptionsSupport(t)
- if os.Getenv("GODEBUG") != "cpu.sse3=off" {
+ if godebug.Get("cpu.sse3") != "off" {
t.Skipf("skipping test: GODEBUG=cpu.sse3=off not set")
}