1 %default {"srcdouble":"1","tgtlong":"1"}
2 /* On fp to int conversions, Java requires that
3 * if the result > maxint, it should be clamped to maxint. If it is less
4 * than minint, it should be clamped to minint. If it is a nan, the result
5 * should be zero. Further, the rounding mode is to truncate. This model
6 * differs from what is delivered normally via the x86 fpu, so we have
9 /* float/double to int/long vA, vB */
10 movzbl rINST_HI,%ecx # ecx<- A+
11 sarl $$12,rINST_FULL # rINST_FULL<- B
13 fldl (rFP,rINST_FULL,4) # %st0<- vB
15 flds (rFP,rINST_FULL,4) # %st0<- vB
18 fnstcw LOCAL0_OFFSET(%ebp) # remember original rounding mode
19 movzwl LOCAL0_OFFSET(%ebp),%eax
21 movw %ax,LOCAL0_OFFSET+2(%ebp)
22 fldcw LOCAL0_OFFSET+2(%ebp) # set "to zero" rounding mode
24 andb $$0xf,%cl # ecx<- A
26 fistpll (rFP,%ecx,4) # convert and store
28 fistpl (rFP,%ecx,4) # convert and store
30 fldcw LOCAL0_OFFSET(%ebp) # restore previous rounding mode
31 jmp .L${opcode}_continue
37 movl $$0x80000000,%eax
38 xorl 4(rFP,%ecx,4),%eax
41 cmpl $$0x80000000,(rFP,%ecx,4)
43 je .L${opcode}_special_case # fix up result
49 .L${opcode}_special_case:
53 adcl $$-1,(rFP,%ecx,4)
55 adcl $$-1,4(rFP,%ecx,4)
57 jmp .L${opcode}_finish
61 movl $$0,4(rFP,%ecx,4)
63 jmp .L${opcode}_finish