Home | History | Annotate | Download | only in mips
      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
     13 
     14     li        t0, INT_MIN_AS_FLOAT
     15     mtc1      t0, fa1
     16 #ifdef MIPS32REVGE6
     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
     26 #else
     27     c.ole.s   fcc0, fa1, fa0
     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
     33 #endif
     34 1:
     35     trunc.w.s fa0, fa0
     36     SET_VREG_F_GOTO(fa0, rOBJ, t1)         #  vA <- result
     37