From patchwork Fri Nov 11 07:40:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623671 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp615627pvb; Thu, 10 Nov 2022 23:41:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ugofl4DmbgtZhcrT+vs/XjPDO14CgWsAcOIjOwvrFQsdtr558MHCcEG7flvQJ2Rt5rg+D X-Received: by 2002:a37:e20e:0:b0:6fa:6fa6:fcb with SMTP id g14-20020a37e20e000000b006fa6fa60fcbmr170153qki.468.1668152504653; Thu, 10 Nov 2022 23:41:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152504; cv=none; d=google.com; s=arc-20160816; b=wq7Kv3ibOmuKedYItYyvUSvVX7liYXZ7VKU/x3JVqrf6RyvnLAKIH2/P5pgBSHNlwC K/YhnT9kAt9WWUQ9MljVZN3jmUNfUNX2vpicMAXxzENNUc6bUKXtFOs4ByD7AP9Zc1FL 5fpCAzEpD8f46+yipukyI21Jg2x4BSqGrWES6yZkgaiFwEw+rEHMSid5R9X6PVEbCrpO J8zn4PC3iGJTOnrWBtBD7RfIDsYXYsSuBr88YZVYck9t2RI+Kmq1A1D7Zagda8VIZtN0 uhyMsXDIwu/0O0+oBTPREWcDKrZL+29/jCsdQxNS8GPCWqy7eJMwyAkkbyEIFmmvzz8W +fQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jblV5uBEeJkgX0vKD5/cHG+S4aK1YYTDrtxKzN8WPJQ=; b=mMrOxHHCFXokK69rF/nlhythwbZjW0+i7LFZpWH0jAc9iUvUm9zgPaosulK4xdG5ta N1WgkqwIdY4JDbN8IykVdCOqEOiTk5Kc8WBq8hQFhulcz2xgzJ0ud1YaeeYDB5o1e592 88+b3Gqhr0LU4Znn9YTMcDb+jBONYOVEKBeDoiHEeTX1VvRtkmVQMWAcd3HaPB0Hq3nc CWJ9eqcqO+M5/RTmAJphj/bp3crFItjOZ3irZNUNBKy7+Mf6SjaDEwea7rRLitBpNbRB fXzjbL8Ple0APxpEVp1hFLJSq3uaK/uHilPoUiAnZOgsQX2eoCr2u1N41MUdZmQqjzhq c6lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z7XHkxYI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ff22-20020a05622a4d9600b0035cee17b7edsi693446qtb.587.2022.11.10.23.41.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:41:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z7XHkxYI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOf6-00064N-Gy; Fri, 11 Nov 2022 02:41:20 -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 1otOf3-00063Q-DE for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:13 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOf1-0007Vn-CF for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:12 -0500 Received: by mail-pj1-x1034.google.com with SMTP id d13-20020a17090a3b0d00b00213519dfe4aso4057921pjc.2 for ; Thu, 10 Nov 2022 23:41:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=jblV5uBEeJkgX0vKD5/cHG+S4aK1YYTDrtxKzN8WPJQ=; b=z7XHkxYImqt2O4B+QXznYJVYtgbuy6yy4fsdp9RI9MGCzvCYozgdGxOm4uf8dUk9ct 1HufzpnI2UTcfwuKHDeHV90ktzj6FzQWJQ2b1FGcufN7GQYPfpkGAg6qCLmviUq7JB4L 9Ky1jjf9eijvezx7TG9TheNMg3A3vBaMYb5iDF48RdrW2D/DPTXqBs+FBERs9CG9zaiF lnUIfyGTktHbOw70oGlcbOXhIXhS/evozO8BGYMder8FJ67IGQa1Z0g97Ed01be5+wx+ 6WKeW8WZofYWVDySKM2fPHBS8M4C4Sy0eQ/7kdj0lo66aqIeSM6X6S1iEuvO/TaIBnPp qDMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=jblV5uBEeJkgX0vKD5/cHG+S4aK1YYTDrtxKzN8WPJQ=; b=i9+ypZY8oSy6SiR0pL0mBTKKs/13qS7E9TcW1b+zbTZD6qozTshoxHNfydaTxRhewX LsP2q5b/FA6dCwIYtwIlbw51DLoItmnSqZUG+Tkm5uP17qu+xwQJo7x7eOCNweVXkIAq 7czCqsjcEIZrbifT574n5DGON3gWEJiMZ2BALC3EN1wam9Kr5DjLJiZL1DTlLB+im0uo /h/ATE1y2BwtXffDFkHtgDsMDtVt6Hyt1b1PPfQkEg8M72dEO138HtSRdQ263LYJwa0t LCMlkStjDi5GQ9zS/t+NtrDidquwRM9bfyiZM6GMzCRFiAVo3TBPpIITplA8waayOb4t AH3Q== X-Gm-Message-State: ANoB5pkbLO8WHBqN8thSEtSEKbmQaKE2pQ9ja0+YKAZyvFWqteEJPyac eHm9yrBTZ5zrAtmjCpI+srOk0kEQUy9lKJvo X-Received: by 2002:a17:902:da90:b0:187:12cc:d6f1 with SMTP id j16-20020a170902da9000b0018712ccd6f1mr1143272plx.63.1668152469825; Thu, 10 Nov 2022 23:41:09 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH for-8.0 v3 01/45] meson: Move CONFIG_TCG_INTERPRETER to config_host Date: Fri, 11 Nov 2022 17:40:17 +1000 Message-Id: <20221111074101.2069454-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Like CONFIG_TCG, the enabled method of execution is a host property not a guest property. This exposes the define to compile-once files. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- meson.build | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/meson.build b/meson.build index cf3e517e56..4984e80e71 100644 --- a/meson.build +++ b/meson.build @@ -469,6 +469,7 @@ if get_option('tcg').allowed() endif if get_option('tcg_interpreter') tcg_arch = 'tci' + config_host += { 'CONFIG_TCG_INTERPRETER': 'y' } elif host_arch == 'x86_64' tcg_arch = 'i386' elif host_arch == 'ppc64' @@ -2540,9 +2541,6 @@ foreach target : target_dirs if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, []) config_target += { sym: 'y' } config_all += { sym: 'y' } - if sym == 'CONFIG_TCG' and tcg_arch == 'tci' - config_target += { 'CONFIG_TCG_INTERPRETER': 'y' } - endif if target in modular_tcg config_target += { 'CONFIG_TCG_MODULAR': 'y' } else From patchwork Fri Nov 11 07:40:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623672 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp615704pvb; Thu, 10 Nov 2022 23:41:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf4HFxfjaYmKXe71iVta7Wx+lqxcGUe3+H0uesXtn/eHbCrGVjMiRSNUcxfEfoSROQpMp369 X-Received: by 2002:ac8:6f1b:0:b0:39c:c0a5:afbb with SMTP id bs27-20020ac86f1b000000b0039cc0a5afbbmr301875qtb.635.1668152517760; Thu, 10 Nov 2022 23:41:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152517; cv=none; d=google.com; s=arc-20160816; b=ek73XQbD9eBk0A1PjJJ5zSspXr9vnsWYP5j53pSC1zhZ8DugknHnJoiysPIJqarKdL C3XHlOcvBE/iAujsL7bDxqY5Io8NAsIJ35BMm0MgU8r8WEmsmGtXA9LpHwwP3XvYeY6X haf6S37Bzf/niL0ED+ihF8oAsWwM/kFgLukJ1GcREvyJNyqdsz2J6Y9WEB27EdXbmGzb Oijmp2G2ffCzblyyEyqIKD9ZGylIxMYxG7NU1B3iH/EsNJr5xxD89pqPjzMdaws+mLlf RDHO6MbcxfRLSNz8cURC7RApSAfLHzc59/p9r2BwsLFYgMXrM1sw6oYf9e8azeZYaHjc fXdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YoRGWSyVwaDhXOkYnUdohylcDpSat7ggSbobPWN00CY=; b=J9fT3Ab+HDt4MuHMtxvCLnbP0VvhYA6BfGmmW7KT4715Gjb05kq8iyPUd/hqx+j3YH 4S0eOQy7IAnHdXj8UyVGIImqhC8zHL19+ezjbHukAlvjnT/pMiWclINwttQNDZJohO5A 8iVlM2RjAHr96DLlssi86LgmzsVKrnxGw0+xhpUfnLB8nTKzPHiwhN9Hs62YQaMA4BwQ lBLRuDftYPopWVvoIO6cCodByPVSxI8jF2PBd4FhOWXM3Nv3ex8O/WtGwjh2zmlxd6s6 qNkoLsfQmwAoShl5tQMVVU9tEIDubzaSLdy9vPtEyHdn/jYUT63v9XnR7hgFEeq1H4Eb 8ffg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=THrAA1z9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l18-20020a05622a175200b003a5108967f9si765225qtk.197.2022.11.10.23.41.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:41:57 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=THrAA1z9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfD-00064r-22; Fri, 11 Nov 2022 02:41:23 -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 1otOf5-00063u-J9 for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:15 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOf3-0007We-VX for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:15 -0500 Received: by mail-pl1-x62b.google.com with SMTP id k7so3625242pll.6 for ; Thu, 10 Nov 2022 23:41:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=YoRGWSyVwaDhXOkYnUdohylcDpSat7ggSbobPWN00CY=; b=THrAA1z9LolC0Oj4hDqhX96ux2dnx2y8ZMbCYsmLhJ3w30J0VogMHNdMguNB19o89T Vmids42Sok93D8/MVW50WEMDxHGdIwe8YxyM1JT4x0my5NBPTyM3C6cF7T4ISUuIFwLN 8/DZ4NFbdtsq1C+sp03RaqEmaaBWidusCRpMA+LV5Zy5Tez1qG6HkyiqeoCV06NEJQHy OyqMOdWG50Dk4k2S4ujd5jeIaR78AdwLsr7oa3V0sMmaTwLy54tw7OoMSdAtnFyMeXJK VuBuirkYDzlQnyBjmx6Rm9QLUVBWyxU5KMVAEZivtUeavqQIPmJmL387NKW2wYGazu7y GDCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=YoRGWSyVwaDhXOkYnUdohylcDpSat7ggSbobPWN00CY=; b=J6WDpUuXNVsir48q7strodt2ZGMOA/kRbDvJGTvBpED7A+xeIkWhIphXQ9zTXGjCyU 5l1ALmVyBN3qYfDoRXDrnL7g6OGamTrnuQh+WjSKkluOqOrpj/0X1Uhwz7MezJvIXfj+ 2ST4tjJgBMbTPA8OhIJ5JGp3pOGUNl8shhf4igeYBAmxmW4Xxi+bwS70wgJuDR7pFDj7 0GBH7zQKMedilxPQNNc/swQ+YAeKRk2icBBYnu92SuJpF5kWGac1A5DWWX1qvhcfz1YH /sujuKSaflRs8kjHH9rmBVVDkqfEm6khBkVs4iS/bjOfXHd1UFnRKX7ok9Ipi+dbAu5w wVCg== X-Gm-Message-State: ANoB5pnfAi3sX2lzR6nksYAx9YGlyPZcDCAxjKObSVqK/tkssNEo7bAk sX0e/8n0VT6hWpYzbQR9Ep/uodduyn8vZXq+ X-Received: by 2002:a17:902:d145:b0:181:b25e:e7bc with SMTP id t5-20020a170902d14500b00181b25ee7bcmr1524109plt.46.1668152472389; Thu, 10 Nov 2022 23:41:12 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH for-8.0 v3 02/45] tcg: Tidy tcg_reg_alloc_op Date: Fri, 11 Nov 2022 17:40:18 +1000 Message-Id: <20221111074101.2069454-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Replace goto allocate_in_reg with a boolean. Remove o_preferred_regs which isn't used, except to copy. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tcg.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 436fcf6ebd..c68fa1d564 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3606,7 +3606,8 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) /* satisfy input constraints */ for (k = 0; k < nb_iargs; k++) { - TCGRegSet i_preferred_regs, o_preferred_regs; + TCGRegSet i_preferred_regs; + bool allocate_new_reg; i = def->args_ct[nb_oargs + k].sort_index; arg = op->args[i]; @@ -3621,9 +3622,12 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) continue; } - i_preferred_regs = o_preferred_regs = 0; + reg = ts->reg; + i_preferred_regs = 0; + allocate_new_reg = false; + if (arg_ct->ialias) { - o_preferred_regs = op->output_pref[arg_ct->alias_index]; + i_preferred_regs = op->output_pref[arg_ct->alias_index]; /* * If the input is readonly, then it cannot also be an @@ -3632,30 +3636,23 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) * register and move it. */ if (temp_readonly(ts) || !IS_DEAD_ARG(i)) { - goto allocate_in_reg; + allocate_new_reg = true; + } else if (ts->val_type == TEMP_VAL_REG) { + /* + * Check if the current register has already been + * allocated for another input. + */ + allocate_new_reg = tcg_regset_test_reg(i_allocated_regs, reg); } - - /* - * Check if the current register has already been allocated - * for another input aliased to an output. - */ - if (ts->val_type == TEMP_VAL_REG) { - reg = ts->reg; - for (int k2 = 0; k2 < k; k2++) { - int i2 = def->args_ct[nb_oargs + k2].sort_index; - if (def->args_ct[i2].ialias && reg == new_args[i2]) { - goto allocate_in_reg; - } - } - } - i_preferred_regs = o_preferred_regs; } - temp_load(s, ts, arg_ct->regs, i_allocated_regs, i_preferred_regs); - reg = ts->reg; + if (!allocate_new_reg) { + temp_load(s, ts, arg_ct->regs, i_allocated_regs, i_preferred_regs); + reg = ts->reg; + allocate_new_reg = !tcg_regset_test_reg(arg_ct->regs, reg); + } - if (!tcg_regset_test_reg(arg_ct->regs, reg)) { - allocate_in_reg: + if (allocate_new_reg) { /* * Allocate a new register matching the constraint * and move the temporary register into it. @@ -3663,7 +3660,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) temp_load(s, ts, tcg_target_available_regs[ts->type], i_allocated_regs, 0); reg = tcg_reg_alloc(s, arg_ct->regs, i_allocated_regs, - o_preferred_regs, ts->indirect_base); + i_preferred_regs, ts->indirect_base); if (!tcg_out_mov(s, ts->type, reg, ts->reg)) { /* * Cross register class move not supported. Sync the From patchwork Fri Nov 11 07:40:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623674 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp615799pvb; Thu, 10 Nov 2022 23:42:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf5xNQSK9blcxAqe3/F/B/NAsTkGPJmaBJHCDCcUtHkv8p6KXLN8SEJ7835SYI83QUGLhMVu X-Received: by 2002:ad4:5384:0:b0:4b4:8037:1303 with SMTP id i4-20020ad45384000000b004b480371303mr992193qvv.16.1668152539013; Thu, 10 Nov 2022 23:42:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152539; cv=none; d=google.com; s=arc-20160816; b=Leb/xQBBY8JllumpfRu2ITKoUsaDIp9zRRSmSWtfEfCsSc5kV5njkxoX1C3TPheJ1s NoKsAzs8Z0pvsaXMBGPtNS8yEagHybqcWNm6HLW7en8VXevwNCw3kDCTNiHoeXw1NOax SdOEl+Yd66p0g9hqHZsjb9eCXNDGZKBWKKM/UbpzsyOjIoJM3ykRwMG/+r6lerf5IZH7 hRvae2Ig2vQhmafp45FpZ+uKMxZ0UzLh2UgaxHcZZxivkXgnQINwRBWtZAYCbl48zqzt MSMUbW9waL+btRH5bX/SzUPxZfGrd5OWGaZ4IK53qgUfxJFdT1ohesASh0E7hD3DmxlT /hhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=SrZQlvErLRNnhP/RZ2dv32a5apAAfuiIKcrDKQjo1/Q=; b=REXvRLN7+wKoS+5yK6ShCcuRsNj16a44FzvcDlsXF301HgbHACqZLMocC6KemvFnwi 35bJT0z2qVYIXwlsgC8t03JYvCFjgJF1XjjRRIkejc1vu4Z1lhYyfHScPkhdxupt1sVE 2+DTqHkQaO3Rc3US3LDQU8K2I1BNxPgJo5WeL1hFDLlHXHxE+U3thpbvHdNxtRgWMm9f zVMlpn/KYUp0y5f04esinOH8mnPUhx0fcIeMrEoc/f/ocFxQGFEN/pp0ELFbzcXvfat1 BbinHILp48sPJFvd/osiW/0hJ6z6p7WnNKtgRo1vdpfEK8aV+iecNxKDNLqbXK+3c6UT XjOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v7CL6oYW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bv18-20020a05622a0a1200b003a4f21d8f92si710583qtb.552.2022.11.10.23.42.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:42:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v7CL6oYW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfP-00067J-Hm; Fri, 11 Nov 2022 02:41:37 -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 1otOf9-00064c-2d for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:21 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOf6-0007X3-Eq for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:18 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d20so3611164plr.10 for ; Thu, 10 Nov 2022 23:41:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=SrZQlvErLRNnhP/RZ2dv32a5apAAfuiIKcrDKQjo1/Q=; b=v7CL6oYWC02mXhQdOQkL4D7QomWeuViS89Aeq/XYDnYIC/jpOb1bZm18GCSfkFTyCs +OGj/8CcjF9nyWpZhus5GN/tI/bZkV/fMSKIYH8KO7c188OntEKBayN4gmUrtTQX21K/ 4R1oCsHL+i0mBfsEu2ByEGOv4XW6WmQF6GD/tIiVkGbsAN1QUdl/kUNQZtrezWkmEImp yZKbHCaqZy1fMZeKc9kfXPtlZ8lwvYWAX3zvPkaWKXF8xbZYJNOnwm705fGcZ2oRYtZl 5qZh384iTOqedHzB36eK8HkBAa7clbMCjvktrV3cjaNYyhNOJBShNYbUowKXnQ5XMRyU p6og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SrZQlvErLRNnhP/RZ2dv32a5apAAfuiIKcrDKQjo1/Q=; b=T+KiHLhTQwLJvgVOKBxqkf3f6nFP887KyVvgHgdcV7a6Kw6xYD5iY8YLoSyNsUFhLj F1H0jm1BRgsq5bbCDn5tKap1udBqCzWGly8v9jRpLfgyfn38Hv6vkEC1aRCCkenu8X0A jd3HhZU9DEtOXAlvORlQ6FwKfdGvu/K1DaOg8BxX1JvhJ8aXCqg5lLKFdBI3cdM9YQZM GKWoonx+GdyBhVgfRxUrjIjyCS0QjIf9TL8lVeJmqtLTI2nIOgyBgG2qWOOFOeM90roh mrX7OGOfHuL3+Satlm3Fssl0J0NTcynuESHDtVH/cjjL535x4CX48fKqC6OehNSUGIVj ddOg== X-Gm-Message-State: ANoB5pmeCqgHVSP6LKwpBUG9hizxePhAk14MYDzLvY1kqBDanxSrJOsx 5z03JGNnRH8cSdTXBBhVb5YBts4eQjNG4YyS X-Received: by 2002:a17:90b:400e:b0:210:f1f7:575e with SMTP id ie14-20020a17090b400e00b00210f1f7575emr677359pjb.47.1668152474580; Thu, 10 Nov 2022 23:41:14 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 03/45] tcg: Introduce paired register allocation Date: Fri, 11 Nov 2022 17:40:19 +1000 Message-Id: <20221111074101.2069454-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org There are several instances where we need to be able to allocate a pair of registers to related inputs/outputs. Add 'p' and 'm' register constraints for this, in order to be able to allocate the even/odd register first or second. Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 2 + tcg/tcg.c | 469 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 393 insertions(+), 78 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index d84bae6e3f..5c2254ce9f 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -951,6 +951,8 @@ typedef struct TCGArgConstraint { unsigned ct : 16; unsigned alias_index : 4; unsigned sort_index : 4; + unsigned pair_index : 4; + unsigned pair : 2; /* 0: none, 1: first, 2: second, 3: second alias */ bool oalias : 1; bool ialias : 1; bool newreg : 1; diff --git a/tcg/tcg.c b/tcg/tcg.c index c68fa1d564..f5383bb2b0 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1985,15 +1985,32 @@ static void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs) static int get_constraint_priority(const TCGOpDef *def, int k) { const TCGArgConstraint *arg_ct = &def->args_ct[k]; - int n; + int n = ctpop64(arg_ct->regs); - if (arg_ct->oalias) { - /* an alias is equivalent to a single register */ - n = 1; - } else { - n = ctpop64(arg_ct->regs); + /* + * Sort constraints of a single register first, which includes output + * aliases (which must exactly match the input already allocated). + */ + if (n == 1 || arg_ct->oalias) { + return INT_MAX; } - return TCG_TARGET_NB_REGS - n + 1; + + /* + * Sort register pairs next, first then second immediately after. + * Arbitrarily sort multiple pairs by the index of the first reg; + * there shouldn't be many pairs. + */ + switch (arg_ct->pair) { + case 1: + case 3: + return (k + 1) * 2; + case 2: + return (arg_ct->pair_index + 1) * 2 - 1; + } + + /* Finally, sort by decreasing register count. */ + assert(n > 1); + return -n; } /* sort from highest priority to lowest */ @@ -2028,7 +2045,8 @@ static void process_op_defs(TCGContext *s) for (op = 0; op < NB_OPS; op++) { TCGOpDef *def = &tcg_op_defs[op]; const TCGTargetOpDef *tdefs; - int i, nb_args; + bool saw_alias_pair = false; + int i, o, i2, o2, nb_args; if (def->flags & TCG_OPF_NOT_PRESENT) { continue; @@ -2050,58 +2068,175 @@ static void process_op_defs(TCGContext *s) for (i = 0; i < nb_args; i++) { const char *ct_str = tdefs->args_ct_str[i]; + bool input_p = i >= def->nb_oargs; + /* Incomplete TCGTargetOpDef entry. */ tcg_debug_assert(ct_str != NULL); - while (*ct_str != '\0') { - switch(*ct_str) { - case '0' ... '9': - { - int oarg = *ct_str - '0'; - tcg_debug_assert(ct_str == tdefs->args_ct_str[i]); - tcg_debug_assert(oarg < def->nb_oargs); - tcg_debug_assert(def->args_ct[oarg].regs != 0); - def->args_ct[i] = def->args_ct[oarg]; - /* The output sets oalias. */ - def->args_ct[oarg].oalias = true; - def->args_ct[oarg].alias_index = i; - /* The input sets ialias. */ - def->args_ct[i].ialias = true; - def->args_ct[i].alias_index = oarg; - } - ct_str++; - break; - case '&': - def->args_ct[i].newreg = true; - ct_str++; - break; + switch (*ct_str) { + case '0' ... '9': + o = *ct_str - '0'; + tcg_debug_assert(input_p); + tcg_debug_assert(o < def->nb_oargs); + tcg_debug_assert(def->args_ct[o].regs != 0); + tcg_debug_assert(!def->args_ct[o].oalias); + def->args_ct[i] = def->args_ct[o]; + /* The output sets oalias. */ + def->args_ct[o].oalias = 1; + def->args_ct[o].alias_index = i; + /* The input sets ialias. */ + def->args_ct[i].ialias = 1; + def->args_ct[i].alias_index = o; + if (def->args_ct[i].pair) { + saw_alias_pair = true; + } + tcg_debug_assert(ct_str[1] == '\0'); + continue; + + case '&': + tcg_debug_assert(!input_p); + def->args_ct[i].newreg = true; + ct_str++; + break; + + case 'p': /* plus */ + /* Allocate to the register after the previous. */ + tcg_debug_assert(i > (input_p ? def->nb_oargs : 0)); + o = i - 1; + tcg_debug_assert(!def->args_ct[o].pair); + tcg_debug_assert(!def->args_ct[o].ct); + def->args_ct[i] = (TCGArgConstraint){ + .pair = 2, + .pair_index = o, + .regs = def->args_ct[o].regs << 1, + }; + def->args_ct[o].pair = 1; + def->args_ct[o].pair_index = i; + tcg_debug_assert(ct_str[1] == '\0'); + continue; + + case 'm': /* minus */ + /* Allocate to the register before the previous. */ + tcg_debug_assert(i > (input_p ? def->nb_oargs : 0)); + o = i - 1; + tcg_debug_assert(!def->args_ct[o].pair); + tcg_debug_assert(!def->args_ct[o].ct); + def->args_ct[i] = (TCGArgConstraint){ + .pair = 1, + .pair_index = o, + .regs = def->args_ct[o].regs >> 1, + }; + def->args_ct[o].pair = 2; + def->args_ct[o].pair_index = i; + tcg_debug_assert(ct_str[1] == '\0'); + continue; + } + + do { + switch (*ct_str) { case 'i': def->args_ct[i].ct |= TCG_CT_CONST; - ct_str++; break; /* Include all of the target-specific constraints. */ #undef CONST #define CONST(CASE, MASK) \ - case CASE: def->args_ct[i].ct |= MASK; ct_str++; break; + case CASE: def->args_ct[i].ct |= MASK; break; #define REGS(CASE, MASK) \ - case CASE: def->args_ct[i].regs |= MASK; ct_str++; break; + case CASE: def->args_ct[i].regs |= MASK; break; #include "tcg-target-con-str.h" #undef REGS #undef CONST default: + case '0' ... '9': + case '&': + case 'p': + case 'm': /* Typo in TCGTargetOpDef constraint. */ g_assert_not_reached(); } - } + } while (*++ct_str != '\0'); } /* TCGTargetOpDef entry with too much information? */ tcg_debug_assert(i == TCG_MAX_OP_ARGS || tdefs->args_ct_str[i] == NULL); + /* + * Fix up output pairs that are aliased with inputs. + * When we created the alias, we copied pair from the output. + * There are three cases: + * (1a) Pairs of inputs alias pairs of outputs. + * (1b) One input aliases the first of a pair of outputs. + * (2) One input aliases the second of a pair of outputs. + * + * Case 1a is handled by making sure that the pair_index'es are + * properly updated so that they appear the same as a pair of inputs. + * + * Case 1b is handled by setting the pair_index of the input to + * itself, simply so it doesn't point to an unrelated argument. + * Since we don't encounter the "second" during the input allocation + * phase, nothing happens with the second half of the input pair. + * + * Case 2 is handled by setting the second input to pair=3, the + * first output to pair=3, and the pair_index'es to match. + */ + if (saw_alias_pair) { + for (i = def->nb_oargs; i < nb_args; i++) { + /* + * Since [0-9pm] must be alone in the constraint string, + * the only way they can both be set is if the pair comes + * from the output alias. + */ + if (!def->args_ct[i].ialias) { + continue; + } + switch (def->args_ct[i].pair) { + case 0: + break; + case 1: + o = def->args_ct[i].alias_index; + o2 = def->args_ct[o].pair_index; + tcg_debug_assert(def->args_ct[o].pair == 1); + tcg_debug_assert(def->args_ct[o2].pair == 2); + if (def->args_ct[o2].oalias) { + /* Case 1a */ + i2 = def->args_ct[o2].alias_index; + tcg_debug_assert(def->args_ct[i2].pair == 2); + def->args_ct[i2].pair_index = i; + def->args_ct[i].pair_index = i2; + } else { + /* Case 1b */ + def->args_ct[i].pair_index = i; + } + break; + case 2: + o = def->args_ct[i].alias_index; + o2 = def->args_ct[o].pair_index; + tcg_debug_assert(def->args_ct[o].pair == 2); + tcg_debug_assert(def->args_ct[o2].pair == 1); + if (def->args_ct[o2].oalias) { + /* Case 1a */ + i2 = def->args_ct[o2].alias_index; + tcg_debug_assert(def->args_ct[i2].pair == 1); + def->args_ct[i2].pair_index = i; + def->args_ct[i].pair_index = i2; + } else { + /* Case 2 */ + def->args_ct[i].pair = 3; + def->args_ct[o2].pair = 3; + def->args_ct[i].pair_index = o2; + def->args_ct[o2].pair_index = i; + } + break; + default: + g_assert_not_reached(); + } + } + } + /* sort the constraints (XXX: this is just an heuristic) */ sort_constraints(def, 0, def->nb_oargs); sort_constraints(def, def->nb_oargs, def->nb_iargs); @@ -3197,6 +3332,52 @@ static TCGReg tcg_reg_alloc(TCGContext *s, TCGRegSet required_regs, tcg_abort(); } +static TCGReg tcg_reg_alloc_pair(TCGContext *s, TCGRegSet required_regs, + TCGRegSet allocated_regs, + TCGRegSet preferred_regs, bool rev) +{ + int i, j, k, fmin, n = ARRAY_SIZE(tcg_target_reg_alloc_order); + TCGRegSet reg_ct[2]; + const int *order; + + /* Ensure that if I is not in allocated_regs, I+1 is not either. */ + reg_ct[1] = required_regs & ~(allocated_regs | (allocated_regs >> 1)); + tcg_debug_assert(reg_ct[1] != 0); + reg_ct[0] = reg_ct[1] & preferred_regs; + + order = rev ? indirect_reg_alloc_order : tcg_target_reg_alloc_order; + + /* + * Skip the preferred_regs option if it cannot be satisfied, + * or if the preference made no difference. + */ + k = reg_ct[0] == 0 || reg_ct[0] == reg_ct[1]; + + /* + * Minimize the number of flushes by looking for 2 free registers first, + * then a single flush, then two flushes. + */ + for (fmin = 2; fmin >= 0; fmin--) { + for (j = k; j < 2; j++) { + TCGRegSet set = reg_ct[j]; + + for (i = 0; i < n; i++) { + TCGReg reg = order[i]; + + if (tcg_regset_test_reg(set, reg)) { + int f = !s->reg_to_temp[reg] + !s->reg_to_temp[reg + 1]; + if (f >= fmin) { + tcg_reg_free(s, reg, allocated_regs); + tcg_reg_free(s, reg + 1, allocated_regs); + return reg; + } + } + } + } + } + tcg_abort(); +} + /* Make sure the temporary is in a register. If needed, allocate the register from DESIRED while avoiding ALLOCATED. */ static void temp_load(TCGContext *s, TCGTemp *ts, TCGRegSet desired_regs, @@ -3606,8 +3787,10 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) /* satisfy input constraints */ for (k = 0; k < nb_iargs; k++) { - TCGRegSet i_preferred_regs; - bool allocate_new_reg; + TCGRegSet i_preferred_regs, i_required_regs; + bool allocate_new_reg, copyto_new_reg; + TCGTemp *ts2; + int i1, i2; i = def->args_ct[nb_oargs + k].sort_index; arg = op->args[i]; @@ -3624,43 +3807,142 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) reg = ts->reg; i_preferred_regs = 0; + i_required_regs = arg_ct->regs; allocate_new_reg = false; + copyto_new_reg = false; - if (arg_ct->ialias) { + switch (arg_ct->pair) { + case 0: /* not paired */ + if (arg_ct->ialias) { + i_preferred_regs = op->output_pref[arg_ct->alias_index]; + + /* + * If the input is readonly, then it cannot also be an + * output and aliased to itself. If the input is not + * dead after the instruction, we must allocate a new + * register and move it. + */ + if (temp_readonly(ts) || !IS_DEAD_ARG(i)) { + allocate_new_reg = true; + } else if (ts->val_type == TEMP_VAL_REG) { + /* + * Check if the current register has already been + * allocated for another input. + */ + allocate_new_reg = + tcg_regset_test_reg(i_allocated_regs, reg); + } + } + if (!allocate_new_reg) { + temp_load(s, ts, i_required_regs, i_allocated_regs, + i_preferred_regs); + reg = ts->reg; + allocate_new_reg = !tcg_regset_test_reg(i_required_regs, reg); + } + if (allocate_new_reg) { + /* + * Allocate a new register matching the constraint + * and move the temporary register into it. + */ + temp_load(s, ts, tcg_target_available_regs[ts->type], + i_allocated_regs, 0); + reg = tcg_reg_alloc(s, i_required_regs, i_allocated_regs, + i_preferred_regs, ts->indirect_base); + copyto_new_reg = true; + } + break; + + case 1: + /* First of an input pair; if i1 == i2, the second is an output. */ + i1 = i; + i2 = arg_ct->pair_index; + + /* + * It is easier to default to allocating a new pair + * and to identify a few cases where it's not required. + */ + allocate_new_reg = true; + ts2 = i1 != i2 ? arg_temp(op->args[i2]) : NULL; + + if (arg_ct->ialias) { + i_preferred_regs = op->output_pref[arg_ct->alias_index]; + if (IS_DEAD_ARG(i1) && + IS_DEAD_ARG(i2) && + !temp_readonly(ts) && + ts->val_type == TEMP_VAL_REG && + ts->reg < TCG_TARGET_NB_REGS - 1 && + tcg_regset_test_reg(i_required_regs, reg) && + !tcg_regset_test_reg(i_allocated_regs, reg) && + !tcg_regset_test_reg(i_allocated_regs, reg + 1) && + (ts2 + ? !temp_readonly(ts2) && + ts2->val_type == TEMP_VAL_REG && + ts2->reg == reg + 1 + : s->reg_to_temp[reg + 1] == NULL)) { + allocate_new_reg = false; + } + } else { + /* Without aliasing, the pair must also be an input. */ + tcg_debug_assert(ts2); + if (ts->val_type == TEMP_VAL_REG && + ts2->val_type == TEMP_VAL_REG && + ts2->reg == reg + 1 && + tcg_regset_test_reg(i_required_regs, reg)) { + allocate_new_reg = false; + } + } + if (allocate_new_reg) { + reg = tcg_reg_alloc_pair(s, i_required_regs, i_allocated_regs, + 0, ts->indirect_base); + if (ts->val_type != TEMP_VAL_REG) { + temp_load(s, ts, (TCGRegSet)1 << reg, i_allocated_regs, 0); + } else { + copyto_new_reg = true; + } + } + break; + + case 2: /* pair second */ + reg = new_args[arg_ct->pair_index] + 1; + i_required_regs = (TCGRegSet)1 << reg; + temp_load(s, ts, i_required_regs, i_allocated_regs, 0); + allocate_new_reg = ts->reg != reg; + break; + + case 3: /* ialias with second output, no first input */ + tcg_debug_assert(arg_ct->ialias); i_preferred_regs = op->output_pref[arg_ct->alias_index]; - /* - * If the input is readonly, then it cannot also be an - * output and aliased to itself. If the input is not - * dead after the instruction, we must allocate a new - * register and move it. - */ - if (temp_readonly(ts) || !IS_DEAD_ARG(i)) { - allocate_new_reg = true; - } else if (ts->val_type == TEMP_VAL_REG) { - /* - * Check if the current register has already been - * allocated for another input. - */ - allocate_new_reg = tcg_regset_test_reg(i_allocated_regs, reg); + allocate_new_reg = true; + if (IS_DEAD_ARG(i) && + ts->val_type == TEMP_VAL_REG && + reg > 0 && + !s->reg_to_temp[reg - 1] && + tcg_regset_test_reg(i_required_regs, reg) && + !tcg_regset_test_reg(i_allocated_regs, reg) && + !tcg_regset_test_reg(i_allocated_regs, reg - 1)) { + tcg_regset_set_reg(i_allocated_regs, reg - 1); + allocate_new_reg = false; } + if (allocate_new_reg) { + reg = tcg_reg_alloc_pair(s, i_required_regs >> 1, + i_allocated_regs, 0, + ts->indirect_base); + tcg_regset_set_reg(i_allocated_regs, reg); + reg += 1; + if (ts->val_type != TEMP_VAL_REG) { + temp_load(s, ts, (TCGRegSet)1 << reg, i_allocated_regs, 0); + } else { + copyto_new_reg = true; + } + } + break; + + default: + g_assert_not_reached(); } - if (!allocate_new_reg) { - temp_load(s, ts, arg_ct->regs, i_allocated_regs, i_preferred_regs); - reg = ts->reg; - allocate_new_reg = !tcg_regset_test_reg(arg_ct->regs, reg); - } - - if (allocate_new_reg) { - /* - * Allocate a new register matching the constraint - * and move the temporary register into it. - */ - temp_load(s, ts, tcg_target_available_regs[ts->type], - i_allocated_regs, 0); - reg = tcg_reg_alloc(s, arg_ct->regs, i_allocated_regs, - i_preferred_regs, ts->indirect_base); + if (copyto_new_reg) { if (!tcg_out_mov(s, ts->type, reg, ts->reg)) { /* * Cross register class move not supported. Sync the @@ -3675,7 +3957,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) const_args[i] = 0; tcg_regset_set_reg(i_allocated_regs, reg); } - + /* mark dead temporaries and free the associated registers */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { if (IS_DEAD_ARG(i)) { @@ -3703,7 +3985,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) } /* satisfy the output constraints */ - for(k = 0; k < nb_oargs; k++) { + for (k = 0; k < nb_oargs; k++) { i = def->args_ct[k].sort_index; arg = op->args[i]; arg_ct = &def->args_ct[i]; @@ -3712,15 +3994,46 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) /* ENV should not be modified. */ tcg_debug_assert(!temp_readonly(ts)); - if (arg_ct->oalias && !const_args[arg_ct->alias_index]) { - reg = new_args[arg_ct->alias_index]; - } else if (arg_ct->newreg) { - reg = tcg_reg_alloc(s, arg_ct->regs, - i_allocated_regs | o_allocated_regs, - op->output_pref[k], ts->indirect_base); - } else { - reg = tcg_reg_alloc(s, arg_ct->regs, o_allocated_regs, - op->output_pref[k], ts->indirect_base); + switch (arg_ct->pair) { + case 0: /* not paired */ + if (arg_ct->oalias && !const_args[arg_ct->alias_index]) { + reg = new_args[arg_ct->alias_index]; + } else if (arg_ct->newreg) { + reg = tcg_reg_alloc(s, arg_ct->regs, + i_allocated_regs | o_allocated_regs, + op->output_pref[k], ts->indirect_base); + } else { + reg = tcg_reg_alloc(s, arg_ct->regs, o_allocated_regs, + op->output_pref[k], ts->indirect_base); + } + break; + + case 1: /* first of pair */ + tcg_debug_assert(!arg_ct->newreg); + if (arg_ct->oalias) { + reg = new_args[arg_ct->alias_index]; + break; + } + reg = tcg_reg_alloc_pair(s, arg_ct->regs, o_allocated_regs, + op->output_pref[k], ts->indirect_base); + break; + + case 2: /* second of pair */ + tcg_debug_assert(!arg_ct->newreg); + if (arg_ct->oalias) { + reg = new_args[arg_ct->alias_index]; + } else { + reg = new_args[arg_ct->pair_index] + 1; + } + break; + + case 3: /* first of pair, aliasing with a second input */ + tcg_debug_assert(!arg_ct->newreg); + reg = new_args[arg_ct->pair_index] - 1; + break; + + default: + g_assert_not_reached(); } tcg_regset_set_reg(o_allocated_regs, reg); if (ts->val_type == TEMP_VAL_REG) { @@ -3728,12 +4041,12 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) } ts->val_type = TEMP_VAL_REG; ts->reg = reg; + s->reg_to_temp[reg] = ts; /* * Temp value is modified, so the value kept in memory is * potentially not the same. */ ts->mem_coherent = 0; - s->reg_to_temp[reg] = ts; new_args[i] = reg; } } From patchwork Fri Nov 11 07:40:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623689 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp619540pvb; Thu, 10 Nov 2022 23:53:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf4OHgTMeau2cruA+iTtO6BEr7/v5BSsvI9UO45elwjJP5K0wa9Z5iTSeiq1lJTlr6um3VR4 X-Received: by 2002:a05:622a:8cf:b0:3a5:c024:7f31 with SMTP id i15-20020a05622a08cf00b003a5c0247f31mr351865qte.311.1668153195267; Thu, 10 Nov 2022 23:53:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668153195; cv=none; d=google.com; s=arc-20160816; b=Ib6ZTiJZn41hCkDYUN/5vpmJyST5lx7mdMH5TdmMpgiCzfyO4Usrbykvh7lzpTHJvw 0JHTezbgB9OkzJkhdoVzwIS6HBYXveeGSdyr2A+2kqQBIfFrnO4mHtoBUnYgqext9tcb h2T/xNCoZ7dykQy8usgPLIehe1yEXQSKZrsfPgD6FAvfB4QQXEXsHsvoDGg9Ec9q4EUm puGZhoH4d8fF28H1R1MO9ZASJZ/iPUfpes27VOEnGne9fzdmoq8HecGamxyTJ7q2TcOj 8OCIQkFuh98Xiz0NwtKKImkBX+8js1QtkE4MnvOahxEjfvCsLHHlrjjNQwRNl7lNSd43 blNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=+XZZb+kD5PLDfiZzYREY/FqgovJZfyA/XfR3p9NEW64=; b=WIjkHyna4AyT7NWXvMzg7CcLCG/cYTfXGuJwxWcbY+qnFqmE7lZpWqNX5Rf15Np8Mm iFEgYnZ+n4H8BsRGYDgq+MfiXwEGw2bB2aafCnvikSiIEcyGkNM/0DRuuB7CzV3bLPes GcVoJRa/K/U2fEeocD0ZLtsunyVui9xw3/dOdrXMNlwMN69QyymZtiGciroI4Mfx0yzT FJWp3aj+OYgOAcwXVSouavzshbDt+l5d66WKt7cozxQnCr5BegiKx4ZksQ8V9We1Zur9 Yta/j+TYO6P21rglQyiA7mu6b8nv1RAG134/sysax/QHwguiWmodMQWglA8hxE3Jq228 Fbiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A9ZnMs44; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o3-20020ad45c83000000b004b4786a4989si700505qvh.164.2022.11.10.23.53.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:53:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A9ZnMs44; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfG-00065o-4R; Fri, 11 Nov 2022 02:41:26 -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 1otOfC-00064n-Bv for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:22 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOf9-0007XP-NF for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:21 -0500 Received: by mail-pl1-x632.google.com with SMTP id g24so3636911plq.3 for ; Thu, 10 Nov 2022 23:41:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+XZZb+kD5PLDfiZzYREY/FqgovJZfyA/XfR3p9NEW64=; b=A9ZnMs44FGkMOtcTBHZ3GDg2bcOLHFu5ytM7tZDt++Q+yx7Fh1ur6sZaWNhFTlAX16 dHqHCqeAN/9Sjz4/RGfukaGc7hHzv3yBWYKgoCDWHVDKK+cVOk0iEmHJV2lKANIuZjIM V9n+RKkTSgFrUwouxVXLJoeqG+5sqFL8Jz1gXRbuFe+vCjnmPR1GLmf5jyRVPk8rRj2m M5t0yLZ79D5itRDRJUt9Y6h5a7XlyGVCirr0cYc6BHNqrqzNT0XQekoTcbfrq5rx90gX djDbDMyvZ1iGNcZFQCSowz8T7Kfqxo3aOTGq8w1QtiYWtrUSk9mYtvxy+Cb/Y8bl/Ich Vflg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+XZZb+kD5PLDfiZzYREY/FqgovJZfyA/XfR3p9NEW64=; b=5bM5YUWkWZg2BFMf/7j4syUlQIjPGFYPuU7fYF80Sov0Lk3ITOgregQhrxTU6ptPS/ YfVpcKFPLAL1zgMzOeNHJNiNjMcmq5XExJ3vt4TUdPILgEy3Putel5PcqevNEtY6DtzP k9XwK2O8nfgLng1812wJEvYgKd+bZySGj6rovMOS3DXBCpcJvl5Osn6m+MBym3NMEyAl aU0YOiAImDYtEWFfDZgNwzWPEAUBPTwLlub70NseA15KaeNMOJRr4sXQ2JxpqB6CWQes 9FFTB51O2yoZp/5BM+wUDWV6xW1/gZTSkgXChGgG/Wi5q+kgD76gWaEVnXBrkBgXRbXO 8RVA== X-Gm-Message-State: ANoB5pk1nl+JZlkzZ81FHtSsFaLZf78rtjqxjY8c9mDrHRWay4v7saZP hF89zzElVB5P6QmFkBUWrAWOJq+wbUhzh8Rn X-Received: by 2002:a17:90a:5a86:b0:214:291f:87b5 with SMTP id n6-20020a17090a5a8600b00214291f87b5mr624280pji.115.1668152477398; Thu, 10 Nov 2022 23:41:17 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:16 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 04/45] tcg/s390x: Use register pair allocation for div and mulu2 Date: Fri, 11 Nov 2022 17:40:20 +1000 Message-Id: <20221111074101.2069454-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Previously we hard-coded R2 and R3. Signed-off-by: Richard Henderson --- tcg/s390x/tcg-target-con-set.h | 4 ++-- tcg/s390x/tcg-target-con-str.h | 8 +------ tcg/s390x/tcg-target.c.inc | 43 +++++++++++++++++++++++++--------- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/tcg/s390x/tcg-target-con-set.h b/tcg/s390x/tcg-target-con-set.h index 426dd92e51..00ba727b70 100644 --- a/tcg/s390x/tcg-target-con-set.h +++ b/tcg/s390x/tcg-target-con-set.h @@ -29,8 +29,8 @@ C_O1_I2(v, v, v) C_O1_I3(v, v, v, v) C_O1_I4(r, r, ri, r, 0) C_O1_I4(r, r, ri, rI, 0) -C_O2_I2(b, a, 0, r) -C_O2_I3(b, a, 0, 1, r) +C_O2_I2(o, m, 0, r) +C_O2_I3(o, m, 0, 1, r) C_O2_I4(r, r, 0, 1, rA, r) C_O2_I4(r, r, 0, 1, ri, r) C_O2_I4(r, r, 0, 1, r, r) diff --git a/tcg/s390x/tcg-target-con-str.h b/tcg/s390x/tcg-target-con-str.h index 8bb0358ae5..76446aecae 100644 --- a/tcg/s390x/tcg-target-con-str.h +++ b/tcg/s390x/tcg-target-con-str.h @@ -11,13 +11,7 @@ REGS('r', ALL_GENERAL_REGS) REGS('L', ALL_GENERAL_REGS & ~SOFTMMU_RESERVE_REGS) REGS('v', ALL_VECTOR_REGS) -/* - * A (single) even/odd pair for division. - * TODO: Add something to the register allocator to allow - * this kind of regno+1 pairing to be done more generally. - */ -REGS('a', 1u << TCG_REG_R2) -REGS('b', 1u << TCG_REG_R3) +REGS('o', 0xaaaa) /* odd numbered general regs */ /* * Define constraint letters for constants: diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index 33becd7694..47aaba7667 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -2258,10 +2258,18 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_div2_i32: - tcg_out_insn(s, RR, DR, TCG_REG_R2, args[4]); + tcg_debug_assert(args[0] == args[2]); + tcg_debug_assert(args[1] == args[3]); + tcg_debug_assert((args[1] & 1) == 0); + tcg_debug_assert(args[0] == args[1] + 1); + tcg_out_insn(s, RR, DR, args[1], args[4]); break; case INDEX_op_divu2_i32: - tcg_out_insn(s, RRE, DLR, TCG_REG_R2, args[4]); + tcg_debug_assert(args[0] == args[2]); + tcg_debug_assert(args[1] == args[3]); + tcg_debug_assert((args[1] & 1) == 0); + tcg_debug_assert(args[0] == args[1] + 1); + tcg_out_insn(s, RRE, DLR, args[1], args[4]); break; case INDEX_op_shl_i32: @@ -2515,17 +2523,30 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_div2_i64: - /* ??? We get an unnecessary sign-extension of the dividend - into R3 with this definition, but as we do in fact always - produce both quotient and remainder using INDEX_op_div_i64 - instead requires jumping through even more hoops. */ - tcg_out_insn(s, RRE, DSGR, TCG_REG_R2, args[4]); + /* + * ??? We get an unnecessary sign-extension of the dividend + * into op0 with this definition, but as we do in fact always + * produce both quotient and remainder using INDEX_op_div_i64 + * instead requires jumping through even more hoops. + */ + tcg_debug_assert(args[0] == args[2]); + tcg_debug_assert(args[1] == args[3]); + tcg_debug_assert((args[1] & 1) == 0); + tcg_debug_assert(args[0] == args[1] + 1); + tcg_out_insn(s, RRE, DSGR, args[1], args[4]); break; case INDEX_op_divu2_i64: - tcg_out_insn(s, RRE, DLGR, TCG_REG_R2, args[4]); + tcg_debug_assert(args[0] == args[2]); + tcg_debug_assert(args[1] == args[3]); + tcg_debug_assert((args[1] & 1) == 0); + tcg_debug_assert(args[0] == args[1] + 1); + tcg_out_insn(s, RRE, DLGR, args[1], args[4]); break; case INDEX_op_mulu2_i64: - tcg_out_insn(s, RRE, MLGR, TCG_REG_R2, args[3]); + tcg_debug_assert(args[0] == args[2]); + tcg_debug_assert((args[1] & 1) == 0); + tcg_debug_assert(args[0] == args[1] + 1); + tcg_out_insn(s, RRE, MLGR, args[1], args[3]); break; case INDEX_op_shl_i64: @@ -3220,10 +3241,10 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_div2_i64: case INDEX_op_divu2_i32: case INDEX_op_divu2_i64: - return C_O2_I3(b, a, 0, 1, r); + return C_O2_I3(o, m, 0, 1, r); case INDEX_op_mulu2_i64: - return C_O2_I2(b, a, 0, r); + return C_O2_I2(o, m, 0, r); case INDEX_op_add2_i32: case INDEX_op_sub2_i32: From patchwork Fri Nov 11 07:40:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623703 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp627794pvb; Fri, 11 Nov 2022 00:11:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf6g1jL8FE3PZ2gQdXe3iqZSS9riFF1SwyN3fB0yFYJUOiPTkNchzx2XX5OuL6d8sIjEBXex X-Received: by 2002:a05:6214:3c98:b0:4bb:77c6:250e with SMTP id ok24-20020a0562143c9800b004bb77c6250emr1048729qvb.53.1668154318925; Fri, 11 Nov 2022 00:11:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668154318; cv=none; d=google.com; s=arc-20160816; b=dxMyD1bmR65teg6/p39ki+eSdbOmsGdmPOLQpBq0tXJbp0oCOmXfzyLhPrUKjUnmPv iPiJ6cVHG4yC9gvo4kQgRDyA4+kOThNNisyiM4UypsU0lJ1zGh+eyT1GI9hrrPyW/zQp EN3HxLqcT3XuuekWzk9/UBOoid3gimgBr06CIbHqRC88Zvid3IEkYag6/eSGxR/r8uS7 i2E6lyN2gA5qJIWY4UaLnNRN4yKUeMwVnlJlKuu0Cb/gTsd5NWEBHufsnSzSAK8gjqgU 86AOhinsR/vBc3Fc7CDRMaDDQYWAbCP1q2EVMe2xQzv8aYYnOpAKSJCzSq0HPG4npQd9 yFpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=pcFc6BCiy8AgtsELn4bI9AGbxpo/4pmRIjtL3WupDdQ=; b=vMCX8hWBSk20Bg6SbX4twNOoOJU/FYP2Cr9AZ5l8V5N4diRFVDIWpyo/uRwqeSgCWs hUWKKUfi0VGLeCVrrdSvJzCRYdoJcOGs6RFjIHScR96JI9UTeRzSfT92I89I5V8rBWAu tqdidj9ylf4e7d1AmuYywmZk7ttygeM2l8X+yjZwOUjMf+zHBOspMhq8BO+SCKGKsVY9 8FbA7QMaV+f3szJePWf21C0h/90zlvtaTgeu8wmm79P/dAPbcgylkfagKSK0K8abY149 mK/9KOjF/7gT0ick2R7FZP5uCjTA6z/As9QJ4armFNkbJmtj2AKorjzP715Cci+WfC+n pb8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=go6U+Gsw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fw9-20020a05622a4a8900b0035e9f74bc22si732728qtb.229.2022.11.11.00.11.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:11:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=go6U+Gsw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfN-00066j-LJ; Fri, 11 Nov 2022 02:41:33 -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 1otOfE-00065Y-1F for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:24 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfB-0007Xu-Ui for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:23 -0500 Received: by mail-pj1-x102c.google.com with SMTP id r61-20020a17090a43c300b00212f4e9cccdso7064776pjg.5 for ; Thu, 10 Nov 2022 23:41:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=pcFc6BCiy8AgtsELn4bI9AGbxpo/4pmRIjtL3WupDdQ=; b=go6U+Gswa9viHTMLfQh5JdMuhK/mjOcYhcNcKcIufcThq4kupDvt0rKCTFdnDr9WQs yCDwh82tUBA+vkBCI1cr5KCb8s78d8YVSPcU9vJIUylKA45s/y0pRcz+k3cAdspwBwhw bSqcTp3qdaeAd3tzZYUYm3Y6FrnSlNUbreB4K66NG389If5Bo/sLJbRkJcR5scydFv9N qWlMHwNQ06aG2SCicEwtxx0a0ru/BmAMe/wCd/D1jhRefyC5nr3fpbar07bD3E+4s5A5 ljkWsAq1YQvj29ykI63Msn6bxn1Z51Ag2p4DFh2Vr8+7hKzShmvbGVXfhKl0YtlEQyWh oeVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pcFc6BCiy8AgtsELn4bI9AGbxpo/4pmRIjtL3WupDdQ=; b=1ectagL+2HTmIw9bcH8zTGZ7u1MhPpY9kzkDz9z3z7xt012+Q0+IW76CG+UFUWQ0X3 Err0Uw1rGqPjH6VlcPlOYj1HPHl+W+frmE23QJ098iPo3X7Dc80kbbGG/7eVvQHhGwxp Kd4S2BrDYzksoY6Lb+8aNgck31ekG6CTr3NCk1GokWnot9yZI7Z8L+Z9zg2YO/J2UvzG 2XPYPKdafAB8vJpkDDaEl08ggXL0hSfqMy+FgUoCQzYeGMUQaDevGMbbUzlYDE0EGsPd SByybwAmJ8++WI6nmkMNUlGmB+iYdnl71JPVkeV7V4PPuJopT8qpyqgcPgHIwkdvrX4c 4IzA== X-Gm-Message-State: ANoB5pmUugy0cGLkiEd1D+WCKhMav0CiuCUlyiOQangVGLcUJ0hB/UGS LIVC+ErnxXqRGTUBbZkDKmnqXDVSw3z2Oeb3 X-Received: by 2002:a17:902:e395:b0:17f:809b:7f85 with SMTP id g21-20020a170902e39500b0017f809b7f85mr1468880ple.21.1668152479447; Thu, 10 Nov 2022 23:41:19 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 05/45] tcg/arm: Use register pair allocation for qemu_{ld, st}_i64 Date: Fri, 11 Nov 2022 17:40:21 +1000 Message-Id: <20221111074101.2069454-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Although we still can't use ldrd and strd for all operations, increase the chances by getting the register allocation correct. Signed-off-by: Richard Henderson --- tcg/arm/tcg-target-con-set.h | 7 ++++--- tcg/arm/tcg-target-con-str.h | 2 ++ tcg/arm/tcg-target.c.inc | 28 ++++++++++++++++++---------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/tcg/arm/tcg-target-con-set.h b/tcg/arm/tcg-target-con-set.h index 3685e1786a..b8849b2478 100644 --- a/tcg/arm/tcg-target-con-set.h +++ b/tcg/arm/tcg-target-con-set.h @@ -15,8 +15,9 @@ C_O0_I2(r, rIN) C_O0_I2(s, s) C_O0_I2(w, r) C_O0_I3(s, s, s) +C_O0_I3(S, p, s) C_O0_I4(r, r, rI, rI) -C_O0_I4(s, s, s, s) +C_O0_I4(S, p, s, s) C_O1_I1(r, l) C_O1_I1(r, r) C_O1_I1(w, r) @@ -38,8 +39,8 @@ C_O1_I2(w, w, wZ) C_O1_I3(w, w, w, w) C_O1_I4(r, r, r, rI, rI) C_O1_I4(r, r, rIN, rIK, 0) -C_O2_I1(r, r, l) -C_O2_I2(r, r, l, l) +C_O2_I1(e, p, l) +C_O2_I2(e, p, l, l) C_O2_I2(r, r, r, r) C_O2_I4(r, r, r, r, rIN, rIK) C_O2_I4(r, r, rI, rI, rIN, rIK) diff --git a/tcg/arm/tcg-target-con-str.h b/tcg/arm/tcg-target-con-str.h index 8f501149e1..24b4b59feb 100644 --- a/tcg/arm/tcg-target-con-str.h +++ b/tcg/arm/tcg-target-con-str.h @@ -8,9 +8,11 @@ * Define constraint letters for register sets: * REGS(letter, register_mask) */ +REGS('e', ALL_GENERAL_REGS & 0x5555) /* even regs */ REGS('r', ALL_GENERAL_REGS) REGS('l', ALL_QLOAD_REGS) REGS('s', ALL_QSTORE_REGS) +REGS('S', ALL_QSTORE_REGS & 0x5555) /* even qstore */ REGS('w', ALL_VECTOR_REGS) /* diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 2c6c353eea..aa3a888fed 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1686,9 +1686,11 @@ static void tcg_out_qemu_ld_index(TCGContext *s, MemOp opc, tcg_out_ld32_r(s, COND_AL, datalo, addrlo, addend); break; case MO_UQ: + /* We used pair allocation for datalo, so already should be aligned. */ + tcg_debug_assert((datalo & 1) == 0); + tcg_debug_assert(datahi == datalo + 1); /* LDRD requires alignment; double-check that. */ - if (get_alignment_bits(opc) >= MO_64 - && (datalo & 1) == 0 && datahi == datalo + 1) { + if (get_alignment_bits(opc) >= MO_64) { /* * Rm (the second address op) must not overlap Rt or Rt + 1. * Since datalo is aligned, we can simplify the test via alignment. @@ -1742,9 +1744,11 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc, TCGReg datalo, tcg_out_ld32_12(s, COND_AL, datalo, addrlo, 0); break; case MO_UQ: + /* We used pair allocation for datalo, so already should be aligned. */ + tcg_debug_assert((datalo & 1) == 0); + tcg_debug_assert(datahi == datalo + 1); /* LDRD requires alignment; double-check that. */ - if (get_alignment_bits(opc) >= MO_64 - && (datalo & 1) == 0 && datahi == datalo + 1) { + if (get_alignment_bits(opc) >= MO_64) { tcg_out_ldrd_8(s, COND_AL, datalo, addrlo, 0); } else if (datalo == addrlo) { tcg_out_ld32_12(s, COND_AL, datahi, addrlo, 4); @@ -1826,9 +1830,11 @@ static void tcg_out_qemu_st_index(TCGContext *s, ARMCond cond, MemOp opc, tcg_out_st32_r(s, cond, datalo, addrlo, addend); break; case MO_64: + /* We used pair allocation for datalo, so already should be aligned. */ + tcg_debug_assert((datalo & 1) == 0); + tcg_debug_assert(datahi == datalo + 1); /* STRD requires alignment; double-check that. */ - if (get_alignment_bits(opc) >= MO_64 - && (datalo & 1) == 0 && datahi == datalo + 1) { + if (get_alignment_bits(opc) >= MO_64) { tcg_out_strd_r(s, cond, datalo, addrlo, addend); } else if (scratch_addend) { tcg_out_st32_rwb(s, cond, datalo, addend, addrlo); @@ -1863,9 +1869,11 @@ static void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc, TCGReg datalo, tcg_out_st32_12(s, COND_AL, datalo, addrlo, 0); break; case MO_64: + /* We used pair allocation for datalo, so already should be aligned. */ + tcg_debug_assert((datalo & 1) == 0); + tcg_debug_assert(datahi == datalo + 1); /* STRD requires alignment; double-check that. */ - if (get_alignment_bits(opc) >= MO_64 - && (datalo & 1) == 0 && datahi == datalo + 1) { + if (get_alignment_bits(opc) >= MO_64) { tcg_out_strd_8(s, COND_AL, datalo, addrlo, 0); } else { tcg_out_st32_12(s, COND_AL, datalo, addrlo, 0); @@ -2333,11 +2341,11 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_qemu_ld_i32: return TARGET_LONG_BITS == 32 ? C_O1_I1(r, l) : C_O1_I2(r, l, l); case INDEX_op_qemu_ld_i64: - return TARGET_LONG_BITS == 32 ? C_O2_I1(r, r, l) : C_O2_I2(r, r, l, l); + return TARGET_LONG_BITS == 32 ? C_O2_I1(e, p, l) : C_O2_I2(e, p, l, l); case INDEX_op_qemu_st_i32: return TARGET_LONG_BITS == 32 ? C_O0_I2(s, s) : C_O0_I3(s, s, s); case INDEX_op_qemu_st_i64: - return TARGET_LONG_BITS == 32 ? C_O0_I3(s, s, s) : C_O0_I4(s, s, s, s); + return TARGET_LONG_BITS == 32 ? C_O0_I3(S, p, s) : C_O0_I4(S, p, s, s); case INDEX_op_st_vec: return C_O0_I2(w, r); From patchwork Fri Nov 11 07:40:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623673 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp615733pvb; Thu, 10 Nov 2022 23:42:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf48tZKX9/f8mN6mKOQB8BZztyPGyh11QOr7pKu/1Su0jqjrbaUJ7XUgu42loihGEm2H4w8m X-Received: by 2002:a37:8084:0:b0:6fa:e240:fed2 with SMTP id b126-20020a378084000000b006fae240fed2mr177984qkd.460.1668152522459; Thu, 10 Nov 2022 23:42:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152522; cv=none; d=google.com; s=arc-20160816; b=O+YdBMwtYli9BfNYrN8KjsebqGB6XUngwrq9LaXUYCWbQaHox2LFAc5V3rfO2ctHtG okFEccAjQW5UVKhcdqJOprNoLo5nsCTTgi/2t6ZMXbRaS9rdhpn6wGJZq+OhwpuiHUZA uP9ocXw3imLVqAmaI2l49W5H9Ldc/3CEWmrnRjdzik09xbezRUaVL7DgPCbkSM50oySy XOqvl0N5mS4CZ6zkkcFWvbeM4VXvghFsWBnw8l72xCRnnERD0ySwgxSD/dR8+HBt9Tkf RnY4JwRGFplbAivi9QeDitgVJJZwunopAOC3Gh0dGlr994qmLfUen3ejJe4uupy5Ij7K ewhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hjVkb/BegzFHY39crLwouqTtFpyTgi6eJ2SZK52jGxk=; b=Pc2wIXfGwq62Ug7ApMjRZgsR+zHEAf72i0wUKkma4U3HzBHJ0+kMyukIDkqHAg5s93 5w4rPlLWU1Cx4CrNuBcWPlwFC2V1ACoiJmQ/99/JVdGH9RxMdDFBHD30IohvJ9G9ZmwY Dw4petGHGXe2D6ccbHHqsgXQUU47gO3sQhYnZ1CptMlZqbxBf8HL1beCtrVzcrE7Cr+3 kt7Tl5yT3SsCxn1rDv/vA5jVTimQHZQrItD0FxgMKaoN0RD7tvQRv6jY68StXlqzydid OFvYHiMOR8xFtF9s2aBXSXPSBmvWA3pXfSfa8SBCK7AZ9ZLpOnxpECCr/lRpr3THEN3v dOoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o9jMkB7M; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 17-20020ac85711000000b00342f6156737si774102qtw.203.2022.11.10.23.42.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:42:02 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o9jMkB7M; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfS-00068O-8f; Fri, 11 Nov 2022 02:41:38 -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 1otOfH-000664-8X for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:31 -0500 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfD-0007Yy-Dv for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:24 -0500 Received: by mail-pg1-x530.google.com with SMTP id f63so3810782pgc.2 for ; Thu, 10 Nov 2022 23:41:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=hjVkb/BegzFHY39crLwouqTtFpyTgi6eJ2SZK52jGxk=; b=o9jMkB7M4yVweOS4/vjj+L+JS2xO3E1b2l8f3FdiFapm9Aq2u/dGvehN8vySjXcVnX JHFLCsM1FhA/aXfKFkfkGgoWCFnqQsysL6EaEz1L/d7UfmtDWZEso0hRVWuEyzs+R4Tu THXOpUZRsLlTP3MSxKa4rt+lAIxVcBdybki9rqsc9nrVRaHknnVOB2LnV9Vkg0V3vwfb z1vAtxMmcvioTtj88HUUPYnfg5+ktAnCT538V0pmB19v3PlGTLZ4cQB20W2RNnQF8rd+ iWVeM+RBRZxVU7U+9zh53TaWeHJAbIQto9OsbCgnnaS0SHYtdBav1cQmDx+JDG7RJv+I 2Taw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=hjVkb/BegzFHY39crLwouqTtFpyTgi6eJ2SZK52jGxk=; b=QuYlg711y3F/dY95MFoemhaKUvUvupvdSqFZSfTBTjmIIwfd0wbCJdmQvUek5cpMcD MlpaH4xr1SbjhWvy6L1uou813b9aOuPbwh3ZlFcf/g/xuJIlqj/l/veuUwQIyu1rn4lh SJ2Zox9Os/88BAYinFFBgEGRNI/oo1XhNKJqx/+QapcyTs/Wu0a7lAePzOgmeVSUhcod JjXonz8VHibxOIL75zSYKv52ZSUbxZKdM0Z3G1Rm87AdLDHInbYg83KIMihZoWno5Ubi CPpjMDYba2NWWA9NcbAecO/3AXfm0a7Nwc/hvUY+hErc6EJP7nRtUNUdMf4kqZYG/t3g 4Kpg== X-Gm-Message-State: ANoB5pni/D9ukN646G6HTer7evTDhO9g3gCuP55N0SDh2aEd4E7cljcK mdxpbC1gs5JOjBXttW3ABwP2Q+bWrg+DE9Ur X-Received: by 2002:a05:6a00:3486:b0:56c:8c13:234c with SMTP id cp6-20020a056a00348600b0056c8c13234cmr1515329pfb.12.1668152481919; Thu, 10 Nov 2022 23:41:21 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH for-8.0 v3 06/45] tcg: Remove TCG_TARGET_STACK_GROWSUP Date: Fri, 11 Nov 2022 17:40:22 +1000 Message-Id: <20221111074101.2069454-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The hppa host code has been removed since 2013; this should have been deleted at the same time. Fixes: 802b5081233a ("tcg-hppa: Remove tcg backend") Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.h | 1 - tcg/arm/tcg-target.h | 1 - tcg/tcg.c | 32 ++------------------------------ 3 files changed, 2 insertions(+), 32 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 485f685bd2..e145d50fef 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -16,7 +16,6 @@ #define TCG_TARGET_INSN_UNIT_SIZE 4 #define TCG_TARGET_TLB_DISPLACEMENT_BITS 24 #define MAX_CODE_GEN_BUFFER_SIZE (2 * GiB) -#undef TCG_TARGET_STACK_GROWSUP typedef enum { TCG_REG_X0, TCG_REG_X1, TCG_REG_X2, TCG_REG_X3, diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 7e96495392..56c1ac4586 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -30,7 +30,6 @@ extern int arm_arch; #define use_armv7_instructions (__ARM_ARCH >= 7 || arm_arch >= 7) -#undef TCG_TARGET_STACK_GROWSUP #define TCG_TARGET_INSN_UNIT_SIZE 4 #define TCG_TARGET_TLB_DISPLACEMENT_BITS 16 #define MAX_CODE_GEN_BUFFER_SIZE UINT32_MAX diff --git a/tcg/tcg.c b/tcg/tcg.c index f5383bb2b0..ae7516627c 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1551,25 +1551,8 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) } if (TCG_TARGET_REG_BITS < 64 && is_64bit) { - /* - * If stack grows up, then we will be placing successive - * arguments at lower addresses, which means we need to - * reverse the order compared to how we would normally - * treat either big or little-endian. For those arguments - * that will wind up in registers, this still works for - * HPPA (the only current STACK_GROWSUP target) since the - * argument registers are *also* allocated in decreasing - * order. If another such target is added, this logic may - * have to get more complicated to differentiate between - * stack arguments and register arguments. - */ -#if HOST_BIG_ENDIAN != defined(TCG_TARGET_STACK_GROWSUP) - op->args[pi++] = temp_arg(args[i] + 1); - op->args[pi++] = temp_arg(args[i]); -#else - op->args[pi++] = temp_arg(args[i]); - op->args[pi++] = temp_arg(args[i] + 1); -#endif + op->args[pi++] = temp_arg(args[i] + HOST_BIG_ENDIAN); + op->args[pi++] = temp_arg(args[i] + !HOST_BIG_ENDIAN); real_args += 2; continue; } @@ -4166,12 +4149,6 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const TCGOp *op) return true; } -#ifdef TCG_TARGET_STACK_GROWSUP -#define STACK_DIR(x) (-(x)) -#else -#define STACK_DIR(x) (x) -#endif - static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) { const int nb_oargs = TCGOP_CALLO(op); @@ -4211,18 +4188,13 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) stack_offset = TCG_TARGET_CALL_STACK_OFFSET; for (i = nb_regs; i < nb_iargs; i++) { arg = op->args[nb_oargs + i]; -#ifdef TCG_TARGET_STACK_GROWSUP - stack_offset -= sizeof(tcg_target_long); -#endif if (arg != TCG_CALL_DUMMY_ARG) { ts = arg_temp(arg); temp_load(s, ts, tcg_target_available_regs[ts->type], s->reserved_regs, 0); tcg_out_st(s, ts->type, ts->reg, TCG_REG_CALL_STACK, stack_offset); } -#ifndef TCG_TARGET_STACK_GROWSUP stack_offset += sizeof(tcg_target_long); -#endif } /* assign input registers */ From patchwork Fri Nov 11 07:40:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623675 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp615890pvb; Thu, 10 Nov 2022 23:42:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf5mmdrz/FxoQg4e3+f9nK+UsjBP7TLFYTAErNczypvs4xm/JIAm2q2ktpwZtcFEkIJDkVz9 X-Received: by 2002:ac8:5ed7:0:b0:3a5:3818:5009 with SMTP id s23-20020ac85ed7000000b003a538185009mr320266qtx.363.1668152552806; Thu, 10 Nov 2022 23:42:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152552; cv=none; d=google.com; s=arc-20160816; b=CTpFj2CGKeTNYvv4ZnYc2O+oBUmU7YncSPJvME2uvYr7NJh4KLdUWzNhWYW5Ozfhrh Jrs47MZMgjJ/2LMztWJyX1hbMtsT59RyrxOf82XaSRI32b9Mt9OCzjBUa4unYChjEX88 AZniGif56l75uEKXYh5yQdedRlHjuE2dyXEgyTT745znS8MIGvpyfti1tESeA0AMhsTG o/UEd+cKQkEiDK5kXL9KZ+Es/YqOHJ9YyMTgz2aoEEetkMTu9x8jg1Yot9htymEHpOWn BS52dRmUN2ompnu85Y+0AdOzyt/CVCfhP1T8+Y2Lg39rZn2xL+GWLEtq6cWOE9dZFojE qTNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=1fcBWbZUmm5Jnpz4Izudl/A6K0HNswQpl9r23JhxDb4=; b=I1xpijn+ER27fAm4DF4oIxub6aYmqbkB3pKchB5JUhiKhWwKZKjxglq58sOnYCamt+ YX2iNiO4oHpE+BKKwWRjE+Y2n9V9NUsMSTuOJJU0pNE1C1lkGt3mRtKkOd4nHirLr4sX UYRw9us5vVyYZl2ukdIukyHOm4pMN4LtonUMyUTt4uv2cGUMwKB7cVqYphDl4Xu8Mdnv GTccjlxOR2A8jIEqdPD2EYDZx3jvJsaQhDfbQtXeni5ZwpbG4FaA/D27wJWMuzdFGNcf oXYelm7CpnVFKBNJ+Y9u8WPRFcQBrIkzjQ+rFCC1RzY8ViP1M2DVWtjbEyIu/6BzHgns fKZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kXndUWUg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v14-20020ac8578e000000b003a53d11a75csi727560qta.519.2022.11.10.23.42.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:42:32 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kXndUWUg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfa-00069G-5p; Fri, 11 Nov 2022 02:41:48 -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 1otOfS-00068P-Dw for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:38 -0500 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfG-0007UR-0G for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:38 -0500 Received: by mail-pf1-x42a.google.com with SMTP id b29so4205970pfp.13 for ; Thu, 10 Nov 2022 23:41:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=1fcBWbZUmm5Jnpz4Izudl/A6K0HNswQpl9r23JhxDb4=; b=kXndUWUgqAVlTHwlL/ikUyabC/IIR7Gnr869HIupBA2HF+thhZ2+lVbv4bb0DIFX7K kKy/2RJB3mQZbeU65aC+dxgY9EcrmJm/KoiNUJX5hRKIabAcRTgPFOVRY9C90zijoVRq 3PWpuFhQYgZl1Lkcogoej3/lQ+OMEFp666WY6NB2h3LPjYjV13h5M1fBvDKbHiI13qLd +wSkA3WnnynVpock6ltg8XV1MaKkYNzd2UecAj0Cv3TiYXT9j0cyY13+lNeTKhvfxc5Z F3vOiHkBcZ2GVtWBjz7FnOOaoUJ+VM+YMWXc7e/7MEnVR/7tbN26J+54MiNkKyObmwl8 BX8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1fcBWbZUmm5Jnpz4Izudl/A6K0HNswQpl9r23JhxDb4=; b=bey5m4xrzGCj50ZWVrP7ZvfPuMwGJ0FDo7eYz/4kZkPD6pw2VH14Dk4QuFWCP1vGjg hFeGWDLhj5a1TeoJcST0HVd9WuFCdKUo28m84xb/CEvzU8VMo2dfLimTemVP85NnC5Lm ez+ScEDumIoLuq1yGQuJU7kVRCfeKrx4NBp14ahv2VH/tYXW/0D1ybytzl+qeRoPO10u U0Cb0gOxljzn6ZCL5RBsWUkmGL+Iplx0E1n8avWbRPi4uXFaEmeAME++eKhkDgnncYBQ 2nfILsGruGCNIdQJAe4nmFT+79k+v115z02vyqLfKsM//KYI8QtACE2oARYNuOGA/udW 1h1Q== X-Gm-Message-State: ANoB5pl29RpvqBPhtZ2TFLKLgiYPXciYBvXxNiabPIudnKCsv3IHtnjD zT5NoUJI1LYghgaWbyJjB/c21Ke4P1fidKaE X-Received: by 2002:a63:d802:0:b0:43c:ac7c:ee27 with SMTP id b2-20020a63d802000000b0043cac7cee27mr572236pgh.583.1668152483981; Thu, 10 Nov 2022 23:41:23 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 07/45] accel/tcg: Set cflags_next_tb in cpu_common_initfn Date: Fri, 11 Nov 2022 17:40:23 +1000 Message-Id: <20221111074101.2069454-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org While we initialize this value in cpu_common_reset, that isn't called during startup, so set it as well in init. This fixes -singlestep versus the very first TB. Fixes: 04f5b647ed07 ("accel/tcg: Handle -singlestep in curr_cflags") Signed-off-by: Richard Henderson --- hw/core/cpu-common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index f9fdd46b9d..6a4022eb14 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -235,6 +235,7 @@ static void cpu_common_initfn(Object *obj) /* the default value is changed by qemu_init_vcpu() for softmmu */ cpu->nr_cores = 1; cpu->nr_threads = 1; + cpu->cflags_next_tb = -1; qemu_mutex_init(&cpu->work_mutex); QSIMPLEQ_INIT(&cpu->work_list); From patchwork Fri Nov 11 07:40:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623693 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp620191pvb; Thu, 10 Nov 2022 23:55:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf4V945DvPrelcOE4jSzGhb+bdmrg36ZEhIQ2NJylR9IafC3PpyT4zFedxMgDX7zrb8iBerQ X-Received: by 2002:ac8:41d3:0:b0:3a5:1f29:f1d with SMTP id o19-20020ac841d3000000b003a51f290f1dmr365191qtm.239.1668153307021; Thu, 10 Nov 2022 23:55:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668153307; cv=none; d=google.com; s=arc-20160816; b=rpfCP5EGxOM3CwfpJsk82f5Eq7RLWEm75DwxIzY+kfjV+FSnTSG8Kflaa6qgNJOhks GEqEnyd/MXDYzzZSm54xieMMX6wNYzsDEcv+ZZaFIobOAi/AYE/J7AqMfJVMZfN0hfuA Zc2aXa+dItiGqQoKZ1PrvqkEJJLyftAt9jGvrYjJIWi9dFmJZEhY12o21uYmr111/BT7 cMwntomelLsKySXpWzZAfJT7bKaCrlOuOFy1pt0W2e75/GEL9qMJSAsljDewT+q9+AnQ 3uczoFgfClm4cxF5gk1pA//2ILHxqIGowCHO69OGXECZtd/QzbnE3vmg5QS0vag4hF8l J/Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RqkUbgBv122Thnf546PHquT7r6o6Y94wYiKV+lBMbFo=; b=z1w9W9SIke58JW59Fi2Lh1c9wfw2eynSkDPo1FwnrTNKgUNa/A81z+NZ59euL6WCYP IvvJvxr/msbs15lwDlTq1uPmE3EoPbjvMjTrytRwFt8j1t8Ipb1Tr8Nht4n/VJ1Ia6Lx lyiPD2ZE75DIINTYLPkrxYQil2J2weQ5JtNB7sk4J/2BtymGOC0lLF8NKYPF3c8ZGznF iIw/IrAcJDfCsjW9mhJXSpYce1NGRBXGr+T5tcix2TgJHXu9RyFbedgnsxEa49GMOp3b aoBj5obPRHd2JLrFFW2fYssyoRQkoVYYtTcDwmj5YLfcYvBQufj38Rnm8oOFBqXEZMTY IdEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PpHNoMGg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u12-20020a05620a084c00b006fa8976b60csi668757qku.233.2022.11.10.23.55.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:55:07 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PpHNoMGg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfT-00068s-Gi; Fri, 11 Nov 2022 02:41:39 -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 1otOfP-00067M-23 for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:35 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfL-0007iI-Mh for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:34 -0500 Received: by mail-pg1-x536.google.com with SMTP id 130so3803552pgc.5 for ; Thu, 10 Nov 2022 23:41:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=RqkUbgBv122Thnf546PHquT7r6o6Y94wYiKV+lBMbFo=; b=PpHNoMGglIE6l35a26vO6QEFLrS9huY/qGMMGsQn11cHX2LrJFi7XUVXXKwLbFUWTK iNMhXn/uc4sUkCsyImnML4TJkRDiLZt266I+soJLvTsV4CULxglWdYcrEicaZm/3vOxD 0NJ8ucYKHREDry6Xshcke+xTPMOASW7G8W/wXBijgbeI8ZHjt8+AC73GahijqpIgxxRX zUvq+7JsFqWC8pRDOPWALgQn3sbo3vrHdaneP2YhcDgQiPg6RH3kjOqOI52xJblonXwr OyupodQuaapDOKr7Q9cruVcUQ7WpYFvLv9Yt3lysS0lP/4ib2tdys1g0JeHTOm7K7sm6 cmog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=RqkUbgBv122Thnf546PHquT7r6o6Y94wYiKV+lBMbFo=; b=rMvJfMzAivGX2Cm/ed1QNxv+yQFrnsIRLvXfZ+vscgdXsWuz2dt6zSreuahJEbTTq1 fFfejfXCuyen9XtNfLzHUdjQ8heTnfKV8Y84IBNTibhBBIKVq+T747pb75Y4SFJrIuOt icGLUa3VfX+y3orU8/+qJ18YZk7f0f4u4E2LiqusSCtPU7bjvhdhJOrDHYqIXm3wz8kQ f4Q66Y0ZD4WRqrYv7V7w043ba5aUCAeMmELgP83PYIfE/6W53fjG3Z5v3JcpWlVC5s6q ptJk6BkKBAmtaJ35oBXL40MmmPaueFt53Q6bwlUBdZ6aIuM24XBkh5LYwu7jFvj7NIJG m2vQ== X-Gm-Message-State: ANoB5pnS0m1mtWJyU+Is6BKtbIzK0UGj4Vik0k+aM6YdxYL+aPSuI4lO dPysuXzMob8IAH6KDDfWq2vkNwn9zqJRH1Zo X-Received: by 2002:a63:1b17:0:b0:457:dced:8ba9 with SMTP id b23-20020a631b17000000b00457dced8ba9mr653117pgb.221.1668152486597; Thu, 10 Nov 2022 23:41:26 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland Subject: [PATCH for-8.0 v3 08/45] target/sparc: Avoid TCGV_{LOW,HIGH} Date: Fri, 11 Nov 2022 17:40:24 +1000 Message-Id: <20221111074101.2069454-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use the official extend/extract functions instead of routines that will shortly be internal to tcg. Cc: Mark Cave-Ayland Signed-off-by: Richard Henderson --- target/sparc/translate.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 34858eb95f..150aeecd14 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -163,13 +163,6 @@ static inline void gen_update_fprs_dirty(DisasContext *dc, int rd) /* floating point registers moves */ static TCGv_i32 gen_load_fpr_F(DisasContext *dc, unsigned int src) { -#if TCG_TARGET_REG_BITS == 32 - if (src & 1) { - return TCGV_LOW(cpu_fpr[src / 2]); - } else { - return TCGV_HIGH(cpu_fpr[src / 2]); - } -#else TCGv_i32 ret = get_temp_i32(dc); if (src & 1) { tcg_gen_extrl_i64_i32(ret, cpu_fpr[src / 2]); @@ -177,22 +170,16 @@ static TCGv_i32 gen_load_fpr_F(DisasContext *dc, unsigned int src) tcg_gen_extrh_i64_i32(ret, cpu_fpr[src / 2]); } return ret; -#endif } static void gen_store_fpr_F(DisasContext *dc, unsigned int dst, TCGv_i32 v) { -#if TCG_TARGET_REG_BITS == 32 - if (dst & 1) { - tcg_gen_mov_i32(TCGV_LOW(cpu_fpr[dst / 2]), v); - } else { - tcg_gen_mov_i32(TCGV_HIGH(cpu_fpr[dst / 2]), v); - } -#else - TCGv_i64 t = (TCGv_i64)v; + TCGv_i64 t = tcg_temp_new_i64(); + + tcg_gen_extu_i32_i64(t, v); tcg_gen_deposit_i64(cpu_fpr[dst / 2], cpu_fpr[dst / 2], t, (dst & 1 ? 0 : 32), 32); -#endif + tcg_temp_free_i64(t); gen_update_fprs_dirty(dc, dst); } From patchwork Fri Nov 11 07:40:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623714 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp631544pvb; Fri, 11 Nov 2022 00:22:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf4zGJ4Kh4XCp4wKFsKnJUn+Q+7huDkGsh+e9AaRoVXb5Po9UgikgbtgnydgR4L5kVAsCoLV X-Received: by 2002:a05:620a:2588:b0:6fa:825b:690a with SMTP id x8-20020a05620a258800b006fa825b690amr248564qko.340.1668154941829; Fri, 11 Nov 2022 00:22:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668154941; cv=none; d=google.com; s=arc-20160816; b=mr57qUR2hXLmfq6ZosxBgLOfTxxJ9dQ3rvsqgFv+TZiCsMp63GjKyZtsXYK3vBHqFM Mf5EX4G3GrvvieCKT6Rs0mE1O3CrEvT6eSEGYc+iWPXEHhj+Y4xmv2gISHgWYhMhoYxc yudgFu8zqHPPJV7VX93sOJrDEORL54XiLT1HgVlK7wH4Xm/rG5dGnWj7Aa3W9E5nZ1/x Dfb3JpLwTQHyz9ppIK8QODmASgBgjFbvpMQbLZNEecJ4QCwqaRKUEAtAPgH9271n0Y5J EfypaQwNkpA4x8HqfeFUm9P/0CPBwr1/EEMGY5Rzq560tenSr3oCJSnNMOvTq0yl4Dvi Wpdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vcQlxYY7mFIcT5pvKb1eZPHlZnAn92mI9Ka1689AM7M=; b=xUX6YvFM9XTJqb8Fq2p4SXb13SK9pRGJas4LRzgE/YcyVqf/c0MXiPQttxvM5k+wkP i1ah90AhWp4SAj8tQtNFdzZ+dJQGg/+iUBmNRgqNPUDziyk5cSy1Gg992cqTr9EmL6p5 uAbDRtv3f+z+ba94RaJ/ZLdGbV/moikoM93Kpo+QtuNWIUBnASEEXuvlYFqULlYEeynX k7tW/ZgEWEeTD2LfDf8HwNwu4OlLfYfvHeHsvSXz5zter3Sqd9zRJBnAxjpNWf6z8G08 aTVKy5MRbXUIHG3cTACoa9rCXGN6liApBVY5ixeQOA2k9f7i/gBWFFJDWvKp0IDGCYDW cFyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MuaSrI6t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id do27-20020a05620a2b1b00b006f9faedd088si754313qkb.384.2022.11.11.00.22.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:22:21 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MuaSrI6t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfn-0006QM-3A; Fri, 11 Nov 2022 02:41:59 -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 1otOfR-00067q-J7 for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:37 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfN-0007jc-Jx for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:36 -0500 Received: by mail-pj1-x102c.google.com with SMTP id f5-20020a17090a4a8500b002131bb59d61so7087227pjh.1 for ; Thu, 10 Nov 2022 23:41:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=vcQlxYY7mFIcT5pvKb1eZPHlZnAn92mI9Ka1689AM7M=; b=MuaSrI6tDjQnBX0IQp79QDaJn0ZXAfFxl4COEGDwf1V/Z6z6wSDDMgBcKeYaKJvRNQ v8FadeQ8V+EPD6kQNlGwDHPHd9v50e5pslTZiLp0YUZEdAJbVMpI2kqX+t53J95eGII4 BXa1zP87d6eLSMStGRArPhCOpxYSspyhJOumv/VfdWjc4uZBIHrXa1gHzkhgXdC++izm fynCc+ON/QTIOc5vpKJ2Y002vB7F9PJz5Gd1X8atiRrw8A2CgWjCGakYklYR5b4y4uZT KDzeXjPtktw0dqyR1FfQSHSOUag7HvVD1LMxHRECUMatYzMzj78bb/UMw1uBhdwritC3 XiWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=vcQlxYY7mFIcT5pvKb1eZPHlZnAn92mI9Ka1689AM7M=; b=TtpZsGgNt9jBEdcWFKqVCn3UKlkZ6mgFW9G3gTV1qRQsnKccnauEu5rOXP6OII8kif pgJ1Jwmv53wCO1M+5Lt6BbwQmjyCyAwyz9K2k8RtvoeBdA/oc5aey+C27mUeyhmdwPPV Qdb2ZCUY5xTtoOblAy01JboaNd5gvGsTDitDXW3cklMeHC5esWajXFmgJfIuPpzOIPAl 0EMc6s5ariFwe+OrDqb88htTW4g4HNVrY8hiZwacOzzyRw2PNTjSr+iJcku2DhA/pZJ2 NmuZdJzque7fmBbI2rIw8/H/P0FtsSWK2FrqhFsVzZnxN/XNn2eQAh8hcPjUkcB+DbE7 QP1w== X-Gm-Message-State: ANoB5pmPdYKfJ5r6H/kSTFFgnLanB17/01QF7gJATzUntGqfrLoEs+Lf +XT0LOY/lFb5VoLjnxQPNvp/CXff8HgjzzMG X-Received: by 2002:a17:902:8210:b0:17c:b7ac:86f with SMTP id x16-20020a170902821000b0017cb7ac086fmr1058200pln.140.1668152489105; Thu, 10 Nov 2022 23:41:29 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH for-8.0 v3 09/45] tcg: Move TCG_{LOW,HIGH} to tcg-internal.h Date: Fri, 11 Nov 2022 17:40:25 +1000 Message-Id: <20221111074101.2069454-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Move the error-generating fallback from tcg-op.c, and replace "_link_error" with modern QEMU_ERROR markup. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/tcg/tcg-op.h | 33 +++++---------------------------- include/tcg/tcg.h | 12 ------------ tcg/tcg-internal.h | 14 ++++++++++++++ tcg/tcg-op-vec.c | 2 ++ tcg/tcg-op.c | 37 ++++++++++++++++++++++++++++--------- 5 files changed, 49 insertions(+), 49 deletions(-) diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h index 209e168305..8176f194cb 100644 --- a/include/tcg/tcg-op.h +++ b/include/tcg/tcg-op.h @@ -667,35 +667,12 @@ static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) tcg_gen_op3_i64(INDEX_op_mul_i64, ret, arg1, arg2); } #else /* TCG_TARGET_REG_BITS == 32 */ -static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2, - tcg_target_long offset) -{ - tcg_gen_st8_i32(TCGV_LOW(arg1), arg2, offset); -} +void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset); +void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset); +void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset); -static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2, - tcg_target_long offset) -{ - tcg_gen_st16_i32(TCGV_LOW(arg1), arg2, offset); -} - -static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2, - tcg_target_long offset) -{ - tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset); -} - -static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) -{ - tcg_gen_add2_i32(TCGV_LOW(ret), TCGV_HIGH(ret), TCGV_LOW(arg1), - TCGV_HIGH(arg1), TCGV_LOW(arg2), TCGV_HIGH(arg2)); -} - -static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) -{ - tcg_gen_sub2_i32(TCGV_LOW(ret), TCGV_HIGH(ret), TCGV_LOW(arg1), - TCGV_HIGH(arg1), TCGV_LOW(arg2), TCGV_HIGH(arg2)); -} +void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); +void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); void tcg_gen_discard_i64(TCGv_i64 arg); void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg); diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 5c2254ce9f..d207bc47be 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -737,18 +737,6 @@ static inline TCGv_vec temp_tcgv_vec(TCGTemp *t) return (TCGv_vec)temp_tcgv_i32(t); } -#if TCG_TARGET_REG_BITS == 32 -static inline TCGv_i32 TCGV_LOW(TCGv_i64 t) -{ - return temp_tcgv_i32(tcgv_i64_temp(t)); -} - -static inline TCGv_i32 TCGV_HIGH(TCGv_i64 t) -{ - return temp_tcgv_i32(tcgv_i64_temp(t) + 1); -} -#endif - static inline TCGArg tcg_get_insn_param(TCGOp *op, int arg) { return op->args[arg]; diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index cc82088d52..a9ea27f67a 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -59,4 +59,18 @@ static inline unsigned tcg_call_flags(TCGOp *op) return tcg_call_info(op)->flags; } +#if TCG_TARGET_REG_BITS == 32 +static inline TCGv_i32 TCGV_LOW(TCGv_i64 t) +{ + return temp_tcgv_i32(tcgv_i64_temp(t)); +} +static inline TCGv_i32 TCGV_HIGH(TCGv_i64 t) +{ + return temp_tcgv_i32(tcgv_i64_temp(t) + 1); +} +#else +extern TCGv_i32 TCGV_LOW(TCGv_i64) QEMU_ERROR("32-bit code path is reachable"); +extern TCGv_i32 TCGV_HIGH(TCGv_i64) QEMU_ERROR("32-bit code path is reachable"); +#endif + #endif /* TCG_INTERNAL_H */ diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c index 463dabf515..5bf100ea7d 100644 --- a/tcg/tcg-op-vec.c +++ b/tcg/tcg-op-vec.c @@ -21,6 +21,8 @@ #include "tcg/tcg.h" #include "tcg/tcg-op.h" #include "tcg/tcg-mo.h" +#include "tcg-internal.h" + /* Reduce the number of ifdefs below. This assumes that all uses of TCGV_HIGH and TCGV_LOW are properly protected by a conditional that diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 019fab00cc..6168327030 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -28,16 +28,8 @@ #include "tcg/tcg-op.h" #include "tcg/tcg-mo.h" #include "exec/plugin-gen.h" +#include "tcg-internal.h" -/* Reduce the number of ifdefs below. This assumes that all uses of - TCGV_HIGH and TCGV_LOW are properly protected by a conditional that - the compiler can eliminate. */ -#if TCG_TARGET_REG_BITS == 64 -extern TCGv_i32 TCGV_LOW_link_error(TCGv_i64); -extern TCGv_i32 TCGV_HIGH_link_error(TCGv_i64); -#define TCGV_LOW TCGV_LOW_link_error -#define TCGV_HIGH TCGV_HIGH_link_error -#endif void tcg_gen_op1(TCGOpcode opc, TCGArg a1) { @@ -1171,6 +1163,21 @@ void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset) #endif } +void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset) +{ + tcg_gen_st8_i32(TCGV_LOW(arg1), arg2, offset); +} + +void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset) +{ + tcg_gen_st16_i32(TCGV_LOW(arg1), arg2, offset); +} + +void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset) +{ + tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset); +} + void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset) { #if HOST_BIG_ENDIAN @@ -1182,6 +1189,18 @@ void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset) #endif } +void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) +{ + tcg_gen_add2_i32(TCGV_LOW(ret), TCGV_HIGH(ret), TCGV_LOW(arg1), + TCGV_HIGH(arg1), TCGV_LOW(arg2), TCGV_HIGH(arg2)); +} + +void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) +{ + tcg_gen_sub2_i32(TCGV_LOW(ret), TCGV_HIGH(ret), TCGV_LOW(arg1), + TCGV_HIGH(arg1), TCGV_LOW(arg2), TCGV_HIGH(arg2)); +} + void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) { tcg_gen_and_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); From patchwork Fri Nov 11 07:40:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623677 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp616164pvb; Thu, 10 Nov 2022 23:43:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf79ySGgAedflrG579zhiTgYho1pMgLbTszsqEuwywJ3/EZOUG3OiC/+KkpQqhJVrnDQUJgs X-Received: by 2002:a05:620a:12c9:b0:6f9:f3f0:61c2 with SMTP id e9-20020a05620a12c900b006f9f3f061c2mr184334qkl.289.1668152598724; Thu, 10 Nov 2022 23:43:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152598; cv=none; d=google.com; s=arc-20160816; b=fBt52B1Jp5T9Lt4K7ddpYJzgbn7zSri3WAc5n1ncx4ivDPIHIDTOKR3fRBobA20bcO kpj9T3714oGV9y4H8wHCgqT00B/U0PSp/pUcdql8ZBSv3zqZGPD5zWyAf81qop3CG8Vt fEc5OxAsDXrsY+TiTv0bXd4ywlLDhZG/V6puLC7aZkmbqefYTDwRUAMxfWfdxE69n6sU zttRvfaHnaVzA6LewWtJWHN4eMItMLnHjCQ4oAluhwlrbW/9ISEw8BE1qKxpFFxdmMEL q3iW2AIKgFCAogIJ3AK/9uyQ3oDBNMoGiL5OFiMV/1BX54mtmNJXCtCLY+2aabVKAavG /Htw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=h5d0cgClQHZWZcoNMsH56nPEAX39ZERzh63wDTrkWF4=; b=cZtMCI5bsNr+kBk+kbo7fzICQF5kLA9IDnbarch7WwGqr68BEmEQmCP5EV0ici+jMb mOtYuBjhXmH1ITQSi7GvyIosElF6k7pXAmA1vuT+uVjWBGWArDog7Lc36hToi7Xkxk7Y eK4DZxiZV46zCmsLGgsvM8wUJ/DbEuCEViEml0ldt/OGU4XfM6SN1JhUBW0e2urSezVT YHq6HadcNJ4DuQiU8FBn5/tAz7vu7XWp9u/nLtXCjttVgfJdM7AwZbs+FQKUjxJlTvgp yu0ImtWs9T9EkpSBSg1C07naF8FpGLdWgcyw5IEtUT2gZ01LQ95aTZZ5Uu5TxWiFL90c LLxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MMoivuhk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fe4-20020a05622a4d4400b003a4f0c53ab1si690579qtb.727.2022.11.10.23.43.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:43:18 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MMoivuhk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfo-0006RJ-3f; Fri, 11 Nov 2022 02:42:00 -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 1otOfR-00067p-If for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:37 -0500 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfN-0007o0-JZ for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:36 -0500 Received: by mail-pg1-x530.google.com with SMTP id 136so3817589pga.1 for ; Thu, 10 Nov 2022 23:41:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=h5d0cgClQHZWZcoNMsH56nPEAX39ZERzh63wDTrkWF4=; b=MMoivuhkxqP5XU35eSKnGEo7XRVxMsauuPnLP7MQhnTI8kanW0fMpKWcAIKEmfAx12 TQxZhEhG6j6RxF67whhMkY1a7yZDteL+xqP4eEJqf4H6PSDI2yNGrszAb3XyQwjwqMdx imh2x30u1NsjG63dqMRyBHFMNFeKuXhiibMCI8y7s0LgrdN7rQ2BUkt6iBYUBsmOxTtu I6k1EkqnG0GMRY6o31s6PynuYjOzfxEczAwc+8HUjVjzdMOzMX/x4LOAwLpPSkFHlRX6 0Et05Ff1O90yyyrHxVwyfU9CO0tcO/fUeRm5okwOqKG2V07ED7dboHDG9EBeQ7hhbFhm zSfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=h5d0cgClQHZWZcoNMsH56nPEAX39ZERzh63wDTrkWF4=; b=hwnxnL1uifIXjwmD5ang9KTjvP1TIKrxpeBWKuVBIL54NtF7kd6MMBWryKYE7DcmYI aei8qj59+vFPyWNeF/iCx9jchpLupDE9Sw22bJvsMvsD06rS2/rLrUR3nSbZ63cNEdOL UfziMEG664MtNDg2EL1l/WPU5i2qyrlzC9yDBbIwYANZtMQRYnBNMiAkGSj6VMgTvF5i 4qCdKwNdcAWzdmcVTgV6HUGIkijnUIlfxPttE+4lSFBHaA2M0QYgii89qaJKSb/VCeKv FUvQArmQjDpKYYWWOZrhhmiYVdIP+J7/0j07MyXJk3DT3bkVEvrwZJl00Uv/rR5k4JFL nshw== X-Gm-Message-State: ANoB5plHhC3Nn9P1hsPHwPXsvwchGwHV+FkVJDTv6oMI+Am2+bLkAox+ ip+M7XUP988ywhjhDLMzK+nke8KeurW3+M8l X-Received: by 2002:a63:4c26:0:b0:43c:969f:18a7 with SMTP id z38-20020a634c26000000b0043c969f18a7mr690478pga.12.1668152491681; Thu, 10 Nov 2022 23:41:31 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH for-8.0 v3 10/45] tcg: Add temp_subindex to TCGTemp Date: Fri, 11 Nov 2022 17:40:26 +1000 Message-Id: <20221111074101.2069454-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Record the location of a TCGTemp within a larger object. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 1 + tcg/tcg.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index d207bc47be..afa18986b1 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -456,6 +456,7 @@ typedef struct TCGTemp { unsigned int mem_coherent:1; unsigned int mem_allocated:1; unsigned int temp_allocated:1; + unsigned int temp_subindex:1; int64_t val; struct TCGTemp *mem_base; diff --git a/tcg/tcg.c b/tcg/tcg.c index ae7516627c..a82c291369 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -927,6 +927,7 @@ TCGTemp *tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, ts2->mem_allocated = 1; ts2->mem_base = base_ts; ts2->mem_offset = offset + (1 - bigendian) * 4; + ts2->temp_subindex = 1; pstrcpy(buf, sizeof(buf), name); pstrcat(buf, sizeof(buf), "_1"); ts2->name = strdup(buf); @@ -973,6 +974,7 @@ TCGTemp *tcg_temp_new_internal(TCGType type, bool temp_local) ts2->base_type = TCG_TYPE_I64; ts2->type = TCG_TYPE_I32; ts2->temp_allocated = 1; + ts2->temp_subindex = 1; ts2->kind = kind; } else { ts->base_type = type; @@ -1091,6 +1093,7 @@ TCGTemp *tcg_constant_internal(TCGType type, int64_t val) ts2->type = TCG_TYPE_I32; ts2->kind = TEMP_CONST; ts2->temp_allocated = 1; + ts2->temp_subindex = 1; ts2->val = val >> 32; } else { ts->base_type = type; From patchwork Fri Nov 11 07:40:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623679 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp616240pvb; Thu, 10 Nov 2022 23:43:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf5F8Q/fE+1biz+OHlKQA0cMAWGqhc9HjRM39GaYQqq6XSqlK6kSJfJTKdDgq2sXUSDinmwj X-Received: by 2002:a37:ab12:0:b0:6fa:156e:4525 with SMTP id u18-20020a37ab12000000b006fa156e4525mr202344qke.76.1668152615276; Thu, 10 Nov 2022 23:43:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152615; cv=none; d=google.com; s=arc-20160816; b=jsbkIf52pqFPMIDcU+ZpfVCB+OULlBZpLiH9cHLp2i/25Brz0xb33v6f0T6WiGSbc6 eJlmoKitTcJ59zrztu9XWyRcqBJHWXtXoYRIOlx1ISJ6oULkdmcchkhrFk25W8lkXx3y 1m/QgKCANzohO9TaC+fE9JnR8YWNYrj3hw+KrQCU1usz88gzMqa7+IIH9WaNbSq2XZtB RF6IWT1VDr7vkhZDKLQ5ZmuhbBeD/w6QQ/SpbuVKdjzXx/PdkQa4MA3lHwP0SnzP9EYl MqO9K+N7jHMWaCle7czFgTJRMR6yERIgCsXEMSQxqbnv0aeP24J7+IrDE7emQg/BaxeJ 7S4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=xahjzoLT2lYIuoORTVfzuekRzoA+kKRZyhuxmI6DMcw=; b=Q7LSSBLAlTtsiw7ffxvsHpxzW/ky1xYtKxStmXyJlPR0O5Uv4WRmvo8fVWBRVu0VaC RFCZDYxDblnMJsZbH2bwk4H6xI80acySblgrFRyCylDEvKWEzoW4FnEh22CNb+0Qhm4g Ym90uw86ToREMiSPCrHb5MwSz3NBY5C7scUJ3dqG6yXKYimFS89FJbECSQfKGJ9yLC0l JuNpQqHUuOqdD+sxKslPwNoh0OUXesYSHwhjNntQ8+kxjUK+dlm7Zq44NIWgp8SdDB8W OX5DL+ppEeaMGRhmWm/AZizHIR5rsXoIeQUBZxj1VKtGloDUvgn/N55bly1zHglcn3lL 6Z5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WjXu6uzc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ey16-20020a05622a4c1000b003a5882a0510si694789qtb.398.2022.11.10.23.43.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:43:35 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WjXu6uzc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfe-0006DY-1Y; Fri, 11 Nov 2022 02:41:51 -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 1otOfS-00068Z-PI for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:38 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfR-0007q4-B9 for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:38 -0500 Received: by mail-pl1-x632.google.com with SMTP id y4so3643538plb.2 for ; Thu, 10 Nov 2022 23:41:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xahjzoLT2lYIuoORTVfzuekRzoA+kKRZyhuxmI6DMcw=; b=WjXu6uzcszp5F/aQaA6GfZs9eRwAHNVzH0+s//5GZ6KfgiroX3RSynGtj/EhF5+O/4 61IUQ0kJ8qE1gCRQ3MElZo/6oj25vZtmpNU7m+JzY9sSpVRX8f6wXZP2ZoTJLmpCXWnj 5wycsanj/TsRc6nlT3I6aB0Jv6o5/tjaMNQFdae06Bs/ApHIRNr81OZi6duRyMKDmwi/ rvgfyeSBKU9BSSIzGDnlM8UQQoCIh6JyQU9cceBv9Zezon0SNXHU8jTX5bZkn+YRSyM9 QmvPGZx8bmyyDE8qOWY2CUhjfGYKBoyvM7VKKfETa0hR7Dq2k9bPftldqnyZg/vuLcoj smyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xahjzoLT2lYIuoORTVfzuekRzoA+kKRZyhuxmI6DMcw=; b=7vhb5fTDCkl0/Pr/QEkHZk2tmltnMFC/iQYVxqrEeEU3HZeeXUrjSRgZxiH/wTQkGt 4MkMui3BOciNcTCJOU0b3xB48qo8eyqnUGuftcVHSJ0zEgwRgfFAHMLLOgQwvlle1pyL LICL53RPNTauiwYRRL/Ts/FM4UmFS/sAAisiHp1lhHSsu/Qh2NmlLZS0RuHT2ZXQ0668 b1qnFCLl5uRHu+frRfT3D+I3/1kHg9Vfco5EthKTQotPFP8wFOa14YmODBNPxLlRN64c 2aWNsfeSpmYnw39BHN/xoHljKiFfemCllroPrXOOC/QkjbKtAMP8xNi+v/+SPkcJ1+xv MpLQ== X-Gm-Message-State: ANoB5plknN8lF3C95/jCvi27e1RQ1G0Vwvf98pIQo2Y2pzHkZZyfzUMr GpVqeQu2Zrx1O6OrpeWyLnflekKO8X3hpQVz X-Received: by 2002:a17:90a:46cb:b0:213:d200:e989 with SMTP id x11-20020a17090a46cb00b00213d200e989mr668232pjg.40.1668152493978; Thu, 10 Nov 2022 23:41:33 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 11/45] tcg: Simplify calls to temp_sync vs mem_coherent Date: Fri, 11 Nov 2022 17:40:27 +1000 Message-Id: <20221111074101.2069454-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The first thing that temp_sync does is check mem_coherent, so there's no need for the caller to do so. Signed-off-by: Richard Henderson --- tcg/tcg.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index a82c291369..583677a1c4 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -4117,12 +4117,8 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const TCGOp *op) /* If the two inputs form one 64-bit value, try dupm_vec. */ if (itsl + 1 == itsh && itsl->base_type == TCG_TYPE_I64) { - if (!itsl->mem_coherent) { - temp_sync(s, itsl, s->reserved_regs, 0, 0); - } - if (!itsh->mem_coherent) { - temp_sync(s, itsh, s->reserved_regs, 0, 0); - } + temp_sync(s, itsl, s->reserved_regs, 0, 0); + temp_sync(s, itsh, s->reserved_regs, 0, 0); #if HOST_BIG_ENDIAN TCGTemp *its = itsh; #else From patchwork Fri Nov 11 07:40:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623692 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp620088pvb; Thu, 10 Nov 2022 23:54:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Wp5kapiLm/mmuO5vNXkv3oyCIzw/XUOKS4hS06CKRG9jIAH93KF/Vq8ENQ2JbISrYYSy1 X-Received: by 2002:a37:9647:0:b0:6f9:ffc6:45d1 with SMTP id y68-20020a379647000000b006f9ffc645d1mr178711qkd.663.1668153288401; Thu, 10 Nov 2022 23:54:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668153288; cv=none; d=google.com; s=arc-20160816; b=TbhJavG0hM5auDsxRvG884PScAW9vOE+vK+6Uiv0Vyfl5TCvlmQ9gDyNTcM/jlWF6v nfFgI7bjSLL8kDtURQ4WXerwVn6p2BAj4SUoa82y5PIc9TIXpxsYqo92mYnOGiYJhifZ /L7yaoSKRF72a+VKOLQedz0cmQ1fmBoPL/1uV8e60TuJIdF+CRMktEUjMRPZRCMhVu4h iWQcVXCwjezS9RHglt13CJUI+8afVqs9m97KjwXD838ydb/hYsmGiVJXkE90eoom1Ois rhOOcTfQfDFi6Kkha2eOyv2p25dpUw4Naq4+Fn2Zsj6ZC0/Xd6/uaQmJKinHzfb49NfA AmMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=gE52zlaTPttNRny+uxuw2pEYfjL4jf4kiCaqy2SgrWY=; b=cynzjxfxNwRRC30WIWO9gHJ2hXP+sOvxH2PfLMICFS4h/uPzl52cZJmhAtmEDre1y/ iZ4Gmm8+XX0NkJ0aakhdkhfyW7fIF9XaKpUfYm2wn41LhTmUTBJMH/GxYwmJ/rGR1ore 7P58RJbGHoP2AdYLVVJPn/5lyM/M2y8VYH3c5GOy3T+B0ISK9sFuKZqiK6p5tcDvgqOr 4GQBtZ9FTAGRMs6gzukKJNp8t7KadP9lpSRlrLZUmY20S7MN/pPH2UKwzqXljdxuxt23 iUwQf3zRpC5MMhpXZxchEYSuchMk1fzDsQNTyR+igpneEYZUxRWJRCw4+8OcBjprMFXa 1/rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a5ISbABu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bk3-20020a05620a1a0300b006fa0db1fdcdsi748190qkb.146.2022.11.10.23.54.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:54:48 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a5ISbABu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfm-0006PZ-LP; Fri, 11 Nov 2022 02:41:58 -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 1otOfT-00068t-Ed for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:39 -0500 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfR-0007vX-MB for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:39 -0500 Received: by mail-pj1-x102f.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so7067281pjs.4 for ; Thu, 10 Nov 2022 23:41:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=gE52zlaTPttNRny+uxuw2pEYfjL4jf4kiCaqy2SgrWY=; b=a5ISbABuYbkfByqD3p6teKxGXhZwMuuHAjRKwfPhQDXzKLRo6lv32SZLB7eExe1neQ oOooezQO+PeBHXmuqo1twpdJ6BEn8bKblXaRhPtWNfgBhRBeIcT5khKbExNn8BnmI6mj TDXB4RpiQluiZS6gnZQhLZq9qRBlxDxh+NNvhT+/OKbUF0l/tuMNkLBjzUOWz34nBVwu wog9qZnePE0tJOKfjlYcMS/jrdC1KGRn3yAhL34r0400dNTSZB9C3nVNldHAEFeJyMyy NIAXnyPA949G1i4ALcr2JpGShOcVna/UMY61qleNiwYCezi03mP7EnDfD1EnHKB66YEf i8iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gE52zlaTPttNRny+uxuw2pEYfjL4jf4kiCaqy2SgrWY=; b=CdS+z9SXcTeljcr9SIYB/tmOgjQaO2e5V7YuaJR0ftQDb5eA1vO5HpWTEBzX12HomT QzsUiN+UeWBeU/BAEjAt5G/fYn3wfdy4MDCWDTDCxgm+W1i9ce3ydUR13z/FWCvvhhR3 MgbEu92lcRJxl5oWVXxmA4fNgE4pVlloy4MIA66lWqTdT9m1BNB0+9q6ibJX/u0f1ACf Ewm13qWJt7u/rHubuWVDp/7kyzsKsRi8q0ycuuaLnskAqr1oMEcd2aaLY/6rmryNtvvP 11I6kJJusNdrz87mgJVB4QwW6O/bsarvcp8gjqVsyUZBDRBxsh1RH2uKEJ08f2kEH0Cb PyRg== X-Gm-Message-State: ANoB5pnF66NsNDQNmn7lv5LT87OKDf0Pv7upPOd6G2YJHdn0c+G7CGtE K23x1DxQ09Q2+6gysiVFtuC0kCXRf8f2hBkZ X-Received: by 2002:a17:902:6b05:b0:186:e568:3442 with SMTP id o5-20020a1709026b0500b00186e5683442mr1416384plk.56.1668152496206; Thu, 10 Nov 2022 23:41:36 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 12/45] tcg: Allocate TCGTemp pairs in host memory order Date: Fri, 11 Nov 2022 17:40:28 +1000 Message-Id: <20221111074101.2069454-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Allocate the first of a pair at the lower address, and the second of a pair at the higher address. This will make it easier to find the beginning of the larger memory block. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/tcg-internal.h | 4 ++-- tcg/tcg.c | 58 ++++++++++++++++++++++------------------------ 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index a9ea27f67a..2c06b5116a 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -62,11 +62,11 @@ static inline unsigned tcg_call_flags(TCGOp *op) #if TCG_TARGET_REG_BITS == 32 static inline TCGv_i32 TCGV_LOW(TCGv_i64 t) { - return temp_tcgv_i32(tcgv_i64_temp(t)); + return temp_tcgv_i32(tcgv_i64_temp(t) + HOST_BIG_ENDIAN); } static inline TCGv_i32 TCGV_HIGH(TCGv_i64 t) { - return temp_tcgv_i32(tcgv_i64_temp(t) + 1); + return temp_tcgv_i32(tcgv_i64_temp(t) + !HOST_BIG_ENDIAN); } #else extern TCGv_i32 TCGV_LOW(TCGv_i64) QEMU_ERROR("32-bit code path is reachable"); diff --git a/tcg/tcg.c b/tcg/tcg.c index 583677a1c4..f9315d00fc 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -886,10 +886,7 @@ TCGTemp *tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, TCGContext *s = tcg_ctx; TCGTemp *base_ts = tcgv_ptr_temp(base); TCGTemp *ts = tcg_global_alloc(s); - int indirect_reg = 0, bigendian = 0; -#if HOST_BIG_ENDIAN - bigendian = 1; -#endif + int indirect_reg = 0; switch (base_ts->kind) { case TEMP_FIXED: @@ -915,7 +912,7 @@ TCGTemp *tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, ts->indirect_reg = indirect_reg; ts->mem_allocated = 1; ts->mem_base = base_ts; - ts->mem_offset = offset + bigendian * 4; + ts->mem_offset = offset; pstrcpy(buf, sizeof(buf), name); pstrcat(buf, sizeof(buf), "_0"); ts->name = strdup(buf); @@ -926,7 +923,7 @@ TCGTemp *tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, ts2->indirect_reg = indirect_reg; ts2->mem_allocated = 1; ts2->mem_base = base_ts; - ts2->mem_offset = offset + (1 - bigendian) * 4; + ts2->mem_offset = offset + 4; ts2->temp_subindex = 1; pstrcpy(buf, sizeof(buf), name); pstrcat(buf, sizeof(buf), "_1"); @@ -1072,37 +1069,43 @@ TCGTemp *tcg_constant_internal(TCGType type, int64_t val) ts = g_hash_table_lookup(h, &val); if (ts == NULL) { + int64_t *val_ptr; + ts = tcg_temp_alloc(s); if (TCG_TARGET_REG_BITS == 32 && type == TCG_TYPE_I64) { TCGTemp *ts2 = tcg_temp_alloc(s); + tcg_debug_assert(ts2 == ts + 1); + ts->base_type = TCG_TYPE_I64; ts->type = TCG_TYPE_I32; ts->kind = TEMP_CONST; ts->temp_allocated = 1; - /* - * Retain the full value of the 64-bit constant in the low - * part, so that the hash table works. Actual uses will - * truncate the value to the low part. - */ - ts->val = val; - tcg_debug_assert(ts2 == ts + 1); ts2->base_type = TCG_TYPE_I64; ts2->type = TCG_TYPE_I32; ts2->kind = TEMP_CONST; ts2->temp_allocated = 1; ts2->temp_subindex = 1; - ts2->val = val >> 32; + + /* + * Retain the full value of the 64-bit constant in the low + * part, so that the hash table works. Actual uses will + * truncate the value to the low part. + */ + ts[HOST_BIG_ENDIAN].val = val; + ts[!HOST_BIG_ENDIAN].val = val >> 32; + val_ptr = &ts[HOST_BIG_ENDIAN].val; } else { ts->base_type = type; ts->type = type; ts->kind = TEMP_CONST; ts->temp_allocated = 1; ts->val = val; + val_ptr = &ts->val; } - g_hash_table_insert(h, &ts->val, ts); + g_hash_table_insert(h, val_ptr, ts); } return ts; @@ -1514,13 +1517,8 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) pi = 0; if (ret != NULL) { if (TCG_TARGET_REG_BITS < 64 && (typemask & 6) == dh_typecode_i64) { -#if HOST_BIG_ENDIAN - op->args[pi++] = temp_arg(ret + 1); - op->args[pi++] = temp_arg(ret); -#else op->args[pi++] = temp_arg(ret); op->args[pi++] = temp_arg(ret + 1); -#endif nb_rets = 2; } else { op->args[pi++] = temp_arg(ret); @@ -1554,8 +1552,8 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) } if (TCG_TARGET_REG_BITS < 64 && is_64bit) { - op->args[pi++] = temp_arg(args[i] + HOST_BIG_ENDIAN); - op->args[pi++] = temp_arg(args[i] + !HOST_BIG_ENDIAN); + op->args[pi++] = temp_arg(args[i]); + op->args[pi++] = temp_arg(args[i] + 1); real_args += 2; continue; } @@ -4116,14 +4114,14 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const TCGOp *op) } /* If the two inputs form one 64-bit value, try dupm_vec. */ - if (itsl + 1 == itsh && itsl->base_type == TCG_TYPE_I64) { - temp_sync(s, itsl, s->reserved_regs, 0, 0); - temp_sync(s, itsh, s->reserved_regs, 0, 0); -#if HOST_BIG_ENDIAN - TCGTemp *its = itsh; -#else - TCGTemp *its = itsl; -#endif + if (itsl->temp_subindex == HOST_BIG_ENDIAN && + itsh->temp_subindex == !HOST_BIG_ENDIAN && + itsl == itsh + (HOST_BIG_ENDIAN ? 1 : -1)) { + TCGTemp *its = itsl - HOST_BIG_ENDIAN; + + temp_sync(s, its + 0, s->reserved_regs, 0, 0); + temp_sync(s, its + 1, s->reserved_regs, 0, 0); + if (tcg_out_dupm_vec(s, vtype, MO_64, ots->reg, its->mem_base->reg, its->mem_offset)) { goto done; From patchwork Fri Nov 11 07:40:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623717 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp632572pvb; Fri, 11 Nov 2022 00:25:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf7/YZj+ftdd7LxMbhSSUPuvvN3fWhEkbUgAiuUlUeQpRORi2iNufcS6qF5Y413ewS85rMpa X-Received: by 2002:ac8:4714:0:b0:397:d070:b7ae with SMTP id f20-20020ac84714000000b00397d070b7aemr399495qtp.496.1668155102803; Fri, 11 Nov 2022 00:25:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668155102; cv=none; d=google.com; s=arc-20160816; b=FWZeJzQl8Tg18ym74M4B42wQLfKplSxtTh342O/eV/JDieHiWyNi28sust2ZO+z7xM FcAX1c6Y+Y/wlu3hrV5u5ploIfqm193HbedL8IzJhdc7DNT2eBZ5AC1eTPXgnqg+H5FO iKYuNhhFk2FjHhTwdzrXIQ2/GRZC2kDds2o/fS5/tpBce0QOiMH5aBHe/vSPSnMABV04 z/JeI5Mor+3aFYrvPEVa5IJJc9QDIyW5aJmkYVMJZXjx3XeTT0FsERbAU5zQyLc0WFeA WORISkg/Fn/6d0DHTUlf7FpVFRLEEDBl/pyII0M8JSC/oPdh7j0YjCjvhyUaKAMeGXmm cbhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g+8yoDAKtbWcn6kd6zbMcipsZN6xB1eyyko6EmQwVd4=; b=iFehmOTXCrSK7zF2tVy7ToAATT+khl29NsvM+zRGUF3ChGQgFs75uwV8vxLasSxZJN X+AoVQ0fa4J3uGxjKTJyuFAH92L2LkGGzOGJvsJ3ENZTWii5DdugSaAI3HWj9k4mDq9L SVr2Sttn78rFKmZ7LzwOobGfgrAEeCJvMh3lfJl3EgWl+gSX/4DhG0AcarXRimcz5enE xqaOH3Kyr7KeNawxcLTaWqhHyrW4wgC0Oi/58UCeeV9T0Q7GiSC2pMTT0sF7vBaxjtZ2 WNIRLxEjuxLKD46jVwGcNTbIu/3XnaRjek81bUmP0iqs5zlT9cJRAAWBNSDm6C+KMDgZ n7iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WTAw1BOO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y18-20020a37f612000000b006f9fed849eesi702915qkj.501.2022.11.11.00.25.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:25:02 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WTAw1BOO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfn-0006RE-VJ; Fri, 11 Nov 2022 02:42:00 -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 1otOfV-00069R-El for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:46 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfT-0007wx-Vo for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:41 -0500 Received: by mail-pl1-x630.google.com with SMTP id c2so3606398plz.11 for ; Thu, 10 Nov 2022 23:41:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=g+8yoDAKtbWcn6kd6zbMcipsZN6xB1eyyko6EmQwVd4=; b=WTAw1BOObhQ9hsFLEWkqihao4XdaLcqlsB3b+ozNJY35kvVu1lmuNum+6+nUgxGkwa VdWWH/c7u/dixm4Lb+M48AG/b/J2xWNFaLcaD87thhLLihQoY3rPH4cHJOQ1gpzhX9ag gBs890U0yXkkGnohFsTezpJY5I7+uJpCbKMvrD+FidZ1ucnSy8L85eKnwNmpfI9cu7Dk zfsFxJOJOZ83nm7AK62CMHyRPTw7UnTP0ChJKwZ9qdWC4S6yLjDYM0t0IeosD3b0mK+H rXQrPHVDaOG0lmPwqFBOOWCyAiUZqcsfoFGStmVyrA4WVVupKHtuPjng72HMc5Jm25cm UfaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=g+8yoDAKtbWcn6kd6zbMcipsZN6xB1eyyko6EmQwVd4=; b=57JsUlaWfttYlLPGsYbgeB89F762mnguxSmnvpEkH1iqw9h1+QlVGS9IT3OPUJxIOg A0YUaIUB7JXC1EMgc3dW2fnbskG3HlEARD3qV7Pl8TLe9AlI2tkf67o+JIHL++xuR3Dt Qy4aR0s2co8n+1lJx/44L8aBfiGOWhmWL6epKTnoJrfTnBgrZ2eEdjP0/T1fuZ06RORE RBzDrH/3B+Wlc4LGEraTaMS94+b9NVIZosDEh5vIrhobWClAVWjq+b2JX9OGZSe1mLFt 0Sz7M5MGYY8145P5Td+vGqJn0icWPd/OMs1JTlYAONJaTlVqOdggWDJ/zdRrHI+wkpzT mKcQ== X-Gm-Message-State: ANoB5pmzr3pAyexCXMYY3WVUYA/uFJqylvRFtkvUncjinmzg2svxOnwv oWJUp8tQSFj1V6uu6VBXYQq0VqrfSwUpg5jF X-Received: by 2002:a17:902:9346:b0:178:71f9:b8fc with SMTP id g6-20020a170902934600b0017871f9b8fcmr1483166plp.44.1668152498501; Thu, 10 Nov 2022 23:41:38 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH for-8.0 v3 13/45] tcg: Move TCG_TYPE_COUNT outside enum Date: Fri, 11 Nov 2022 17:40:29 +1000 Message-Id: <20221111074101.2069454-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The count is not itself an enumerator. Move it outside to prevent the compiler from considering it with -Wswitch-enum. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index afa18986b1..f2da340bb9 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -294,7 +294,8 @@ typedef enum TCGType { TCG_TYPE_V128, TCG_TYPE_V256, - TCG_TYPE_COUNT, /* number of different types */ + /* Number of different types (integer not enum) */ +#define TCG_TYPE_COUNT (TCG_TYPE_V256 + 1) /* An alias for the size of the host register. */ #if TCG_TARGET_REG_BITS == 32 From patchwork Fri Nov 11 07:40:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623701 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp625532pvb; Fri, 11 Nov 2022 00:06:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf57FO8WxCHg3kitUYnvJ1rk7W+gSwZKZyatF7nQmaU7333WsNTIspOFzIcLBVrPU60QZmDU X-Received: by 2002:a05:620a:1713:b0:6ed:9450:9f5 with SMTP id az19-20020a05620a171300b006ed945009f5mr219063qkb.310.1668154001243; Fri, 11 Nov 2022 00:06:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668154001; cv=none; d=google.com; s=arc-20160816; b=ATjD0KJSXYN9PdtPmLJk1m9Ks93oDIq3GUC/4VcGPe2Xj+ho7GBRjiZxH2XouSTs8C 38lwvc+GW1YM3Ju/dJ/tkdTDl72SSsZRIC2XNmGQwM+CNm4duazTD2M/GAH58qiTSkCl WiaFcwSv9XxyIYgodAVkqvU+y0x1njnPRiBoKCPi2iJS9dyeQevflF/aRt7IGb9X/uH2 IDBlYQW7iS2by+3fMzJj8SDUg2n6+NM0oStwx47JXudVkVvHWll5xw5wQM37gS5q6Zf3 YZuAG1Yi94rSnnYI4zkq7PGQrvMu3SbVuDaf6QHfw8go4EWtTTngL2qkJ1PhscSMqHuf zhQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=FrghbrOmwlRnL2e6OOqpXhf7jPD3Ma/5bcPh3TvRHME=; b=vaZ/cRKkoPvHcKKjWit2GP1HedXiN+B6t83JoORpNxM0YNXclquUO9oo4TOmlQ0wcl b+HHCeAcNtRmMvG6uybom0ChiMj3Atd+IUWNab3x9YzPZBtwt4nx1ZvBUXctoDeGBozW DT5F4J7R/invUuOfDqR4DZyxobA3RP0oxd9Ca/BvSY2D1s1KVWVgeE4Pkm72R4s8k8LW JBjhWFnTlKRoW7UiDWYiHj1Or4ynOLezxwZZGrIPILtLUq5pnzQf6fti0dEKSIOcka6D imkdiBqXCpbqVSXWaklTk5Swe+oeuH02GM/Pzb6Z44ghV8mbeLA4aP9PXp+5U3cKuUVk hsbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e5b2lawj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u19-20020ac858d3000000b00399d69cfe35si809257qta.110.2022.11.11.00.06.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:06:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e5b2lawj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfq-0006bR-Op; Fri, 11 Nov 2022 02:42: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 1otOfY-0006Bd-Cv for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:46 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfW-00082S-0e for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:43 -0500 Received: by mail-pl1-x62a.google.com with SMTP id l2so3600868pld.13 for ; Thu, 10 Nov 2022 23:41:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=FrghbrOmwlRnL2e6OOqpXhf7jPD3Ma/5bcPh3TvRHME=; b=e5b2lawj6t1ic1BEGnykBVITwtscs84+VCQF7p0ub4c5vmf659ianyDFlZJu+T9GZ9 e43kJZd7liHBZTKJ3pZuIAVG/LN4dqTb2ls00e5GymAtrqB8Dt2GK7fuW56mHXex+nRp rGzRwRRMotIKw6spe6fajOd9XrlFYJ/4dGShlyc97LUYxpkPhCvTPFtI+kRqbcQGoipJ 7867qw50dQBtjj2C/LXaCrjMtQf1bofUm6roQCx/OQhfGXqb1HRPn9gp0Xk9A3QUkxbb AhXKytTvmPZaYLeP/8VWOePebjRgNAHAgEOy+1xV8pZlUXQ8pW5zv5FgE4h3+doBGzzj Obvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FrghbrOmwlRnL2e6OOqpXhf7jPD3Ma/5bcPh3TvRHME=; b=ANPr3YBBUwsxpNMoICVVCwtJWNXYE9UeWj2xytnEAPbCAWuEpmU2WUtHoq8Z1Sz8Fl NHAtOd20e3g/wRbUyNrjXh35/8EaLDF5L8fRz24l7TTvP7c72niF1LSsg/PMJt8QvzFK bYmh5i1yG2702EeMIYkQg2DP4JTYlNZa6t5KEzj21UswrO5TlUOA5s/mApQX/NcV9x/6 52180KGnBXY/wFSXn2fiNUueCIWlIqgHC2n+jvY9nTPpD73i4mmZcZB3qrAHtF3mSrkO /Wwr2QiBsYrBjfo/MTWCP82EmC6nigPI9jSx6n750T0R73eiNxocZrg6D4yLEBuqDFOe 2+1A== X-Gm-Message-State: ANoB5pkfPvKzzdXf8yL1QokOhyYwkIyQW45qh6CPk/aw23AQgnyKh0+1 a64NxTUZHkmb3DX4S3+Y+euyvQIMzwFy3UZF X-Received: by 2002:a17:90a:7442:b0:212:d686:f99f with SMTP id o2-20020a17090a744200b00212d686f99fmr626722pjk.109.1668152500746; Thu, 10 Nov 2022 23:41:40 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 14/45] tcg: Introduce tcg_type_size Date: Fri, 11 Nov 2022 17:40:30 +1000 Message-Id: <20221111074101.2069454-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Add a helper function for computing the size of a type. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/tcg/tcg.h | 16 ++++++++++++++++ tcg/tcg.c | 26 ++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index f2da340bb9..8bcd60d0ed 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -319,6 +319,22 @@ typedef enum TCGType { #endif } TCGType; +/** + * tcg_type_size + * @t: type + * + * Return the size of the type in bytes. + */ +static inline int tcg_type_size(TCGType t) +{ + unsigned i = t; + if (i >= TCG_TYPE_V64) { + tcg_debug_assert(i < TCG_TYPE_COUNT); + i -= TCG_TYPE_V64 - 1; + } + return 4 << i; +} + /** * get_alignment_bits * @memop: MemOp value diff --git a/tcg/tcg.c b/tcg/tcg.c index f9315d00fc..ec03bd3d6a 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3110,22 +3110,22 @@ static void check_regs(TCGContext *s) static void temp_allocate_frame(TCGContext *s, TCGTemp *ts) { - intptr_t off, size, align; + int size = tcg_type_size(ts->type); + int align; + intptr_t off; switch (ts->type) { case TCG_TYPE_I32: - size = align = 4; + align = 4; break; case TCG_TYPE_I64: case TCG_TYPE_V64: - size = align = 8; + align = 8; break; case TCG_TYPE_V128: - size = align = 16; - break; case TCG_TYPE_V256: /* Note that we do not require aligned storage for V256. */ - size = 32, align = 16; + align = 16; break; default: g_assert_not_reached(); @@ -3641,8 +3641,8 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TCGOp *op) TCGRegSet dup_out_regs, dup_in_regs; TCGTemp *its, *ots; TCGType itype, vtype; - intptr_t endian_fixup; unsigned vece; + int lowpart_ofs; bool ok; ots = arg_temp(op->args[0]); @@ -3711,14 +3711,12 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TCGOp *op) /* fall through */ case TEMP_VAL_MEM: -#if HOST_BIG_ENDIAN - endian_fixup = itype == TCG_TYPE_I32 ? 4 : 8; - endian_fixup -= 1 << vece; -#else - endian_fixup = 0; -#endif + lowpart_ofs = 0; + if (HOST_BIG_ENDIAN) { + lowpart_ofs = tcg_type_size(itype) - (1 << vece); + } if (tcg_out_dupm_vec(s, vtype, vece, ots->reg, its->mem_base->reg, - its->mem_offset + endian_fixup)) { + its->mem_offset + lowpart_ofs)) { goto done; } tcg_out_ld(s, itype, ots->reg, its->mem_base->reg, its->mem_offset); From patchwork Fri Nov 11 07:40:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623690 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp619741pvb; Thu, 10 Nov 2022 23:53:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf5pmvU9HnNEacetfcyiotWKRt9qcisFWL7uq6kEyE5N35zKml/rW5F+u3s15Pqbk/uvVmlp X-Received: by 2002:a05:622a:174a:b0:3a5:13b0:e040 with SMTP id l10-20020a05622a174a00b003a513b0e040mr332386qtk.625.1668153232897; Thu, 10 Nov 2022 23:53:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668153232; cv=none; d=google.com; s=arc-20160816; b=x4Edm9zoIVwoUkzJ4Int3jvSGVMdrG6phpTSa+aJ0lSVCKHbeyoTmEc76ZiykG7Er6 RvsMTnlSpvpmf0Hc0TATaLwdRqMxJkcnpqAsHgt4LfK5E9eaNsgaeDnPOUiCjJYcabaH OXPZ52qTK07fqqQtCwnzvveRvKhWommy/exAFuQCBUWVkoZCc5vFRrZ3U2+Yst057zhh LEtrEYuATQvd9TeoukdGnigKGaeT2wnNFj8YHVASoiTA2VQIRV5FTHKIgIn0N8e3OoaF HEIO/tObnS9XzEed/nrXiF+GhhDlOB/okuT58zh+dNgvFNNG0jjEBVMPT4JmR5lSEQQq uPYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=5vQArXkcT1RDMZRTO1vvTA3LiXCIJpRLbh9UK0Nx/ps=; b=AV6E5FpdzVB6ei7Wkp9LEgCOhIsofSSlRBtJJoqVBJXADcNpUjhFpj35H4lPg/5UnW twPY8ju4840w4QmEwbDYSlokdiwwaWqqCwmswMsCym9x+UT8u77ky9yEQ8wnkOdyfidt NyO9iTKPMwfCRsxQ4rc/Lnbc0WSRNpZWNIEEK5kxF3yLnFM/rwVb1RhUlK8daOCZbyx1 V5IIHbglBqq+Oo8TgdsV1UqROfOtXO0iSJD6GJKNWIhiYBlSdg/yJ0P4g/GWeD1FbD5m jzVtuL7MOFdY+tjoVpvTU4N6C7Ay4yuUU1tTpVvywwYG/4wNrop98QEUR4/yr6uaiayl BAIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qT8XAxGG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d9-20020a05621421c900b004ad1fd02c0dsi618188qvh.552.2022.11.10.23.53.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:53:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qT8XAxGG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfp-0006Xk-3C; Fri, 11 Nov 2022 02:42:01 -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 1otOfa-0006DC-6n for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:48 -0500 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfY-00087A-Nt for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:45 -0500 Received: by mail-pf1-x430.google.com with SMTP id q9so4236664pfg.5 for ; Thu, 10 Nov 2022 23:41:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=5vQArXkcT1RDMZRTO1vvTA3LiXCIJpRLbh9UK0Nx/ps=; b=qT8XAxGGZFuHOzauYRmYlZffWUsLQ5NRlyolO/qhkXeQoyg0S8iy18NMeUUyBz0W+o GrIKUCWxY2FCmeaUSfl+UZVoxJsubX6uPqCkzVtHVMQTC91obvBHLiXj88KL2jl70Q+C R/A1Ed0Wb1yy1zVQt7DER8ANkzD5LVr92sNSNxQgsk4LFK80kvcdyPacdJean2khW+7z ymVqv4wYK2gFngOFxMfhFDDZpLBNKWILaRR6Ke4UpEA2rNECXm82mwbIncobRxS2C7eA cAfkVt/q3R6IBrB0zSjSs8ISvvtch5nwTjK+9obmuYEZ60Tu7spfZyUy+nsHH3/RpKhn frxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5vQArXkcT1RDMZRTO1vvTA3LiXCIJpRLbh9UK0Nx/ps=; b=chgtmBBr7PsPcn7oEyCOP9Fso30bagh4btEKFfj/Ykofosmyu5tb51JBaJ6OKww7+D NiUIwhjGh/tFWK5Yq4ngvZUcoUfFSqgC9gAFf48Lcf6Qrw2BTiu1tVHFNm4rUaZmicy+ MJfsYW1Lp3B1e73kyXGL51WCZLBRx6TuShCHwC9lfDFR3mUXk2nsn4F7qP1tC2knxTo9 PhBF4TToEI3QXA/7j/dVdNozQBrY5/UAvvkC/s3EUL6mi2Tp2EvdoYXtJJAZl3HMOoAL DpTV7Vw/u0ex6J8wVuN4hQakJonAAcQL21MEsR2qvUEtjj6zQkBRloOQEGYvr5Q/okD4 aQ+g== X-Gm-Message-State: ANoB5pkFi3udG4BSsSWIU3f9rf+9GM2VfpeqCSl+hCr34m0MXtPW1LEl jjoLb5gNAf3MOt502vh93oYyAF8uWoY1M4HO X-Received: by 2002:a63:4f50:0:b0:46f:cbcb:761a with SMTP id p16-20020a634f50000000b0046fcbcb761amr652075pgl.82.1668152503003; Thu, 10 Nov 2022 23:41:43 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 15/45] tcg: Introduce TCGCallReturnKind and TCGCallArgumentKind Date: Fri, 11 Nov 2022 17:40:31 +1000 Message-Id: <20221111074101.2069454-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Prepare to replace a bunch of separate ifdefs with a consistent way to describe the abi of a function call. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/tcg-internal.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index 2c06b5116a..f574743ff8 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -27,6 +27,21 @@ #define TCG_HIGHWATER 1024 +/* + * Describe the calling convention of a given argument type. + */ +typedef enum { + TCG_CALL_RET_NORMAL, /* by registers */ +} TCGCallReturnKind; + +typedef enum { + TCG_CALL_ARG_NORMAL, /* by registers (continuing onto stack) */ + TCG_CALL_ARG_EVEN, /* like normal, but skipping odd slots */ + TCG_CALL_ARG_EXTEND, /* for i32, as a sign/zero-extended i64 */ + TCG_CALL_ARG_EXTEND_U, /* ... as a zero-extended i64 */ + TCG_CALL_ARG_EXTEND_S, /* ... as a sign-extended i64 */ +} TCGCallArgumentKind; + typedef struct TCGHelperInfo { void *func; const char *name; From patchwork Fri Nov 11 07:40:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623723 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp634221pvb; Fri, 11 Nov 2022 00:29:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf614rym76RVY1dw5GjYPK8Tftc6wgqi5TgjtxhY3Kd/FmMi/0vYZ3j+RKsAWGx0CBbP9EpI X-Received: by 2002:a05:6214:428f:b0:4bb:6882:4339 with SMTP id og15-20020a056214428f00b004bb68824339mr1094650qvb.28.1668155392024; Fri, 11 Nov 2022 00:29:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668155392; cv=none; d=google.com; s=arc-20160816; b=j67aGo040IZ5DEX8uGzCa+juilB9JxQJdyI8apVx1Oxik7VMPig12qXWWRnpGydPjl tZYw3QpNK5adxl6SpVwzs0HWdBjqc2hWkJxgDy9q8rCWYmJZAduu4C/y3g4+XsVYUZpK JvORSSorw+3boK1klqDOX8szb1YhY1CVvhQT+6ENBNQSd5IM5aVT6NZ91Z7uTpS8BBFg 5xfah+FOxKbSOUQ/U9g9LGy+0tnTD1lYpb8wJjvzFaRQABKuxAX++acsB+pZEAYEBBMH 0aylheE88dLXYxYLJTb2TH2pDNKoo8RhvzdZhW5n9tJUfiSaNBlklGHetjuoJRcNZiOV 99Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6oOaMB/UTSXeF5QPT6/5LHPWXpkLpJtHXDzu2XZxCtc=; b=DMOs0JHglgAOfzQAJGRBdmbzyBcCcnUuqwc+7WWYOG5d+sns1Y/3JOQgGxpK41qLqD ggNxlnZEe0kdaDW8meNfckHzWILzzO0QvXIL7iVbZTwYvwtuZBlQd/kXutB3RZwG0Ykd 9OlmcwCu8f5gIorQ1fe/o4zvhrio4BNKlLAKmEiW2S49jexcl+O4q2iq+erp1HTPpl+w xwkWKCasvGgYh6Ryt7lFcbXCmJTP8KVaQt2mCHHzOopB0vdJ54RFoHb4en6lS8QLxpYc E+EOFGPyHribiCDsjb6/nWa6tdITx0AAYaxWaUpJIUYefeYdYaWTAl6Hk9utrROXIers A/OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Zl//JQVl"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fa6-20020a05622a4cc600b0035d517ce638si772986qtb.160.2022.11.11.00.29.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:29:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Zl//JQVl"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfr-0006by-EF; Fri, 11 Nov 2022 02:42:03 -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 1otOfc-0006EC-Sx for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:49 -0500 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfa-0008Fc-Ry for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:48 -0500 Received: by mail-pg1-x52f.google.com with SMTP id e129so3790774pgc.9 for ; Thu, 10 Nov 2022 23:41:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=6oOaMB/UTSXeF5QPT6/5LHPWXpkLpJtHXDzu2XZxCtc=; b=Zl//JQVlqoUv7GGmKg6zPMPGBfZpS4T47TeF7YMqFcY6rlmRA042k73g7kj7uDkgd0 3LvWcR4FpQQ837Xg8IfvvTyQhLG8GsFmVxKPWoObyuSq9p69F2huVE3LbhbP7nSfSCsd ju8kDLa+Bk9vJMgYCzThjRWg6rB6FiycpxjMOurHEiOJO79rEwMILNL0/ncbiKC0CzAz STheaP0JGh0FjYHi42aNmomqPoqs3A4dBF3WMijsUBaQ6SwRlfUgfo1D7gWHv1RbSlM8 RxQoRAGby19vzPk5yv7/fkiQS7PFyC0IBOPb8sRKJIqdlzd2LzNLyrjPfbG6TXQTrHbs zCYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=6oOaMB/UTSXeF5QPT6/5LHPWXpkLpJtHXDzu2XZxCtc=; b=Yt31kmqJ1mbanxd2fzt9iRzpc89eYUkJpbZJN6Ruy28JrC0v8+xcq3Z+7XfOXpyQ+N WJGr4ansxG8MqeFzJH3xNeifejYpa6DtaPy68Wxxq09m7LIYW5Tc3AMVbHnKxH0RkgRr D0NScYSTiWgfDiN3p/Kgz/I2kmPtTqHwDOKP81UlHU/xICZS+9PLyYyjDef15bTT9OSj nYDt90xenGkcPXWUeCHnKDWB46JUhS3aW6o6RgenxEX10Zzry1gS1sTgvKGOOHiWK9RE PDmg+L5r1O273Qvpygu7x7Uv65vuIiwaYxh3RooD5il/9oOCHc0ivviYFbgumXuRSbPu mCrg== X-Gm-Message-State: ANoB5plwkGF198LV6TkxAbtZKriu/P0EODXi/iJ7k42UAu75b43bOAGP YY+N66VWKVtA2RJv1W5xii3KBIrio3/iryp9 X-Received: by 2002:a63:3157:0:b0:473:ef9c:e1e5 with SMTP id x84-20020a633157000000b00473ef9ce1e5mr632479pgx.241.1668152505447; Thu, 10 Nov 2022 23:41:45 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH for-8.0 v3 16/45] tcg: Replace TCG_TARGET_CALL_ALIGN_ARGS with TCG_TARGET_CALL_ARG_I64 Date: Fri, 11 Nov 2022 17:40:32 +1000 Message-Id: <20221111074101.2069454-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org For 32-bit hosts when TCG_TARGET_CALL_ALIGN_ARGS was set, use TCG_CALL_ARG_EVEN. For 64-bit hosts, TCG_TARGET_CALL_ALIGN_ARGS was silently ignored, so always use TCG_CALL_ARG_NORMAL. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.h | 2 +- tcg/arm/tcg-target.h | 2 +- tcg/i386/tcg-target.h | 1 + tcg/loongarch64/tcg-target.h | 2 +- tcg/mips/tcg-target.h | 3 ++- tcg/riscv/tcg-target.h | 6 +++++- tcg/s390x/tcg-target.h | 1 + tcg/sparc64/tcg-target.h | 1 + tcg/tci/tcg-target.h | 5 +++++ tcg/tcg.c | 6 ++++-- tcg/ppc/tcg-target.c.inc | 21 ++++++++------------- 11 files changed, 30 insertions(+), 20 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index e145d50fef..d9dd777caa 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -51,8 +51,8 @@ typedef enum { /* used for function call generation */ #define TCG_REG_CALL_STACK TCG_REG_SP #define TCG_TARGET_STACK_ALIGN 16 -#define TCG_TARGET_CALL_ALIGN_ARGS 1 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL /* optional instructions */ #define TCG_TARGET_HAS_div_i32 1 diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 56c1ac4586..09dd0550aa 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -88,8 +88,8 @@ extern bool use_neon_instructions; /* used for function call generation */ #define TCG_TARGET_STACK_ALIGN 8 -#define TCG_TARGET_CALL_ALIGN_ARGS 1 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN /* optional instructions */ #define TCG_TARGET_HAS_ext8s_i32 1 diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 00fcbe297d..42628a2791 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -98,6 +98,7 @@ typedef enum { #else #define TCG_TARGET_CALL_STACK_OFFSET 0 #endif +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL extern bool have_bmi1; extern bool have_popcnt; diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index a659c8d6fd..19d4c07170 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -92,8 +92,8 @@ typedef enum { /* used for function call generation */ #define TCG_REG_CALL_STACK TCG_REG_SP #define TCG_TARGET_STACK_ALIGN 16 -#define TCG_TARGET_CALL_ALIGN_ARGS 1 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL /* optional instructions */ #define TCG_TARGET_HAS_movcond_i32 0 diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 7669213175..bb7312aed4 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -83,10 +83,11 @@ typedef enum { #define TCG_TARGET_STACK_ALIGN 16 #if _MIPS_SIM == _ABIO32 # define TCG_TARGET_CALL_STACK_OFFSET 16 +# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN #else # define TCG_TARGET_CALL_STACK_OFFSET 0 +# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL #endif -#define TCG_TARGET_CALL_ALIGN_ARGS 1 /* MOVN/MOVZ instructions detection */ #if (defined(__mips_isa_rev) && (__mips_isa_rev >= 1)) || \ diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 11c9b3e4f4..2ab4b8d04a 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -81,8 +81,12 @@ typedef enum { /* used for function call generation */ #define TCG_REG_CALL_STACK TCG_REG_SP #define TCG_TARGET_STACK_ALIGN 16 -#define TCG_TARGET_CALL_ALIGN_ARGS 1 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#if TCG_TARGET_REG_BITS == 32 +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN +#else +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL +#endif /* optional instructions */ #define TCG_TARGET_HAS_movcond_i32 0 diff --git a/tcg/s390x/tcg-target.h b/tcg/s390x/tcg-target.h index 23e2063667..7e86791ff6 100644 --- a/tcg/s390x/tcg-target.h +++ b/tcg/s390x/tcg-target.h @@ -166,6 +166,7 @@ extern uint64_t s390_facilities[3]; /* used for function call generation */ #define TCG_TARGET_STACK_ALIGN 8 #define TCG_TARGET_CALL_STACK_OFFSET 160 +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_RET_NORMAL #define TCG_TARGET_EXTEND_ARGS 1 #define TCG_TARGET_HAS_MEMORY_BSWAP 1 diff --git a/tcg/sparc64/tcg-target.h b/tcg/sparc64/tcg-target.h index 8655acdbe5..44ac164b31 100644 --- a/tcg/sparc64/tcg-target.h +++ b/tcg/sparc64/tcg-target.h @@ -72,6 +72,7 @@ typedef enum { #define TCG_TARGET_STACK_ALIGN 16 #define TCG_TARGET_CALL_STACK_OFFSET (128 + 6*8 + TCG_TARGET_STACK_BIAS) #define TCG_TARGET_EXTEND_ARGS 1 +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL #if defined(__VIS__) && __VIS__ >= 0x300 #define use_vis3_instructions 1 diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index ceb36c4f7a..e11c293906 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -158,6 +158,11 @@ typedef enum { /* Used for function call generation. */ #define TCG_TARGET_CALL_STACK_OFFSET 0 #define TCG_TARGET_STACK_ALIGN 8 +#if TCG_TARGET_REG_BITS == 32 +# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN +#else +# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL +#endif #define HAVE_TCG_QEMU_TB_EXEC #define TCG_TARGET_NEED_POOL_LABELS diff --git a/tcg/tcg.c b/tcg/tcg.c index ec03bd3d6a..a23c5af1b7 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1541,9 +1541,11 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) * for passing off to ffi_call. */ want_align = true; -#elif defined(TCG_TARGET_CALL_ALIGN_ARGS) +#else /* Some targets want aligned 64 bit args */ - want_align = is_64bit; + if (is_64bit) { + want_align = TCG_TARGET_CALL_ARG_I64 == TCG_CALL_ARG_EVEN; + } #endif if (TCG_TARGET_REG_BITS < 64 && want_align && (real_args & 1)) { diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index e3dba47697..d1d6a40c6c 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -45,7 +45,9 @@ #endif #ifdef _CALL_SYSV -# define TCG_TARGET_CALL_ALIGN_ARGS 1 +# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN +#else +# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL #endif /* For some memory operations, we need a scratch that isn't R0. For the AIX @@ -2202,9 +2204,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) lo = lb->addrlo_reg; hi = lb->addrhi_reg; if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { -#ifdef TCG_TARGET_CALL_ALIGN_ARGS - arg |= 1; -#endif + arg |= (TCG_TARGET_CALL_ARG_I64 == TCG_CALL_ARG_EVEN); tcg_out_mov(s, TCG_TYPE_I32, arg++, hi); tcg_out_mov(s, TCG_TYPE_I32, arg++, lo); } else { @@ -2250,9 +2250,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) lo = lb->addrlo_reg; hi = lb->addrhi_reg; if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { -#ifdef TCG_TARGET_CALL_ALIGN_ARGS - arg |= 1; -#endif + arg |= (TCG_TARGET_CALL_ARG_I64 == TCG_CALL_ARG_EVEN); tcg_out_mov(s, TCG_TYPE_I32, arg++, hi); tcg_out_mov(s, TCG_TYPE_I32, arg++, lo); } else { @@ -2266,9 +2264,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) if (TCG_TARGET_REG_BITS == 32) { switch (s_bits) { case MO_64: -#ifdef TCG_TARGET_CALL_ALIGN_ARGS - arg |= 1; -#endif + arg |= (TCG_TARGET_CALL_ARG_I64 == TCG_CALL_ARG_EVEN); tcg_out_mov(s, TCG_TYPE_I32, arg++, hi); /* FALLTHRU */ case MO_32: @@ -2324,9 +2320,8 @@ static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { TCGReg arg = TCG_REG_R4; -#ifdef TCG_TARGET_CALL_ALIGN_ARGS - arg |= 1; -#endif + + arg |= (TCG_TARGET_CALL_ARG_I64 == TCG_CALL_ARG_EVEN); if (l->addrlo_reg != arg) { tcg_out_mov(s, TCG_TYPE_I32, arg, l->addrhi_reg); tcg_out_mov(s, TCG_TYPE_I32, arg + 1, l->addrlo_reg); From patchwork Fri Nov 11 07:40:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623722 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp633558pvb; Fri, 11 Nov 2022 00:27:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf7X6s8IYK2CMH/2X2uRKDqL/+SiFS6nDiRBW9A97TPWGQ3BuiogFwHpXjneLYYv6W8yx+X5 X-Received: by 2002:a05:622a:1f8e:b0:3a5:89c1:a4bf with SMTP id cb14-20020a05622a1f8e00b003a589c1a4bfmr421710qtb.387.1668155274095; Fri, 11 Nov 2022 00:27:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668155274; cv=none; d=google.com; s=arc-20160816; b=dAedywVT+H3CZ/fQCnKnU7eIldVE9UM+1pXjnAQU7VASQ+rtYN/0R5i4wPhmvCCVy9 Ov2azJuVmF7/T0HUHR2m/OpO3FQi5xnje1CUXD20KE2EICcATmLV8m6QYjw9+lJDUHqR 9l11vOwc2Mkh5cf4EfUFmAzW7R7ADHOJ5ReJo1OSROCvYkM0s9J3QxHeBn7x4aV61udV xafwOQO2wR/a1wzvsNtps/z6ED1bhRtz2l3q90dggXPn6i/E4Ot4417zGR3o+nRpxsdr JiNI7q1wU+6uYxAw3HgEItMU3PNQAVXqxVZIdxZb9t66leqR+TkFw0CdxSzHmkt9GisQ N3FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=20PLRuYTKO3Drl843or1+TFvXCIkhFXtY1RhfnvDMn4=; b=0aZ1haKKmlxpXBDzXsec7s8kubYsYKx6QpFO+vo5Yq5lzEn8O68FIL+IEDyfNmhbbH oMhhNQAqQXKpRzudMJex1sFO+teLb93VB6KWSwpyl3yjH3/VVAbkIE8tEm6wpqspmsQj FMP5g3/edeSW+0QaBDcfQVdGJB9ESfqzORi5cc68kjMVAt1hWpff8ebEKrM3euaNoiyS j1tBsC5fxQ7VFejvNImesoYPGnEokGvPOBDquZVKsjGIkJtFz4aFNAGdSQxoU1VpH18v MqTG5PCqOnLp4UgocOiBwlVQpBkTVBXmodZKb0Tqnw5Y2jCzNN/w0S9hP68k9oK46I+E j41Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z5d+XCNe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ed2-20020a05620a490200b006fb1672db16si695178qkb.562.2022.11.11.00.27.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:27:54 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z5d+XCNe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfr-0006bh-4x; Fri, 11 Nov 2022 02:42:03 -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 1otOfk-0006OC-3P for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:57 -0500 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfd-0008He-Bg for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:51 -0500 Received: by mail-pj1-x1036.google.com with SMTP id k5so3768401pjo.5 for ; Thu, 10 Nov 2022 23:41:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=20PLRuYTKO3Drl843or1+TFvXCIkhFXtY1RhfnvDMn4=; b=Z5d+XCNe13fdezXz89C6PAvmYxygINZKy+eSH6a2IrFzyYX1DWOPE469NKitm0IJFS OiWVRfHY9WdA7EAhP2jDoyUHAI9rehdYjY0ZH0a/pQX+JVi7uavydCvRFoIQy1bjdTXc FJsXa1jj3VSneNQW+xG8PDNWFLGMSvr0rYRVB1aNUxWEJ2eYCGUH5AfeB5m0Pkin2/fE bCQ5Z/Hrr6V2dx7UsQw7B0Do61qZURw7zjU57qjvDIAqpGXk6qRn/LJNXIBnzbb6y1uI zUQpXvHTHCL4u5CvTavqv7ZBvB2Z+pOt75IQQVu+xZeRznHI9DM1vAMm0SmTOmfIaL7d /dCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=20PLRuYTKO3Drl843or1+TFvXCIkhFXtY1RhfnvDMn4=; b=AiGovyX9dp5tGQ0v8tVO9C6BH6JefDv8OhjFx0FO51BNg4gIfXUwENGssEGtSOGVx+ dcqUOqiY5C1tXcg+kl4bOx3mdk5BkUhG8DVs2YxMzx0WIcVRJdwmsda7USSSh2h4AqKs utgv3d6Z8OVDlwXqDKR/XX3yS456eInEhl/YyLXUMcoG91AGqlIpQ0znKHY8I4MUGrF8 0Hl+CrXgi2/N7m9qjeWnnHREFovSoAZ7Z+wTPzJ+AuGH1Hyb/MgdpyuBAfzWAkst97ue a8YnTvI2gpJIWrsL/qCQgrsShL5QsgKcU5fx00Oba3s+9eE4e1j0wm5u+zARhFER7v5q 7+Ow== X-Gm-Message-State: ANoB5pnZWsITgZNPRhhoghl86A+ahKdTstmtvEyOVdQeue32lOZcgBVx ZhZ5C9sXR7nqOXCmkLaeZie8Bk+pU1YEY71t X-Received: by 2002:a17:90b:d86:b0:213:5dd:f523 with SMTP id bg6-20020a17090b0d8600b0021305ddf523mr653566pjb.63.1668152508087; Thu, 10 Nov 2022 23:41:48 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH for-8.0 v3 17/45] tcg: Replace TCG_TARGET_EXTEND_ARGS with TCG_TARGET_CALL_ARG_I32 Date: Fri, 11 Nov 2022 17:40:33 +1000 Message-Id: <20221111074101.2069454-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org For 64-bit hosts that had TCG_TARGET_EXTEND_ARGS, set TCG_TARGET_CALL_ARG_I32 to TCG_CALL_ARG_EXTEND. Otherwise, use TCG_CALL_ARG_NORMAL. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.h | 1 + tcg/arm/tcg-target.h | 1 + tcg/i386/tcg-target.h | 1 + tcg/loongarch64/tcg-target.h | 1 + tcg/mips/tcg-target.h | 1 + tcg/riscv/tcg-target.h | 1 + tcg/s390x/tcg-target.h | 2 +- tcg/sparc64/tcg-target.h | 2 +- tcg/tci/tcg-target.h | 1 + tcg/tcg.c | 42 ++++++++++++++++++------------------ tcg/ppc/tcg-target.c.inc | 6 +++++- 11 files changed, 35 insertions(+), 24 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index d9dd777caa..413a5410c5 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -52,6 +52,7 @@ typedef enum { #define TCG_REG_CALL_STACK TCG_REG_SP #define TCG_TARGET_STACK_ALIGN 16 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL /* optional instructions */ diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 09dd0550aa..b7843d2d54 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -89,6 +89,7 @@ extern bool use_neon_instructions; /* used for function call generation */ #define TCG_TARGET_STACK_ALIGN 8 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN /* optional instructions */ diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 42628a2791..7edb7f1d9a 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -98,6 +98,7 @@ typedef enum { #else #define TCG_TARGET_CALL_STACK_OFFSET 0 #endif +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL extern bool have_bmi1; diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index 19d4c07170..e5f7a1f09d 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -93,6 +93,7 @@ typedef enum { #define TCG_REG_CALL_STACK TCG_REG_SP #define TCG_TARGET_STACK_ALIGN 16 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL /* optional instructions */ diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index bb7312aed4..15721c3e42 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -88,6 +88,7 @@ typedef enum { # define TCG_TARGET_CALL_STACK_OFFSET 0 # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL #endif +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL /* MOVN/MOVZ instructions detection */ #if (defined(__mips_isa_rev) && (__mips_isa_rev >= 1)) || \ diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 2ab4b8d04a..232537ccea 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -82,6 +82,7 @@ typedef enum { #define TCG_REG_CALL_STACK TCG_REG_SP #define TCG_TARGET_STACK_ALIGN 16 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #if TCG_TARGET_REG_BITS == 32 #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN #else diff --git a/tcg/s390x/tcg-target.h b/tcg/s390x/tcg-target.h index 7e86791ff6..db5665c375 100644 --- a/tcg/s390x/tcg-target.h +++ b/tcg/s390x/tcg-target.h @@ -166,9 +166,9 @@ extern uint64_t s390_facilities[3]; /* used for function call generation */ #define TCG_TARGET_STACK_ALIGN 8 #define TCG_TARGET_CALL_STACK_OFFSET 160 +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_EXTEND #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_RET_NORMAL -#define TCG_TARGET_EXTEND_ARGS 1 #define TCG_TARGET_HAS_MEMORY_BSWAP 1 #define TCG_TARGET_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD) diff --git a/tcg/sparc64/tcg-target.h b/tcg/sparc64/tcg-target.h index 44ac164b31..0044ac8d78 100644 --- a/tcg/sparc64/tcg-target.h +++ b/tcg/sparc64/tcg-target.h @@ -71,7 +71,7 @@ typedef enum { #define TCG_TARGET_STACK_BIAS 2047 #define TCG_TARGET_STACK_ALIGN 16 #define TCG_TARGET_CALL_STACK_OFFSET (128 + 6*8 + TCG_TARGET_STACK_BIAS) -#define TCG_TARGET_EXTEND_ARGS 1 +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_EXTEND #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL #if defined(__VIS__) && __VIS__ >= 0x300 diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index e11c293906..d6e0450ed8 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -158,6 +158,7 @@ typedef enum { /* Used for function call generation. */ #define TCG_TARGET_CALL_STACK_OFFSET 0 #define TCG_TARGET_STACK_ALIGN 8 +#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #if TCG_TARGET_REG_BITS == 32 # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN #else diff --git a/tcg/tcg.c b/tcg/tcg.c index a23c5af1b7..b43a5200ad 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1493,24 +1493,24 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) } #endif -#if defined(TCG_TARGET_EXTEND_ARGS) && TCG_TARGET_REG_BITS == 64 - for (i = 0; i < nargs; ++i) { - int argtype = extract32(typemask, (i + 1) * 3, 3); - bool is_32bit = (argtype & ~1) == dh_typecode_i32; - bool is_signed = argtype & 1; + if (TCG_TARGET_CALL_ARG_I32 == TCG_CALL_ARG_EXTEND) { + for (i = 0; i < nargs; ++i) { + int argtype = extract32(typemask, (i + 1) * 3, 3); + bool is_32bit = (argtype & ~1) == dh_typecode_i32; + bool is_signed = argtype & 1; - if (is_32bit) { - TCGv_i64 temp = tcg_temp_new_i64(); - TCGv_i32 orig = temp_tcgv_i32(args[i]); - if (is_signed) { - tcg_gen_ext_i32_i64(temp, orig); - } else { - tcg_gen_extu_i32_i64(temp, orig); + if (is_32bit) { + TCGv_i64 temp = tcg_temp_new_i64(); + TCGv_i32 orig = temp_tcgv_i32(args[i]); + if (is_signed) { + tcg_gen_ext_i32_i64(temp, orig); + } else { + tcg_gen_extu_i32_i64(temp, orig); + } + args[i] = tcgv_i64_temp(temp); } - args[i] = tcgv_i64_temp(temp); } } -#endif /* TCG_TARGET_EXTEND_ARGS */ op = tcg_emit_op(INDEX_op_call); @@ -1571,16 +1571,16 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) tcg_debug_assert(TCGOP_CALLI(op) == real_args); tcg_debug_assert(pi <= ARRAY_SIZE(op->args)); -#if defined(TCG_TARGET_EXTEND_ARGS) && TCG_TARGET_REG_BITS == 64 - for (i = 0; i < nargs; ++i) { - int argtype = extract32(typemask, (i + 1) * 3, 3); - bool is_32bit = (argtype & ~1) == dh_typecode_i32; + if (TCG_TARGET_CALL_ARG_I32 == TCG_CALL_ARG_EXTEND) { + for (i = 0; i < nargs; ++i) { + int argtype = extract32(typemask, (i + 1) * 3, 3); + bool is_32bit = (argtype & ~1) == dh_typecode_i32; - if (is_32bit) { - tcg_temp_free_internal(args[i]); + if (is_32bit) { + tcg_temp_free_internal(args[i]); + } } } -#endif /* TCG_TARGET_EXTEND_ARGS */ } static void tcg_reg_alloc_start(TCGContext *s) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index d1d6a40c6c..500b75a03a 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -44,6 +44,11 @@ # endif #endif +#if TCG_TARGET_REG_BITS == 64 +# define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_EXTEND +#else +# define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL +#endif #ifdef _CALL_SYSV # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN #else @@ -2520,7 +2525,6 @@ static void tcg_out_nop_fill(tcg_insn_unit *p, int count) /* Parameters for function call generation, used in tcg.c. */ #define TCG_TARGET_STACK_ALIGN 16 -#define TCG_TARGET_EXTEND_ARGS 1 #ifdef _CALL_AIX # define LINK_AREA_SIZE (6 * SZR) From patchwork Fri Nov 11 07:40:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623728 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp636328pvb; Fri, 11 Nov 2022 00:34:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf62Iqxe6qaMRkr664Z7ysoORxfqWHAYBQ4OzvOB9t/v6YUPxCUlubVPUhqDwZJz7OORnG76 X-Received: by 2002:a37:e20e:0:b0:6fa:7e04:5f2c with SMTP id g14-20020a37e20e000000b006fa7e045f2cmr252721qki.471.1668155697827; Fri, 11 Nov 2022 00:34:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668155697; cv=none; d=google.com; s=arc-20160816; b=G4AfXdJjXAuJwgMMZVhkNz99f5KcmwYNpvWaBKdiA9iaKxl4j0PajM0sbv2JkBGA89 wGcDnkmPozkYeE/vUcWV3f/hpkj2Y7J9M7F6G9K4tNJ4oHtnXXl5xEDjqXaworT/Y5l5 zO7qw2+gTXKbD53vgXf/TVd/5BrDiX0cNjr4VWxMSiEeP0VlDrg0k6P7J6/k/Z2EXvVy QgD0OdjHPiA6jBc0QLSsuYwGoQY9H8zMZxJMoDB+Sb/s4H3hUSOSxCYsviQB87l19DTk EW4F44aaHqLVqphnOAwZ1AUqydpRPMDuLiG0MvFsSxvu6tXRPy+PPJc9IU05YPa64UpH U9Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3IvH3a4hJ5hvV/BTIYuq60e5ApjpQFWGSwmOpPcPvBI=; b=prsOkQz1BGbb/IVoWWxzjs82jEoHqULwmyvpG3KHNlp3Z5Mw49H2UY4eJrmsKSzCIK WLqbgQ9nBuMwidYiKpNDo5aeJhaBvYvigultq67T1NNSHj/a46D+XdWgtYNi6SWy417u Psp6KMdsW+SG6FGFf8ArdmzK0+ceQtkOyuhAqqNFbGy8fHqYESmMday1dU2Mu10pkHwt nYSP4R7XQ6EkS1bKUUTxWCYsPdWjDDedo6IDr6zU0emag9EOSYts8gC5riLw0GA2V2RE dtweZ/8ZsRYY/hvHS+P367J/Ee+5pM53VmJp4NxDEarpdihE8GrZjJ7v4Cc1I7mqaUSW aRlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mYwePqDr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bl20-20020a05620a1a9400b006fa0774280fsi779115qkb.119.2022.11.11.00.34.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:34:57 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mYwePqDr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfr-0006cY-Tn; Fri, 11 Nov 2022 02:42:03 -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 1otOfm-0006Pw-N2 for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:58 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfj-0008MR-IJ for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:58 -0500 Received: by mail-pj1-x1029.google.com with SMTP id gw22so3777665pjb.3 for ; Thu, 10 Nov 2022 23:41:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=3IvH3a4hJ5hvV/BTIYuq60e5ApjpQFWGSwmOpPcPvBI=; b=mYwePqDrxJW27cYki/BTL9fKArrn7YgP/vvcBtQOztuZd4qUG75LmplrKEdY3AnEd3 bL6EtqhEzP9OSopPA3dY9mS5sAncSKkOYhkXQi7LK3qcHGTK4TamcoWgRdE+qbn/fbrq 2OI5fUYEcxCZtL3YGx9YVKLDSCL7OOzunN8f4wO3WlBMo94ZLaGpmEmifuYXkieUxKBp BCeF0Rx5NOrSogpQjf53LgbkaacH1fUB2CeC06vhtXiEYQrMoMMLt2eQcojficrscIZJ Njp2C0d1d23zmh+CofLtdw82d519MVfyR7DRtKnJ2/jrPlB1wdF0ceQqO48M1IwP82Ve YGvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=3IvH3a4hJ5hvV/BTIYuq60e5ApjpQFWGSwmOpPcPvBI=; b=AHPkLgESqE2QGxNXRN8nbbP0iAXKT+DtaDhnwu41GJnq5VYJNyHsrkFfQxDG3WxqLY War5qZ5PVCDSldTOczuAH4Yf+GYGWxeRhYDCHO1X0+1ITA0bwiTYMtVuAPEAoxShFTNV Tdce2+qKssu4q2s+WmDits/8vQKrx0puCukfuk1InH34+OLvDfLMGYALBKjrfLaLryzw M/mxzL2Sn8BsF/ovTJ7ESYTpD6yZU3VcztsCGCz3agVwSAILIZHWxPC+xaeJnxD11On6 iPPl48crcSd7vHXWPkdyJ3p5RUXtfhv0CjM2mLAtqq3Odak5oRHl5SdLE0kL0l0aVCAo jX+w== X-Gm-Message-State: ANoB5pmcoOoGMiDGNsSIQIa5JKVPij6S0QV4BKLsVSyRBnQ133WK0dKj ip0w+MV0ZsTWJv+Em10VauX4jyt9dReqI6Yo X-Received: by 2002:a17:90a:14a4:b0:212:d62a:aeb8 with SMTP id k33-20020a17090a14a400b00212d62aaeb8mr558889pja.221.1668152510557; Thu, 10 Nov 2022 23:41:50 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH for-8.0 v3 18/45] tcg: Use TCG_CALL_ARG_EVEN for TCI special case Date: Fri, 11 Nov 2022 17:40:34 +1000 Message-Id: <20221111074101.2069454-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Change 32-bit tci TCG_TARGET_CALL_ARG_I32 to TCG_CALL_ARG_EVEN, to force 32-bit values to be aligned to 64-bit. With a small reorg to the argument processing loop, this neatly replaces an ifdef for CONFIG_TCG_INTERPRETER. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tci/tcg-target.h | 3 ++- tcg/tcg.c | 62 ++++++++++++++++++++++++++------------------ 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index d6e0450ed8..94ec541b4e 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -158,10 +158,11 @@ typedef enum { /* Used for function call generation. */ #define TCG_TARGET_CALL_STACK_OFFSET 0 #define TCG_TARGET_STACK_ALIGN 8 -#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #if TCG_TARGET_REG_BITS == 32 +# define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_EVEN # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN #else +# define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL #endif diff --git a/tcg/tcg.c b/tcg/tcg.c index b43a5200ad..b4d0ad8a17 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1532,36 +1532,48 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) real_args = 0; for (i = 0; i < nargs; i++) { int argtype = extract32(typemask, (i + 1) * 3, 3); - bool is_64bit = (argtype & ~1) == dh_typecode_i64; - bool want_align = false; + TCGCallArgumentKind kind; + TCGType type; -#if defined(CONFIG_TCG_INTERPRETER) - /* - * Align all arguments, so that they land in predictable places - * for passing off to ffi_call. - */ - want_align = true; -#else - /* Some targets want aligned 64 bit args */ - if (is_64bit) { - want_align = TCG_TARGET_CALL_ARG_I64 == TCG_CALL_ARG_EVEN; - } -#endif - - if (TCG_TARGET_REG_BITS < 64 && want_align && (real_args & 1)) { - op->args[pi++] = TCG_CALL_DUMMY_ARG; - real_args++; + switch (argtype) { + case dh_typecode_i32: + case dh_typecode_s32: + type = TCG_TYPE_I32; + kind = TCG_TARGET_CALL_ARG_I32; + break; + case dh_typecode_i64: + case dh_typecode_s64: + type = TCG_TYPE_I64; + kind = TCG_TARGET_CALL_ARG_I64; + break; + case dh_typecode_ptr: + type = TCG_TYPE_PTR; + kind = TCG_CALL_ARG_NORMAL; + break; + default: + g_assert_not_reached(); } - if (TCG_TARGET_REG_BITS < 64 && is_64bit) { + switch (kind) { + case TCG_CALL_ARG_EVEN: + if (real_args & 1) { + op->args[pi++] = TCG_CALL_DUMMY_ARG; + real_args++; + } + /* fall through */ + case TCG_CALL_ARG_NORMAL: + if (TCG_TARGET_REG_BITS == 32 && type == TCG_TYPE_I64) { + op->args[pi++] = temp_arg(args[i]); + op->args[pi++] = temp_arg(args[i] + 1); + real_args += 2; + break; + } op->args[pi++] = temp_arg(args[i]); - op->args[pi++] = temp_arg(args[i] + 1); - real_args += 2; - continue; + real_args++; + break; + default: + g_assert_not_reached(); } - - op->args[pi++] = temp_arg(args[i]); - real_args++; } op->args[pi++] = (uintptr_t)func; op->args[pi++] = (uintptr_t)info; From patchwork Fri Nov 11 07:40:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623688 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp619288pvb; Thu, 10 Nov 2022 23:52:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf6dcJYQODMOeCWyle0NSR5oNEXYjZaLHkbEgl7+hnPPUid3SJ+7vhMpadxYQt5mSCwoO9qK X-Received: by 2002:a05:6214:1630:b0:4b1:d52d:3c29 with SMTP id e16-20020a056214163000b004b1d52d3c29mr959752qvw.68.1668153155239; Thu, 10 Nov 2022 23:52:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668153155; cv=none; d=google.com; s=arc-20160816; b=vHXrM9Pr9qPrVRGfclZDKWUH/9oNzzwf5zDUy0yKPmjPZH7eil2OH+eTDmDRFgd9tb HbqpT6k/YoxroSnW2jk8seIv1YUv/+miB+xtaGvj0MMFNwU8jEYf45RUmUwtLTdMERyX nuSsuYwWvDm0jSv10h03FelxLNuQtGDLnocPfpsvbgcSNsulCsaTmBl0pI1PMCQxtHQs SdW1LfQGnV95jTGIk5notIdnZGv/yEtmWkUD78A/vkb3lOUnz2TAy2SStTGa41aLTRTq SzNXsPylekNjKRl4upQuiu/rlKRjKCNP5GkEAm0BOqt7h3mTrIkorzj5OIOWdy80j2Vl kamA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=y8WEsTTyeGQR6dZ2OaXpTAI/FZ+2tdaCITo/e1JRHd4=; b=s4T7Hkqs4LODI1tCFxhqa/Cgbi4S52emdppyQML1cVpQgG4A4I4HHxXeqBWQX+JGEY 91D1eu5x7GJoZjv60UqXN7+Gy9M3xiejU15mXVDBHwKilRrlFf6P1QGFSSo2EbL092X0 yyKDwvIGE76OJvbAOPUFaqPo6Aszi7ORGXlZ5DosXA1BP0S9iAgOQWesLxWxvY96V3eq eRJGIs5jHTYFeSl4MbqdImthpdc5ozEYFE4s9l3UDtHzaDXmtuJnJboJhdfUKbsGrtqR PQS7wLBC0bE99dkxzjTm+9IBWxV7bzriGbCprtdFzVx3cVQAer+GGsUWX04L/5Z3aDlm 2KNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jiHVK5gV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d5-20020a05621421c500b004aa73d9f4dcsi649584qvh.295.2022.11.10.23.52.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:52:35 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jiHVK5gV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfp-0006Xh-3R; Fri, 11 Nov 2022 02:42:01 -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 1otOfm-0006PW-Br for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:58 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfj-0007q4-IN for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:58 -0500 Received: by mail-pl1-x632.google.com with SMTP id y4so3644020plb.2 for ; Thu, 10 Nov 2022 23:41:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=y8WEsTTyeGQR6dZ2OaXpTAI/FZ+2tdaCITo/e1JRHd4=; b=jiHVK5gVUs5ScMiO5cnvRwM3PLSds5+MY+21m9e7V5IWtOZyf+UuOlj55Wb2YdojK+ GZ3twK1duIBxQJLv8ITaKZmdSIqDAVwPliFA3WBXTjcrJqGcIrCzX+t0x433Wb6VoisH t3hjFRlo+DrY7T5NFufnmZ4y45acgODdPJigxbtqKRQTsURvdkB2PzLTW/Yxv9KvHEhW Y6ObvBBn8VZvbKSCB/DPSkkDc5kqaOgCTsuVEj1jKUwMPsEFk8XNKKdEsDU3YgUuK/HD q1MH0nQkcU31XDK1DRqAnQr/Kj9HMvGrfjxBOGyWNO6YZiWyIPv7Uc9skH2r0B2kQkQN jzfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y8WEsTTyeGQR6dZ2OaXpTAI/FZ+2tdaCITo/e1JRHd4=; b=JBtVt3+UR5xjEh2Nw5jdpNu7rxiR7KQjexmWJjQDty2uDxLyaG9vqySU6HiCkA/0kA pjI/jBudiKYuWaD3dm64KYtwOIlZZBCNcontcwBWwKFM/OSijRoHBaJb0vZQb4VEpbr8 xxL3022N9IWwdRmSjbUA+J9HNo/3D3u77Ofl750QtSjdbrF7Km/q79iPMARWi7kFtDrU 2P416FKZe7KMkmtil8FBJyO1Cl0JoJr9utnX6nrJrzqGSf5IARymS5c0tx5uVfDcdxNi KYn4g9446GmI44tYh8ZQNoikjH9pY8Yw5UmFmcm+sQPRG1czkDy4UODD6DwR7+q1WXLI 0M7w== X-Gm-Message-State: ANoB5pmjElxvy1jxtnaGd5iAXnlnYGyLQi/KfJ+jr4ENUlXVHlf2Wdh+ hiBtG2LCUuw//86+0Z16Wqfja0xLSSTJWPm5 X-Received: by 2002:a17:902:7b96:b0:188:53bd:878a with SMTP id w22-20020a1709027b9600b0018853bd878amr1493597pll.12.1668152512863; Thu, 10 Nov 2022 23:41:52 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 19/45] accel/tcg/plugin: Don't search for the function pointer index Date: Fri, 11 Nov 2022 17:40:35 +1000 Message-Id: <20221111074101.2069454-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The function pointer is immediately after the output and input operands; no need to search. Signed-off-by: Richard Henderson --- accel/tcg/plugin-gen.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 80dff68934..9e359c006a 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -381,32 +381,25 @@ static TCGOp *copy_st_ptr(TCGOp **begin_op, TCGOp *op) static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, void *empty_func, void *func, int *cb_idx) { + TCGOp *old_op; + int func_idx; + /* copy all ops until the call */ do { op = copy_op_nocheck(begin_op, op); } while (op->opc != INDEX_op_call); /* fill in the op call */ - op->param1 = (*begin_op)->param1; - op->param2 = (*begin_op)->param2; + old_op = *begin_op; + TCGOP_CALLI(op) = TCGOP_CALLI(old_op); + TCGOP_CALLO(op) = TCGOP_CALLO(old_op); tcg_debug_assert(op->life == 0); - if (*cb_idx == -1) { - int i; - /* - * Instead of working out the position of the callback in args[], just - * look for @empty_func, since it should be a unique pointer. - */ - for (i = 0; i < MAX_OPC_PARAM_ARGS; i++) { - if ((uintptr_t)(*begin_op)->args[i] == (uintptr_t)empty_func) { - *cb_idx = i; - break; - } - } - tcg_debug_assert(i < MAX_OPC_PARAM_ARGS); - } - op->args[*cb_idx] = (uintptr_t)func; - op->args[*cb_idx + 1] = (*begin_op)->args[*cb_idx + 1]; + func_idx = TCGOP_CALLO(op) + TCGOP_CALLI(op); + *cb_idx = func_idx; + + op->args[func_idx] = (uintptr_t)func; + op->args[func_idx + 1] = old_op->args[func_idx + 1]; return op; } From patchwork Fri Nov 11 07:40:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623707 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp628980pvb; Fri, 11 Nov 2022 00:15:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf4iilCmRz6MnY6KN2hj2d9jVw2sqt2p9xEk3gfasW48RKyOB2nDwiJPVMLpb7K2i748P8z6 X-Received: by 2002:a37:84b:0:b0:6f9:ffc7:a9e4 with SMTP id 72-20020a37084b000000b006f9ffc7a9e4mr239611qki.277.1668154508303; Fri, 11 Nov 2022 00:15:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668154508; cv=none; d=google.com; s=arc-20160816; b=b8KJY0p1DIPVPLQfI9SP7xOrZTEx/kyemVJPwQKWNZUkb59dkqjYxvatN0rNec7kRC L1sitf08RjAA5HSg8IJwYUapK+bW4PSLJz4N8Oefj0eRjVQFc1W9QOqPr3oAxg6qapGX SrO7tc8QeqzPMYJ6Pm3R5Hsra5+nfwsuwzUDJXQPE8KIJAvbrxZ7YSyfy4OAMOR18Bl9 iclt5Vc4N2qoxkYTGBHTUE0mqnmrYojmO3Rkp3RHm3eGdFgFG80X+2hhwzk/CeA6CEO9 djjtXwB6TFm4ZVWPpv5r6YeZxJ1yoiYblzVS13VXLpM9oge71zC2udBVKlxhW7EWZIEU ebag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=KbxYnYMZOdgUIKzB3W7e4WMSmPoKgVqMloJtF9P8blQ=; b=X7j7T9kfcekk4aTFLEUuv3PW7nnUv5clcGschQdGyJnCEE8pWbaAVvywmORyPHM0c5 weUsjBNfmVys4baIPoFih92/3vJaPNNlbODZfk7WnvPEPH6MZzqhWPUk5VK/jlilBdFo 99FKgYXtzrDiBYgWUcboWi67dNwV03/alZ6Qyqj6fUwLwn6HliE6+3LLrUYFsLmP1dIU Z8eaXx0gI0K9NsxuOLxmFFpBlTf4MVNLyTTAyI7m37XERZuWyhDSiG/ONTeJl1Hx0ZF/ bKR0SIJ26dog/UEdLeXRekFwA19SnqIO/qzCFWwE1ad91uZCoi3atF3PwnfgyQ2RebK/ iJSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JIq3MuhG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h17-20020ac87d51000000b003a50cd2492bsi761260qtb.457.2022.11.11.00.15.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:15:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JIq3MuhG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfs-0006dY-Ne; Fri, 11 Nov 2022 02:42:04 -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 1otOfn-0006Qr-Eu for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:59 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfk-0007wx-Vn for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:59 -0500 Received: by mail-pl1-x630.google.com with SMTP id c2so3606800plz.11 for ; Thu, 10 Nov 2022 23:41:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=KbxYnYMZOdgUIKzB3W7e4WMSmPoKgVqMloJtF9P8blQ=; b=JIq3MuhGP0xwgKD7RVZhZAtekwztkmgNKhrEPRscQ4bjdpIqzEhyDZ3b5upHGgqZ9e yebruR2XNtCPWMqgPS6jQbXCc7Ebx+YcTL4NtP7lnJvT2/d8/syi0oSgMhIkW7Ic3JZr LrgfBv3g1jcMGAHOiT7Mor9WbwA73XOG9j6FA55975u+1MMzLyln1xkR4czbz6MTi/Ql BIApSoav1vWNmEWep6k0FAIpMYiz0yT5bkozL91vutXmIqMmrUYx59iSuEU5UPf1v4ll yDxD6KkyOzqA03i371UnA4f/6Q8tq6dXYMzzsLgqBa57FQDHRYSrldz7ONnjbR+gv/dM YKKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KbxYnYMZOdgUIKzB3W7e4WMSmPoKgVqMloJtF9P8blQ=; b=xH5kfjGuFH3g0kK+Llg0NQLAlK42epzLQ5ECn1nmf7ch+k61M9K7C4oJly9kNhi5QX 4VaYxcDS+mAGqRHP/YU3UhJh2qq9WP8BdM1GXVDp8jwBpPtpyWn7LoMFqreUzhQgqfC3 spDq707be8/9xz4FsRf1VxHzRCExDhjXi6D7DiglM6jarKbfeZCzWj8PQQEIfHeSRB/v 57y7vV9lvYxf5elRn69/ZX6gaNbKgWf3ZcsQ4OvLcSqUXPyu1gnottLZhOSyaw7U34Bk Vlc7Yiw8Mlvlmbq8lFJf5NbhEKLZxvQgrKvFAIb1XPV5Skmx87L8sbDTNb3aK88XNSyW tDOw== X-Gm-Message-State: ANoB5pnFvzUZfUlTA4lTcnjoc0Uo4nUQpgjM6gm7NRIXbkLjv2qL9S3Q TMHNKrExEU9IlZKQ30XS4FLMbiP0BuxAh037 X-Received: by 2002:a17:90a:ac11:b0:213:f398:ed51 with SMTP id o17-20020a17090aac1100b00213f398ed51mr575046pjq.216.1668152514904; Thu, 10 Nov 2022 23:41:54 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 20/45] accel/tcg/plugin: Avoid duplicate copy in copy_call Date: Fri, 11 Nov 2022 17:40:36 +1000 Message-Id: <20221111074101.2069454-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We copied all of the arguments in copy_op_nocheck. We only need to replace the one argument that we change. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- accel/tcg/plugin-gen.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 9e359c006a..77e6823d6b 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -397,9 +397,7 @@ static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, void *empty_func, func_idx = TCGOP_CALLO(op) + TCGOP_CALLI(op); *cb_idx = func_idx; - op->args[func_idx] = (uintptr_t)func; - op->args[func_idx + 1] = old_op->args[func_idx + 1]; return op; } From patchwork Fri Nov 11 07:40:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623687 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp619265pvb; Thu, 10 Nov 2022 23:52:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf5n+03PVpqWKSxyrD9wEvEceIw218DW6och2XiVyXKoZnXYHArO9aU4x3tYQs3kMZhCR7Pd X-Received: by 2002:a05:622a:346:b0:3a5:3029:eb12 with SMTP id r6-20020a05622a034600b003a53029eb12mr343663qtw.412.1668153151183; Thu, 10 Nov 2022 23:52:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668153151; cv=none; d=google.com; s=arc-20160816; b=zyIzWEzFK1CeW54K9zwNNHgzNYtdgwE6+K9KESUHpPpRlpkt78PjVcAM8oYUz89oVe twgsl19Y5Fec46sXYXZvnU/PzJpJvjjCJ0pohOmkwp8z4rfH/90fp2MWcmvO2oxe55fP CsGTTafQGQOSAgX08KgFpfJpjBsg1tadXq1Nxad33BUU2k3wapvbVGHwBmnfTZmO9dY9 YGeNR6jUg5/FR2+Fir0ZcCcZti6CY3eS3y2lQGidKrQxO84nWSUC3sr8vAlfrboDxja7 QIXub7Bkh5ZPwnhC0nVmbTct3jCDgQ+FkXrSMh8DajLzBTO6fuRPxO5VT3FAfgu4SctX OQJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=hLmDMZ6Q2dYQvv5OiwJz7cIfL/6TjT5fPdV3Xfp0DQ4=; b=GRrd+GiiZ6Hw/5oRaovtSMRPo5ZOckWU8yNoGOnwauFE436SM10UNSPYRg8Gdh2ajV aroj4JyYZLJ0Mr2F2JoHtlaTONxcq7QZ1Skxx21gdVsUW0gqI8vqMWBz98niELZVKmFU dEhvZAVDCFd/IYTVsZa7Dz5oobzRRKrAvSYS4B8PUfbc4+B9tuDDPNG7dIT/RxVTlPRe +VG6Ak5icPva3v090w4xDXKIEA4fqedZiT4VgMV330he7+XXP7h6o35g0vwRduEyMGWx 2vBUIYsQuCETwnMdgovztUEB472f+hF02AlIDfHecjDF8W4AX+OJ09zFfW5mZGc4cIJN zHoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VcHJ+uLk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v15-20020ad4528f000000b004bb607cf844si570450qvr.134.2022.11.10.23.52.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:52:31 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VcHJ+uLk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOfs-0006cm-58; Fri, 11 Nov 2022 02:42:04 -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 1otOfo-0006RP-1L for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:00 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfm-0008TL-DM for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:41:59 -0500 Received: by mail-pj1-x1034.google.com with SMTP id b1-20020a17090a7ac100b00213fde52d49so4042615pjl.3 for ; Thu, 10 Nov 2022 23:41:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=hLmDMZ6Q2dYQvv5OiwJz7cIfL/6TjT5fPdV3Xfp0DQ4=; b=VcHJ+uLkTnF3d7zgP8Ry046aISww/6Hd1Udnlqkop4/nuqhVmcuoFvjfEbOg1xblFP JTdPaOEYFAopzw2AFQu1CYpNONovTGo3XamBGBL8S6QYn8+T+/uAlBYhrv7mlAcTo4RJ 1QLCcYa50wpkYACjH0mREYjXRXtVnv3JtFR7x7OcNWNsvBYQkmS/2y+2MEp9F84pdyvP Sh3xDgAGUKF8/P6XwCovZmRUAr7PoNay+49e07zVw5WwiL7ydTlplaOKKN8+KbjHwUqh Eh0GtTTWyHTxyjSOsfGTFoWkx8SmcUn2cPx5KdnlYRcfilCgRpnn7Dl7eNKfQN4bd0SA CQZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hLmDMZ6Q2dYQvv5OiwJz7cIfL/6TjT5fPdV3Xfp0DQ4=; b=uOhPJOzCOBRSEoiNkDsFP+iJ2GN+QbRPrmJmqn9bKG9nXadwNN+BlHS0QJpO6dHFaG sOoKrWuyZDUup8gamBVJbjewYCeNKSnOGtssAiDhG5pAnlCcnIxtkHPTpEi2+vWJJDYZ FAVE+dCXnCzR0YnG+rr/hiPhm0ISfH6J6j3TA36ATbKUOjmfA+HtmRDjeJRv+gcP/IVw daw5fht7eIiVx9JzNMqMxeBfBMmy+++JVG08V+k2h12ee0WQdPiGjEbO55ny7SLkBUT9 Sdsg+5URboC0F3VkOuSYtv93q8pIEmh3vewuLH6id20GaWQuj1yBMzMDdhoOazgvgrau WVhg== X-Gm-Message-State: ANoB5pmja5JCC+KzdJMcLXfE5ugT6DKF2W9hXSY/pfALQ9w1MkVfa5lQ BwlQziExVoBVjRWJHaD84pO/rqZ1G70zZz7V X-Received: by 2002:a17:902:9b96:b0:186:8558:ded2 with SMTP id y22-20020a1709029b9600b001868558ded2mr1400707plp.95.1668152516965; Thu, 10 Nov 2022 23:41:56 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 21/45] accel/tcg/plugin: Use copy_op in append_{udata, mem}_cb Date: Fri, 11 Nov 2022 17:40:37 +1000 Message-Id: <20221111074101.2069454-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Better to re-use the existing function for copying ops. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- accel/tcg/plugin-gen.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 77e6823d6b..a6aaacd053 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -415,11 +415,11 @@ static TCGOp *append_udata_cb(const struct qemu_plugin_dyn_cb *cb, op = copy_const_ptr(&begin_op, op, cb->userp); /* copy the ld_i32, but note that we only have to copy it once */ - begin_op = QTAILQ_NEXT(begin_op, link); - tcg_debug_assert(begin_op && begin_op->opc == INDEX_op_ld_i32); if (*cb_idx == -1) { - op = tcg_op_insert_after(tcg_ctx, op, INDEX_op_ld_i32); - memcpy(op->args, begin_op->args, sizeof(op->args)); + op = copy_op(&begin_op, op, INDEX_op_ld_i32); + } else { + begin_op = QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(begin_op && begin_op->opc == INDEX_op_ld_i32); } /* call */ @@ -462,11 +462,11 @@ static TCGOp *append_mem_cb(const struct qemu_plugin_dyn_cb *cb, op = copy_const_ptr(&begin_op, op, cb->userp); /* copy the ld_i32, but note that we only have to copy it once */ - begin_op = QTAILQ_NEXT(begin_op, link); - tcg_debug_assert(begin_op && begin_op->opc == INDEX_op_ld_i32); if (*cb_idx == -1) { - op = tcg_op_insert_after(tcg_ctx, op, INDEX_op_ld_i32); - memcpy(op->args, begin_op->args, sizeof(op->args)); + op = copy_op(&begin_op, op, INDEX_op_ld_i32); + } else { + begin_op = QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(begin_op && begin_op->opc == INDEX_op_ld_i32); } /* extu_tl_i64 */ From patchwork Fri Nov 11 07:40:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623686 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp616724pvb; Thu, 10 Nov 2022 23:45:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf6VhNzl6v41fQrN6mCyHF7Ufm7XglzJi9UxjtimlfNmRvW70jHwZ6gy9n4GhaTdaAbc7zsb X-Received: by 2002:a05:6214:1028:b0:4bb:6b9e:7ecb with SMTP id k8-20020a056214102800b004bb6b9e7ecbmr976777qvr.49.1668152710616; Thu, 10 Nov 2022 23:45:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152710; cv=none; d=google.com; s=arc-20160816; b=EU/TNuyuTbje14JjbOxzn7Ys4C+nYGP1vmheJHOnnHbqK6PlXGQVNH+kSUHtN2RLqp m7qp9tIj37DXuNERJWQKZtMeBRQgCQiIMHc7EnIdAJUDwMyxM3cc8t/MGgOwoeoKFE2S 9+9C11GHUx3Tbr/u+8NHY3BaHJbUyUMKKkpsAAF2Qk+oFMsG9lY31mL6K6320F5Lrix9 dQlq5ZIPkMSPZnIPPM+l1WhgyLH16FCXTn/hysn/Pc3w2iE5ognXZ60JkjG7qwQPyPi/ 2T70fOhvGWtxS6zGoRG97CamiRVm8u7OPofkIFOVluQOTe4cePdNqtq+kSsrmkaqS39b 9hRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=vAH5UQ1VorYpkAuxK6us0chqcuZbbeFNgh5YdpTMZU4=; b=DLbba35aLx1K0+AtyeP1aZ2JAS7Lt80Wfac2tYHvMS3VveUp2chQpHJ9QsIiU6Pukf 0vC7x8xtuXiK9LS9MykRvJ3mZPSK8BXNQCyjz7cxEvoKxLjfedfvQejMZUxbPTdLDLew oNz7gHerK8h8kwoTDL6UyAeGDOHiQ6p6Hio9TA5h2WpTtFecU17I0Ygw1kHQmVsCUTIO P4dkMm8TZWBGjhW8rebzeCeH2hMb2UVD1o1V8YCHhxVXqncQeWqMH7yOcq7i7rU7vU2l 308kA4K7eFQcb835NGnGtB3waKxnXHQvyNNwEnzZ58EsihphDKF87JkY2UrYa9ar5XQt kbyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pjIOmnmT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r2-20020a056214212200b004b3e48b39e2si702851qvc.22.2022.11.10.23.45.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:45:10 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pjIOmnmT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOft-0006en-6Z; Fri, 11 Nov 2022 02:42:05 -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 1otOfq-0006a0-52 for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:02 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfo-00005x-LT for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:01 -0500 Received: by mail-pj1-x102d.google.com with SMTP id q1-20020a17090a750100b002139ec1e999so4063293pjk.1 for ; Thu, 10 Nov 2022 23:42:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vAH5UQ1VorYpkAuxK6us0chqcuZbbeFNgh5YdpTMZU4=; b=pjIOmnmTnAI3rFR9Ag383XRZY3XCxAMSuzhEzk5qlrMPXk5OS92MNScx3f3YI+GSF7 ZEHf6RKfj9EYyXF9UtKoebRIPL5uQJ045vuSzMcElOKGZZf4r6YFgRaGREfHaVqG2SyF M3syhOqk6p2qrwm2Ek0p1jGlXBiURXmE4JXa4EZeQy+3RgBsSltFaQUbc/6104EcZO2/ ncoTVLbPOml4ET78+xmYgzBXKwPP4vY/KYtYMClBh+ThhJgiiqtGci6Q5CjZh+zxwTb/ Nww4PPGJ+ks6dqhlNdH2YOCV+tgmWywWO+3eDlEP5R+ju8biSaqE0oDt/MfqszkT4xc6 ujgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vAH5UQ1VorYpkAuxK6us0chqcuZbbeFNgh5YdpTMZU4=; b=Ul1ax/QKq5XwQAxrNt21fde+96wFVcmtfNyfTC68nRoWb4g0hLfesPUaiR2Ll6NmmN cekO4PxTB167Uj7h2VkH3LSBl5/bB27UoJ242rJLWd27FuacUQRrlkv6Fk6eswOE+3XB bXLU5FWCRe4WEdF8FIDiUBnXeSE024yHmQZ4+glAagCJ6RueL9FEGWl4LwJ9bvIVJvky Qor6Kuc6+iYkH+qj6l6WT7YHAd7KuZPFwDFRZDvS8sxm5h7MNhKI2ViG738Aq+klQVJ/ zhF2MhF56khItiQS0m7Lb4Gs6UsS5Nzb6qyQRrBpc5bRAdswGxlZHBVwh0jg1omIQmPL xQmg== X-Gm-Message-State: ANoB5pmZgXud8oZrdxQsNqQitQwfcvAaD1MWlMcnaw2ufdmKSA4ncbg4 lO0OousBdqoNkVfMHOaaVtK/mikB+l2pGDed X-Received: by 2002:a17:90b:3a8e:b0:212:b4a9:889f with SMTP id om14-20020a17090b3a8e00b00212b4a9889fmr674926pjb.12.1668152519160; Thu, 10 Nov 2022 23:41:59 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:41:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 22/45] tci: MAX_OPC_PARAM_IARGS is no longer used Date: Fri, 11 Nov 2022 17:40:38 +1000 Message-Id: <20221111074101.2069454-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/tci.c | 1 - tcg/tci/tcg-target.c.inc | 4 ---- 2 files changed, 5 deletions(-) diff --git a/tcg/tci.c b/tcg/tci.c index bdfac83492..05a24163d3 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -18,7 +18,6 @@ */ #include "qemu/osdep.h" -#include "tcg/tcg.h" /* MAX_OPC_PARAM_IARGS */ #include "exec/cpu_ldst.h" #include "tcg/tcg-op.h" #include "tcg/tcg-ldst.h" diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index f3d7441e06..c1acaa943e 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -197,10 +197,6 @@ static const int tcg_target_reg_alloc_order[] = { TCG_REG_R0, }; -#if MAX_OPC_PARAM_IARGS != 7 -# error Fix needed, number of supported input arguments changed! -#endif - /* No call arguments via registers. All will be stored on the "stack". */ static const int tcg_target_call_iarg_regs[] = { }; From patchwork Fri Nov 11 07:40:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623678 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp616167pvb; Thu, 10 Nov 2022 23:43:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf5U2299tlVVcTGSbjgpSe9BPMrizK4kHomJvUWXlSXTDc5xKPiarE1A+45pQkjscAjG9Pa4 X-Received: by 2002:a05:6214:5f8b:b0:4bb:8077:951 with SMTP id ls11-20020a0562145f8b00b004bb80770951mr1042262qvb.20.1668152598760; Thu, 10 Nov 2022 23:43:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152598; cv=none; d=google.com; s=arc-20160816; b=wqx7M5/e3Esr3u52QRztx/maqKoZbZCb+Aaysfto6R/q8q71bpp35FJk0WK+cnk5GN 3F/CUl6KZKr75oTWx7AR7rsb8XZqa5lkPDBDILgUJ1AKpz+Vy7WCum/MCbpD4GFZbg+f 7/IEON3V8Wpl8QY1BAOiBFffBxdTGZChbCS/hbNRkbDuqFvVBJWf5Tz2d53VB/Wuvbjt /f72p2D0FV1ri/xZ6Inh6rsFd1uzyh4XVFhM/aYzUneUT3CkNWqy1gszbxW5Vr4he4ay BqIJ7snqwL/5ED0Sd31wsDS5VeYugBPUryb3iqI5yE7KzhW9Y1QIOrnu1cZTbkbbcDgw T3/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=XQHhk/CzUnWnaWUxs81mbGLoVXcQfjsaK2eUJgwESV4=; b=FuXHgm8Ln3Sv7V6yAPeIXfpkiw1QI8dnto15rguh6wRcV+ebOaCeqDWrsk+alrRICp I6pXt2cckCXZ4JtjvGyJm1HHsHdwxt+bZWSyeoXCiO2r7Sc4oek9/zyqW4jWJCbuwXfg Wjdpu7Hb3WApCykIxGfGX/DBX0nmOPfh1qxAoBJp7hvJ4+UDD2IRirkBL/J0V3yl3/Ne 4PYfty0hqT8mln4rePx7q+8ADtlT+xcfma3ZHTqDkJkA/01gW5RFYfenkVumkya6beie GuFcuc0KrBiY9PMznFk/6npWYx4YTPWB0dyz+AzXEjoCWC0HgfXXiiSc1Ull6JnFxosQ UbsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PJUqdjD7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c3-20020ac84e03000000b0039c11d9ab02si635191qtw.557.2022.11.10.23.43.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:43:18 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PJUqdjD7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOg4-0006gG-QM; Fri, 11 Nov 2022 02:42:16 -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 1otOft-0006ea-25 for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:05 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfq-00006P-Lf for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:04 -0500 Received: by mail-pj1-x1029.google.com with SMTP id d13-20020a17090a3b0d00b00213519dfe4aso4059521pjc.2 for ; Thu, 10 Nov 2022 23:42:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=XQHhk/CzUnWnaWUxs81mbGLoVXcQfjsaK2eUJgwESV4=; b=PJUqdjD7Ev4YoASF5PTvAJ1gdaeNx59P+czN0ILRqO4nNJPhV2PeCfdg22hy71NMdQ Rin0TzULweOcCI90+DFGiSWAlwbFujoKgdTAxufpaBGBk3UDH4ua+53hbxihbezmcNtU c42XOkvvaGlrq1+zd0uct/IyqT1h9dmONdUBwaxqcLDz+lra3QvMNdNFp+yYwDtMppOl QFMK1fGXtROwkacxCg5wGGb1bw9VQ8G+M0IuXk5JyxNlmQlLxaRYFct9agW8jgpIVoJw kDTBe93F5a7Q4QGiYBQxyup6a31Lx9b6esMe4a8DbiRrCpwIWq3IfTZKwN1iSqwF8wjm ZIBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XQHhk/CzUnWnaWUxs81mbGLoVXcQfjsaK2eUJgwESV4=; b=sL+d/nqEiDF4dExmddWbZTLn7z5jzJ3LBhrqDePuokbhpNIiBkVI5Bh+u6yKT7NaeP sQHezXoCKWZijVQYDmIoQDuedhgILpnSD+Nyf6sLzibOwc7ecu29+grUrASY7Qwl+ewA RvBSONd1z4LVseo+gOsCcjdx1shttDEMm9KodLadLGGXdD5WtIhnkop5Zyw+kV1FSaOX PDQ15oZ9gxtlafZD7o8s9DKEMMbtnSk0Iv6LwhbHDs+/FHwbXuiLS59Z10KJDsuju2Sy ZRpzJl3KhUOgwylnBoAvsCjMguboXkIFWRrosKSXqY6M/Oq5h6TPTZ6/hXQGuA/laCyM pZ8Q== X-Gm-Message-State: ANoB5pkV6v3SKqwI+MwvgpgboUq24x2Tre8qjOZxjkt4p4Vn/S8XDCpg jg+GDTzjaWftKCSDUyUYyJBTwK8sl+YlJk9a X-Received: by 2002:a17:90a:b288:b0:20c:9d98:13f4 with SMTP id c8-20020a17090ab28800b0020c9d9813f4mr638387pjr.87.1668152521317; Thu, 10 Nov 2022 23:42:01 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.41.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 23/45] tcg: Vary the allocation size for TCGOp Date: Fri, 11 Nov 2022 17:40:39 +1000 Message-Id: <20221111074101.2069454-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We have been allocating a worst case number of arguments to support calls. Instead, allow the size to vary. By default leave space for 4 args, to maximize reuse, but allow calls to increase the number of args to 32. Signed-off-by: Richard Henderson --- include/exec/helper-head.h | 2 -- include/tcg/tcg-op.h | 2 +- include/tcg/tcg.h | 54 +++++++++++++-------------------- accel/tcg/plugin-gen.c | 11 ++++--- tcg/optimize.c | 4 +-- tcg/tcg-op-vec.c | 8 ++--- tcg/tcg-op.c | 12 ++++---- tcg/tcg.c | 61 +++++++++++++++++++++++++------------- 8 files changed, 82 insertions(+), 72 deletions(-) diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h index e242fed46e..8bdf0f6ea2 100644 --- a/include/exec/helper-head.h +++ b/include/exec/helper-head.h @@ -133,6 +133,4 @@ #define DEF_HELPER_7(name, ret, t1, t2, t3, t4, t5, t6, t7) \ DEF_HELPER_FLAGS_7(name, 0, ret, t1, t2, t3, t4, t5, t6, t7) -/* MAX_OPC_PARAM_IARGS must be set to n if last entry is DEF_HELPER_FLAGS_n. */ - #endif /* EXEC_HELPER_HEAD_H */ diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h index 8176f194cb..79b1cf786f 100644 --- a/include/tcg/tcg-op.h +++ b/include/tcg/tcg-op.h @@ -818,7 +818,7 @@ static inline void tcg_gen_plugin_cb_start(unsigned from, unsigned type, static inline void tcg_gen_plugin_cb_end(void) { - tcg_emit_op(INDEX_op_plugin_cb_end); + tcg_emit_op(INDEX_op_plugin_cb_end, 0); } #if TARGET_LONG_BITS == 32 diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 8bcd60d0ed..d430ea10c8 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -38,20 +38,6 @@ /* XXX: make safe guess about sizes */ #define MAX_OP_PER_INSTR 266 -#if HOST_LONG_BITS == 32 -#define MAX_OPC_PARAM_PER_ARG 2 -#else -#define MAX_OPC_PARAM_PER_ARG 1 -#endif -#define MAX_OPC_PARAM_IARGS 7 -#define MAX_OPC_PARAM_OARGS 1 -#define MAX_OPC_PARAM_ARGS (MAX_OPC_PARAM_IARGS + MAX_OPC_PARAM_OARGS) - -/* A Call op needs up to 4 + 2N parameters on 32-bit archs, - * and up to 4 + N parameters on 64-bit archs - * (N = number of input arguments + output arguments). */ -#define MAX_OPC_PARAM (4 + (MAX_OPC_PARAM_PER_ARG * MAX_OPC_PARAM_ARGS)) - #define CPU_TEMP_BUF_NLONGS 128 #define TCG_STATIC_FRAME_SIZE (CPU_TEMP_BUF_NLONGS * sizeof(long)) @@ -493,34 +479,34 @@ typedef struct TCGTempSet { unsigned long l[BITS_TO_LONGS(TCG_MAX_TEMPS)]; } TCGTempSet; -/* While we limit helpers to 6 arguments, for 32-bit hosts, with padding, - this imples a max of 6*2 (64-bit in) + 2 (64-bit out) = 14 operands. - There are never more than 2 outputs, which means that we can store all - dead + sync data within 16 bits. */ -#define DEAD_ARG 4 -#define SYNC_ARG 1 -typedef uint16_t TCGLifeData; +/* + * With 1 128-bit output, a 32-bit host requires 4 output parameters, + * which leaves a maximum of 28 other slots. Which is enough for 7 + * 128-bit operands. + */ +#define DEAD_ARG (1 << 4) +#define SYNC_ARG (1 << 0) +typedef uint32_t TCGLifeData; -/* The layout here is designed to avoid a bitfield crossing of - a 32-bit boundary, which would cause GCC to add extra padding. */ typedef struct TCGOp { - TCGOpcode opc : 8; /* 8 */ + TCGOpcode opc : 8; + unsigned nargs : 8; /* Parameters for this opcode. See below. */ - unsigned param1 : 4; /* 12 */ - unsigned param2 : 4; /* 16 */ + unsigned param1 : 8; + unsigned param2 : 8; /* Lifetime data of the operands. */ - unsigned life : 16; /* 32 */ + TCGLifeData life; /* Next and previous opcodes. */ QTAILQ_ENTRY(TCGOp) link; - /* Arguments for the opcode. */ - TCGArg args[MAX_OPC_PARAM]; - /* Register preferences for the output(s). */ TCGRegSet output_pref[2]; + + /* Arguments for the opcode. */ + TCGArg args[]; } TCGOp; #define TCGOP_CALLI(X) (X)->param1 @@ -1014,10 +1000,12 @@ bool tcg_op_supported(TCGOpcode op); void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args); -TCGOp *tcg_emit_op(TCGOpcode opc); +TCGOp *tcg_emit_op(TCGOpcode opc, unsigned nargs); void tcg_op_remove(TCGContext *s, TCGOp *op); -TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *op, TCGOpcode opc); -TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *op, TCGOpcode opc); +TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *op, + TCGOpcode opc, unsigned nargs); +TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *op, + TCGOpcode opc, unsigned nargs); /** * tcg_remove_ops_after: diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index a6aaacd053..c7d6514840 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -258,10 +258,13 @@ static TCGOp *rm_ops(TCGOp *op) static TCGOp *copy_op_nocheck(TCGOp **begin_op, TCGOp *op) { - *begin_op = QTAILQ_NEXT(*begin_op, link); - tcg_debug_assert(*begin_op); - op = tcg_op_insert_after(tcg_ctx, op, (*begin_op)->opc); - memcpy(op->args, (*begin_op)->args, sizeof(op->args)); + TCGOp *old_op = QTAILQ_NEXT(*begin_op, link); + unsigned nargs = old_op->nargs; + + *begin_op = old_op; + op = tcg_op_insert_after(tcg_ctx, op, old_op->opc, nargs); + memcpy(op->args, old_op->args, sizeof(op->args[0]) * nargs); + return op; } diff --git a/tcg/optimize.c b/tcg/optimize.c index ae081ab29c..1afd50175b 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -962,7 +962,7 @@ static bool fold_addsub2(OptContext *ctx, TCGOp *op, bool add) rh = op->args[1]; /* The proper opcode is supplied by tcg_opt_gen_mov. */ - op2 = tcg_op_insert_before(ctx->tcg, op, 0); + op2 = tcg_op_insert_before(ctx->tcg, op, 0, 2); tcg_opt_gen_movi(ctx, op, rl, al); tcg_opt_gen_movi(ctx, op2, rh, ah); @@ -1613,7 +1613,7 @@ static bool fold_multiply2(OptContext *ctx, TCGOp *op) rh = op->args[1]; /* The proper opcode is supplied by tcg_opt_gen_mov. */ - op2 = tcg_op_insert_before(ctx->tcg, op, 0); + op2 = tcg_op_insert_before(ctx->tcg, op, 0, 2); tcg_opt_gen_movi(ctx, op, rl, l); tcg_opt_gen_movi(ctx, op2, rh, h); diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c index 5bf100ea7d..966d41d65a 100644 --- a/tcg/tcg-op-vec.c +++ b/tcg/tcg-op-vec.c @@ -152,7 +152,7 @@ bool tcg_can_emit_vecop_list(const TCGOpcode *list, void vec_gen_2(TCGOpcode opc, TCGType type, unsigned vece, TCGArg r, TCGArg a) { - TCGOp *op = tcg_emit_op(opc); + TCGOp *op = tcg_emit_op(opc, 2); TCGOP_VECL(op) = type - TCG_TYPE_V64; TCGOP_VECE(op) = vece; op->args[0] = r; @@ -162,7 +162,7 @@ void vec_gen_2(TCGOpcode opc, TCGType type, unsigned vece, TCGArg r, TCGArg a) void vec_gen_3(TCGOpcode opc, TCGType type, unsigned vece, TCGArg r, TCGArg a, TCGArg b) { - TCGOp *op = tcg_emit_op(opc); + TCGOp *op = tcg_emit_op(opc, 3); TCGOP_VECL(op) = type - TCG_TYPE_V64; TCGOP_VECE(op) = vece; op->args[0] = r; @@ -173,7 +173,7 @@ void vec_gen_3(TCGOpcode opc, TCGType type, unsigned vece, void vec_gen_4(TCGOpcode opc, TCGType type, unsigned vece, TCGArg r, TCGArg a, TCGArg b, TCGArg c) { - TCGOp *op = tcg_emit_op(opc); + TCGOp *op = tcg_emit_op(opc, 4); TCGOP_VECL(op) = type - TCG_TYPE_V64; TCGOP_VECE(op) = vece; op->args[0] = r; @@ -185,7 +185,7 @@ void vec_gen_4(TCGOpcode opc, TCGType type, unsigned vece, static void vec_gen_6(TCGOpcode opc, TCGType type, unsigned vece, TCGArg r, TCGArg a, TCGArg b, TCGArg c, TCGArg d, TCGArg e) { - TCGOp *op = tcg_emit_op(opc); + TCGOp *op = tcg_emit_op(opc, 6); TCGOP_VECL(op) = type - TCG_TYPE_V64; TCGOP_VECE(op) = vece; op->args[0] = r; diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 6168327030..cd1cd4e736 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -33,20 +33,20 @@ void tcg_gen_op1(TCGOpcode opc, TCGArg a1) { - TCGOp *op = tcg_emit_op(opc); + TCGOp *op = tcg_emit_op(opc, 1); op->args[0] = a1; } void tcg_gen_op2(TCGOpcode opc, TCGArg a1, TCGArg a2) { - TCGOp *op = tcg_emit_op(opc); + TCGOp *op = tcg_emit_op(opc, 2); op->args[0] = a1; op->args[1] = a2; } void tcg_gen_op3(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3) { - TCGOp *op = tcg_emit_op(opc); + TCGOp *op = tcg_emit_op(opc, 3); op->args[0] = a1; op->args[1] = a2; op->args[2] = a3; @@ -54,7 +54,7 @@ void tcg_gen_op3(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3) void tcg_gen_op4(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, TCGArg a4) { - TCGOp *op = tcg_emit_op(opc); + TCGOp *op = tcg_emit_op(opc, 4); op->args[0] = a1; op->args[1] = a2; op->args[2] = a3; @@ -64,7 +64,7 @@ void tcg_gen_op4(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, TCGArg a4) void tcg_gen_op5(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, TCGArg a4, TCGArg a5) { - TCGOp *op = tcg_emit_op(opc); + TCGOp *op = tcg_emit_op(opc, 5); op->args[0] = a1; op->args[1] = a2; op->args[2] = a3; @@ -75,7 +75,7 @@ void tcg_gen_op5(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, void tcg_gen_op6(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, TCGArg a4, TCGArg a5, TCGArg a6) { - TCGOp *op = tcg_emit_op(opc); + TCGOp *op = tcg_emit_op(opc, 6); op->args[0] = a1; op->args[1] = a2; op->args[2] = a3; diff --git a/tcg/tcg.c b/tcg/tcg.c index b4d0ad8a17..52261417b8 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1478,7 +1478,7 @@ bool tcg_op_supported(TCGOpcode op) and endian swap in tcg_reg_alloc_call(). */ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) { - int i, real_args, nb_rets, pi; + int i, real_args, nb_rets, pi, max_args; unsigned typemask; const TCGHelperInfo *info; TCGOp *op; @@ -1512,7 +1512,13 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) } } - op = tcg_emit_op(INDEX_op_call); + /* + * A Call op needs up to 4 + 2N parameters on 32-bit archs, + * and up to 4 + N parameters on 64-bit archs + * (N = number of input arguments + output arguments). + */ + max_args = (64 / TCG_TARGET_REG_BITS) * nargs + 4; + op = tcg_emit_op(INDEX_op_call, max_args); pi = 0; if (ret != NULL) { @@ -1581,7 +1587,7 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) /* Make sure the fields didn't overflow. */ tcg_debug_assert(TCGOP_CALLI(op) == real_args); - tcg_debug_assert(pi <= ARRAY_SIZE(op->args)); + tcg_debug_assert(pi <= max_args); if (TCG_TARGET_CALL_ARG_I32 == TCG_CALL_ARG_EXTEND) { for (i = 0; i < nargs; ++i) { @@ -2285,41 +2291,56 @@ void tcg_remove_ops_after(TCGOp *op) } } -static TCGOp *tcg_op_alloc(TCGOpcode opc) +static TCGOp *tcg_op_alloc(TCGOpcode opc, unsigned nargs) { TCGContext *s = tcg_ctx; - TCGOp *op; + TCGOp *op = NULL; - if (likely(QTAILQ_EMPTY(&s->free_ops))) { - op = tcg_malloc(sizeof(TCGOp)); - } else { - op = QTAILQ_FIRST(&s->free_ops); - QTAILQ_REMOVE(&s->free_ops, op, link); + if (unlikely(!QTAILQ_EMPTY(&s->free_ops))) { + QTAILQ_FOREACH(op, &s->free_ops, link) { + if (nargs <= op->nargs) { + QTAILQ_REMOVE(&s->free_ops, op, link); + nargs = op->nargs; + goto found; + } + } } + + /* Most opcodes have 3 or 4 operands: reduce fragmentation. */ + nargs = MAX(4, nargs); + op = tcg_malloc(sizeof(TCGOp) + sizeof(TCGArg) * nargs); + + found: memset(op, 0, offsetof(TCGOp, link)); op->opc = opc; - s->nb_ops++; + op->nargs = nargs; + /* Check for bitfield overflow. */ + tcg_debug_assert(op->nargs == nargs); + + s->nb_ops++; return op; } -TCGOp *tcg_emit_op(TCGOpcode opc) +TCGOp *tcg_emit_op(TCGOpcode opc, unsigned nargs) { - TCGOp *op = tcg_op_alloc(opc); + TCGOp *op = tcg_op_alloc(opc, nargs); QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); return op; } -TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *old_op, TCGOpcode opc) +TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *old_op, + TCGOpcode opc, unsigned nargs) { - TCGOp *new_op = tcg_op_alloc(opc); + TCGOp *new_op = tcg_op_alloc(opc, nargs); QTAILQ_INSERT_BEFORE(old_op, new_op, link); return new_op; } -TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *old_op, TCGOpcode opc) +TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *old_op, + TCGOpcode opc, unsigned nargs) { - TCGOp *new_op = tcg_op_alloc(opc); + TCGOp *new_op = tcg_op_alloc(opc, nargs); QTAILQ_INSERT_AFTER(&s->ops, old_op, new_op, link); return new_op; } @@ -2928,7 +2949,7 @@ static bool liveness_pass_2(TCGContext *s) TCGOpcode lopc = (arg_ts->type == TCG_TYPE_I32 ? INDEX_op_ld_i32 : INDEX_op_ld_i64); - TCGOp *lop = tcg_op_insert_before(s, op, lopc); + TCGOp *lop = tcg_op_insert_before(s, op, lopc, 3); lop->args[0] = temp_arg(dir_ts); lop->args[1] = temp_arg(arg_ts->mem_base); @@ -2994,7 +3015,7 @@ static bool liveness_pass_2(TCGContext *s) TCGOpcode sopc = (arg_ts->type == TCG_TYPE_I32 ? INDEX_op_st_i32 : INDEX_op_st_i64); - TCGOp *sop = tcg_op_insert_after(s, op, sopc); + TCGOp *sop = tcg_op_insert_after(s, op, sopc, 3); TCGTemp *out_ts = dir_ts; if (IS_DEAD_ARG(0)) { @@ -3030,7 +3051,7 @@ static bool liveness_pass_2(TCGContext *s) TCGOpcode sopc = (arg_ts->type == TCG_TYPE_I32 ? INDEX_op_st_i32 : INDEX_op_st_i64); - TCGOp *sop = tcg_op_insert_after(s, op, sopc); + TCGOp *sop = tcg_op_insert_after(s, op, sopc, 3); sop->args[0] = temp_arg(dir_ts); sop->args[1] = temp_arg(arg_ts->mem_base); From patchwork Fri Nov 11 07:40:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623685 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp616676pvb; Thu, 10 Nov 2022 23:45:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf58rogNmooqNVl6Xh3h1X26nVUYToIc7LIMFdLx0or3pxT6UMsrApPJCXTbkEbUMV0qIj1I X-Received: by 2002:ac8:6f17:0:b0:39d:85a:2399 with SMTP id bs23-20020ac86f17000000b0039d085a2399mr309681qtb.648.1668152701066; Thu, 10 Nov 2022 23:45:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152701; cv=none; d=google.com; s=arc-20160816; b=YjILzMVsY86rs98jeetDkPNwzhozIvreUjpYFXaGOMtGYo0fzGTKJIx3Efy+VWKTJ4 naQA7CbIQhdJDbKhpbYtWK5TfP8T/aWN16HzkLG5EJTSDWzIQd6wHktrd6X4cr/8K+Z4 AwUxQGEiYIFyf+/7cIVGlwgnn5lRgt12pGKdeQ/x7x/V5VAgY2Z/IJqPBAFXahR4WoaW aiGrDow/Cu4QSkLsN1cZq+TwxW4COTuESmgnCK3kXdtavhYzdl7bnPBvuFAe2Wh01z/d iWoecL6ajZWW8Q483dKwV4YO4BBpET2i8ugs7/1F7FxMxzfOeZdT4d2OeffBDw98nOO4 ydSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=4Y/D4Kc0/92RtE/IJVZhIY6ejmFtU7crmyDlGuoab6g=; b=wfjLwRgY7qCXu24R3j5c2e8cXny2gv1z31BfdITrpKS4JEgGe6w0IkPlg+ZVzFZ6gb a7V3nXafx3fhqBJZw6g26yWQjRp3CRztx5J1yCWC3FGoteKvOoWSB1l4EBdMVpk9SBgd oOW5OgBlVXvr7wI99tBcQYnNHBMpP+9Hs/xJS1/k9vNXB5Ql8T7YBQAxuwithc5E3lbR TCmR2btvhEFsmkw6nHN6JyPWN6ojGHMq1DEFwGr/o2VugnSAxA508K8hzRsR7G2tTMTY Z0svpwI++R4DufuxI2xEqLb0zBRqs9OCYglKitf+gfpUbSIdFfjB+0pJ50/+hJG6HrY+ 4EZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wpgD0VtP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l24-20020ac84a98000000b003997ef368ebsi686555qtq.454.2022.11.10.23.45.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:45:01 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wpgD0VtP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOg9-0006nu-2R; Fri, 11 Nov 2022 02:42:21 -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 1otOfu-0006g6-Jp for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:09 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfs-00009W-RG for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:06 -0500 Received: by mail-pj1-x102c.google.com with SMTP id l6so3813708pjj.0 for ; Thu, 10 Nov 2022 23:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4Y/D4Kc0/92RtE/IJVZhIY6ejmFtU7crmyDlGuoab6g=; b=wpgD0VtP6x1Ds+zCMMA+8TKE2iHe6u/WiHf2Cp0SO45L2+KFONVa3GubRLDZq01gvf /FGDi13gdKrUN9rdVngisjSjdRriUq7ByVNv6dZG1B5mIMqFkMb6vLTljqJpzsZnbrJt jB9Taar6rc65+OCew246wgIbIpwykEITLRwal3r3XNQ5zfJuf52rXMHMflILIyEF2zNN e3I/kOqE8cHKzgB5HJekKyPz75UwUHRTPEqhyKRqNrxem1sRdReRKKD4hKNW49XAQZUW MlI+KZf7V4XxtasMi5rYCPaXaeQe+1yFiQ8Q32OebVXXLEAiCZzzPr1uKhrCq77W4yp6 rQPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4Y/D4Kc0/92RtE/IJVZhIY6ejmFtU7crmyDlGuoab6g=; b=Z3P5gTmN/aAQ4E1aDC0ymwiGDJfGCgcT3gQyTKDxsUNCG7cxPiD8z6YJikNnmQrQZX 6J51+GmzQUIHxqRJnGMM7pRt5eMX+5Ame41sCx9hxptJH0MyvgnaRPt2OH+KbnMBbZBY 6wgRcP7bEnjvomTy1S0z3Oz+FH5dPdkYXCSeG9Rh3wgZMM0ArKqeVYpn78VqmGnRpjrY zLKbopQM+ddZc75LfJ2vHLrNgXKMFSfoxT7cRJqozrSJpC/hg1BVSy7z7KVTvj6C2VhB cGjxjazFOu5ltwnVH3xjNIqDQEuW4StjaJ6iZDxoaS+IU+AxoXX014UTIsW+/n3/1JOu jdPg== X-Gm-Message-State: ANoB5pkHCCtEg23ncxdiiKi2VQ0+xRgBNLggx8Tto4B22nN/kVGlJMQ0 emvZ53IyAEYlkGeuCWNF+j3r4c0PT5rqIFWR X-Received: by 2002:a17:90b:3d0e:b0:20a:d81d:a8 with SMTP id pt14-20020a17090b3d0e00b0020ad81d00a8mr594044pjb.177.1668152523462; Thu, 10 Nov 2022 23:42:03 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 24/45] tcg: Use output_pref wrapper function Date: Fri, 11 Nov 2022 17:40:40 +1000 Message-Id: <20221111074101.2069454-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We will shortly have the possibility of more that two outputs, though only for calls (for which preferences are moot). Avoid direct references to op->output_pref[] when possible. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/tcg/tcg.h | 5 +++++ tcg/tcg.c | 34 ++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index d430ea10c8..a6310b898f 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -518,6 +518,11 @@ typedef struct TCGOp { /* Make sure operands fit in the bitfields above. */ QEMU_BUILD_BUG_ON(NB_OPS > (1 << 8)); +static inline TCGRegSet output_pref(const TCGOp *op, unsigned i) +{ + return i < ARRAY_SIZE(op->output_pref) ? op->output_pref[i] : 0; +} + typedef struct TCGProfile { int64_t cpu_exec_time; int64_t tb_count1; diff --git a/tcg/tcg.c b/tcg/tcg.c index 52261417b8..65be472fef 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1957,7 +1957,7 @@ static void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs) if (have_prefs) { for (i = 0; i < nb_oargs; ++i) { - TCGRegSet set = op->output_pref[i]; + TCGRegSet set = output_pref(op, i); if (i == 0) { ne_fprintf(f, " pref="); @@ -2627,11 +2627,11 @@ static void liveness_pass_1(TCGContext *s) } ts->state = TS_DEAD; la_reset_pref(ts); - - /* Not used -- it will be tcg_target_call_oarg_regs[i]. */ - op->output_pref[i] = 0; } + /* Not used -- it will be tcg_target_call_oarg_reg(). */ + memset(op->output_pref, 0, sizeof(op->output_pref)); + if (!(call_flags & (TCG_CALL_NO_WRITE_GLOBALS | TCG_CALL_NO_READ_GLOBALS))) { la_global_kill(s, nb_globals); @@ -2793,7 +2793,9 @@ static void liveness_pass_1(TCGContext *s) ts = arg_temp(op->args[i]); /* Remember the preference of the uses that followed. */ - op->output_pref[i] = *la_temp_pref(ts); + if (i < ARRAY_SIZE(op->output_pref)) { + op->output_pref[i] = *la_temp_pref(ts); + } /* Output args are dead. */ if (ts->state & TS_DEAD) { @@ -2863,7 +2865,7 @@ static void liveness_pass_1(TCGContext *s) set &= ct->regs; if (ct->ialias) { - set &= op->output_pref[ct->alias_index]; + set &= output_pref(op, ct->alias_index); } /* If the combination is not possible, restart. */ if (set == 0) { @@ -3581,7 +3583,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) TCGType otype, itype; allocated_regs = s->reserved_regs; - preferred_regs = op->output_pref[0]; + preferred_regs = output_pref(op, 0); ots = arg_temp(op->args[0]); ts = arg_temp(op->args[1]); @@ -3696,7 +3698,7 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TCGOp *op) if (IS_DEAD_ARG(1)) { temp_dead(s, its); } - tcg_reg_alloc_do_movi(s, ots, val, arg_life, op->output_pref[0]); + tcg_reg_alloc_do_movi(s, ots, val, arg_life, output_pref(op, 0)); return; } @@ -3712,7 +3714,7 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TCGOp *op) tcg_regset_set_reg(allocated_regs, its->reg); } ots->reg = tcg_reg_alloc(s, dup_out_regs, allocated_regs, - op->output_pref[0], ots->indirect_base); + output_pref(op, 0), ots->indirect_base); ots->val_type = TEMP_VAL_REG; ots->mem_coherent = 0; s->reg_to_temp[ots->reg] = ots; @@ -3831,7 +3833,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) switch (arg_ct->pair) { case 0: /* not paired */ if (arg_ct->ialias) { - i_preferred_regs = op->output_pref[arg_ct->alias_index]; + i_preferred_regs = output_pref(op, arg_ct->alias_index); /* * If the input is readonly, then it cannot also be an @@ -3882,7 +3884,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) ts2 = i1 != i2 ? arg_temp(op->args[i2]) : NULL; if (arg_ct->ialias) { - i_preferred_regs = op->output_pref[arg_ct->alias_index]; + i_preferred_regs = output_pref(op, arg_ct->alias_index); if (IS_DEAD_ARG(i1) && IS_DEAD_ARG(i2) && !temp_readonly(ts) && @@ -3928,7 +3930,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) case 3: /* ialias with second output, no first input */ tcg_debug_assert(arg_ct->ialias); - i_preferred_regs = op->output_pref[arg_ct->alias_index]; + i_preferred_regs = output_pref(op, arg_ct->alias_index); allocate_new_reg = true; if (IS_DEAD_ARG(i) && @@ -4018,10 +4020,10 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) } else if (arg_ct->newreg) { reg = tcg_reg_alloc(s, arg_ct->regs, i_allocated_regs | o_allocated_regs, - op->output_pref[k], ts->indirect_base); + output_pref(op, k), ts->indirect_base); } else { reg = tcg_reg_alloc(s, arg_ct->regs, o_allocated_regs, - op->output_pref[k], ts->indirect_base); + output_pref(op, k), ts->indirect_base); } break; @@ -4032,7 +4034,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) break; } reg = tcg_reg_alloc_pair(s, arg_ct->regs, o_allocated_regs, - op->output_pref[k], ts->indirect_base); + output_pref(op, k), ts->indirect_base); break; case 2: /* second of pair */ @@ -4123,7 +4125,7 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const TCGOp *op) } ots->reg = tcg_reg_alloc(s, dup_out_regs, allocated_regs, - op->output_pref[0], ots->indirect_base); + output_pref(op, 0), ots->indirect_base); ots->val_type = TEMP_VAL_REG; ots->mem_coherent = 0; s->reg_to_temp[ots->reg] = ots; From patchwork Fri Nov 11 07:40:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623683 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp616427pvb; Thu, 10 Nov 2022 23:44:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf5vSiVHHdxdaaSRA8G1cmEE0a9ujsyhWjLWWgfSch+GN+bxCICl8jl1FMX5PU4LcYPFgANW X-Received: by 2002:a0c:90f1:0:b0:4bb:75b4:3ccf with SMTP id p104-20020a0c90f1000000b004bb75b43ccfmr940716qvp.104.1668152656016; Thu, 10 Nov 2022 23:44:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152656; cv=none; d=google.com; s=arc-20160816; b=WzrF76AH3In0iYsoVDfS1tZz/mBNJzEvMEoH2lrhbkz6ImrGn8SsSCZ8BNI07n1E0P 670XShW+PRDcxeydi6CYb9BMHdjKObV8CSAS4G0cs6lcoZwGhAv9fzboS35xM+6weCua j91imv0RG8EGKx8uR97pHRM9RwBDFYJ5HIRPvQy7VPpeIYlBf+1PeT211dA/SjfEDrSA l+VFpFdTRVcD2Sf0MMdEpH3gsKsgy8cUpHQTIjMZ3dn+rGaD9C3cszXivK7wfVv0ZHsV OlNIjWnFDlMPm7gRIQ9fViMIQilWKiDwzBPdsizPCq/fPVRVY3ukV5MLI8C3Bv9ZOB3l XovA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=RfMEHKg0KKPxSd2iaR+EBnsQ5GqO2EMMWetPguBEX2g=; b=vKOfkv+1121V3mqBDJBa2gEFH1Zlt8qbnBOMAsjZvY4f2Un/gEbgsNEalIwkMdmHHp Nn8ALl2yc3R9Y3VHRBSg0NP4IWn5gfs6V49Fe9Qhc8tDdJsYlYmVsrOf7wUZUfkKb8cA NGfK/gjXvGK6Rnqs4dzUxW/9OV5gd8ete1E2hDvhiwwawNDeao5ss8t4GkgOL/EcfaJd d3EP/hwmW4i/DY0RbFEHUMvJuvjPZWXDcoOUJeHDJ5cWdSnS87KQ2tAvg+npsg1YzuIo pXFpE2AqkozXF0jJPSMEfnbdq+FK7aL+XvBfz/aPtEmBr/4Zajpp8qTCH8kGKR/f4ocq Zfqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZsyxjRBT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f29-20020ac86edd000000b003a573b691a4si657651qtv.494.2022.11.10.23.44.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:44:16 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZsyxjRBT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOg8-0006ng-NS; Fri, 11 Nov 2022 02:42:20 -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 1otOfz-0006gT-7z for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:14 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfv-0000Eh-9w for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:10 -0500 Received: by mail-pj1-x1034.google.com with SMTP id l6so3813790pjj.0 for ; Thu, 10 Nov 2022 23:42:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=RfMEHKg0KKPxSd2iaR+EBnsQ5GqO2EMMWetPguBEX2g=; b=ZsyxjRBT8iXrQSXin48aM4HJ5lMgHyqRAdFAdKiRXup0Yw0J67q3d86cjrf/9hellC 0hq7AC1o8/5Mv0jCrk1R7WAVZc7qvV/rNlxU1+vf1LFRkxa+C6plMjTPErxzS8NOYQvh 3xEhPEf7QBQLdAjjWbnBMnNDSVY1sAd0M+SVdG/Iwws6GcRvdqF5X4iIMnQNrd+jyrbH ZqfF/lReuXqrgGmB4FgZIfWqc/W3NnASLLuW4hX76nKHaad3cCBQPrh/b5lMjisREhnt 99YjjormcGeOY2o2/oAYtD5cGtYTbYhjI9Qfg9rh37Z1U3GwHzXEnXX2rZ+FeUEQrJJZ XH2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RfMEHKg0KKPxSd2iaR+EBnsQ5GqO2EMMWetPguBEX2g=; b=JqSPo2tlgI7g4Yu/t8VxlFkIvWIzrZ+RQassN3GHgR6i5M3B/MN1G+uBeroNh2ht4Y 31I2KBT0j7udG6fTRdXhirlvn8Quq+V9pt/A266eZvH0DXGbFuOmnugUt5e9n7pOBQNv w0SZ479h3B5ECUD76/gnAY6nXHVvF4KPCwJjV9TLVHKnIR7Z4UNrU6rrg+U9nbi0jHsc UiCXIf33823/sH8DA2GqobPD9EbWt5FoHOLvaHgpTP7x5P0R74kTqlB5MZLW+YAi8uSy WHgin6XL732U1D5kEDYQICNLW5UYcyFa/6RWVHogM6vh6b73Pf3mZTQcX2nirh4h/8jm 1xPg== X-Gm-Message-State: ANoB5pnlMSMdkWALVB719RaEZRS8x72UGe9PGw+5lMHx1WI7arUXxJeL dKL6O5tLpqFTvWWFct7+dE2sHW3mPYxwJbsS X-Received: by 2002:a17:90a:804c:b0:20d:d531:97cc with SMTP id e12-20020a17090a804c00b0020dd53197ccmr596500pjw.164.1668152525746; Thu, 10 Nov 2022 23:42:05 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 25/45] tcg: Reorg function calls Date: Fri, 11 Nov 2022 17:40:41 +1000 Message-Id: <20221111074101.2069454-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Pre-compute the function call layout for each helper at startup. Drop TCG_CALL_DUMMY_ARG, as we no longer need to leave gaps in the op->args[] array. This allows several places to stop checking for NULL TCGTemp, to which TCG_CALL_DUMMY_ARG mapped. For tcg_gen_callN, loop over the arguments once. Allocate the TCGOp for the call early but delay emitting it, collecting arguments first. This allows the argument processing loop to emit code for extensions and have them sequenced before the call. For tcg_reg_alloc_call, loop over the arguments in reverse order, which allows stack slots to be filled first naturally. Signed-off-by: Richard Henderson --- include/exec/helper-head.h | 2 + include/tcg/tcg.h | 5 +- tcg/tcg-internal.h | 22 +- tcg/optimize.c | 6 +- tcg/tcg.c | 601 ++++++++++++++++++++++--------------- 5 files changed, 387 insertions(+), 249 deletions(-) diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h index 8bdf0f6ea2..bc6698b19f 100644 --- a/include/exec/helper-head.h +++ b/include/exec/helper-head.h @@ -133,4 +133,6 @@ #define DEF_HELPER_7(name, ret, t1, t2, t3, t4, t5, t6, t7) \ DEF_HELPER_FLAGS_7(name, 0, ret, t1, t2, t3, t4, t5, t6, t7) +/* MAX_CALL_IARGS must be set to n if last entry is DEF_HELPER_FLAGS_n. */ + #endif /* EXEC_HELPER_HEAD_H */ diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index a6310b898f..b949d75fdd 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -38,6 +38,8 @@ /* XXX: make safe guess about sizes */ #define MAX_OP_PER_INSTR 266 +#define MAX_CALL_IARGS 7 + #define CPU_TEMP_BUF_NLONGS 128 #define TCG_STATIC_FRAME_SIZE (CPU_TEMP_BUF_NLONGS * sizeof(long)) @@ -411,9 +413,6 @@ typedef TCGv_ptr TCGv_env; #define TCG_CALL_NO_RWG_SE (TCG_CALL_NO_RWG | TCG_CALL_NO_SE) #define TCG_CALL_NO_WG_SE (TCG_CALL_NO_WG | TCG_CALL_NO_SE) -/* Used to align parameters. See the comment before tcgv_i32_temp. */ -#define TCG_CALL_DUMMY_ARG ((TCGArg)0) - /* * Flags for the bswap opcodes. * If IZ, the input is zero-extended, otherwise unknown. diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index f574743ff8..c7e87e193d 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -42,11 +42,29 @@ typedef enum { TCG_CALL_ARG_EXTEND_S, /* ... as a sign-extended i64 */ } TCGCallArgumentKind; +typedef struct TCGCallArgumentLoc { + TCGCallArgumentKind kind : 8; + unsigned arg_slot : 8; + unsigned ref_slot : 8; + unsigned arg_idx : 4; + unsigned tmp_subindex : 2; +} TCGCallArgumentLoc; + +/* Avoid "unsigned < 0 is always false" Werror, when iarg_regs is empty. */ +#define REG_P(L) \ + ((int)(L)->arg_slot < (int)ARRAY_SIZE(tcg_target_call_iarg_regs)) + typedef struct TCGHelperInfo { void *func; const char *name; - unsigned flags; - unsigned typemask; + unsigned typemask : 32; + unsigned flags : 8; + unsigned nr_in : 8; + unsigned nr_out : 8; + TCGCallReturnKind out_kind : 8; + + /* Maximum physical arguments are constrained by TCG_TYPE_I128. */ + TCGCallArgumentLoc in[MAX_CALL_IARGS * (128 / TCG_TARGET_REG_BITS)]; } TCGHelperInfo; extern TCGContext tcg_init_ctx; diff --git a/tcg/optimize.c b/tcg/optimize.c index 1afd50175b..763bca9ea6 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -667,9 +667,7 @@ static void init_arguments(OptContext *ctx, TCGOp *op, int nb_args) { for (int i = 0; i < nb_args; i++) { TCGTemp *ts = arg_temp(op->args[i]); - if (ts) { - init_ts_info(ctx, ts); - } + init_ts_info(ctx, ts); } } @@ -680,7 +678,7 @@ static void copy_propagate(OptContext *ctx, TCGOp *op, for (int i = nb_oargs; i < nb_oargs + nb_iargs; i++) { TCGTemp *ts = arg_temp(op->args[i]); - if (ts && ts_is_copy(ts)) { + if (ts_is_copy(ts)) { op->args[i] = temp_arg(find_better_copy(s, ts)); } } diff --git a/tcg/tcg.c b/tcg/tcg.c index 65be472fef..cabc397a38 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -546,7 +546,7 @@ void tcg_pool_reset(TCGContext *s) #include "exec/helper-proto.h" -static const TCGHelperInfo all_helpers[] = { +static TCGHelperInfo all_helpers[] = { #include "exec/helper-tcg.h" }; static GHashTable *helper_table; @@ -564,6 +564,140 @@ static ffi_type * const typecode_to_ffi[8] = { }; #endif +typedef struct TCGCumulativeArgs { + int arg_idx; /* tcg_gen_callN args[] */ + int info_in_idx; /* TCGHelperInfo in[] */ + int arg_slot; /* regs+stack slot */ + int ref_slot; /* stack slots for references */ +} TCGCumulativeArgs; + +static void layout_arg_even(TCGCumulativeArgs *cum) +{ + cum->arg_slot += cum->arg_slot & 1; +} + +static void layout_arg_1(TCGCumulativeArgs *cum, TCGHelperInfo *info, + TCGCallArgumentKind kind) +{ + TCGCallArgumentLoc *loc = &info->in[cum->info_in_idx]; + + *loc = (TCGCallArgumentLoc){ + .kind = kind, + .arg_idx = cum->arg_idx, + .arg_slot = cum->arg_slot, + }; + cum->info_in_idx++; + cum->arg_slot++; +} + +static void layout_arg_normal_n(TCGCumulativeArgs *cum, + TCGHelperInfo *info, int n) +{ + TCGCallArgumentLoc *loc = &info->in[cum->info_in_idx]; + + for (int i = 0; i < n; ++i) { + /* Layout all using the same arg_idx, adjusting the subindex. */ + loc[i] = (TCGCallArgumentLoc){ + .kind = TCG_CALL_ARG_NORMAL, + .arg_idx = cum->arg_idx, + .tmp_subindex = i, + .arg_slot = cum->arg_slot + i, + }; + } + cum->info_in_idx += n; + cum->arg_slot += n; +} + +static void init_call_layout(TCGHelperInfo *info) +{ + int max_reg_slots = ARRAY_SIZE(tcg_target_call_iarg_regs); + int max_stk_slots = TCG_STATIC_CALL_ARGS_SIZE / sizeof(tcg_target_long); + unsigned typemask = info->typemask; + unsigned typecode; + TCGCumulativeArgs cum = { }; + + /* + * Parse and place any function return value. + */ + typecode = typemask & 7; + switch (typecode) { + case dh_typecode_void: + info->nr_out = 0; + break; + case dh_typecode_i32: + case dh_typecode_s32: + case dh_typecode_ptr: + info->nr_out = 1; + info->out_kind = TCG_CALL_RET_NORMAL; + break; + case dh_typecode_i64: + case dh_typecode_s64: + info->nr_out = 64 / TCG_TARGET_REG_BITS; + info->out_kind = TCG_CALL_RET_NORMAL; + break; + default: + g_assert_not_reached(); + } + assert(info->nr_out <= ARRAY_SIZE(tcg_target_call_oarg_regs)); + + /* + * Parse and place function arguments. + */ + for (typemask >>= 3; typemask; typemask >>= 3, cum.arg_idx++) { + TCGCallArgumentKind kind; + + typecode = typemask & 7; + switch (typecode) { + case dh_typecode_i32: + case dh_typecode_s32: + switch (TCG_TARGET_CALL_ARG_I32) { + case TCG_CALL_ARG_EVEN: + layout_arg_even(&cum); + /* fall through */ + case TCG_CALL_ARG_NORMAL: + layout_arg_1(&cum, info, TCG_CALL_ARG_NORMAL); + break; + case TCG_CALL_ARG_EXTEND: + kind = TCG_CALL_ARG_EXTEND_U + (typecode & 1); + layout_arg_1(&cum, info, kind); + break; + default: + qemu_build_not_reached(); + } + break; + case dh_typecode_i64: + case dh_typecode_s64: + switch (TCG_TARGET_CALL_ARG_I64) { + case TCG_CALL_ARG_EVEN: + layout_arg_even(&cum); + /* fall through */ + case TCG_CALL_ARG_NORMAL: + if (TCG_TARGET_REG_BITS == 32) { + layout_arg_normal_n(&cum, info, 2); + } else { + layout_arg_1(&cum, info, TCG_CALL_ARG_NORMAL); + } + break; + default: + qemu_build_not_reached(); + } + break; + case dh_typecode_ptr: + layout_arg_1(&cum, info, TCG_CALL_ARG_NORMAL); + break; + default: + g_assert_not_reached(); + } + } + info->nr_in = cum.info_in_idx; + + /* Validate that we didn't overrun the input array. */ + assert(cum.info_in_idx <= ARRAY_SIZE(info->in)); + /* Validate the backend has enough argument space. */ + assert(cum.arg_slot <= max_reg_slots + max_stk_slots); + assert(cum.ref_slot <= max_stk_slots); +} + static int indirect_reg_alloc_order[ARRAY_SIZE(tcg_target_reg_alloc_order)]; static void process_op_defs(TCGContext *s); static TCGTemp *tcg_global_reg_new_internal(TCGContext *s, TCGType type, @@ -603,6 +737,7 @@ static void tcg_context_init(unsigned max_cpus) helper_table = g_hash_table_new(NULL, NULL); for (i = 0; i < ARRAY_SIZE(all_helpers); ++i) { + init_call_layout(&all_helpers[i]); g_hash_table_insert(helper_table, (gpointer)all_helpers[i].func, (gpointer)&all_helpers[i]); } @@ -1473,18 +1608,19 @@ bool tcg_op_supported(TCGOpcode op) } } -/* Note: we convert the 64 bit args to 32 bit and do some alignment - and endian swap. Maybe it would be better to do the alignment - and endian swap in tcg_reg_alloc_call(). */ +static TCGOp *tcg_op_alloc(TCGOpcode opc, unsigned nargs); + void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) { - int i, real_args, nb_rets, pi, max_args; - unsigned typemask; const TCGHelperInfo *info; + TCGv_i64 extend_free[MAX_CALL_IARGS]; + int n_extend = 0; TCGOp *op; + int i, n, pi = 0, total_args; info = g_hash_table_lookup(helper_table, (gpointer)func); - typemask = info->typemask; + total_args = info->nr_out + info->nr_in + 2; + op = tcg_op_alloc(INDEX_op_call, total_args); #ifdef CONFIG_PLUGIN /* detect non-plugin helpers */ @@ -1493,111 +1629,65 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) } #endif - if (TCG_TARGET_CALL_ARG_I32 == TCG_CALL_ARG_EXTEND) { - for (i = 0; i < nargs; ++i) { - int argtype = extract32(typemask, (i + 1) * 3, 3); - bool is_32bit = (argtype & ~1) == dh_typecode_i32; - bool is_signed = argtype & 1; + TCGOP_CALLO(op) = n = info->nr_out; + switch (n) { + case 0: + tcg_debug_assert(ret == NULL); + break; + case 1: + tcg_debug_assert(ret != NULL); + op->args[pi++] = temp_arg(ret); + break; + case 2: + tcg_debug_assert(ret != NULL); + tcg_debug_assert(ret->base_type == ret->type + 1); + tcg_debug_assert(ret->temp_subindex == 0); + op->args[pi++] = temp_arg(ret); + op->args[pi++] = temp_arg(ret + 1); + break; + default: + g_assert_not_reached(); + } - if (is_32bit) { + TCGOP_CALLI(op) = n = info->nr_in; + for (i = 0; i < n; i++) { + const TCGCallArgumentLoc *loc = &info->in[i]; + TCGTemp *ts = args[loc->arg_idx] + loc->tmp_subindex; + + switch (loc->kind) { + case TCG_CALL_ARG_NORMAL: + op->args[pi++] = temp_arg(ts); + break; + + case TCG_CALL_ARG_EXTEND_U: + case TCG_CALL_ARG_EXTEND_S: + { TCGv_i64 temp = tcg_temp_new_i64(); - TCGv_i32 orig = temp_tcgv_i32(args[i]); - if (is_signed) { + TCGv_i32 orig = temp_tcgv_i32(ts); + + if (loc->kind == TCG_CALL_ARG_EXTEND_S) { tcg_gen_ext_i32_i64(temp, orig); } else { tcg_gen_extu_i32_i64(temp, orig); } - args[i] = tcgv_i64_temp(temp); + op->args[pi++] = tcgv_i64_arg(temp); + extend_free[n_extend++] = temp; } - } - } - - /* - * A Call op needs up to 4 + 2N parameters on 32-bit archs, - * and up to 4 + N parameters on 64-bit archs - * (N = number of input arguments + output arguments). - */ - max_args = (64 / TCG_TARGET_REG_BITS) * nargs + 4; - op = tcg_emit_op(INDEX_op_call, max_args); - - pi = 0; - if (ret != NULL) { - if (TCG_TARGET_REG_BITS < 64 && (typemask & 6) == dh_typecode_i64) { - op->args[pi++] = temp_arg(ret); - op->args[pi++] = temp_arg(ret + 1); - nb_rets = 2; - } else { - op->args[pi++] = temp_arg(ret); - nb_rets = 1; - } - } else { - nb_rets = 0; - } - TCGOP_CALLO(op) = nb_rets; - - real_args = 0; - for (i = 0; i < nargs; i++) { - int argtype = extract32(typemask, (i + 1) * 3, 3); - TCGCallArgumentKind kind; - TCGType type; - - switch (argtype) { - case dh_typecode_i32: - case dh_typecode_s32: - type = TCG_TYPE_I32; - kind = TCG_TARGET_CALL_ARG_I32; break; - case dh_typecode_i64: - case dh_typecode_s64: - type = TCG_TYPE_I64; - kind = TCG_TARGET_CALL_ARG_I64; - break; - case dh_typecode_ptr: - type = TCG_TYPE_PTR; - kind = TCG_CALL_ARG_NORMAL; - break; - default: - g_assert_not_reached(); - } - switch (kind) { - case TCG_CALL_ARG_EVEN: - if (real_args & 1) { - op->args[pi++] = TCG_CALL_DUMMY_ARG; - real_args++; - } - /* fall through */ - case TCG_CALL_ARG_NORMAL: - if (TCG_TARGET_REG_BITS == 32 && type == TCG_TYPE_I64) { - op->args[pi++] = temp_arg(args[i]); - op->args[pi++] = temp_arg(args[i] + 1); - real_args += 2; - break; - } - op->args[pi++] = temp_arg(args[i]); - real_args++; - break; default: g_assert_not_reached(); } } op->args[pi++] = (uintptr_t)func; op->args[pi++] = (uintptr_t)info; - TCGOP_CALLI(op) = real_args; + tcg_debug_assert(pi == total_args); - /* Make sure the fields didn't overflow. */ - tcg_debug_assert(TCGOP_CALLI(op) == real_args); - tcg_debug_assert(pi <= max_args); + QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); - if (TCG_TARGET_CALL_ARG_I32 == TCG_CALL_ARG_EXTEND) { - for (i = 0; i < nargs; ++i) { - int argtype = extract32(typemask, (i + 1) * 3, 3); - bool is_32bit = (argtype & ~1) == dh_typecode_i32; - - if (is_32bit) { - tcg_temp_free_internal(args[i]); - } - } + tcg_debug_assert(n_extend < ARRAY_SIZE(extend_free)); + for (i = 0; i < n_extend; ++i) { + tcg_temp_free_i64(extend_free[i]); } } @@ -1813,10 +1903,7 @@ static void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs) } for (i = 0; i < nb_iargs; i++) { TCGArg arg = op->args[nb_oargs + i]; - const char *t = ""; - if (arg != TCG_CALL_DUMMY_ARG) { - t = tcg_get_arg_str(s, buf, sizeof(buf), arg); - } + const char *t = tcg_get_arg_str(s, buf, sizeof(buf), arg); col += ne_fprintf(f, ",%s", t); } } else { @@ -2597,12 +2684,11 @@ static void liveness_pass_1(TCGContext *s) switch (opc) { case INDEX_op_call: { - int call_flags; - int nb_call_regs; + const TCGHelperInfo *info = tcg_call_info(op); + int call_flags = tcg_call_flags(op); nb_oargs = TCGOP_CALLO(op); nb_iargs = TCGOP_CALLI(op); - call_flags = tcg_call_flags(op); /* pure functions can be removed if their result is unused */ if (call_flags & TCG_CALL_NO_SIDE_EFFECTS) { @@ -2642,7 +2728,7 @@ static void liveness_pass_1(TCGContext *s) /* Record arguments that die in this helper. */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { ts = arg_temp(op->args[i]); - if (ts && ts->state & TS_DEAD) { + if (ts->state & TS_DEAD) { arg_life |= DEAD_ARG << i; } } @@ -2650,31 +2736,59 @@ static void liveness_pass_1(TCGContext *s) /* For all live registers, remove call-clobbered prefs. */ la_cross_call(s, nb_temps); - nb_call_regs = ARRAY_SIZE(tcg_target_call_iarg_regs); + /* + * Input arguments are live for preceding opcodes. + * + * For those arguments that die, and will be allocated in + * registers, clear the register set for that arg, to be + * filled in below. For args that will be on the stack, + * reset to any available reg. Process arguments in reverse + * order so that if a temp is used more than once, the stack + * reset to max happens before the register reset to 0. + */ + for (i = nb_iargs - 1; i >= 0; i--) { + const TCGCallArgumentLoc *loc = &info->in[i]; + ts = arg_temp(op->args[nb_oargs + i]); - /* Input arguments are live for preceding opcodes. */ - for (i = 0; i < nb_iargs; i++) { - ts = arg_temp(op->args[i + nb_oargs]); - if (ts && ts->state & TS_DEAD) { - /* For those arguments that die, and will be allocated - * in registers, clear the register set for that arg, - * to be filled in below. For args that will be on - * the stack, reset to any available reg. - */ - *la_temp_pref(ts) - = (i < nb_call_regs ? 0 : - tcg_target_available_regs[ts->type]); + if (ts->state & TS_DEAD) { + switch (loc->kind) { + case TCG_CALL_ARG_NORMAL: + case TCG_CALL_ARG_EXTEND_U: + case TCG_CALL_ARG_EXTEND_S: + if (REG_P(loc)) { + *la_temp_pref(ts) = 0; + break; + } + /* fall through */ + default: + *la_temp_pref(ts) = + tcg_target_available_regs[ts->type]; + break; + } ts->state &= ~TS_DEAD; } } - /* For each input argument, add its input register to prefs. - If a temp is used once, this produces a single set bit. */ - for (i = 0; i < MIN(nb_call_regs, nb_iargs); i++) { - ts = arg_temp(op->args[i + nb_oargs]); - if (ts) { - tcg_regset_set_reg(*la_temp_pref(ts), - tcg_target_call_iarg_regs[i]); + /* + * For each input argument, add its input register to prefs. + * If a temp is used once, this produces a single set bit; + * if a temp is used multiple times, this produces a set. + */ + for (i = 0; i < nb_iargs; i++) { + const TCGCallArgumentLoc *loc = &info->in[i]; + ts = arg_temp(op->args[nb_oargs + i]); + + switch (loc->kind) { + case TCG_CALL_ARG_NORMAL: + case TCG_CALL_ARG_EXTEND_U: + case TCG_CALL_ARG_EXTEND_S: + if (REG_P(loc)) { + tcg_regset_set_reg(*la_temp_pref(ts), + tcg_target_call_iarg_regs[loc->arg_slot]); + } + break; + default: + break; } } } @@ -2945,21 +3059,19 @@ static bool liveness_pass_2(TCGContext *s) /* Make sure that input arguments are available. */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { arg_ts = arg_temp(op->args[i]); - if (arg_ts) { - dir_ts = arg_ts->state_ptr; - if (dir_ts && arg_ts->state == TS_DEAD) { - TCGOpcode lopc = (arg_ts->type == TCG_TYPE_I32 - ? INDEX_op_ld_i32 - : INDEX_op_ld_i64); - TCGOp *lop = tcg_op_insert_before(s, op, lopc, 3); + dir_ts = arg_ts->state_ptr; + if (dir_ts && arg_ts->state == TS_DEAD) { + TCGOpcode lopc = (arg_ts->type == TCG_TYPE_I32 + ? INDEX_op_ld_i32 + : INDEX_op_ld_i64); + TCGOp *lop = tcg_op_insert_before(s, op, lopc, 3); - lop->args[0] = temp_arg(dir_ts); - lop->args[1] = temp_arg(arg_ts->mem_base); - lop->args[2] = arg_ts->mem_offset; + lop->args[0] = temp_arg(dir_ts); + lop->args[1] = temp_arg(arg_ts->mem_base); + lop->args[2] = arg_ts->mem_offset; - /* Loaded, but synced with memory. */ - arg_ts->state = TS_MEM; - } + /* Loaded, but synced with memory. */ + arg_ts->state = TS_MEM; } } @@ -2968,14 +3080,12 @@ static bool liveness_pass_2(TCGContext *s) so that we reload when needed. */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { arg_ts = arg_temp(op->args[i]); - if (arg_ts) { - dir_ts = arg_ts->state_ptr; - if (dir_ts) { - op->args[i] = temp_arg(dir_ts); - changes = true; - if (IS_DEAD_ARG(i)) { - arg_ts->state = TS_DEAD; - } + dir_ts = arg_ts->state_ptr; + if (dir_ts) { + op->args[i] = temp_arg(dir_ts); + changes = true; + if (IS_DEAD_ARG(i)) { + arg_ts->state = TS_DEAD; } } } @@ -4181,106 +4291,107 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const TCGOp *op) return true; } +static void load_arg_reg(TCGContext *s, TCGReg reg, TCGTemp *ts, + TCGRegSet allocated_regs) +{ + if (ts->val_type == TEMP_VAL_REG) { + if (ts->reg != reg) { + tcg_reg_free(s, reg, allocated_regs); + if (!tcg_out_mov(s, ts->type, reg, ts->reg)) { + /* + * Cross register class move not supported. Sync the + * temp back to its slot and load from there. + */ + temp_sync(s, ts, allocated_regs, 0, 0); + tcg_out_ld(s, ts->type, reg, + ts->mem_base->reg, ts->mem_offset); + } + } + } else { + TCGRegSet arg_set = 0; + + tcg_reg_free(s, reg, allocated_regs); + tcg_regset_set_reg(arg_set, reg); + temp_load(s, ts, arg_set, allocated_regs, 0); + } +} + +static void load_arg_stk(TCGContext *s, int stk_slot, TCGTemp *ts, + TCGRegSet allocated_regs) +{ + /* + * When the destination is on the stack, load up the temp and store. + * If there are many call-saved registers, the temp might live to + * see another use; otherwise it'll be discarded. + */ + temp_load(s, ts, tcg_target_available_regs[ts->type], allocated_regs, 0); + tcg_out_st(s, ts->type, ts->reg, TCG_REG_CALL_STACK, + TCG_TARGET_CALL_STACK_OFFSET + + stk_slot * sizeof(tcg_target_long)); +} + +static void load_arg_normal(TCGContext *s, const TCGCallArgumentLoc *l, + TCGTemp *ts, TCGRegSet *allocated_regs) +{ + if (REG_P(l)) { + TCGReg reg = tcg_target_call_iarg_regs[l->arg_slot]; + load_arg_reg(s, reg, ts, *allocated_regs); + tcg_regset_set_reg(*allocated_regs, reg); + } else { + load_arg_stk(s, l->arg_slot - ARRAY_SIZE(tcg_target_call_iarg_regs), + ts, *allocated_regs); + } +} + static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) { const int nb_oargs = TCGOP_CALLO(op); const int nb_iargs = TCGOP_CALLI(op); const TCGLifeData arg_life = op->life; - const TCGHelperInfo *info; - int flags, nb_regs, i; - TCGReg reg; - TCGArg arg; - TCGTemp *ts; - intptr_t stack_offset; - size_t call_stack_size; - tcg_insn_unit *func_addr; - int allocate_args; - TCGRegSet allocated_regs; + const TCGHelperInfo *info = tcg_call_info(op); + TCGRegSet allocated_regs = s->reserved_regs; + int i; - func_addr = tcg_call_func(op); - info = tcg_call_info(op); - flags = info->flags; + /* + * Move inputs into place in reverse order, + * so that we place stacked arguments first. + */ + for (i = nb_iargs - 1; i >= 0; --i) { + const TCGCallArgumentLoc *loc = &info->in[i]; + TCGTemp *ts = arg_temp(op->args[nb_oargs + i]); - nb_regs = ARRAY_SIZE(tcg_target_call_iarg_regs); - if (nb_regs > nb_iargs) { - nb_regs = nb_iargs; - } - - /* assign stack slots first */ - call_stack_size = (nb_iargs - nb_regs) * sizeof(tcg_target_long); - call_stack_size = (call_stack_size + TCG_TARGET_STACK_ALIGN - 1) & - ~(TCG_TARGET_STACK_ALIGN - 1); - allocate_args = (call_stack_size > TCG_STATIC_CALL_ARGS_SIZE); - if (allocate_args) { - /* XXX: if more than TCG_STATIC_CALL_ARGS_SIZE is needed, - preallocate call stack */ - tcg_abort(); - } - - stack_offset = TCG_TARGET_CALL_STACK_OFFSET; - for (i = nb_regs; i < nb_iargs; i++) { - arg = op->args[nb_oargs + i]; - if (arg != TCG_CALL_DUMMY_ARG) { - ts = arg_temp(arg); - temp_load(s, ts, tcg_target_available_regs[ts->type], - s->reserved_regs, 0); - tcg_out_st(s, ts->type, ts->reg, TCG_REG_CALL_STACK, stack_offset); - } - stack_offset += sizeof(tcg_target_long); - } - - /* assign input registers */ - allocated_regs = s->reserved_regs; - for (i = 0; i < nb_regs; i++) { - arg = op->args[nb_oargs + i]; - if (arg != TCG_CALL_DUMMY_ARG) { - ts = arg_temp(arg); - reg = tcg_target_call_iarg_regs[i]; - - if (ts->val_type == TEMP_VAL_REG) { - if (ts->reg != reg) { - tcg_reg_free(s, reg, allocated_regs); - if (!tcg_out_mov(s, ts->type, reg, ts->reg)) { - /* - * Cross register class move not supported. Sync the - * temp back to its slot and load from there. - */ - temp_sync(s, ts, allocated_regs, 0, 0); - tcg_out_ld(s, ts->type, reg, - ts->mem_base->reg, ts->mem_offset); - } - } - } else { - TCGRegSet arg_set = 0; - - tcg_reg_free(s, reg, allocated_regs); - tcg_regset_set_reg(arg_set, reg); - temp_load(s, ts, arg_set, allocated_regs, 0); - } - - tcg_regset_set_reg(allocated_regs, reg); + switch (loc->kind) { + case TCG_CALL_ARG_NORMAL: + case TCG_CALL_ARG_EXTEND_U: + case TCG_CALL_ARG_EXTEND_S: + load_arg_normal(s, loc, ts, &allocated_regs); + break; + default: + g_assert_not_reached(); } } - - /* mark dead temporaries and free the associated registers */ + + /* Mark dead temporaries and free the associated registers. */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { if (IS_DEAD_ARG(i)) { temp_dead(s, arg_temp(op->args[i])); } } - - /* clobber call registers */ + + /* Clobber call registers. */ for (i = 0; i < TCG_TARGET_NB_REGS; i++) { if (tcg_regset_test_reg(tcg_target_call_clobber_regs, i)) { tcg_reg_free(s, i, allocated_regs); } } - /* Save globals if they might be written by the helper, sync them if - they might be read. */ - if (flags & TCG_CALL_NO_READ_GLOBALS) { + /* + * Save globals if they might be written by the helper, + * sync them if they might be read. + */ + if (info->flags & TCG_CALL_NO_READ_GLOBALS) { /* Nothing to do */ - } else if (flags & TCG_CALL_NO_WRITE_GLOBALS) { + } else if (info->flags & TCG_CALL_NO_WRITE_GLOBALS) { sync_globals(s, allocated_regs); } else { save_globals(s, allocated_regs); @@ -4291,31 +4402,41 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) gpointer hash = (gpointer)(uintptr_t)info->typemask; ffi_cif *cif = g_hash_table_lookup(ffi_table, hash); assert(cif != NULL); - tcg_out_call(s, func_addr, cif); + tcg_out_call(s, tcg_call_func(op), cif); } #else - tcg_out_call(s, func_addr); + tcg_out_call(s, tcg_call_func(op)); #endif - /* assign output registers and emit moves if needed */ - for(i = 0; i < nb_oargs; i++) { - arg = op->args[i]; - ts = arg_temp(arg); + /* Assign output registers and emit moves if needed. */ + switch (info->out_kind) { + case TCG_CALL_RET_NORMAL: + for (i = 0; i < nb_oargs; i++) { + TCGTemp *ts = arg_temp(op->args[i]); + TCGReg reg = tcg_target_call_oarg_regs[i]; - /* ENV should not be modified. */ - tcg_debug_assert(!temp_readonly(ts)); + /* ENV should not be modified. */ + tcg_debug_assert(!temp_readonly(ts)); - reg = tcg_target_call_oarg_regs[i]; - tcg_debug_assert(s->reg_to_temp[reg] == NULL); - if (ts->val_type == TEMP_VAL_REG) { - s->reg_to_temp[ts->reg] = NULL; + tcg_debug_assert(s->reg_to_temp[reg] == NULL); + if (ts->val_type == TEMP_VAL_REG) { + s->reg_to_temp[ts->reg] = NULL; + } + ts->val_type = TEMP_VAL_REG; + ts->reg = reg; + ts->mem_coherent = 0; + s->reg_to_temp[reg] = ts; } - ts->val_type = TEMP_VAL_REG; - ts->reg = reg; - ts->mem_coherent = 0; - s->reg_to_temp[reg] = ts; + break; + default: + g_assert_not_reached(); + } + + /* Flush or discard output registers as needed. */ + for (i = 0; i < nb_oargs; i++) { + TCGTemp *ts = arg_temp(op->args[i]); if (NEED_SYNC_ARG(i)) { - temp_sync(s, ts, allocated_regs, 0, IS_DEAD_ARG(i)); + temp_sync(s, ts, s->reserved_regs, 0, IS_DEAD_ARG(i)); } else if (IS_DEAD_ARG(i)) { temp_dead(s, ts); } From patchwork Fri Nov 11 07:40:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623676 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp616117pvb; Thu, 10 Nov 2022 23:43:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf7AHZbq/6QxPjHpPXGk3ipiTTzj80iBsWCFEd6rIOhTEY9XFUwsI69Y1U81w116K3ksnNXn X-Received: by 2002:ac8:741a:0:b0:394:24cb:b18d with SMTP id p26-20020ac8741a000000b0039424cbb18dmr332373qtq.468.1668152589168; Thu, 10 Nov 2022 23:43:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152589; cv=none; d=google.com; s=arc-20160816; b=xemY9GzvxlSXGlgaq8HBQdnBxTEWrEFc95yKo1VFdeuByvO1+hNLnTv+LW9DGlqCOe wO3JADDo6CMLlkUsU7EbblQnfhzVEu0CyZtl/M+7cF1eV2ak19CxCZT5Zsj44yOZMvOr X8/67P2L2h+XvrEqpztPJ2dGFz4eWy1XsfNNtktcbsDoxFCEQh6Uh9+GW5AgeLyCajSp H6Vs274G9b7McVlI9YF4bqHTSLlB9J7lc+JgiTNnm4az7Py+brqT6vZWDulbA0WpvbBV 0ejCbvNU3OGY2gkdFZIRQJd6tTlCyO+4COf1ID1OD5t05ZT9YhLroNhKuqeWEdbm6xIN uXJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=0ZQG968cCLHg8HVm2dJGoqT+NSocp8qSs9dff1Js7hI=; b=xY2VW80qpeUQPxEvAMh0P2CBlZgnIdwaaQPxGeLjSreF+S3ffSkgytB8CVxR+JW4ld iHqJiXmICBlwzdD3LrQk9YPMMQ4cxNgYyH5PEHGctggfwkEbzNpnJMI7nubgKVGAHUjh YQgF8m294NNfyzJfqgxQ7rZMq5zoH2AxXdcN4cjmCVWE8GeyfqwmFHhOmw4HHdx8UyAO j9LGy0lxRNRLOBifdtTbg1ITAFAClTsiZ7gxGNNCOsA/WSiF2qpTdAwtTwQW1dfcZU4B 3SKVYksdlHpmr8Kubq8q9I4uSdFOS0yvflifkdy2zhq+7sirL34qH2t9TuodubbxFbCD VZYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gxQiJkhb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r201-20020a3744d2000000b006bb1387fdc9si671573qka.468.2022.11.10.23.43.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:43:09 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gxQiJkhb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOgB-0006q1-GL; Fri, 11 Nov 2022 02:42:23 -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 1otOg7-0006ms-UM for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:19 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOfz-0000G5-0d for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:19 -0500 Received: by mail-pj1-x102d.google.com with SMTP id m14-20020a17090a3f8e00b00212dab39bcdso7114858pjc.0 for ; Thu, 10 Nov 2022 23:42:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=0ZQG968cCLHg8HVm2dJGoqT+NSocp8qSs9dff1Js7hI=; b=gxQiJkhbqeptLj/PONnwOG7SVGYwS0OHxrvnRqD284OZV04YrrG4x1FeJ4HQFjtSVT uVDmBhBf4cmnEE/TyxKRobv7+nvPGGtXghdaPVyZHEF9+iNrQr8yLudW80IjLbtI9pEa CebdKmDDCGnch9wxe9UyDrfWqpTEwCR6iR2rLw2tiTEcw7EXDJsX0fS3oPXeledPQHwe dPljodtnCxXNmeLt/bHzw++i7YDMnZQxWMJwgGVijQW4dk+5lZN8RCPMFeqPK11oyBUH s1LUp9bBBoDUsZt8IFu2Ed0Nogmf/kr7bfAGo5HIl7ffvyeMBWPuxBznqL9IMVPP2tFW OH3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0ZQG968cCLHg8HVm2dJGoqT+NSocp8qSs9dff1Js7hI=; b=mDK1PnxrHTXnFlgEncKAk3ZKO7JuryWcSd41Z8L9ZvTburqukrROzMpPAswLMhKwy4 thv1Y49A5+QDG5lKKkoLujYwLqLPX2JyPp6rF0IKjldnegMd80a5HVEs8ysy7OELabF9 0eUa9MVUFWkVYfpgQ3+V/pgK0F34zoQCGMJ3MDc/RiYgyK7MvgkCYaRKAW9wcQKjR6T8 xZVgJb7RrWu3ee2OkvYciYdQyVjKum/SzkdEogSqJEZ0JYweWszj7z3N1UXFYiKhA17D C4jLhyXZm4hGdfldsqoC4Djca5C0rJOyn/Sb0Qz6nZR6DLb5EJUJ5giDDsIATsFH78n/ h34w== X-Gm-Message-State: ANoB5pkpTXyt7K+BUHmCx77o96fKI3XbZNMg+uH3QvIsQHKvUYYarmjB 9fGIERzYtKYbaOmsMhJ8sxHe5WsZg9fKg5Px X-Received: by 2002:a17:903:3303:b0:180:e685:2db5 with SMTP id jk3-20020a170903330300b00180e6852db5mr1432372plb.112.1668152528456; Thu, 10 Nov 2022 23:42:08 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 26/45] tcg: Move ffi_cif pointer into TCGHelperInfo Date: Fri, 11 Nov 2022 17:40:42 +1000 Message-Id: <20221111074101.2069454-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Instead of requiring a separate hash table lookup, put a pointer to the CIF into TCGHelperInfo. Signed-off-by: Richard Henderson --- tcg/tcg-internal.h | 7 +++ tcg/tcg.c | 129 +++++++++++++++++++++++++-------------------- 2 files changed, 78 insertions(+), 58 deletions(-) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index c7e87e193d..6e50aeba3a 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -25,6 +25,10 @@ #ifndef TCG_INTERNAL_H #define TCG_INTERNAL_H +#ifdef CONFIG_TCG_INTERPRETER +#include +#endif + #define TCG_HIGHWATER 1024 /* @@ -57,6 +61,9 @@ typedef struct TCGCallArgumentLoc { typedef struct TCGHelperInfo { void *func; const char *name; +#ifdef CONFIG_TCG_INTERPRETER + ffi_cif *cif; +#endif unsigned typemask : 32; unsigned flags : 8; unsigned nr_in : 8; diff --git a/tcg/tcg.c b/tcg/tcg.c index cabc397a38..cb203db4b5 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -62,10 +62,6 @@ #include "tcg/tcg-ldst.h" #include "tcg-internal.h" -#ifdef CONFIG_TCG_INTERPRETER -#include -#endif - /* Forward declarations for functions declared in tcg-target.c.inc and used here. */ static void tcg_target_init(TCGContext *s); @@ -552,17 +548,76 @@ static TCGHelperInfo all_helpers[] = { static GHashTable *helper_table; #ifdef CONFIG_TCG_INTERPRETER -static GHashTable *ffi_table; +static ffi_type *typecode_to_ffi(int argmask) +{ + switch (argmask) { + case dh_typecode_void: + return &ffi_type_void; + case dh_typecode_i32: + return &ffi_type_uint32; + case dh_typecode_s32: + return &ffi_type_sint32; + case dh_typecode_i64: + return &ffi_type_uint64; + case dh_typecode_s64: + return &ffi_type_sint64; + case dh_typecode_ptr: + return &ffi_type_pointer; + } + g_assert_not_reached(); +} -static ffi_type * const typecode_to_ffi[8] = { - [dh_typecode_void] = &ffi_type_void, - [dh_typecode_i32] = &ffi_type_uint32, - [dh_typecode_s32] = &ffi_type_sint32, - [dh_typecode_i64] = &ffi_type_uint64, - [dh_typecode_s64] = &ffi_type_sint64, - [dh_typecode_ptr] = &ffi_type_pointer, -}; -#endif +static void init_ffi_layouts(void) +{ + /* g_direct_hash/equal for direct comparisons on uint32_t. */ + GHashTable *ffi_table = g_hash_table_new(NULL, NULL); + + for (int i = 0; i < ARRAY_SIZE(all_helpers); ++i) { + TCGHelperInfo *info = &all_helpers[i]; + unsigned typemask = info->typemask; + gpointer hash = (gpointer)(uintptr_t)typemask; + struct { + ffi_cif cif; + ffi_type *args[]; + } *ca; + ffi_status status; + int nargs; + ffi_cif *cif; + + cif = g_hash_table_lookup(ffi_table, hash); + if (cif) { + info->cif = cif; + continue; + } + + /* Ignoring the return type, find the last non-zero field. */ + nargs = 32 - clz32(typemask >> 3); + nargs = DIV_ROUND_UP(nargs, 3); + + ca = g_malloc0(sizeof(*ca) + nargs * sizeof(ffi_type *)); + ca->cif.rtype = typecode_to_ffi(typemask & 7); + ca->cif.nargs = nargs; + + if (nargs != 0) { + ca->cif.arg_types = ca->args; + for (int j = 0; j < nargs; ++j) { + int typecode = extract32(typemask, (j + 1) * 3, 3); + ca->args[j] = typecode_to_ffi(typecode); + } + } + + status = ffi_prep_cif(&ca->cif, FFI_DEFAULT_ABI, nargs, + ca->cif.rtype, ca->cif.arg_types); + assert(status == FFI_OK); + + cif = &ca->cif; + info->cif = cif; + g_hash_table_insert(ffi_table, hash, (gpointer)cif); + } + + g_hash_table_destroy(ffi_table); +} +#endif /* CONFIG_TCG_INTERPRETER */ typedef struct TCGCumulativeArgs { int arg_idx; /* tcg_gen_callN args[] */ @@ -743,44 +798,7 @@ static void tcg_context_init(unsigned max_cpus) } #ifdef CONFIG_TCG_INTERPRETER - /* g_direct_hash/equal for direct comparisons on uint32_t. */ - ffi_table = g_hash_table_new(NULL, NULL); - for (i = 0; i < ARRAY_SIZE(all_helpers); ++i) { - struct { - ffi_cif cif; - ffi_type *args[]; - } *ca; - uint32_t typemask = all_helpers[i].typemask; - gpointer hash = (gpointer)(uintptr_t)typemask; - ffi_status status; - int nargs; - - if (g_hash_table_lookup(ffi_table, hash)) { - continue; - } - - /* Ignoring the return type, find the last non-zero field. */ - nargs = 32 - clz32(typemask >> 3); - nargs = DIV_ROUND_UP(nargs, 3); - - ca = g_malloc0(sizeof(*ca) + nargs * sizeof(ffi_type *)); - ca->cif.rtype = typecode_to_ffi[typemask & 7]; - ca->cif.nargs = nargs; - - if (nargs != 0) { - ca->cif.arg_types = ca->args; - for (int j = 0; j < nargs; ++j) { - int typecode = extract32(typemask, (j + 1) * 3, 3); - ca->args[j] = typecode_to_ffi[typecode]; - } - } - - status = ffi_prep_cif(&ca->cif, FFI_DEFAULT_ABI, nargs, - ca->cif.rtype, ca->cif.arg_types); - assert(status == FFI_OK); - - g_hash_table_insert(ffi_table, hash, (gpointer)&ca->cif); - } + init_ffi_layouts(); #endif tcg_target_init(s); @@ -4398,12 +4416,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) } #ifdef CONFIG_TCG_INTERPRETER - { - gpointer hash = (gpointer)(uintptr_t)info->typemask; - ffi_cif *cif = g_hash_table_lookup(ffi_table, hash); - assert(cif != NULL); - tcg_out_call(s, tcg_call_func(op), cif); - } + tcg_out_call(s, tcg_call_func(op), info->cif); #else tcg_out_call(s, tcg_call_func(op)); #endif From patchwork Fri Nov 11 07:40:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623682 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp616376pvb; Thu, 10 Nov 2022 23:44:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Rnlb91GRekZiR9zo1/iMuPx4alpeaiSgTrFzCnhozAfTbwxzIXbbtDlOV5Gt2f6flqMuO X-Received: by 2002:a05:620a:892:b0:6ee:3e43:ac50 with SMTP id b18-20020a05620a089200b006ee3e43ac50mr185433qka.359.1668152648771; Thu, 10 Nov 2022 23:44:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152648; cv=none; d=google.com; s=arc-20160816; b=E91qH706QK7MKNZNzAqJsykJOQCAmOytE+Om5YLU2JYf685Lb1/VRaoSWbNOww5F6+ RYC7GmT1so+ySUo1p5KXxoiqg6aHD474wnADcnZnksMX/SlQL9b4UkAyBhHbl1lXt45g cWbvrqGcRoq25S6Bw38biGcd76DtlN7b2gWnhTs4eLnIqoW0TGYKQP47VKCZfPYg/tez VLxdZ8a96qmzCShIblLPU14jgyN7G1kjp9gkBRDOJ5Zta/zfylaMfIx57jUA6kknrPQH tNlry3yNKQhW7jWksweqvk1vQFdi1xwpYwFMWW2Q3yZdrEGrGj5PQtzaklk3NrDgqIsI jt8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=tSbRzCjHlrSQSoghRByzLuEHEpXHbvdfoP5b3KIKF+c=; b=kXNNAYnX/gzH69LDzRj+f1yU2RAofCdm7u+D3MCf9Kq9/Hyhl9XBKUI3yDxTaj8xo+ 94YxyzI1FS5P/4A3iIYpdPWiuR6NIBCmHqUjri+PLmFYn2kR+LeaWAs5UMguBNmA2VEK iIjOWzW3H+5RSg26HhOXhrD7lDr4UhgWlxhwilX09tQ+kSFuv10yRKkX5LCDEf99f1Cm h4n+Q1jcLb1vDQLMOdMS98Tx+Bbh5gVceIQIprtptGjlwlwpxbeNgCOPgviglhzXFJWr 2NirmeA63yor/rZYhPq8XMvX1Cs9tnSmEy3C0VyrASSkONkl4gCaGmxSx4ohVQj6MvIC 8kKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qUuq9QN/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v5-20020a05622a188500b003a51c960c9bsi715698qtc.653.2022.11.10.23.44.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:44:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qUuq9QN/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOgB-0006qK-Ni; Fri, 11 Nov 2022 02:42:23 -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 1otOg9-0006o4-3j for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:21 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOg2-00082S-R7 for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:20 -0500 Received: by mail-pl1-x62a.google.com with SMTP id l2so3601547pld.13 for ; Thu, 10 Nov 2022 23:42:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=tSbRzCjHlrSQSoghRByzLuEHEpXHbvdfoP5b3KIKF+c=; b=qUuq9QN/1GOuvvv3rdTcqjGcNENyVX9CCFSqId0unweu07cr6iEBPBros8pFwaEZYQ Rpi1VghcVUaNYoSLpI3nnXgddLwa9UYkUaCEkFY09t1AsHNDLIFsY8LibMG4I0SxVIbj 2hqcdXdlX+XHWig2CJqKJ5S0NEGY0WktrQiFxdoTXm+TGoT80l63LpG0RFBqW8jOlaw/ ks0P7h4HOkHy4HCIoTAwIP4+XUgyrFSnIEuBZv9T7MHqrY8NDqCQpTlv3r22P2Zl42kI OfTSfHbyviXIt9KtviN3zd+ilTbtbx+T/GsMijV4GKhb5am4b0FTp4aRrZDj4iZ86fcF 3DRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tSbRzCjHlrSQSoghRByzLuEHEpXHbvdfoP5b3KIKF+c=; b=1z6q5SBnLdDNP0qV4zCLycgMaVXR/DMDsu7iHszg5lIPNUXJxAwdiT0/oY6sZjk33/ XDorQSblkU0p68xocoOn8pcsfd+MLqtQxENSSyPQCndzR6uitBlnbciNPDY5byA+rzqf SFzjSsLY1yvPg3RRXAg6sE4S4kr4gJId9qp9nTPUtYW6Cqpl4US9/5ybQpSlkucBZ+jX ni2SvWhHaJ+8Vn6f5T3fcNyklG3K0xgpCunzsBTgLSJxkPyUnFJphktpicTuoxYqAQrP s2sPvIfx65bBIpp94DiK2xQk6vQxZl+WPTQaOtK1lJKEANr4KDSIfCspvr2GtS4Scbjc +kOA== X-Gm-Message-State: ANoB5pnQHmDHVyjddYidrPxkPEzfeCu1tbM1mgEPyS2iCantX/BEMVPf NV0FpKuxWE8K6vD8BZpwjPEWid2CYRfdvVGU X-Received: by 2002:a17:902:f68c:b0:186:90a7:6b80 with SMTP id l12-20020a170902f68c00b0018690a76b80mr1284094plg.172.1668152530466; Thu, 10 Nov 2022 23:42:10 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 27/45] tcg/aarch64: Merge tcg_out_callr into tcg_out_call Date: Fri, 11 Nov 2022 17:40:43 +1000 Message-Id: <20221111074101.2069454-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org There is only one use, and BLR is perhaps even more self-documentary than CALLR. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c.inc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 344b63e20f..1af879e6f5 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1336,11 +1336,6 @@ static void tcg_out_goto_long(TCGContext *s, const tcg_insn_unit *target) } } -static inline void tcg_out_callr(TCGContext *s, TCGReg reg) -{ - tcg_out_insn(s, 3207, BLR, reg); -} - static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) { ptrdiff_t offset = tcg_pcrel_diff(s, target) >> 2; @@ -1348,7 +1343,7 @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) tcg_out_insn(s, 3206, BL, offset); } else { tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, (intptr_t)target); - tcg_out_callr(s, TCG_REG_TMP); + tcg_out_insn(s, 3207, BLR, TCG_REG_TMP); } } From patchwork Fri Nov 11 07:40:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623708 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp630203pvb; Fri, 11 Nov 2022 00:18:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf62hwGTrKFbaxC9c2OnjJm4CAzAzroRmOOQWkajxFBvFSmfR8iz4t5abdIll0A8plmOH0Id X-Received: by 2002:ae9:eb8c:0:b0:6f6:59fd:3cd1 with SMTP id b134-20020ae9eb8c000000b006f659fd3cd1mr259438qkg.96.1668154716941; Fri, 11 Nov 2022 00:18:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668154716; cv=none; d=google.com; s=arc-20160816; b=U3mEJBsnq02CAc87D95S2mPuJd5HMFFEIANubbFNQi8oObrA8jE86jqSCv6mGRV8uf 5kwn31VLRXVCHbYlKyommJTvA1125PnAtDsfOaCBzm1CIiS/tWAmylWG8nfczR3dfMLy HGEOR/Vu+JSSgIb+5+GcMZiPhoZ5leYAom1zrQR3fdVmCk8w6U5e21/pCKdgJlSBI2Dy bRYpb+jnIY+sR2hBIdyXFf3TGvPSV0hWvWmCNjzI0pM/SpVheF2uF4yUOkFsnBZXrKR5 esLF/ZcOEzv44VpiPD5bcxCyRgM43JIPJ9hcN7ItSqxKeKjpbr46LbZwUH+M+WrWOg8l TPKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ME63TjYqNRpM02aThyymAHM7GLv4ouYyhPoDevl49WI=; b=e95bqHUmNCRSW8q43XbtfTBHLtxb+Ks+dpyxjfByqsXx9htr+YRaJOCWdSlOdSbuX6 wy3JGsrq32XJc3ragStzq8e7iSruASHbG0XkcQp2PwCM8nlBmsbRcqwZBC/gRkoAAOVE BlavO+iQv2z4h+DntEHdaFl7KOpRWrh69m8zlWbHPLrIlMY+N+6hPJI3ZAhpvnQ/PrPq tSR2GXX/xKhroTEQPUyVGWLzf8InCoZeP2kvh+Uz3KxKk06mph3w+zbV6DtxnM1XHchL WDoV5obdAdrjfU68iVnassHIMW1DjJ/dO6uPXV2fhLUH4Z2mjPjmCslnUbXq7gtUQRRs jeeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AzfZ/yeH"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y20-20020a05620a25d400b006fb0b944a7asi795878qko.161.2022.11.11.00.18.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:18:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AzfZ/yeH"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOgI-0006yz-IP; Fri, 11 Nov 2022 02:42:30 -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 1otOg9-0006pQ-Q2 for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:23 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOg2-0000Gn-Q1 for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:21 -0500 Received: by mail-pl1-x62c.google.com with SMTP id io19so3620426plb.8 for ; Thu, 10 Nov 2022 23:42:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=ME63TjYqNRpM02aThyymAHM7GLv4ouYyhPoDevl49WI=; b=AzfZ/yeHkxbOYgclhTZRV+kAFjoWbVmPewm2I3h+ALomWbAvXTX7K6Q8yeKE9pCAoW GVM5Ji33Ib358njpyp9e5XZzoekt6bII3l+satQGVhzlBh5qMu4gl83QSoytm+TKdl5W 3Ogz4Q8t6AH91X778VN1RNS8SImVfYScNQwxLVie+Qb51z/neuvMyZWAcU9SSvwlf/Oz D8dFfN75dAAXrheGfgj0dNbVbL7gBP62U20s9IoSu4BUmExdZ5OaK8iM70TyV0BrpLlu UlhFn9DyUvEBOkHauvRspqUk4UfpXyaKRI+s47qdJ4VvG6qQcTrF9XBkzDCthz1vrpYf 3IOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ME63TjYqNRpM02aThyymAHM7GLv4ouYyhPoDevl49WI=; b=7l8zQTjlXdpjwGDS0kbXno4m9eBJMfdFhHc14ywALnewas8YOQRgfvE2baiNLli3aU KSWSysRLIddjppOikokESPtt7HWL0d5b884PM9bmYbKFSGnm+O/k4QWrctduVS2gDcgp nOMRC+RD+RbkiZvzi/w3Si8yfwJ72ppWEMFcysp7S79WM5+1XFIpdUlnd7xf6cI2NYIR j71RFB4rnPKOCLVhOMdKNlUE8Gq/lyG4t9p+cgA8tBdmRxpbKkef1dPy33YUSqmLHsx/ gccaA4qgy10mXHzHDc0vx/Vbum4vDLF1P0TDiR1yIzKOLagXWXeNJefYw61+M1X2LVZL T8gg== X-Gm-Message-State: ANoB5pkRLE0RIvqGovpahUp8iHt5ukmnWoFpAHd7VkY4vPt4BP8XJWdo b+GlYe5s1ibu5HwCmUexN0X6Mxp0iEawwEMV X-Received: by 2002:a17:90b:400e:b0:210:f1f7:575e with SMTP id ie14-20020a17090b400e00b00210f1f7575emr680585pjb.47.1668152532997; Thu, 10 Nov 2022 23:42:12 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH for-8.0 v3 28/45] tcg: Add TCGHelperInfo argument to tcg_out_call Date: Fri, 11 Nov 2022 17:40:44 +1000 Message-Id: <20221111074101.2069454-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This eliminates an ifdef for TCI, and will be required for expanding the call for TCGv_i128. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tcg.c | 12 ++---------- tcg/aarch64/tcg-target.c.inc | 12 +++++++++--- tcg/arm/tcg-target.c.inc | 10 ++++++++-- tcg/i386/tcg-target.c.inc | 5 +++-- tcg/loongarch64/tcg-target.c.inc | 7 ++++--- tcg/mips/tcg-target.c.inc | 3 ++- tcg/ppc/tcg-target.c.inc | 7 ++++--- tcg/riscv/tcg-target.c.inc | 7 ++++--- tcg/s390x/tcg-target.c.inc | 12 +++++++++--- tcg/sparc64/tcg-target.c.inc | 3 ++- tcg/tci/tcg-target.c.inc | 3 ++- 11 files changed, 49 insertions(+), 32 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index cb203db4b5..c5f8f4ac2c 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -145,12 +145,8 @@ static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, TCGReg arg1, intptr_t arg2); static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, TCGReg base, intptr_t ofs); -#ifdef CONFIG_TCG_INTERPRETER static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target, - ffi_cif *cif); -#else -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target); -#endif + const TCGHelperInfo *info); static bool tcg_target_const_match(int64_t val, TCGType type, int ct); #ifdef TCG_TARGET_NEED_LDST_LABELS static int tcg_out_ldst_finalize(TCGContext *s); @@ -4415,11 +4411,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) save_globals(s, allocated_regs); } -#ifdef CONFIG_TCG_INTERPRETER - tcg_out_call(s, tcg_call_func(op), info->cif); -#else - tcg_out_call(s, tcg_call_func(op)); -#endif + tcg_out_call(s, tcg_call_func(op), info); /* Assign output registers and emit moves if needed. */ switch (info->out_kind) { diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 1af879e6f5..ad1816e32d 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1336,7 +1336,7 @@ static void tcg_out_goto_long(TCGContext *s, const tcg_insn_unit *target) } } -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) +static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *target) { ptrdiff_t offset = tcg_pcrel_diff(s, target) >> 2; if (offset == sextract64(offset, 0, 26)) { @@ -1347,6 +1347,12 @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) } } +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target, + const TCGHelperInfo *info) +{ + tcg_out_call_int(s, target); +} + void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, uintptr_t jmp_rw, uintptr_t addr) { @@ -1594,7 +1600,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) tcg_out_mov(s, TARGET_LONG_BITS == 64, TCG_REG_X1, lb->addrlo_reg); tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_X2, oi); tcg_out_adr(s, TCG_REG_X3, lb->raddr); - tcg_out_call(s, qemu_ld_helpers[opc & MO_SIZE]); + tcg_out_call_int(s, qemu_ld_helpers[opc & MO_SIZE]); if (opc & MO_SIGN) { tcg_out_sxt(s, lb->type, size, lb->datalo_reg, TCG_REG_X0); } else { @@ -1620,7 +1626,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) tcg_out_mov(s, size == MO_64, TCG_REG_X2, lb->datalo_reg); tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_X3, oi); tcg_out_adr(s, TCG_REG_X4, lb->raddr); - tcg_out_call(s, qemu_st_helpers[opc & MO_SIZE]); + tcg_out_call_int(s, qemu_st_helpers[opc & MO_SIZE]); tcg_out_goto(s, lb->raddr); return true; } diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index aa3a888fed..e82749a602 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1131,7 +1131,7 @@ static void tcg_out_goto(TCGContext *s, ARMCond cond, const tcg_insn_unit *addr) * The call case is mostly used for helpers - so it's not unreasonable * for them to be beyond branch range. */ -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *addr) +static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *addr) { intptr_t addri = (intptr_t)addr; ptrdiff_t disp = tcg_pcrel_diff(s, addr); @@ -1150,6 +1150,12 @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *addr) tcg_out_blx_reg(s, COND_AL, TCG_REG_TMP); } +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *addr, + const TCGHelperInfo *info) +{ + tcg_out_call_int(s, addr); +} + static void tcg_out_goto_label(TCGContext *s, ARMCond cond, TCGLabel *l) { if (l->has_value) { @@ -1515,7 +1521,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) argreg = tcg_out_arg_reg32(s, argreg, TCG_REG_R14); /* Use the canonical unsigned helpers and minimize icache usage. */ - tcg_out_call(s, qemu_ld_helpers[opc & MO_SIZE]); + tcg_out_call_int(s, qemu_ld_helpers[opc & MO_SIZE]); datalo = lb->datalo_reg; datahi = lb->datahi_reg; diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index cb04e4b3ad..58bd5873f5 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1661,7 +1661,8 @@ static void tcg_out_branch(TCGContext *s, int call, const tcg_insn_unit *dest) } } -static inline void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest, + const TCGHelperInfo *info) { tcg_out_branch(s, 1, dest); } @@ -1885,7 +1886,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) (uintptr_t)l->raddr); } - tcg_out_call(s, qemu_ld_helpers[opc & (MO_BSWAP | MO_SIZE)]); + tcg_out_branch(s, 1, qemu_ld_helpers[opc & (MO_BSWAP | MO_SIZE)]); data_reg = l->datalo_reg; switch (opc & MO_SSIZE) { diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index d326e28740..c9e99e8ec3 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -567,7 +567,8 @@ static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool tail) } } -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg, + const TCGHelperInfo *info) { tcg_out_call_int(s, arg, false); } @@ -760,7 +761,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A2, oi); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A3, (tcg_target_long)l->raddr); - tcg_out_call(s, qemu_ld_helpers[size]); + tcg_out_call_int(s, qemu_ld_helpers[size], false); switch (opc & MO_SSIZE) { case MO_SB: @@ -821,7 +822,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A3, oi); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A4, (tcg_target_long)l->raddr); - tcg_out_call(s, qemu_st_helpers[size]); + tcg_out_call_int(s, qemu_st_helpers[size], false); return tcg_out_goto(s, l->raddr); } diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index bd76f0c97f..292e490b5c 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -1020,7 +1020,8 @@ static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool tail) } } -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg, + const TCGHelperInfo *info) { tcg_out_call_int(s, arg, false); tcg_out_nop(s); diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 500b75a03a..f561a3492f 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -2002,7 +2002,8 @@ static void tcg_out_call_int(TCGContext *s, int lk, #endif } -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target, + const TCGHelperInfo *info) { tcg_out_call_int(s, LK, target); } @@ -2221,7 +2222,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) tcg_out_movi(s, TCG_TYPE_I32, arg++, oi); tcg_out32(s, MFSPR | RT(arg) | LR); - tcg_out_call(s, qemu_ld_helpers[opc & (MO_BSWAP | MO_SIZE)]); + tcg_out_call_int(s, LK, qemu_ld_helpers[opc & (MO_BSWAP | MO_SIZE)]); lo = lb->datalo_reg; hi = lb->datahi_reg; @@ -2290,7 +2291,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) tcg_out_movi(s, TCG_TYPE_I32, arg++, oi); tcg_out32(s, MFSPR | RT(arg) | LR); - tcg_out_call(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); + tcg_out_call_int(s, LK, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); tcg_out_b(s, 0, lb->raddr); return true; diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 81a83e45b1..aa017d665a 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -819,7 +819,8 @@ static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool tail) } } -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg, + const TCGHelperInfo *info) { tcg_out_call_int(s, arg, false); } @@ -1002,7 +1003,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) tcg_out_movi(s, TCG_TYPE_PTR, a2, oi); tcg_out_movi(s, TCG_TYPE_PTR, a3, (tcg_target_long)l->raddr); - tcg_out_call(s, qemu_ld_helpers[opc & MO_SSIZE]); + tcg_out_call_int(s, qemu_ld_helpers[opc & MO_SSIZE], false); tcg_out_mov(s, (opc & MO_SIZE) == MO_64, l->datalo_reg, a0); tcg_out_goto(s, l->raddr); @@ -1047,7 +1048,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) tcg_out_movi(s, TCG_TYPE_PTR, a3, oi); tcg_out_movi(s, TCG_TYPE_PTR, a4, (tcg_target_long)l->raddr); - tcg_out_call(s, qemu_st_helpers[opc & MO_SIZE]); + tcg_out_call_int(s, qemu_st_helpers[opc & MO_SIZE], false); tcg_out_goto(s, l->raddr); return true; diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index 47aaba7667..c3c0bcc3eb 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -1691,7 +1691,7 @@ static void tgen_brcond(TCGContext *s, TCGType type, TCGCond c, tgen_branch(s, cc, l); } -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) +static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *dest) { ptrdiff_t off = tcg_pcrel_diff(s, dest) >> 1; if (off == (int32_t)off) { @@ -1702,6 +1702,12 @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) } } +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest, + const TCGHelperInfo *info) +{ + tcg_out_call_int(s, dest); +} + static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc, TCGReg data, TCGReg base, TCGReg index, int disp) { @@ -1897,7 +1903,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) } tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_R4, oi); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R5, (uintptr_t)lb->raddr); - tcg_out_call(s, qemu_ld_helpers[opc & (MO_BSWAP | MO_SSIZE)]); + tcg_out_call_int(s, qemu_ld_helpers[opc & (MO_BSWAP | MO_SSIZE)]); tcg_out_mov(s, TCG_TYPE_I64, data_reg, TCG_REG_R2); tgen_gotoi(s, S390_CC_ALWAYS, lb->raddr); @@ -1938,7 +1944,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) } tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_R5, oi); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R6, (uintptr_t)lb->raddr); - tcg_out_call(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); + tcg_out_call_int(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); tgen_gotoi(s, S390_CC_ALWAYS, lb->raddr); return true; diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index cb9453efdd..eb913f33c8 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -859,7 +859,8 @@ static void tcg_out_call_nodelay(TCGContext *s, const tcg_insn_unit *dest, } } -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest, + const TCGHelperInfo *info) { tcg_out_call_nodelay(s, dest, false); tcg_out_nop(s); diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index c1acaa943e..d36a7ebdd1 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -558,8 +558,9 @@ static void tcg_out_movi(TCGContext *s, TCGType type, } static void tcg_out_call(TCGContext *s, const tcg_insn_unit *func, - ffi_cif *cif) + const TCGHelperInfo *info) { + ffi_cif *cif = info->cif; tcg_insn_unit insn = 0; uint8_t which; From patchwork Fri Nov 11 07:40:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623700 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp624532pvb; Fri, 11 Nov 2022 00:04:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf7de71wBDmcCwVlqzX5jnTUlIB33ymMUxf97AWAkQKZ2yYJSJ583aR+Mlwl00pS2YkCBQLP X-Received: by 2002:ac8:71c4:0:b0:3a4:f1c1:49a9 with SMTP id i4-20020ac871c4000000b003a4f1c149a9mr370018qtp.464.1668153875750; Fri, 11 Nov 2022 00:04:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668153875; cv=none; d=google.com; s=arc-20160816; b=Pi3SPwacwiV26UdeX0kxrSN66IUjRtBQLFrG7JAyb5Ae0myyIXp96a1I/tuwqFQzc3 ZswFHKzQ9bnL5uP5LejUphpcL7GWxoy4fIXs/REGywPlPC/CPIzX9DOY4B1SP8m9DUlx n3YoHDUhpoSF51YRuakvy2pOO72RlPtx20tgoKhcMYyUYtDejlvyMLIHrCiUHhFQH5KX RfwUwil+CeYOJh+Bk4JLA2YEvu7s3TOapB6/dZ1Qw5xgYp8DdeU2/Ea6ouZ/lDcDuG0c 7uw9WDm8DomUS0MLPqAYGvSUcgZZ+rjBU10azTzKqnbYYhAu33qZQm/y29O1LRMa8r7S cSBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=AYWDMTmY+SCzbBTfhDbUxfPgw9Xf88DejLV4GZrSQBc=; b=tqAhbN8x2n6HLZDpddCSlXr8wtbxp5mqI/W4ceQTpmFJG4IZ5HD4y4/qD+fkWydhje 3rwaZaMXR3J9h9kcpKC2rkDqsHqo3dtgCdO1/GHNAhyTlbyFpf+2qjOq1hGioWayfinP 0QfRNGbBrxyG9m5Y/jHYNkOf/unyzO3nEUfNyQXvXmJ+wlAT4xhzY0xpxsWsS1gmuHxo loJ6q9hbuUhrI/kir+crHIYwVMe/1T8vHnFPQBUnjoo3jx/AodFHM3EFVLtWPNLRRTi6 2TLf7RhdqSRHWQzCcXpv+IEeJy53wqimwCREK7D+zMiW6+T+XxAYCbXB4gXogWUaaIl+ al9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eE0koXYe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gd11-20020a05622a5c0b00b0039cb84b2f4csi707531qtb.763.2022.11.11.00.04.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:04:35 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eE0koXYe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOgH-0006yg-Pv; Fri, 11 Nov 2022 02:42:29 -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 1otOg9-0006oR-CN for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:21 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOg4-0000H1-Iu for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:21 -0500 Received: by mail-pl1-x631.google.com with SMTP id l2so3601655pld.13 for ; Thu, 10 Nov 2022 23:42:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=AYWDMTmY+SCzbBTfhDbUxfPgw9Xf88DejLV4GZrSQBc=; b=eE0koXYee/C9gxFvEcZtnb1oCeVIr+EMJnb3POBDRSyEvihNoM418vSi2amDnMbvq5 oqG08I2d667cnV9VAJqeMoHnZvwDumve67lhoteVwQ1b6dA8GA7jLj+oTHa1tM5W6g1+ k9EMHd7weD1HD5cMUiQDxwLJz0yP+B7PmIj9PDuNHW/yrTYwWfn3y7Rfg5fDoFiV6Fhx zvOeb/twoMdkbCWalBFQTgL+NTh82PtvpFhdOvOGtpsD1KmuQc8/3ymuaJk72vb67EUZ iOAEdfvKV63I23oDWws0eU8Xxq6eftcvFaoSxbcM2bFq4UcfB2aep0P+8HxdRpj7X1/B 7AZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AYWDMTmY+SCzbBTfhDbUxfPgw9Xf88DejLV4GZrSQBc=; b=q1zcLQ/4pAYzw8D/fCPAxzVLPlhJrRJgmFCamLsSMOYonVxy7lO/IaLxC6CcItLVUH 0Y5wX/8nVwzujPTC/0VOpnK2DclQWoVA8x1jWjRT+379YltlbnNQn1I5jGOtlMJXjdeM zk+Nx5GeLqQFykifppUyktYp5UAzTwNktwlJAJkDbN4mcEgmLBMd3QaB8l2aFgmTM/mQ 4ZcxREuYXx7lIbFhH0eGgEGePqzcTwGDLQQSA4++FGty8ObHe+YafjzTOPS0HMwBjZ/8 oGJeB+egucmb9jCe1br1/+SZ1RRBM00CvBN9X3p6yVMgDC5LAp7/UMZYUnQZbuksA/ce TpJA== X-Gm-Message-State: ANoB5pn02RyDyWk34xL8smMg5P3wTxcyHntgQGIwTyGkeCtl7966lqs7 PCcoEUCnAKWggMuBj17zQ+pSoFZ602i8dO0K X-Received: by 2002:a17:902:f60d:b0:186:de87:7ff8 with SMTP id n13-20020a170902f60d00b00186de877ff8mr1268140plg.155.1668152535178; Thu, 10 Nov 2022 23:42:15 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 29/45] tcg: Define TCG_TYPE_I128 and related helper macros Date: Fri, 11 Nov 2022 17:40:45 +1000 Message-Id: <20221111074101.2069454-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Begin staging in support for TCGv_i128 with Int128. Define the type enumerator, the typedef, and the helper-head.h macros. This cannot yet be used, because you can't allocate temporaries of this new type. Signed-off-by: Richard Henderson --- include/exec/helper-head.h | 7 +++++++ include/tcg/tcg.h | 17 ++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h index bc6698b19f..b8d1140dc7 100644 --- a/include/exec/helper-head.h +++ b/include/exec/helper-head.h @@ -26,6 +26,7 @@ #define dh_alias_int i32 #define dh_alias_i64 i64 #define dh_alias_s64 i64 +#define dh_alias_i128 i128 #define dh_alias_f16 i32 #define dh_alias_f32 i32 #define dh_alias_f64 i64 @@ -40,6 +41,7 @@ #define dh_ctype_int int #define dh_ctype_i64 uint64_t #define dh_ctype_s64 int64_t +#define dh_ctype_i128 Int128 #define dh_ctype_f16 uint32_t #define dh_ctype_f32 float32 #define dh_ctype_f64 float64 @@ -71,6 +73,7 @@ #define dh_retvar_decl0_noreturn void #define dh_retvar_decl0_i32 TCGv_i32 retval #define dh_retvar_decl0_i64 TCGv_i64 retval +#define dh_retval_decl0_i128 TCGv_i128 retval #define dh_retvar_decl0_ptr TCGv_ptr retval #define dh_retvar_decl0(t) glue(dh_retvar_decl0_, dh_alias(t)) @@ -78,6 +81,7 @@ #define dh_retvar_decl_noreturn #define dh_retvar_decl_i32 TCGv_i32 retval, #define dh_retvar_decl_i64 TCGv_i64 retval, +#define dh_retvar_decl_i128 TCGv_i128 retval, #define dh_retvar_decl_ptr TCGv_ptr retval, #define dh_retvar_decl(t) glue(dh_retvar_decl_, dh_alias(t)) @@ -85,6 +89,7 @@ #define dh_retvar_noreturn NULL #define dh_retvar_i32 tcgv_i32_temp(retval) #define dh_retvar_i64 tcgv_i64_temp(retval) +#define dh_retvar_i128 tcgv_i128_temp(retval) #define dh_retvar_ptr tcgv_ptr_temp(retval) #define dh_retvar(t) glue(dh_retvar_, dh_alias(t)) @@ -95,6 +100,7 @@ #define dh_typecode_i64 4 #define dh_typecode_s64 5 #define dh_typecode_ptr 6 +#define dh_typecode_i128 7 #define dh_typecode_int dh_typecode_s32 #define dh_typecode_f16 dh_typecode_i32 #define dh_typecode_f32 dh_typecode_i32 @@ -104,6 +110,7 @@ #define dh_callflag_i32 0 #define dh_callflag_i64 0 +#define dh_callflag_i128 0 #define dh_callflag_ptr 0 #define dh_callflag_void 0 #define dh_callflag_noreturn TCG_CALL_NO_RETURN diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index b949d75fdd..7d346192ca 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -277,6 +277,7 @@ typedef struct TCGPool { typedef enum TCGType { TCG_TYPE_I32, TCG_TYPE_I64, + TCG_TYPE_I128, TCG_TYPE_V64, TCG_TYPE_V128, @@ -358,13 +359,14 @@ typedef tcg_target_ulong TCGArg; in tcg/README. Target CPU front-end code uses these types to deal with TCG variables as it emits TCG code via the tcg_gen_* functions. They come in several flavours: - * TCGv_i32 : 32 bit integer type - * TCGv_i64 : 64 bit integer type - * TCGv_ptr : a host pointer type - * TCGv_vec : a host vector type; the exact size is not exposed - to the CPU front-end code. - * TCGv : an integer type the same size as target_ulong - (an alias for either TCGv_i32 or TCGv_i64) + * TCGv_i32 : 32 bit integer type + * TCGv_i64 : 64 bit integer type + * TCGv_i128 : 128 bit integer type + * TCGv_ptr : a host pointer type + * TCGv_vec : a host vector type; the exact size is not exposed + to the CPU front-end code. + * TCGv : an integer type the same size as target_ulong + (an alias for either TCGv_i32 or TCGv_i64) The compiler's type checking will complain if you mix them up and pass the wrong sized TCGv to a function. @@ -384,6 +386,7 @@ typedef tcg_target_ulong TCGArg; typedef struct TCGv_i32_d *TCGv_i32; typedef struct TCGv_i64_d *TCGv_i64; +typedef struct TCGv_i128_d *TCGv_i128; typedef struct TCGv_ptr_d *TCGv_ptr; typedef struct TCGv_vec_d *TCGv_vec; typedef TCGv_ptr TCGv_env; From patchwork Fri Nov 11 07:40:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623684 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp616453pvb; Thu, 10 Nov 2022 23:44:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf5VRUfqh/6+0meWE9Ba9MGZm+QIM+WPQI+aC+e2b2p4UjxMtJYRB0f7Ezho/GjFJ/RdwgN3 X-Received: by 2002:a0c:e84b:0:b0:4b4:4f9:1776 with SMTP id l11-20020a0ce84b000000b004b404f91776mr951293qvo.116.1668152659498; Thu, 10 Nov 2022 23:44:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152659; cv=none; d=google.com; s=arc-20160816; b=KERlnvEiz0EqfDXBr6SO8uVKfFFo9/ES4UszjqaKIa6CmjPWZfL9jcHKm4Q7pWEp9d 0lts834RN9a5bwRzLeRfddC86M/890cILELeVSX78wJHI3JxCzdQY9VRJqqrbAyrzSz5 zcrS90eME0OgHdPaHALbtHUn7haS9Z3RIrblUAcv6igUUw4y74Cb6QBjQ8pYDNKHXZjU sZLQDmkUckPZlAFUHl1aCK34GpWtjphQQU/9gs2EqEhbS1ni3XOUGKPV1FuHj2Ft4aW7 sV3hYaQAL6DklAoLSqBiQSkfNCXJuV6Z8SOiRZqIBRTJAEWxFRb67LLjiIKTfvBBERzc nK/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=9Jpwsf6+2qL2tkXL6kSO45vZ0jCGkW11UYFWxCwtIV0=; b=oAIqiz7JOiXhjWf+YGBX65vZLA+TGgFB4aE1ZUIwWm8Kx52MP/W2G2qi9uK8EAeOfe a7vfwNJLwIPG2YzOu4W1xCs5epTWA/EE0D5Je5Cb9a8IydYtkSvaR83J5hnjB/k9Dg3U 5ZIv0CKeUbkPSwKTm1QlTu5kSg+B3v3C8wBkgXmeiLBnIhggyPUpOKUXKAkiwYnrp+nj j1gG51EOkVJFjns2qxneTeDV6knS1B1MZBivdaYTpQpZD3H1qi9TrJI9ho5EfG26HT7V JZtjxJW62FGfLrJFcVxWNNfK2zBJaNeEVheDnXwXwIBr0+H0Xy8l6cm5HN/K3PeQYxZ/ WjpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lU2qM7dN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c20-20020ac87d94000000b003a5504674e8si743496qtd.278.2022.11.10.23.44.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:44:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lU2qM7dN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOgJ-00070L-Qe; Fri, 11 Nov 2022 02:42:31 -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 1otOgA-0006pm-Kn for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:23 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOg6-0000HE-V3 for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:22 -0500 Received: by mail-pj1-x1032.google.com with SMTP id z5-20020a17090a8b8500b00210a3a2364fso7370936pjn.0 for ; Thu, 10 Nov 2022 23:42:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=9Jpwsf6+2qL2tkXL6kSO45vZ0jCGkW11UYFWxCwtIV0=; b=lU2qM7dNR1+4xpakBfuq3ZgoiSDPrl5YlXaipkyrSiwuRD4baI71swryBYPKpilltA 6lxVBE+xDQMhaU5fofoQp6BDWngucwwQVyw52pO5IGtSSCS1Hq7NbyOL0ZYyt/YEQH72 26RGGAYbilidsRVj7T7AG644zkusCMfi/+t5tAC1BbvGWj66DWKF+8Rj05iVsNh21oDV mhAOStB3HxWLShja2bvcQ9ZLtHAGxGDsJZkiG320QvSYwsiLRlIzJ+gl5W21M1cIZzsz Z2YUzm6rS/tRyslggb0qDPi8uNB44ajkk+yKhEbWbx1Y3BG0Croad817cUUUGYxDQXNd V+rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9Jpwsf6+2qL2tkXL6kSO45vZ0jCGkW11UYFWxCwtIV0=; b=RNW37tkB8uaXuSmhr4pnyqoDKkcdTsdseMt58UN7GgG13eHSiE/FkG+7/aCZPbTt6n GA2Y3bmWU0Q59mHT2JR1/B7G/wIqRYDqz1dFFzsDpu2CLVJCqUUyGqiw6v4uoeWe0C/8 Qp4nh/0ZrTKLEeS39YrBJQiTRUTcDvL/BbbmxsnRRbHeuOKFicPSTeTZudoOGYpkLBu5 kV1LKQ+qoxgVqN9HipfL1MT5mwwUtpMfW52MSV9BdWHgpcw7cVkFkjPZbWu8HwoWl3W9 If3UiO5Amy9etI6ppLx131wwe3kstk283AsRCw/Yraw1y9jltkvzJjPoitnR3syr1rgw bW9Q== X-Gm-Message-State: ANoB5pkHbEskzZkbMBcfEcKZB+S8Cky7wzag+l0yblkq0hw1+PsJcd2v vu/y8eO3Qdg8xSvIXqkZYR1zNnfYKw0VRABX X-Received: by 2002:a17:903:3286:b0:187:a98:7eea with SMTP id jh6-20020a170903328600b001870a987eeamr1122854plb.109.1668152537327; Thu, 10 Nov 2022 23:42:17 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:16 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 30/45] tcg: Handle dh_typecode_i128 with TCG_CALL_{RET, ARG}_NORMAL Date: Fri, 11 Nov 2022 17:40:46 +1000 Message-Id: <20221111074101.2069454-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Many hosts pass and return 128-bit quantities like sequential 64-bit quantities. Treat this just like we currently break down 64-bit quantities for a 32-bit host. Signed-off-by: Richard Henderson --- tcg/tcg.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index c5f8f4ac2c..11948256f2 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -685,11 +685,22 @@ static void init_call_layout(TCGHelperInfo *info) case dh_typecode_s64: info->nr_out = 64 / TCG_TARGET_REG_BITS; info->out_kind = TCG_CALL_RET_NORMAL; + assert(info->nr_out <= ARRAY_SIZE(tcg_target_call_oarg_regs)); + break; + case dh_typecode_i128: + info->nr_out = 128 / TCG_TARGET_REG_BITS; + info->out_kind = TCG_CALL_RET_NORMAL; /* TODO */ + switch (/* TODO */ TCG_CALL_RET_NORMAL) { + case TCG_CALL_RET_NORMAL: + assert(info->nr_out <= ARRAY_SIZE(tcg_target_call_oarg_regs)); + break; + default: + qemu_build_not_reached(); + } break; default: g_assert_not_reached(); } - assert(info->nr_out <= ARRAY_SIZE(tcg_target_call_oarg_regs)); /* * Parse and place function arguments. @@ -736,6 +747,18 @@ static void init_call_layout(TCGHelperInfo *info) case dh_typecode_ptr: layout_arg_1(&cum, info, TCG_CALL_ARG_NORMAL); break; + case dh_typecode_i128: + switch (/* TODO */ TCG_CALL_ARG_NORMAL) { + case TCG_CALL_ARG_EVEN: + layout_arg_even(&cum); + /* fall through */ + case TCG_CALL_ARG_NORMAL: + layout_arg_normal_n(&cum, info, 128 / TCG_TARGET_REG_BITS); + break; + default: + qemu_build_not_reached(); + } + break; default: g_assert_not_reached(); } @@ -1653,11 +1676,13 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) op->args[pi++] = temp_arg(ret); break; case 2: + case 4: tcg_debug_assert(ret != NULL); - tcg_debug_assert(ret->base_type == ret->type + 1); + tcg_debug_assert(ret->base_type == ret->type + ctz32(n)); tcg_debug_assert(ret->temp_subindex == 0); - op->args[pi++] = temp_arg(ret); - op->args[pi++] = temp_arg(ret + 1); + for (i = 0; i < n; ++i) { + op->args[pi++] = temp_arg(ret + i); + } break; default: g_assert_not_reached(); From patchwork Fri Nov 11 07:40:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623721 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp633148pvb; Fri, 11 Nov 2022 00:26:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf7cigJ6HawuKbXrzQW1f61LaFNvOpfwQ3yYCafG0wpDsRCo0R1+n9nsVmXEXaZEiOTs6pW7 X-Received: by 2002:a37:c245:0:b0:6ee:909e:ed6c with SMTP id j5-20020a37c245000000b006ee909eed6cmr266075qkm.264.1668155196866; Fri, 11 Nov 2022 00:26:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668155196; cv=none; d=google.com; s=arc-20160816; b=IjnelMRNTRty1Fcdq9ludr/egU9xWYI5XojVs5kBfihg2jCeVWpmiheqPBW/ac5RQP 0sDPxNEQbLfRgLREvDKqkhfdYWvT162euG/Bqa4M+7kkRW390/Y4tAM2I6BVgkpypn5g gaKjUZfumtIWxNTBqPY7N3GX21cIClGRIv4tE1KiqIhaQUTbLRNC6buc9LYyr6jrJX47 RE7b7Fo80ULV1mhzRqRontk1fHDcrtKf2oK8kJByJjxJ58nSDC3HsA0XnQCh94cVnzeu ndfnMKh7nLeAt0JgfWlw+uMyb7ujlbim9jailuUkEtlgyzKcBPWuTshqwALM/qkXTTxf ZOHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=e3FO2jzvIYQcueRqn3HizCpFs7YYSJ2M6+2goqVEkVA=; b=HXdioACffb7H42c8f1PO+VZInkxb3JeJYPyGgsvjy+SU8x4oM4N2FnFsKaFDPT/W1g 2UI1fvV+IUGznSfsquawp+fZ736ivQ2cZ8ehrf/roic1pHkACE5ZDX518k9brleoPW8N twq7eBi0Udc4jZXg1n/tymg13jl2UIKTKG5YDVq5jiWSq3sxE631nEphKVrAUEkoo5Rh VRxF/vmJEXpqNrkuO76Q1xpzZG1jJW5ygmb0ti0AD+/xbDG0CpSyLfzwElVTSbE9qg5L sObSVXFrq6mw6v4XlSKIyFtYNplDyTFwZOnDj3tcDpW+xJkimyYu5IYDxrZWZayZVkJt lLkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vzbGTbDD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r6-20020ac87ee6000000b00397107724f3si720682qtc.205.2022.11.11.00.26.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:26:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vzbGTbDD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOgL-000738-HZ; Fri, 11 Nov 2022 02:42:33 -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 1otOgA-0006po-NA for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:23 -0500 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOg8-0000HZ-PQ for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:22 -0500 Received: by mail-pf1-x42a.google.com with SMTP id k22so4249710pfd.3 for ; Thu, 10 Nov 2022 23:42:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=e3FO2jzvIYQcueRqn3HizCpFs7YYSJ2M6+2goqVEkVA=; b=vzbGTbDDKHAlig8yqbw10X1+5m1n1BFECddiH4nlE8fBsp2rQzhODNkyLdtgtV3cLt DKT6f797bQ4sLaYqZjAgb5kVNTxf05eNdOqQ4mhp//f4aWrAQFwhAFaNqzHfjFU4pRlp QaQBPcpoXsVwqQ7geF+Yav+hWTnLUREDACmDgn+VyUHv6WTktP/leZwp6xnpqKL5+iTJ qJrCjJwxitmUotE2G5unzfvc56ZkgzDEogfOFbUN1ersv64MZINu2a8gK/irwURof/vR otHe2zSli/YECRURYRj/i9flRJS5sSki5RdGxA7giX+cLDFL/sEd0kGhj/RIAQStmWha JETw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e3FO2jzvIYQcueRqn3HizCpFs7YYSJ2M6+2goqVEkVA=; b=RyCC9Yiqn7d+DMblWJgUFd4xKPfcr4OiEnSXH2BbHrV/sa2xyzBVogYO3Z5bONIk+p UvEktukN5HMQltbkWqV0rnnFhHauJ6YYDjIf0ddm5kcVaKRV/DQVbT522fYB0B1Vp2ug uXtjhwZA1eiZo5L2GKIKnkrKp1LZ8yrp6xsu9QF5sQ+j7zSWaKzeUfAkxa0l1EMnUMjZ 87K0LVsGSI6p0W1YxmOZAHYct7lzCZS0juP8TlbD0XY9pXOW2eqrFzwIRMwCgvNipgku jGRCytSmKnd8Qscq28Q/CheyDQaQZvzGsdB5IS2RDrTTkw+ZKIuca60gBWmgDhGw8H9b LFAA== X-Gm-Message-State: ANoB5pnu+SdLO5YgtJcHnmPTnPe4qgUPuA1FB4KG9ByKCFQ2Gmq4V3lU 9phDqmElHl4nPkRvD8mhpNDaH+PrRVp8ce+v X-Received: by 2002:a63:4551:0:b0:435:7957:559d with SMTP id u17-20020a634551000000b004357957559dmr650320pgk.122.1668152539431; Thu, 10 Nov 2022 23:42:19 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 31/45] tcg: Allocate objects contiguously in temp_allocate_frame Date: Fri, 11 Nov 2022 17:40:47 +1000 Message-Id: <20221111074101.2069454-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org When allocating a temp to the stack frame, consider the base type and allocate all parts at once. Signed-off-by: Richard Henderson --- tcg/tcg.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 11948256f2..3eabb6ef4d 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3296,11 +3296,12 @@ static void check_regs(TCGContext *s) static void temp_allocate_frame(TCGContext *s, TCGTemp *ts) { - int size = tcg_type_size(ts->type); - int align; intptr_t off; + int size, align; - switch (ts->type) { + /* When allocating an object, look at the full type. */ + size = tcg_type_size(ts->base_type); + switch (ts->base_type) { case TCG_TYPE_I32: align = 4; break; @@ -3331,13 +3332,26 @@ static void temp_allocate_frame(TCGContext *s, TCGTemp *ts) tcg_raise_tb_overflow(s); } s->current_frame_offset = off + size; - - ts->mem_offset = off; #if defined(__sparc__) - ts->mem_offset += TCG_TARGET_STACK_BIAS; + off += TCG_TARGET_STACK_BIAS; #endif - ts->mem_base = s->frame_temp; - ts->mem_allocated = 1; + + /* If the object was subdivided, assign memory to all the parts. */ + if (ts->base_type != ts->type) { + int part_size = tcg_type_size(ts->type); + int part_count = size / part_size; + + ts -= ts->temp_subindex; + for (int i = 0; i < part_count; ++i) { + ts[i].mem_offset = off + i * part_size; + ts[i].mem_base = s->frame_temp; + ts[i].mem_allocated = 1; + } + } else { + ts->mem_offset = off; + ts->mem_base = s->frame_temp; + ts->mem_allocated = 1; + } } static void temp_load(TCGContext *, TCGTemp *, TCGRegSet, TCGRegSet, TCGRegSet); From patchwork Fri Nov 11 07:40:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623699 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp623556pvb; Fri, 11 Nov 2022 00:02:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf6v1EwfG/A6H+eWWBeGj6/4NgZDAn5XZOidymdKPQNcfDloCmXprallDhbJIhr/dvo5TUbc X-Received: by 2002:a37:b8c5:0:b0:6fa:3477:d48f with SMTP id i188-20020a37b8c5000000b006fa3477d48fmr215841qkf.275.1668153772465; Fri, 11 Nov 2022 00:02:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668153772; cv=none; d=google.com; s=arc-20160816; b=hKaCEFmy3x+K/kw1Q0WgF3ZYreXeIDwe/SXtgspKhCcmpE6WfE8EGCpsT9Fiar3Sjy d+/+bahZeFuNFPCpootW5y/2qz9qEiKGaVFAPsote5MwkEj3Fp/ZOT+5IT067AZY3Ueh 1Ts2PEGZjLpIDItlZZ5YHnrt8N39Qp4olJWtELm+PlsmNNPnSsJVmgsWTRsN5cQwT9Pd MDKaLe5mYrqZUbrnblMyv7HKMu2s+xTvo1O21PL3PIso13qtNRJ0NjSnZuc3POQRMNyG Ey/uiV7PTDj+W4G/7hIdxTJV0ReSAVBRL6AEallfZC5kJhOJUnBh0AbQMqSaIRnvwaTL f1aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=a3o9hMOt9ChKJsIdLgVPveNaJVcSBQHfbJiizanAGuk=; b=z9HAg7lclSEEdeE50kYyExFfEu3r7LcO0oO7KJi+unaTJhPaNGTy2LfwRMXGXEa6bS W0Q0z2JvfI5uryJipYl4UZ0PrU4gFaiu6Dt45CDWFLyx5uBk4qDXfHWsKWHBJG8j/M2W Nzzx6iRAAqZfT4CFZI+rEJOJnlRr9BOVyD5mWv17ap6CugvR9I8oMFTXgFRxLQL9VoVn R37IgVVEqCc4N6k9M1u4P1m+hQKNNY+dYQCuL1gI/fERpChoQRUQlsKnoIja41TdWtXy yr8zfKV15GUQuJt9k8f9cf0NRe+WRrCKJoLXVCL2X4T8V/vyjOBtwy8ElTxIUNjbfyq1 qb9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vw5l9yG3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x12-20020a05622a000c00b0035a89595940si811476qtw.19.2022.11.11.00.02.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:02:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vw5l9yG3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOgq-0007C4-MV; Fri, 11 Nov 2022 02:43:05 -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 1otOgC-0006sP-P6 for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:24 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOgA-0000IA-M3 for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:24 -0500 Received: by mail-pl1-x62a.google.com with SMTP id g24so3638457plq.3 for ; Thu, 10 Nov 2022 23:42:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=a3o9hMOt9ChKJsIdLgVPveNaJVcSBQHfbJiizanAGuk=; b=Vw5l9yG3mMcmWndZbliaTZaZz+BttL+KsitJtPv7YFjVaHZb0rboI0mlymdVOLPvZd bbxwPxsrcwWoa2HU+UsbtKfTexnqLt8E/RCPcFr0HrPSCnKlfkqYsABqqctfoxAG03xK lu0Isr8QA/fJwssas6DrFKVFmphLpSMVf9ojNuUQfLWvEJyV7LXZOaNBorz0X0KUPCXc lBKIZkFcYdK7IM7PcI8B1bRAF3MxjnqLQicw4oNMI4lQ5c9Y/Mwu166LxUklTKBqbEpb pvmAlpFuDfWODLYGcczqf/IXlJGgXlFR/O8Vlis9iBkapwSCdGilEzE7EwPCnOl28xgV gyLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a3o9hMOt9ChKJsIdLgVPveNaJVcSBQHfbJiizanAGuk=; b=6iWx5aqez78O+Xv/YB9gmdipMFt1bq4HrR/u2vbs6KG1dUMc1w+TKLm4E/mx545Pm2 dH5E8pfbQP+B5QUTAhO1Q6wms7r6K5000sx766MWZCIC0R/ahr2IQBhaEPOAQI3toPoP Rx0ipFdiGJMOXAhCKFerv4IeXDhUgUuWWK7PZgidTSyC5GRCeZqnZ+FdEIIUGILGD6bQ 7czY4fmdOQo1vGFJpF//NSvFGPl7lCdId6N/prBuSUwfgCLDrNgWiHSg6SsjKhhALTQ4 OAgs9A/zhUaSt2pfhXsqvTBK1wVafvDrp6GhhkOBd62d/Q1Tp5/rEFoIzFC22hnDyhdh dB1Q== X-Gm-Message-State: ANoB5pngZR1LPjqwLvgCkQzPMDNhPIgsTPcBViXiXIdHls1O0gbvqW0p DiMMukiGalQaB+drMNVRlBwMGcFMLWSE6XiE X-Received: by 2002:a17:90a:d716:b0:214:1328:ac8f with SMTP id y22-20020a17090ad71600b002141328ac8fmr583340pju.198.1668152541391; Thu, 10 Nov 2022 23:42:21 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 32/45] tcg: Introduce tcg_out_addi_ptr Date: Fri, 11 Nov 2022 17:40:48 +1000 Message-Id: <20221111074101.2069454-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Implement the function for arm, i386, and s390x, which will use it. Add stubs for all other backends. Signed-off-by: Richard Henderson Reviewed-by: Daniel Henrique Barboza --- tcg/tcg.c | 2 ++ tcg/aarch64/tcg-target.c.inc | 7 +++++++ tcg/arm/tcg-target.c.inc | 20 ++++++++++++++++++++ tcg/i386/tcg-target.c.inc | 8 ++++++++ tcg/loongarch64/tcg-target.c.inc | 7 +++++++ tcg/mips/tcg-target.c.inc | 7 +++++++ tcg/ppc/tcg-target.c.inc | 7 +++++++ tcg/riscv/tcg-target.c.inc | 7 +++++++ tcg/s390x/tcg-target.c.inc | 7 +++++++ tcg/sparc64/tcg-target.c.inc | 7 +++++++ tcg/tci/tcg-target.c.inc | 7 +++++++ 11 files changed, 86 insertions(+) diff --git a/tcg/tcg.c b/tcg/tcg.c index 3eabb6ef4d..c276cc87ee 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -103,6 +103,8 @@ static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1, static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg); static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg); +static void tcg_out_addi_ptr(TCGContext *s, TCGReg, TCGReg, tcg_target_long) + __attribute__((unused)); static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg args[TCG_MAX_OP_ARGS], const int const_args[TCG_MAX_OP_ARGS]); diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index ad1816e32d..2279a14c11 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1102,6 +1102,13 @@ static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, tcg_out_insn(s, 3305, LDR, 0, rd); } +static void tcg_out_addi_ptr(TCGContext *s, TCGReg rd, TCGReg rs, + tcg_target_long imm) +{ + /* This function is only used for passing structs by reference. */ + g_assert_not_reached(); +} + /* Define something more legible for general use. */ #define tcg_out_ldst_r tcg_out_insn_3310 diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index e82749a602..2950a29d49 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -2548,6 +2548,26 @@ static void tcg_out_movi(TCGContext *s, TCGType type, tcg_out_movi32(s, COND_AL, ret, arg); } +static void tcg_out_addi_ptr(TCGContext *s, TCGReg rd, TCGReg rs, + tcg_target_long imm) +{ + int enc, opc = ARITH_ADD; + + /* All of the easiest immediates to encode are positive. */ + if (imm < 0) { + imm = -imm; + opc = ARITH_SUB; + } + enc = encode_imm(imm); + if (enc >= 0) { + tcg_out_dat_imm(s, COND_AL, opc, rd, rs, enc); + } else { + tcg_out_movi32(s, COND_AL, TCG_REG_TMP, imm); + tcg_out_dat_reg(s, COND_AL, opc, rd, rs, + TCG_REG_TMP, SHIFT_IMM_LSL(0)); + } +} + /* Type is always V128, with I64 elements. */ static void tcg_out_dup2_vec(TCGContext *s, TCGReg rd, TCGReg rl, TCGReg rh) { diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 58bd5873f5..6a021dda8b 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1069,6 +1069,14 @@ static void tcg_out_movi(TCGContext *s, TCGType type, } } +static void tcg_out_addi_ptr(TCGContext *s, TCGReg rd, TCGReg rs, + tcg_target_long imm) +{ + /* This function is only used for passing structs by reference. */ + tcg_debug_assert(TCG_TARGET_REG_BITS == 32); + tcg_out_modrm_offset(s, OPC_LEA, rd, rs, imm); +} + static inline void tcg_out_pushi(TCGContext *s, tcg_target_long val) { if (val == (int8_t)val) { diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index c9e99e8ec3..54b1dcd911 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -389,6 +389,13 @@ static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, } } +static void tcg_out_addi_ptr(TCGContext *s, TCGReg rd, TCGReg rs, + tcg_target_long imm) +{ + /* This function is only used for passing structs by reference. */ + g_assert_not_reached(); +} + static void tcg_out_ext8u(TCGContext *s, TCGReg ret, TCGReg arg) { tcg_out_opc_andi(s, ret, arg, 0xff); diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 292e490b5c..22b5463f0f 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -550,6 +550,13 @@ static void tcg_out_movi(TCGContext *s, TCGType type, } } +static void tcg_out_addi_ptr(TCGContext *s, TCGReg rd, TCGReg rs, + tcg_target_long imm) +{ + /* This function is only used for passing structs by reference. */ + g_assert_not_reached(); +} + static void tcg_out_bswap16(TCGContext *s, TCGReg ret, TCGReg arg, int flags) { /* ret and arg can't be register tmp0 */ diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index f561a3492f..d9e4ba8883 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -1125,6 +1125,13 @@ static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, } } +static void tcg_out_addi_ptr(TCGContext *s, TCGReg rd, TCGReg rs, + tcg_target_long imm) +{ + /* This function is only used for passing structs by reference. */ + g_assert_not_reached(); +} + static bool mask_operand(uint32_t c, int *mb, int *me) { uint32_t lsb, test; diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index aa017d665a..6072945ccb 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -545,6 +545,13 @@ static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, tcg_out_opc_imm(s, OPC_LD, rd, rd, 0); } +static void tcg_out_addi_ptr(TCGContext *s, TCGReg rd, TCGReg rs, + tcg_target_long imm) +{ + /* This function is only used for passing structs by reference. */ + g_assert_not_reached(); +} + static void tcg_out_ext8u(TCGContext *s, TCGReg ret, TCGReg arg) { tcg_out_opc_imm(s, OPC_ANDI, ret, arg, 0xff); diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index c3c0bcc3eb..8663a963a6 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -1020,6 +1020,13 @@ static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, return false; } +static void tcg_out_addi_ptr(TCGContext *s, TCGReg rd, TCGReg rs, + tcg_target_long imm) +{ + /* This function is only used for passing structs by reference. */ + tcg_out_mem(s, RX_LA, RXY_LAY, rd, rs, TCG_REG_NONE, imm); +} + /* load data from an absolute host address */ static void tcg_out_ld_abs(TCGContext *s, TCGType type, TCGReg dest, const void *abs) diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index eb913f33c8..f6a8a8e605 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -497,6 +497,13 @@ static void tcg_out_movi(TCGContext *s, TCGType type, tcg_out_movi_int(s, type, ret, arg, false, TCG_REG_T2); } +static void tcg_out_addi_ptr(TCGContext *s, TCGReg rd, TCGReg rs, + tcg_target_long imm) +{ + /* This function is only used for passing structs by reference. */ + g_assert_not_reached(); +} + static void tcg_out_ldst_rr(TCGContext *s, TCGReg data, TCGReg a1, TCGReg a2, int op) { diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index d36a7ebdd1..633345d74b 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -557,6 +557,13 @@ static void tcg_out_movi(TCGContext *s, TCGType type, } } +static void tcg_out_addi_ptr(TCGContext *s, TCGReg rd, TCGReg rs, + tcg_target_long imm) +{ + /* This function is only used for passing structs by reference. */ + g_assert_not_reached(); +} + static void tcg_out_call(TCGContext *s, const tcg_insn_unit *func, const TCGHelperInfo *info) { From patchwork Fri Nov 11 07:40:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623680 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp616254pvb; Thu, 10 Nov 2022 23:43:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf5TNAz5NVNYNNmIa3wbdS0l8Tt+tcadagQ/5xcanKBE7zh9BhTONJlc+n6GnpGKBdVozS8Z X-Received: by 2002:a05:6214:a63:b0:4bb:fa56:34d3 with SMTP id ef3-20020a0562140a6300b004bbfa5634d3mr984479qvb.89.1668152618246; Thu, 10 Nov 2022 23:43:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152618; cv=none; d=google.com; s=arc-20160816; b=D9qGLMiikKHaG9Ul0+aLJseFhXGO4ZnknO8dE+DBeRxspH06wJQRO7tMACbAwpwDop RhXVkR+17PaaomOaDSrhFmj/vrIFoPEqhD+TB4pps8sNZ9yzkJ9QK66H6BN1qyQah7yH /eyUQJaWcvQ0wfgUrdJvcZjM5xVm5F7c7AS8DwS3QFljc9sVJ/WqtHgvPA/kYK3g13ye bO1nc8RV08SwoGsl8xULzSlcjViYINE+/RqbCOZB59IQS6KjrHAp4fIGmy8DIVJVxjBR r4ZLMtCweqNRzL272mHf39yTN8eO+9FFnzN/jW85pG7IQ5PTyvDdAxG/G8Pns4k8kZTP F2fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=CPYxlgCVaE7nzaX4H41USC5VWvqB07xTjuetGSjKU6w=; b=sejLJqFxyNYOS0+WNugh1/A5OjsRF6rlDZIrdGl0e5/Qj3eOpXDIoO9gu5ky+yw9Gh /A9V+C3rqBihXY+0emjbKRW1y7HE/o0mXxFQ0Fjj7ZV2k5BIqW8pMpt1lRHC8XsE5/2z QyvygnmDqE5o/RTTnWI8XoGvc5cNppbLRzf2lsI0vPR75GVBRq/5OOykALy63jaB6PXl 7vQAAlpN5UZYFiLqaD8BQ2VNah5ImZ2Q+G+f1A+7MVApBwrfXYvUY7dlQyDB4UFN9gwT gt/jvo5+iXwt45ECmTVnnFkRvWEl9ZfQFtCYqEQmdRKS8sM8//mq1+a5S6r2WQlgJGOY FUqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZCsurHcV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id jn2-20020ad45de2000000b004c5d9df15desi608106qvb.321.2022.11.10.23.43.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:43:38 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZCsurHcV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOgJ-0006zc-8a; Fri, 11 Nov 2022 02:42:31 -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 1otOgE-0006tS-Sh for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:29 -0500 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOgC-0000IZ-UJ for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:26 -0500 Received: by mail-pg1-x52b.google.com with SMTP id q71so3797064pgq.8 for ; Thu, 10 Nov 2022 23:42:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=CPYxlgCVaE7nzaX4H41USC5VWvqB07xTjuetGSjKU6w=; b=ZCsurHcV4WOnzBMJWgUBINjy0ICIO7O1g/SQlAbRn0Se+xuRyMea1coguC831b3qRW gTZprRZxMrhH6Icbd5O17UbLysAItMcpxDdh5oVxDwBj2BKjqQLGMgWiPGIwnlvGvyHH HE2NyyT3EWQDh7k1MiubhzY0bYLyVP5cc9120RTi07oRxyYtz1V7oNvHM1ZV4ebCmhL+ GkdyZgE/pFuIJqOy1Hjtq67C/0Xch14Mmh6fI/ji3shZh3fKW+TxUPJC8NoMERT+BAhZ +TAQ/h64t5uD1dVRk+ZBik6Sb5bt5scm0EJ9hWwkHHhA7yNGCgWqguYo7E3ZeLK/pF1L yemA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CPYxlgCVaE7nzaX4H41USC5VWvqB07xTjuetGSjKU6w=; b=ZAmeuOKy6hF60x5l5pBcz+0thooBftsJJmzQyGHBSg5wMNDpq18LOMFQUUDmuU2mPh 2wT+mnNDd3fhZIaog3+R/umFI2TiJd3lM2hrvWOLWGwqNN4vQEeWyALzpvJaM7z0syBJ i6DGMUzDs0cu1bkNVt3L06yDaDPBg6V6J2QkpnuCr/i2boRVESBp1XPvUgYGw92VRRUA NmVytyQ30k9GRZmAVGsHiSCazeZEj8C0yBA3+0+XLNzYge5Hp+r7dVtkJDGDWUEeweKS m2uPdnDeBrFQog2H/uwAKTwVw6VCDOGzoTja143CqWtitAQ1UudlXz4WYTIoNQqa7Nxs eN5g== X-Gm-Message-State: ANoB5pkM/p2IbaE+i1j9N4QR6GcAaf1EcUSaO6LJS5wOwmc57eUBb6Vk YcVC9EWTHdOPLmTSUOYNfZmJq85rT+LMWe7c X-Received: by 2002:a65:590b:0:b0:462:8605:7fe7 with SMTP id f11-20020a65590b000000b0046286057fe7mr612271pgu.445.1668152543485; Thu, 10 Nov 2022 23:42:23 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 33/45] tcg: Add TCG_CALL_{RET,ARG}_BY_REF Date: Fri, 11 Nov 2022 17:40:49 +1000 Message-Id: <20221111074101.2069454-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These will be used by some hosts, both 32 and 64-bit, to pass and return i128. Not yet used, because allocation is not yet enabled. Signed-off-by: Richard Henderson --- tcg/tcg-internal.h | 3 + tcg/tcg.c | 135 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 135 insertions(+), 3 deletions(-) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index 6e50aeba3a..2ec1ea01df 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -36,6 +36,7 @@ */ typedef enum { TCG_CALL_RET_NORMAL, /* by registers */ + TCG_CALL_RET_BY_REF, /* for i128, by reference */ } TCGCallReturnKind; typedef enum { @@ -44,6 +45,8 @@ typedef enum { TCG_CALL_ARG_EXTEND, /* for i32, as a sign/zero-extended i64 */ TCG_CALL_ARG_EXTEND_U, /* ... as a zero-extended i64 */ TCG_CALL_ARG_EXTEND_S, /* ... as a sign-extended i64 */ + TCG_CALL_ARG_BY_REF, /* for i128, by reference, first */ + TCG_CALL_ARG_BY_REF_N, /* ... by reference, subsequent */ } TCGCallArgumentKind; typedef struct TCGCallArgumentLoc { diff --git a/tcg/tcg.c b/tcg/tcg.c index c276cc87ee..b61551913b 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -103,8 +103,7 @@ static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1, static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg); static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg); -static void tcg_out_addi_ptr(TCGContext *s, TCGReg, TCGReg, tcg_target_long) - __attribute__((unused)); +static void tcg_out_addi_ptr(TCGContext *s, TCGReg, TCGReg, tcg_target_long); static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg args[TCG_MAX_OP_ARGS], const int const_args[TCG_MAX_OP_ARGS]); @@ -661,6 +660,38 @@ static void layout_arg_normal_n(TCGCumulativeArgs *cum, cum->arg_slot += n; } +static void layout_arg_by_ref(TCGCumulativeArgs *cum, TCGHelperInfo *info) +{ + TCGCallArgumentLoc *loc = &info->in[cum->info_in_idx]; + int n = 128 / TCG_TARGET_REG_BITS; + + /* The first subindex carries the pointer. */ + layout_arg_1(cum, info, TCG_CALL_ARG_BY_REF); + + /* + * The callee is allowed to clobber memory associated with + * structure pass by-reference. Therefore we must make copies. + * Allocate space from "ref_slot", which will be adjusted to + * follow the parameters on the stack. + */ + loc[0].ref_slot = cum->ref_slot; + + /* + * Subsequent words also go into the reference slot, but + * do not accumulate into the regular arguments. + */ + for (int i = 1; i < n; ++i) { + loc[i] = (TCGCallArgumentLoc){ + .kind = TCG_CALL_ARG_BY_REF_N, + .arg_idx = cum->arg_idx, + .tmp_subindex = i, + .ref_slot = cum->ref_slot + i, + }; + } + cum->info_in_idx += n; + cum->ref_slot += n; +} + static void init_call_layout(TCGHelperInfo *info) { int max_reg_slots = ARRAY_SIZE(tcg_target_call_iarg_regs); @@ -696,6 +727,14 @@ static void init_call_layout(TCGHelperInfo *info) case TCG_CALL_RET_NORMAL: assert(info->nr_out <= ARRAY_SIZE(tcg_target_call_oarg_regs)); break; + case TCG_CALL_RET_BY_REF: + /* + * Allocate the first argument to the output. + * We don't need to store this anywhere, just make it + * unavailable for use in the input loop below. + */ + cum.arg_slot = 1; + break; default: qemu_build_not_reached(); } @@ -757,6 +796,9 @@ static void init_call_layout(TCGHelperInfo *info) case TCG_CALL_ARG_NORMAL: layout_arg_normal_n(&cum, info, 128 / TCG_TARGET_REG_BITS); break; + case TCG_CALL_ARG_BY_REF: + layout_arg_by_ref(&cum, info); + break; default: qemu_build_not_reached(); } @@ -771,7 +813,39 @@ static void init_call_layout(TCGHelperInfo *info) assert(cum.info_in_idx <= ARRAY_SIZE(info->in)); /* Validate the backend has enough argument space. */ assert(cum.arg_slot <= max_reg_slots + max_stk_slots); - assert(cum.ref_slot <= max_stk_slots); + + /* + * Relocate the "ref_slot" area to the end of the parameters. + * Minimizing this stack offset helps code size for x86, + * which has a signed 8-bit offset encoding. + */ + if (cum.ref_slot != 0) { + int ref_base = 0; + + if (cum.arg_slot > max_reg_slots) { + int align = __alignof(Int128) / sizeof(tcg_target_long); + + ref_base = cum.arg_slot - max_reg_slots; + if (align > 1) { + ref_base = ROUND_UP(ref_base, align); + } + } + assert(ref_base + cum.ref_slot <= max_stk_slots); + + if (ref_base != 0) { + for (int i = cum.info_in_idx - 1; i >= 0; --i) { + TCGCallArgumentLoc *loc = &info->in[i]; + switch (loc->kind) { + case TCG_CALL_ARG_BY_REF: + case TCG_CALL_ARG_BY_REF_N: + loc->ref_slot += ref_base; + break; + default: + break; + } + } + } + } } static int indirect_reg_alloc_order[ARRAY_SIZE(tcg_target_reg_alloc_order)]; @@ -1697,6 +1771,8 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) switch (loc->kind) { case TCG_CALL_ARG_NORMAL: + case TCG_CALL_ARG_BY_REF: + case TCG_CALL_ARG_BY_REF_N: op->args[pi++] = temp_arg(ts); break; @@ -4398,6 +4474,27 @@ static void load_arg_normal(TCGContext *s, const TCGCallArgumentLoc *l, } } +static void load_arg_ref(TCGContext *s, int arg_slot, TCGReg ref_base, + intptr_t ref_off, TCGRegSet *allocated_regs) +{ + TCGReg reg; + int stk_slot = arg_slot - ARRAY_SIZE(tcg_target_call_iarg_regs); + + if (stk_slot < 0) { + reg = tcg_target_call_iarg_regs[arg_slot]; + tcg_reg_free(s, reg, *allocated_regs); + tcg_out_addi_ptr(s, reg, ref_base, ref_off); + tcg_regset_set_reg(*allocated_regs, reg); + } else { + reg = tcg_reg_alloc(s, tcg_target_available_regs[TCG_TYPE_PTR], + *allocated_regs, 0, false); + tcg_out_addi_ptr(s, reg, ref_base, ref_off); + tcg_out_st(s, TCG_TYPE_PTR, reg, TCG_REG_CALL_STACK, + TCG_TARGET_CALL_STACK_OFFSET + + stk_slot * sizeof(tcg_target_long)); + } +} + static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) { const int nb_oargs = TCGOP_CALLO(op); @@ -4421,6 +4518,16 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) case TCG_CALL_ARG_EXTEND_S: load_arg_normal(s, loc, ts, &allocated_regs); break; + case TCG_CALL_ARG_BY_REF: + load_arg_stk(s, loc->ref_slot, ts, allocated_regs); + load_arg_ref(s, loc->arg_slot, TCG_REG_CALL_STACK, + TCG_TARGET_CALL_STACK_OFFSET + + loc->ref_slot * sizeof(tcg_target_long), + &allocated_regs); + break; + case TCG_CALL_ARG_BY_REF_N: + load_arg_stk(s, loc->ref_slot, ts, allocated_regs); + break; default: g_assert_not_reached(); } @@ -4452,6 +4559,19 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) save_globals(s, allocated_regs); } + /* + * If the ABI passes a pointer to the returned struct as the first + * argument, load that now. Pass a pointer to the output home slot. + */ + if (info->out_kind == TCG_CALL_RET_BY_REF) { + TCGTemp *ts = arg_temp(op->args[0]); + + if (!ts->mem_allocated) { + temp_allocate_frame(s, ts); + } + load_arg_ref(s, 0, ts->mem_base->reg, ts->mem_offset, &allocated_regs); + } + tcg_out_call(s, tcg_call_func(op), info); /* Assign output registers and emit moves if needed. */ @@ -4474,6 +4594,15 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) s->reg_to_temp[reg] = ts; } break; + + case TCG_CALL_RET_BY_REF: + /* The callee has performed a write through the reference. */ + for (i = 0; i < nb_oargs; i++) { + TCGTemp *ts = arg_temp(op->args[i]); + ts->val_type = TEMP_VAL_MEM; + } + break; + default: g_assert_not_reached(); } From patchwork Fri Nov 11 07:40:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623697 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp621579pvb; Thu, 10 Nov 2022 23:58:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf5xTxPPiAZKka9+jBndBhjz4kCyL5HQ2qmY5p5hToFptGfM15dj2zk8simWYGfjqnxB0teS X-Received: by 2002:ac8:520c:0:b0:3a4:f479:e14a with SMTP id r12-20020ac8520c000000b003a4f479e14amr370521qtn.271.1668153531328; Thu, 10 Nov 2022 23:58:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668153531; cv=none; d=google.com; s=arc-20160816; b=RvG1aQYYpnWzI+2GcIHWxSLFVZQeE4cs7ciU1WoM8jrHQBnLNSM66E1zj6nRegkZhx Msz1JRd8h0879Re6tazvcp7nSnNQOoSFQYt/KEq8ksyeQDMevUtRviuH8ROKlt2mxd1U 0+zvBvX9U2bMwuA82N4X8S/woDsAvYsVY99VnRmzYozLlILaNZ0yF9Cw7f2rhT3xW+eP nQzRiztv9rofynmLmQoQ9L1iAe5gB3LowVzvvbzQ04mYhv8xjIOaD/AyTIA3IvUMuRQV HwW53ghBnVwEZ5Kb63rElF1rWEhHHdhIa5/qROoN0BX3RCQJcWd5TQ4VXVtnkAPMF67/ OM+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=L+S0yiDUL5LJhfVfrgX3VxmNsOJpAn5JdOtGMrMcV5s=; b=YFCPhWdfhn0ZpMIpxdpVAXfVplTc0q6k8w82DFNGIjRzLNXm8lRrDCMpy7EpdNOaee FvivcCWQR9bs2fP0ypBfAyuafe4xB+xUe5SP7kXJnrrBNtEcMkeF2zNG3fGcgrjkZa7E uy3S+LViJROrbvbsMzXP2XWvMIzt6KZp6DXo0QPR4/ROOf7gcZcjmqczXmsuy6X9zebu QfDJ9k+VSuPUW3J9pUJtIlOL3kj01YxaIsJdWLg9nSDv4/zEgAn+RY/mKNSsT9ZW6Hu0 wp77kCCNnpsrIyqYi4BTWniNU1GSJQVg9dI+K6YsE1BZ+UxsKI3+5zrQhMd0bQhJPufN mcBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vN2N9CSl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d14-20020a05622a100e00b0039d0b7ce2c0si776493qte.258.2022.11.10.23.58.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:58:51 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vN2N9CSl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOgK-000716-K5; Fri, 11 Nov 2022 02:42:32 -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 1otOgH-0006w4-CA for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:29 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOgF-0000J0-4U for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:28 -0500 Received: by mail-pj1-x102d.google.com with SMTP id f5-20020a17090a4a8500b002131bb59d61so7088442pjh.1 for ; Thu, 10 Nov 2022 23:42:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=L+S0yiDUL5LJhfVfrgX3VxmNsOJpAn5JdOtGMrMcV5s=; b=vN2N9CSliiu//oQ2kbTPwak2X2xQFkWSURzeGlcjAXn14jI7QljU2psxlaBG2t6LgA eLpkhytqGfgOuCK0XS+WiR1L575Tl+B9MrlN2YE8StjCOhF84SoQd5WpEviBxUMJcbv6 9c9OTi0nKEk18y7SEQOq9ENsHd7FVJ5J/49wMSNGm4m29ChKSs2LP6agTkHCPXnxNz2f 81YpLpcMn9cM206tcGebaxP7C3Z3J6lt5H+8bTuXjXkGazMUgL/j/uPMLIKDjJnVyfj4 1dAfJiOjarAgShwLTId5DY2cA7oU+3q4nfQqNS1yA19PqVQ53dELKeSNuiS3bvoilu0D zBDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L+S0yiDUL5LJhfVfrgX3VxmNsOJpAn5JdOtGMrMcV5s=; b=Pxn69nXJPZZ/vOA1Y6jzpOwzm+WykCPNWNGjB98n6lHK4zGAilasMq9dqiVIZYctDs 74mnKeK1dgCaZbjvvzOvvpbia5T2jyKMJVr9MrjqmEdOiSrIf6+NX+s8OeeWsEHaDoYE +YZly2R3FTNZc6fzLkCeriaNaoP8XJX73GG/Z6yhI71w2w1845AayXvo7T/rT9KuVEEi wnIwcK1ZXwxFwfGW/YOolS+WfmkUqD/8yeM7hvZ4+8MZ326+TsgNw68hm+TXdLxg/KYv 5QVlgJk/8FUIQg1MaVlJCQenO09JXmS43jQxzz10dF8Tu/3F4ei5sxgB30b0c7lGOP9L Yv2g== X-Gm-Message-State: ANoB5pn+fQ1xJQA2OHTvoB6NI3pr7nJ62R8hg9ybepb+rMtVnmNJMsCm ft5PoQphYxTwkymJnbJfRB81o/UofT0EJ7nS X-Received: by 2002:a17:903:3111:b0:186:5ef5:bda1 with SMTP id w17-20020a170903311100b001865ef5bda1mr1383257plc.78.1668152545828; Thu, 10 Nov 2022 23:42:25 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 34/45] tcg: Introduce tcg_target_call_oarg_reg Date: Fri, 11 Nov 2022 17:40:50 +1000 Message-Id: <20221111074101.2069454-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Replace the flat array tcg_target_call_oarg_regs[] with a function call including the TCGCallReturnKind. Signed-off-by: Richard Henderson Reviewed-by: Daniel Henrique Barboza --- tcg/tcg.c | 9 ++++++--- tcg/aarch64/tcg-target.c.inc | 10 +++++++--- tcg/arm/tcg-target.c.inc | 10 +++++++--- tcg/i386/tcg-target.c.inc | 16 ++++++++++------ tcg/loongarch64/tcg-target.c.inc | 10 ++++++---- tcg/mips/tcg-target.c.inc | 10 ++++++---- tcg/ppc/tcg-target.c.inc | 10 ++++++---- tcg/riscv/tcg-target.c.inc | 10 ++++++---- tcg/s390x/tcg-target.c.inc | 9 ++++++--- tcg/sparc64/tcg-target.c.inc | 12 ++++++------ tcg/tci/tcg-target.c.inc | 12 ++++++------ 11 files changed, 72 insertions(+), 46 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index b61551913b..97c97158cd 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -148,6 +148,7 @@ static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, TCGReg base, intptr_t ofs); static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target, const TCGHelperInfo *info); +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot); static bool tcg_target_const_match(int64_t val, TCGType type, int ct); #ifdef TCG_TARGET_NEED_LDST_LABELS static int tcg_out_ldst_finalize(TCGContext *s); @@ -718,14 +719,16 @@ static void init_call_layout(TCGHelperInfo *info) case dh_typecode_s64: info->nr_out = 64 / TCG_TARGET_REG_BITS; info->out_kind = TCG_CALL_RET_NORMAL; - assert(info->nr_out <= ARRAY_SIZE(tcg_target_call_oarg_regs)); + /* Query the last register now to trigger any assert early. */ + tcg_target_call_oarg_reg(info->out_kind, info->nr_out - 1); break; case dh_typecode_i128: info->nr_out = 128 / TCG_TARGET_REG_BITS; info->out_kind = TCG_CALL_RET_NORMAL; /* TODO */ switch (/* TODO */ TCG_CALL_RET_NORMAL) { case TCG_CALL_RET_NORMAL: - assert(info->nr_out <= ARRAY_SIZE(tcg_target_call_oarg_regs)); + /* Query the last register now to trigger any assert early. */ + tcg_target_call_oarg_reg(info->out_kind, info->nr_out - 1); break; case TCG_CALL_RET_BY_REF: /* @@ -4579,7 +4582,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) case TCG_CALL_RET_NORMAL: for (i = 0; i < nb_oargs; i++) { TCGTemp *ts = arg_temp(op->args[i]); - TCGReg reg = tcg_target_call_oarg_regs[i]; + TCGReg reg = tcg_target_call_oarg_reg(TCG_CALL_RET_NORMAL, i); /* ENV should not be modified. */ tcg_debug_assert(!temp_readonly(ts)); diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 2279a14c11..dfe569dd8c 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -63,9 +63,13 @@ static const int tcg_target_call_iarg_regs[8] = { TCG_REG_X0, TCG_REG_X1, TCG_REG_X2, TCG_REG_X3, TCG_REG_X4, TCG_REG_X5, TCG_REG_X6, TCG_REG_X7 }; -static const int tcg_target_call_oarg_regs[1] = { - TCG_REG_X0 -}; + +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(kind == TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot >= 0 && slot <= 1); + return TCG_REG_X0 + slot; +} #define TCG_REG_TMP TCG_REG_X30 #define TCG_VEC_TMP TCG_REG_V31 diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 2950a29d49..add90ddeb4 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -79,9 +79,13 @@ static const int tcg_target_reg_alloc_order[] = { static const int tcg_target_call_iarg_regs[4] = { TCG_REG_R0, TCG_REG_R1, TCG_REG_R2, TCG_REG_R3 }; -static const int tcg_target_call_oarg_regs[2] = { - TCG_REG_R0, TCG_REG_R1 -}; + +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(kind == TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot >= 0 && slot <= 3); + return TCG_REG_R0 + slot; +} #define TCG_REG_TMP TCG_REG_R12 #define TCG_VEC_TMP TCG_REG_Q15 diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 6a021dda8b..ab6881a4f3 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -109,12 +109,16 @@ static const int tcg_target_call_iarg_regs[] = { #endif }; -static const int tcg_target_call_oarg_regs[] = { - TCG_REG_EAX, -#if TCG_TARGET_REG_BITS == 32 - TCG_REG_EDX -#endif -}; +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + switch (kind) { + case TCG_CALL_RET_NORMAL: + tcg_debug_assert(slot >= 0 && slot <= 1); + return slot ? TCG_REG_EDX : TCG_REG_EAX; + default: + g_assert_not_reached(); + } +} /* Constants we accept. */ #define TCG_CT_CONST_S32 0x100 diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 54b1dcd911..f6b0ed00bb 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -114,10 +114,12 @@ static const int tcg_target_call_iarg_regs[] = { TCG_REG_A7, }; -static const int tcg_target_call_oarg_regs[] = { - TCG_REG_A0, - TCG_REG_A1, -}; +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(kind == TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot >= 0 && slot <= 1); + return TCG_REG_A0 + slot; +} #ifndef CONFIG_SOFTMMU #define USE_GUEST_BASE (guest_base != 0) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 22b5463f0f..92883176c6 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -136,10 +136,12 @@ static const TCGReg tcg_target_call_iarg_regs[] = { #endif }; -static const TCGReg tcg_target_call_oarg_regs[2] = { - TCG_REG_V0, - TCG_REG_V1 -}; +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(kind == TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot >= 0 && slot <= 1); + return TCG_REG_V0 + slot; +} static const tcg_insn_unit *tb_ret_addr; static const tcg_insn_unit *bswap32_addr; diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index d9e4ba8883..781ecfe161 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -186,10 +186,12 @@ static const int tcg_target_call_iarg_regs[] = { TCG_REG_R10 }; -static const int tcg_target_call_oarg_regs[] = { - TCG_REG_R3, - TCG_REG_R4 -}; +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(kind == TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot >= 0 && slot <= 1); + return TCG_REG_R3 + slot; +} static const int tcg_target_callee_save_regs[] = { #ifdef _CALL_DARWIN diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 6072945ccb..417736cae7 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -113,10 +113,12 @@ static const int tcg_target_call_iarg_regs[] = { TCG_REG_A7, }; -static const int tcg_target_call_oarg_regs[] = { - TCG_REG_A0, - TCG_REG_A1, -}; +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(kind == TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot >= 0 && slot <= 1); + return TCG_REG_A0 + slot; +} #define TCG_CT_CONST_ZERO 0x100 #define TCG_CT_CONST_S12 0x200 diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index 8663a963a6..50655e9d1d 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -390,9 +390,12 @@ static const int tcg_target_call_iarg_regs[] = { TCG_REG_R6, }; -static const int tcg_target_call_oarg_regs[] = { - TCG_REG_R2, -}; +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(kind == TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot == 0); + return TCG_REG_R2; +} #define S390_CC_EQ 8 #define S390_CC_LT 4 diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index f6a8a8e605..9b5afb8248 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -133,12 +133,12 @@ static const int tcg_target_call_iarg_regs[6] = { TCG_REG_O5, }; -static const int tcg_target_call_oarg_regs[] = { - TCG_REG_O0, - TCG_REG_O1, - TCG_REG_O2, - TCG_REG_O3, -}; +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(kind == TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot >= 0 && slot <= 3); + return TCG_REG_O0 + slot; +} #define INSN_OP(x) ((x) << 30) #define INSN_OP2(x) ((x) << 22) diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index 633345d74b..cd53cb6b6b 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -200,12 +200,12 @@ static const int tcg_target_reg_alloc_order[] = { /* No call arguments via registers. All will be stored on the "stack". */ static const int tcg_target_call_iarg_regs[] = { }; -static const int tcg_target_call_oarg_regs[] = { - TCG_REG_R0, -#if TCG_TARGET_REG_BITS == 32 - TCG_REG_R1 -#endif -}; +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(kind == TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot >= 0 && slot < 64 / TCG_TARGET_REG_BITS); + return TCG_REG_R0 + slot; +} #ifdef CONFIG_DEBUG_TCG static const char *const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { From patchwork Fri Nov 11 07:40:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623698 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp623292pvb; Fri, 11 Nov 2022 00:02:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf7m2xEu69NoiBdOrj4MV8pq1OXrhXCbOH9OpSS1qGfUTBdR/VhtBd9CGKYOPfv25cZ+5IWR X-Received: by 2002:a37:e204:0:b0:6fa:2050:ea8e with SMTP id g4-20020a37e204000000b006fa2050ea8emr195105qki.608.1668153740483; Fri, 11 Nov 2022 00:02:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668153740; cv=none; d=google.com; s=arc-20160816; b=dULUfOsJo8cJwTwchZUG1Tue0On5y/PQCJzKHx5Od9YohtNTt1NNKgeyT+F3BDLCs1 /djmyo/NNvIPUwNRgYAPqzbDPnhI/9J/N5Wet3PhWzdHHONvsFZ8gE2KHyIfdQbxwrMq SrBcEQbgRD8sR0Jxe9HgXBuyOqm0BCwIJyiBjDqWVL6DzTvarxyFrskm12B/wxcvapGS Km2sUFXKbCAtZfu3HaqNBmrTiiMnVTCXOeBVVcDFqQWp2bmaKLnuwDkAPYvgVKmlwlPq nxpstCZeRVsB/LdpRsF97Y/aYmpni4K7XSxP71M0HZsloasOCN8PI/Epk4wnCNSWTIVV Tsvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ykW3p8xDFujqs9enheSpuJYpD12Nxn1fGpKV437Ebps=; b=uZ9jUG71pinmUcCxbR82pUDfECI27ykHLmniui1K+whyt6ou232DCRJ7nH1zS52vkZ gph4hRHmWmu5Szjieoef7UZmBQThKu3yqfkpjCYUFP1hV08IKBSPng/UCB8qQ1LdrJ/1 AWe6TGLvgv454gfpxMQAZt0PPkadxfDBXaHMGP/YJrwFwbGLTmItfDDlj//Kdevbeif2 4DjxsCcTXfXhLeW+COnkJvT1OE3WGmdwnMJVp/QrKC48GZxKrAWJdfDINfwuVPJeo8gh PpP12QuaQlJ7PFNYV1vON4qO8RZ3i0GrE/uu/mUGbAgRLUknT/t/j4FvbAzT5OaNUytu tMmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NTcjZpfW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bm34-20020a05620a19a200b006cf0ae1f6e0si737044qkb.623.2022.11.11.00.02.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:02:20 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NTcjZpfW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOgL-000733-As; Fri, 11 Nov 2022 02:42:33 -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 1otOgJ-0006za-53 for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:31 -0500 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOgH-0000JD-EV for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:30 -0500 Received: by mail-pf1-x42e.google.com with SMTP id i3so4210850pfc.11 for ; Thu, 10 Nov 2022 23:42:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ykW3p8xDFujqs9enheSpuJYpD12Nxn1fGpKV437Ebps=; b=NTcjZpfWPvhdBvM+9dOQ18RqXlkZKZKtpAkFKOt5OK75jwc0K6r3w32QR8uUWy2QZq xr9SH8tyvVbklFph0kmNExIQwvxP0jMb4H0gJuBVKaM1BNrEh7tF1mSI9cIQhNC9B5vV FU+Bv8Ib8NIW0JxCV8U4tJ0Na2YDtUny8553V1SE5iL5eKTw6qwxymYPQAUckyNPAPLl bVL/m5jH8/8yRIxuVCQFAjb5LcU3a2UaMV/tN1ngKv1J21eY28D7IFybZEeTXVybdnps +MV5i/L9IIO1RBaPQmxOFMPy/eCQz//rCUidyC3ffqMzYHXnsCyT6aocaR7z7TSwxiTT F6SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ykW3p8xDFujqs9enheSpuJYpD12Nxn1fGpKV437Ebps=; b=fiYls68NOYar6JFkPJLu34fITP7f33MiDKz/E/bpyNQP6NDbPvmQGVc2BPP515ouC8 RgqvmU6yzmVgAYmjp+usmsdH/8CFLFbiNo81Uh+xPLYrhfHUxBiVqVIiZGhtJXgRNOPX RMkcG0uvi5mWq1NJPCwmLwFJ2jLJd7nutN4qcMbYuaPc1lASPzSd/gjHBy8KoeIPk/52 9bj7rY6Q5o2m7TlwfzcnT17tQRxSV/PTcw4yUSNjALKnMHCn4fbalFxMWHf2lzmDQrFW 85K1qscg22Zskd3lZX9xNbjIpJIyCNX9zCtOYMjmpYLb3ctyE4R9MhQ8VY2nlMDwfFAf XuHg== X-Gm-Message-State: ANoB5pnxM+R5v3S7zC2PtiHmG8CUAeqgr+cZlT2DAV8DDdJb4lKNO5A0 pEEVYTztw9q60LU2KfZKuWFiXSOPSOP6H8vn X-Received: by 2002:a63:e644:0:b0:459:7d5f:293e with SMTP id p4-20020a63e644000000b004597d5f293emr569379pgj.602.1668152547996; Thu, 10 Nov 2022 23:42:27 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 35/45] tcg: Add TCG_CALL_RET_BY_VEC Date: Fri, 11 Nov 2022 17:40:51 +1000 Message-Id: <20221111074101.2069454-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This will be used by _WIN64 to return i128. Not yet used, because allocation is not yet enabled. Signed-off-by: Richard Henderson --- tcg/tcg-internal.h | 1 + tcg/tcg.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index 2ec1ea01df..33f1d8b411 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -37,6 +37,7 @@ typedef enum { TCG_CALL_RET_NORMAL, /* by registers */ TCG_CALL_RET_BY_REF, /* for i128, by reference */ + TCG_CALL_RET_BY_VEC, /* for i128, by vector register */ } TCGCallReturnKind; typedef enum { diff --git a/tcg/tcg.c b/tcg/tcg.c index 97c97158cd..3476721fbe 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -730,6 +730,10 @@ static void init_call_layout(TCGHelperInfo *info) /* Query the last register now to trigger any assert early. */ tcg_target_call_oarg_reg(info->out_kind, info->nr_out - 1); break; + case TCG_CALL_RET_BY_VEC: + /* Query the single register now to trigger any assert early. */ + tcg_target_call_oarg_reg(TCG_CALL_RET_BY_VEC, 0); + break; case TCG_CALL_RET_BY_REF: /* * Allocate the first argument to the output. @@ -4598,6 +4602,21 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) } break; + case TCG_CALL_RET_BY_VEC: + { + TCGTemp *ts = arg_temp(op->args[0]); + + tcg_debug_assert(ts->base_type == TCG_TYPE_I128); + tcg_debug_assert(ts->temp_subindex == 0); + if (!ts->mem_allocated) { + temp_allocate_frame(s, ts); + } + tcg_out_st(s, TCG_TYPE_V128, + tcg_target_call_oarg_reg(TCG_CALL_RET_BY_VEC, 0), + ts->mem_base->reg, ts->mem_offset); + } + /* fall through to mark all parts in memory */ + case TCG_CALL_RET_BY_REF: /* The callee has performed a write through the reference. */ for (i = 0; i < nb_oargs; i++) { From patchwork Fri Nov 11 07:40:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623705 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp628823pvb; Fri, 11 Nov 2022 00:14:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf4UssJloblchg9eIKmtykH8DJHYCHnfBmgzeYzNE9CZkqvGTus5N71GD2iNHtYAsxmdjRqx X-Received: by 2002:ac8:544b:0:b0:3a5:6961:e1b5 with SMTP id d11-20020ac8544b000000b003a56961e1b5mr373073qtq.598.1668154487651; Fri, 11 Nov 2022 00:14:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668154487; cv=none; d=google.com; s=arc-20160816; b=AavqWyzNhoEy7ZYX7exjDxLEwljSujfs5OvgW/jB9Lra9r8Y0eLrB6svvxm9xfqPin AaNdFTkn5jlM2gEnx/JW0hqiVhjPKo5MDlcnmhSpqFWNAi4dLHotjuOMqpJOwNg7BaIl a8sSB4+/rwtlLRxOdyr8V3+bzsuqmN0IDFZlQkWa1kyahc1X2YQySfKXPFPXb6nYrL3b GGfT8VNNnHAaF1grYaorOHGwDN4LR1xx75oC4yoXdQ7F1h+4H84H7BHMWm89rixaLW3J K11ZDqNcwF9FsmTrXnUN6tcVPD2J57leHCIabUbBQOR4Ellfklk9IbmpExgT/r3dBV+5 2UNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=WlfgTKwjPzR9xe9xdxRaR9DbAja99BeWVoRkY0FKPGQ=; b=rcNo5UNzsVXqTTINgKoMzuDOGelfvdbbQpUS+gGbQNLkJo6sl7rb5K6Ey9YmENmumU 10lZ1XHvi8tR6h9UIshklEdrmOLTXl5dheBFdhN1SKdQcG51//Z9ceh0JjbxvhyxncMK ujzObPY/oewYv5iog8xE2LFsy2MXzpq5PAc4LZWprvCJFLtjL9CRVk0shOZVSR/fGUqA ijEmM6EYmYrFstvZrjtPohi7/ocKNPY46NgSaedG5XAlXaQ9vL3lBJizXzu8uEz0jNmM tO0OItpvBGuYiGvBUc9SK51ntnISeGEBh2AHc9rfDkQc/3MsL1Slv58XY2vVmg+jj0xM ve9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g8eNcfJA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y20-20020a05620a25d400b006cf2a95a11bsi805557qko.125.2022.11.11.00.14.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:14:47 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g8eNcfJA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOgv-0007KR-1T; Fri, 11 Nov 2022 02:43:09 -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 1otOgL-00073D-GK for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:33 -0500 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOgJ-0000Jk-Ma for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:33 -0500 Received: by mail-pj1-x1036.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so7068925pjs.4 for ; Thu, 10 Nov 2022 23:42:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=WlfgTKwjPzR9xe9xdxRaR9DbAja99BeWVoRkY0FKPGQ=; b=g8eNcfJA8o7QHJ9q+8/qadavI3KG27PFTYT04f2hN8mSqv6aWgcc5pOeYjmOWQ11kS PT0El6lsd2WeXTCI1lio6xvYv+txj2MJ6J/6AeRAQxBPGS/MeSwjIbLMIEvKzamJUr7D +vHFY1dmurCGQDlm2h9tCKHUKTkmWGV/4BjnzqYWzOXnMG9/sBe+aJkkRUQ8fqqmqjz6 eXrCmypPV1nqPK5XK5ttJ1IevIFdNwebfnjZqLbk01jYYuOrg4tbLpe4ClquBy298jkW 5r6dMaSgoD1V+85aMVhQLUQKSI+QwjMG2ReZ5tLjv0chElQckJiYrkJ5CvUIuZn3mHJp RgOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WlfgTKwjPzR9xe9xdxRaR9DbAja99BeWVoRkY0FKPGQ=; b=ie/IrkZZlJKbKRGX2Il6kirZzmtvZVdQHpPuZ2lX5qdjOYBDX3ehD6LIXivUQL702G 87dzugPiTZt1O239j4D7y3AfnKSEDuKrKD9AVpqoe5yJaoO2EW6Mdpcvp4xyjFuUHWXR orOJY/5gZOw4g/SVrd6/GU/Qg3F0JVUNBkmZKdpzA+CEkDayabwlouib4lNBXP1Xvdhf GMViQ36eH5IBFAsKJey96AiP/D9W4u15c2Ek9Xn7hdL5mnZL1Uj57Ij1X3jKk+Xd9r+U ZJ8ofeLTfT9sQshESGMe+raCrJJbJiKL8kUtEmEe0VjXrN6/sYU0q3OgUO2d3vd3avUA Nolg== X-Gm-Message-State: ANoB5pmkrv18oGJsp/ZjruisYgTq1FM2dpOjW6LlY96fSMM2JdNCES27 GzSLCdn/mHK/S6C7WdntJRB27QGNCfBpTyLp X-Received: by 2002:a17:902:da90:b0:187:12cc:d6f1 with SMTP id j16-20020a170902da9000b0018712ccd6f1mr1146761plx.63.1668152550164; Thu, 10 Nov 2022 23:42:30 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 36/45] include/qemu/int128: Use Int128 structure for TCI Date: Fri, 11 Nov 2022 17:40:52 +1000 Message-Id: <20221111074101.2069454-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We are about to allow passing Int128 to/from tcg helper functions, but libffi doesn't support __int128_t, so use the structure. In order for atomic128.h to continue working, we must provide a mechanism to frob between real __int128_t and the structure. Provide a new union, Int128Alias, for this. We cannot modify Int128 itself, as any changed alignment would also break libffi. Signed-off-by: Richard Henderson --- include/qemu/atomic128.h | 29 +++++++++++++++++++++------ include/qemu/int128.h | 25 +++++++++++++++++++++--- util/int128.c | 42 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 9 deletions(-) diff --git a/include/qemu/atomic128.h b/include/qemu/atomic128.h index adb9a1a260..d0ba0b9c65 100644 --- a/include/qemu/atomic128.h +++ b/include/qemu/atomic128.h @@ -44,13 +44,23 @@ #if defined(CONFIG_ATOMIC128) static inline Int128 atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new) { - return qatomic_cmpxchg__nocheck(ptr, cmp, new); + Int128Alias r, c, n; + + c.s = cmp; + n.s = new; + r.i = qatomic_cmpxchg__nocheck((__int128_t *)ptr, c.i, n.i); + return r.s; } # define HAVE_CMPXCHG128 1 #elif defined(CONFIG_CMPXCHG128) static inline Int128 atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new) { - return __sync_val_compare_and_swap_16(ptr, cmp, new); + Int128Alias r, c, n; + + c.s = cmp; + n.s = new; + r.i = __sync_val_compare_and_swap_16((__int128_t *)ptr, c.i, n.i); + return r.s; } # define HAVE_CMPXCHG128 1 #elif defined(__aarch64__) @@ -89,12 +99,18 @@ Int128 QEMU_ERROR("unsupported atomic") #if defined(CONFIG_ATOMIC128) static inline Int128 atomic16_read(Int128 *ptr) { - return qatomic_read__nocheck(ptr); + Int128Alias r; + + r.i = qatomic_read__nocheck((__int128_t *)ptr); + return r.s; } static inline void atomic16_set(Int128 *ptr, Int128 val) { - qatomic_set__nocheck(ptr, val); + Int128Alias v; + + v.s = val; + qatomic_set__nocheck((__int128_t *)ptr, v.i); } # define HAVE_ATOMIC128 1 @@ -132,7 +148,8 @@ static inline void atomic16_set(Int128 *ptr, Int128 val) static inline Int128 atomic16_read(Int128 *ptr) { /* Maybe replace 0 with 0, returning the old value. */ - return atomic16_cmpxchg(ptr, 0, 0); + Int128 z = int128_make64(0); + return atomic16_cmpxchg(ptr, z, z); } static inline void atomic16_set(Int128 *ptr, Int128 val) @@ -141,7 +158,7 @@ static inline void atomic16_set(Int128 *ptr, Int128 val) do { cmp = old; old = atomic16_cmpxchg(ptr, cmp, val); - } while (old != cmp); + } while (int128_ne(old, cmp)); } # define HAVE_ATOMIC128 1 diff --git a/include/qemu/int128.h b/include/qemu/int128.h index d2b76ca6ac..f62a46b48c 100644 --- a/include/qemu/int128.h +++ b/include/qemu/int128.h @@ -3,7 +3,12 @@ #include "qemu/bswap.h" -#ifdef CONFIG_INT128 +/* + * With TCI, we need to use libffi for interfacing with TCG helpers. + * But libffi does not support __int128_t, and therefore cannot pass + * or return values of this type, force use of the Int128 struct. + */ +#if defined(CONFIG_INT128) && !defined(CONFIG_TCG_INTERPRETER) typedef __int128_t Int128; static inline Int128 int128_make64(uint64_t a) @@ -460,8 +465,7 @@ Int128 int128_divu(Int128, Int128); Int128 int128_remu(Int128, Int128); Int128 int128_divs(Int128, Int128); Int128 int128_rems(Int128, Int128); - -#endif /* CONFIG_INT128 */ +#endif /* CONFIG_INT128 && !CONFIG_TCG_INTERPRETER */ static inline void bswap128s(Int128 *s) { @@ -472,4 +476,19 @@ static inline void bswap128s(Int128 *s) #define INT128_MAX int128_make128(UINT64_MAX, INT64_MAX) #define INT128_MIN int128_make128(0, INT64_MIN) +/* + * When compiler supports a 128-bit type, define a combination of + * a possible structure and the native types. Ease parameter passing + * via use of the transparent union extension. + */ +#ifdef CONFIG_INT128 +typedef union { + Int128 s; + __int128_t i; + __uint128_t u; +} Int128Alias __attribute__((transparent_union)); +#else +typedef Int128 Int128Alias; +#endif /* CONFIG_INT128 */ + #endif /* INT128_H */ diff --git a/util/int128.c b/util/int128.c index ed8f25fef1..df6c6331bd 100644 --- a/util/int128.c +++ b/util/int128.c @@ -144,4 +144,46 @@ Int128 int128_rems(Int128 a, Int128 b) return r; } +#elif defined(CONFIG_TCG_INTERPRETER) + +Int128 int128_divu(Int128 a_s, Int128 b_s) +{ + Int128Alias r, a, b; + + a.s = a_s; + b.s = b_s; + r.u = a.u / b.u; + return r.s; +} + +Int128 int128_remu(Int128 a_s, Int128 b_s) +{ + Int128Alias r, a, b; + + a.s = a_s; + b.s = b_s; + r.u = a.u % b.u; + return r.s; +} + +Int128 int128_divs(Int128 a_s, Int128 b_s) +{ + Int128Alias r, a, b; + + a.s = a_s; + b.s = b_s; + r.i = a.i / b.i; + return r.s; +} + +Int128 int128_rems(Int128 a_s, Int128 b_s) +{ + Int128Alias r, a, b; + + a.s = a_s; + b.s = b_s; + r.i = a.i % b.i; + return r.s; +} + #endif From patchwork Fri Nov 11 07:40:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623729 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp636517pvb; Fri, 11 Nov 2022 00:35:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf6y0xDviwPnDZsxtupIruJvslrCApzMGhD/GdlWJcNoepFJeLlVXPKkmHTHf9urwwR1QXgm X-Received: by 2002:ad4:5a42:0:b0:4b8:5bce:14c3 with SMTP id ej2-20020ad45a42000000b004b85bce14c3mr1060425qvb.123.1668155723642; Fri, 11 Nov 2022 00:35:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668155723; cv=none; d=google.com; s=arc-20160816; b=GwFRalU5vXMJOoLsyETCbpXfHa8e2cXBBYQGjfjnqAmlIpgyhsW20OqAR78hmM74DS QceNfy8pXW3a3Zm56FbWcOYeMJcBr1NnoumFTLavyNgCl38hWW/csyOvoYnQ5TZcFQXx 6TkedythZfOEGHkgVDX9EO7+jva85YdpDdb2ierdKM9dNNT3jzJA7anaBLZgK/aD7h/c qenoqyh7nNbCFggxEaaJBiFoYm89TQDk7rA2NYu3AMVUdhtESPG3eCek1cxStypRvHMj w/1abOXo7DWx5wwBEbdpTQNShAoahGO4c+uKFSiHaXoKBv06QIg6hkqEonHSgcss3Rc6 /bmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=xWtD/TEe250UHjk6klCm4KJGVjq9QANqtB38KitJ/cg=; b=jnQ7yXNahM3N7QhKfUudJA4lXTK5uNP/rsIqUzgHEMScTFd3GSxNmEuzExuvy6OQmI NzY5mXrLr/AyeGfos7iPgaSt8wsx0SC2OBURdfAC6fTfM4GpkEb+b7RZ2W3tv6T74L41 kxjhbs/c0+kRKe5htFrmYMY4v8J+TI0ia5wm8qR7lQMDqiW2HbP9B2XfmeNPaL7apBWI ZUNvx6rm9l3iaMOtn95TyMqV+WE3w/6rVBHqFMtQkdPn77CA5uRN2PJ9WowL0ENxzHns debAQflVJ1Kkh3pU17J3sQm7C8/gPAsAlljeZ6vA+P+h1mWzIasabVye3ab1Rdm2NkxO TbRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qAccBX9X; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id lk5-20020a0562145cc500b004b7c99958c6si622598qvb.150.2022.11.11.00.35.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:35:23 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qAccBX9X; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOgr-0007JC-Cz; Fri, 11 Nov 2022 02:43:05 -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 1otOgN-000745-KG for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:35 -0500 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 1otOgL-0000K1-Vr for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:35 -0500 Received: by mail-pj1-x1035.google.com with SMTP id m6-20020a17090a5a4600b00212f8dffec9so4083684pji.0 for ; Thu, 10 Nov 2022 23:42:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xWtD/TEe250UHjk6klCm4KJGVjq9QANqtB38KitJ/cg=; b=qAccBX9XdMhBmHK6UCYYJhlWFg0QQ4y+W8/ZvtS6k2z+UhkZarJrt4IsC7T86crMYC NJoSyH5QGTC+GN6UHMHSac0phYCdZsqmgymPVNLeM3e2Z5TyJsap1csp2rpdPwxnKwVO 5Jt6V1n6xJzjno0qxUwWTjlvM8eyW6FvlYbGOnmFnk+0YJOJ+UNLYK9Hn0sfN6aC/3de +8I/5UkZekf68UmWVlINH9VjBZrsJyJHIN0cZlvgvO3AY6Dmn4ndP2HFYphxYcPbrzIm vp/j4MZKR9TywKayWRvuhI4S6ANMqXld1kZS5gYhdIGaegNJGHCESAnBzOiG//Fo6QcP /zww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xWtD/TEe250UHjk6klCm4KJGVjq9QANqtB38KitJ/cg=; b=FB2KZrk/yw53mJFaxx9SRwR7nRXeQmza/8PhZGQDtoN2sfEoL0w5TaikWJWWUpqCui vSfQWyI50E4uqmBl4flVeSay7Fg4I7TwTxWnc+cT3OsUx5A1QuHbrIGHz5YekBM4fYr2 zN6ze80UQQhvONhcmBl0xSrJ160uA18TnVgH+HHfayXNkzgo3ngtDcPEQJJdi/1V95QU eVESO5wjW5RU6DgZXe/LaIjCEY41oHdTJ5VHnzBTzOYZdmhE3p5FguveeR1pT2ZxxV4I L/yWR/p2Td0wbJuyMhr2fwIhHhN/Kk+EJWeMt9jV74kZ0GcGevEXam4oLGjDMeQVcXTw AYNA== X-Gm-Message-State: ANoB5pmx0QeQjUByHCl7E34BhDxBFN+Kj2t9z6KwCRhBVRu5C+RmD5zK dyetTWdcke+C22Xf0DVoa985GrbgE9AVPSvY X-Received: by 2002:a17:902:8210:b0:17c:b7ac:86f with SMTP id x16-20020a170902821000b0017cb7ac086fmr1060981pln.140.1668152552506; Thu, 10 Nov 2022 23:42:32 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 37/45] tcg/i386: Add TCG_TARGET_CALL_{RET, ARG}_I128 Date: Fri, 11 Nov 2022 17:40:53 +1000 Message-Id: <20221111074101.2069454-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; 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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Fill in the parameters for the host ABI for Int128. Adjust tcg_target_call_oarg_reg for _WIN64, and tcg_out_call for i386 sysv. Allow TCG_TYPE_V128 stores without AVX enabled. Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.h | 10 ++++++++++ tcg/i386/tcg-target.c.inc | 30 +++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 7edb7f1d9a..9e0e82d80a 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -100,6 +100,16 @@ typedef enum { #endif #define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL +#if defined(_WIN64) +# define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_BY_REF +# define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_BY_VEC +#elif TCG_TARGET_REG_BITS == 64 +# define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_NORMAL +# define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_NORMAL +#else +# define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_NORMAL +# define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_BY_REF +#endif extern bool have_bmi1; extern bool have_popcnt; diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index ab6881a4f3..c96b5a6f43 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -115,6 +115,11 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) case TCG_CALL_RET_NORMAL: tcg_debug_assert(slot >= 0 && slot <= 1); return slot ? TCG_REG_EDX : TCG_REG_EAX; +#ifdef _WIN64 + case TCG_CALL_RET_BY_VEC: + tcg_debug_assert(slot == 0); + return TCG_REG_XMM0; +#endif default: g_assert_not_reached(); } @@ -1188,9 +1193,16 @@ static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, * The gvec infrastructure is asserts that v128 vector loads * and stores use a 16-byte aligned offset. Validate that the * final pointer is aligned by using an insn that will SIGSEGV. + * + * This specific instance is also used by TCG_CALL_RET_BY_VEC, + * for _WIN64, which must have SSE2 but may not have AVX. */ tcg_debug_assert(arg >= 16); - tcg_out_vex_modrm_offset(s, OPC_MOVDQA_WxVx, arg, 0, arg1, arg2); + if (have_avx1) { + tcg_out_vex_modrm_offset(s, OPC_MOVDQA_WxVx, arg, 0, arg1, arg2); + } else { + tcg_out_modrm_offset(s, OPC_MOVDQA_WxVx, arg, arg1, arg2); + } break; case TCG_TYPE_V256: /* @@ -1677,6 +1689,22 @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest, const TCGHelperInfo *info) { tcg_out_branch(s, 1, dest); + +#ifndef _WIN32 + if (TCG_TARGET_REG_BITS == 32 && info->out_kind == TCG_CALL_RET_BY_REF) { + /* + * The sysv i386 abi for struct return places a reference as the + * first argument of the stack, and pops that argument with the + * return statement. Since we want to retain the aligned stack + * pointer for the callee, we do not want to actually push that + * argument before the call but rely on the normal store to the + * stack slot. But we do need to compensate for the pop in order + * to reset our correct stack pointer value. + * Pushing a garbage value back onto the stack is quickest. + */ + tcg_out_push(s, TCG_REG_EAX); + } +#endif } static void tcg_out_jmp(TCGContext *s, const tcg_insn_unit *dest) From patchwork Fri Nov 11 07:40:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623681 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp616299pvb; Thu, 10 Nov 2022 23:43:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf6C/3ciHUYgWYRQ+R7wbqSM/kLlo+G68pixOBBhYRH4G5CGOie8l7GVfwm7Z75YkTf3d3wr X-Received: by 2002:a05:620a:1013:b0:6fa:c94:5c06 with SMTP id z19-20020a05620a101300b006fa0c945c06mr200885qkj.91.1668152628991; Thu, 10 Nov 2022 23:43:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668152628; cv=none; d=google.com; s=arc-20160816; b=MCFqD9NfBV7jW7rny2jPLNaA3/OU3+PGCgqy2/uy/JCkNGX6O2hRBxGL+vP9IOAozR YXpJoqGEIihWqV0rAOBblCFioN2Xnorje1LVOWZthuW1rlkbbHkgTX2gJaf1pofg4uDn gnlfPgr0hbsi0ox5MnNaSu3Nyq1NiXhsXXtzGLD2rT06aTbbaq97NenXYoDxr4I3GDqk P7v+cvmeMDqmRxnY16z5YSLXCrb/LZv3BTpcVFwtJjsDzNmb+85xyEGo98I8GtVKxARt a6+gXK5s5vABsE0No4tSGd4AU6pYoNRgsSCtUH5eUhwhOkGNyJNcY6f1jYTctmF1CPjC Tpmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=vaZgOeSJc5X20dDhSfYmqdZAzqI99H2R1i2kilXRvO0=; b=MJKX+ZrXtmynA0X3u3c6eHdcuSuwCz56ZgPNs6+7u06m1NieIk1GubD8Ff9dwMjmf2 a5Db+4I7O7yza0Uhy8OAe8DynaoXotGtGoHrmaCuY0fZrP4wQqnrC6Oitz7AbuII6K6P 1VAYNNIWURJs3Dl+1EIEK584NEcBAsyKfY1Mdmpn0glJPamYwBuacGBGqRtQ9dTTtvYB 7GYyQxNGu7BT0u6UBlFRzyrA20ZnkDfGn/XJuAM9Abrw9b4Qo3cLHnRM9rr1eUfgbVVk /JeYIez8/wGtDlbruSrrkhtNE7/VtWO+xPB7ANwkSe3nAfeegd7aynAS5395KhYZgRET cx3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rnjdarfd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c27-20020a05620a201b00b006fa48d9c1bdsi694096qka.442.2022.11.10.23.43.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:43:48 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rnjdarfd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOgu-0007KY-F5; Fri, 11 Nov 2022 02:43:08 -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 1otOgT-00077X-Va for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:49 -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 1otOgO-0000KM-2a for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:40 -0500 Received: by mail-pf1-x436.google.com with SMTP id y13so4236348pfp.7 for ; Thu, 10 Nov 2022 23:42:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vaZgOeSJc5X20dDhSfYmqdZAzqI99H2R1i2kilXRvO0=; b=RnjdarfdiOjiNjCqjvcklpMvGDKm2lRgC50AnUNu4IWC3Z1Rm596Ddo4kyOJVWA68f HQZPIAEtRLeAn+0SFxzYMthdysw5s3cuCrziWTLCpEY9Y2PmRKcjhVxwImr8qKGqoN26 VP07uT95stoxIm6Jed1dDSKogS4LswZZ4HLyxNYfQftaLqzSxZ/MpDS80TMMWXMFAS9+ qh29Ur+xFDm2TxtGaDTpIjrO44HsupotZrkglm7Xy3QeQifr4aQVYplNEHQ5yrXy59oO du2o7RlXsO8lQEkueizX5dkdWrhL+FMetf61PV+XUHOjuwmujPYxCAmIo3H/OXpQTexN 3aaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vaZgOeSJc5X20dDhSfYmqdZAzqI99H2R1i2kilXRvO0=; b=tvyuzV89GKUkvTRxsFoY27X7b4O/ygoOMtqktck59P3u2uaPWJwRflIAUQQe0BBBgg iaXRnD0hBsbZqtvfxyrJ5X0AT2/mWXFVr30JlIZI8/dSOp6HIMD9oEfaSJUfey/sNQnf TcowKmKXrnPQyywQO0Xs4M5N0RR0jIBppJ3wgVgFkZ6DiNsoZh3sp4hp/BPI1fJjB5uT ka/CR06RHuvR6CvS2bBd4MHLFOaHUSrFERQDhBECOLoAuiFwFlAUiSHzN3PXg17U8sMa VFN9uzx44LBMauxeztWEQ97dvfihrslcDuCAVr/ta2F4yT8neetfR5Vi5oEKP1SpSYGr S4DQ== X-Gm-Message-State: ANoB5pkpSJMR6+DD1gnv5uGH/wgDL0/o9p0N5wxT+NWUDoRLzarT5fSH dJoV5+PcaTtQr/oVG6LTaIQFAyy/N8iTlFme X-Received: by 2002:a05:6a00:1c86:b0:56b:d027:214 with SMTP id y6-20020a056a001c8600b0056bd0270214mr1373977pfw.79.1668152554581; Thu, 10 Nov 2022 23:42:34 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:34 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 38/45] tcg/tci: Fix big-endian return register ordering Date: Fri, 11 Nov 2022 17:40:54 +1000 Message-Id: <20221111074101.2069454-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We expect the backend to require register pairs in host-endian ordering, thus for big-endian the first register of a pair contains the high part. We were forcing R0 to contain the low part for calls. Signed-off-by: Richard Henderson --- tcg/tci.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tcg/tci.c b/tcg/tci.c index 05a24163d3..eeccdde8bc 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -520,27 +520,28 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, ffi_call(pptr[1], pptr[0], stack, call_slots); } - /* Any result winds up "left-aligned" in the stack[0] slot. */ switch (len) { case 0: /* void */ break; case 1: /* uint32_t */ /* + * The result winds up "left-aligned" in the stack[0] slot. * Note that libffi has an odd special case in that it will * always widen an integral result to ffi_arg. */ - if (sizeof(ffi_arg) == 4) { - regs[TCG_REG_R0] = *(uint32_t *)stack; - break; - } - /* fall through */ - case 2: /* uint64_t */ - if (TCG_TARGET_REG_BITS == 32) { - tci_write_reg64(regs, TCG_REG_R1, TCG_REG_R0, stack[0]); + if (sizeof(ffi_arg) == 8) { + regs[TCG_REG_R0] = (uint32_t)stack[0]; } else { - regs[TCG_REG_R0] = stack[0]; + regs[TCG_REG_R0] = *(uint32_t *)stack; } break; + case 2: /* uint64_t */ + /* + * For TCG_TARGET_REG_BITS == 32, the register pair + * must stay in host memory order. + */ + memcpy(®s[TCG_REG_R0], stack, 8); + break; default: g_assert_not_reached(); } From patchwork Fri Nov 11 07:40:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623691 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp619792pvb; Thu, 10 Nov 2022 23:54:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf7dmQEv5pApWt/1UUzZaY75C7ByyZuvC8IgMXuToYuUnRrASBq0oD1YVmaRJkmCjAF1+xSI X-Received: by 2002:a05:622a:1b20:b0:3a5:1e70:f3cd with SMTP id bb32-20020a05622a1b2000b003a51e70f3cdmr389001qtb.70.1668153240928; Thu, 10 Nov 2022 23:54:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668153240; cv=none; d=google.com; s=arc-20160816; b=nbygs0nlw5T8mYcCBaOD/gQRGcJWyE52ccVStwE91bptCEK41z9lqUhzRtAmqIAP9Q +CasCd/JT3O+xTNh+ADQPdKRxwhMeYEgvUIcA6Jk31LnYShha1j28wrV3hKISTgAX+FM EVdjS/FoCS4fPMqSBvo/nW91fQwiuEJZ8dB4hkPWSK1ZJ2PDBjb4h6s3xfE/IRKmPGTG 4tvMikEbpr6abAM71d3RyTovKpSBobrgE1SB6fMdzozLpvYsCklpLckNRB5LybA0Z/Le KMCvpBOdaf9Z5bTYOp8OFwALGCNfDZgT9CPLM52bsGMa+m92Xxru5K8VMEzKW4mrn2E+ QLBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=jkMEHyKXRx2RUVUHUzML8Xa/7tYiAZGILcpHuyAmn/s=; b=SLp+2DSS1R/nFbsgs5qHug91AG0HtIw2buYKd5mpJbPvciJE6UEBYHhVz+7d/T1i2P voE0S8Ykby6NiNATXjh6SSLL/PsqJzuCKCuuzMcqKMywf3t1szJ2gnJqYc7bC/fw2Hi5 HDBjY8J5cecvrdtt4yXqoNggsRnVCQFJTMdjOgZ1SRsEWP36vqGyr82nJm0ZiYyqHimP 1Hb+IOuzsAdIl8abwDpweoFK9HkJsh0Iq3d1QmqRkfIs8a30vSJ2dcybDC5eAkBqD4cd NRnBki7HUkWignz+zvhH69fzkQdERHo+FYUk+c2NzRuXw7We4rdiyNfcvUbvHGhSrvMt XRlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FxGzRAY0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h10-20020a0562140daa00b004aaa72ac376si655740qvh.364.2022.11.10.23.54.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:54:00 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FxGzRAY0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOgu-0007Kb-Gg; Fri, 11 Nov 2022 02:43:08 -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 1otOgW-00077u-Qx for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:48 -0500 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOgT-0000Kb-Od for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:42:44 -0500 Received: by mail-pj1-x102f.google.com with SMTP id gw22so3779131pjb.3 for ; Thu, 10 Nov 2022 23:42:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jkMEHyKXRx2RUVUHUzML8Xa/7tYiAZGILcpHuyAmn/s=; b=FxGzRAY0I2yHcTNGDquY0pJzDnqjUai1jqdFQfqJHyRWdSCa+1HtFB0fCoif5kOqMx qyRsD017b58ba2o2yxPE1ylREHP03uZtytL3QQTkbSDBvBEsYYvzWnv7kMOXSHGRcAH/ 932YzTpdk2XggzgetV7i39Tati2mlKe7HhRiZnWcJ5UbJhu7fXtB7O1UyY3NMTCRRADl aGqPRoNcxUWAXZw5iNBjusQiaZ0h9n0xHZ7EGiuJxWGWwIsgDtSZu54qdGyrAp73yvnI FFlkVZYTLbn4+S2lZws58vyTjNHQXyhqNh4QFdpwnxah3zYC0OV3ouN7j/5UupgXvffi 6Opg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jkMEHyKXRx2RUVUHUzML8Xa/7tYiAZGILcpHuyAmn/s=; b=5gJFKfROse58PEd+HNQ0DjrdkRV/6tBSHhFHAm7GxN1ZDcP9AK77xV2Vz6C9rmTIse WVgqoG05x7LycOGFm9ggO7hkCLm0mzrXgfGtTFzWZ3GlhoaaPuX3O/nupaa0AYOoaA1H cH8AxPXMsoP8eUV3RxfwoVJLpQYA7n1p/69rF1NxG8NjcOEVOhnykUUMV4lE3KSCujSC 0YTFoOSgVunJ75Ye3du+MUy7Uanz9Xxf3FEIjFDfm5X835htM4qMguoasuuQ+wY6PyGb mh6LilZXUbNuH+HOeJPRT+3DPWEzUnfs600NCN/akRwgFzneXERTO1AViMZ801dW94vw nr3A== X-Gm-Message-State: ANoB5pkjdSDtRrxBvs1bTeHzl7OGKl30EDX0yBBMileVCnmGWBKMlSUz 7CUyLcF1cUR6NqwCVHi9SPhbZr6AxRtNXqyK X-Received: by 2002:a17:903:2112:b0:186:68e6:ed6d with SMTP id o18-20020a170903211200b0018668e6ed6dmr1365068ple.129.1668152556704; Thu, 10 Nov 2022 23:42:36 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001754fa42065sm976069plg.143.2022.11.10.23.42.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:42:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 39/45] tcg/tci: Add TCG_TARGET_CALL_{RET,ARG}_I128 Date: Fri, 11 Nov 2022 17:40:55 +1000 Message-Id: <20221111074101.2069454-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Fill in the parameters for libffi for Int128. Adjust the interpreter to allow for 16-byte return values. Adjust tcg_out_call to record the return value length. Call parameters are no longer all the same size, so we cannot reuse the same call_slots array for every function. Compute it each time now, but only fill in slots required for the call we're about to make. Signed-off-by: Richard Henderson --- tcg/tci/tcg-target.h | 3 +++ tcg/tcg.c | 19 +++++++++++++++++ tcg/tci.c | 44 ++++++++++++++++++++-------------------- tcg/tci/tcg-target.c.inc | 10 ++++----- 4 files changed, 49 insertions(+), 27 deletions(-) diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index 94ec541b4e..9d569c9e04 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -161,10 +161,13 @@ typedef enum { #if TCG_TARGET_REG_BITS == 32 # define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_EVEN # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN +# define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_EVEN #else # define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL +# define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_NORMAL #endif +#define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_NORMAL #define HAVE_TCG_QEMU_TB_EXEC #define TCG_TARGET_NEED_POOL_LABELS diff --git a/tcg/tcg.c b/tcg/tcg.c index 3476721fbe..9dd194a2f2 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -548,6 +548,22 @@ static GHashTable *helper_table; #ifdef CONFIG_TCG_INTERPRETER static ffi_type *typecode_to_ffi(int argmask) { + /* + * libffi does not support __int128_t, so we have forced Int128 + * to use the structure definition instead of the builtin type. + */ + static ffi_type *ffi_type_i128_elements[3] = { + &ffi_type_uint64, + &ffi_type_uint64, + NULL + }; + static ffi_type ffi_type_i128 = { + .size = 16, + .alignment = __alignof__(Int128), + .type = FFI_TYPE_STRUCT, + .elements = ffi_type_i128_elements, + }; + switch (argmask) { case dh_typecode_void: return &ffi_type_void; @@ -561,6 +577,8 @@ static ffi_type *typecode_to_ffi(int argmask) return &ffi_type_sint64; case dh_typecode_ptr: return &ffi_type_pointer; + case dh_typecode_i128: + return &ffi_type_i128; } g_assert_not_reached(); } @@ -591,6 +609,7 @@ static void init_ffi_layouts(void) /* Ignoring the return type, find the last non-zero field. */ nargs = 32 - clz32(typemask >> 3); nargs = DIV_ROUND_UP(nargs, 3); + assert(nargs <= MAX_CALL_IARGS); ca = g_malloc0(sizeof(*ca) + nargs * sizeof(ffi_type *)); ca->cif.rtype = typecode_to_ffi(typemask & 7); diff --git a/tcg/tci.c b/tcg/tci.c index eeccdde8bc..022fe9d0f8 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -470,12 +470,9 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, tcg_target_ulong regs[TCG_TARGET_NB_REGS]; uint64_t stack[(TCG_STATIC_CALL_ARGS_SIZE + TCG_STATIC_FRAME_SIZE) / sizeof(uint64_t)]; - void *call_slots[TCG_STATIC_CALL_ARGS_SIZE / sizeof(uint64_t)]; regs[TCG_AREG0] = (tcg_target_ulong)env; regs[TCG_REG_CALL_STACK] = (uintptr_t)stack; - /* Other call_slots entries initialized at first use (see below). */ - call_slots[0] = NULL; tci_assert(tb_ptr); for (;;) { @@ -498,26 +495,26 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, switch (opc) { case INDEX_op_call: - /* - * Set up the ffi_avalue array once, delayed until now - * because many TB's do not make any calls. In tcg_gen_callN, - * we arranged for every real argument to be "left-aligned" - * in each 64-bit slot. - */ - if (unlikely(call_slots[0] == NULL)) { - for (int i = 0; i < ARRAY_SIZE(call_slots); ++i) { - call_slots[i] = &stack[i]; - } - } - - tci_args_nl(insn, tb_ptr, &len, &ptr); - - /* Helper functions may need to access the "return address" */ - tci_tb_ptr = (uintptr_t)tb_ptr; - { - void **pptr = ptr; - ffi_call(pptr[1], pptr[0], stack, call_slots); + void *call_slots[MAX_CALL_IARGS]; + ffi_cif *cif; + void *func; + unsigned i, s, n; + + tci_args_nl(insn, tb_ptr, &len, &ptr); + func = ((void **)ptr)[0]; + cif = ((void **)ptr)[1]; + + n = cif->nargs; + for (i = s = 0; i < n; ++i) { + ffi_type *t = cif->arg_types[i]; + call_slots[i] = &stack[s]; + s += DIV_ROUND_UP(t->size, 8); + } + + /* Helper functions may need to access the "return address" */ + tci_tb_ptr = (uintptr_t)tb_ptr; + ffi_call(cif, func, stack, call_slots); } switch (len) { @@ -542,6 +539,9 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, */ memcpy(®s[TCG_REG_R0], stack, 8); break; + case 3: /* Int128 */ + memcpy(®s[TCG_REG_R0], stack, 16); + break; default: g_assert_not_reached(); } diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index cd53cb6b6b..357888a532 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -203,7 +203,7 @@ static const int tcg_target_call_iarg_regs[] = { }; static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) { tcg_debug_assert(kind == TCG_CALL_RET_NORMAL); - tcg_debug_assert(slot >= 0 && slot < 64 / TCG_TARGET_REG_BITS); + tcg_debug_assert(slot >= 0 && slot < 128 / TCG_TARGET_REG_BITS); return TCG_REG_R0 + slot; } @@ -573,11 +573,11 @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *func, if (cif->rtype == &ffi_type_void) { which = 0; - } else if (cif->rtype->size == 4) { - which = 1; } else { - tcg_debug_assert(cif->rtype->size == 8); - which = 2; + tcg_debug_assert(cif->rtype->size == 4 || + cif->rtype->size == 8 || + cif->rtype->size == 16); + which = ctz32(cif->rtype->size) - 1; } new_pool_l2(s, 20, s->code_ptr, 0, (uintptr_t)func, (uintptr_t)cif); insn = deposit32(insn, 0, 8, INDEX_op_call); From patchwork Fri Nov 11 07:40:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623696 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp621186pvb; Thu, 10 Nov 2022 23:57:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf43pNK2IgYs1wKXRetXjIZgmGRHjdnLq2j5utOFJwQafKBfu2PcZ47Cstv4HfOENiAKugeq X-Received: by 2002:a05:620a:31a1:b0:6e7:2a1a:e756 with SMTP id bi33-20020a05620a31a100b006e72a1ae756mr184319qkb.569.1668153459831; Thu, 10 Nov 2022 23:57:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668153459; cv=none; d=google.com; s=arc-20160816; b=sraVV1n8HCG920zb1Ds+dXQJmUf00kSmsicsCcIBJvWVYCYughVY5zPccVCWAxewog FSxXxPzEDokw3e5l9DFocKgE67wQu0VmRGBckZAhtl1bksqVFpPmopGj6lVKgMmu9nPJ nPbJogm50KFesSyjwXLrZUOdXoZot56RV3iN4H2ejdGO6WzIm0jjLRN1rtqmSPb/lyRj YYslcrzk6mLI9DI2bFctrjO6Ck7qga20YW31Sp/UKZF25JYvTESOdpxjM1Vj6M7vAj1y Pny3gA8cljtcE7oI+mgYRMVlfbBv/UBvt5u9o0E0yJ4Mtyihlq+di0PXoh67NTffepoU gFQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=UiqM1xpZUrdT5wKdp2vT9gWYvDkW+t7k776FpqUx6QM=; b=EkBxXx/T8Ex+l8Wn458p5BjIgKkYMIxFp2FFezg7ZrcOQ3FGqO1jp8uNnNBQrzqT8E p4qpfdac3bgO2ZJM/p3xP8X0JnxuTwrfnPBn9j/IQgRflM6XsUDnCd3Jlp/OXs55DiGQ oOqF0XPX4Ouw7ORIlV73v5IPNxHbX7h3GLaX2tFnLjBcitOKLEY7Rh2qpXQHvaOgV7Jc K3jHBB/VehDYotLMXCnzqkQVHXNIWDRDAFwiZ4b+MAK/JvjEGegT9PEWaiO+BwUmoxFM Q2pEIu45l9Gcfxgsw4dILI754+mAiXaDsc82/BWirXiUiTCf0j/UeeRt0d2usWxG1n2e B89Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dpl3Uf58; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ay41-20020a05620a17a900b006fb0d63d886si829086qkb.19.2022.11.10.23.57.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:57:39 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dpl3Uf58; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOjT-0001Mu-Sc; Fri, 11 Nov 2022 02:45:47 -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 1otOjR-0001Ku-LA for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:45:45 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOjP-00017o-PY for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:45:45 -0500 Received: by mail-pj1-x1034.google.com with SMTP id c15-20020a17090a1d0f00b0021365864446so4041228pjd.4 for ; Thu, 10 Nov 2022 23:45:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=UiqM1xpZUrdT5wKdp2vT9gWYvDkW+t7k776FpqUx6QM=; b=dpl3Uf5884YJRkzGDmAFuknQcbPrHJ14nJJYTqwDenImsgu+xPxf93xpOAdyqEtUe+ XrvLXrshKlwZW+Ryl8sgNxd9kAX13a6Y7NmziCv4CBk9b4wzPDpKLXYSJ6GCX1hAhj28 iClouZnt2Vj97FDLn9dKXs3xblC09C2M2sSGjrCTQt97KKVBs3bV1orMr768/3Fas32I GIDJfmR5bkSgX7zBAlAZGXiYY+RHUPihRZHeSQavu0UTS12SamBmM4oyfLBkqSL2gbUk iBQZwU1Q6RMQ0V6mLEy3Azh63uBmamr5NUwGKZo17znjqgcQhMug9YP9X8Qkw55G38G4 nwNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UiqM1xpZUrdT5wKdp2vT9gWYvDkW+t7k776FpqUx6QM=; b=obZ9qMlWC/zT/3vgw8uXoOHEFGmCWHtbtIpqMqaF9Xq48kaOXxUSAvrqVf9M0aoaLo corgu3gXqmkPnDGrZvcxyUV4Kv3TXlTYv5UFw8l9uqYWogVRXJ3DpoRpE0VUvK2zRyYg 5v5LSi62ER6WHqwC9NH3m548AjcXa06Dq+6es4Vt7BsyWYpSjoY1khTLQMJXoEh8Y+kJ pEjZo2b5H3DjOsQullq18dT8GzFoUMdaw+8wzbSILyCQp4aQLnqWhJb7oHzyq7/YmsGj Qrdmkj6vqV4hQyn5oI4+LaqT5CtdDBCQHU5oPiJNfY5MvMLdDxuM25723V3+hlTQoLB8 4sDg== X-Gm-Message-State: ANoB5pnIRVfQeF1PXtxJQcCBnRDsKA4t5iETJW0Wj0sanUDpmffc0/D7 CLbOatDW9L/mgjr1IUifPwLN9Y45wZC3sXxZ X-Received: by 2002:a17:90a:b894:b0:20a:7294:47dd with SMTP id o20-20020a17090ab89400b0020a729447ddmr570493pjr.207.1668152742488; Thu, 10 Nov 2022 23:45:42 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id u13-20020a170902e80d00b001869f2120a6sm983802plg.108.2022.11.10.23.45.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:45:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 40/45] tcg: Add TCG_TARGET_CALL_{RET,ARG}_I128 Date: Fri, 11 Nov 2022 17:40:56 +1000 Message-Id: <20221111074101.2069454-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Fill in the parameters for the host ABI for Int128 for those backends which require no extra modification. Signed-off-by: Richard Henderson Reviewed-by: Daniel Henrique Barboza --- tcg/aarch64/tcg-target.h | 2 ++ tcg/arm/tcg-target.h | 2 ++ tcg/loongarch64/tcg-target.h | 2 ++ tcg/mips/tcg-target.h | 2 ++ tcg/riscv/tcg-target.h | 3 +++ tcg/s390x/tcg-target.h | 2 ++ tcg/sparc64/tcg-target.h | 2 ++ tcg/tcg.c | 6 +++--- tcg/ppc/tcg-target.c.inc | 3 +++ 9 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 413a5410c5..0dff5807f6 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -54,6 +54,8 @@ typedef enum { #define TCG_TARGET_CALL_STACK_OFFSET 0 #define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL +#define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_NORMAL +#define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_NORMAL /* optional instructions */ #define TCG_TARGET_HAS_div_i32 1 diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index b7843d2d54..6613d3d791 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -91,6 +91,8 @@ extern bool use_neon_instructions; #define TCG_TARGET_CALL_STACK_OFFSET 0 #define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN +#define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_EVEN +#define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_BY_REF /* optional instructions */ #define TCG_TARGET_HAS_ext8s_i32 1 diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index e5f7a1f09d..9d0db8fdfe 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -95,6 +95,8 @@ typedef enum { #define TCG_TARGET_CALL_STACK_OFFSET 0 #define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL +#define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_NORMAL +#define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_NORMAL /* optional instructions */ #define TCG_TARGET_HAS_movcond_i32 0 diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 15721c3e42..b235cba8ba 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -89,6 +89,8 @@ typedef enum { # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL #endif #define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL +#define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_EVEN +#define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_NORMAL /* MOVN/MOVZ instructions detection */ #if (defined(__mips_isa_rev) && (__mips_isa_rev >= 1)) || \ diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 232537ccea..d61ca902d3 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -85,9 +85,12 @@ typedef enum { #define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #if TCG_TARGET_REG_BITS == 32 #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN +#define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_EVEN #else #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL +#define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_NORMAL #endif +#define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_NORMAL /* optional instructions */ #define TCG_TARGET_HAS_movcond_i32 0 diff --git a/tcg/s390x/tcg-target.h b/tcg/s390x/tcg-target.h index db5665c375..9a3856f0b3 100644 --- a/tcg/s390x/tcg-target.h +++ b/tcg/s390x/tcg-target.h @@ -168,6 +168,8 @@ extern uint64_t s390_facilities[3]; #define TCG_TARGET_CALL_STACK_OFFSET 160 #define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_EXTEND #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_RET_NORMAL +#define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_BY_REF +#define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_BY_REF #define TCG_TARGET_HAS_MEMORY_BSWAP 1 diff --git a/tcg/sparc64/tcg-target.h b/tcg/sparc64/tcg-target.h index 0044ac8d78..53cfa843da 100644 --- a/tcg/sparc64/tcg-target.h +++ b/tcg/sparc64/tcg-target.h @@ -73,6 +73,8 @@ typedef enum { #define TCG_TARGET_CALL_STACK_OFFSET (128 + 6*8 + TCG_TARGET_STACK_BIAS) #define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_EXTEND #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL +#define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_NORMAL +#define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_NORMAL #if defined(__VIS__) && __VIS__ >= 0x300 #define use_vis3_instructions 1 diff --git a/tcg/tcg.c b/tcg/tcg.c index 9dd194a2f2..5465297495 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -743,8 +743,8 @@ static void init_call_layout(TCGHelperInfo *info) break; case dh_typecode_i128: info->nr_out = 128 / TCG_TARGET_REG_BITS; - info->out_kind = TCG_CALL_RET_NORMAL; /* TODO */ - switch (/* TODO */ TCG_CALL_RET_NORMAL) { + info->out_kind = TCG_TARGET_CALL_RET_I128; + switch (TCG_TARGET_CALL_RET_I128) { case TCG_CALL_RET_NORMAL: /* Query the last register now to trigger any assert early. */ tcg_target_call_oarg_reg(info->out_kind, info->nr_out - 1); @@ -815,7 +815,7 @@ static void init_call_layout(TCGHelperInfo *info) layout_arg_1(&cum, info, TCG_CALL_ARG_NORMAL); break; case dh_typecode_i128: - switch (/* TODO */ TCG_CALL_ARG_NORMAL) { + switch (TCG_TARGET_CALL_ARG_I128) { case TCG_CALL_ARG_EVEN: layout_arg_even(&cum); /* fall through */ diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 781ecfe161..e86d4a5e78 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -54,6 +54,9 @@ #else # define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL #endif +/* Note sysv arg alignment applies only to 2-word types, not more. */ +#define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_NORMAL +#define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_NORMAL /* For some memory operations, we need a scratch that isn't R0. For the AIX calling convention, we can re-use the TOC register since we'll be reloading From patchwork Fri Nov 11 07:40:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623704 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp628220pvb; Fri, 11 Nov 2022 00:13:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf4XTgpf51XtXSxladAL1v0bogVII+npErAy00kkBKQ/KlrLfCV7CJHgn2LjOLOev1n+sH1t X-Received: by 2002:a05:6214:1192:b0:4bb:65cb:cff5 with SMTP id t18-20020a056214119200b004bb65cbcff5mr1024829qvv.38.1668154387600; Fri, 11 Nov 2022 00:13:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668154387; cv=none; d=google.com; s=arc-20160816; b=BsM496zLoJObL+skkv/xNSBFWaXDHK3cXOXF1aUmAA49RcFWaPRQ2FmveM1g/hR4WC zFj+mAryhdBLrRp9KJr1RKEch6EzEeTWe9X1DKi5wzHbYHMDM8MpITEu5x1yU93PyBbu 3Vu7nlbYqdqHM14iLb9RJzRRag4m/KTFg+X5hfdk+uX5QE8iS1oYK4APPRz2WVmJi6YH wRhJaC7a3QHfS/YQSr2tJQj3WSReQ6bk89sV7GchyIK827lMLGdZzpNgZYsaW2EI7tO6 11tUQE1nkQyObLsdfuR2gBCnqHmWHwx0R0kVQNyr8TnGeZ5kfx3SpiJTuu1Ihqogp88w nL4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=8Y1g/wUg06QV14OKflOwRGsY0ezG4rnZiU5/c0ET0lg=; b=iRhZ/WT45EvmiA/Tq27ETDBFNJ7Tdo1PD2wc9k6e3A3X3ZqA5AGIjGHeGLttRv8MY+ lo6bRLIeOHMSIA2WQZqEb0V1EL9tUYU+fhHEKBtBHO3RrTD/hLzDxf7+O+77crivYBe4 U0Yv8dTI+V3csjAdwwxgPtVfpEjoZJGFPfohCYjJjwGIVOB2D7Q72BoQgfl9F0WS2Fsn ZUtuNcdEq1YB7tCxFoLBsPurtm06JFvxsyQdMxn+H9cJTB7Q0E1a4Hgjnl99XAAK5s+D OUIKQvgzfuAKNN6cloExVLku3xAHnt2/sUBTK6mUuHxspKz2q19r++yO4yLkyhtJ2n4i N01A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lY7a8gE2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gv10-20020a056214262a00b004bb95ea0e4fsi626561qvb.350.2022.11.11.00.13.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:13:07 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lY7a8gE2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOjV-0001Pb-OL; Fri, 11 Nov 2022 02:45:49 -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 1otOjT-0001N0-RZ for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:45:47 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOjS-000182-36 for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:45:47 -0500 Received: by mail-pj1-x1033.google.com with SMTP id m6-20020a17090a5a4600b00212f8dffec9so4089262pji.0 for ; Thu, 10 Nov 2022 23:45:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=8Y1g/wUg06QV14OKflOwRGsY0ezG4rnZiU5/c0ET0lg=; b=lY7a8gE2C9IWsGik3j4R92fFRpym2KWYCKJn/lpenv1VRt/JfEd+0xbV3odxYqI8js aX2OcgwqE+YtjuPPfXM+oBfMTLmr3P7YxRludhe2ntBYidiNh9V77dy35TS1gyzp6Ojm aFIKxfXAiyhtbdAc7l2JD3W4WfKeH1slF9/CD2YImHjZCjqunuVMmemuKtRGyvl/X8kH vN6WVQu+4ke/HyqCV7Z6bseTs1irFGOPKoBNhzfCMQX63JkWoZ+y7obw+kWzwrHufh9h AeFHl+fmYMACwBWF3jihb9khVPJwfYqAivgDHA0y/SBHYgznyp7hQoeKafzIM0WL3653 6O0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8Y1g/wUg06QV14OKflOwRGsY0ezG4rnZiU5/c0ET0lg=; b=OgrVvwKiAEzhOrOb1HrBU3CFF7rhZUa3QDPEpi7AydJrOo0VP7rasMUaWhJHUQ2W7M ipQ/dYCtSQVkt8OZSnJdKEB/a8yv0Aq0UawwD+L4hsvVRITARkyY7nGQ2dFN3aS1cDDD Xk/sNBf9aySdQnFgGwc2OiVaLhbWT9Ac/SSsP8gVxhUvBz/5h95ww4N7R2EUk6zuIeki DJ67PxjmwzkezmDHyu5mQRBFShrlGLfrvYjczm51Th7ZAIKhIDaxwYmyuRtCZ+xJ1LGi UjAjYzRf/dFomoSbDT2GyjqG/6Hrb6VZh/Bt3cwiRGRdB+3QLwi9aWKBCJfw7fnSZuei IoNw== X-Gm-Message-State: ANoB5pmSdgC58lwP8pXMXqCSIPOvBCoo6y04YkUytF1q8A2s4yo99RFo RbyB3bSKs2zIpa0/hE+9LFdqVOKbh91z+n3t X-Received: by 2002:a17:903:284:b0:186:b91b:17ec with SMTP id j4-20020a170903028400b00186b91b17ecmr1479921plr.10.1668152744588; Thu, 10 Nov 2022 23:45:44 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id u13-20020a170902e80d00b001869f2120a6sm983802plg.108.2022.11.10.23.45.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:45:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 41/45] tcg: Add temp allocation for TCGv_i128 Date: Fri, 11 Nov 2022 17:40:57 +1000 Message-Id: <20221111074101.2069454-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This enables allocation of i128. The type is not yet usable, as we have not yet added data movement ops. Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 32 +++++++++++++++++++++++++ tcg/tcg.c | 60 +++++++++++++++++++++++++++++++++-------------- 2 files changed, 74 insertions(+), 18 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 7d346192ca..a996da60b5 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -697,6 +697,11 @@ static inline TCGTemp *tcgv_i64_temp(TCGv_i64 v) return tcgv_i32_temp((TCGv_i32)v); } +static inline TCGTemp *tcgv_i128_temp(TCGv_i128 v) +{ + return tcgv_i32_temp((TCGv_i32)v); +} + static inline TCGTemp *tcgv_ptr_temp(TCGv_ptr v) { return tcgv_i32_temp((TCGv_i32)v); @@ -717,6 +722,11 @@ static inline TCGArg tcgv_i64_arg(TCGv_i64 v) return temp_arg(tcgv_i64_temp(v)); } +static inline TCGArg tcgv_i128_arg(TCGv_i128 v) +{ + return temp_arg(tcgv_i128_temp(v)); +} + static inline TCGArg tcgv_ptr_arg(TCGv_ptr v) { return temp_arg(tcgv_ptr_temp(v)); @@ -738,6 +748,11 @@ static inline TCGv_i64 temp_tcgv_i64(TCGTemp *t) return (TCGv_i64)temp_tcgv_i32(t); } +static inline TCGv_i128 temp_tcgv_i128(TCGTemp *t) +{ + return (TCGv_i128)temp_tcgv_i32(t); +} + static inline TCGv_ptr temp_tcgv_ptr(TCGTemp *t) { return (TCGv_ptr)temp_tcgv_i32(t); @@ -860,6 +875,11 @@ static inline void tcg_temp_free_i64(TCGv_i64 arg) tcg_temp_free_internal(tcgv_i64_temp(arg)); } +static inline void tcg_temp_free_i128(TCGv_i128 arg) +{ + tcg_temp_free_internal(tcgv_i128_temp(arg)); +} + static inline void tcg_temp_free_ptr(TCGv_ptr arg) { tcg_temp_free_internal(tcgv_ptr_temp(arg)); @@ -908,6 +928,18 @@ static inline TCGv_i64 tcg_temp_local_new_i64(void) return temp_tcgv_i64(t); } +static inline TCGv_i128 tcg_temp_new_i128(void) +{ + TCGTemp *t = tcg_temp_new_internal(TCG_TYPE_I128, false); + return temp_tcgv_i128(t); +} + +static inline TCGv_i128 tcg_temp_local_new_i128(void) +{ + TCGTemp *t = tcg_temp_new_internal(TCG_TYPE_I128, true); + return temp_tcgv_i128(t); +} + static inline TCGv_ptr tcg_global_mem_new_ptr(TCGv_ptr reg, intptr_t offset, const char *name) { diff --git a/tcg/tcg.c b/tcg/tcg.c index 5465297495..50db393594 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1232,26 +1232,45 @@ TCGTemp *tcg_temp_new_internal(TCGType type, bool temp_local) tcg_debug_assert(ts->base_type == type); tcg_debug_assert(ts->kind == kind); } else { + int i, n; + + switch (type) { + case TCG_TYPE_I32: + case TCG_TYPE_V64: + case TCG_TYPE_V128: + case TCG_TYPE_V256: + n = 1; + break; + case TCG_TYPE_I64: + n = 64 / TCG_TARGET_REG_BITS; + break; + case TCG_TYPE_I128: + n = 128 / TCG_TARGET_REG_BITS; + break; + default: + g_assert_not_reached(); + } + ts = tcg_temp_alloc(s); - if (TCG_TARGET_REG_BITS == 32 && type == TCG_TYPE_I64) { - TCGTemp *ts2 = tcg_temp_alloc(s); + ts->base_type = type; + ts->temp_allocated = 1; + ts->kind = kind; - ts->base_type = type; - ts->type = TCG_TYPE_I32; - ts->temp_allocated = 1; - ts->kind = kind; - - tcg_debug_assert(ts2 == ts + 1); - ts2->base_type = TCG_TYPE_I64; - ts2->type = TCG_TYPE_I32; - ts2->temp_allocated = 1; - ts2->temp_subindex = 1; - ts2->kind = kind; - } else { - ts->base_type = type; + if (n == 1) { ts->type = type; - ts->temp_allocated = 1; - ts->kind = kind; + } else { + ts->type = TCG_TYPE_REG; + + for (i = 1; i < n; ++i) { + TCGTemp *ts2 = tcg_temp_alloc(s); + + tcg_debug_assert(ts2 == ts + i); + ts2->base_type = type; + ts2->type = TCG_TYPE_REG; + ts2->temp_allocated = 1; + ts2->temp_subindex = i; + ts2->kind = kind; + } } } @@ -3413,9 +3432,14 @@ static void temp_allocate_frame(TCGContext *s, TCGTemp *ts) case TCG_TYPE_V64: align = 8; break; + case TCG_TYPE_I128: case TCG_TYPE_V128: case TCG_TYPE_V256: - /* Note that we do not require aligned storage for V256. */ + /* + * Note that we do not require aligned storage for V256, + * and that we provide alignment for I128 to match V128, + * even if that's above what the host ABI requires. + */ align = 16; break; default: From patchwork Fri Nov 11 07:40:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623694 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp620414pvb; Thu, 10 Nov 2022 23:55:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf65f8d4HHa3atDnd71vHhOK4MaGv5FGPcucO1KagDPRyxbFd8WHoU0nlik6aeMFmM8tCWQp X-Received: by 2002:a05:6214:590c:b0:4b4:95b9:674f with SMTP id lp12-20020a056214590c00b004b495b9674fmr962085qvb.110.1668153344060; Thu, 10 Nov 2022 23:55:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668153344; cv=none; d=google.com; s=arc-20160816; b=RgN5pnJk4orAwm+HilArj8BTSgVPluJ6CAqxo/ibXtCc6AGRNohBbfSKRsSzhEeMx8 wrtbVCiYqId7AdEQIOX1W3sg7sebyynaPahERHPIWm9pAFC7MPsrS+BlwALu3hqaReTY 00qCaznNuMYsTu1pGk1FxIltxPP8OAgbL4O9VB3w9aoRIllo/jEb+XtslHx+bstpuDLc E4DVLI0BO/DfyLCezeHGOF6Rngci+M9CnBW+TpNaBOrkOZwa74rYhcJTvvo3TgA4bi1N eZoggy24bHbzZeg+pIUJA9PzuYE2HEb+R/oiU831/bjw4X3JH2OlxZfcVl3xeo+6vBvw MHBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=WRIZMZP9j9SPp1EX0fHgPhfmFfX9VpYNwtU5BnkhtFg=; b=ouIjqia1qBLWOMbrJ2lM4PfeNbIgnjWMRfMZ8Ihn6AgPPsQ+CcDFh4kYpSFiLnFAto lBK+fdTj7bijj8bRevyB8qc4RENURDekVsjsLjcCGxYqRpfUEtfpLpMUEkSpzqQYzZLk +MFbY76y2S5YqVhAUdIIhkAU4KxmavQqj+mwlAdv93MHKrIABfjnSRTIZZi8Nah1xqzZ Gabijht2Zxu6GYQ7hWXUZ3OYIJdZz2uI3xyaJr896QftBQ3aGC6mkKdht13X5Pzy5tJt qZXWhAtKniv+tGof/2vfVYeXmwjbJh+9JfkAwJeGc402owYmxeS/QVOEUGdTI1JhGH3s zN4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gk9KJFPQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n26-20020ac8675a000000b0035a70424231si688689qtp.690.2022.11.10.23.55.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:55:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gk9KJFPQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOjc-0001Ve-Ju; Fri, 11 Nov 2022 02:45:56 -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 1otOjV-0001Pe-NF for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:45:49 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOjT-00018N-Vi for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:45:49 -0500 Received: by mail-pl1-x62f.google.com with SMTP id b21so3620646plc.9 for ; Thu, 10 Nov 2022 23:45:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=WRIZMZP9j9SPp1EX0fHgPhfmFfX9VpYNwtU5BnkhtFg=; b=Gk9KJFPQEzCagr6T2N754tZLBBzWJCmqprvYfaQ49S4xlAysH4FeBEJwr+WT2xRaBn VKlPTFfgNAfk3GtS/ZXJ2Ps3e2LhRA8lIn0xIMYlEebF/a1NS4J7jPhB/aGeyceYu0gO V+zd3n8iw8g+M2MO67xYmR2EfwTh1VKEnjVob6ziSa02Ri7vyAiij37AAy7Xinvphz+v 2C48DWjBBlC2CMI6JVJLVMj1iMve862OklW3WqFfWsweew43Zyt3KEPHGQJrua4sIEfQ Fyx2nQvKb4bBjy/UE+16P+5A1oYGEV++ZzDFy8jUaKd/+VGzI1K0dGU6cMC+1vwrfTa3 0tnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WRIZMZP9j9SPp1EX0fHgPhfmFfX9VpYNwtU5BnkhtFg=; b=Cf8ANXuxTNyc/LdGqlkL6OWKxU7gcli3DGeFAl0C798v+S9cAiRw77YWMBRfk3FnWh qvq8R+7xJSGEb/gatRMN8sHwQqHj77gkzrqMswQemmPGx+2MnkTqh4uUadTC1TfDk+/X UGiUCMTXSV0gUACGAEnKUTFE3g10+k4wWj+MgUZ2DfEEQVT8YzWAHL254qO0WJq4D0hs TDIWaX4KZ2VmXdbVqlbQNEO+D1f9F941HZpzfmI43zn0VODoU7poWRdDDy+I59I22EYR fie4/YtrWaaTaDJuMye3pUy5ANhjz1aw+8HdNf34gjr5/UYgAK1qKRPnPtvFlsekO2tm bbmQ== X-Gm-Message-State: ANoB5plHbvx9xs7c344eTLzP5pTKMN+nrlf/1opWJPd/DkL3rBh/wySW Jxysr7HTWmHHGoLD0AZ8gEhzCMkrBXC5F4em X-Received: by 2002:a17:902:a60b:b0:17f:66ae:b84 with SMTP id u11-20020a170902a60b00b0017f66ae0b84mr1532090plq.32.1668152746695; Thu, 10 Nov 2022 23:45:46 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id u13-20020a170902e80d00b001869f2120a6sm983802plg.108.2022.11.10.23.45.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:45:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 42/45] tcg: Add basic data movement for TCGv_i128 Date: Fri, 11 Nov 2022 17:40:58 +1000 Message-Id: <20221111074101.2069454-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Add code generation functions for data movement between TCGv_i128 (mov) and to/from TCGv_i64 (concat, extract). Signed-off-by: Richard Henderson --- include/tcg/tcg-op.h | 4 ++++ tcg/tcg-internal.h | 13 +++++++++++++ tcg/tcg-op.c | 20 ++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h index 79b1cf786f..c4276767d1 100644 --- a/include/tcg/tcg-op.h +++ b/include/tcg/tcg-op.h @@ -712,6 +712,10 @@ void tcg_gen_extrh_i64_i32(TCGv_i32 ret, TCGv_i64 arg); void tcg_gen_extr_i64_i32(TCGv_i32 lo, TCGv_i32 hi, TCGv_i64 arg); void tcg_gen_extr32_i64(TCGv_i64 lo, TCGv_i64 hi, TCGv_i64 arg); +void tcg_gen_mov_i128(TCGv_i128 dst, TCGv_i128 src); +void tcg_gen_extr_i128_i64(TCGv_i64 lo, TCGv_i64 hi, TCGv_i128 arg); +void tcg_gen_concat_i64_i128(TCGv_i128 ret, TCGv_i64 lo, TCGv_i64 hi); + static inline void tcg_gen_concat32_i64(TCGv_i64 ret, TCGv_i64 lo, TCGv_i64 hi) { tcg_gen_deposit_i64(ret, lo, hi, 32, 32); diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index 33f1d8b411..e542a4e9b7 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -117,4 +117,17 @@ extern TCGv_i32 TCGV_LOW(TCGv_i64) QEMU_ERROR("32-bit code path is reachable"); extern TCGv_i32 TCGV_HIGH(TCGv_i64) QEMU_ERROR("32-bit code path is reachable"); #endif +static inline TCGv_i64 TCGV128_LOW(TCGv_i128 t) +{ + /* For 32-bit, offset by 2, which may then have TCGV_{LOW,HIGH} applied. */ + int o = HOST_BIG_ENDIAN ? 64 / TCG_TARGET_REG_BITS : 0; + return temp_tcgv_i64(tcgv_i128_temp(t) + o); +} + +static inline TCGv_i64 TCGV128_HIGH(TCGv_i128 t) +{ + int o = HOST_BIG_ENDIAN ? 0 : 64 / TCG_TARGET_REG_BITS; + return temp_tcgv_i64(tcgv_i128_temp(t) + o); +} + #endif /* TCG_INTERNAL_H */ diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index cd1cd4e736..658cee7d6c 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2745,6 +2745,26 @@ void tcg_gen_extr32_i64(TCGv_i64 lo, TCGv_i64 hi, TCGv_i64 arg) tcg_gen_shri_i64(hi, arg, 32); } +void tcg_gen_extr_i128_i64(TCGv_i64 lo, TCGv_i64 hi, TCGv_i128 arg) +{ + tcg_gen_mov_i64(lo, TCGV128_LOW(arg)); + tcg_gen_mov_i64(hi, TCGV128_HIGH(arg)); +} + +void tcg_gen_concat_i64_i128(TCGv_i128 ret, TCGv_i64 lo, TCGv_i64 hi) +{ + tcg_gen_mov_i64(TCGV128_LOW(ret), lo); + tcg_gen_mov_i64(TCGV128_HIGH(ret), hi); +} + +void tcg_gen_mov_i128(TCGv_i128 dst, TCGv_i128 src) +{ + if (dst != src) { + tcg_gen_mov_i64(TCGV128_LOW(dst), TCGV128_LOW(src)); + tcg_gen_mov_i64(TCGV128_HIGH(dst), TCGV128_HIGH(src)); + } +} + /* QEMU specific operations. */ void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx) From patchwork Fri Nov 11 07:40:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623713 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp631492pvb; Fri, 11 Nov 2022 00:22:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf7uFF6qG46Fyu7Qqju6hIcgBtu2HjHnQFKuQupxWntdY7Su3FieGQhsgTSksh6Eo5h8iDXx X-Received: by 2002:ad4:58f3:0:b0:4bb:e056:b148 with SMTP id di19-20020ad458f3000000b004bbe056b148mr1052609qvb.87.1668154935095; Fri, 11 Nov 2022 00:22:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668154935; cv=none; d=google.com; s=arc-20160816; b=JjHorYtRR8Eocz2CO/6S//gpCnKvYcRRil/kB+xfTEU10GfAkomKvGVjr6MiW+wQLM SkepjAa4/QWd2X70oN5qSQuTUcO7nyQYw/aCzwjKk4X/ABURGqXIEpLh8OCT/w8iCNWQ Op7rLp+B8HLN2QQF2UcadidMcDDfqcIFB/WYfbJIYho4x98EH0ubNsXSfKKDyiWZX7di j/mStSdm9RHd73wl9M5jnznC6cWFK8u230S+jJqfqO+F6VCvTuXeGzizBLxXzh7snNUY wuUXwSTMubG2CTCwG2VRK83Ox+84oJsxlfNq71JT2bUN4Z952nMDJHPjypdVQ8RK+k7F 1a1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=E3EDmZssKDAomqvf3LSFkv7aqgJxt2osQBuACWOJwMs=; b=ArkgCd7fv17KZ3iATCX6GLJP36quUIVC8CNDeKVZvY6DQlonGxgwfLIQVQ0bdxOEyl onuku/skuU3lGagKXaWZhw7BIpemchCIU5E6RmQcFW7iZZnYpalJf3ErSZ0z4h5IgIHA vMt1geTRfIwl8A86v2d6gKdDb+DiYk+6EZyLvpJ/9j68toCKVAYgQtHrS9ZILRK/PhBV u/vdJxwZEi/jQOUER6rvnuGxzOs74Fp+55n2X8eoRVp4N+w8S9ylL3M6Zkx6rOKwQT2j /FrsrnPwIwJRN1jpkJ3ak/bDo6wixYZcGt78Emb+2JWlOnUHbRso2FJdq8DVUlnA8+xn g0CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JlprR2S4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id cd6-20020a05622a418600b003a582dc8cc3si696102qtb.545.2022.11.11.00.22.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:22:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JlprR2S4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOje-0001Wt-56; Fri, 11 Nov 2022 02:45:58 -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 1otOjY-0001S9-Ns for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:45:55 -0500 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOjW-00018g-9K for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:45:52 -0500 Received: by mail-pf1-x429.google.com with SMTP id q9so4243469pfg.5 for ; Thu, 10 Nov 2022 23:45:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=E3EDmZssKDAomqvf3LSFkv7aqgJxt2osQBuACWOJwMs=; b=JlprR2S4YecmLU7u3DOaYIM/w2YTLQTMZPprFDx26bDaK/gDUy9l19VFREUcvmgIfE /kX8osmfNx5ZMFuAHqT9VIsrVnvS0RjDFWmDOIB85NQx97ECXGaBOhdxsP+mi33pxOHP +D7132opRMp6PBjcaN6S8e88wG8zl4PU2f23s4V++4qP6cjBAYHPheMNp2sa7urBcC3M LWkSw6OflKypvAdi97J7mHasss/Fz7LQelKsfQTJzKDtoyiIMbuSU7BmcQFcyQTxkanC /ZCaJzidzVk5nN+bs82gcJzCuvfutVkHZGdvDKgx64lXhvaGG5ejPbiIYNAhBga24wmL AVlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E3EDmZssKDAomqvf3LSFkv7aqgJxt2osQBuACWOJwMs=; b=S7Xa/wp9cbb8z/JZFl3zkLn12tkQMSM5qoRLMEUeT+0XDYCrvdzvagwUKKJNdrPwmA hTWgXtQlK9J4LEKySgeAsOJ9rts9+qpkLKebxaXUjVSCkMs2ORnl7M9d/apmlPDrQbmG Ta76nBx1sfOz07G2egmx0kuqnU+NktH1S1uQFozt7FT8fbKiL4VM1D0Mz1hFXVdTn++t B/3NjwIQqQ1CpZ00fpe3Y894oVLaxqgF/qClqcUeQjk/GnupDkOkM7mKbGuKGVSqVlP+ xDEfZbRk/kxd7k+AY7e9xIHF7+9X8LoRQ6AHbxO/Yh5DzEnU9ejgs9j00YF69M+XXQeg PQww== X-Gm-Message-State: ANoB5pl+EdU1wncYL0Cv/Tx2lqiEMrgD5H05fPGBbqmjY1NVRKGK0zdR 3GvZ9Go/ldgtmamZZ1x0cCGq/JrRKP0/Ndy1 X-Received: by 2002:a62:1a06:0:b0:56d:570a:ef1c with SMTP id a6-20020a621a06000000b0056d570aef1cmr1505047pfa.22.1668152748732; Thu, 10 Nov 2022 23:45:48 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id u13-20020a170902e80d00b001869f2120a6sm983802plg.108.2022.11.10.23.45.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:45:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 43/45] tcg: Add guest load/store primitives for TCGv_i128 Date: Fri, 11 Nov 2022 17:40:59 +1000 Message-Id: <20221111074101.2069454-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These are not yet considering atomicity of the 16-byte value; this is a direct replacement for the current target code which uses a pair of 8-byte operations. Signed-off-by: Richard Henderson --- include/exec/cpu_ldst.h | 10 +++ include/tcg/tcg-op.h | 2 + accel/tcg/cputlb.c | 112 +++++++++++++++++++++++++++++++++ accel/tcg/user-exec.c | 66 ++++++++++++++++++++ tcg/tcg-op.c | 134 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 324 insertions(+) diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index d0c7c0d5fe..09b55cc0ee 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -220,6 +220,11 @@ uint32_t cpu_ldl_le_mmu(CPUArchState *env, abi_ptr ptr, uint64_t cpu_ldq_le_mmu(CPUArchState *env, abi_ptr ptr, MemOpIdx oi, uintptr_t ra); +Int128 cpu_ld16_be_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t ra); +Int128 cpu_ld16_le_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t ra); + void cpu_stb_mmu(CPUArchState *env, abi_ptr ptr, uint8_t val, MemOpIdx oi, uintptr_t ra); void cpu_stw_be_mmu(CPUArchState *env, abi_ptr ptr, uint16_t val, @@ -235,6 +240,11 @@ void cpu_stl_le_mmu(CPUArchState *env, abi_ptr ptr, uint32_t val, void cpu_stq_le_mmu(CPUArchState *env, abi_ptr ptr, uint64_t val, MemOpIdx oi, uintptr_t ra); +void cpu_st16_be_mmu(CPUArchState *env, abi_ptr addr, Int128 val, + MemOpIdx oi, uintptr_t ra); +void cpu_st16_le_mmu(CPUArchState *env, abi_ptr addr, Int128 val, + MemOpIdx oi, uintptr_t ra); + uint32_t cpu_atomic_cmpxchgb_mmu(CPUArchState *env, target_ulong addr, uint32_t cmpv, uint32_t newv, MemOpIdx oi, uintptr_t retaddr); diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h index c4276767d1..e5f5b63c37 100644 --- a/include/tcg/tcg-op.h +++ b/include/tcg/tcg-op.h @@ -845,6 +845,8 @@ void tcg_gen_qemu_ld_i32(TCGv_i32, TCGv, TCGArg, MemOp); void tcg_gen_qemu_st_i32(TCGv_i32, TCGv, TCGArg, MemOp); void tcg_gen_qemu_ld_i64(TCGv_i64, TCGv, TCGArg, MemOp); void tcg_gen_qemu_st_i64(TCGv_i64, TCGv, TCGArg, MemOp); +void tcg_gen_qemu_ld_i128(TCGv_i128, TCGv, TCGArg, MemOp); +void tcg_gen_qemu_st_i128(TCGv_i128, TCGv, TCGArg, MemOp); static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index) { diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 6f1c00682b..f7d510f68d 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -2199,6 +2199,64 @@ uint64_t cpu_ldq_le_mmu(CPUArchState *env, abi_ptr addr, return cpu_load_helper(env, addr, oi, ra, helper_le_ldq_mmu); } +Int128 cpu_ld16_be_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t ra) +{ + MemOp mop = get_memop(oi); + int mmu_idx = get_mmuidx(oi); + MemOpIdx new_oi; + unsigned a_bits; + uint64_t h, l; + + tcg_debug_assert((mop & (MO_BSWAP|MO_SSIZE)) == (MO_BE|MO_128)); + a_bits = get_alignment_bits(mop); + + /* Handle CPU specific unaligned behaviour */ + if (addr & ((1 << a_bits) - 1)) { + cpu_unaligned_access(env_cpu(env), addr, MMU_DATA_LOAD, + mmu_idx, ra); + } + + /* Construct an unaligned 64-bit replacement MemOpIdx. */ + mop = (mop & ~(MO_SIZE | MO_AMASK)) | MO_64 | MO_UNALN; + new_oi = make_memop_idx(mop, mmu_idx); + + h = helper_be_ldq_mmu(env, addr, new_oi, ra); + l = helper_be_ldq_mmu(env, addr + 8, new_oi, ra); + + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_R); + return int128_make128(l, h); +} + +Int128 cpu_ld16_le_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t ra) +{ + MemOp mop = get_memop(oi); + int mmu_idx = get_mmuidx(oi); + MemOpIdx new_oi; + unsigned a_bits; + uint64_t h, l; + + tcg_debug_assert((mop & (MO_BSWAP|MO_SSIZE)) == (MO_LE|MO_128)); + a_bits = get_alignment_bits(mop); + + /* Handle CPU specific unaligned behaviour */ + if (addr & ((1 << a_bits) - 1)) { + cpu_unaligned_access(env_cpu(env), addr, MMU_DATA_LOAD, + mmu_idx, ra); + } + + /* Construct an unaligned 64-bit replacement MemOpIdx. */ + mop = (mop & ~(MO_SIZE | MO_AMASK)) | MO_64 | MO_UNALN; + new_oi = make_memop_idx(mop, mmu_idx); + + l = helper_le_ldq_mmu(env, addr, new_oi, ra); + h = helper_le_ldq_mmu(env, addr + 8, new_oi, ra); + + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_R); + return int128_make128(l, h); +} + /* * Store Helpers */ @@ -2553,6 +2611,60 @@ void cpu_stq_le_mmu(CPUArchState *env, target_ulong addr, uint64_t val, cpu_store_helper(env, addr, val, oi, retaddr, helper_le_stq_mmu); } +void cpu_st16_be_mmu(CPUArchState *env, abi_ptr addr, Int128 val, + MemOpIdx oi, uintptr_t ra) +{ + MemOp mop = get_memop(oi); + int mmu_idx = get_mmuidx(oi); + MemOpIdx new_oi; + unsigned a_bits; + + tcg_debug_assert((mop & (MO_BSWAP|MO_SSIZE)) == (MO_BE|MO_128)); + a_bits = get_alignment_bits(mop); + + /* Handle CPU specific unaligned behaviour */ + if (addr & ((1 << a_bits) - 1)) { + cpu_unaligned_access(env_cpu(env), addr, MMU_DATA_STORE, + mmu_idx, ra); + } + + /* Construct an unaligned 64-bit replacement MemOpIdx. */ + mop = (mop & ~(MO_SIZE | MO_AMASK)) | MO_64 | MO_UNALN; + new_oi = make_memop_idx(mop, mmu_idx); + + helper_be_stq_mmu(env, addr, int128_gethi(val), new_oi, ra); + helper_be_stq_mmu(env, addr + 8, int128_getlo(val), new_oi, ra); + + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_W); +} + +void cpu_st16_le_mmu(CPUArchState *env, abi_ptr addr, Int128 val, + MemOpIdx oi, uintptr_t ra) +{ + MemOp mop = get_memop(oi); + int mmu_idx = get_mmuidx(oi); + MemOpIdx new_oi; + unsigned a_bits; + + tcg_debug_assert((mop & (MO_BSWAP|MO_SSIZE)) == (MO_LE|MO_128)); + a_bits = get_alignment_bits(mop); + + /* Handle CPU specific unaligned behaviour */ + if (addr & ((1 << a_bits) - 1)) { + cpu_unaligned_access(env_cpu(env), addr, MMU_DATA_STORE, + mmu_idx, ra); + } + + /* Construct an unaligned 64-bit replacement MemOpIdx. */ + mop = (mop & ~(MO_SIZE | MO_AMASK)) | MO_64 | MO_UNALN; + new_oi = make_memop_idx(mop, mmu_idx); + + helper_be_stq_mmu(env, addr, int128_getlo(val), new_oi, ra); + helper_be_stq_mmu(env, addr + 8, int128_gethi(val), new_oi, ra); + + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_W); +} + #include "ldst_common.c.inc" /* diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index fb7d6ee9e9..a52c7ef826 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -394,6 +394,42 @@ uint64_t cpu_ldq_le_mmu(CPUArchState *env, abi_ptr addr, return ret; } +Int128 cpu_ld16_be_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t ra) +{ + void *haddr; + Int128 ret; + + validate_memop(oi, MO_128 | MO_BE); + haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_LOAD); + memcpy(&ret, haddr, 16); + clear_helper_retaddr(); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_R); + + if (!HOST_BIG_ENDIAN) { + ret = bswap128(ret); + } + return ret; +} + +Int128 cpu_ld16_le_mmu(CPUArchState *env, abi_ptr addr, + MemOpIdx oi, uintptr_t ra) +{ + void *haddr; + Int128 ret; + + validate_memop(oi, MO_128 | MO_LE); + haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_LOAD); + memcpy(&ret, haddr, 16); + clear_helper_retaddr(); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_R); + + if (HOST_BIG_ENDIAN) { + ret = bswap128(ret); + } + return ret; +} + void cpu_stb_mmu(CPUArchState *env, abi_ptr addr, uint8_t val, MemOpIdx oi, uintptr_t ra) { @@ -478,6 +514,36 @@ void cpu_stq_le_mmu(CPUArchState *env, abi_ptr addr, uint64_t val, qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_W); } +void cpu_st16_be_mmu(CPUArchState *env, abi_ptr addr, + Int128 val, MemOpIdx oi, uintptr_t ra) +{ + void *haddr; + + validate_memop(oi, MO_128 | MO_BE); + haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_STORE); + if (!HOST_BIG_ENDIAN) { + val = bswap128(val); + } + memcpy(haddr, &val, 16); + clear_helper_retaddr(); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_W); +} + +void cpu_st16_le_mmu(CPUArchState *env, abi_ptr addr, + Int128 val, MemOpIdx oi, uintptr_t ra) +{ + void *haddr; + + validate_memop(oi, MO_128 | MO_LE); + haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_STORE); + if (HOST_BIG_ENDIAN) { + val = bswap128(val); + } + memcpy(haddr, &val, 16); + clear_helper_retaddr(); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_W); +} + uint32_t cpu_ldub_code(CPUArchState *env, abi_ptr ptr) { uint32_t ret; diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 658cee7d6c..55ecedb66f 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -3107,6 +3107,140 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) } } +static void canonicalize_memop_i128_as_i64(MemOp ret[2], MemOp orig) +{ + MemOp mop_1 = orig, mop_2; + + tcg_debug_assert((orig & MO_SIZE) == MO_128); + tcg_debug_assert((orig & MO_SIGN) == 0); + + /* Use a memory ordering implemented by the host. */ + if (!TCG_TARGET_HAS_MEMORY_BSWAP && (orig & MO_BSWAP)) { + mop_1 &= ~MO_BSWAP; + } + + /* Reduce the size to 64-bit. */ + mop_1 = (mop_1 & ~MO_SIZE) | MO_64; + + /* Retain the alignment constraints of the original. */ + switch (orig & MO_AMASK) { + case MO_UNALN: + case MO_ALIGN_2: + case MO_ALIGN_4: + mop_2 = mop_1; + break; + case MO_ALIGN_8: + /* Prefer MO_ALIGN+MO_64 to MO_ALIGN_8+MO_64. */ + mop_1 = (mop_1 & ~MO_AMASK) | MO_ALIGN; + mop_2 = mop_1; + break; + case MO_ALIGN: + /* Second has 8-byte alignment; first has 16-byte alignment. */ + mop_2 = mop_1; + mop_1 = (mop_1 & ~MO_AMASK) | MO_ALIGN_16; + break; + case MO_ALIGN_16: + case MO_ALIGN_32: + case MO_ALIGN_64: + /* Second has 8-byte alignment; first retains original. */ + mop_2 = (mop_1 & ~MO_AMASK) | MO_ALIGN; + break; + default: + g_assert_not_reached(); + } + ret[0] = mop_1; + ret[1] = mop_2; +} + +void tcg_gen_qemu_ld_i128(TCGv_i128 val, TCGv addr, TCGArg idx, MemOp memop) +{ + MemOp mop[2]; + TCGv addr_p8; + TCGv_i64 x, y; + + canonicalize_memop_i128_as_i64(mop, memop); + + tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); + addr = plugin_prep_mem_callbacks(addr); + + /* TODO: respect atomicity of the operation. */ + /* TODO: allow the tcg backend to see the whole operation. */ + + /* + * Since there are no global TCGv_i128, there is no visible state + * changed if the second load faults. Load directly into the two + * subwords. + */ + if ((memop & MO_BSWAP) == MO_LE) { + x = TCGV128_LOW(val); + y = TCGV128_HIGH(val); + } else { + x = TCGV128_HIGH(val); + y = TCGV128_LOW(val); + } + + gen_ldst_i64(INDEX_op_qemu_ld_i64, x, addr, mop[0], idx); + + if ((mop[0] ^ memop) & MO_BSWAP) { + tcg_gen_bswap64_i64(x, x); + } + + addr_p8 = tcg_temp_new(); + tcg_gen_addi_tl(addr_p8, addr, 8); + gen_ldst_i64(INDEX_op_qemu_ld_i64, y, addr_p8, mop[1], idx); + tcg_temp_free(addr_p8); + + if ((mop[0] ^ memop) & MO_BSWAP) { + tcg_gen_bswap64_i64(y, y); + } + + plugin_gen_mem_callbacks(addr, make_memop_idx(memop, idx), + QEMU_PLUGIN_MEM_R); +} + +void tcg_gen_qemu_st_i128(TCGv_i128 val, TCGv addr, TCGArg idx, MemOp memop) +{ + MemOp mop[2]; + TCGv addr_p8; + TCGv_i64 x, y; + + canonicalize_memop_i128_as_i64(mop, memop); + + tcg_gen_req_mo(TCG_MO_ST_LD | TCG_MO_ST_ST); + addr = plugin_prep_mem_callbacks(addr); + + /* TODO: respect atomicity of the operation. */ + /* TODO: allow the tcg backend to see the whole operation. */ + + if ((memop & MO_BSWAP) == MO_LE) { + x = TCGV128_LOW(val); + y = TCGV128_HIGH(val); + } else { + x = TCGV128_HIGH(val); + y = TCGV128_LOW(val); + } + + addr_p8 = tcg_temp_new(); + if ((mop[0] ^ memop) & MO_BSWAP) { + TCGv_i64 t = tcg_temp_new_i64(); + + tcg_gen_bswap64_i64(t, x); + gen_ldst_i64(INDEX_op_qemu_st_i64, t, addr, mop[0], idx); + tcg_gen_bswap64_i64(t, y); + tcg_gen_addi_tl(addr_p8, addr, 8); + gen_ldst_i64(INDEX_op_qemu_st_i64, t, addr_p8, mop[1], idx); + tcg_temp_free_i64(t); + } else { + gen_ldst_i64(INDEX_op_qemu_st_i64, x, addr, mop[0], idx); + tcg_gen_addi_tl(addr_p8, addr, 8); + gen_ldst_i64(INDEX_op_qemu_st_i64, y, addr_p8, mop[1], idx); + } + tcg_temp_free(addr_p8); + + plugin_gen_mem_callbacks(addr, make_memop_idx(memop, idx), + QEMU_PLUGIN_MEM_W); +} + static void tcg_gen_ext_i32(TCGv_i32 ret, TCGv_i32 val, MemOp opc) { switch (opc & MO_SSIZE) { From patchwork Fri Nov 11 07:41:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623695 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp621070pvb; Thu, 10 Nov 2022 23:57:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf5tJzmjKlRrlUY8QSrLtrR7oiNoGescQMgADFHeymSuj2oZUOndgwGdthehSlMoxEXAGSoD X-Received: by 2002:a37:b2c6:0:b0:6fa:15e3:2fac with SMTP id b189-20020a37b2c6000000b006fa15e32facmr220583qkf.116.1668153438430; Thu, 10 Nov 2022 23:57:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668153438; cv=none; d=google.com; s=arc-20160816; b=gHk+lEgFbNWwSNSyGGTYAoE7gl6QArGPvG1uhUxmoIJUOrjY94oCsZ/C3wij5Kci0a m1dIVfR+Grhqf+buAZr4HaXR37nXFnxHMs3CfwP7x/ds+cGvQGogHjfUuvRVUAZ8Bb2J Hoh7p1zfeHfWnAUokRCW4sWB5v4JHApxGtxVTHfo7zDKCHT+YuVBxk88K7x6KJcEsZnK MvUevLWyxmJI6tBCBYWGUmygmnPAXLVrvy4x9RDuQYSiSyiVBeo69mZIrA46uFkKHp7X FZBQ2dA+jRVRGHasLZobmiv0HKrR302rvtZ3tjfeVpL68Zz2ygj+eYMBFlsmNcmjqQ0Q uvog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=tmU0MjgiKsSxPUHRGzRVInhdiWEFNbDXapXPwryhCsg=; b=hm40XsFW+xKXJOUC+CrrkQRAo2tFBeSdKGMep2NkHWKBk2/SKyWmUuhZQuXgRUHqOP xAf8RX6+xhhNRoZIM+di4vBpEwt+DwlaRkcYb62BciZVVk0YDB8C0mtLOOp9y5xL+3PB 9d2K+2woSxKsGAw+sRhx2Zk2AtvNhyLFpPrpn+xyb1HReKHI8xYh/c2LYA+9OKBIX2qX opc3xeUlE9MiY3pTU6YuLwuiUl/QuPF2fNFYdB7JRd2fftYLjlPxaaBZA/NL+9a228nD 9oJrsjqwmDpl+KRA1yyOsBt2nvVhs0YUf/AWRhG4L8/X7iPNjqh2LNuKBmwDipB6UANR T5cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yaUQEB0g; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r7-20020ac867c7000000b003a4f6a57a30si682922qtp.461.2022.11.10.23.57.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 23:57:18 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yaUQEB0g; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOjf-0001YA-3A; Fri, 11 Nov 2022 02:45:59 -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 1otOjc-0001Vx-MW for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:45:56 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOjY-00018y-Gd for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:45:56 -0500 Received: by mail-pl1-x629.google.com with SMTP id p21so3630152plr.7 for ; Thu, 10 Nov 2022 23:45:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=tmU0MjgiKsSxPUHRGzRVInhdiWEFNbDXapXPwryhCsg=; b=yaUQEB0gq46RYQK0mf39X6Aq2Hv+bnqOc5M1Vs625hvQkVHae8evPMPA5c4Yzr51Ew uQTRW0+CnqdZ7UuKEDXpymHgppESt5IYW8yMZLji0Z7b0MmGXZrAlfNXvl4V5llBDeUK It9fHrjtNyrcoUIo/r8JdPG7XqSJmWEECi3zAn+ElEK9FjIIrnLEHAfwV6B1RYJbf16I JJMolrZJAaDQs/IuZY7tSWwvsC/WLeiaqC0VE3+acGhuuiBfmUfr+K9odYDToPDwZbrH rhYEmMCyif+QIi14qKzOqNg2pm7uPFerl8AVaH98aGsGsg3k+QBLr6/H20hrr2sk6pKy CZjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tmU0MjgiKsSxPUHRGzRVInhdiWEFNbDXapXPwryhCsg=; b=yTFlnJFjHGOTAtFlbuCFVPiOYbt7TRQ1MJ7d4narsOplUARBb9QjNmbtVWZSv5gLAf RxKXIlc8ofGdiJEY7rkVvpEC5PL0yQi1P5q9nQQQsJO1L27jLw2kZHW8qWjkG20qVgcV DVFiCQ0dENf60iIEll+1zWKP+pCWYqDjR8b8jLh/kxvTXOzZXSJ7gLJX+iPUkIA5fuhS FGrF/KdV+lBJAo42JxjsqyJOaF6wTD4uGKibBxedBN1paD4+KywKXPoeCOcq9mWTDu5D PblkPOTBDwJTXLaZj9PFnvNPOVVN13DreWHUFknpMAKFG9lgjCUj+K26+4wFH4SzUYUk E7xw== X-Gm-Message-State: ANoB5pnh/v7M+J41y4Kywe14ok8qNg/0oY6pSLlPG4ihyPcGSTUD4kR3 WfBCKsUjWElqYgaftQhjg9VCqc5k5fjTHuTZ X-Received: by 2002:a17:902:6ac6:b0:188:62b9:a6ef with SMTP id i6-20020a1709026ac600b0018862b9a6efmr1490594plt.4.1668152751110; Thu, 10 Nov 2022 23:45:51 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id u13-20020a170902e80d00b001869f2120a6sm983802plg.108.2022.11.10.23.45.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:45:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 44/45] tcg: Add tcg_gen_{non}atomic_cmpxchg_i128 Date: Fri, 11 Nov 2022 17:41:00 +1000 Message-Id: <20221111074101.2069454-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This will allow targets to avoid rolling their own. Signed-off-by: Richard Henderson --- accel/tcg/tcg-runtime.h | 11 +++++ include/tcg/tcg-op.h | 5 +++ tcg/tcg-op.c | 85 +++++++++++++++++++++++++++++++++++ accel/tcg/atomic_common.c.inc | 45 +++++++++++++++++++ 4 files changed, 146 insertions(+) diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h index 37cbd722bf..e141a6ab24 100644 --- a/accel/tcg/tcg-runtime.h +++ b/accel/tcg/tcg-runtime.h @@ -55,6 +55,17 @@ DEF_HELPER_FLAGS_5(atomic_cmpxchgq_be, TCG_CALL_NO_WG, DEF_HELPER_FLAGS_5(atomic_cmpxchgq_le, TCG_CALL_NO_WG, i64, env, tl, i64, i64, i32) #endif +#ifdef CONFIG_CMPXCHG128 +DEF_HELPER_FLAGS_5(atomic_cmpxchgo_be, TCG_CALL_NO_WG, + i128, env, tl, i128, i128, i32) +DEF_HELPER_FLAGS_5(atomic_cmpxchgo_le, TCG_CALL_NO_WG, + i128, env, tl, i128, i128, i32) +#endif + +DEF_HELPER_FLAGS_5(nonatomic_cmpxchgo_be, TCG_CALL_NO_WG, + i128, env, tl, i128, i128, i32) +DEF_HELPER_FLAGS_5(nonatomic_cmpxchgo_le, TCG_CALL_NO_WG, + i128, env, tl, i128, i128, i32) #ifdef CONFIG_ATOMIC64 #define GEN_ATOMIC_HELPERS(NAME) \ diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h index e5f5b63c37..31bf3d287e 100644 --- a/include/tcg/tcg-op.h +++ b/include/tcg/tcg-op.h @@ -907,6 +907,11 @@ void tcg_gen_atomic_cmpxchg_i32(TCGv_i32, TCGv, TCGv_i32, TCGv_i32, TCGArg, MemOp); void tcg_gen_atomic_cmpxchg_i64(TCGv_i64, TCGv, TCGv_i64, TCGv_i64, TCGArg, MemOp); +void tcg_gen_atomic_cmpxchg_i128(TCGv_i128, TCGv, TCGv_i128, TCGv_i128, + TCGArg, MemOp); + +void tcg_gen_nonatomic_cmpxchg_i128(TCGv_i128, TCGv, TCGv_i128, TCGv_i128, + TCGArg, MemOp); void tcg_gen_atomic_xchg_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, MemOp); void tcg_gen_atomic_xchg_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, MemOp); diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 55ecedb66f..66f9c894ad 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -3293,6 +3293,8 @@ typedef void (*gen_atomic_cx_i32)(TCGv_i32, TCGv_env, TCGv, TCGv_i32, TCGv_i32, TCGv_i32); typedef void (*gen_atomic_cx_i64)(TCGv_i64, TCGv_env, TCGv, TCGv_i64, TCGv_i64, TCGv_i32); +typedef void (*gen_atomic_cx_i128)(TCGv_i128, TCGv_env, TCGv, + TCGv_i128, TCGv_i128, TCGv_i32); typedef void (*gen_atomic_op_i32)(TCGv_i32, TCGv_env, TCGv, TCGv_i32, TCGv_i32); typedef void (*gen_atomic_op_i64)(TCGv_i64, TCGv_env, TCGv, @@ -3303,6 +3305,11 @@ typedef void (*gen_atomic_op_i64)(TCGv_i64, TCGv_env, TCGv, #else # define WITH_ATOMIC64(X) #endif +#ifdef CONFIG_CMPXCHG128 +# define WITH_ATOMIC128(X) X, +#else +# define WITH_ATOMIC128(X) +#endif static void * const table_cmpxchg[(MO_SIZE | MO_BSWAP) + 1] = { [MO_8] = gen_helper_atomic_cmpxchgb, @@ -3312,6 +3319,8 @@ static void * const table_cmpxchg[(MO_SIZE | MO_BSWAP) + 1] = { [MO_32 | MO_BE] = gen_helper_atomic_cmpxchgl_be, WITH_ATOMIC64([MO_64 | MO_LE] = gen_helper_atomic_cmpxchgq_le) WITH_ATOMIC64([MO_64 | MO_BE] = gen_helper_atomic_cmpxchgq_be) + WITH_ATOMIC128([MO_128 | MO_LE] = gen_helper_atomic_cmpxchgo_le) + WITH_ATOMIC128([MO_128 | MO_BE] = gen_helper_atomic_cmpxchgo_be) }; void tcg_gen_atomic_cmpxchg_i32(TCGv_i32 retv, TCGv addr, TCGv_i32 cmpv, @@ -3410,6 +3419,82 @@ void tcg_gen_atomic_cmpxchg_i64(TCGv_i64 retv, TCGv addr, TCGv_i64 cmpv, } } +void tcg_gen_nonatomic_cmpxchg_i128(TCGv_i128 retv, TCGv addr, TCGv_i128 cmpv, + TCGv_i128 newv, TCGArg idx, MemOp memop) +{ + if (TCG_TARGET_REG_BITS == 32) { + /* Inline expansion below is simply too large for 32-bit hosts. */ + gen_atomic_cx_i128 gen = ((memop & MO_BSWAP) == MO_LE + ? gen_helper_nonatomic_cmpxchgo_le + : gen_helper_nonatomic_cmpxchgo_be); + MemOpIdx oi = make_memop_idx(memop, idx); + + tcg_debug_assert((memop & MO_SIZE) == MO_128); + tcg_debug_assert((memop & MO_SIGN) == 0); + + gen(retv, cpu_env, addr, cmpv, newv, tcg_constant_i32(oi)); + } else { + TCGv_i128 oldv = tcg_temp_new_i128(); + TCGv_i128 tmpv = tcg_temp_new_i128(); + TCGv_i64 t0 = tcg_temp_new_i64(); + TCGv_i64 t1 = tcg_temp_new_i64(); + TCGv_i64 z = tcg_constant_i64(0); + + tcg_gen_qemu_ld_i128(oldv, addr, idx, memop); + + /* Compare i128 */ + tcg_gen_xor_i64(t0, TCGV128_LOW(oldv), TCGV128_LOW(cmpv)); + tcg_gen_xor_i64(t1, TCGV128_HIGH(oldv), TCGV128_HIGH(cmpv)); + tcg_gen_or_i64(t0, t0, t1); + + /* tmpv = equal ? newv : oldv */ + tcg_gen_movcond_i64(TCG_COND_EQ, TCGV128_LOW(tmpv), t0, z, + TCGV128_LOW(newv), TCGV128_LOW(oldv)); + tcg_gen_movcond_i64(TCG_COND_EQ, TCGV128_HIGH(tmpv), t0, z, + TCGV128_HIGH(newv), TCGV128_HIGH(oldv)); + + /* Unconditional writeback. */ + tcg_gen_qemu_st_i128(tmpv, addr, idx, memop); + tcg_gen_mov_i128(retv, oldv); + + tcg_temp_free_i64(t0); + tcg_temp_free_i64(t1); + tcg_temp_free_i128(tmpv); + tcg_temp_free_i128(oldv); + } +} + +void tcg_gen_atomic_cmpxchg_i128(TCGv_i128 retv, TCGv addr, TCGv_i128 cmpv, + TCGv_i128 newv, TCGArg idx, MemOp memop) +{ + gen_atomic_cx_i128 gen; + + if (!(tcg_ctx->tb_cflags & CF_PARALLEL)) { + tcg_gen_nonatomic_cmpxchg_i128(retv, addr, cmpv, newv, idx, memop); + return; + } + + tcg_debug_assert((memop & MO_SIZE) == MO_128); + tcg_debug_assert((memop & MO_SIGN) == 0); + gen = table_cmpxchg[memop & (MO_SIZE | MO_BSWAP)]; + + if (gen) { + MemOpIdx oi = make_memop_idx(memop, idx); + gen(retv, cpu_env, addr, cmpv, newv, tcg_constant_i32(oi)); + return; + } + + gen_helper_exit_atomic(cpu_env); + + /* + * Produce a result for a well-formed opcode stream. This satisfies + * liveness for set before used, which happens before this dead code + * is removed. + */ + tcg_gen_movi_i64(TCGV128_LOW(retv), 0); + tcg_gen_movi_i64(TCGV128_HIGH(retv), 0); +} + static void do_nonatomic_op_i32(TCGv_i32 ret, TCGv addr, TCGv_i32 val, TCGArg idx, MemOp memop, bool new_val, void (*gen)(TCGv_i32, TCGv_i32, TCGv_i32)) diff --git a/accel/tcg/atomic_common.c.inc b/accel/tcg/atomic_common.c.inc index 6602d7689f..8f2ce43ee6 100644 --- a/accel/tcg/atomic_common.c.inc +++ b/accel/tcg/atomic_common.c.inc @@ -55,8 +55,53 @@ CMPXCHG_HELPER(cmpxchgq_be, uint64_t) CMPXCHG_HELPER(cmpxchgq_le, uint64_t) #endif +#ifdef CONFIG_CMPXCHG128 +CMPXCHG_HELPER(cmpxchgo_be, Int128) +CMPXCHG_HELPER(cmpxchgo_le, Int128) +#endif + #undef CMPXCHG_HELPER +Int128 HELPER(nonatomic_cmpxchgo_be)(CPUArchState *env, target_ulong addr, + Int128 cmpv, Int128 newv, uint32_t oi) +{ +#if TCG_TARGET_REG_BITS == 32 + uintptr_t ra = GETPC(); + Int128 oldv; + + oldv = cpu_ld16_be_mmu(env, addr, oi, ra); + if (int128_eq(oldv, cmpv)) { + cpu_st16_be_mmu(env, addr, newv, oi, ra); + } else { + /* Even with comparison failure, still need a write cycle. */ + probe_write(env, addr, 16, get_mmuidx(oi), ra); + } + return oldv; +#else + g_assert_not_reached(); +#endif +} + +Int128 HELPER(nonatomic_cmpxchgo_le)(CPUArchState *env, target_ulong addr, + Int128 cmpv, Int128 newv, uint32_t oi) +{ +#if TCG_TARGET_REG_BITS == 32 + uintptr_t ra = GETPC(); + Int128 oldv; + + oldv = cpu_ld16_le_mmu(env, addr, oi, ra); + if (int128_eq(oldv, cmpv)) { + cpu_st16_le_mmu(env, addr, newv, oi, ra); + } else { + /* Even with comparison failure, still need a write cycle. */ + probe_write(env, addr, 16, get_mmuidx(oi), ra); + } + return oldv; +#else + g_assert_not_reached(); +#endif +} + #define ATOMIC_HELPER(OP, TYPE) \ TYPE HELPER(glue(atomic_,OP))(CPUArchState *env, target_ulong addr, \ TYPE val, uint32_t oi) \ From patchwork Fri Nov 11 07:41:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 623716 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp632261pvb; Fri, 11 Nov 2022 00:24:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf4u2/P6+TULXREjq4JP56Rhyj8hTkvZf05j6bzE+0YyIiBnomkeSIYkU1WHKpMK/gYvBmwm X-Received: by 2002:ae9:ee05:0:b0:6fa:121:42f7 with SMTP id i5-20020ae9ee05000000b006fa012142f7mr256623qkg.283.1668155053562; Fri, 11 Nov 2022 00:24:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668155053; cv=none; d=google.com; s=arc-20160816; b=deUmx6ytMB4dBFt6LHDgZ3nFHrlvD6DhiSZt9zGdolO8xpRKiPnlFA/2vmeQZ9gXRD X+KsLbpf4lCRn0vZ2kD/ybJtJOkR/RQgslVcgDbRWX4Z4faKpk9VUt8r/uLaa2N7INtV S38l5LcNZ3b6WcFUHdiLWkfFYHjiaVjZ9lM/5RU650HR5LwjyRtjIOrkRud03B9IacOm jNhfKy2LuxUz4b6nJEcd1TMYVga8Hgrc+l/7I15AJYiGapdLAe4Oa3J6dUMhgCEjfrP4 9sUXlbZbOoerjYY/3XVwh/NV8ZO3QoWIebSvGtWxkPoCjNs5AsudjjYnUV9u/5WTJrjM O+5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=dmbx+CEV8/se/3fSeHkhg92bMZKxyEmSGS7vO3Es65k=; b=hJ/cbAwdnx7zjvBH0SuFVG8OqGEKhF0bmuQ5+3L+iXBORbkQeM7WXGKQ/YdFeP8g80 tRC+KWmg4Q/DEIgReJJrxFzKOz42gulmZmfkyMQfKj/9lhw/U+S7hjuliMOmTjPmyWlx 66ey8K9r2RBs7GqZOLo5hOdjFD0Qjoh+OxeX6OLnrd9Hj43WT7nmpDgiNtW8zaegv1dF hxcAXzWfYIk8Vr/9JfNWrL2Y7y2u+qQ00iLEu5prWeqHyI62yXjBKy+1Sk7OSq746YOA M5x7F7arFPZwcApyu4cqhmg9MOyvVciPYjoZona5eqEI/7PfIrjbbVpfxg5dolme4ezL U9hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=co1iPseD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i18-20020ac85e52000000b003a5460f2d2bsi791450qtx.369.2022.11.11.00.24.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 00:24:13 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=co1iPseD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otOjf-0001Z3-Pf; Fri, 11 Nov 2022 02:45:59 -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 1otOjc-0001Vz-Pw for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:45:56 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otOja-00019S-QH for qemu-devel@nongnu.org; Fri, 11 Nov 2022 02:45:56 -0500 Received: by mail-pl1-x633.google.com with SMTP id j12so3636199plj.5 for ; Thu, 10 Nov 2022 23:45:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=dmbx+CEV8/se/3fSeHkhg92bMZKxyEmSGS7vO3Es65k=; b=co1iPseDsJ16UzH1ZtUoYHmfIhQv64uNXJBzMHRUvyH/DxnwtRmc6UZ0d0/1WVhD/d 2aaoza9QdwCGCo/+zAjdcVqGJk/sw8C3GjfAq/g84dTmDBQuqhZEfuErp15AFfqkgPuo CgYNDQsoA1wwBzMYSzwBepByf+yJwqEQtMf44xgS4m3jRDNXOuNYLh4Qe1gp+tw71uWU PweAwz+L51v3gSMwAJmdpZAydyBQtWDDrJCQ0MmGS4GNKd8k/3jnYnafDThGo54Sm89+ tqMlCBpJ2olhjgtHEmtDCSHjG6GdsUc0RAfgICK6h1ZmYCHkSNNKszUcLT53dvjkqzDK Lvcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dmbx+CEV8/se/3fSeHkhg92bMZKxyEmSGS7vO3Es65k=; b=OYlEGv/XGlIgUjB2QF7dti3FUVZac4bX2/LqZpfqjI4e4emtcTI4pQr5G0fHxQVjtj pKKvel1MN9DGNASNnFqP37DjSjzMmiG6hQJemztjfJB2V+8uflQZAXsbLu5UFXf6mYip pAGQvLLGOw4voXLUMKNuxmxmonodOHba9rXMDnIPIbzntt3arWSwzIgkC5DLqQfA4hRo yC1tBdFkECtkUDXCRzw6gDOBCmVQXajJ7uny6PFh2ILDwjhYYa+0n+w3h9hTp5SFCQMG DPIBxuei6AncdCDIjfma0meBiwvFrlrpbztVapxhNTgwAbZcL4b8TuVdsTrJgtughQ/5 7HzA== X-Gm-Message-State: ANoB5pnVyvxnTZiOjkpEYGFDzv2DsqC9VsapAx0OOKNxCvEQZphqEkIR 8TjCv5n1kSlUYIt28x3pYT0B2ISDe8aVyQqt X-Received: by 2002:a17:902:bd86:b0:186:8d12:f51f with SMTP id q6-20020a170902bd8600b001868d12f51fmr1115489pls.129.1668152753109; Thu, 10 Nov 2022 23:45:53 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-0aef-59aa-1faf-7e61.static.ipv6.internode.on.net. [2001:44b8:2176:c800:aef:59aa:1faf:7e61]) by smtp.gmail.com with ESMTPSA id u13-20020a170902e80d00b001869f2120a6sm983802plg.108.2022.11.10.23.45.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 23:45:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 v3 45/45] tcg: Split out tcg_gen_nonatomic_cmpxchg_i{32, 64} Date: Fri, 11 Nov 2022 17:41:01 +1000 Message-Id: <20221111074101.2069454-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111074101.2069454-1-richard.henderson@linaro.org> References: <20221111074101.2069454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Normally this is automatically handled by the CF_PARALLEL checks with in tcg_gen_atomic_cmpxchg_i{32,64}, but x86 has a special case of !PREFIX_LOCK where it always wants the non-atomic version. Split these out so that x86 does not have to roll its own. Signed-off-by: Richard Henderson --- include/tcg/tcg-op.h | 4 ++ tcg/tcg-op.c | 154 +++++++++++++++++++++++++++---------------- 2 files changed, 101 insertions(+), 57 deletions(-) diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h index 31bf3d287e..839d91c0c7 100644 --- a/include/tcg/tcg-op.h +++ b/include/tcg/tcg-op.h @@ -910,6 +910,10 @@ void tcg_gen_atomic_cmpxchg_i64(TCGv_i64, TCGv, TCGv_i64, TCGv_i64, void tcg_gen_atomic_cmpxchg_i128(TCGv_i128, TCGv, TCGv_i128, TCGv_i128, TCGArg, MemOp); +void tcg_gen_nonatomic_cmpxchg_i32(TCGv_i32, TCGv, TCGv_i32, TCGv_i32, + TCGArg, MemOp); +void tcg_gen_nonatomic_cmpxchg_i64(TCGv_i64, TCGv, TCGv_i64, TCGv_i64, + TCGArg, MemOp); void tcg_gen_nonatomic_cmpxchg_i128(TCGv_i128, TCGv, TCGv_i128, TCGv_i128, TCGArg, MemOp); diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 66f9c894ad..e7e4951a3c 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -3323,82 +3323,122 @@ static void * const table_cmpxchg[(MO_SIZE | MO_BSWAP) + 1] = { WITH_ATOMIC128([MO_128 | MO_BE] = gen_helper_atomic_cmpxchgo_be) }; +void tcg_gen_nonatomic_cmpxchg_i32(TCGv_i32 retv, TCGv addr, TCGv_i32 cmpv, + TCGv_i32 newv, TCGArg idx, MemOp memop) +{ + TCGv_i32 t1 = tcg_temp_new_i32(); + TCGv_i32 t2 = tcg_temp_new_i32(); + + tcg_gen_ext_i32(t2, cmpv, memop & MO_SIZE); + + tcg_gen_qemu_ld_i32(t1, addr, idx, memop & ~MO_SIGN); + tcg_gen_movcond_i32(TCG_COND_EQ, t2, t1, t2, newv, t1); + tcg_gen_qemu_st_i32(t2, addr, idx, memop); + tcg_temp_free_i32(t2); + + if (memop & MO_SIGN) { + tcg_gen_ext_i32(retv, t1, memop); + } else { + tcg_gen_mov_i32(retv, t1); + } + tcg_temp_free_i32(t1); +} + void tcg_gen_atomic_cmpxchg_i32(TCGv_i32 retv, TCGv addr, TCGv_i32 cmpv, TCGv_i32 newv, TCGArg idx, MemOp memop) { - memop = tcg_canonicalize_memop(memop, 0, 0); + gen_atomic_cx_i32 gen; + MemOpIdx oi; if (!(tcg_ctx->tb_cflags & CF_PARALLEL)) { - TCGv_i32 t1 = tcg_temp_new_i32(); - TCGv_i32 t2 = tcg_temp_new_i32(); - - tcg_gen_ext_i32(t2, cmpv, memop & MO_SIZE); - - tcg_gen_qemu_ld_i32(t1, addr, idx, memop & ~MO_SIGN); - tcg_gen_movcond_i32(TCG_COND_EQ, t2, t1, t2, newv, t1); - tcg_gen_qemu_st_i32(t2, addr, idx, memop); - tcg_temp_free_i32(t2); - - if (memop & MO_SIGN) { - tcg_gen_ext_i32(retv, t1, memop); - } else { - tcg_gen_mov_i32(retv, t1); - } - tcg_temp_free_i32(t1); - } else { - gen_atomic_cx_i32 gen; - MemOpIdx oi; - - gen = table_cmpxchg[memop & (MO_SIZE | MO_BSWAP)]; - tcg_debug_assert(gen != NULL); - - oi = make_memop_idx(memop & ~MO_SIGN, idx); - gen(retv, cpu_env, addr, cmpv, newv, tcg_constant_i32(oi)); - - if (memop & MO_SIGN) { - tcg_gen_ext_i32(retv, retv, memop); - } + tcg_gen_nonatomic_cmpxchg_i32(retv, addr, cmpv, newv, idx, memop); + return; } + + memop = tcg_canonicalize_memop(memop, 0, 0); + gen = table_cmpxchg[memop & (MO_SIZE | MO_BSWAP)]; + tcg_debug_assert(gen != NULL); + + oi = make_memop_idx(memop & ~MO_SIGN, idx); + gen(retv, cpu_env, addr, cmpv, newv, tcg_constant_i32(oi)); + + if (memop & MO_SIGN) { + tcg_gen_ext_i32(retv, retv, memop); + } +} + +void tcg_gen_nonatomic_cmpxchg_i64(TCGv_i64 retv, TCGv addr, TCGv_i64 cmpv, + TCGv_i64 newv, TCGArg idx, MemOp memop) +{ + TCGv_i64 t1, t2; + + if (TCG_TARGET_REG_BITS == 32 && (memop & MO_SIZE) < MO_64) { + tcg_gen_nonatomic_cmpxchg_i32(TCGV_LOW(retv), addr, TCGV_LOW(cmpv), + TCGV_LOW(newv), idx, memop); + if (memop & MO_SIGN) { + tcg_gen_sari_i32(TCGV_HIGH(retv), TCGV_LOW(retv), 31); + } else { + tcg_gen_movi_i32(TCGV_HIGH(retv), 0); + } + return; + } + + t1 = tcg_temp_new_i64(); + t2 = tcg_temp_new_i64(); + + tcg_gen_ext_i64(t2, cmpv, memop & MO_SIZE); + + tcg_gen_qemu_ld_i64(t1, addr, idx, memop & ~MO_SIGN); + tcg_gen_movcond_i64(TCG_COND_EQ, t2, t1, t2, newv, t1); + tcg_gen_qemu_st_i64(t2, addr, idx, memop); + tcg_temp_free_i64(t2); + + if (memop & MO_SIGN) { + tcg_gen_ext_i64(retv, t1, memop); + } else { + tcg_gen_mov_i64(retv, t1); + } + tcg_temp_free_i64(t1); } void tcg_gen_atomic_cmpxchg_i64(TCGv_i64 retv, TCGv addr, TCGv_i64 cmpv, TCGv_i64 newv, TCGArg idx, MemOp memop) { - memop = tcg_canonicalize_memop(memop, 1, 0); - if (!(tcg_ctx->tb_cflags & CF_PARALLEL)) { - TCGv_i64 t1 = tcg_temp_new_i64(); - TCGv_i64 t2 = tcg_temp_new_i64(); + tcg_gen_nonatomic_cmpxchg_i64(retv, addr, cmpv, newv, idx, memop); + return; + } - tcg_gen_ext_i64(t2, cmpv, memop & MO_SIZE); - - tcg_gen_qemu_ld_i64(t1, addr, idx, memop & ~MO_SIGN); - tcg_gen_movcond_i64(TCG_COND_EQ, t2, t1, t2, newv, t1); - tcg_gen_qemu_st_i64(t2, addr, idx, memop); - tcg_temp_free_i64(t2); - - if (memop & MO_SIGN) { - tcg_gen_ext_i64(retv, t1, memop); - } else { - tcg_gen_mov_i64(retv, t1); - } - tcg_temp_free_i64(t1); - } else if ((memop & MO_SIZE) == MO_64) { -#ifdef CONFIG_ATOMIC64 + if ((memop & MO_SIZE) == MO_64) { gen_atomic_cx_i64 gen; - MemOpIdx oi; + memop = tcg_canonicalize_memop(memop, 1, 0); gen = table_cmpxchg[memop & (MO_SIZE | MO_BSWAP)]; - tcg_debug_assert(gen != NULL); + if (gen) { + MemOpIdx oi = make_memop_idx(memop, idx); + gen(retv, cpu_env, addr, cmpv, newv, tcg_constant_i32(oi)); + return; + } - oi = make_memop_idx(memop, idx); - gen(retv, cpu_env, addr, cmpv, newv, tcg_constant_i32(oi)); -#else gen_helper_exit_atomic(cpu_env); - /* Produce a result, so that we have a well-formed opcode stream - with respect to uses of the result in the (dead) code following. */ + + /* + * Produce a result for a well-formed opcode stream. This satisfies + * liveness for set before used, which happens before this dead code + * is removed. + */ tcg_gen_movi_i64(retv, 0); -#endif /* CONFIG_ATOMIC64 */ + return; + } + + if (TCG_TARGET_REG_BITS == 32) { + tcg_gen_atomic_cmpxchg_i32(TCGV_LOW(retv), addr, TCGV_LOW(cmpv), + TCGV_LOW(newv), idx, memop); + if (memop & MO_SIGN) { + tcg_gen_sari_i32(TCGV_HIGH(retv), TCGV_LOW(retv), 31); + } else { + tcg_gen_movi_i32(TCGV_HIGH(retv), 0); + } } else { TCGv_i32 c32 = tcg_temp_new_i32(); TCGv_i32 n32 = tcg_temp_new_i32();