• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1    /*
2     * double-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     * for pre-R6.
8     */
9    /* unop vA, vB */
10    GET_OPA4(rOBJ)                         #  rOBJ <- A+
11    GET_OPB(a3)                            #  a3 <- B
12    EAS2(a3, rFP, a3)                      #  a3 <- &fp[B]
13    LOAD64_F(fa0, fa0f, a3)
14    FETCH_ADVANCE_INST(1)                  #  advance rPC, load rINST
15
16#ifdef MIPS32REVGE6
17    GET_INST_OPCODE(t1)                    #  extract opcode from rINST
18    trunc.l.d fa0, fa0
19    SET_VREG64_F_GOTO(fa0, fa0f, rOBJ, t1) #  vA <- result
20#else
21    c.eq.d    fcc0, fa0, fa0
22    li        rRESULT0, 0
23    li        rRESULT1, 0
24    bc1f      fcc0, .L${opcode}_get_opcode
25
26    li        t0, LONG_MIN_AS_DOUBLE_HIGH
27    mtc1      zero, fa1
28    MOVE_TO_FPU_HIGH(t0, fa1, fa1f)
29    c.ole.d   fcc0, fa0, fa1
30    li        rRESULT1, LONG_MIN_HIGH
31    bc1t      fcc0, .L${opcode}_get_opcode
32
33    neg.d     fa1, fa1
34    c.ole.d   fcc0, fa1, fa0
35    nor       rRESULT0, rRESULT0, zero
36    nor       rRESULT1, rRESULT1, zero
37    bc1t      fcc0, .L${opcode}_get_opcode
38
39    JAL(__fixdfdi)
40    GET_INST_OPCODE(t1)                    #  extract opcode from rINST
41    b         .L${opcode}_set_vreg
42#endif
43%break
44
45#ifndef MIPS32REVGE6
46.L${opcode}_get_opcode:
47    GET_INST_OPCODE(t1)                    #  extract opcode from rINST
48.L${opcode}_set_vreg:
49    SET_VREG64_GOTO(rRESULT0, rRESULT1, rOBJ, t1)   #  vA/vA+1 <- v0/v1
50#endif
51