From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KZWzD-0004t4-Fi for qemu-devel@nongnu.org; Sat, 30 Aug 2008 16:23:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KZWzB-0004re-PY for qemu-devel@nongnu.org; Sat, 30 Aug 2008 16:23:54 -0400 Received: from [199.232.76.173] (port=38099 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KZWzB-0004rZ-Ie for qemu-devel@nongnu.org; Sat, 30 Aug 2008 16:23:53 -0400 Received: from wf-out-1314.google.com ([209.85.200.174]:57015) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KZWzA-0004r7-Ay for qemu-devel@nongnu.org; Sat, 30 Aug 2008 16:23:52 -0400 Received: by wf-out-1314.google.com with SMTP id 27so1271956wfd.4 for ; Sat, 30 Aug 2008 13:23:50 -0700 (PDT) Message-ID: Date: Sat, 30 Aug 2008 23:23:50 +0300 From: "Blue Swirl" Subject: Re: [Qemu-devel] [PATCH] SH4: convert fmov/fadd to TCG In-Reply-To: <48B9A131.7080400@juno.dti.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <48B9A131.7080400@juno.dti.ne.jp> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On 8/30/08, Shin-ichiro KAWASAKI wrote: > This patch converts two SH4 float instructions, 'fmov Rm,Rn' and > 'fadd' into TCG. Before converting other float instructions > into TCG, comments on it will be appreciated. > > - TCG variables intorudced for float operation : FT[01], and DT[01]. > - I think float registers 'fregs' are not to be mapped for > TCG variables, because TCG does not support float operations, now. In TCG README Fabrice mentioned that he's working on a floating point version. It would be nice to get that committed, already m68k has a fake version. I did not use TCG variables for float just because I've been waiting for that. It's not possible to pass env->fp_status cleanly now (for example to call softfloat functions directly). And for example on Sparc host, moving data from integer registers to floating point registers must use memory in between them so there the integer TCG registers should be separate from float TCG registers. > +uint32_t helper_fadd_FT(uint32_t t0, uint32_t t1, CPUState * env) > +{ > + float32 ret = float32_add(*(float32*)&t0, *(float32*)&t1, &env->fp_status); > + return *(uint32_t*)(&ret); > +} There is no need to pass env as a parameter, it's available to op_helper.c code anyway. > +static inline void gen_ld_frN(TCGv ft, TCGv cpu_env, uint32_t reg) > +{ > + tcg_gen_ld_i32(ft, cpu_env, offsetof(CPUState, fregs[reg])); > +} > + > +static inline void gen_ld_drN(TCGv dt, TCGv cpu_env, uint32_t reg) > +{ > + TCGv tmp = tcg_temp_new(TCG_TYPE_I64); > + > + tcg_gen_ld_i64(dt, cpu_env, offsetof(CPUState, fregs[reg])); > + tcg_gen_shli_i64(tmp, dt, 32); > + tcg_gen_shri_i64(dt, dt, 32); > + tcg_gen_or_i64(dt, tmp, dt); > + > + tcg_temp_free(tmp); > +} I guess that like in Sparc, two 32 bit fregs can be combined to a 64 bit double. Please have a look at target-sparc/translate.c on the use of CPU_DoubleU, there should be a safer way to access the registers. Otherwise, good work!