• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
13
14#ifdef MIPS32REVGE6
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
261:
27    trunc.l.s fa0, fa0
28    SET_VREG64_F_GOTO(fa0, fa0f, rOBJ, t1) #  vA <- result
29#else
30    c.eq.s    fcc0, fa0, fa0
31    li        rRESULT0, 0
32    li        rRESULT1, 0
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
46
47    JAL(__fixsfdi)
48    GET_INST_OPCODE(t1)                    #  extract opcode from rINST
49    b         .L${opcode}_set_vreg
50#endif
51%break
52
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
59