Alexey Frunze | 84603bf | 2016-10-21 19:54:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * float-to-int |
| 3 | * |
| 4 | * We have to clip values to int 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_OPB(a3) # a3 <- B |
| 10 | GET_OPA4(rOBJ) # rOBJ <- A+ |
| 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 | |
Alexey Frunze | 84603bf | 2016-10-21 19:54:43 -0700 | [diff] [blame] | 14 | li t0, INT_MIN_AS_FLOAT |
| 15 | mtc1 t0, fa1 |
Douglas Leung | 200f040 | 2016-02-25 20:05:47 -0800 | [diff] [blame] | 16 | #ifdef MIPS32REVGE6 |
Alexey Frunze | 84603bf | 2016-10-21 19:54:43 -0700 | [diff] [blame] | 17 | /* |
| 18 | * TODO: simplify this when the MIPS64R6 emulator |
| 19 | * supports NAN2008=1. |
| 20 | */ |
| 21 | cmp.le.s ft0, fa1, fa0 |
| 22 | GET_INST_OPCODE(t1) # extract opcode from rINST |
| 23 | bc1nez ft0, 1f # if INT_MIN <= vB, proceed to truncation |
| 24 | cmp.eq.s ft0, fa0, fa0 |
| 25 | selnez.s fa0, fa1, ft0 # fa0 = ordered(vB) ? INT_MIN_AS_FLOAT : 0 |
Douglas Leung | 200f040 | 2016-02-25 20:05:47 -0800 | [diff] [blame] | 26 | #else |
Douglas Leung | 200f040 | 2016-02-25 20:05:47 -0800 | [diff] [blame] | 27 | c.ole.s fcc0, fa1, fa0 |
Alexey Frunze | 84603bf | 2016-10-21 19:54:43 -0700 | [diff] [blame] | 28 | GET_INST_OPCODE(t1) # extract opcode from rINST |
| 29 | bc1t fcc0, 1f # if INT_MIN <= vB, proceed to truncation |
| 30 | c.eq.s fcc0, fa0, fa0 |
| 31 | mtc1 zero, fa0 |
| 32 | movt.s fa0, fa1, fcc0 # fa0 = ordered(vB) ? INT_MIN_AS_FLOAT : 0 |
Douglas Leung | 200f040 | 2016-02-25 20:05:47 -0800 | [diff] [blame] | 33 | #endif |
Alexey Frunze | 84603bf | 2016-10-21 19:54:43 -0700 | [diff] [blame] | 34 | 1: |
| 35 | trunc.w.s fa0, fa0 |
| 36 | SET_VREG_F_GOTO(fa0, rOBJ, t1) # vA <- result |