From patchwork Tue Oct 9 22:04:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 190481 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9E6312C0088 for ; Wed, 10 Oct 2012 09:04:55 +1100 (EST) Received: from localhost ([::1]:47479 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLhv3-0004N7-HJ for incoming@patchwork.ozlabs.org; Tue, 09 Oct 2012 18:04:53 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47832) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLhul-0004HM-DP for qemu-devel@nongnu.org; Tue, 09 Oct 2012 18:04:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLhuk-0001gw-7i for qemu-devel@nongnu.org; Tue, 09 Oct 2012 18:04:35 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:34860) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLhuk-0001fh-27 for qemu-devel@nongnu.org; Tue, 09 Oct 2012 18:04:34 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp2so5751708pbb.4 for ; Tue, 09 Oct 2012 15:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=E3Q6vz3TWpU9jjPLAPOQONLLQvN5STHQi1XbOtC3IPI=; b=MUYm8BNZ6gwCqrETqZtHpFStJLlVQz8Y5GbkXJt53UOYBdpYiP900yHnwHMrYKbWml hVwmzMiC/UtXUrVq+PuuD9YRYMPIvlh28RUqeTFn/PJQ73t8OHKrPca+LNdpsWkOg9vy mKYel0ejI5smWyaaIQmCnBWI26xgpCQMkkk2kHiXuKehGCvT5CCtKYaibSsv73BM67SX 6zbAcg5lDVI45xkbCQ9kWBV50hzjNoFmqqMBtquFqYxkY/sjACd6Q2veGJC9oyPB3gio LKgoqJaj5kOTZSnEyk4O5V4eKl9JoTPQ51sZ5ioVXK4pvszaJuadwBMDT3EU4oYKVANC d30w== Received: by 10.66.86.2 with SMTP id l2mr56835831paz.70.1349820273626; Tue, 09 Oct 2012 15:04:33 -0700 (PDT) Received: from anchor.twiddle.home.com (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPS id tt6sm12970604pbc.51.2012.10.09.15.04.32 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 09 Oct 2012 15:04:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 9 Oct 2012 15:04:08 -0700 Message-Id: <1349820267-26320-2-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1349820267-26320-1-git-send-email-rth@twiddle.net> References: <1349820267-26320-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: Blue Swirl Subject: [Qemu-devel] [PATCH 01/20] target-sparc: Add gen_load/store/dest_gpr X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Infrastructure to be used to clean up handling of temporaries. Signed-off-by: Richard Henderson --- target-sparc/translate.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/target-sparc/translate.c b/target-sparc/translate.c index 6cef96b..eec0db0 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -83,7 +83,9 @@ typedef struct DisasContext { struct TranslationBlock *tb; sparc_def_t *def; TCGv_i32 t32[3]; + TCGv ttl[5]; int n_t32; + int n_ttl; } DisasContext; typedef struct { @@ -263,6 +265,49 @@ static inline void gen_address_mask(DisasContext *dc, TCGv addr) #endif } +static inline TCGv get_temp_tl(DisasContext *dc) +{ + TCGv t; + assert(dc->n_ttl < ARRAY_SIZE(dc->ttl)); + dc->ttl[dc->n_ttl++] = t = tcg_temp_new(); + return t; +} + +static inline TCGv gen_load_gpr(DisasContext *dc, int reg) +{ + if (reg == 0 || reg >= 8) { + TCGv t = get_temp_tl(dc); + if (reg == 0) { + tcg_gen_movi_tl(t, 0); + } else { + tcg_gen_ld_tl(t, cpu_regwptr, (reg - 8) * sizeof(target_ulong)); + } + return t; + } else { + return cpu_gregs[reg]; + } +} + +static inline void gen_store_gpr(DisasContext *dc, int reg, TCGv v) +{ + if (reg > 0) { + if (reg < 8) { + tcg_gen_mov_tl(cpu_gregs[reg], v); + } else { + tcg_gen_st_tl(v, cpu_regwptr, (reg - 8) * sizeof(target_ulong)); + } + } +} + +static inline TCGv gen_dest_gpr(DisasContext *dc, int reg) +{ + if (reg == 0 || reg >= 8) { + return get_temp_tl(dc); + } else { + return cpu_gregs[reg]; + } +} + static inline void gen_movl_reg_TN(int reg, TCGv tn) { if (reg == 0) @@ -5229,6 +5274,13 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) } dc->n_t32 = 0; } + if (dc->n_ttl != 0) { + int i; + for (i = dc->n_ttl - 1; i >= 0; --i) { + tcg_temp_free(dc->ttl[i]); + } + dc->n_ttl = 0; + } } static inline void gen_intermediate_code_internal(TranslationBlock * tb,