qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC] TCG new op: setcond


From: Avi Kivity
Subject: Re: [Qemu-devel] [RFC] TCG new op: setcond
Date: Tue, 04 Nov 2008 16:24:29 +0200
User-agent: Thunderbird 2.0.0.16 (X11/20080723)

Laurent Desnogues wrote:
this patch implements a new TCG op, setcond, that sets a temp
to 1 if the condition is true, else to 0.  The benefit is the potential
removal of brcond instructions, and helpers size reduction which
can lead to using TCG instead of helpers.

This patch is only posted here to get comments before I dig
further into that and propose a proper update.

One of the ARM helpers (sub with flag settings) has been
converted to TCG and uses setcond to compute carry.

setcond has been implemented only for x86_64 TCG back-end.

+// TODO should apply to setcond_i64 but not tested
+static void tcg_out_setcond(TCGContext *s, int cond,
+                            TCGArg ret, TCGArg arg1, TCGArg arg2, int rexw)
+{
+    /* clear ret since setcc only sets the lower 8 bits */
+    tcg_out_modrm(s, 0x01 | (ARITH_XOR << 3) | rexw, ret, ret);
+    /* cmp */
+    tcg_out_modrm(s, 0x01 | (ARITH_CMP << 3) | rexw, arg2, arg1);
+    /* setcc */
+    // TODO this should use tcg_out_modrm
+    //      however currently tcg_out_modrm outputs an extra byte for [abcd]l
+    //tcg_out_modrm(s, (0x90 + tcg_cond_to_jcc[cond]) | P_EXT | P_REXB, ret, 
0);
+    if (ret > 3)
+        tcg_out8(s, 0x40);
+    else if (ret > 7)
+        tcg_out8(s, 0x41);

if ret == 8 this fails.  You need to reverse the order of the tests.

+    tcg_out8(s, 0x0f);
+    tcg_out8(s, 0x90 + tcg_cond_to_jcc[cond]);
+    tcg_out8(s, 0xc0 + (ret & 7));
+}
+

--
error compiling committee.c: too many arguments to function





reply via email to

[Prev in Thread] Current Thread [Next in Thread]