From nobody Tue Nov 26 18:29:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1705675485; cv=none; d=zohomail.com; s=zohoarc; b=LdDRpRKXxJE9/QgC/EQe9mMFcn6938ChpzwmA7l9ioSQV0XwYk2u2V1BTnCb60f7NsFat8nb9pc8T9G74qHOsLSZ+00uriNJrC4bSVr1q6H49bolvucl63Fra16kxmQn6cuKN/7VPNcIqQwynC+Xq9TVv9qh4mysz9s1cDqP4+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705675485; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=r7k10i1SVH85ChTA6Z/gMmAlYkPdspyjFqih1CaFIEM=; b=AYhlHadvPAnCO6tCZD5sb0ofEUO+GovkB0TRXTGUwSuqKyXdMmHshNjfmOB8NbAWtJUdjWaJQLTGNFRE3S86XQPLA95lPFyeImAOnNImV6j60iWEWWxOkyHynki73uo/aB8QAURvs8iWyiyle8cjKejJ5ayx8WGm0DH7N99V464= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705675485222969.3273642844946; Fri, 19 Jan 2024 06:44:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQq3K-00061C-45; Fri, 19 Jan 2024 09:41:02 -0500 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 1rQq30-0005th-V8 for qemu-devel@nongnu.org; Fri, 19 Jan 2024 09:40:42 -0500 Received: from rev.ng ([5.9.113.41]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQq2w-0003vW-B0 for qemu-devel@nongnu.org; Fri, 19 Jan 2024 09:40:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rev.ng; s=dkim; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=r7k10i1SVH85ChTA6Z/gMmAlYkPdspyjFqih1CaFIEM=; b=mV5pRoDJz+iAaydAXG7S7xYx7k qcVGE3O8k/1/ig9cNgDD+5hKT903P1s8e2FIPk7onc1ANXrR9DU6LQpeONvdYC1teQlTOkwXFwheB 2qE+MCoXf19YGbg8v9+nBKq9yub9dUkskXpuIqaqL8HP+iORruvYYSKXeii6ZsVtMO5I=; To: qemu-devel@nongnu.org Cc: ale@rev.ng, richard.henderson@linaro.org, philmd@linaro.org Subject: [RFC PATCH 27/34] accel/tcg: Make translate-all.c target independent Date: Fri, 19 Jan 2024 15:40:17 +0100 Message-ID: <20240119144024.14289-28-anjo@rev.ng> In-Reply-To: <20240119144024.14289-1-anjo@rev.ng> References: <20240119144024.14289-1-anjo@rev.ng> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=5.9.113.41; envelope-from=anjo@rev.ng; helo=rev.ng 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Reply-to: Anton Johansson From: Anton Johansson via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1705675485654100003 Content-Type: text/plain; charset="utf-8" Makes translate-all.c independent of softmmu target by switching TARGET_LONG_BITS -> target_long_bits() TARGET_INSN_START_WORDS -> tcg_ctx->insn_start_words, target_insn_start_words(), TCG_GUEST_DEFAULT_MO -> target_default_memory_order() MO_TE -> target_endian_memory_order() Signed-off-by: Anton Johansson --- accel/tcg/translate-all.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 9c981d1750..a3ae0c6910 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -65,7 +65,6 @@ #include "internal-common.h" #include "internal-target.h" #include "perf.h" -#include "tcg/insn-start-words.h" =20 TBContext tb_ctx; =20 @@ -106,7 +105,7 @@ static int64_t decode_sleb128(const uint8_t **pp) val |=3D (int64_t)(byte & 0x7f) << shift; shift +=3D 7; } while (byte & 0x80); - if (shift < TARGET_LONG_BITS && (byte & 0x40)) { + if (shift < target_long_bits() && (byte & 0x40)) { val |=3D -(int64_t)1 << shift; } =20 @@ -117,7 +116,7 @@ static int64_t decode_sleb128(const uint8_t **pp) /* Encode the data collected about the instructions while compiling TB. Place the data at BLOCK, and return the number of bytes consumed. =20 - The logical table consists of TARGET_INSN_START_WORDS target_ulong's, + The logical table consists of tcg_ctx->insn_start_words target_ulong's, which come from the target's insn_start data, followed by a uintptr_t which comes from the host pc of the end of the code implementing the in= sn. =20 @@ -128,6 +127,7 @@ static int64_t decode_sleb128(const uint8_t **pp) =20 static int encode_search(TranslationBlock *tb, uint8_t *block) { + const uint8_t insn_start_words =3D tcg_ctx->insn_start_words; uint8_t *highwater =3D tcg_ctx->code_gen_highwater; uint64_t *insn_data =3D tcg_ctx->gen_insn_data; uint16_t *insn_end_off =3D tcg_ctx->gen_insn_end_off; @@ -137,13 +137,13 @@ static int encode_search(TranslationBlock *tb, uint8_= t *block) for (i =3D 0, n =3D tb->icount; i < n; ++i) { uint64_t prev, curr; =20 - for (j =3D 0; j < TARGET_INSN_START_WORDS; ++j) { + for (j =3D 0; j < insn_start_words; ++j) { if (i =3D=3D 0) { prev =3D (!(tb_cflags(tb) & CF_PCREL) && j =3D=3D 0 ? tb->= pc : 0); } else { - prev =3D insn_data[(i - 1) * TARGET_INSN_START_WORDS + j]; + prev =3D insn_data[(i - 1) * insn_start_words + j]; } - curr =3D insn_data[i * TARGET_INSN_START_WORDS + j]; + curr =3D insn_data[i * insn_start_words + j]; p =3D encode_sleb128(p, curr - prev); } prev =3D (i =3D=3D 0 ? 0 : insn_end_off[i - 1]); @@ -165,6 +165,7 @@ static int encode_search(TranslationBlock *tb, uint8_t = *block) static int cpu_unwind_data_from_tb(TranslationBlock *tb, uintptr_t host_pc, uint64_t *data) { + const uint8_t insn_start_words =3D tcg_ctx->insn_start_words; uintptr_t iter_pc =3D (uintptr_t)tb->tc.ptr; const uint8_t *p =3D tb->tc.ptr + tb->tc.size; int i, j, num_insns =3D tb->icount; @@ -175,7 +176,7 @@ static int cpu_unwind_data_from_tb(TranslationBlock *tb= , uintptr_t host_pc, return -1; } =20 - memset(data, 0, sizeof(uint64_t) * TARGET_INSN_START_WORDS); + memset(data, 0, sizeof(uint64_t) * insn_start_words); if (!(tb_cflags(tb) & CF_PCREL)) { data[0] =3D tb->pc; } @@ -185,7 +186,7 @@ static int cpu_unwind_data_from_tb(TranslationBlock *tb= , uintptr_t host_pc, * at which the end of the insn exceeds host_pc. */ for (i =3D 0; i < num_insns; ++i) { - for (j =3D 0; j < TARGET_INSN_START_WORDS; ++j) { + for (j =3D 0; j < insn_start_words; ++j) { data[j] +=3D decode_sleb128(&p); } iter_pc +=3D decode_sleb128(&p); @@ -203,7 +204,7 @@ static int cpu_unwind_data_from_tb(TranslationBlock *tb= , uintptr_t host_pc, void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, uintptr_t host_pc) { - uint64_t data[TARGET_INSN_START_WORDS]; + uint64_t data[tcg_ctx->insn_start_words]; int insns_left =3D cpu_unwind_data_from_tb(tb, host_pc, data); =20 if (insns_left < 0) { @@ -341,19 +342,15 @@ TranslationBlock *tb_gen_code(CPUState *cpu, } =20 tcg_ctx->gen_tb =3D tb; - tcg_ctx->addr_type =3D TARGET_LONG_BITS =3D=3D 32 ? TCG_TYPE_I32 : TCG= _TYPE_I64; + tcg_ctx->addr_type =3D target_long_bits() =3D=3D 32 ? TCG_TYPE_I32 : T= CG_TYPE_I64; #ifdef CONFIG_SOFTMMU - tcg_ctx->mo_te =3D MO_TE; + tcg_ctx->mo_te =3D target_endian_memory_order(); tcg_ctx->page_bits =3D TARGET_PAGE_BITS; tcg_ctx->page_mask =3D TARGET_PAGE_MASK; - tcg_ctx->tlb_dyn_max_bits =3D CPU_TLB_DYN_MAX_BITS; -#endif - tcg_ctx->insn_start_words =3D TARGET_INSN_START_WORDS; -#ifdef TCG_GUEST_DEFAULT_MO - tcg_ctx->guest_mo =3D TCG_GUEST_DEFAULT_MO; -#else - tcg_ctx->guest_mo =3D TCG_MO_ALL; + tcg_ctx->tlb_dyn_max_bits =3D target_tlb_dyn_max_bits(); #endif + tcg_ctx->insn_start_words =3D target_insn_start_words(); + tcg_ctx->guest_mo =3D target_default_memory_order(); =20 restart_translate: trace_translate_block(tb, pc, tb->tc.ptr); @@ -441,6 +438,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, qemu_log_in_addr_range(pc)) { FILE *logfile =3D qemu_log_trylock(); if (logfile) { + const uint8_t insn_start_words =3D tcg_ctx->insn_start_words; int code_size, data_size; const tcg_target_ulong *rx_data_gen_ptr; size_t chunk_start; @@ -460,7 +458,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, fprintf(logfile, "OUT: [size=3D%d]\n", gen_code_size); fprintf(logfile, " -- guest addr 0x%016" PRIx64 " + tb prologue\n", - tcg_ctx->gen_insn_data[insn * TARGET_INSN_START_WORDS]= ); + tcg_ctx->gen_insn_data[insn * insn_start_words]); chunk_start =3D tcg_ctx->gen_insn_end_off[insn]; disas(logfile, tb->tc.ptr, chunk_start); =20 @@ -473,7 +471,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, size_t chunk_end =3D tcg_ctx->gen_insn_end_off[insn]; if (chunk_end > chunk_start) { fprintf(logfile, " -- guest addr 0x%016" PRIx64 "\n", - tcg_ctx->gen_insn_data[insn * TARGET_INSN_STAR= T_WORDS]); + tcg_ctx->gen_insn_data[insn * insn_start_words= ]); disas(logfile, tb->tc.ptr + chunk_start, chunk_end - chunk_start); chunk_start =3D chunk_end; --=20 2.43.0