From patchwork Mon Jul 24 20:27:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9860423 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0F1CF60349 for ; Mon, 24 Jul 2017 20:45:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02A5128538 for ; Mon, 24 Jul 2017 20:45:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBDFB285C1; Mon, 24 Jul 2017 20:45:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4D9A628538 for ; Mon, 24 Jul 2017 20:45:40 +0000 (UTC) Received: from localhost ([::1]:56892 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZkEV-00083T-F3 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 24 Jul 2017 16:45:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZjxu-0003I7-Bf for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZjxt-0001HF-2T for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:30 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:38089) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZjxs-0001GW-UM for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:29 -0400 Received: by mail-qt0-x242.google.com with SMTP id p3so2660250qtg.5 for ; Mon, 24 Jul 2017 13:28:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HNsH8uprwpWU8HLk/8041XnWXuiZW4bVZK15kEqh1fo=; b=m6AuZcWmQqApWXo+2wmvODBRGjyoqBEkql9tf0HC1HFYGlzwnUgss3tsqCrPU1RAPf w63qDTdYVggOMMqEyVw455Uk8XW+ih1MD2iY4xZHpPHSeg8at06q8M0WOHAdEBp/4KCz QiZF+FxsUUKF8zvxjJyfLV2FPDxl30pTx2PHD6XVYFLXy80hQEnfdGfT7TQX7hOVwKyt q+U+3nEk6Rc5OaQ5MkmYVWTIkQSmjK/NE/Hw5dEcYzBRLAQk5hDNFIZksiZA1LUDfOgC +gJCWioOMWwLuJ2rmL4zD7mCzXkOHwlK6I8qrV/HGwB/RxHbQ8n7N3TUFDmzzIeY5Pa7 cNrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=HNsH8uprwpWU8HLk/8041XnWXuiZW4bVZK15kEqh1fo=; b=PdYk661zbmOhXraSr5Ud190FmnX0DXRUDtbSXMw/28R6p5N6xaAMjJ/tKqe+urXDbY rtQkYZj33V5lZhymqpBaOeem+9lyoAxdwyoeLF4YWFf4/v9gDS5Jkb+frlscFxFUyE1n OavwK9oVvMfIUfEhKW1RKSTyLOPYn+JqMKlX5G6HYhZPLxgMUMZ2P5EfQXyc7fzqGQn5 pR4OH6P+1mjqzMzLtRcG3dUYNf+2P/PnFH/oBbe0fSZR/nHR6kK2LHi62qNwCNBWJTl5 lNJ5mGPJSPYnHs8aRy6D/e9pdJJYSuCCecsB5XIMzChLsdrA4/LjNxCHEVieTRhHEXh8 1xWg== X-Gm-Message-State: AIVw110mJbbg/1H96597Oog1gi7Z+pr2E2ddXkuYjIk4sA7Flwl0hHcJ 2P1mHEA4HNeTdPCEhzE= X-Received: by 10.237.41.230 with SMTP id o93mr23656627qtd.27.1500928108049; Mon, 24 Jul 2017 13:28:28 -0700 (PDT) Received: from bigtime.com ([71.217.194.233]) by smtp.gmail.com with ESMTPSA id p52sm9196808qtc.74.2017.07.24.13.28.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jul 2017 13:28:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 24 Jul 2017 13:27:14 -0700 Message-Id: <20170724202728.25960-19-rth@twiddle.net> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170724202728.25960-1-rth@twiddle.net> References: <20170724202728.25960-1-rth@twiddle.net> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PATCH v15 18/32] target/arm: [tcg] Port to tb_start X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cota@braap.org, vilanova@ac.upc.edu Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Lluís Vilanova Incrementally paves the way towards using the generic instruction translation loop. Signed-off-by: Lluís Vilanova Reviewed-by: Richard Henderson Reviewed-by: Alex Benneé Message-Id: <150002364681.22386.1701754996184325808.stgit@frigg.lan> [rth: Adjust for tb_start interface change.] Signed-off-by: Richard Henderson --- target/arm/translate.c | 82 +++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index 4e9e3c46b3..5acdeabebb 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -11863,6 +11863,49 @@ static int arm_tr_init_disas_context(DisasContextBase *dcbase, return max_insns; } +static void arm_tr_tb_start(DisasContextBase *dcbase, CPUState *cpu) +{ + DisasContext *dc = container_of(dcbase, DisasContext, base); + + /* A note on handling of the condexec (IT) bits: + * + * We want to avoid the overhead of having to write the updated condexec + * bits back to the CPUARMState for every instruction in an IT block. So: + * (1) if the condexec bits are not already zero then we write + * zero back into the CPUARMState now. This avoids complications trying + * to do it at the end of the block. (For example if we don't do this + * it's hard to identify whether we can safely skip writing condexec + * at the end of the TB, which we definitely want to do for the case + * where a TB doesn't do anything with the IT state at all.) + * (2) if we are going to leave the TB then we call gen_set_condexec() + * which will write the correct value into CPUARMState if zero is wrong. + * This is done both for leaving the TB at the end, and for leaving + * it because of an exception we know will happen, which is done in + * gen_exception_insn(). The latter is necessary because we need to + * leave the TB with the PC/IT state just prior to execution of the + * instruction which caused the exception. + * (3) if we leave the TB unexpectedly (eg a data abort on a load) + * then the CPUARMState will be wrong and we need to reset it. + * This is handled in the same way as restoration of the + * PC in these situations; we save the value of the condexec bits + * for each PC via tcg_gen_insn_start(), and restore_state_to_opc() + * then uses this to restore them after an exception. + * + * Note that there are no instructions which can read the condexec + * bits, and none which can write non-static values to them, so + * we don't need to care about whether CPUARMState is correct in the + * middle of a TB. + */ + + /* Reset the conditional execution bits immediately. This avoids + complications trying to do it at the end of the block. */ + if (dc->condexec_mask || dc->condexec_cond) { + TCGv_i32 tmp = tcg_temp_new_i32(); + tcg_gen_movi_i32(tmp, 0); + store_cpu_field(tmp, condexec_bits); + } +} + /* generate intermediate code for basic block 'tb'. */ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) { @@ -11902,45 +11945,8 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) gen_tb_start(tb); tcg_clear_temp_count(); + arm_tr_tb_start(&dc->base, cs); - /* A note on handling of the condexec (IT) bits: - * - * We want to avoid the overhead of having to write the updated condexec - * bits back to the CPUARMState for every instruction in an IT block. So: - * (1) if the condexec bits are not already zero then we write - * zero back into the CPUARMState now. This avoids complications trying - * to do it at the end of the block. (For example if we don't do this - * it's hard to identify whether we can safely skip writing condexec - * at the end of the TB, which we definitely want to do for the case - * where a TB doesn't do anything with the IT state at all.) - * (2) if we are going to leave the TB then we call gen_set_condexec() - * which will write the correct value into CPUARMState if zero is wrong. - * This is done both for leaving the TB at the end, and for leaving - * it because of an exception we know will happen, which is done in - * gen_exception_insn(). The latter is necessary because we need to - * leave the TB with the PC/IT state just prior to execution of the - * instruction which caused the exception. - * (3) if we leave the TB unexpectedly (eg a data abort on a load) - * then the CPUARMState will be wrong and we need to reset it. - * This is handled in the same way as restoration of the - * PC in these situations; we save the value of the condexec bits - * for each PC via tcg_gen_insn_start(), and restore_state_to_opc() - * then uses this to restore them after an exception. - * - * Note that there are no instructions which can read the condexec - * bits, and none which can write non-static values to them, so - * we don't need to care about whether CPUARMState is correct in the - * middle of a TB. - */ - - /* Reset the conditional execution bits immediately. This avoids - complications trying to do it at the end of the block. */ - if (dc->condexec_mask || dc->condexec_cond) - { - TCGv_i32 tmp = tcg_temp_new_i32(); - tcg_gen_movi_i32(tmp, 0); - store_cpu_field(tmp, condexec_bits); - } do { dc->base.num_insns++; dc->insn_start_idx = tcg_op_buf_count();