Alexey Frunze | 84603bf | 2016-10-21 19:54:43 -0700 | [diff] [blame] | 1 | /* |
| 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 Leung | 200f040 | 2016-02-25 20:05:47 -0800 | [diff] [blame] | 13 | |
Douglas Leung | 200f040 | 2016-02-25 20:05:47 -0800 | [diff] [blame] | 14 | #ifdef MIPS32REVGE6 |
Alexey Frunze | 84603bf | 2016-10-21 19:54:43 -0700 | [diff] [blame] | 15 | /* |
| 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 |
| 26 | 1: |
| 27 | trunc.l.s fa0, fa0 |
| 28 | SET_VREG64_F_GOTO(fa0, fa0f, rOBJ, t1) # vA <- result |
Douglas Leung | 200f040 | 2016-02-25 20:05:47 -0800 | [diff] [blame] | 29 | #else |
Alexey Frunze | 84603bf | 2016-10-21 19:54:43 -0700 | [diff] [blame] | 30 | c.eq.s fcc0, fa0, fa0 |
Douglas Leung | 200f040 | 2016-02-25 20:05:47 -0800 | [diff] [blame] | 31 | li rRESULT0, 0 |
| 32 | li rRESULT1, 0 |
Alexey Frunze | 84603bf | 2016-10-21 19:54:43 -0700 | [diff] [blame] | 33 | 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 Leung | 200f040 | 2016-02-25 20:05:47 -0800 | [diff] [blame] | 46 | |
| 47 | JAL(__fixsfdi) |
Alexey Frunze | 84603bf | 2016-10-21 19:54:43 -0700 | [diff] [blame] | 48 | GET_INST_OPCODE(t1) # extract opcode from rINST |
Douglas Leung | 200f040 | 2016-02-25 20:05:47 -0800 | [diff] [blame] | 49 | b .L${opcode}_set_vreg |
Alexey Frunze | 84603bf | 2016-10-21 19:54:43 -0700 | [diff] [blame] | 50 | #endif |
| 51 | %break |
Douglas Leung | 200f040 | 2016-02-25 20:05:47 -0800 | [diff] [blame] | 52 | |
Alexey Frunze | 84603bf | 2016-10-21 19:54:43 -0700 | [diff] [blame] | 53 | #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 |