From nobody Sun Nov 2 02:32:33 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1747746410; cv=none; d=zohomail.com; s=zohoarc; b=m2Dp7X4bd44eXoTY8AIjELrEbfx54802UHf6uTXoOrlMFHSEaNAwXz5gXth2JkcLJftv0jAK1PtSHj9OBJ7lGn21Tw/AEoJo14jpdwSaaJ/0uD3TuGxPwGbxYFpT6ibzoWUgBelravw7lBGaLGDcKPogv8K5ZiMzk+BZtOi6bqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747746410; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=T0PaUQzzHF5lFv29qjDHJ20TRr//FMkUoGozxMxxEDU=; b=GthahOW2P3txBE9PqBo+ayX0xf0o7LoTVnIcbbRgH3B4XcXeXflBaYYIDc0pgEWY62JMvo5nA9MBkShQ90GzE2DtGrK8f1a+FSPnQj2YVaLx7LGips8UvHPsstG90LaAdAYfKWmooBAh7NCI9uqtl5zwpht8IY8GP7wcvfm0Iqo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 174774641049075.27584051795168; Tue, 20 May 2025 06:06:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHMSb-0000kK-AU; Tue, 20 May 2025 08:52:45 -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 1uHMSa-0000k4-A2; Tue, 20 May 2025 08:52:44 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uHMSX-0000iZ-RA; Tue, 20 May 2025 08:52:44 -0400 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-30e80f03760so3988330a91.0; Tue, 20 May 2025 05:52:40 -0700 (PDT) Received: from ktock.. ([240d:1a:3b6:8b00:1bde:8310:e993:5dcc]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-30f36364f9asm1625916a91.4.2025.05.20.05.52.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 May 2025 05:52:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747745559; x=1748350359; 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=T0PaUQzzHF5lFv29qjDHJ20TRr//FMkUoGozxMxxEDU=; b=FS3V0Pvzr2N10i15ejl4MWc5HhSaoGPjbjgxb+gnshBGDqxaR5/mT+w1dzsEfHQyzl ssPrxvM44s5qcgTF0+H+VBKrsVOpH1MIpUvTZty7t8Dhte8MnKGFakBgtygxedzNK8NQ Qbk0bgzDj8cEoD1/EruOMuViML2FsONiwW8mZ8oG7qP+UxufcdOH+R4C1TR4CWqp2Iv4 hIk7QftCfBvBOx/M+FahQZNHFia5Zca08k5asF0aAKCkCDaj9FhYT49WWXPF/UmH4bAQ xi3XNZFJxWY+e1hR9pH7wtXAhOVmhO8uRnrDXOHrUZD8ZQ+If8gdohYFykSWbFY3DlXD bCHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747745559; x=1748350359; 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=T0PaUQzzHF5lFv29qjDHJ20TRr//FMkUoGozxMxxEDU=; b=EHAafzbqmC0nfRJD7UXVSw2b6isGgmfSlPlOpt0D5Qg41TgJ6/n8hzSyXQiFJCPVLj B9PJSUzu/7loASUw+u/SARxRkCMVFd87W/v5l72DqZlpKF7TUtXL/aKZQ3eraSt5Of0i GCy31OALFDzYqAbfm2UJfR8aKRXkhPN7BtnjNdGVq2kOlL/YT71EWeBUd9tx3i2K2+7t Q3jnip2xtkwFqgYhEestDIFdmwGPD+MiF8XXLWx4hDp3JuDIT/vDjNMgjnCT3mlr1Cf/ 6I+QzPnIP3vboquP9QdsXyhyJqmufn/YpwG3dzzUQ7Ky3ZQzwKeBlmUoXoqeiQTkVrtP nryg== X-Forwarded-Encrypted: i=1; AJvYcCU5bjgQMXlDh5qnFCjFznM+WwlUjRx6v8M+sdy8fHaIpa63qTAYirRLkoPPC1ehgQJ9cZUPg4oprZ200A==@nongnu.org, AJvYcCVHb+O5FG25BH3j2/0N/b/Xl1gnuaHPuNXZ7UVEaKpDyWPfcBPaV7CdIWsGdrnc6CGsNhnxMTGnrQ==@nongnu.org X-Gm-Message-State: AOJu0Yzf9gv8G8FaQWQiNpuNcHSm5TF/J/FG5bzONl55XpEgQdZocFq0 sEiX9IJEOV3zz68rQBtqNKyqQgf+T4as07mGORjFwxSTDlyBCoGT6+NLmrAU9/+b X-Gm-Gg: ASbGncuKr1e7rZbY7HY5xB5H323UVHn7f85UdkqAJcIgrrWjXY9WZoK3YvxPLC/dp0E /0jQdV7uHxytJlO0QDD66JQHfEWefo1QlzcBuVxjRLmicsaMBs+Vm8IME1eE3oe3xglpluUJg6I F4YjrmvlG2dbc1rlvQcrDSHvEU4r9qsUQIQcGIFgIT3qLG2CoMxYETYsLQWpSQCYKITETfrCEWV ybuDns4gHWiPRr11+W661/znJ3Y7CX67X8Oh76Fc45uhBy9KqFCebpktgbiTJ+McdUQ5EknVoom nq/zWLPsY0lE8osv2/Pi1Sj3ijIcZ4YslyZmQXuf1IRTBz32z+w= X-Google-Smtp-Source: AGHT+IG4z7uH3nJBTNDQfyLfNQV18rt8GBswaQum9LIXlORmpxAC/0+aqvV7Ejz1IYPaI3IHgNwiMg== X-Received: by 2002:a17:90b:3a48:b0:2ff:72f8:3708 with SMTP id 98e67ed59e1d1-30e8314fdb5mr30880280a91.17.1747745558661; Tue, 20 May 2025 05:52:38 -0700 (PDT) From: Kohei Tokunaga To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth , Richard Henderson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , WANG Xuerui , Aurelien Jarno , Huacai Chen , Jiaxun Yang , Aleksandar Rikalo , Palmer Dabbelt , Alistair Francis , Stefan Weil , Stefan Hajnoczi , Pierrick Bouvier , Kohei Tokunaga , qemu-arm@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH 04/33] tcg/wasm32: Set TCG_TARGET_INSN_UNIT_SIZE to 1 Date: Tue, 20 May 2025 21:51:06 +0900 Message-ID: <9e2af431443c9b4b70f1fc1ee02e1030318c0b8f.1747744132.git.ktokunaga.mail@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: 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=2607:f8b0:4864:20::1035; envelope-from=ktokunaga.mail@gmail.com; helo=mail-pj1-x1035.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, FREEMAIL_FROM=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1747746413174116600 Content-Type: text/plain; charset="utf-8" WebAssembly instructions vary in size, including single-byte instructions. This commit sets TCG_TARGET_INSN_UNIT_SIZE to 1 and updates the TCI fork to use "tcg_insn_unit_tci" (a uint32_t) for 4-byte operations. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c.inc | 40 ++++++++++++++++++++----------------- tcg/wasm32/tcg-target.h | 2 +- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/tcg/wasm32/tcg-target.c.inc b/tcg/wasm32/tcg-target.c.inc index 33b81f1fe2..126f9c0de7 100644 --- a/tcg/wasm32/tcg-target.c.inc +++ b/tcg/wasm32/tcg-target.c.inc @@ -39,6 +39,8 @@ #endif #define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_NORMAL =20 +typedef uint32_t tcg_insn_unit_tci; + static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op, TCGType type, unsigned flags) { @@ -96,16 +98,18 @@ static const char *const tcg_target_reg_names[TCG_TARGE= T_NB_REGS] =3D { }; #endif =20 -static bool patch_reloc(tcg_insn_unit *code_ptr, int type, +static bool patch_reloc(tcg_insn_unit *code_ptr_i, int type, intptr_t value, intptr_t addend) { + tcg_insn_unit_tci *code_ptr =3D (tcg_insn_unit_tci *)code_ptr_i; intptr_t diff =3D value - (intptr_t)(code_ptr + 1); =20 tcg_debug_assert(addend =3D=3D 0); tcg_debug_assert(type =3D=3D 20); =20 if (diff =3D=3D sextract32(diff, 0, type)) { - tcg_patch32(code_ptr, deposit32(*code_ptr, 32 - type, type, diff)); + tcg_patch32((tcg_insn_unit *)code_ptr, + deposit32(*code_ptr, 32 - type, type, diff)); return true; } return false; @@ -122,7 +126,7 @@ static void stack_bounds_check(TCGReg base, intptr_t of= fset) =20 static void tcg_out_op_l(TCGContext *s, TCGOpcode op, TCGLabel *l0) { - tcg_insn_unit insn =3D 0; + tcg_insn_unit_tci insn =3D 0; =20 tcg_out_reloc(s, s->code_ptr, 20, l0, 0); insn =3D deposit32(insn, 0, 8, op); @@ -131,14 +135,14 @@ static void tcg_out_op_l(TCGContext *s, TCGOpcode op,= TCGLabel *l0) =20 static void tcg_out_op_p(TCGContext *s, TCGOpcode op, void *p0) { - tcg_insn_unit insn =3D 0; + tcg_insn_unit_tci insn =3D 0; intptr_t diff; =20 /* Special case for exit_tb: map null -> 0. */ if (p0 =3D=3D NULL) { diff =3D 0; } else { - diff =3D p0 - (void *)(s->code_ptr + 1); + diff =3D p0 - (void *)(s->code_ptr + 4); tcg_debug_assert(diff !=3D 0); if (diff !=3D sextract32(diff, 0, 20)) { tcg_raise_tb_overflow(s); @@ -151,7 +155,7 @@ static void tcg_out_op_p(TCGContext *s, TCGOpcode op, v= oid *p0) =20 static void tcg_out_op_r(TCGContext *s, TCGOpcode op, TCGReg r0) { - tcg_insn_unit insn =3D 0; + tcg_insn_unit_tci insn =3D 0; =20 insn =3D deposit32(insn, 0, 8, op); insn =3D deposit32(insn, 8, 4, r0); @@ -165,7 +169,7 @@ static void tcg_out_op_v(TCGContext *s, TCGOpcode op) =20 static void tcg_out_op_ri(TCGContext *s, TCGOpcode op, TCGReg r0, int32_t = i1) { - tcg_insn_unit insn =3D 0; + tcg_insn_unit_tci insn =3D 0; =20 tcg_debug_assert(i1 =3D=3D sextract32(i1, 0, 20)); insn =3D deposit32(insn, 0, 8, op); @@ -176,7 +180,7 @@ static void tcg_out_op_ri(TCGContext *s, TCGOpcode op, = TCGReg r0, int32_t i1) =20 static void tcg_out_op_rl(TCGContext *s, TCGOpcode op, TCGReg r0, TCGLabel= *l1) { - tcg_insn_unit insn =3D 0; + tcg_insn_unit_tci insn =3D 0; =20 tcg_out_reloc(s, s->code_ptr, 20, l1, 0); insn =3D deposit32(insn, 0, 8, op); @@ -186,7 +190,7 @@ static void tcg_out_op_rl(TCGContext *s, TCGOpcode op, = TCGReg r0, TCGLabel *l1) =20 static void tcg_out_op_rr(TCGContext *s, TCGOpcode op, TCGReg r0, TCGReg r= 1) { - tcg_insn_unit insn =3D 0; + tcg_insn_unit_tci insn =3D 0; =20 insn =3D deposit32(insn, 0, 8, op); insn =3D deposit32(insn, 8, 4, r0); @@ -197,7 +201,7 @@ static void tcg_out_op_rr(TCGContext *s, TCGOpcode op, = TCGReg r0, TCGReg r1) static void tcg_out_op_rrm(TCGContext *s, TCGOpcode op, TCGReg r0, TCGReg r1, TCGArg m2) { - tcg_insn_unit insn =3D 0; + tcg_insn_unit_tci insn =3D 0; =20 tcg_debug_assert(m2 =3D=3D extract32(m2, 0, 16)); insn =3D deposit32(insn, 0, 8, op); @@ -210,7 +214,7 @@ static void tcg_out_op_rrm(TCGContext *s, TCGOpcode op, static void tcg_out_op_rrr(TCGContext *s, TCGOpcode op, TCGReg r0, TCGReg r1, TCGReg r2) { - tcg_insn_unit insn =3D 0; + tcg_insn_unit_tci insn =3D 0; =20 insn =3D deposit32(insn, 0, 8, op); insn =3D deposit32(insn, 8, 4, r0); @@ -222,7 +226,7 @@ static void tcg_out_op_rrr(TCGContext *s, TCGOpcode op, static void tcg_out_op_rrs(TCGContext *s, TCGOpcode op, TCGReg r0, TCGReg r1, intptr_t i2) { - tcg_insn_unit insn =3D 0; + tcg_insn_unit_tci insn =3D 0; =20 tcg_debug_assert(i2 =3D=3D sextract32(i2, 0, 16)); insn =3D deposit32(insn, 0, 8, op); @@ -235,7 +239,7 @@ static void tcg_out_op_rrs(TCGContext *s, TCGOpcode op, static void tcg_out_op_rrbb(TCGContext *s, TCGOpcode op, TCGReg r0, TCGReg r1, uint8_t b2, uint8_t b3) { - tcg_insn_unit insn =3D 0; + tcg_insn_unit_tci insn =3D 0; =20 tcg_debug_assert(b2 =3D=3D extract32(b2, 0, 6)); tcg_debug_assert(b3 =3D=3D extract32(b3, 0, 6)); @@ -250,7 +254,7 @@ static void tcg_out_op_rrbb(TCGContext *s, TCGOpcode op= , TCGReg r0, static void tcg_out_op_rrrc(TCGContext *s, TCGOpcode op, TCGReg r0, TCGReg r1, TCGReg r2, TCGCond c3) { - tcg_insn_unit insn =3D 0; + tcg_insn_unit_tci insn =3D 0; =20 insn =3D deposit32(insn, 0, 8, op); insn =3D deposit32(insn, 8, 4, r0); @@ -263,7 +267,7 @@ static void tcg_out_op_rrrc(TCGContext *s, TCGOpcode op, static void tcg_out_op_rrrbb(TCGContext *s, TCGOpcode op, TCGReg r0, TCGReg r1, TCGReg r2, uint8_t b3, uint8_t b4) { - tcg_insn_unit insn =3D 0; + tcg_insn_unit_tci insn =3D 0; =20 tcg_debug_assert(b3 =3D=3D extract32(b3, 0, 6)); tcg_debug_assert(b4 =3D=3D extract32(b4, 0, 6)); @@ -279,7 +283,7 @@ static void tcg_out_op_rrrbb(TCGContext *s, TCGOpcode o= p, TCGReg r0, static void tcg_out_op_rrrr(TCGContext *s, TCGOpcode op, TCGReg r0, TCGReg r1, TCGReg r2, TCGReg r3) { - tcg_insn_unit insn =3D 0; + tcg_insn_unit_tci insn =3D 0; =20 insn =3D deposit32(insn, 0, 8, op); insn =3D deposit32(insn, 8, 4, r0); @@ -293,7 +297,7 @@ static void tcg_out_op_rrrrrc(TCGContext *s, TCGOpcode = op, TCGReg r0, TCGReg r1, TCGReg r2, TCGReg r3, TCGReg r4, TCGCond c5) { - tcg_insn_unit insn =3D 0; + tcg_insn_unit_tci insn =3D 0; =20 insn =3D deposit32(insn, 0, 8, op); insn =3D deposit32(insn, 8, 4, r0); @@ -452,7 +456,7 @@ static void tcg_out_call(TCGContext *s, const tcg_insn_= unit *func, const TCGHelperInfo *info) { ffi_cif *cif =3D info->cif; - tcg_insn_unit insn =3D 0; + tcg_insn_unit_tci insn =3D 0; uint8_t which; =20 if (cif->rtype =3D=3D &ffi_type_void) { diff --git a/tcg/wasm32/tcg-target.h b/tcg/wasm32/tcg-target.h index bd03aa1bc4..2f0c27c905 100644 --- a/tcg/wasm32/tcg-target.h +++ b/tcg/wasm32/tcg-target.h @@ -41,7 +41,7 @@ #define TCG_TARGET_H =20 #define TCG_TARGET_INTERPRETER 1 -#define TCG_TARGET_INSN_UNIT_SIZE 4 +#define TCG_TARGET_INSN_UNIT_SIZE 1 #define MAX_CODE_GEN_BUFFER_SIZE ((size_t)-1) =20 /* Number of registers available. */ --=20 2.43.0