From nobody Mon Feb 9 15:36:00 2026 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=1769412228; cv=none; d=zohomail.com; s=zohoarc; b=bP/Zbb8t6MLT5Vrh0EZ+FPm8liqr8BHlytS6CAa9FkHKvp/iKCFmJXuXE0MwhWwlomcd4ZR11EPogkASLz5ZlZ9LOEqz6lW6TbuFjVExIsIldj82Bkes6lbVNO6zkSnvmTSCDWWQzN5V0WQwc+kxLA3NvoZF1kzDmbINY2GdNpQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769412228; 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=XETmM2o4EihK8AYeDPsdnFJxfC4XHKe6S6lQlmdsixE=; b=oFpOfNG3bnj3Re1ifal5Ag8kSHl+ZkdlR83ekskjg6dE0WOz96re79SJgHKxBC/KeKP4erSopanvMv0pUVO6hPn96gxZiy/1/3G+LueFtov+GLeZf+6BDIjXIgrW6eV92a3YkGCfxwz1ceVkwC6KIHyDmaEa41EfvhzDDAZnGiw= 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 1769412228317383.97509058964795; Sun, 25 Jan 2026 23:23:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vkGtm-0005mc-He; Mon, 26 Jan 2026 02:20:34 -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 1vkGg6-0003AB-PL for qemu-devel@nongnu.org; Mon, 26 Jan 2026 02:06:34 -0500 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vkGfu-0004Pv-CI for qemu-devel@nongnu.org; Mon, 26 Jan 2026 02:06:20 -0500 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-82318702afbso2961030b3a.1 for ; Sun, 25 Jan 2026 23:05:47 -0800 (PST) Received: from brahms.. (fp93c00990.tkyc601.ap.nuro.jp. [147.192.9.144]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-823187716ebsm8661487b3a.66.2026.01.25.23.05.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jan 2026 23:05:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769411146; x=1770015946; 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=XETmM2o4EihK8AYeDPsdnFJxfC4XHKe6S6lQlmdsixE=; b=eYHahDfWFF4r920hK66ZPecCEIXyRcDI5s1whq8qu54ogaLduvag3CjyQVEjBipGoE vv8ZmNSh8AA6Bo1HYvjg67r+eAKrp3YxS9TavRgA+myrVwo7tL8lY5F7mBBOojD8Z6zM kSJUZREkqquwEvbcGm4PwShfuCzLfCW1nGO8aNuFSn8NCO2jz5EtyuMVbW8gl+4SxPYy ZcuGQ/vHhQrm6zsbEdd21riRKwqMIIFtQFRA6yk/cSG4tmYUYVsUCLBkQ1fD/b6B1R4F ub8E0RkjS2+PhTrnsEtsHBHyu/4IIQlL36MF8ZlHTIqtbSmpNS/qFZVfW/Cqt67ej5RJ imGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769411146; x=1770015946; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=XETmM2o4EihK8AYeDPsdnFJxfC4XHKe6S6lQlmdsixE=; b=HRphmgJqot/xpEr2rrhsQMFWlmiF07eIASuh2/y2CE1kFOi+GB/zVf4V1D1mCklh3j +IFhIGeBGiY7LQ9CDuZcWPxorngttvvkYw0al8jmYHFjJZG106K7WqGGtbKyVCCgH+s9 WUBMbgV598ZnuRG7yyB0GjhjCNxb+kITzl9onu5xLf4829szPeyzYT/pJy8OZjLCh5PO Y/lLEJ1zkZMicuXgSON29bkJn+IVWyGSYbcD2UXTnVAo7LIU8MaoVALVmmxbDyOWOBUw ewXUtI3KztecAFCU2K0h3mwrckaJbkp1wGxcd2EaK03+HN7V5s6nnOol7J+S3ZFp+F0U Se5w== X-Gm-Message-State: AOJu0YxTwerd+CrgV2NrbEQCW3p8cGOrsFUOZmsUHLE/28h3ux8qvyVz BmI30dDpQh7dtswO5wYLZSYu/3oJHpuL6+3CThx/5gwx7yzL65Hk8KNlbh7IVCCz X-Gm-Gg: AZuq6aJ/y7e60FeOWdsiYo8R5Q1SbnL2N/nV5Kk1Qfe5Np1b94zRhkPJa74Bi8oD8oY CNmvoGMHHYQakhCzrGsfPvSIQPYQHw3eZBItYPf/305KZtvi85rVPViRDOncw0BCDJzHscJjgpX GGJdHn1ov8P8i/eEVyuG4HTEcUxuLQBj6ZABjeXJ+mDoZ11xhJx9hTuhI8H6t0XiW9gu/z72l/w 7nww2kaKolCI+xIk3yb6WAyrnQkhEfjSb3kk2OPPJKnYUCP7oI5Iils3oBkIR0mz7UoXPj6Shy7 LqxK2oXDDZ44qFqwdZy68k84p6Sp3jglohOg6o371VK04Vc4pHN+H49qtTBW7GCw91OayZzSxSg V15sTTyDf5l8vVwL/CoTsHoJwu71H1uMGLZT2o9qOua7AN/xvj1R8Je1MiDo3m3VHK7KUE6LNR6 OCREeTOGRxVfbu8r+/GkJcalTXWITVkzUfBqXeFN1LFA== X-Received: by 2002:aa7:9067:0:b0:823:d04:dee1 with SMTP id d2e1a72fcca58-823412a2f70mr3586480b3a.32.1769411146200; Sun, 25 Jan 2026 23:05:46 -0800 (PST) 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 , Kohei Tokunaga , qemu-arm@nongnu.org, qemu-riscv@nongnu.org, Stefan Hajnoczi , Pierrick Bouvier Subject: [PATCH v4 22/33] tcg/wasm64: Add initialization of fundamental registers Date: Mon, 26 Jan 2026 07:03:35 +0000 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::436; envelope-from=ktokunaga.mail@gmail.com; helo=mail-pf1-x436.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, FORGED_GMAIL_RCVD=1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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: 1769412229594154100 Content-Type: text/plain; charset="utf-8" This commit adds initialization of TCG_AREG0 and TCG_REG_CALL_STACK at the beginning of each TB. The CPUArchState struct and the stack array are passed from the caller via the WasmContext structure. The BLOCK_IDX variable is initialized to 0 as TB execution begins at the first block. Signed-off-by: Kohei Tokunaga --- tcg/wasm64.h | 10 ++++++++++ tcg/wasm64/tcg-target.c.inc | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/tcg/wasm64.h b/tcg/wasm64.h index a3631b34a8..f2b67c1099 100644 --- a/tcg/wasm64.h +++ b/tcg/wasm64.h @@ -20,6 +20,16 @@ struct WasmContext { * Buffer to store 128bit return value on call. */ void *buf128; + + /* + * Pointer to the CPUArchState struct. + */ + CPUArchState *env; + + /* + * Pointer to a stack array. + */ + uint64_t *stack; }; =20 #endif diff --git a/tcg/wasm64/tcg-target.c.inc b/tcg/wasm64/tcg-target.c.inc index bab69b00ca..f5d4cb4139 100644 --- a/tcg/wasm64/tcg-target.c.inc +++ b/tcg/wasm64/tcg-target.c.inc @@ -2081,11 +2081,30 @@ static void tcg_out_set_carry(TCGContext *s) =20 static void tcg_out_tb_start(TCGContext *s) { + intptr_t ofs; + init_sub_buf(); init_blocks(); init_label_info(); init_helpers(); =20 + /* Initialize fundamental registers */ + tcg_wasm_out_op_idx(s, OPC_GLOBAL_GET, REG_IDX(TCG_AREG0)); + tcg_wasm_out_op(s, OPC_I64_EQZ); + tcg_wasm_out_op_block(s, OPC_IF, BLOCK_NORET); + + ofs =3D tcg_wasm_out_get_ctx(s, CTX_OFFSET(env)); + tcg_wasm_out_op_ldst(s, OPC_I64_LOAD, 0, ofs); + tcg_wasm_out_op_idx(s, OPC_GLOBAL_SET, REG_IDX(TCG_AREG0)); + + ofs =3D tcg_wasm_out_get_ctx(s, CTX_OFFSET(stack)); + tcg_wasm_out_op_ldst(s, OPC_I64_LOAD, 0, ofs); + tcg_wasm_out_op_idx(s, OPC_GLOBAL_SET, REG_IDX(TCG_REG_CALL_STACK)); + tcg_wasm_out_op(s, OPC_END); + + tcg_wasm_out_op_const(s, OPC_I64_CONST, 0); + tcg_wasm_out_op_idx(s, OPC_GLOBAL_SET, BLOCK_IDX); + tcg_wasm_out_op_block(s, OPC_LOOP, BLOCK_NORET); tcg_wasm_out_op_idx(s, OPC_GLOBAL_GET, BLOCK_IDX); tcg_wasm_out_op(s, OPC_I64_EQZ); --=20 2.43.0