mirror of
https://github.com/golang/go
synced 2024-11-19 10:04:56 -07:00
runtime: implement some soft-float routines (used by GOMIPS=softfloat)
Updates #18162 Change-Id: Iee854f48b2d1432955fdb462f2073ebbe76c34f8 Reviewed-on: https://go-review.googlesource.com/37957 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
12abacb555
commit
ac987df87c
@ -483,3 +483,115 @@ again2:
|
||||
|
||||
return q1*b + q0, (un21*b + un0 - q0*v) >> s
|
||||
}
|
||||
|
||||
func fadd32(x, y uint32) uint32 {
|
||||
return f64to32(fadd64(f32to64(x), f32to64(y)))
|
||||
}
|
||||
|
||||
func fmul32(x, y uint32) uint32 {
|
||||
return f64to32(fmul64(f32to64(x), f32to64(y)))
|
||||
}
|
||||
|
||||
func fdiv32(x, y uint32) uint32 {
|
||||
return f64to32(fdiv64(f32to64(x), f32to64(y)))
|
||||
}
|
||||
|
||||
func feq32(x, y uint32) bool {
|
||||
cmp, nan := fcmp64(f32to64(x), f32to64(y))
|
||||
return cmp == 0 && !nan
|
||||
}
|
||||
|
||||
func fgt32(x, y uint32) bool {
|
||||
cmp, nan := fcmp64(f32to64(x), f32to64(y))
|
||||
return cmp >= 1 && !nan
|
||||
}
|
||||
|
||||
func fge32(x, y uint32) bool {
|
||||
cmp, nan := fcmp64(f32to64(x), f32to64(y))
|
||||
return cmp >= 0 && !nan
|
||||
}
|
||||
|
||||
func feq64(x, y uint64) bool {
|
||||
cmp, nan := fcmp64(x, y)
|
||||
return cmp == 0 && !nan
|
||||
}
|
||||
|
||||
func fgt64(x, y uint64) bool {
|
||||
cmp, nan := fcmp64(x, y)
|
||||
return cmp >= 1 && !nan
|
||||
}
|
||||
|
||||
func fge64(x, y uint64) bool {
|
||||
cmp, nan := fcmp64(x, y)
|
||||
return cmp >= 0 && !nan
|
||||
}
|
||||
|
||||
func fint32to32(x int32) uint32 {
|
||||
return f64to32(fintto64(int64(x)))
|
||||
}
|
||||
|
||||
func fint32to64(x int32) uint64 {
|
||||
return fintto64(int64(x))
|
||||
}
|
||||
|
||||
func fint64to32(x int64) uint32 {
|
||||
return f64to32(fintto64(x))
|
||||
}
|
||||
|
||||
func fint64to64(x int64) uint64 {
|
||||
return fintto64(x)
|
||||
}
|
||||
|
||||
func f32toint32(x uint32) int32 {
|
||||
val, _ := f64toint(f32to64(x))
|
||||
return int32(val)
|
||||
}
|
||||
|
||||
func f32toint64(x uint32) int64 {
|
||||
val, _ := f64toint(f32to64(x))
|
||||
return val
|
||||
}
|
||||
|
||||
func f64toint32(x uint64) int32 {
|
||||
val, _ := f64toint(x)
|
||||
return int32(val)
|
||||
}
|
||||
|
||||
func f64toint64(x uint64) int64 {
|
||||
val, _ := f64toint(x)
|
||||
return val
|
||||
}
|
||||
|
||||
func f64touint64(x float64) uint64 {
|
||||
if x < float64(1<<63) {
|
||||
return uint64(int64(x))
|
||||
}
|
||||
y := x - float64(1<<63)
|
||||
z := uint64(int64(y))
|
||||
return z | (1 << 63)
|
||||
}
|
||||
|
||||
func f32touint64(x float32) uint64 {
|
||||
if x < float32(1<<63) {
|
||||
return uint64(int64(x))
|
||||
}
|
||||
y := x - float32(1<<63)
|
||||
z := uint64(int64(y))
|
||||
return z | (1 << 63)
|
||||
}
|
||||
|
||||
func fuint64to64(x uint64) float64 {
|
||||
if int64(x) >= 0 {
|
||||
return float64(int64(x))
|
||||
}
|
||||
// See ../cmd/compile/internal/gc/ssa.go:uint64Tofloat
|
||||
y := x & 1
|
||||
z := x >> 1
|
||||
z = z | y
|
||||
r := float64(int64(z))
|
||||
return r + r
|
||||
}
|
||||
|
||||
func fuint64to32(x uint64) float32 {
|
||||
return float32(fuint64to64(x))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user