From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4Nuy-0008F7-Ec for qemu-devel@nongnu.org; Tue, 08 Jul 2014 01:26:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4Nus-0007y1-Oz for qemu-devel@nongnu.org; Tue, 08 Jul 2014 01:26:16 -0400 Received: from mail-qa0-x22a.google.com ([2607:f8b0:400d:c00::22a]:34681) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4Nus-0007xx-KO for qemu-devel@nongnu.org; Tue, 08 Jul 2014 01:26:10 -0400 Received: by mail-qa0-f42.google.com with SMTP id dc16so4501455qab.1 for ; Mon, 07 Jul 2014 22:26:10 -0700 (PDT) Sender: Richard Henderson Message-ID: <53BB80EE.7000607@twiddle.net> Date: Mon, 07 Jul 2014 22:26:06 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1404756822-3253-1-git-send-email-kbastian@mail.uni-paderborn.de> <1404756822-3253-13-git-send-email-kbastian@mail.uni-paderborn.de> In-Reply-To: <1404756822-3253-13-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 12/15] target-tricore: Add instructions of SBR 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 07/07/2014 11:13 AM, Bastian Koppelmann wrote: > Add instructions of SBR opcode format. > Add gen_loop micro-op generator function. > > Signed-off-by: Bastian Koppelmann > --- > target-tricore/translate.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 69 insertions(+) > > diff --git a/target-tricore/translate.c b/target-tricore/translate.c > index 69d99d3..5b11396 100644 > --- a/target-tricore/translate.c > +++ b/target-tricore/translate.c > @@ -281,6 +281,22 @@ static inline void gen_branch_condi(DisasContext *ctx, int cond, TCGv r1, > tcg_temp_free(temp); > } > > +static void gen_loop(DisasContext *ctx, int r1, int32_t offset) > +{ > + int l1; > + l1 = gen_new_label(); > + > + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr_a[r1], 0, l1); > + gen_save_pc(ctx->pc+offset); > + tcg_gen_subi_tl(cpu_gpr_a[r1], cpu_gpr_a[r1], 1); > + tcg_gen_exit_tb(0); > + gen_set_label(l1); > + gen_save_pc(ctx->pc+insn_bytes); > + tcg_gen_subi_tl(cpu_gpr_a[r1], cpu_gpr_a[r1], 1); > + tcg_gen_exit_tb(0); Given that TCG does not register allocate over blocks, you're probably better off subtracting first and comparing against -1, that way you don't need to keep re-loading a[r1] from memory. Again, goto_tb. > + gen_loop(ctx, r1, 0xffffffe0+(offset<<1)); > + break; I'd be happier seeing offset * 2 - 32. r~