alias("runtime/internal/atomic", "CasRel", "runtime/internal/atomic", "Cas", lwatomics...)
/******** math ********/
- addF("math", "Sqrt",
+ addF("math", "sqrt",
func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
return s.newValue1(ssa.OpSqrt, types.Types[types.TFLOAT64], args[0])
},
// Sqrt(x < 0) = NaN
// Sqrt(NaN) = NaN
func Sqrt(x float64) float64 {
- if haveArchSqrt {
- return archSqrt(x)
- }
return sqrt(x)
}
-// Note: Sqrt is implemented in assembly on some systems.
-// Others have assembly stubs that jump to func sqrt below.
-// On systems where Sqrt is a single instruction, the compiler
+// Note: On systems where Sqrt is a single instruction, the compiler
// may turn a direct call into a direct use of that instruction instead.
func sqrt(x float64) float64 {
+++ /dev/null
-// Copyright 2009 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.
-
-#include "textflag.h"
-
-// func archSqrt(x float64) float64
-TEXT ·archSqrt(SB),NOSPLIT,$0
- FMOVD x+0(FP),F0
- FSQRT
- FMOVDP F0,ret+8(FP)
- RET
+++ /dev/null
-// Copyright 2009 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.
-
-#include "textflag.h"
-
-// func archSqrt(x float64) float64
-TEXT ·archSqrt(SB), NOSPLIT, $0
- XORPS X0, X0 // break dependency
- SQRTSD x+0(FP), X0
- MOVSD X0, ret+8(FP)
- RET
+++ /dev/null
-// Copyright 2011 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.
-
-#include "textflag.h"
-
-// func archSqrt(x float64) float64
-TEXT ·archSqrt(SB),NOSPLIT,$0
- MOVB runtime·goarm(SB), R11
- CMP $5, R11
- BEQ arm5
- MOVD x+0(FP),F0
- SQRTD F0,F0
- MOVD F0,ret+8(FP)
- RET
-arm5:
- // Tail call to Go implementation.
- // Can't use JMP, as in softfloat mode SQRTD is rewritten
- // to a CALL, which makes this function have a frame.
- RET ·sqrt(SB)
+++ /dev/null
-// Copyright 2015 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.
-
-#include "textflag.h"
-
-// func archSqrt(x float64) float64
-TEXT ·archSqrt(SB),NOSPLIT,$0
- FMOVD x+0(FP), F0
- FSQRTD F0, F0
- FMOVD F0, ret+8(FP)
- RET
+++ /dev/null
-// Copyright 2021 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.
-
-//go:build 386 || amd64 || arm64 || arm || mips || mipsle || ppc64 || ppc64le || s390x || riscv64 || wasm
-
-package math
-
-const haveArchSqrt = true
-
-func archSqrt(x float64) float64
+++ /dev/null
-// Copyright 2016 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.
-
-//go:build mips || mipsle
-// +build mips mipsle
-
-#include "textflag.h"
-
-// func archSqrt(x float64) float64
-TEXT ·archSqrt(SB),NOSPLIT,$0
-#ifdef GOMIPS_softfloat
- JMP ·sqrt(SB)
-#else
- MOVD x+0(FP), F0
- SQRTD F0, F0
- MOVD F0, ret+8(FP)
-#endif
- RET
+++ /dev/null
-// Copyright 2021 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.
-
-//go:build !386 && !amd64 && !arm64 && !arm && !mips && !mipsle && !ppc64 && !ppc64le && !s390x && !riscv64 && !wasm
-
-package math
-
-const haveArchSqrt = false
-
-func archSqrt(x float64) float64 {
- panic("not implemented")
-}
+++ /dev/null
-// Copyright 2016 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.
-
-//go:build ppc64 || ppc64le
-// +build ppc64 ppc64le
-
-#include "textflag.h"
-
-// func archSqrt(x float64) float64
-TEXT ·archSqrt(SB),NOSPLIT,$0
- FMOVD x+0(FP), F0
- FSQRT F0, F0
- FMOVD F0, ret+8(FP)
- RET
+++ /dev/null
-// 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.
-
-#include "textflag.h"
-
-// func archSqrt(x float64) float64
-TEXT ·archSqrt(SB),NOSPLIT,$0
- MOVD x+0(FP), F0
- FSQRTD F0, F0
- MOVD F0, ret+8(FP)
- RET
+++ /dev/null
-// Copyright 2016 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.
-
-#include "textflag.h"
-
-// func archSqrt(x float64) float64
-TEXT ·archSqrt(SB),NOSPLIT,$0
- FMOVD x+0(FP), F1
- FSQRT F1, F1
- FMOVD F1, ret+8(FP)
- RET
+++ /dev/null
-// Copyright 2018 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.
-
-#include "textflag.h"
-
-TEXT ·archSqrt(SB),NOSPLIT,$0
- Get SP
- F64Load x+0(FP)
- F64Sqrt
- F64Store ret+8(FP)
- RET