aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/builtin.go
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.go
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.go')
-rw-r--r--src/cmd/compile/internal/typecheck/builtin.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/typecheck/builtin.go b/src/cmd/compile/internal/typecheck/builtin.go
index 3421c44588..225dd682f0 100644
--- a/src/cmd/compile/internal/typecheck/builtin.go
+++ b/src/cmd/compile/internal/typecheck/builtin.go
@@ -73,7 +73,9 @@ var runtimeDecls = [...]struct {
{"convI2I", funcTag, 57},
{"convT16", funcTag, 58},
{"convT32", funcTag, 58},
+ {"convT32F", funcTag, 58},
{"convT64", funcTag, 58},
+ {"convT64F", funcTag, 58},
{"convTstring", funcTag, 58},
{"convTslice", funcTag, 58},
{"convT2E", funcTag, 59},