From patchwork Mon Mar 25 12:41:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 782326 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp1149670wrt; Mon, 25 Mar 2024 05:43:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVzcBl9E6QMRQ99+XzAbzaS8OGHYCDUlE6XtqkIrAaBq3IHcW4zQ087HpHmw4LursXmTxx3mhlVqkdD7ej8rpMA X-Google-Smtp-Source: AGHT+IFDeRLIFgxhdj+5fhd5AUv8672M0BMaXy/RS22QPFN3+SCYBsrsZXhlhmH4GLInG8hhhZjs X-Received: by 2002:a05:620a:8401:b0:78a:76b:a90f with SMTP id pc1-20020a05620a840100b0078a076ba90fmr6341520qkn.33.1711370604923; Mon, 25 Mar 2024 05:43:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711370604; cv=none; d=google.com; s=arc-20160816; b=RAJducCuAOuCYE/1vYeU02IKxlqQNeOSbwXNZp/2/orvJ27JjSU7mtmLPM1bIMq4/y CGNRFtNWgxcuyRs8iKGh2z7y9TTQBGt73zuzhUYb1VMtw9FMwjdwYLoHlP9dLCHn9hrw QuEs4JNFUgPTbaj4IUmoozbOyujFL3HlCR+fdGcfajRwIoPlRqXnw28UirFBWqtgbwJJ nq7OaTxUcnj7h1FEMxceDUxsBNbS55sdUFAFLCsrsT3XJx4p/GzHmnD0azW6HCQYJth5 k1kSvnk0o3WBff4uVQ3+jzvB8nC1c6JfvWYCXSR7FgavVDEDGhxB4XxQiYw0vGfN7AwL gU4Q== 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=tBbBJBKlzbAiSe9s/4Me+wF/GqPYbBpWR9ono1LAYxM=; fh=lDUBIxRmlFMVCYepQTPJQoo4dC2bnsDTL2QxjcosbcE=; b=daCLrCAj8CrfGkOaHo2VMaj9Wg7mq0bUdvC8bCVnj2aES4bbiE7HZGQ699f+n+n+Aw E7r+VOk9J0zbb9N0z8qgRZGjVZDxjV+pgWANHOTRUaYsWiT4tUNK/fqmMYjozmDPyabv 9jymUfFDrPIVrxrD4S3e48vuP8r983dQwo1Jd4okYTJwt2bzYfXcj4L/F+wKM/jYJhnG n6U5eMKGzwzRKizS29M4ZQHgpsFzLi3y2XoL3jsn4WfNXmNGKKZ0KtB2jc0S/JemGOPQ W3cZorP13QCnv1lqGDSCSEaf91j1fhhXkbqbNtfkDue3jL4RelafCx2PA3AnfxoUxjEg wEtQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zSCp4U32; 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 u4-20020a05620a022400b00789f0f147d5si5389723qkm.497.2024.03.25.05.43.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2024 05:43:24 -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=zSCp4U32; 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 1rojfC-0000PA-4Q; Mon, 25 Mar 2024 08:42:55 -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 1rojeb-0008Rw-Pd for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:42:17 -0400 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rojeZ-0006dq-3m for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:42:17 -0400 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2d48d75ab70so63117721fa.0 for ; Mon, 25 Mar 2024 05:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711370531; x=1711975331; 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=tBbBJBKlzbAiSe9s/4Me+wF/GqPYbBpWR9ono1LAYxM=; b=zSCp4U32PYwyuU0StsZ7jdGC3tBQmrdnvZaEi47ugIX4sfrFbrtbEDWuLBLYH6r/4B nNyAIxciFajX4z8r2AKqzyNymibwn2qmjBAuQuVgFOYpLJi0av3H6fcXEqAD7JR61lkQ /aEH3SwTgPq7rlIptdEkipJwza92lElcWfiAr1pUmilMlf3kxlaVEs3lrBXwc28vhC2k lN3AC6SpKj/YRf+boHKtfWWNmDU+ucZPz9GhMrBgdS8TgRn+HEBiJcFe7Ia6GlREUyhI ujdXwLJsF904ua5pxRDQfQTZZvS7lAImDFb66Bl3P9NmUJXaxb77JXCfn2K8FaQRcmHU KC3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711370531; x=1711975331; 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=tBbBJBKlzbAiSe9s/4Me+wF/GqPYbBpWR9ono1LAYxM=; b=p4t5KsqCx9zqE9Y0ikug0wa8gS7QfdfyHhJ4TWzAE2FexLBDuHQPNFKYeDzk8IGwPm srzf0hZIDrsOOrbpkL7GVKHcvGVIeEBPESwUSnBpIvJ+rlke74JMXsyxEgBTE16HdL92 5xk48jhBidMdMEKQ9D79rLxtHNXM63nCPy6eUFw8P1nuMA1gQd2VzguaPvJBSSU8sMBP arWWAphRzVp2jXSbAB6q192L+yPm02xd2N+IsJ7SSC1qm0vZRmF3DihDs/m6E178aE5r +ceBHZ/lM1QXmpojivmR873Y6UM1zp8cXTMsVK4E3LHwrDx9oMF3Kt36+89cBqwfuUsV 7dzQ== X-Gm-Message-State: AOJu0YwwLtlFqkWyIwkQzvOVi5Y+cTNxlO0HNIlk8l0syrEAgLnovRAb 7MWxAMxNfM6Y4p8ZvJKIG9oA4tHXuxrXN07el5J6D6THn7owuRIcq7iPL3TTiwe3LvGCniWrD4M m X-Received: by 2002:a05:6512:32a3:b0:513:cfd5:4217 with SMTP id q3-20020a05651232a300b00513cfd54217mr4741540lfe.1.1711370531318; Mon, 25 Mar 2024 05:42:11 -0700 (PDT) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id t20-20020ac243b4000000b00515b1b3a2bdsm35231lfl.194.2024.03.25.05.42.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 05:42:11 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Pierrick Bouvier , Richard Henderson , Paolo Bonzini , Mahmoud Mandour Subject: [PATCH v3 2/8] plugins: extract generate ptr for qemu_plugin_u64 Date: Mon, 25 Mar 2024 16:41:45 +0400 Message-Id: <20240325124151.336003-3-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240325124151.336003-1-pierrick.bouvier@linaro.org> References: <20240325124151.336003-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=pierrick.bouvier@linaro.org; helo=mail-lj1-x231.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 Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- accel/tcg/plugin-gen.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 41d4d83f547..d3667203546 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -120,24 +120,33 @@ static void gen_udata_cb(struct qemu_plugin_dyn_cb *cb) tcg_temp_free_i32(cpu_index); } -static void gen_inline_add_u64_cb(struct qemu_plugin_dyn_cb *cb) +static TCGv_ptr gen_plugin_u64_ptr(qemu_plugin_u64 entry) { - GArray *arr = cb->inline_insn.entry.score->data; - size_t offset = cb->inline_insn.entry.offset; - TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); - TCGv_i64 val = tcg_temp_ebb_new_i64(); TCGv_ptr ptr = tcg_temp_ebb_new_ptr(); + GArray *arr = entry.score->data; + char *base_ptr = arr->data + entry.offset; + size_t entry_size = g_array_get_element_size(arr); + + TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); tcg_gen_ld_i32(cpu_index, tcg_env, -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); - tcg_gen_muli_i32(cpu_index, cpu_index, g_array_get_element_size(arr)); + tcg_gen_muli_i32(cpu_index, cpu_index, entry_size); tcg_gen_ext_i32_ptr(ptr, cpu_index); tcg_temp_free_i32(cpu_index); + tcg_gen_addi_ptr(ptr, ptr, (intptr_t) base_ptr); - tcg_gen_addi_ptr(ptr, ptr, (intptr_t)arr->data); - tcg_gen_ld_i64(val, ptr, offset); + return ptr; +} + +static void gen_inline_add_u64_cb(struct qemu_plugin_dyn_cb *cb) +{ + TCGv_ptr ptr = gen_plugin_u64_ptr(cb->inline_insn.entry); + TCGv_i64 val = tcg_temp_ebb_new_i64(); + + tcg_gen_ld_i64(val, ptr, 0); tcg_gen_addi_i64(val, val, cb->inline_insn.imm); - tcg_gen_st_i64(val, ptr, offset); + tcg_gen_st_i64(val, ptr, 0); tcg_temp_free_i64(val); tcg_temp_free_ptr(ptr);