From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrVT2-0003Ah-Fl for qemu-devel@nongnu.org; Thu, 20 Nov 2014 12:24:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XrVSt-0007ne-BC for qemu-devel@nongnu.org; Thu, 20 Nov 2014 12:24:28 -0500 Received: from mail-wg0-x22e.google.com ([2a00:1450:400c:c00::22e]:60422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrVSt-0007nC-5V for qemu-devel@nongnu.org; Thu, 20 Nov 2014 12:24:19 -0500 Received: by mail-wg0-f46.google.com with SMTP id x12so4344629wgg.19 for ; Thu, 20 Nov 2014 09:24:18 -0800 (PST) Sender: Richard Henderson Message-ID: <546E23BD.60803@twiddle.net> Date: Thu, 20 Nov 2014 18:24:13 +0100 From: Richard Henderson MIME-Version: 1.0 References: <1416490114-26848-1-git-send-email-kbastian@mail.uni-paderborn.de> <1416490114-26848-5-git-send-email-kbastian@mail.uni-paderborn.de> In-Reply-To: <1416490114-26848-5-git-send-email-kbastian@mail.uni-paderborn.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 4/4] target-tricore: Add instructions of RCR opcode format List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bastian Koppelmann , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org 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~