On Tue, Jun 26, 2012 at 1:14 PM, 陳韋任 (Wei-Ren Chen)
<che...@iis.sinica.edu.tw> wrote:
>> > 0xffffffff is -1, 0x80000000 is -MAX.
>> > -1/-MAX ?will raise a exception, and I've handle this.

-1 / -MAX equals 0, it's not the issue here.

>> > -MAX/-1 ?will get a MAX, for max value of a register is -(-MAX)-1, so,
>> > it overflowed, I didn't handle this.
>>
>> Actually you did this with three brcondi in the else branch. The only thing
>> left is not to crash in case guest doesn't want range exception.
>
> So Jia need to do something like below
>
>  /*
>   *  if ((%ra == 0xffffffff || %rb == 0x80000000) && (sr_ove == 0))

Actually the condition that needs special care is

((%rb == 0 || %ra == 0x80000000 && %rb == 0xffffffff) && sr_ove == 0)

>   *    goto lab3;
>   *
>   *  lab3:
>   *    compute %ra/%rb but do NOT cause host failed?

This step is empty if the result is undefined, which I think is the case.

>   */
>  tcg_gen_ori_tl(cpu_sr, cpu_sr, SR_OV);
>  tcg_gen_ori_tl(cpu_sr, cpu_sr, SR_CY);

If we get here then the first part of condition (before && sr_ove == 0)
is true.

>  tcg_gen_brcondi_tl(TCG_COND_NE, sr_ove, SR_OVE, lab3);
>  gen_exception(dc, EXCP_RANGE);
>  gen_set_label(lab2);
>  tcg_gen_div_tl(cpu_R[rd], cpu_R[ra], cpu_R[rb]);
>  gen_set_label(lab3);
>
>    ???

??? == just nothing.

-- 
Thanks.
-- Max

Reply via email to