From patchwork Fri Feb 19 20:04:46 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: 8363581 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9B7059F2F0 for ; Fri, 19 Feb 2016 20:06:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED6ED2044C for ; Fri, 19 Feb 2016 20:06: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 460902044B for ; Fri, 19 Feb 2016 20:06:12 +0000 (UTC) Received: from localhost ([::1]:55001 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWrJb-0005CP-Ko for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Feb 2016 15:06:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWrId-0003oa-HU for qemu-devel@nongnu.org; Fri, 19 Feb 2016 15:05:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWrIa-0007KK-9C for qemu-devel@nongnu.org; Fri, 19 Feb 2016 15:05:11 -0500 Received: from mail-pa0-x231.google.com ([2607:f8b0:400e:c03::231]:34592) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWrIa-0007K4-2A; Fri, 19 Feb 2016 15:05:08 -0500 Received: by mail-pa0-x231.google.com with SMTP id fy10so55456050pac.1; Fri, 19 Feb 2016 12:05:07 -0800 (PST) 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=9zHW8MdnBap+PWGIIZRvMIc3FR2lIZ7K0NVWqwaDLNg=; b=aVjLW3wNzPkmw279qZ2yZ4l3Tx/MMPLS4+cvzxjLh1Fy96+0T+vsuzdTxY9CQyw1RB G7sRuajAfOijis0+r2vKjTXJXPYvm1Gr6RC8+IW6w/s+W7o4MR/1OuknonDM1kd7fWZ1 THaVVxLpcgNhob9vC4eu8JALhil7McoYz2W41/1+0MyisIMlgDO64aY0KzAi7hPFvVZz qWr8VSASKocFkTPP28qnuk1bxuwa3eCFoX0JLqZqRJprwCyLp6tXIpFLirU3LmV0kNnX lzmSZebiJsShVsUAI3e5QP9jY1italxemwOxZmY1Z9QGYCeT9suk7ImgLfjDoPntuTXh Lerw== 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=9zHW8MdnBap+PWGIIZRvMIc3FR2lIZ7K0NVWqwaDLNg=; b=hwxlpi9h9qUGpCEJMTv/luywPNJRrhkVqTXVe065w3qPJLmNeHoM4UELyOerUVomJV JraQTPWMv1W3OmzXggi0UnBvPDrRBeJHRBrCp5JNSoPxBWKw97JcFShd0jQsgHT105t4 ZIeiZi6KZHZ8/3FNEl3WKZq5hy76hw3erbyN8MkTaMwq5rJqipJ2+F8Ynlzf2eb8U8vU b3bnTqs66z+2Di9LkAZJij/Kv61p9+y0FxafcVpnSFFMOXMLBoRmQJhn9r7DAh+ZEWL+ FIlsAihkpUO4dUZFENfEX34rEm15ewheSLEdJ+BYv0+FurtNtgCjWztLVP722aRpyeH8 EZqg== X-Gm-Message-State: AG10YOTVZHYue8as+chFNV6ITefpm4HoZ4JPrbjpJpyfMefiQ+hvY7ju2X+Y8R0nQ9rihA== X-Received: by 10.66.187.36 with SMTP id fp4mr20691889pac.47.1455912307394; Fri, 19 Feb 2016 12:05:07 -0800 (PST) Received: from localhost (ec2-52-8-89-49.us-west-1.compute.amazonaws.com. [52.8.89.49]) by smtp.gmail.com with ESMTPSA id x12sm19564114pfi.88.2016.02.19.12.05.05 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 19 Feb 2016 12:05:06 -0800 (PST) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Fri, 19 Feb 2016 21:04:46 +0100 Message-Id: <1455912292-23807-3-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455912292-23807-1-git-send-email-edgar.iglesias@gmail.com> References: <1455912292-23807-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: 2607:f8b0:400e:c03::231 Cc: edgar.iglesias@xilinx.com, serge.fdrv@gmail.com, qemu-arm@nongnu.org, alex.bennee@linaro.org, rth@twiddle.net Subject: [Qemu-devel] [PATCH v2 2/8] gen-icount: Use tcg_set_insn_param 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org 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); }