From: Aurelien Jarno <aurelien@aurel32.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [5249] target-alpha: convert cmp* instructions to TCG
Date: Thu, 18 Sep 2008 09:24:25 +0000 [thread overview]
Message-ID: <E1KgFkP-0004Ld-Pm@cvs.savannah.gnu.org> (raw)
Revision: 5249
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5249
Author: aurel32
Date: 2008-09-18 09:24:25 +0000 (Thu, 18 Sep 2008)
Log Message:
-----------
target-alpha: convert cmp* instructions to TCG
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Modified Paths:
--------------
trunk/target-alpha/op.c
trunk/target-alpha/translate.c
Modified: trunk/target-alpha/op.c
===================================================================
--- trunk/target-alpha/op.c 2008-09-18 09:17:13 UTC (rev 5248)
+++ trunk/target-alpha/op.c 2008-09-18 09:24:25 UTC (rev 5249)
@@ -208,51 +208,6 @@
}
/* Tests */
-void OPPROTO op_cmpult (void)
-{
- if (T0 < T1)
- T0 = 1;
- else
- T0 = 0;
- RETURN();
-}
-
-void OPPROTO op_cmpule (void)
-{
- if (T0 <= T1)
- T0 = 1;
- else
- T0 = 0;
- RETURN();
-}
-
-void OPPROTO op_cmpeq (void)
-{
- if (T0 == T1)
- T0 = 1;
- else
- T0 = 0;
- RETURN();
-}
-
-void OPPROTO op_cmplt (void)
-{
- if ((int64_t)T0 < (int64_t)T1)
- T0 = 1;
- else
- T0 = 0;
- RETURN();
-}
-
-void OPPROTO op_cmple (void)
-{
- if ((int64_t)T0 <= (int64_t)T1)
- T0 = 1;
- else
- T0 = 0;
- RETURN();
-}
-
void OPPROTO op_cmpbge (void)
{
helper_cmpbge();
Modified: trunk/target-alpha/translate.c
===================================================================
--- trunk/target-alpha/translate.c 2008-09-18 09:17:13 UTC (rev 5248)
+++ trunk/target-alpha/translate.c 2008-09-18 09:24:25 UTC (rev 5249)
@@ -561,6 +561,38 @@
tcg_gen_movi_i64(cpu_ir[rc], 0);
}
+static always_inline void gen_cmp(TCGCond cond,
+ int ra, int rb, int rc,
+ int islit, int8_t lit)
+{
+ int l1, l2;
+ TCGv tmp;
+
+ if (unlikely(rc == 31))
+ return;
+
+ l1 = gen_new_label();
+ l2 = gen_new_label();
+
+ if (ra != 31) {
+ tmp = tcg_temp_new(TCG_TYPE_I64);
+ tcg_gen_mov_i64(tmp, cpu_ir[ra]);
+ } else
+ tmp = tcg_const_i64(0);
+ if (islit)
+ tcg_gen_brcondi_i64(cond, tmp, lit, l1);
+ else if (rb != 31)
+ tcg_gen_brcond_i64(cond, tmp, cpu_ir[rb], l1);
+ else
+ tcg_gen_brcondi_i64(cond, tmp, 0, l1);
+
+ tcg_gen_movi_i64(cpu_ir[rc], 0);
+ tcg_gen_br(l2);
+ gen_set_label(l1);
+ tcg_gen_movi_i64(cpu_ir[rc], 1);
+ gen_set_label(l2);
+}
+
static always_inline int translate_one (DisasContext *ctx, uint32_t insn)
{
uint32_t palcode;
@@ -848,7 +880,7 @@
break;
case 0x1D:
/* CMPULT */
- gen_arith3(ctx, &gen_op_cmpult, ra, rb, rc, islit, lit);
+ gen_cmp(TCG_COND_LTU, ra, rb, rc, islit, lit);
break;
case 0x20:
/* ADDQ */
@@ -940,7 +972,7 @@
break;
case 0x2D:
/* CMPEQ */
- gen_arith3(ctx, &gen_op_cmpeq, ra, rb, rc, islit, lit);
+ gen_cmp(TCG_COND_EQ, ra, rb, rc, islit, lit);
break;
case 0x32:
/* S8ADDQ */
@@ -992,7 +1024,7 @@
break;
case 0x3D:
/* CMPULE */
- gen_arith3(ctx, &gen_op_cmpule, ra, rb, rc, islit, lit);
+ gen_cmp(TCG_COND_LEU, ra, rb, rc, islit, lit);
break;
case 0x40:
/* ADDL/V */
@@ -1004,7 +1036,7 @@
break;
case 0x4D:
/* CMPLT */
- gen_arith3(ctx, &gen_op_cmplt, ra, rb, rc, islit, lit);
+ gen_cmp(TCG_COND_LT, ra, rb, rc, islit, lit);
break;
case 0x60:
/* ADDQ/V */
@@ -1016,7 +1048,7 @@
break;
case 0x6D:
/* CMPLE */
- gen_arith3(ctx, &gen_op_cmple, ra, rb, rc, islit, lit);
+ gen_cmp(TCG_COND_LE, ra, rb, rc, islit, lit);
break;
default:
goto invalid_opc;
reply other threads:[~2008-09-18 9:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1KgFkP-0004Ld-Pm@cvs.savannah.gnu.org \
--to=aurelien@aurel32.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).