From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KQTGy-0001Eb-Iw for qemu-devel@nongnu.org; Tue, 05 Aug 2008 16:36:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KQTGw-0001Db-PO for qemu-devel@nongnu.org; Tue, 05 Aug 2008 16:36:48 -0400 Received: from [199.232.76.173] (port=47822 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KQTGw-0001DD-Fe for qemu-devel@nongnu.org; Tue, 05 Aug 2008 16:36:46 -0400 Received: from rv-out-0708.google.com ([209.85.198.245]:19257) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KQTGw-0002LI-2a for qemu-devel@nongnu.org; Tue, 05 Aug 2008 16:36:46 -0400 Received: by rv-out-0708.google.com with SMTP id f25so2138923rvb.22 for ; Tue, 05 Aug 2008 13:36:43 -0700 (PDT) Message-ID: <761ea48b0808051336o120c3e9j286d9523a693f98f@mail.gmail.com> Date: Tue, 5 Aug 2008 22:36:43 +0200 From: "Laurent Desnogues" Subject: Re: [Qemu-devel] another SPARC issue In-Reply-To: <20080805161615.S57426@stanley.csl.cornell.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080728225136.C26546@stanley.csl.cornell.edu> <20080805161615.S57426@stanley.csl.cornell.edu> 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 Tue, Aug 5, 2008 at 10:20 PM, Vince Weaver wrote: > > The instruction is > ldda [ %o1 + 0x40 ] %asi, %f16 > > but under Qemu for some reason 0x80 is added to %o1 (instead of 0x40). > > Indeed if you look at the generated TCG (see below), the 0x40 is being added > in twice. I was digging around in translate.c but can't seem to see why > this is happning. > > Any help would be appreciated... Since I am not afraid to be ridiculous again, here is my take: - in disas_sparc_insn, line 4199: } else if (IS_IMM) { /* immediate */ rs2 = GET_FIELDs(insn, 19, 31); tcg_gen_addi_tl(cpu_addr, cpu_src1, (int)rs2); - line 4307: case 0x13: /* load double word alternate */ save_state(dc, cpu_cond); gen_ldda_asi(cpu_val, cpu_addr, insn, rd); static inline void gen_ldda_asi(TCGv hi, TCGv addr, int insn, int rd) { TCGv r_asi, r_rd; r_asi = gen_get_asi(insn, addr); r_rd = tcg_const_i32(rd); tcg_gen_helper_0_3(helper_ldda_asi, addr, r_asi, r_rd); tcg_temp_free(r_rd); tcg_temp_free(r_asi); } static inline TCGv gen_get_asi(int insn, TCGv r_addr) { int asi, offset; TCGv r_asi; if (IS_IMM) { r_asi = tcg_temp_new(TCG_TYPE_I32); offset = GET_FIELD(insn, 25, 31); tcg_gen_addi_tl(r_addr, r_addr, offset); tcg_gen_ld_i32(r_asi, cpu_env, offsetof(CPUSPARCState, asi)); } else { asi = GET_FIELD(insn, 19, 26); r_asi = tcg_const_i32(asi); } return r_asi; } I am not sure I followed the right path, but it seems that indeed for asi ld/st the constant gets added twice: once in the disas function and once in gen_get_asi. Laurent