* [Qemu-devel] [4622] Fix for 32-bit MIPS.
@ 2008-05-30 0:12 Thiemo Seufer
2008-06-01 7:50 ` [Qemu-devel] " Richard Sandiford
0 siblings, 1 reply; 2+ messages in thread
From: Thiemo Seufer @ 2008-05-30 0:12 UTC (permalink / raw)
To: qemu-devel
Revision: 4622
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4622
Author: ths
Date: 2008-05-30 00:12:52 +0000 (Fri, 30 May 2008)
Log Message:
-----------
Fix for 32-bit MIPS.
Modified Paths:
--------------
trunk/target-mips/translate.c
Modified: trunk/target-mips/translate.c
===================================================================
--- trunk/target-mips/translate.c 2008-05-29 18:29:05 UTC (rev 4621)
+++ trunk/target-mips/translate.c 2008-05-30 00:12:52 UTC (rev 4622)
@@ -1904,15 +1904,16 @@
{
TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I64);
TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_I64);
+ TCGv r_tmp3 = tcg_temp_new(TCG_TYPE_I64);
- tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
- tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
- tcg_gen_div_i64(r_tmp1, cpu_T[0], cpu_T[1]);
- tcg_gen_rem_i64(r_tmp2, cpu_T[0], cpu_T[1]);
- tcg_gen_ext32s_tl(r_tmp1, r_tmp1);
- tcg_gen_ext32s_tl(r_tmp2, r_tmp2);
- gen_store_LO(r_tmp1, 0);
- gen_store_HI(r_tmp2, 0);
+ tcg_gen_ext_tl_i64(r_tmp1, cpu_T[0]);
+ tcg_gen_ext_tl_i64(r_tmp2, cpu_T[1]);
+ tcg_gen_div_i64(r_tmp3, r_tmp1, r_tmp2);
+ tcg_gen_rem_i64(r_tmp2, r_tmp1, r_tmp2);
+ tcg_gen_trunc_i64_tl(cpu_T[0], r_tmp3);
+ tcg_gen_trunc_i64_tl(cpu_T[1], r_tmp2);
+ gen_store_LO(cpu_T[0], 0);
+ gen_store_HI(cpu_T[1], 0);
}
gen_set_label(l1);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Qemu-devel] Re: [4622] Fix for 32-bit MIPS.
2008-05-30 0:12 [Qemu-devel] [4622] Fix for 32-bit MIPS Thiemo Seufer
@ 2008-06-01 7:50 ` Richard Sandiford
0 siblings, 0 replies; 2+ messages in thread
From: Richard Sandiford @ 2008-06-01 7:50 UTC (permalink / raw)
To: qemu-devel
Hi Thiemo,
Thanks for applying the patches, and sorry for the fallout on 32-bit
targets from the DIV patch.
Thiemo Seufer <ths@networkno.de> writes:
> @@ -1904,15 +1904,16 @@
> {
> TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I64);
> TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_I64);
> + TCGv r_tmp3 = tcg_temp_new(TCG_TYPE_I64);
>
> - tcg_gen_ext32s_tl(cpu_T[0], cpu_T[0]);
> - tcg_gen_ext32s_tl(cpu_T[1], cpu_T[1]);
> - tcg_gen_div_i64(r_tmp1, cpu_T[0], cpu_T[1]);
> - tcg_gen_rem_i64(r_tmp2, cpu_T[0], cpu_T[1]);
> - tcg_gen_ext32s_tl(r_tmp1, r_tmp1);
> - tcg_gen_ext32s_tl(r_tmp2, r_tmp2);
> - gen_store_LO(r_tmp1, 0);
> - gen_store_HI(r_tmp2, 0);
> + tcg_gen_ext_tl_i64(r_tmp1, cpu_T[0]);
> + tcg_gen_ext_tl_i64(r_tmp2, cpu_T[1]);
> + tcg_gen_div_i64(r_tmp3, r_tmp1, r_tmp2);
> + tcg_gen_rem_i64(r_tmp2, r_tmp1, r_tmp2);
> + tcg_gen_trunc_i64_tl(cpu_T[0], r_tmp3);
> + tcg_gen_trunc_i64_tl(cpu_T[1], r_tmp2);
> + gen_store_LO(cpu_T[0], 0);
> + gen_store_HI(cpu_T[1], 0);
> }
> gen_set_label(l1);
> }
This isn't quite right for 64-bit targets. Both pairs of "ext32s"s
really were needed. The input pair were needed so that we don't trigger
the SIGFPE for unpredictable cases in which the source operands are not
sign-extended. (Should never happen, of course, but it's a pain if it
crashes the emulator.) The output pair are needed so that the 32-bit
result is correctly sign-extended. E.g., with the problem case of
0xffffffff80000000 / -1, the result is now 0x0000000080000000 instead
of 0xffffffff80000000.
In other words, I think we need both the ext32s_tl and the ext_tl_i64/
trunc_i64_tl operations. Sorry for not picking this up in the original
submission.
Richard
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-06-01 7:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-30 0:12 [Qemu-devel] [4622] Fix for 32-bit MIPS Thiemo Seufer
2008-06-01 7:50 ` [Qemu-devel] " Richard Sandiford
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).