From patchwork Fri Apr 29 12:07:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 8980351 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6BAD3BF440 for ; Fri, 29 Apr 2016 12:09:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B5C56201FA for ; Fri, 29 Apr 2016 12:09:12 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id E1833200E7 for ; Fri, 29 Apr 2016 12:09:11 +0000 (UTC) Received: from localhost ([::1]:53859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aw7EK-0002u7-0S for patchwork-qemu-devel@patchwork.kernel.org; Fri, 29 Apr 2016 08:09:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aw7E2-0002d8-QM for qemu-devel@nongnu.org; Fri, 29 Apr 2016 08:08:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aw7Dr-0001uO-5m for qemu-devel@nongnu.org; Fri, 29 Apr 2016 08:08:45 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:34520) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aw7Dp-0001m5-S4; Fri, 29 Apr 2016 08:08:39 -0400 Received: by mail-wm0-x241.google.com with SMTP id n129so4550069wmn.1; Fri, 29 Apr 2016 05:08:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+QWtejpj7urMP5cQsAvn135kbQjniVxyKEehJs0yjlc=; b=kNwXVlvvbjrxfN5ed05mV8N8qRebB8HbOF4jAG1BYC4BcfPUbCtaSwWAVFCkWD16WY 9Uc4oKTOoaaURoccrAkkJRIMZEF1m7wcI/GdAdwo28R65p7vlV1nux/5e21x2B5KrEe6 SHzI3T4nULOMY5RwKLuRzGbFHk+6DUpxdDYnwJbTa2EOezphq6JtwFpZQEDMd6kuWUGq GjL6cUfJJUj9HAcqBuOAeTUNMAPGbvWpsjgr2GETf9r+PgGC3ds2Lfe86pOiOqMVrlLz 1Zltyr3uGESl3dKLFPG83xHXiq/PrRXXrhqlv6Y2puFA5xAhq2WWm4pZqvka+v28ulz9 gr1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+QWtejpj7urMP5cQsAvn135kbQjniVxyKEehJs0yjlc=; b=HuW1PUcr4XZAUykLv7Kf64zSlcDFqJL7fPz7Trxti09/6HY8Tx3x8CgHBzb9HdBNRA 1yz+gXkAeYToz5kUR0xtFXRNRVQg/+55RqYBdCpq02DZzqGap371pT9A/S9FfjJXjG4Z Z5g1q2gukSwa2X2QNJ6+GKeDVbfa5igeyjoSUpqXnsYJ7KlBQY9OW/w3FkmZ8/P2YTvX HQuI7ykl7bGIumKRbVWCRhG15iPpXtKRj21H+IJjM0W6jsWEBNKPSxXhdhx5bzb7NuRJ 8YygAFDRkNpObY4HWfn6q09VkgE03DP9sKgSzYilB8bW/91xYerrV1EZbi3Mh/20A2aQ aElA== X-Gm-Message-State: AOPr4FXRfYINr1g6xtvHzbi3AhR/lRlEJE3K8jemlKkn5QK+1zTFpcZVVt2D4xsiYjFP5A== X-Received: by 10.194.15.8 with SMTP id t8mr1144181wjc.177.1461931688330; Fri, 29 Apr 2016 05:08:08 -0700 (PDT) Received: from localhost (81-231-233-234-no56.tbcn.telia.com. [81.231.233.234]) by smtp.gmail.com with ESMTPSA id n66sm3027718wmf.6.2016.04.29.05.08.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Apr 2016 05:08:07 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Fri, 29 Apr 2016 14:07:59 +0200 Message-Id: <1461931684-1867-3-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1461931684-1867-1-git-send-email-edgar.iglesias@gmail.com> References: <1461931684-1867-1-git-send-email-edgar.iglesias@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH v3 2/7] gen-icount: Use tcg_set_insn_param 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: edgar.iglesias@xilinx.com, serge.fdrv@gmail.com, qemu-arm@nongnu.org, alex.bennee@linaro.org, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Edgar E. Iglesias" Use tcg_set_insn_param() instead of directly accessing internal tcg data structures to update an insn param. Reviewed-by: Richard Henderson Signed-off-by: Edgar E. Iglesias --- include/exec/gen-icount.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index 05d89d3..a011324 100644 --- a/include/exec/gen-icount.h +++ b/include/exec/gen-icount.h @@ -5,14 +5,13 @@ /* Helpers for instruction counting code generation. */ -static TCGArg *icount_arg; +static int icount_start_insn_idx; static TCGLabel *icount_label; static TCGLabel *exitreq_label; static inline void gen_tb_start(TranslationBlock *tb) { TCGv_i32 count, flag, imm; - int i; exitreq_label = gen_new_label(); flag = tcg_temp_new_i32(); @@ -31,13 +30,12 @@ static inline void gen_tb_start(TranslationBlock *tb) -ENV_OFFSET + offsetof(CPUState, icount_decr.u32)); imm = tcg_temp_new_i32(); + /* We emit a movi with a dummy immediate argument. Keep the insn index + * of the movi so that we later (when we know the actual insn count) + * can update the immediate argument with the actual insn count. */ + icount_start_insn_idx = tcg_op_buf_count(); tcg_gen_movi_i32(imm, 0xdeadbeef); - /* This is a horrid hack to allow fixing up the value later. */ - i = tcg_ctx.gen_last_op_idx; - i = tcg_ctx.gen_op_buf[i].args; - icount_arg = &tcg_ctx.gen_opparam_buf[i + 1]; - tcg_gen_sub_i32(count, count, imm); tcg_temp_free_i32(imm); @@ -53,7 +51,9 @@ static void gen_tb_end(TranslationBlock *tb, int num_insns) tcg_gen_exit_tb((uintptr_t)tb + TB_EXIT_REQUESTED); if (tb->cflags & CF_USE_ICOUNT) { - *icount_arg = num_insns; + /* Update the num_insn immediate parameter now that we know + * the actual insn count. */ + tcg_set_insn_param(icount_start_insn_idx, 1, num_insns); gen_set_label(icount_label); tcg_gen_exit_tb((uintptr_t)tb + TB_EXIT_ICOUNT_EXPIRED); }