aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/builtin
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2021-04-03 20:49:03 -0400
committerCherry Zhang <cherryyz@google.com>2021-04-05 18:22:47 +0000
commitcf148f3d468f4d0648e7fc6d2858d2afdc37f70d (patch)
tree4183db29450c0750533bd2568f055baa3030a786 /src/cmd/compile/internal/typecheck/builtin
parenta040ebeb980d1a712509fa3d8073cf6ae16cbe78 (diff)
downloadgo-cf148f3d468f4d0648e7fc6d2858d2afdc37f70d.tar.gz
go-cf148f3d468f4d0648e7fc6d2858d2afdc37f70d.zip
cmd/compile, runtime: use ABI-aware function converting float to interface
Currently, when converting a float (say float64), we use convT64 function. In the runtime convT64 expects a uint64 argument. In the compiler, convT64 is defined as taking an "any" argument (so it works with also uint64-like types such as [1]uint64). The "any" type is instantiated with the concrete type in walk. So the backend will see instances such as convT64([1]uint64). Currently, float64 is treated as uint64-like. So the backend will see convT64(float64). With a memory-based calling convention this is fine. With a register-based calling convention, however, it will pass the argument in a floating point register, whereas the runtime expects the argument in an integer register (as it is declared as uint64). To fix this, this CL introduces runtime functions convT32F and convT64F. They behave the same as convT32/convT64, but with a float argument. In the compiler, use convT32F/convT64F to convert float-like type to interface. With this, "GOEXPERIMENT=regabi,regabiargs go test math fmt" works. Updates #40724. Change-Id: I8b2e232096a95e4a7c4ab81795d77ef224ffaab3 Reviewed-on: https://go-review.googlesource.com/c/go/+/307232 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/builtin')
-rw-r--r--src/cmd/compile/internal/typecheck/builtin/runtime.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/typecheck/builtin/runtime.go b/src/cmd/compile/internal/typecheck/builtin/runtime.go
index 614bd46177..7c9599b54e 100644
--- a/src/cmd/compile/internal/typecheck/builtin/runtime.go
+++ b/src/cmd/compile/internal/typecheck/builtin/runtime.go
@@ -89,7 +89,9 @@ func convI2I(typ *byte, elem any) (ret any)
// These return only a data pointer.
func convT16(val any) unsafe.Pointer // val must be uint16-like (same size and alignment as a uint16)
func convT32(val any) unsafe.Pointer // val must be uint32-like (same size and alignment as a uint32)
+func convT32F(val any) unsafe.Pointer // val must be float32-like
func convT64(val any) unsafe.Pointer // val must be uint64-like (same size and alignment as a uint64 and contains no pointers)
+func convT64F(val any) unsafe.Pointer // val must be float64-like
func convTstring(val any) unsafe.Pointer // val must be a string
func convTslice(val any) unsafe.Pointer // val must be a slice