]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] internal/abi: add new internal/abi package for ABI constants
authorMichael Anthony Knyszek <mknyszek@google.com>
Thu, 22 Oct 2020 16:02:14 +0000 (16:02 +0000)
committerMichael Knyszek <mknyszek@google.com>
Fri, 12 Feb 2021 22:11:52 +0000 (22:11 +0000)
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>
src/go/build/deps_test.go
src/internal/abi/abi.go [new file with mode: 0644]
src/internal/abi/abi_amd64.go [new file with mode: 0644]
src/internal/abi/abi_generic.go [new file with mode: 0644]

index c97c668cc4922914c12008c4c53f0ebd8321fb14..02b29f498a66463e4c9bc6cff1d8a07be659fc12 100644 (file)
@@ -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 (file)
index 0000000..07ea51d
--- /dev/null
@@ -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 (file)
index 0000000..6574d42
--- /dev/null
@@ -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 (file)
index 0000000..5ef9883
--- /dev/null
@@ -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
+)