qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: "Guo, Lei" <guol-fnst@cn.fujitsu.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "Wang, Chunping" <wangcp@cn.fujitsu.com>
Subject: Re: [Qemu-devel] Add CMP2 instruction
Date: Fri, 07 Nov 2014 12:26:22 +0100	[thread overview]
Message-ID: <545CAC5E.2030607@twiddle.net> (raw)
In-Reply-To: <36D1AB4E1AAC4541A1C88167C7231D0B74BAAD@G08CNEXMBPEKD02.g08.fujitsu.local>

On 11/07/2014 11:14 AM, Guo, Lei wrote:
> This patch aims to add CMP2 instruction for m68k family.

Mainline target-m68k supports coldfire only.

There is an external tree for full m68k support:

   https://gitorious.org/qemu-m68k

That said, before you send this to them...

> +    if (ext & 0x8000) {
> +           reg = AREG(ext, 12);

Failure to sign-extend for opsize == OS_WORD.
You need to use signed comparisons for this case.

> +    } else {
> +           reg = DREG(ext, 12);
> +           if (opsize == OS_BYTE){
> +                    tcg_gen_andi_i32(reg, reg, 0xf);
> +           } else if (opsize == OS_WORD) {
> +                          tcg_gen_andi_i32(reg, reg, 0xff);
> +           }
> +    }

Incorrect zero-extension; you've messed up the constants.
Use tcg_gen_ext{8,16}u_i32, anyway.
You need to use unsigned comparisons for this case.

> +    l1 = gen_new_label();
> +    l2 = gen_new_label();
> +    l3 = gen_new_label();
> +    l4 = gen_new_label();
> +   
> +    tcg_gen_brcond_i32(TCG_COND_NE, reg, lower, l1);

Ew.  You'd be much better off doing this with setcond than brcond.

  gen_flush_flags(s);

  t1 = tcg_temp_new();
  t2 = tcg_temp_new();
  t3 = tcg_temp_new();
  t4 = tcg_temp_new();

  tcg_gen_setcond_i32(TCG_COND_EQ, t1, reg, upper);
  tcg_gen_setcond_i32(TCG_COND_EQ, t2, reg, lower);
  tcg_gen_setcond_i32(which_gt, t3, reg, upper);
  tcg_gen_setcond_i32(which_lt, t4, reg, lower);

  tcg_gen_or_i32(t1, t1, t2);		/* equal to either bound */
  tcg_gen_or_i32(t3, t3, t4);		/* out of bounds */

  tcg_gen_shl_i32(t1, t1, ctz32(CCF_Z));	/* shift Z into place */
  tcg_gen_shl_i32(t3, t3, ctz32(CCF_C));	/* shift C into place */
  tcg_gen_or_i32(t1, t1, t3);
  tcg_gen_andi_i32(QREG_CC_DEST, QREG_CC_DEST, ~(CCF_C | CCF_Z));
  tcg_gen_or_i32(QREG_CC_DEST, QREG_CC_DEST, t1);


r~

  parent reply	other threads:[~2014-11-07 11:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-07 10:14 [Qemu-devel] Add CMP2 instruction Guo, Lei
2014-11-07 11:10 ` Alex Bennée
2014-11-07 11:15 ` Andreas Färber
2014-11-10  3:21   ` [Qemu-devel] 答复: " Guo, Lei
2014-11-10 11:30     ` Laurent Vivier
2014-11-07 11:26 ` Richard Henderson [this message]
2014-11-07 11:57 ` [Qemu-devel] " Laurent Vivier
2014-11-07 13:44 ` Laurent Vivier
2014-11-07 20:05 ` Andreas Schwab
  -- strict thread matches above, loose matches on Subject: below --
2014-11-10  1:35 Guo, Lei

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=545CAC5E.2030607@twiddle.net \
    --to=rth@twiddle.net \
    --cc=guol-fnst@cn.fujitsu.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wangcp@cn.fujitsu.com \
    /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).