1    /*
2     * double-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     * for pre-R6.
8     */
9    /* unop vA, vB */
10    GET_OPB(a3)                            #  a3 <- B
11    GET_OPA4(rOBJ)                         #  rOBJ <- A+
12    EAS2(a3, rFP, a3)                      #  a3 <- &fp[B]
13    LOAD64_F(fa0, fa0f, a3)
14    FETCH_ADVANCE_INST(1)                  #  advance rPC, load rINST
15#ifndef MIPS32REVGE6
16    li        t0, INT_MIN_AS_DOUBLE_HIGH
17    mtc1      zero, fa1
18    MOVE_TO_FPU_HIGH(t0, fa1, fa1f)
19    c.ole.d   fcc0, fa1, fa0
20#endif
21    GET_INST_OPCODE(t1)                    #  extract opcode from rINST
22#ifndef MIPS32REVGE6
23    bc1t      fcc0, 1f                     #  if INT_MIN <= vB, proceed to truncation
24    c.eq.d    fcc0, fa0, fa0
25    mtc1      zero, fa0
26    MOVE_TO_FPU_HIGH(zero, fa0, fa0f)
27    movt.d    fa0, fa1, fcc0               #  fa0 = ordered(vB) ? INT_MIN_AS_DOUBLE : 0
281:
29#endif
30    trunc.w.d fa0, fa0
31    SET_VREG_F_GOTO(fa0, rOBJ, t1)         #  vA <- result
32