From nobody Sat Nov 15 07:42:59 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=1755627918; cv=none; d=zohomail.com; s=zohoarc; b=CdGU0+qSb06j6eRhz79GWYPw2xJUehtDb7M4mhuitJX5OxrUHzR2Vo62s4RK5mPmv1N3iWuIZOXJfqt2tQ9/s6474sooPSSUHzq6XYW941P7S/Vrru72kEcXOR8geKS0rgJckiNNaWuRc+3uIvjJUSgmOz1DMQ8nkXFfTMM7mbM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755627918; 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=Lk2Yx8bK7zSWcPnckyiRTc9Ulm/rb4Y7KbbWAMUJAus=; b=L5SVW7GEc6F/H8Q8zu7wE65xonL6GzzoSBNA36ueF6gEK75jHLjqaCr+969AnKouwVPAXFEqDJJPM+7vTvEdEDKFG8rKyVmdF7q4Et1SFF4P4ajlmCDnH5/kjVtut5pjfEWFUTaZ6Li0+EQ5UPmQ+w4xbnBuMIfSs1yQFlpFAmU= 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 1755627918180453.9469154065008; Tue, 19 Aug 2025 11:25:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uoR0I-0006LE-My; Tue, 19 Aug 2025 14:24:14 -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 1uoR0G-0006D4-1b; Tue, 19 Aug 2025 14:24:12 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uoR0C-0003uU-Tv; Tue, 19 Aug 2025 14:24:11 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-76e2e88c6a6so5244847b3a.1; Tue, 19 Aug 2025 11:24:06 -0700 (PDT) Received: from ktock.. ([240d:1a:3b6:8b00:29ce:ef58:c2c9:e52f]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-245ed33b4c2sm3725125ad.25.2025.08.19.11.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Aug 2025 11:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755627845; x=1756232645; 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=Lk2Yx8bK7zSWcPnckyiRTc9Ulm/rb4Y7KbbWAMUJAus=; b=FF72qoAS0qTksH4THuaAqGFKnYM62anplzRCUWpp2VXp8NQPWUpkIdBTsCez4LujTY HsV9AR2Pr7k4qNtg1LlwcWBlHHgFP+qpoQn8CzGjJY6l5llPDJKTAItVl56g0Ope2ZLk ikdFtxNZrpi8tyGficB0jB8myZWCCP4bWBxUgWrfmAaLwGdm8RDMkkxynfiwpwOAukkZ 0dUHWBhxuW5FWSil40YXpYAapzGAeWHLimmSFMaqJY9U65Fdc5m75/xi5h5k4lqbyIUj JZnTIbplNiOyt2XSqo2pX71zV2GbYkKZVicVMxoIgOlcFcrrF6E9jIfDIV6MEkxcPy+x Epog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755627845; x=1756232645; 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=Lk2Yx8bK7zSWcPnckyiRTc9Ulm/rb4Y7KbbWAMUJAus=; b=jrEVLNC9J8GdWuizJb0C6sq9DjoF2h0v9IxwnBTEDWOMLskyRub527FLCRFAIjSgP/ BKNXy62BuaJlS/OXiDo07T1Asmm5pwFD1cCxMMq80vUeJ+jXlUdnjP5gU2sh5n5UaSxP oi2Ilck0BKFJZz+uWo9D4jb4r71qBEiEp3JxahbYxPSsQje/yEQV9MFv5NxlDNJP4Oq6 St0uhW8fEnGWP7hBFHit9SyyrT3WTiDSIBn9dgu02y5QxoeLV6LTpJE0DXQClTMlvhzQ HnpRnvDutDSbtyi+pYBOhmSXtvQ53kAYE8KFJqjXBHOGZE8Bm/QmWlUjhaqP0NNH18XJ kGYw== X-Forwarded-Encrypted: i=1; AJvYcCVvzjdK32PVqI8Ky30BNef/G1I9Mj+rFI4cH4CG/g1q3/oQLf6cry+DRKcZWy0fUnQdDRZWH6g4j+7W0g==@nongnu.org, AJvYcCWxUU1VpMru2eZUWj94kef9hMU8lchu1yPKKW/upHrmV5rX6s0FeorFEwZVls2EhmDId+oUyTifew==@nongnu.org X-Gm-Message-State: AOJu0YwHMdWMdeZlMcZERHs4pzNPUODt3hlRkcXGGjq/A9Fa7XfEYjoj B+jteSLr3ZMLc0qtlQWf5bHERZh8CuNBIr5ykT7WuaAbF+zIepk3jGAWos6NCH6R X-Gm-Gg: ASbGncsUx/TEEyoE4hKJUeYUEMTU4EIxe7ANdX6WSt2Z8d/MvzGDT8NBttGaxCXblj3 gvpdXj+vv7jtcZlKKJcFfnfeWdFfcRIglRmlnpWpt+J7L5tkN41FkfR0EUO1HZp8ZU7+ZKCKrNg nlrr87fu3Fv5GsQfY0H7cOAWtrYSDoIa6GyS2gTbTGfETACpHXC3rLXhG22ejmELnW9AcHL6zjo VuqiXpainbB5nxWMifD3h/fu9cIz4caxme3g75dPwh6k4/ZHUz1ARv1hbRUc32LZ0/KKaXHeZVi RQOk96w8ZAOVwwM1dcke0ty9gP2nSJByK5FjM7sgqRwqbWB/v/BsZG3b+yN12jTnOOZkDZQE6Z5 Yc73P+62kPpJuIHQhPpclnm5aCicBReIwVS7SmvCACAk= X-Google-Smtp-Source: AGHT+IFo0O9d6lUvgk6SML1wwE+NBqP30D9IhObZ+SO91sE8A93CRPYQIshu9HJQmCe7WqNtxOBqcA== X-Received: by 2002:a17:902:cecd:b0:242:a1ee:6c3f with SMTP id d9443c01a7336-245e02db248mr42235245ad.4.1755627845057; Tue, 19 Aug 2025 11:24:05 -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 , Paolo Bonzini , Richard Henderson , =?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 , qemu-arm@nongnu.org, qemu-riscv@nongnu.org, Stefan Hajnoczi , Pierrick Bouvier , ktokunaga.mail@gmail.com Subject: [PATCH 16/35] tcg/wasm: Add mov/movi instructions Date: Wed, 20 Aug 2025 03:21:45 +0900 Message-ID: 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::42d; envelope-from=ktokunaga.mail@gmail.com; helo=mail-pf1-x42d.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: 1755627921174124100 Content-Type: text/plain; charset="utf-8" The tcg_out_mov and tcg_out_movi functions were used by several other functions and intended to emit TCI code. So they have been renamed to tcg_tci_out_mov and tcg_tci_out_movi. Signed-off-by: Kohei Tokunaga --- tcg/wasm/tcg-target.c.inc | 85 +++++++++++++++++++++++++++------------ 1 file changed, 60 insertions(+), 25 deletions(-) diff --git a/tcg/wasm/tcg-target.c.inc b/tcg/wasm/tcg-target.c.inc index c7da6ae055..ec5c45c69e 100644 --- a/tcg/wasm/tcg-target.c.inc +++ b/tcg/wasm/tcg-target.c.inc @@ -524,6 +524,28 @@ static void tcg_wasm_out_sextract(TCGContext *s, TCGRe= g dest, TCGReg arg1, tcg_wasm_out_op_idx(s, OPC_GLOBAL_SET, REG_IDX(dest)); } =20 +static void tcg_wasm_out_mov(TCGContext *s, TCGReg ret, TCGReg arg) +{ + tcg_wasm_out_op_idx(s, OPC_GLOBAL_GET, REG_IDX(arg)); + tcg_wasm_out_op_idx(s, OPC_GLOBAL_SET, REG_IDX(ret)); +} + +static void tcg_wasm_out_movi(TCGContext *s, TCGType type, + TCGReg ret, tcg_target_long arg) +{ + switch (type) { + case TCG_TYPE_I32: + tcg_wasm_out_op_const(s, OPC_I64_CONST, (int32_t)arg); + break; + case TCG_TYPE_I64: + tcg_wasm_out_op_const(s, OPC_I64_CONST, arg); + break; + default: + g_assert_not_reached(); + } + tcg_wasm_out_op_idx(s, OPC_GLOBAL_SET, REG_IDX(ret)); +} + static bool patch_reloc(tcg_insn_unit *code_ptr_i, int type, intptr_t value, intptr_t addend) { @@ -735,6 +757,33 @@ static void tcg_out_op_rrrrrc(TCGContext *s, TCGOpcode= op, tcg_out32(s, insn); } =20 +static void tcg_tci_out_movi(TCGContext *s, TCGType type, + TCGReg ret, tcg_target_long arg) +{ + switch (type) { + case TCG_TYPE_I32: +#if TCG_TARGET_REG_BITS =3D=3D 64 + arg =3D (int32_t)arg; + /* fall through */ + case TCG_TYPE_I64: +#endif + break; + default: + g_assert_not_reached(); + } + + if (arg =3D=3D sextract32(arg, 0, 20)) { + tcg_out_op_ri(s, INDEX_op_tci_movi, ret, arg); + } else { + tcg_insn_unit_tci insn =3D 0; + + new_pool_label(s, arg, 20, s->code_ptr, 0); + insn =3D deposit32(insn, 0, 8, INDEX_op_tci_movl); + insn =3D deposit32(insn, 8, 4, ret); + tcg_out32(s, insn); + } +} + static void tcg_tci_out_extract(TCGContext *s, TCGType type, TCGReg rd, TCGReg rs, unsigned pos, unsigned len) { @@ -746,7 +795,7 @@ static void tcg_out_ldst(TCGContext *s, TCGOpcode op, T= CGReg val, { stack_bounds_check(base, offset); if (offset !=3D sextract32(offset, 0, 16)) { - tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP, offset); + tcg_tci_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP, offset); tcg_out_op_rrr(s, INDEX_op_add, TCG_REG_TMP, TCG_REG_TMP, base); base =3D TCG_REG_TMP; offset =3D 0; @@ -768,37 +817,23 @@ static void tcg_out_ld(TCGContext *s, TCGType type, T= CGReg val, TCGReg base, tcg_wasm_out_ld(s, wasm_opc, val, base, offset); } =20 -static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg ar= g) +static void tcg_tci_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGRe= g arg) { tcg_out_op_rr(s, INDEX_op_mov, ret, arg); +} + +static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg ar= g) +{ + tcg_tci_out_mov(s, type, ret, arg); + tcg_wasm_out_mov(s, ret, arg); return true; } =20 static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg) { - switch (type) { - case TCG_TYPE_I32: -#if TCG_TARGET_REG_BITS =3D=3D 64 - arg =3D (int32_t)arg; - /* fall through */ - case TCG_TYPE_I64: -#endif - break; - default: - g_assert_not_reached(); - } - - if (arg =3D=3D sextract32(arg, 0, 20)) { - tcg_out_op_ri(s, INDEX_op_tci_movi, ret, arg); - } else { - tcg_insn_unit insn =3D 0; - - new_pool_label(s, arg, 20, s->code_ptr, 0); - insn =3D deposit32(insn, 0, 8, INDEX_op_tci_movl); - insn =3D deposit32(insn, 8, 4, ret); - tcg_out32(s, insn); - } + tcg_tci_out_movi(s, type, ret, arg); + tcg_wasm_out_movi(s, type, ret, arg); } =20 static void tcg_out_extract(TCGContext *s, TCGType type, TCGReg rd, @@ -880,7 +915,7 @@ static void tcg_out_extu_i32_i64(TCGContext *s, TCGReg = rd, TCGReg rs) static void tcg_out_extrl_i64_i32(TCGContext *s, TCGReg rd, TCGReg rs) { tcg_debug_assert(TCG_TARGET_REG_BITS =3D=3D 64); - tcg_out_mov(s, TCG_TYPE_I32, rd, rs); + tcg_tci_out_mov(s, TCG_TYPE_I32, rd, rs); } =20 static bool tcg_out_xchg(TCGContext *s, TCGType type, TCGReg r1, TCGReg r2) --=20 2.43.0