aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2020-10-22 16:02:14 +0000
committerMichael Knyszek <mknyszek@google.com>2021-02-12 22:11:52 +0000
commitbaa6c75dcef23aa51e95bf7818b7ded5262fbaa8 (patch)
tree5948d18e4bb9bfa32a2f7380335a64b5b4ba87b5
parentd1fd9a8863df6e8dc24dd1756550d341a26ed76c (diff)
downloadgo-baa6c75dcef23aa51e95bf7818b7ded5262fbaa8.tar.gz
go-baa6c75dcef23aa51e95bf7818b7ded5262fbaa8.zip
[dev.regabi] internal/abi: add new internal/abi package for ABI constants
This change creates a new internal std package internal/abi which is intended to hold constants with platform-specific values related to our ABI that is useful to different std packages, such as runtime and reflect. For #40724. Change-Id: Ie7ae7f687629cd3d613ba603e9371f0887601fe6 Reviewed-on: https://go-review.googlesource.com/c/go/+/272567 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Austin Clements <austin@google.com>
-rw-r--r--src/go/build/deps_test.go4
-rw-r--r--src/internal/abi/abi.go12
-rw-r--r--src/internal/abi/abi_amd64.go20
-rw-r--r--src/internal/abi/abi_generic.go38
4 files changed, 72 insertions, 2 deletions
diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go
index c97c668cc4..02b29f498a 100644
--- a/src/go/build/deps_test.go
+++ b/src/go/build/deps_test.go
@@ -71,13 +71,13 @@ var depsRules = `
# No dependencies allowed for any of these packages.
NONE
< container/list, container/ring,
- internal/cfg, internal/cpu,
+ internal/abi, internal/cfg, internal/cpu,
internal/goversion, internal/nettrace,
unicode/utf8, unicode/utf16, unicode,
unsafe;
# RUNTIME is the core runtime group of packages, all of them very light-weight.
- internal/cpu, unsafe
+ internal/abi, internal/cpu, unsafe
< internal/bytealg
< internal/unsafeheader
< runtime/internal/sys
diff --git a/src/internal/abi/abi.go b/src/internal/abi/abi.go
new file mode 100644
index 0000000000..07ea51df8f
--- /dev/null
+++ b/src/internal/abi/abi.go
@@ -0,0 +1,12 @@
+// 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 abi
+
+// RegArgs is a struct that has space for each argument
+// and return value register on the current architecture.
+type RegArgs struct {
+ Ints [IntArgRegs]uintptr
+ Floats [FloatArgRegs]uint64
+}
diff --git a/src/internal/abi/abi_amd64.go b/src/internal/abi/abi_amd64.go
new file mode 100644
index 0000000000..6574d4216d
--- /dev/null
+++ b/src/internal/abi/abi_amd64.go
@@ -0,0 +1,20 @@
+// 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.
+
+// +build goexperiment.regabi
+
+package abi
+
+const (
+ // See abi_generic.go.
+
+ // RAX, RBX, RCX, RDI, RSI, R8, R9, R10, R11.
+ IntArgRegs = 9
+
+ // X0 -> X14.
+ FloatArgRegs = 15
+
+ // We use SSE2 registers which support 64-bit float operations.
+ EffectiveFloatRegSize = 8
+)
diff --git a/src/internal/abi/abi_generic.go b/src/internal/abi/abi_generic.go
new file mode 100644
index 0000000000..5ef9883dc6
--- /dev/null
+++ b/src/internal/abi/abi_generic.go
@@ -0,0 +1,38 @@
+// 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.
+
+// +build !goexperiment.regabi
+
+package abi
+
+const (
+ // ABI-related constants.
+ //
+ // In the generic case, these are all zero
+ // which lets them gracefully degrade to ABI0.
+
+ // IntArgRegs is the number of registers dedicated
+ // to passing integer argument values. Result registers are identical
+ // to argument registers, so this number is used for those too.
+ IntArgRegs = 0
+
+ // FloatArgRegs is the number of registers dedicated
+ // to passing floating-point argument values. Result registers are
+ // identical to argument registers, so this number is used for
+ // those too.
+ FloatArgRegs = 0
+
+ // EffectiveFloatRegSize describes the width of floating point
+ // registers on the current platform from the ABI's perspective.
+ //
+ // Since Go only supports 32-bit and 64-bit floating point primitives,
+ // this number should be either 0, 4, or 8. 0 indicates no floating
+ // point registers for the ABI or that floating point values will be
+ // passed via the softfloat ABI.
+ //
+ // For platforms that support larger floating point register widths,
+ // such as x87's 80-bit "registers" (not that we support x87 currently),
+ // use 8.
+ EffectiveFloatRegSize = 0
+)