From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XENiX-0008Km-MN for qemu-devel@nongnu.org; Mon, 04 Aug 2014 15:14:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XENiO-0004Ru-LV for qemu-devel@nongnu.org; Mon, 04 Aug 2014 15:14:45 -0400 Received: from mail-qg0-x235.google.com ([2607:f8b0:400d:c04::235]:38717) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XENiO-0004Rq-H5 for qemu-devel@nongnu.org; Mon, 04 Aug 2014 15:14:36 -0400 Received: by mail-qg0-f53.google.com with SMTP id q107so9352460qgd.26 for ; Mon, 04 Aug 2014 12:14:36 -0700 (PDT) Sender: Richard Henderson Message-ID: <53DFDB95.2010904@twiddle.net> Date: Mon, 04 Aug 2014 09:14:29 -1000 From: Richard Henderson MIME-Version: 1.0 References: <1407173932-969-1-git-send-email-kbastian@mail.uni-paderborn.de> <1407173932-969-8-git-send-email-kbastian@mail.uni-paderborn.de> In-Reply-To: <1407173932-969-8-git-send-email-kbastian@mail.uni-paderborn.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 07/15] target-tricore: Add instructions of SRR 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 08/04/2014 07:38 AM, Bastian Koppelmann wrote: > +target_ulong helper_add_ssov(CPUTRICOREState *env, target_ulong r1, > + target_ulong r2) > +{ > + target_ulong ret; > + int64_t result = (int64_t)r1 + (int64_t)r2; > + SSOV(env, ret, result, 32); > + return ret; > +} > + > +target_ulong helper_sub_ssov(CPUTRICOREState *env, target_ulong r1, > + target_ulong r2) > +{ > + target_ulong ret; > + int64_t result = (int64_t)r1 - (int64_t)r2; > + SSOV(env, ret, result, 32); > + return ret; > +} > + This zero-extends r1 and r2; you need to sign-extend in order for your saturation to work. > + tcg_gen_sub2_tl(ret, cpu_PSW_V, r1, t0, r2, t0); > + gen_calc_psw_sv_i32(cpu_PSW_SV, cpu_PSW_V); This computes neither carry nor overflow. > + /* mul and set V/SV bits */ > + tcg_gen_muls2_tl(ret, cpu_PSW_V, r1, r2); Overflow computation requires that you compare the high part of the result vs the sign of the low part of the result. I.e. overflow = (high != (low >> 31)); r~