From patchwork Thu Oct 16 08:56:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Batuzov X-Patchwork-Id: 400227 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DDD481400D6 for ; Thu, 16 Oct 2014 19:58:05 +1100 (AEDT) Received: from localhost ([::1]:49285 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xegsl-0002iJ-RP for incoming@patchwork.ozlabs.org; Thu, 16 Oct 2014 04:58:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xegs1-0001Y5-Om for qemu-devel@nongnu.org; Thu, 16 Oct 2014 04:57:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xegrq-0006Uq-Us for qemu-devel@nongnu.org; Thu, 16 Oct 2014 04:57:17 -0400 Received: from smtp.ispras.ru ([83.149.199.79]:49274) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xegrq-0006UE-OG for qemu-devel@nongnu.org; Thu, 16 Oct 2014 04:57:06 -0400 Received: from bulbul.intra.ispras.ru (unknown [83.149.199.91]) by smtp.ispras.ru (Postfix) with ESMTP id 0F9DF224AF; Thu, 16 Oct 2014 12:57:06 +0400 (MSK) From: Kirill Batuzov To: qemu-devel@nongnu.org Date: Thu, 16 Oct 2014 12:56:50 +0400 Message-Id: <456dce4adb69662d9a17d9686e9b17febba8f765.1413286807.git.batuzovk@ispras.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: <87k3571pb5.fsf@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.79 Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Kirill Batuzov Subject: [Qemu-devel] [PATCH RFC 3/7] tcg: add sync_temp opcode 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 Currently every field of CPUArchState can be accessed from the TCG-generated code as a memory location or as a global but not both. In order to be able to mix these two approaches we need to restore consistency between value of global (possibly kept on register) and value in corresponding memory location. Introduce sync_temp TCGOpcode which instructs register allocator to save value of a global into its memory location. Signed-off-by: Kirill Batuzov --- tcg/tcg-op.h | 10 ++++++++++ tcg/tcg-opc.h | 1 + tcg/tcg.c | 12 ++++++++++++ 3 files changed, 23 insertions(+) diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index 81291fd..ea2b14f 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -1808,6 +1808,16 @@ static inline void tcg_gen_discard_i64(TCGv_i64 arg) #endif } +static inline void tcg_gen_discard_v128(TCGv_v128 arg) +{ + tcg_gen_op1_v128(INDEX_op_discard, arg); +} + +static inline void tcg_gen_sync_temp_v128(TCGv_v128 arg) +{ + tcg_gen_op1_v128(INDEX_op_sync_temp, arg); +} + static inline void tcg_gen_andc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) { if (TCG_TARGET_HAS_andc_i32) { diff --git a/tcg/tcg-opc.h b/tcg/tcg-opc.h index 042d442..0916d83 100644 --- a/tcg/tcg-opc.h +++ b/tcg/tcg-opc.h @@ -37,6 +37,7 @@ DEF(nop3, 0, 0, 3, TCG_OPF_NOT_PRESENT) DEF(nopn, 0, 0, 1, TCG_OPF_NOT_PRESENT) DEF(discard, 1, 0, 0, TCG_OPF_NOT_PRESENT) +DEF(sync_temp, 0, 1, 0, TCG_OPF_NOT_PRESENT) DEF(set_label, 0, 0, 1, TCG_OPF_BB_END | TCG_OPF_NOT_PRESENT) /* variable number of parameters */ diff --git a/tcg/tcg.c b/tcg/tcg.c index d01f357..ff157b7 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1553,6 +1553,11 @@ static void tcg_liveness_analysis(TCGContext *s) dead_temps[args[0]] = 1; mem_temps[args[0]] = 0; break; + case INDEX_op_sync_temp: + args--; + dead_temps[args[0]] = 1; + mem_temps[args[0]] = 1; + break; case INDEX_op_end: break; @@ -2527,6 +2532,13 @@ static inline int tcg_gen_code_common(TCGContext *s, case INDEX_op_discard: temp_dead(s, args[0]); break; + case INDEX_op_sync_temp: + /* We use it only for globals currently. */ + assert(args[0] < s->nb_globals); + if (s->temps[args[0]].val_type == TEMP_VAL_REG) { + tcg_reg_free(s, s->temps[args[0]].reg); + } + break; case INDEX_op_set_label: tcg_reg_alloc_bb_end(s, s->reserved_regs); tcg_out_label(s, args[0], s->code_ptr);