From nobody Sat Nov 15 07:42:56 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=1755627956; cv=none; d=zohomail.com; s=zohoarc; b=IgtZCh8gOKW0eqbke2/kBrUfXcZ/V9NlueCJxFGriPylFsZ41DBoi3uj8+/XupvdE2w6JVNYXAFYoToa9UudmrHQjiUv+GsMBKdFfQf1e4+rH8iQkXgLUHa8yGeXVQ4/XVNgTR5tkrny7LhkSBTEfC3JUcX2y4ckzFNTzCI3o54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755627956; 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=/Uxl4hRz+IS3ofUlHMTimcLwfnwpWGHBSdo9rZYe2Aw=; b=IbByV3KPqWzLKNftge8AdaYRFZe41hZwZucofFF0rPmF3bFRQPAvKVuv+Tbi3Ej9YJIq2Xrof1bi1/Mia88i+prZm1yHSVMSUHVXFl6qx8vohEvN/eRxHkwWF6hRvwl++QeRYpif9HT+aMyVa2rhI/x9miGVyW2lRFPhQzsdTy0= 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 1755627956101566.5105094884923; Tue, 19 Aug 2025 11:25:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uoR0i-0007XE-Nn; Tue, 19 Aug 2025 14:24:40 -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 1uoR0a-0007Bf-Fb; Tue, 19 Aug 2025 14:24:33 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uoR0X-0003xb-Sj; Tue, 19 Aug 2025 14:24:31 -0400 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-b471754c159so3818632a12.3; Tue, 19 Aug 2025 11:24:28 -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.24.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Aug 2025 11:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755627867; x=1756232667; 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=/Uxl4hRz+IS3ofUlHMTimcLwfnwpWGHBSdo9rZYe2Aw=; b=lA/cDKtvbNT3e+Xfd2A5PlJdZTsOFBIl1KKuALUolntb9M4SnZrYrlpTJuGPWLauA5 6sF4Lh4iBrAVbWL4B/1tacioqma1049MTuevd8ehhWVBdTyAFzgvR0FEs26WMJ7J9fBA twuV2Uk1njTOZhmXYEoMCvW4Eve8Z0jig99nCMimy7q0WmRfTuYVor510F/KXnEt2FfB j8upAYEZegh62ieXgPbjXsWrQNPRCq0poQg9NXqtdjB9GeOrGWvvRht2Cv1Tb73R9vqo I/xG3G6dXAqVwiJO0drEFhXabneRdbr8JE6f3ohGhyjRCoDkosPXjtnF94e72/aCnT9X rB/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755627867; x=1756232667; 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=/Uxl4hRz+IS3ofUlHMTimcLwfnwpWGHBSdo9rZYe2Aw=; b=ajQblg1Ku8Y1zKjJw8BZMv2nTNpwP2MTAn/CZm3swSI+n8rgeOu2MeWxvIb/8lEX0V HpAk5vm9ckVwKOT2azRTFdiNeDOCUE0AVNiRtvC1de5J57B3UrvV1FjRUhf7jb/Ra4Ts wSydMWIoKJmr8/QWfGxhhl1fve71sgSHJrJJg24CPS7o2PPHSmNaZWVEjzWifT66goSO 1ON768aURf25IdttUBYjmxVmSHZSg2/gc6jY4LWK1b7AHzxDPlC2ROcG3FRXHpW7Zxkr nP//UsbJ2S5HxkpgYXNIm1Tp7QqLsBxWpdsd2KtrEbN72MIfnci6P0P0FclVwTLQmvXI vPZA== X-Forwarded-Encrypted: i=1; AJvYcCV7Svwv5wjStHe4oPw0NHBJkvu+aPpRda/VPpp805GR1oWLltx2XrYq3AgDAmQqxNNAlOwvjfewAw==@nongnu.org, AJvYcCWslTV2RH+PfjQoY8o69QvR/kqQAXFS4N1aa9JiAo25tG5Lg4DSUm1QQAYOxJvnORASsDQcfysLX/VL5A==@nongnu.org X-Gm-Message-State: AOJu0YwzP54EdgeNtCjh8tapbs/NfE1/A7Uwl0v82pMQTF/+bEamJNR6 iVBLv7rH7wYuyOucBzpbGNA/fALL5956xFSdslzXj5s69Nwuojrp3K+xYWfyPhGJ X-Gm-Gg: ASbGnctJfMH4zgxcnHU24XvSrA1Twbmh6uJtN1zmNTS4gOuN/I00mlczgtIBZdTXp0t JQ5RjEs2lxzdHknD7qF9EVPjrgB9iF8vGYm+m6SVO9M2A5BXQDCgremb0Am4tfYbsk5Jjxigrgp nBhywxH09qqY+4smBLgfpoutWQKkd/7V9yqtXy2O6F4BJ88BuI3RJghZRZyiIX2UUwCUqYKuR2U CEIaOOerhzQgOm3eAObo+p9X7fMQmF+RCaufCVz5bdAXIxQxRDJLDHvF4+XIhBD0r3MpPJJo6Z/ odJmDLHYPHd36UGBPSCc9pIXgPL2uxbyHJXpQp+ieunnu18yiXqn8SYc/Q1lye2EWiLc6Gq6dWz sbQlaq9oxpcZMp3sBC+VmqMrVeGOeSVJk X-Google-Smtp-Source: AGHT+IFptKn6/1+hfiOBYp4Ar7Op0/yESM5nLqJes5p4R9zBhW3KpTmz1veH2B/fTkU4utWReLHnWw== X-Received: by 2002:a17:902:f541:b0:23f:f074:415e with SMTP id d9443c01a7336-245e030fd76mr35962265ad.14.1755627867321; Tue, 19 Aug 2025 11:24:27 -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 20/35] tcg/wasm: Add andc/orc/eqv/nand/nor instructions Date: Wed, 20 Aug 2025 03:21:49 +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::529; envelope-from=ktokunaga.mail@gmail.com; helo=mail-pg1-x529.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: 1755627956601116600 Content-Type: text/plain; charset="utf-8" This commit implements andc, orc, eqv, nand and nor operations using Wasm instructions. Signed-off-by: Kohei Tokunaga --- tcg/wasm/tcg-target.c.inc | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tcg/wasm/tcg-target.c.inc b/tcg/wasm/tcg-target.c.inc index 01ef7d32f3..3c0374cd01 100644 --- a/tcg/wasm/tcg-target.c.inc +++ b/tcg/wasm/tcg-target.c.inc @@ -449,6 +449,56 @@ static void tcg_wasm_out_cond( } } =20 +static void tcg_wasm_out_andc( + TCGContext *s, TCGReg ret, TCGReg arg1, TCGReg arg2) +{ + tcg_wasm_out_op_idx(s, OPC_GLOBAL_GET, REG_IDX(arg1)); + tcg_wasm_out_op_idx(s, OPC_GLOBAL_GET, REG_IDX(arg2)); + tcg_wasm_out_op_not(s); + tcg_wasm_out_op(s, OPC_I64_AND); + tcg_wasm_out_op_idx(s, OPC_GLOBAL_SET, REG_IDX(ret)); +} + +static void tcg_wasm_out_orc( + TCGContext *s, TCGReg ret, TCGReg arg1, TCGReg arg2) +{ + tcg_wasm_out_op_idx(s, OPC_GLOBAL_GET, REG_IDX(arg1)); + tcg_wasm_out_op_idx(s, OPC_GLOBAL_GET, REG_IDX(arg2)); + tcg_wasm_out_op_not(s); + tcg_wasm_out_op(s, OPC_I64_OR); + tcg_wasm_out_op_idx(s, OPC_GLOBAL_SET, REG_IDX(ret)); +} + +static void tcg_wasm_out_eqv( + TCGContext *s, TCGReg ret, TCGReg arg1, TCGReg arg2) +{ + tcg_wasm_out_op_idx(s, OPC_GLOBAL_GET, REG_IDX(arg1)); + tcg_wasm_out_op_idx(s, OPC_GLOBAL_GET, REG_IDX(arg2)); + tcg_wasm_out_op(s, OPC_I64_XOR); + tcg_wasm_out_op_not(s); + tcg_wasm_out_op_idx(s, OPC_GLOBAL_SET, REG_IDX(ret)); +} + +static void tcg_wasm_out_nand( + TCGContext *s, TCGReg ret, TCGReg arg1, TCGReg arg2) +{ + tcg_wasm_out_op_idx(s, OPC_GLOBAL_GET, REG_IDX(arg1)); + tcg_wasm_out_op_idx(s, OPC_GLOBAL_GET, REG_IDX(arg2)); + tcg_wasm_out_op(s, OPC_I64_AND); + tcg_wasm_out_op_not(s); + tcg_wasm_out_op_idx(s, OPC_GLOBAL_SET, REG_IDX(ret)); +} + +static void tcg_wasm_out_nor( + TCGContext *s, TCGReg ret, TCGReg arg1, TCGReg arg2) +{ + tcg_wasm_out_op_idx(s, OPC_GLOBAL_GET, REG_IDX(arg1)); + tcg_wasm_out_op_idx(s, OPC_GLOBAL_GET, REG_IDX(arg2)); + tcg_wasm_out_op(s, OPC_I64_OR); + tcg_wasm_out_op_not(s); + tcg_wasm_out_op_idx(s, OPC_GLOBAL_SET, REG_IDX(ret)); +} + static void tcg_wasm_out_setcond(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1, TCGReg arg2, TCGCond cond) { @@ -1177,6 +1227,7 @@ static void tgen_andc(TCGContext *s, TCGType type, TCGReg a0, TCGReg a1, TCGReg a2) { tcg_out_op_rrr(s, INDEX_op_andc, a0, a1, a2); + tcg_wasm_out_andc(s, a0, a1, a2); } =20 static const TCGOutOpBinary outop_andc =3D { @@ -1266,6 +1317,7 @@ static void tgen_eqv(TCGContext *s, TCGType type, TCGReg a0, TCGReg a1, TCGReg a2) { tcg_out_op_rrr(s, INDEX_op_eqv, a0, a1, a2); + tcg_wasm_out_eqv(s, a0, a1, a2); } =20 static const TCGOutOpBinary outop_eqv =3D { @@ -1339,6 +1391,7 @@ static void tgen_nand(TCGContext *s, TCGType type, TCGReg a0, TCGReg a1, TCGReg a2) { tcg_out_op_rrr(s, INDEX_op_nand, a0, a1, a2); + tcg_wasm_out_nand(s, a0, a1, a2); } =20 static const TCGOutOpBinary outop_nand =3D { @@ -1350,6 +1403,7 @@ static void tgen_nor(TCGContext *s, TCGType type, TCGReg a0, TCGReg a1, TCGReg a2) { tcg_out_op_rrr(s, INDEX_op_nor, a0, a1, a2); + tcg_wasm_out_nor(s, a0, a1, a2); } =20 static const TCGOutOpBinary outop_nor =3D { @@ -1373,6 +1427,7 @@ static void tgen_orc(TCGContext *s, TCGType type, TCGReg a0, TCGReg a1, TCGReg a2) { tcg_out_op_rrr(s, INDEX_op_orc, a0, a1, a2); + tcg_wasm_out_orc(s, a0, a1, a2); } =20 static const TCGOutOpBinary outop_orc =3D { --=20 2.43.0