blob: dc88a78e7a7a06081f60d5b9dd8b303683280e81 [file] [log] [blame]
Alexey Frunze84603bf2016-10-21 19:54:43 -07001 /*
2 * float-to-long
3 *
4 * We have to clip values to long min/max per the specification. The
5 * expected common case is a "reasonable" value that converts directly
6 * to modest integer. The EABI convert function isn't doing this for us.
7 */
8 /* unop vA, vB */
9 GET_OPA4(rOBJ) # rOBJ <- A+
10 GET_OPB(a3) # a3 <- B
11 GET_VREG_F(fa0, a3)
12 FETCH_ADVANCE_INST(1) # advance rPC, load rINST
Douglas Leung200f0402016-02-25 20:05:47 -080013
Douglas Leung200f0402016-02-25 20:05:47 -080014#ifdef MIPS32REVGE6
Alexey Frunze84603bf2016-10-21 19:54:43 -070015 /*
16 * TODO: simplify this when the MIPS64R6 emulator
17 * supports NAN2008=1.
18 */
19 li t0, LONG_MIN_AS_FLOAT
20 mtc1 t0, fa1
21 cmp.le.s ft0, fa1, fa0
22 GET_INST_OPCODE(t1) # extract opcode from rINST
23 bc1nez ft0, 1f # if LONG_MIN <= vB, proceed to truncation
24 cmp.eq.s ft0, fa0, fa0
25 selnez.s fa0, fa1, ft0 # fa0 = ordered(vB) ? LONG_MIN_AS_FLOAT : 0
261:
27 trunc.l.s fa0, fa0
28 SET_VREG64_F_GOTO(fa0, fa0f, rOBJ, t1) # vA <- result
Douglas Leung200f0402016-02-25 20:05:47 -080029#else
Alexey Frunze84603bf2016-10-21 19:54:43 -070030 c.eq.s fcc0, fa0, fa0
Douglas Leung200f0402016-02-25 20:05:47 -080031 li rRESULT0, 0
32 li rRESULT1, 0
Alexey Frunze84603bf2016-10-21 19:54:43 -070033 bc1f fcc0, .L${opcode}_get_opcode
34
35 li t0, LONG_MIN_AS_FLOAT
36 mtc1 t0, fa1
37 c.ole.s fcc0, fa0, fa1
38 li rRESULT1, LONG_MIN_HIGH
39 bc1t fcc0, .L${opcode}_get_opcode
40
41 neg.s fa1, fa1
42 c.ole.s fcc0, fa1, fa0
43 nor rRESULT0, rRESULT0, zero
44 nor rRESULT1, rRESULT1, zero
45 bc1t fcc0, .L${opcode}_get_opcode
Douglas Leung200f0402016-02-25 20:05:47 -080046
47 JAL(__fixsfdi)
Alexey Frunze84603bf2016-10-21 19:54:43 -070048 GET_INST_OPCODE(t1) # extract opcode from rINST
Douglas Leung200f0402016-02-25 20:05:47 -080049 b .L${opcode}_set_vreg
Alexey Frunze84603bf2016-10-21 19:54:43 -070050#endif
51%break
Douglas Leung200f0402016-02-25 20:05:47 -080052
Alexey Frunze84603bf2016-10-21 19:54:43 -070053#ifndef MIPS32REVGE6
54.L${opcode}_get_opcode:
55 GET_INST_OPCODE(t1) # extract opcode from rINST
56.L${opcode}_set_vreg:
57 SET_VREG64_GOTO(rRESULT0, rRESULT1, rOBJ, t1) # vA/vA+1 <- v0/v1
58#endif