From patchwork Thu Apr 4 23:06:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785860 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074604wro; Thu, 4 Apr 2024 16:09:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWO/wryL7NAad5rljNnTlxaZ+sAPKzkdHpDZYm/1SMUYhWsu0+ga+SDqgScXd9Eeka/5T2ykZeQ0tZXpgOWpKXs X-Google-Smtp-Source: AGHT+IFxOMvpGLIKleI3vR/Ze3kJ/SSRFRWureOhvYN+casrfEtnX1fyfMLytp8hCFLQj6g0kyJT X-Received: by 2002:a05:620a:880a:b0:78b:e555:a680 with SMTP id qj10-20020a05620a880a00b0078be555a680mr1158778qkn.52.1712272160113; Thu, 04 Apr 2024 16:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272160; cv=none; d=google.com; s=arc-20160816; b=EtxdPszEnt1qhyzP+cEMPdcmdzkpg6wez2dyldSLIj8RZNV+5/29CVKXNDh32o3/0U p1FZRL0XBwyVx2JtkYoY/AlQWRU5GdsvjdrZDRHoy6/uIVIpGnqguegM9TpGW9WOCUqf By9ZReihE0l3Q+VryddUyAQidhmUZ9VP/BvwJ0hQsGeXYFYGhYs+hftUZV4s0eCKDcN3 lb8hproo17AXGSruLJkr0SXGylYblM0xjbjJskquxWoMJp1igomG/e/gIiJVXhqxNNF2 PmIUu+cwawzYZApUoEDUXEoPEAOHaE2bbF4bL2uCHJJ/LaPC1WSvy76doS0tP/NJktKF OsBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LosuIyCzAc9oB5OxDPZNgW94mh4MJImjLMLCS31GDcs=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=Tn9faO1OmZEWrNSAQvYpEaeGCO+cy5DfbF1UGcqpKXIZ8SnOTuOQeSVDbQueDG+Ta6 GfqnujD+hUMkL6/ruY9A/i8wGJOn1BfnnfTyaDGUIJVyFZu7Cz6Z53a11mGJ5J7WHkZt esDMxtTK3OdCyThiX0rc8uWVqeqVcWjG5dM0ltrog1Lt6dE0RielAmXE5aDf1+2NLkxj 6VF1gwuXMnoUDBR+4EGiog7+DSoeDv8eRD/MKlieLal30zL8m8/TIB6SmrhFKRnVf9Gy oiShr0ozEam2ukfdXQs9JLUMbgNRAEuMI+IRkY/1FTd0gbYygCge3pBEha3WGt8gWLSY ABfg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OboIGTMZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id pa16-20020a05620a831000b0078a0a41e771si425600qkn.725.2024.04.04.16.09.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:09:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OboIGTMZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rsWAX-00029D-90; Thu, 04 Apr 2024 19:06:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rsWAL-00024X-Af for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:42 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWAJ-0007oQ-B9 for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:41 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-2a2c9903ef0so1149349a91.3 for ; Thu, 04 Apr 2024 16:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271998; x=1712876798; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LosuIyCzAc9oB5OxDPZNgW94mh4MJImjLMLCS31GDcs=; b=OboIGTMZwcuNF2FF1HLxC0z92zAMXT9T1BPVbYOgbx7zCjFwMB5Ro8znA4SX4daNxZ HJFRlpWt434bNppObDsjeasDDcVr8i5z8F5rp+bLC/esQFBV6uRE3Pqmlouoo6jDQgH2 qqG0/vlJT+wn2Z+LMSkStzClFvHlxI3F1jfjlveiu8LD2FU9J2EEQpxpYRuIlTy5JkBL YgCn5Tyw2Tn+zsyPy5v9tB3D4Aktovg9VvMphws19w9dbY91ZUceA0ry1EL5G6GaO8YZ vbP6pFZrfgIVS/7KLT/Km5ifgAaRHsdceO2ON+if57fpVns7iSecr9tgo9JBT4yV4aTk EEbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271998; x=1712876798; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LosuIyCzAc9oB5OxDPZNgW94mh4MJImjLMLCS31GDcs=; b=dcHFGl+m5Vj81SPoyL6nmkZQpswTSZW8KfzrVCQuFMJRMA5y22mUGsLUSx7sqHqj61 UejsNzTtg7v2B0fNHFHZ/xlxe/+pXFV4xEVyDP/sijkqKfB2wN0LoUHGli8LSCXo7Z99 kBhj35867VPHEABta4xksESROQ/wz8aP1OuMcn101gDGp0eAC2xVn4DWNXHznRo99HpU CEP5ohRC9MGcltZY2mwvMv/QmnYPYHXa8TK/3p/C6CScooK7InrnSQIC5bqVq8TKhYLf juUtsPhcXzWXFZw2uwVvBFhf0jy2lzzcSNjK3fr6kAW5iBk39PydxoXmNR4RJyLU7bkB hKIg== X-Gm-Message-State: AOJu0Yw3xbbLkc6NLvj0UEoRtMoMlGXF749M92h3fBCFPk7czHlbs7wJ PLWg5QXqvT31LplOL0z1TOw6uZzAyPLnGrBrNiuvrTdbP0OHjb/xD8uph20XA01UscrlzehAe6b h X-Received: by 2002:a17:90a:cb8d:b0:2a2:7064:447a with SMTP id a13-20020a17090acb8d00b002a27064447amr1166183pju.18.1712271998141; Thu, 04 Apr 2024 16:06:38 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 18/21] plugins: Split out common cb expanders Date: Thu, 4 Apr 2024 13:06:08 -1000 Message-Id: <20240404230611.21231-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- accel/tcg/plugin-gen.c | 84 +++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 49d9b07438..5b63b93114 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -187,6 +187,37 @@ static void gen_mem_cb(struct qemu_plugin_dyn_cb *cb, tcg_temp_free_i32(cpu_index); } +static void inject_cb(struct qemu_plugin_dyn_cb *cb) + +{ + switch (cb->type) { + case PLUGIN_CB_REGULAR: + gen_udata_cb(cb); + break; + case PLUGIN_CB_INLINE: + gen_inline_cb(cb); + break; + default: + g_assert_not_reached(); + } +} + +static void inject_mem_cb(struct qemu_plugin_dyn_cb *cb, + enum qemu_plugin_mem_rw rw, + qemu_plugin_meminfo_t meminfo, TCGv_i64 addr) +{ + if (cb->rw & rw) { + switch (cb->type) { + case PLUGIN_CB_MEM_REGULAR: + gen_mem_cb(cb, meminfo, addr); + break; + default: + inject_cb(cb); + break; + } + } +} + static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) { TCGOp *op, *next; @@ -248,19 +279,8 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) cbs = plugin_tb->cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - - switch (cb->type) { - case PLUGIN_CB_REGULAR: - gen_udata_cb(cb); - break; - case PLUGIN_CB_INLINE: - gen_inline_cb(cb); - break; - default: - g_assert_not_reached(); - } + inject_cb( + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i)); } break; @@ -271,19 +291,8 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) cbs = insn->insn_cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - - switch (cb->type) { - case PLUGIN_CB_REGULAR: - gen_udata_cb(cb); - break; - case PLUGIN_CB_INLINE: - gen_inline_cb(cb); - break; - default: - g_assert_not_reached(); - } + inject_cb( + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i)); } break; @@ -300,33 +309,22 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) { TCGv_i64 addr = temp_tcgv_i64(arg_temp(op->args[0])); qemu_plugin_meminfo_t meminfo = op->args[1]; + enum qemu_plugin_mem_rw rw = + (qemu_plugin_mem_is_store(meminfo) + ? QEMU_PLUGIN_MEM_W : QEMU_PLUGIN_MEM_R); struct qemu_plugin_insn *insn; const GArray *cbs; - int i, n, rw; + int i, n; assert(insn_idx >= 0); insn = g_ptr_array_index(plugin_tb->insns, insn_idx); - rw = qemu_plugin_mem_is_store(meminfo) ? 2 : 1; tcg_ctx->emit_before_op = op; cbs = insn->mem_cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - - if (cb->rw & rw) { - switch (cb->type) { - case PLUGIN_CB_MEM_REGULAR: - gen_mem_cb(cb, meminfo, addr); - break; - case PLUGIN_CB_INLINE: - gen_inline_cb(cb); - break; - default: - g_assert_not_reached(); - } - } + inject_mem_cb(&g_array_index(cbs, struct qemu_plugin_dyn_cb, i), + rw, meminfo, addr); } tcg_ctx->emit_before_op = NULL;