From patchwork Fri Feb 12 14:33:55 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: 8292371 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 0EB7EC1F0D for ; Fri, 12 Feb 2016 14:38:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 619C7203C1 for ; Fri, 12 Feb 2016 14:38:43 +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 B82F22039E for ; Fri, 12 Feb 2016 14:38:42 +0000 (UTC) Received: from localhost ([::1]:33142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUErp-0003JS-QS for patchwork-qemu-devel@patchwork.kernel.org; Fri, 12 Feb 2016 09:38:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUEpu-0008Q2-PR for qemu-devel@nongnu.org; Fri, 12 Feb 2016 09:36:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aUEpt-0002bv-Qr for qemu-devel@nongnu.org; Fri, 12 Feb 2016 09:36:42 -0500 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:32848) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUEpt-0002br-Jx; Fri, 12 Feb 2016 09:36:41 -0500 Received: by mail-pf0-x244.google.com with SMTP id c10so4067631pfc.0; Fri, 12 Feb 2016 06:36:41 -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=TGRKBg0n9luRafbj/tDQZ1aELREVGp8P/29q7b0CGPIB3h3B+gz1qckCfNoNLPV+YT imx7PrO2KPJn4Knyw341QGQmNaJ4Eds5yt8ugOkNyYnVZgSn+aXo1gecKnCnTAhuyj53 AC5wPGsCLM4KM2MEJtIk81PNXpVMaw9MlGtLlT28P9H3N8pt13zInFTaA6aVInI8FEsx mFjCWNAkSPiVUUoDFvDJZfckL/Spuc3oDpL46753OMGaIc/02dSQzAoOzG0XWDDtgYF1 OaFrnfoswHJ0eqnqu8+L7QvrLwTn/Ps0zzRnRUY9oiGdUydJOBG9BsqCBzssftL3m522 kuWA== 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=XRSKMrQkn8XDBw2FXTLx/sCe0Ghxmd5tjc61nSoF52JDCCPoVPjTLH7y3laKTegESk 0CaUxqM/wKHPlZzZLmYyeFxEEe8+mRcNRgKO8Z4ct5avTEaUnmiirK5EwMCUY7SzdUd7 0zWc69KvV2x3BLm18l9NcbGjPrd9KwBWiiOy7SNDjXaabwXMqcTrxDP2pPhMydv/V09W uMCG/Nx4BQVSN00asEgCR2WlnIZuS+jIEdKj0aRccSRkR8c2DdSdxr8Y5zZGDsXHqEaA 2n37c0JSA8GDidWoVwQAzHayZ2PK9dub6tTbi9J2fcYzpTtqOwM3QteQqDou7Tubx8a3 t65A== X-Gm-Message-State: AG10YOR9MLpZUoIKYtrKu0IPGEbhOHRGvWoMt2AM4m/wWogPfrvCwfqtsya4C1Uvw4Sa5w== X-Received: by 10.98.40.5 with SMTP id o5mr2651791pfo.76.1455287800928; Fri, 12 Feb 2016 06:36:40 -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 82sm19965622pfn.89.2016.02.12.06.36.39 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 12 Feb 2016 06:36:40 -0800 (PST) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Fri, 12 Feb 2016 15:33:55 +0100 Message-Id: <1455287642-28166-3-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455287642-28166-1-git-send-email-edgar.iglesias@gmail.com> References: <1455287642-28166-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:c00::244 Cc: edgar.iglesias@xilinx.com, serge.fdrv@gmail.com, qemu-arm@nongnu.org, alex.bennee@linaro.org, rth@twiddle.net Subject: [Qemu-devel] [PATCH v1 2/9] 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); }