summaryrefslogtreecommitdiff
path: root/lib/libc/arch/mips64
diff options
context:
space:
mode:
authorPer Fogelstrom <pefo@cvs.openbsd.org>2004-10-02 15:30:34 +0000
committerPer Fogelstrom <pefo@cvs.openbsd.org>2004-10-02 15:30:34 +0000
commit3cfe8dfff1982f52339547506a29d6877e8b2cf1 (patch)
treef06315b812fa37f0fbf21ef2c7dad6d5d4d0dcf0 /lib/libc/arch/mips64
parent0c1d401a7455c08719d579669d0392712b123c15 (diff)
convert to 64 bit
Diffstat (limited to 'lib/libc/arch/mips64')
-rw-r--r--lib/libc/arch/mips64/gen/ldexp.S152
1 files changed, 55 insertions, 97 deletions
diff --git a/lib/libc/arch/mips64/gen/ldexp.S b/lib/libc/arch/mips64/gen/ldexp.S
index 85aa8765940..187ccf4cc3e 100644
--- a/lib/libc/arch/mips64/gen/ldexp.S
+++ b/lib/libc/arch/mips64/gen/ldexp.S
@@ -34,7 +34,7 @@
#if defined(LIBC_SCCS)
.text
- .asciz "$OpenBSD: ldexp.S,v 1.3 2004/09/15 16:11:26 pefo Exp $"
+ .asciz "$OpenBSD: ldexp.S,v 1.4 2004/10/02 15:30:33 pefo Exp $"
#endif /* LIBC_SCCS */
#define DEXP_INF 0x7ff
@@ -43,7 +43,7 @@
#define DEXP_MAX 1023
#define DFRAC_BITS 52
#define DIMPL_ONE 0x00100000
-#define DLEAD_ZEROS 31 - 20
+#define DLEAD_ZEROS 63 - 52
#define STICKYBIT 1
#define GUARDBIT 0x80000000
#define DSIGNAL_NAN 0x00040000
@@ -58,150 +58,108 @@
*/
LEAF(ldexp, 0)
.set reorder
- mfc1 v1, $f13 # get MSW of x
- mfc1 t3, $f12 # get LSW of x
- sll t1, v1, 1 # get x exponent
- srl t1, t1, 32 - 11
+ dmfc1 t3, $f12 # get x
+ dsll t1, t3, 1 # get x exponent
+ dsrl t1, t1, 64 - 11
beq t1, DEXP_INF, 9f # is it a NAN or infinity?
beq t1, zero, 1f # zero or denormalized number?
- addu t1, t1, a2 # scale exponent
- sll v0, a2, 20 # position N for addition
+ daddu t1, a1 # scale exponent
+ dsll v0, a1, 52 # position N for addition
bge t1, DEXP_INF, 8f # overflow?
- addu v0, v0, v1 # multiply by (2**N)
+ daddu v0, t3, v0 # multiply by (2**N)
ble t1, zero, 4f # underflow?
- mtc1 v0, $f1 # save MSW of result
- mtc1 t3, $f0 # save LSW of result
+ dmtc1 v0, $f0 # save result
j ra
1:
- sll t2, v1, 32 - 20 # get x fraction
- srl t2, t2, 32 - 20
- srl t0, v1, 31 # get x sign
- bne t2, zero, 1f
- beq t3, zero, 9f # result is zero
-1:
+ dsll t2, t3, 64 - 52 # get x fraction
+ dsrl t2, t2, 64 - 52
+ dsrl t0, t3, 63 # get x sign
+ beq t2, zero, 9f # result is zero
/*
- * Find out how many leading zero bits are in t2,t3 and put in t9.
+ * Find out how many leading zero bits are in t2 and put in t9.
*/
move v0, t2
move t9, zero
- bne t2, zero, 1f
- move v0, t3
- addu t9, 32
+ dsrl ta0, v0, 32
+ bne ta0, zero, 1f
+ daddu t9, 32
+ dsll v0, 32
1:
- srl ta0, v0, 16
+ dsrl ta0, v0, 16
bne ta0, zero, 1f
- addu t9, 16
- sll v0, 16
+ daddu t9, 16
+ dsll v0, 16
1:
- srl ta0, v0, 24
+ dsrl ta0, v0, 24
bne ta0, zero, 1f
- addu t9, 8
- sll v0, 8
+ daddu t9, 8
+ dsll v0, 8
1:
- srl ta0, v0, 28
+ dsrl ta0, v0, 28
bne ta0, zero, 1f
- addu t9, 4
- sll v0, 4
+ daddu t9, 4
+ dsll v0, 4
1:
- srl ta0, v0, 30
+ dsrl ta0, v0, 30
bne ta0, zero, 1f
- addu t9, 2
- sll v0, 2
+ daddu t9, 2
+ dsll v0, 2
1:
- srl ta0, v0, 31
+ dsrl ta0, v0, 31
bne ta0, zero, 1f
- addu t9, 1
+ daddu t9, 1
/*
- * Now shift t2,t3 the correct number of bits.
+ * Now shift t2 the correct number of bits.
*/
1:
- subu t9, t9, DLEAD_ZEROS # dont count normal leading zeros
+ dsubu t9, t9, DLEAD_ZEROS # dont count normal leading zeros
li t1, DEXP_MIN + DEXP_BIAS
subu t1, t1, t9 # adjust exponent
addu t1, t1, a2 # scale exponent
- li v0, 32
- blt t9, v0, 1f
- subu t9, t9, v0 # shift fraction left >= 32 bits
- sll t2, t3, t9
- move t3, zero
- b 2f
-1:
- subu v0, v0, t9 # shift fraction left < 32 bits
- sll t2, t2, t9
- srl ta0, t3, v0
- or t2, t2, ta0
- sll t3, t3, t9
-2:
+ dsll t2, t9
+
bge t1, DEXP_INF, 8f # overflow?
ble t1, zero, 4f # underflow?
- sll t2, t2, 32 - 20 # clear implied one bit
- srl t2, t2, 32 - 20
-3:
- sll t1, t1, 31 - 11 # reposition exponent
- sll t0, t0, 31 # reposition sign
+ dsll t2, t2, 64 - 52 # clear implied one bit
+ dsrl t2, t2, 64 - 52
+
+ dsll t1, t1, 63 - 11 # reposition exponent
+ dsll t0, t0, 63 # reposition sign
or t0, t0, t1 # put result back together
or t0, t0, t2
- mtc1 t0, $f1 # save MSW of result
- mtc1 t3, $f0 # save LSW of result
+ dmtc1 t0, $f0 # save result
j ra
4:
- li v0, 0x80000000
+ li v0, 0x8000000000000000
ble t1, -52, 7f # is result too small for denorm?
- sll t2, v1, 31 - 20 # clear exponent, extract fraction
+ dsll t2, t3, 63 - 52 # clear exponent, extract fraction
or t2, t2, v0 # set implied one bit
- blt t1, -30, 2f # will all bits in t3 be shifted out?
- srl t2, t2, 31 - 20 # shift fraction back to normal position
+ dsrl t2, t2, 63 - 52 # shift fraction back to normal position
subu t1, t1, 1
- sll ta0, t2, t1 # shift right t2,t3 based on exponent
- srl t8, t3, t1 # save bits shifted out
+ dsrl t8, t2, t1 # save bits shifted out
negu t1
- srl t3, t3, t1
- or t3, t3, ta0
- srl t2, t2, t1
+ dsrl t2, t2, t1
bge t8, zero, 1f # does result need to be rounded?
- addu t3, t3, 1 # round result
- sltu ta0, t3, 1
- sll t8, t8, 1
- addu t2, t2, ta0
+ daddu t2, t2, 1 # round result
+ dsll t8, t8, 1
bne t8, zero, 1f # round result to nearest
- and t3, t3, ~1
+ ori t2, 1
+ xori t2, 1
1:
- mtc1 t3, $f0 # save denormalized result (LSW)
- mtc1 t2, $f1 # save denormalized result (MSW)
+ dmtc1 t2, $f0 # save denormalized result (LSW)
bge v1, zero, 1f # should result be negative?
neg.d $f0, $f0 # negate result
1:
j ra
-2:
- mtc1 zero, $f1 # exponent and upper fraction
- addu t1, t1, 20 # compute amount to shift right by
- sll t8, t2, t1 # save bits shifted out
- negu t1
- srl t3, t2, t1
- bge t8, zero, 1f # does result need to be rounded?
- addu t3, t3, 1 # round result
- sltu ta0, t3, 1
- sll t8, t8, 1
- mtc1 ta0, $f1 # exponent and upper fraction
- bne t8, zero, 1f # round result to nearest
- and t3, t3, ~1
-1:
- mtc1 t3, $f0
- bge v1, zero, 1f # is result negative?
- neg.d $f0, $f0 # negate result
-1:
- j ra
7:
- mtc1 zero, $f0 # result is zero
- mtc1 zero, $f1
+ dmtc1 zero, $f0 # result is zero
beq t0, zero, 1f # is result positive?
neg.d $f0, $f0 # negate result
1:
j ra
8:
- li t1, 0x7ff00000 # result is infinity (MSW)
- mtc1 t1, $f1
- mtc1 zero, $f0 # result is infinity (LSW)
+ li t1, 0x7ff0000000000000 # result is infinity (MSW)
+ dmtc1 t1, $f0
bge v1, zero, 1f # should result be negative infinity?
neg.d $f0, $f0 # result is negative infinity
1: