From: Richard Henderson <rth@twiddle.net>
To: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>,
qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PATCH v3 4/4] target-tricore: Add instructions of RCR opcode format
Date: Thu, 20 Nov 2014 18:24:13 +0100 [thread overview]
Message-ID: <546E23BD.60803@twiddle.net> (raw)
In-Reply-To: <1416490114-26848-5-git-send-email-kbastian@mail.uni-paderborn.de>
On 11/20/2014 02:28 PM, Bastian Koppelmann wrote:
> +uint64_t helper_madd64_ssov(CPUTriCoreState *env, target_ulong r1,
> + uint64_t r2, target_ulong r3)
> +{
> + uint64_t ret_low, ret_high;
> + uint64_t r2_high;
> + int64_t t1 = sextract64(r1, 0, 32);
> + int64_t t3 = sextract64(r3, 0, 32);
> +
> + ret_low = t1 * t3;
> + ret_high = ((int64_t)ret_low >> 63);
> + r2_high = ((int64_t)r2 >> 63);
> + add128(&ret_low, &ret_high, r2, r2_high);
> +
> + /* check for saturate */
> + t1 = (int64_t)ret_low >> 63;
> + if (t1 != ret_high) {
Instead of 128-bit addition, just use the "normal" overflow detection:
mul = t1 * t3;
ret = mul + r2;
ovf = (ret ^ mul) & ~(mul ^ r2);
if ((int64_t)ovf < 0)
> +uint64_t helper_madd64_suov(CPUTriCoreState *env, target_ulong r1,
> + uint64_t r2, target_ulong r3)
> +{
> + uint64_t ret_low, ret_high;
> + uint64_t t1 = extract64(r1, 0, 32);
> + uint64_t t3 = extract64(r3, 0, 32);
> +
> + ret_low = t1 * t3;
> + ret_high = 0;
> + add128(&ret_low, &ret_high, r2, 0);
> +
> + if (ret_high != 0) {
I'm sure this is similar, though easier since its unsigned:
mul = t1 * t3;
ret = mul + r2;
if (ret < r2)
> + env->PSW_USB_V = (1 << 31);
> + env->PSW_USB_SV = (1 << 31);
> + ret_low = UINT64_MAX;
> + } else if ((ret_high & (1LL << 63)) != 0) {
I'm not sure what this is about though, since your "ret_high != 0" shadows it,
so it'll never be executed. Cut and paste from ssov, or is the addition
actually signed?
> +uint64_t helper_msub64_ssov(CPUTriCoreState *env, target_ulong r1,
> + uint64_t r2, target_ulong r3)
...
> +uint64_t helper_msub64_suov(CPUTriCoreState *env, target_ulong r1,
> + uint64_t r2, target_ulong r3)
Likewise, of course.
Otherwise, it looks good.
r~
prev parent reply other threads:[~2014-11-20 17:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-20 13:28 [Qemu-devel] [PATCH v3 0/4] Add TriCore RCPW, RCRR, RCRW, RLC and RCR instructions Bastian Koppelmann
2014-11-20 13:28 ` [Qemu-devel] [PATCH v3 1/4] target-tricore: Make TRICORE_FEATURES implying others Bastian Koppelmann
2014-11-20 13:28 ` [Qemu-devel] [PATCH v3 2/4] target-tricore: Add instructions of RCPW, RCRR and RCRW opcode format Bastian Koppelmann
2014-11-20 13:28 ` [Qemu-devel] [PATCH v3 3/4] target-tricore: Add instructions of RLC " Bastian Koppelmann
2014-11-20 13:28 ` [Qemu-devel] [PATCH v3 4/4] target-tricore: Add instructions of RCR " Bastian Koppelmann
2014-11-20 17:24 ` Richard Henderson [this message]
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=546E23BD.60803@twiddle.net \
--to=rth@twiddle.net \
--cc=kbastian@mail.uni-paderborn.de \
--cc=peter.maydell@linaro.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.