mirror of
https://github.com/golang/go
synced 2024-11-22 19:54:39 -07:00
[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>
This commit is contained in:
parent
d1fd9a8863
commit
baa6c75dce
@ -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
|
||||
|
12
src/internal/abi/abi.go
Normal file
12
src/internal/abi/abi.go
Normal file
@ -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
|
||||
}
|
20
src/internal/abi/abi_amd64.go
Normal file
20
src/internal/abi/abi_amd64.go
Normal file
@ -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
|
||||
)
|
38
src/internal/abi/abi_generic.go
Normal file
38
src/internal/abi/abi_generic.go
Normal file
@ -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
|
||||
)
|
Loading…
Reference in New Issue
Block a user