From patchwork Fri Oct 21 07:15:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617128 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp801051pvb; Fri, 21 Oct 2022 00:49:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4jNx853ypj26Vj2p94sedD3cmRw2DhgOWztrcFRssjR3neN0MIRhs1V+sC97aj7nmY1o2z X-Received: by 2002:ad4:5763:0:b0:4af:b800:be6b with SMTP id r3-20020ad45763000000b004afb800be6bmr15709033qvx.70.1666338550518; Fri, 21 Oct 2022 00:49:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666338550; cv=none; d=google.com; s=arc-20160816; b=cbYOPmGhJsl2org1GGX81nHB2N5PKQadPZkv5aCtG6hsTzsaL6qgdHx5eIs7l0dGpI 4R58eauvxVz8a+t2yIkhmPmIS89vIzDd/ODRvk3W4hyma7dNIl1mVO7uOxqm+guXfp5Z 8k05+wIh2smdeUKgzX8iOLlwFyG3rGNHNay5OqkfpZUtm2W9vQ/IzEb2gc06l6IE7fCU i7EPX47lNXWwcmXQjNcOV0YFJjsBPhL2xDf0xOOblZLUEJCDpXHYrzPCRb/GbncPE1Oc ZfBzreAiCeQ0n+727/51JG4/zPMIUTvSLKR64HmyKTV4dF1PkqIBd4XAeFYhiBbj4uGh NR/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=PB3nAjYqPE0Ri3rKlsMJ9c6TgJjZ6GaMPRBD/PmouBs=; b=CbacHGtzjxgzNbkiQQc5pYD3YtSEeS41rcxUkpInl4ceZjfVSDCosAVA33aPJhlW9H 2mw0eibiWH8KeaBARF4r7mcwnpNE6qaohlCMJ/dKrnTI3KlYn2qAG7ql5nBaR/mCAriZ 75lTrCZ+O8wZe3JNpYeGMXg4oOSOxVpY0IRaLvKg3rbAuU5otSQXGfAfZq/GI1DzZlSw k4b362joYxbeEO4ChhXdlYzQmIahsiLgWt99Z8z1Rr6UUncBTvAqmeMYWsKZSdbLETyh 2CYquSnPPjT60SjaGM9YCHjx2RSfWd+U54BxFjlZNlz3mzghNuvB5j4kfhTrp/IydUi/ Mq3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F9iS+YBp; 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 bt11-20020ac8690b000000b0039ce9741c46si8117216qtb.185.2022.10.21.00.49.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:49:10 -0700 (PDT) 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=F9iS+YBp; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmmC-0008R6-7p for patch@linaro.org; Fri, 21 Oct 2022 03:49:09 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmGw-00030c-6G for patch@linaro.org; Fri, 21 Oct 2022 03:16:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmGe-0002vD-9h for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:32 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmGc-0005bK-9E for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:31 -0400 Received: by mail-pg1-x52c.google.com with SMTP id 20so1804354pgc.5 for ; Fri, 21 Oct 2022 00:16:29 -0700 (PDT) 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=PB3nAjYqPE0Ri3rKlsMJ9c6TgJjZ6GaMPRBD/PmouBs=; b=F9iS+YBpSImt8bieV9JH3062iAxm0rA2e75f1dotc1/K6WT2+6pu4SinR0jY8EXZhB PNwyR0iAFu4we0MjGavdAZ+EpezSQhlNpjmbQOEBUpc8P+2/8ntAVfAHtwOpr/IBSRfR V5WSuXMX3htp3GoJWVDNHQodKw2AgavTIHK1jJli+dDISUJzyw0++iqOoWMHm31RiY44 gZzpAgvzF/EkjG2stCTJoDGoU0MuIwayAvgDSt3cI1J48Fq2WOL/rS/8+JYoxIFtVJ5A 0a5H0W6UA22rZrCvy+4+87fpyQJ+jWrXpDFrpmfhyWvxw14F6NLT3MNF00THy9Zdt3zM HgTA== 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=PB3nAjYqPE0Ri3rKlsMJ9c6TgJjZ6GaMPRBD/PmouBs=; b=38UgUm9JevIpulKzf4eQW5M4/BAh3KMHI6SfM0q641ffyIfq2tD1S0GJzkQq5v2A9U 2+NUvslnNGKnpaHorCPNRm1aPDVD1W52b0doeQK5Cc6ih4jP3VYjFkAeWE2DnoK6krHl /o2j2Y3Re/63LedvAiyDLtXfXVRzKxD1SsFoiiOa9YdLGV/2rHAxKWtmsAauSLMeXRce BFt33Gs36UpN41tZ8nksVD9DZqE02/NbaOjMReFfd1hrV1qDwAT9BbnMe3L8aIFT+Nqg kv1pfri4CKuiorSxpruAxjd+qok1KbDZMPei+yngOZJsJ90baW1Ov2KFrDL4w7Hh1lSi 65rw== X-Gm-Message-State: ACrzQf0WCjtrW5zDRZxR36tSQqM6cUdt0sVas23xOzZHKf0pxikoZWHJ jyOTPhtD6fGwpNmLup+oiSlC4eYVTbeJ5j1T X-Received: by 2002:a65:6cc7:0:b0:42a:4d40:8dc1 with SMTP id g7-20020a656cc7000000b0042a4d408dc1mr15328647pgw.321.1666336588701; Fri, 21 Oct 2022 00:16:28 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.16.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:16:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 01/36] include/qemu/atomic128: Support 16-byte atomic read/write for Intel AVX Date: Fri, 21 Oct 2022 17:15:14 +1000 Message-Id: <20221021071549.2398137-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.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" Intel has now given guarantees about the atomicity of SSE read and write instructions on cpus supporting AVX. We can use these instead of the much slower cmpxchg16b. Derived from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104688 Signed-off-by: Richard Henderson --- include/qemu/atomic128.h | 44 ++++++++++++++++++++++++++ util/atomic128.c | 67 ++++++++++++++++++++++++++++++++++++++++ util/meson.build | 1 + 3 files changed, 112 insertions(+) create mode 100644 util/atomic128.c diff --git a/include/qemu/atomic128.h b/include/qemu/atomic128.h index adb9a1a260..d179c05ede 100644 --- a/include/qemu/atomic128.h +++ b/include/qemu/atomic128.h @@ -127,6 +127,50 @@ static inline void atomic16_set(Int128 *ptr, Int128 val) : [l] "r"(l), [h] "r"(h)); } +# define HAVE_ATOMIC128 1 +#elif !defined(CONFIG_USER_ONLY) && defined(__x86_64__) +/* + * The latest Intel SDM has added: + * Processors that enumerate support for Intel® AVX (by setting + * the feature flag CPUID.01H:ECX.AVX[bit 28]) guarantee that the + * 16-byte memory operations performed by the following instructions + * will always be carried out atomically: + * - MOVAPD, MOVAPS, and MOVDQA. + * - VMOVAPD, VMOVAPS, and VMOVDQA when encoded with VEX.128. + * - VMOVAPD, VMOVAPS, VMOVDQA32, and VMOVDQA64 when encoded + * with EVEX.128 and k0 (masking disabled). + * Note that these instructions require the linear addresses of their + * memory operands to be 16-byte aligned. + * + * We do not yet have a similar guarantee from AMD, so we detect this + * at runtime rather than assuming the fact when __AVX__ is defined. + */ +extern bool have_atomic128; + +static inline Int128 atomic16_read(Int128 *ptr) +{ + Int128 ret; + if (have_atomic128) { + asm("vmovdqa %1, %0" : "=x" (ret) : "m" (*ptr)); + } else { + ret = atomic16_cmpxchg(ptr, 0, 0); + } + return ret; +} + +static inline void atomic16_set(Int128 *ptr, Int128 val) +{ + if (have_atomic128) { + asm("vmovdqa %1, %0" : "=m" (*ptr) : "x" (val)); + } else { + Int128 old = *ptr, cmp; + do { + cmp = old; + old = atomic16_cmpxchg(ptr, cmp, val); + } while (old != cmp); + } +} + # define HAVE_ATOMIC128 1 #elif !defined(CONFIG_USER_ONLY) && HAVE_CMPXCHG128 static inline Int128 atomic16_read(Int128 *ptr) diff --git a/util/atomic128.c b/util/atomic128.c new file mode 100644 index 0000000000..55863ce9bd --- /dev/null +++ b/util/atomic128.c @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2022, Linaro Ltd. + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include "qemu/osdep.h" +#include "qemu/atomic128.h" + +#ifdef __x86_64__ +#include "qemu/cpuid.h" + +#ifndef signature_INTEL_ecx +/* "Genu ineI ntel" */ +#define signature_INTEL_ebx 0x756e6547 +#define signature_INTEL_edx 0x49656e69 +#define signature_INTEL_ecx 0x6c65746e +#endif + +/* + * The latest Intel SDM has added: + * Processors that enumerate support for Intel® AVX (by setting + * the feature flag CPUID.01H:ECX.AVX[bit 28]) guarantee that the + * 16-byte memory operations performed by the following instructions + * will always be carried out atomically: + * - MOVAPD, MOVAPS, and MOVDQA. + * - VMOVAPD, VMOVAPS, and VMOVDQA when encoded with VEX.128. + * - VMOVAPD, VMOVAPS, VMOVDQA32, and VMOVDQA64 when encoded + * with EVEX.128 and k0 (masking disabled). + * Note that these instructions require the linear addresses of their + * memory operands to be 16-byte aligned. + * + * We do not yet have a similar guarantee from AMD, so we detect this + * at runtime rather than assuming the fact when __AVX__ is defined. + */ +bool have_atomic128; + +static void __attribute__((constructor)) +init_have_atomic128(void) +{ + unsigned int a, b, c, d, xcrl, xcrh; + + __cpuid(0, a, b, c, d); + if (a < 1) { + return; /* AVX leaf not present */ + } + if (c != signature_INTEL_ecx) { + return; /* Not an Intel product */ + } + + __cpuid(1, a, b, c, d); + if ((c & (bit_AVX | bit_OSXSAVE)) != (bit_AVX | bit_OSXSAVE)) { + return; /* AVX not present or XSAVE not enabled by OS */ + } + + /* + * The xgetbv instruction is not available to older versions of + * the assembler, so we encode the instruction manually. + */ + asm(".byte 0x0f, 0x01, 0xd0" : "=a" (xcrl), "=d" (xcrh) : "c" (0)); + if ((xcrl & 6) != 6) { + return; /* AVX not enabled by OS */ + } + + have_atomic128 = true; +} +#endif /* __x86_64__ */ diff --git a/util/meson.build b/util/meson.build index 5e282130df..4b29b719a8 100644 --- a/util/meson.build +++ b/util/meson.build @@ -2,6 +2,7 @@ util_ss.add(files('osdep.c', 'cutils.c', 'unicode.c', 'qemu-timer-common.c')) if not config_host_data.get('CONFIG_ATOMIC64') util_ss.add(files('atomic64.c')) endif +util_ss.add(when: 'CONFIG_SOFTMMU', if_true: files('atomic128.c')) util_ss.add(when: 'CONFIG_POSIX', if_true: files('aio-posix.c')) util_ss.add(when: 'CONFIG_POSIX', if_true: files('fdmon-poll.c')) if config_host_data.get('CONFIG_EPOLL_CREATE1') From patchwork Fri Oct 21 07:15:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617126 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp800088pvb; Fri, 21 Oct 2022 00:47:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5dRt0Ko77zMycg+SzNic0+CuPtJE7o8KIhCcU6ykqaitNbIHyqndIVkx6/U2jTd5nC1V9M X-Received: by 2002:ac8:5a8d:0:b0:39c:f9c3:6575 with SMTP id c13-20020ac85a8d000000b0039cf9c36575mr13184917qtc.655.1666338433155; Fri, 21 Oct 2022 00:47:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666338433; cv=none; d=google.com; s=arc-20160816; b=A+Uu0gIDS1QXGgnzi+lmc3Wk2z63sjmBzdC4yvPZPKKH1sddKnvlHTuTO4mgjqfyc3 NnUKN+LfwTVK7S4Qv7KktzQZ5NYy/bLD296qKscv/b+XvwHAM6PnGR+SAp3zhFvz4BR8 dekXJhfBWeyLx2ErsDo+niEFYVHLDWwjmaAs150ZjD/86XwJAzqa11wwzoxuBIf4cU+r 5zbUkPlQNB/wLFIwvMhWemsnZ1V4KQmFbwhcx/+OcssnmcnOg7HGeURJGe5qr7tv1+0f ZQuVJCmmlpKUKZtcfral7O4BtcbMa2UZfadAzOVKCGjk4pIKEnljt/Z5RaxZMuiCDARB UzFQ== 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=0N2X3V1riRQReX4ltI4ULsG1O5wdgfurbMkc7ES3gzU=; b=rRw+nXeFbLoDy7aRAlmdjbiZrptGEoC+rJfCcqBFJZJQVC/7eX2KHQRN+QJRhAb7CD 6cdjdSXEoJxOIRQNfWzcDqzG9hLmUkhxjaHdfY2WIevgwppnos0cL66P3SOoxHMLpvvp 0LjczrZSubCjqgPaYiRid5lwfLYNbTegTQL8ZwION8T/fjbXVi9pAfJqPGgIi43bXReh lIjVY+GhI6NV761Eejns5w5sN7Stv1uvn61nWmMyErFtQ0wdU7wwXO3jJszT0SYs25n9 E+5uHdMu+Q3sjhkLRxe9G0dEkhgg43USxUMTThabDr7lPRkAk18EiEOJpJY7voN6NM/b 8yqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HRqEdCti; 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 p2-20020a378d02000000b006ce93e46f95si10982905qkd.40.2022.10.21.00.47.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:47:13 -0700 (PDT) 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=HRqEdCti; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmkK-000650-Io for patch@linaro.org; Fri, 21 Oct 2022 03:47:12 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmGx-00031i-AB for patch@linaro.org; Fri, 21 Oct 2022 03:16:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmGg-0002vr-Im for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:37 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmGe-0005bl-QR for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:34 -0400 Received: by mail-pj1-x1030.google.com with SMTP id pq16so1686309pjb.2 for ; Fri, 21 Oct 2022 00:16:32 -0700 (PDT) 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=0N2X3V1riRQReX4ltI4ULsG1O5wdgfurbMkc7ES3gzU=; b=HRqEdCtiFfzrYtv4NLUFj4DMapt93Xyto+5bjCiyFgCepO6/G4f7JpWjsCp+EJjFTj +fAAnZhJoQinghYcieigcMyuT3yNueTX2g/88Cu43aRraJKjQciS4jS5Gxu9NMYjdXQy /VUpjJnA8/ddcyCxX8EUnYMJHYGOHlvnBfvJVDo6x9E7FXIzrcqccvrMB8SmSq7XVhq5 /nY5HMsLJ0rDECv4Dhm+Y/I7S8LWQnN2PrUHGOYY3niZuvr3qr02Wdb3DDXIBy7TtJev RAumzHONZSFGoyCM7g40yTMy75Q3W1SZ7qXFJCViQJM77pZvVQMMeKqhf0Q5qmM2Ukd+ dcKw== 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=0N2X3V1riRQReX4ltI4ULsG1O5wdgfurbMkc7ES3gzU=; b=sV0/hkPJOitKnepS3BCeUET1GyKRTDfJIlrEalQHrw9S5gbVx0EduaTtkF8jeq2WHz cj0IBHpTJsChuYba2GXHYTGAmS8xMgpRb5exTPKAudaeX2Kyt9LosonCzmpDqQwrpfuR OQALJb5cf2Rq/fJdhlqXphp2tY8oCizVTZWrVyDmFGHxTQ1rN5jTbgLWMZfN3bYyVTdT s/oXH6M3DA4YR/CirDmsL5AxZk91T/M9VelZbQU67gOv0ywPfqHZdAeW/1/vU66KJAwG d7gmokKMXOxIGEYHZS89CaCsrQGenUYAcaRcZZBBsgtVOQOnYg4XQIAD4ussxcNnaPrM 5p1A== X-Gm-Message-State: ACrzQf35PtplM0WrUjYAMG9/KqxT1S4szwtqaEmBmD/P4AUfYUrqpvgx erwpUw3zA8LsvLPc1UtAEu/ObZ7ah+1qeWxw X-Received: by 2002:a17:90a:e387:b0:211:2d90:675 with SMTP id b7-20020a17090ae38700b002112d900675mr10149073pjz.66.1666336591367; Fri, 21 Oct 2022 00:16:31 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.16.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:16:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 02/36] tcg: Tidy tcg_reg_alloc_op Date: Fri, 21 Oct 2022 17:15:15 +1000 Message-Id: <20221021071549.2398137-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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" Replace goto allocate_in_reg with a boolean. Remove o_preferred_regs which isn't used, except to copy. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/tcg.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index c9e664ee31..660d5eb098 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 Oct 21 07:15:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617122 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp799385pvb; Fri, 21 Oct 2022 00:45:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM52O6txeEH2LC+0Wy37TXFHrFj7Z2uHWRMtY2NWmDQaDa8amqrq4s9xMO94+6WeNe7jrFEy X-Received: by 2002:a05:622a:7:b0:39c:14ff:32bc with SMTP id x7-20020a05622a000700b0039c14ff32bcmr14798510qtw.125.1666338343673; Fri, 21 Oct 2022 00:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666338343; cv=none; d=google.com; s=arc-20160816; b=03E/T0TSOWgZN7PudHEi8tSQLHw/waBn8bCHSiyrMdDn8TDHYwL9OfP1pQhenh7B4D 8e8AegNFn9D4dIEIpCIqkMm8Jd08V3/kbeGdBFcepF2o3rtnSp8scoF8Iq9P0f0NKKEP JieIq8gozSeceRsaLdbeZ9g+ANkFdqxjBcPmJZYcFCBujAv76uCJedAvRp7cmV7nxQxs fl2Wp3lXZiFkwCzdGKYC6UB/WL67b5aab5l3A3xq1R5Dh1q62gDEYFqZFDFUQNskxuQl qAVHkoyR7x9RN6VHB1p0XPxl4be7bWVPcaO0fmrlgJ5IkA/14VibSfv0CuSYHDzPqp9n FhPA== 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=x7WYQtCAL6ZzGFr7jsOhX+NZYzn5szp042JeNsGxFIQ=; b=KTIfoTD+Mvvw8FYcYchC9YCs5SDstP6AkMZr8AQDxuennLJLZ12XQTd2YrUdETbEgp D0/1Zzgom2yo3ZY4Cu8ZNVpiF1sa0DtI9MYMtFXwRubJlEjN9XdM7PMfuPpwm5vZtNmO 8GvX3eS4dFxzIK13Wy2bb2drW7BrbyRuuOdXY2ukKB6zt1uMwKymn+DyZlMjUcBMxuxe nYqR+bnU9I+B3D6sarjpD6uzL9tj8B+hzIZQmHE/187Owv2oVrjxYlA8pFKr7y44ldrA zyXM8/n5XNM5T8Axgjjd7FRvCa3veU4nAXzOtnJM2f67ox3zcDw3yOw2ZctbcfzaKSYr H76g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zqIxtnVL; 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 fw5-20020a056214238500b004b485342adasi11460168qvb.187.2022.10.21.00.45.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:45:43 -0700 (PDT) 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=zqIxtnVL; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmit-0003NS-0t for patch@linaro.org; Fri, 21 Oct 2022 03:45:43 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmGx-000317-V7 for patch@linaro.org; Fri, 21 Oct 2022 03:16:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmGk-0002wA-Th for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:40 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmGh-0005c9-N5 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:38 -0400 Received: by mail-pj1-x1031.google.com with SMTP id pb15so1652888pjb.5 for ; Fri, 21 Oct 2022 00:16:35 -0700 (PDT) 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=x7WYQtCAL6ZzGFr7jsOhX+NZYzn5szp042JeNsGxFIQ=; b=zqIxtnVLFMoKQCJr0SOAqmGIInJNB0BlyFdewxuAUdGUKccX+E3t84ToRyC6Re47tg lmNSwShl89RERYcSth/eTuUAZahW0FqYXOuqn/yS+MyI1fgssgehF1g/wM4r0BFD78tb 1CVcNNMyqSZlMa9fmZjchxSBtuQUSCpB3jUraWKrWhNJl6TPAHrAOWUYEShv8Y5CfmNE ofEOnvH1J29ugWj9DL/rxCdIMyX/S0ANqDTuy6FMOkLxq8NMq58NUk/Uk/iWYaHHQ5r0 JYAEKqWKRpof5xg8xONEyfFz8duN6wO3svNT8jJ44DDtqAxknE/f6P4kVg9eNaSm7cl3 hQ9Q== 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=x7WYQtCAL6ZzGFr7jsOhX+NZYzn5szp042JeNsGxFIQ=; b=v7QjodkJqt58v91HzwXH2BuVzkc0dsy9r8rLcvs76vD+0FE4yTzPK7PFUtJizHz5Fc NjfGfdQB/4BJsUG6mbqq3Cf2jF8Gn4OqHOJ3ErPP+SfG+mcRz9lA/l11FS9zfuf7sivz RLvM2QOMtc0mhzHApU83nN2sJ8Lzcj/k7uYfIpX3bJIPNhX62QioQqjZ/V8Jw6O+ScuF p+v0KTRrnrBX5FVKHUBJ2LTK0b0VER+15KC32TMwDg2rORjnqCv1L0TardD6++BqPZH8 /RxzfzoS9NrUxL0ov0kdZsOAAF4+m69Hcm0Z0zp0Vo55IKWBnwARtD6DVTnPqLpsaMoB dYGw== X-Gm-Message-State: ACrzQf3DreE7Qw5WWOrNvs4UkoKUwPjDbNBnZbfwisKkgsktNEXKV6jM ldQmZLffy1cTUeuYw8eRvu9HDs1JoQAgZ74l X-Received: by 2002:a17:90a:ad08:b0:212:d5f1:e0c6 with SMTP id r8-20020a17090aad0800b00212d5f1e0c6mr294604pjq.228.1666336593969; Fri, 21 Oct 2022 00:16:33 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.16.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:16:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 03/36] tcg: Introduce paired register allocation Date: Fri, 21 Oct 2022 17:15:16 +1000 Message-Id: <20221021071549.2398137-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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" 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 660d5eb098..e9ff3c92e5 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 Oct 21 07:15:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617134 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp807505pvb; Fri, 21 Oct 2022 01:03:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4LC0hstvhvEzZt49+CYOm0wIMzkC10K5A4CkiG4qMD6HazynHaAZ+tB+qzmEDem8G0Pxdd X-Received: by 2002:a05:620a:1d0d:b0:6ee:3a2e:d225 with SMTP id dl13-20020a05620a1d0d00b006ee3a2ed225mr13250635qkb.10.1666339406805; Fri, 21 Oct 2022 01:03:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666339406; cv=none; d=google.com; s=arc-20160816; b=FjHKCMO/wph8p/PBf2XrSfIs758Ia+cVsjieZ4seIC7YQIyj2wjd7fqmjRBNBoT0hl c0cbpLY+2FoCzznbGdSmLJinhjvWxtBcGeaRwWcpAra3wRdLzjLNaystbNX3Eso4O8yh iWWcDL5JBpgtO1Xp7FBxcwZ3cntfqVs31220wf7i2yG0ot7JPH4W+diJf2P9pMxZarpC haDy6MN9bZ6eyKXCWg0JayN+SbykBuX0fWNqtOapMvgIzLfHKXHv3JLyp6ddnnNDZMy5 /cjXj94ecJaWLFhpFMNQF8yJfF+1IArqS9b7vA8xFN18VBR6ynmb4hZ8YQUPiJK5wm+x u/4w== 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=HybygAWflUBPhXXJIkUQk6lvAKDE9LHcysJZW3idZLBVvAxi6N0LmwCYaug5TmmyXJ xHIlldKozb09sfqj/1ffbkdDVfVeB1lI/DRseDoHbz6K6pgBwk6K1tES0N6hFgJyzkcB Dk6Ij1k6FS6Ki7O5iZHiKMrFVdUQTj7170ch0x7v1oFuv9EWrUvMvHs6aQ3tCWKHaRDR RYXsLQhfKEEAj2oqRY4zEIpVrJ9Ji57NtVByekY4SpQrsxRa21BNO5qukTosiS1BXRjK wOVraKAFxoLplnwvnxPEFO1RtyDfmmWMHqPoeyXe3qFSFwB45g5lA/3zAUtq0CrvzfC6 OUCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AceTDJUd; 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 c10-20020a056214224a00b004afa3c396a6si12558695qvc.219.2022.10.21.01.03.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 01:03:26 -0700 (PDT) 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=AceTDJUd; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oln02-0005HB-6r for patch@linaro.org; Fri, 21 Oct 2022 04:03:26 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmGv-0002z8-03 for patch@linaro.org; Fri, 21 Oct 2022 03:16:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmGm-0002wL-Ex for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:41 -0400 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 1olmGk-0005cd-Mc for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:40 -0400 Received: by mail-pl1-x632.google.com with SMTP id c24so1560457pls.9 for ; Fri, 21 Oct 2022 00:16:37 -0700 (PDT) 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=AceTDJUdB6BqpwvfOC88MYN1lkhrIHQnsO0Ih5ym5HFangUeALvATOU/kDCvPIffio 0e+fV7CGWYD8RScoei0hGjOzy0ksW/rKVqOtuQWSA/1AHwIM8f7XJD1m5NHtHc4rDGph R62lv9GDJ46jVOcJnabQjjcTm0TiyaWTuSVD8n36V9DaukISTQjdzyBOGQ4bwejSVcSd eUUWVUyl4CtQPDRUW73x9gSVmBz/YvW5QdoH+vZqE7NsJaJCiyTLGGhfbFh46J9feopR zOPPhbuFSuR880cKXMScU4BxHvnOzs81t25NsCiNl6tstATe+1VVddz2wOMGn2FYA/Wz xhjA== 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=ryf5hnQ/0ilUQELMZ9QK+4BMwaCM0EB8ju4t8Gzqx3LSG8qVeGI4zG1bsm+oNZGR1b /gzcHRdZnNKtP7YPOIqT62+tqHSiflbx9yi0u57BZShP/iQMS06uC6W4Xnu3kIlopPci Xy3yF4+gm1vs300w2C3O343tkXnA8KjWwyvRlhBwHUgCyr/CqcgI6f1sWhzAOBkiRTFF nGPFXfKSqR2GoPxQjxw6AUp12tK4Ja9PRIK6yR0rTNTky+Z25wREX7zGObEAzTh3Oss0 5uh3ff6ofQVfutKdDjm2LHPh+YBTfCf+FKGHXdhHJu79J0mV/ol9yD2cqCs8L0EgLxe9 a6dg== X-Gm-Message-State: ACrzQf0aAc3m6QBh9lqf7Zp2dmixK3/BNk5YB2KcALynHrcW9XJ7FlCo ozWBnTJJIhBi+UP/vzlgTTGjBarVJq8lqCS1 X-Received: by 2002:a17:902:e5c5:b0:186:5f09:8468 with SMTP id u5-20020a170902e5c500b001865f098468mr9282058plf.122.1666336596594; Fri, 21 Oct 2022 00:16:36 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.16.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:16:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 04/36] tcg/s390x: Use register pair allocation for div and mulu2 Date: Fri, 21 Oct 2022 17:15:17 +1000 Message-Id: <20221021071549.2398137-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-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" 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 Oct 21 07:15:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617125 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp799753pvb; Fri, 21 Oct 2022 00:46:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5+dwCRjoRwX+ewszIlWspS2quuOhej16u7hdwnT4qL4lwA9lfClh4MOcMz3GZiTtWStnpl X-Received: by 2002:a05:6214:2681:b0:4b3:ed11:eb5d with SMTP id gm1-20020a056214268100b004b3ed11eb5dmr14977279qvb.17.1666338390100; Fri, 21 Oct 2022 00:46:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666338390; cv=none; d=google.com; s=arc-20160816; b=ypRcXl+bW9djPN0anCfVV8xwh77yE+iyeytXIMiABJ0GcS9g2zPxguDSfSn6MlILhN 8R2SzgjZVOx8zR03z+Cr25oYOtzss54eL+ZHkuLzGVZpHs+A8Nv/MYl+NKvFdt70G419 9vjnCiWd0Q0TNA0H0sCyh1hOQTdc1kq8Jf9JGcxuTVIE6K1KkLZJ3hUYQnGvn/H+gF6Z iyb0T96omVTNLIRvIw2M3Y6a3mGz/iov6eyyONEMur6wKbEtGzy81e4jk+J3eVgLVyI4 kbL1W8dyFBOYJmJRbd+t/ei6F9QB3qDhs+5alIZNrrYSuZhDAGJZn2dTRqhDbZi+ETJG IiTQ== 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=A46X1JeJzFNowYINHOL6hUA+uF8JVCz68FOL1amM3QJLGMobmqP32lFq/eDGYp22/M F5jbyPpbQIk0XZKULfyFUy9lnpM6ZI/czWqrsmSAXrtostuZZ3kRbtwQXuEhH76mkN5e 6Q9YtDa9T1CR1DeAi1ppweAwFLP9rc04xigADNl3OLnepcEJgKL9ytue4qxqGd8C9slr PqNmcsEtfcPdj+b5TrLiiTFFq3aGoR+zoL7hn60B8BJhaiF1SS8LiRrgjQd7vDGk0lQ1 4Q8ynzUKpD1e7lGBG5HQAjO/pzivZ3QTmFlknEpopX2B5h+Ima0mOzortuRmOAWQsvA7 3ECQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d7uxq0v7; 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 10-20020a0562140cca00b004b1aafe878bsi11603517qvx.463.2022.10.21.00.46.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:46:30 -0700 (PDT) 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=d7uxq0v7; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmjd-0004m7-9M for patch@linaro.org; Fri, 21 Oct 2022 03:46:29 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmGx-00031U-L6 for patch@linaro.org; Fri, 21 Oct 2022 03:16:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmGo-0002x2-FE for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:45 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmGm-0005d3-F0 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:42 -0400 Received: by mail-pj1-x102e.google.com with SMTP id ez6so1688923pjb.1 for ; Fri, 21 Oct 2022 00:16:40 -0700 (PDT) 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=d7uxq0v7iEmNumcYcjP/cIDwcGioQIiqwKLIe2rltU/x/PIgShfXztkffaalOn/zJ5 K187OOIDYwKeKTnBxRPsu8G/sbgZ/KB27Q2p6FZd8G55prSGtXliBJ3qcKlURp5hjzD0 LKhM81wLnNx63M5xIJ5l3Qa5XZZxmdAuGjFmHfejlDKrKPVjd4KUgkdswwZyu41LVRus 2XMmSsGsVHDZjHEbu52BlFcIQcHWNzQ8X29BmiHCfJSFjGq0cpdxoytJOTErMojMPhBe bcS7pfP41PdNA9mOc60zt6POMZ7ek+Yt/Sa+5Y0Dux6uaa80DKDZAuymVTbL5QlC8eVb r+eA== 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=HMzydYpg/2G3H6R0cCPeFCk2F7TZolf5TbJs2eErFKCohixXWq4BCRHCJEVV9ZQpbv 82cFUTP4rBDzAMZDXoQhmqiO4GQvm3/spopYSPC7xLbMdQlFaZ8sBVIMq/bxfsgYLvxc 6TNrDWszDyHoFHo2JVMmxEcNTA8K0gM6HjZX7oUOyfOrU05AwaCjCcqmDENoqFHntBv8 thcznycILzf6PUoMJjTD/BseDuiT7nt3q/VhX5+nuctasXcnqprcuKEXIkefHZSeJaEv BdjlV/Id/oAzOs8xBjnyyTyImB9m9NT8ESR9i3SYrqrh4pQXyWefG3tOEcg06FEGPyE3 g27A== X-Gm-Message-State: ACrzQf32FkpncXTMOrkOjQQsoEq/qBF25rV+aMwB5yFzCkNhkU5iVBcG EjORq8npL2doIL+mNDi5REtuQnuTreunTp76 X-Received: by 2002:a17:90b:3141:b0:20d:1690:d3d2 with SMTP id ip1-20020a17090b314100b0020d1690d3d2mr57013105pjb.230.1666336599061; Fri, 21 Oct 2022 00:16:39 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.16.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:16:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 05/36] tcg/arm: Use register pair allocation for qemu_{ld, st}_i64 Date: Fri, 21 Oct 2022 17:15:18 +1000 Message-Id: <20221021071549.2398137-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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" 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 Oct 21 07:15:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617127 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp800853pvb; Fri, 21 Oct 2022 00:48:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6W3SXy+PPMHTN+p+qRqWfWZAlyQtJQtr7lPUR90FMmfLFvdL0/ZJ2noG9+6TrMVwnaBdqa X-Received: by 2002:a05:6214:4109:b0:4b2:9961:9037 with SMTP id kc9-20020a056214410900b004b299619037mr14431781qvb.13.1666338522753; Fri, 21 Oct 2022 00:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666338522; cv=none; d=google.com; s=arc-20160816; b=Eu4aKzkC7UHItB6orPVZM386Ea9iPGEm6s1P1Jdt/Ms0fj4lrkzYpkaZ0RYrmGGG7R /n7mghi64QXfvvuH5/0N39xbhTf3MwwNMd/fw42G0BXN1H0oEMNgUiT+iMn4dDj2l7fj OxTpPtI7AsG5PA2o/6+tT8RA6HeIHiBq5Ra9XmbEN8jGp+l6aUxI8SZQoizJAR1QWlCu jSYaplFisHUsBSuQeAoDIH3gs0DyvMMogVUJP2DTIPITHZD6sMYbq7jRtWE1Mja6dPjW Nmuj0T57yMCFmV3LyEVrziks5n1oEZejaTmmuvQ23WG76sXSLdv/O4m59rUspUomUCBk of0A== 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=3WQZzPRazLKJGEWz/VuQ3kFYrNgQhqvNUOfet5eTrD4=; b=Y2wv45+AQbJUMGLu65YMQX8QquE8TioC2/pt31T38FdriCygXRUTeWBXY+1s2qKqCR o5++FzD82qcDtkndiig3vFS5KfD08IIiT3mp9+beJ3B0lF0EUggRgv/Og/T703Eu7cWz SMpB0ySMvu4tVGAqPSdpHY8WUNR2eShZW+M17yTsAvSE2tqs/q7Xx0VvJu0bB6LyyYl0 9RoqWkz+KGu3RDZnXuCbd4ryVtN3slGNOYGnM9I0bCT3/x3kcoMsdSEpOIy2Q0h7kEMl 1/KmNIZbdDXE2lilYOjo4+oZcl6OTykXnCbI6FOK7RM9J8BtlPlxT6Za6CA8N+ZAAZtQ w3TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B4hkVi7L; 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 o17-20020a05620a15d100b006ce5a8fdeb7si10975765qkm.83.2022.10.21.00.48.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:48:42 -0700 (PDT) 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=B4hkVi7L; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmli-0007m4-MP for patch@linaro.org; Fri, 21 Oct 2022 03:48:38 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmGw-00030e-4B for patch@linaro.org; Fri, 21 Oct 2022 03:16:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmGq-0002yN-HO for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:45 -0400 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 1olmGo-0005dR-Tu for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:44 -0400 Received: by mail-pl1-x631.google.com with SMTP id d24so1583323pls.4 for ; Fri, 21 Oct 2022 00:16:42 -0700 (PDT) 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=3WQZzPRazLKJGEWz/VuQ3kFYrNgQhqvNUOfet5eTrD4=; b=B4hkVi7Lwa8mwbU7h+eN7W6dirVbhXHKVW/DFysm6huMUbbVPhJ31propZbPBxsMOS vcVf4Rgr9ZRtBwa1C+KrrljYr5MAGpqpZ6H6x7F9bAtHPR0d9AiyBuV6fiuqULUB6z9U lLsBAOOlCqAdNWxFZo2YKIcQn1rEPE6DLF1DqFe1LFANGh+gKMgJ/e46f0/9sRzxeWYv g0rxBfEbp6R1duYZKjch6NYjJSI99z6wDSOTwDq+jnilhh/HpXnOHPJZWybD1rbzS2Ey p5kK4LxneXmQvziuuBpM1FoAQTsUJ2P0Ka/BZZU1GEIlHnezvnxSEOiXDjfW2wY4dM68 Sn+w== 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=3WQZzPRazLKJGEWz/VuQ3kFYrNgQhqvNUOfet5eTrD4=; b=EyiEpk3plNj5g/vevcfLBTZh2+MEO+YApu9MlHRhjxd6raUd7cdORCDTUCwhL/7sra luTlkqONkBIAuDZuCRVlgkdaylqWmmYtxmAi/ioxNagblN2IrodNyhqGMglHD1kaxM6S OlXtEDXFnw/ngFThpcKLi49qb+5S4sHVLDh+PTvrvul0mY/UOtW3ub1tLft8iXfU+Mpi ido1cYGt+J0pW8BwBM6H3Mn7ytoHeYtl7YKlJUtqwimd8C3j2CR/8aPwykRs3ooiApLg eVyai0qhZ7zg8GkXeXeWM2kpowcIdG2fw732kVZrVtb7qiby6Y0RLsD6AINujoTajM3n KSXg== X-Gm-Message-State: ACrzQf35Kp0VVle6Bm/Ufc3CCpNH7OyUYRsYMfIgEv31MPI6a7S1DrU+ 2847OtBre2sAZEDao6f576oDFX4trM2VIhVl X-Received: by 2002:a17:902:f7cf:b0:17f:9081:a3f7 with SMTP id h15-20020a170902f7cf00b0017f9081a3f7mr17730445plw.3.1666336601644; Fri, 21 Oct 2022 00:16:41 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.16.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:16:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 06/36] meson: Move CONFIG_TCG_INTERPRETER to config_host Date: Fri, 21 Oct 2022 17:15:19 +1000 Message-Id: <20221021071549.2398137-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-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" 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 1ec3f72edc..64c87d45a5 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' @@ -2507,9 +2508,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 Oct 21 07:15:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617116 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp789692pvb; Fri, 21 Oct 2022 00:22:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM51FEOUY9kjX5Oj2UFl9zi7DgE/wpLvRXAprHJQnTscYsegj1fmlGcERgws8BP0v33EUJRL X-Received: by 2002:a05:620a:2849:b0:6a6:5998:f743 with SMTP id h9-20020a05620a284900b006a65998f743mr12358148qkp.757.1666336961844; Fri, 21 Oct 2022 00:22:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666336961; cv=none; d=google.com; s=arc-20160816; b=mSYH3v15hQ8H3bdSLRdE82pfhdslu/kplxcCOP6A0za8Yhjy5l1FD8J4koH3dutgP1 Hlzf3JleyYbpeEdNb8EZSS0X5CnU8VIVTVFMlc+HgHLKILxu5gi84NminFdefuCUpruW Fg/P62X0i640PE6kBYQrTiLnNArdZNC/PAP36mAAACI81KFTruJOM8L690aAyGc58e3S W2QLP9Ue/baqBUtOdw0jOm19QLD4kEt9gH9D9iVz1xpt6avFVjbhHcehrWL80LSwydJT s5OOm833I9XPw7fR3hJgvUzw5aOzjMK1G4Q1Pz6hY5jcfAaDc7CYhA9BzGXh1NQvcPql fZWQ== 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=6W8q5KR3SkNfvwFl20KCGR9C9fb12M8X2VM4t5Cdh0w=; b=XyTKsA4QwkXKpg5esOVczTDLNIbQ5zhaTQiAn/7TEs2ai2Fa0jQSTrHbCyq747w7fH 7L/lkBgbO+qURPkyqZWBBgd/L6ViNVr1X12WfDvIDzcrOEhF8PmmVzv86h8SacRjrTTg 38nJtAS9uoI2Uofsr+JoQfmQ/OL9c8wmKtsDrL47xrHag1S6OAI81CUSdgPw3PZ+lrh9 Klg3S1ljzGn4OQ+fAY9ywfxY6pLTnFiPhZqpYEKrcsfIvlJDsmbxMjds+S0PNdBc0Uxc ys3XhMCQaQVCQxK1nQlGLzTLD9I3Q2XLiO1PCHgOujQ4t+mA2Ve8pPoMIg8xv46rKLu0 Bvhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tS0xUprr; 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 o8-20020ac85548000000b00397dbfac7c8si10835533qtr.437.2022.10.21.00.22.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:22:41 -0700 (PDT) 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=tS0xUprr; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmMb-0006lw-4p for patch@linaro.org; Fri, 21 Oct 2022 03:22:41 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmGz-00033h-E3 for patch@linaro.org; Fri, 21 Oct 2022 03:16:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmGt-00030p-HW for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:47 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmGr-0005ex-Nl for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:47 -0400 Received: by mail-pj1-x102b.google.com with SMTP id a6-20020a17090abe0600b0020d7c0c6650so5895325pjs.0 for ; Fri, 21 Oct 2022 00:16:45 -0700 (PDT) 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=6W8q5KR3SkNfvwFl20KCGR9C9fb12M8X2VM4t5Cdh0w=; b=tS0xUprr9gCTyINl1r37qzNjSF4Ye/NyA3opYBLeDgoXjKX6PWh0XDgshZNl7ERhZD /5MAWSc1cNR1wrJbEC562gm6jT2IExdbKbBs2sBNFcRkuk1rrLBkZyxlNQ+GFiFt0oZO 0KV9JF5Db0P4LWn79ZzlOVPiItyRpMuma5uHOCKY98hb1N97gLS7ha4udhET1HorC5Z1 2L+HcO07UwP6hGBbXtKDGXnohmlU2zkiyQuwKW2Ft5syjkn2xp6v/wVkXNkFcKHV5yCP L66bFjIlXbAxYzvdcvqq9LFZYJRuTqGYdEet+ov3dpNmcseKfUeEbRTCavP8ydRjfjUh aRbQ== 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=6W8q5KR3SkNfvwFl20KCGR9C9fb12M8X2VM4t5Cdh0w=; b=ZKPiKPQFu/rmgsMco0JoFzczIlFXRkxaGN9BJlq9zw5Q3fE5Yy1Wqj7I4/1IZMTgAa 5KL47irnSuJqXnJp/L/FzgdEY1cFy0y2tulMYlCNXTbOkljRX561+MmYmY38cJLWZ0D5 OBRQ6WllIdGEXiQo0ECOITJJQvDaDYGLSK5sqAGeA/+60d4yfPWQwC5XFr8We9CgsWXp YllfMsmElrNI7jh03EzLydpt/ku4GQfWRpguzLcjbU7gAw24pdhtcK5nnqitoZm6LKZf 89Gk3+NzfkNgdc2Z0OY7idYFsHfyMvEncvdDG8TzxeA4XqjM5ZEQqLQAumv/bSLc1hHN 0XCg== X-Gm-Message-State: ACrzQf1DMFFmvmnwY7MNgvfDr65wWtezueJQ08ecstNBi8Y1ElCB06ZB drNGd+K6Bcdj3CI1LJeIiTHeGzxSgZGb+ldO X-Received: by 2002:a17:90b:4d07:b0:1ef:521c:f051 with SMTP id mw7-20020a17090b4d0700b001ef521cf051mr57566644pjb.164.1666336604368; Fri, 21 Oct 2022 00:16:44 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.16.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:16:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 07/36] tcg: Remove TCG_TARGET_STACK_GROWSUP Date: Fri, 21 Oct 2022 17:15:20 +1000 Message-Id: <20221021071549.2398137-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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" 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 e9ff3c92e5..6c4f949c85 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 Oct 21 07:15: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: 617117 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp792699pvb; Fri, 21 Oct 2022 00:29:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4aWsStdVMLZs0JOeszRD3dapqk+3OJQSXbNzAIVVC1l+Gq0c58tB66fsbmkzTyNhG+Ss1d X-Received: by 2002:a05:620a:424c:b0:6d9:7c3:fe1a with SMTP id w12-20020a05620a424c00b006d907c3fe1amr12276040qko.197.1666337396106; Fri, 21 Oct 2022 00:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666337396; cv=none; d=google.com; s=arc-20160816; b=avAuOe9BTb1ze869m4CtHDtxTyaXDaZwKabwR9IsoU2XSSv0OocAM5/0V3r7msN2k4 Ox9kCWyWSdO+sdrJOc1DzkZNxerkDbZqHrpn3LBdGNBMvuZxb7Bw8ZdFz8OXKOCZl+ai FG5TAuSnuKVo7JxOQm3U4UVkIM8rTXDsaX7TjDaP+KIkyurOBwLR/Iur1JA2oyGVdPme w3jMAqcdwJYKbQTTKH8VV7d9BV4CvJBNmTzCnwNEa16XnrGluRo3VegZpdeKeguq+RWW kLXn+L8ZMAHT9c9zp7X4kb5F6sBbHpxYsTm7kFjmoiNI8u3PRv7exBoxKw5JFRTvPOXW 9Q2A== 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=gjjYr4EVoJfjYD8KnAL4QCtVaNgkj83rjDO3NQIB4uaPs0OHsuQk+Yg9b4eJdsCyQ8 +DCv56+f7gKgEIE2ons1jUaGZQWPAS4lklRcNxp9YizDPPLpn3thK0Qy2m+JrorVJfYH TI7lvxsJRZC/XhGYNaExc8s9V/0LcEGQBQmAKB4A+fpboB9Ni44I4T2tJZP9lAf0RGeD dDShZhadUpJ7EvXv0RnNifU0pzc377oKwPYs9ivhZ3nYBXQXbRXm39SzH1d9dDkOjd3k aZa3LvQIL5f6Xyqa/wdm0+VNFmwPgZGwo7A0LsLmZCQ6I51todAe2m0idB7S2OS1in/m Jr4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EfeGSJN5; 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 75-20020a370c4e000000b006cfb0f21728si10938371qkm.230.2022.10.21.00.29.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:29:56 -0700 (PDT) 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=EfeGSJN5; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmTb-0002mw-HC for patch@linaro.org; Fri, 21 Oct 2022 03:29:55 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmH0-00035D-VP for patch@linaro.org; Fri, 21 Oct 2022 03:16:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmGw-00033y-9X for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:50 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmGu-0005fK-NL for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:49 -0400 Received: by mail-pl1-x636.google.com with SMTP id l4so1565481plb.8 for ; Fri, 21 Oct 2022 00:16:48 -0700 (PDT) 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=EfeGSJN5LIhg5P+Ac3FuxmvuWKqRbCNdRXXzUEEng4lzd0Dnc2SBJSjZEcQ7xZRHcV NVNeThNK+I6jEFlXktISA7aKos0ENj1/t4plNIckQHdrdapFPvfeEBl4niT8Ud/eyfqJ 6bNuRChAEYNbk46dhkuE6PhXr+O4bJXke0JdZwCksIigrYD1t7KOxScJFvsYYrSdIaUj JqixMuF7Wl4LG6t05FpuUfJqgLb/dPD4dXjw6zlCL7KAF+JG1d+weSlto02bBy0lWc6Q G3BUiCcSmxLlF7s5hBCfoTCqTJrcf4P9Ph2UDQmkmSr53bmPRvKLatNeiVaw5D4j6mJJ oEPg== 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=5VWhI0n2EPn0YXNuDBVMlqzlDuXlAfapAQ2gNC71t4Z3a3g63gPkxFr9ZwvelTPnCT /rRTs9hnwLgsR878VQ81zsXsjnX0aUBg/OfI7MNZeTGGF3EPnvRKQOxxVe3+TSqfdaEi 2es8h7vXESf7WuFOzKa94YaSbLMkSZ22V8ZKzAzKT1tqD5vvz8dWgJUNRMfqy/FB25kM M9Z6ZLbLRITRJ5M/nmBSRyBoZLBetjVizGAsFJ8JZ+J1w922tdIIzpAKAex5hoKhD1bn MMC35wpL7YVJMvg3GJW0+CPKXlVwI8VtvjNUT3Ik/CS5bWTroriFRybyd4aIys4aLcBU EMUA== X-Gm-Message-State: ACrzQf3ble+M0IQgUAZ7WyvfkGHxlpHkCRqFOr377mioyqX/Kh+Aj7FN vccjU9S69zDCB7wrvuNKcPMRR46+dtfS2XNv X-Received: by 2002:a17:90a:4607:b0:202:e22d:489c with SMTP id w7-20020a17090a460700b00202e22d489cmr57407036pjg.80.1666336607257; Fri, 21 Oct 2022 00:16:47 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.16.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:16:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 08/36] accel/tcg: Set cflags_next_tb in cpu_common_initfn Date: Fri, 21 Oct 2022 17:15:21 +1000 Message-Id: <20221021071549.2398137-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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" 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 Oct 21 07:15:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617139 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp820664pvb; Fri, 21 Oct 2022 01:32:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM76WpMEWmS9asaCnlt7Qiftd52qjVoY95Js59JMUKtFDCGDiszFBHNQgIkvdkcL1CHzpWO7 X-Received: by 2002:ac8:5702:0:b0:39c:f612:29b8 with SMTP id 2-20020ac85702000000b0039cf61229b8mr14819113qtw.68.1666341140516; Fri, 21 Oct 2022 01:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666341140; cv=none; d=google.com; s=arc-20160816; b=QAkvzszvUKxTSiY+O+GWuwDrvqX29KRXODlTcnSdFdIyMY5qegfgYEVTJeRMpWMnap idMZ+tJDeQdGQbD98wcnwJpdBHK1ozsoAB9nJnFDPgCxl+UxxjcO38AWtc94AYYpx8OD fnUPcSrfAm5BP98qxjeFZknO5ldVtvTjmI/PSiHl+RNO2AIZJ4XE+C6k5WWQz6kl+E+u kw1RCL+mxPqLjAMgFJOowpqhyreruTlC1d+ZTjZbxBJsN/AWf3RAjnbpy396Ud7yzufP nWkWBtFnZKPj2PGjaauoJGDHtJundYoxldZ5ighu/UlB03UitKBnUtzTdKOstX+7PcPj fWqA== 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=ffAk/uKFmYMud8oNMjB2hkT94GX/9Rmm5gafjNWj2X0=; b=02gLVkPpbpBVAXYyLKDAJJym33kS7RnOa/8F/KZBDndB+Fz4zuRtyyL1J690cl6g0d kWOSnplKm/6nk/GxAzKdCjGLAGls32HbSyuMVMvsQn7inbzS+R5kjJH7eDJ6KH6jrM2p XdkfdQkGV8KdMJbYtrkMOLywVY6pVjoWbjgQghHMAWsq2L7mED4yJF8do0T3PcyTZ/Yw +bM3rwscgv704+421z9f8ubUY8Y/LkcR2tSe8WgBZNg6aSeCA7ZdiMw4ZOeh/lvFS/Au I9WNbbCHjJmjDmYdY5kbuBYaW3QHGb3LeVOu87JWWWSO0a3Ir1pBfBUW3k2VlSgc6IfG 0ASQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wNFTdlBq; 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 j3-20020ac86643000000b0038fbcf8b10fsi11257181qtp.745.2022.10.21.01.32.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 01:32:20 -0700 (PDT) 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=wNFTdlBq; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnRr-0001V7-Rw for patch@linaro.org; Fri, 21 Oct 2022 04:32:17 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmH4-000371-GI for patch@linaro.org; Fri, 21 Oct 2022 03:16:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmGz-000367-16 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:53 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmGx-0005fo-Ba for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:52 -0400 Received: by mail-pj1-x102b.google.com with SMTP id t10-20020a17090a4e4a00b0020af4bcae10so2013371pjl.3 for ; Fri, 21 Oct 2022 00:16:50 -0700 (PDT) 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=ffAk/uKFmYMud8oNMjB2hkT94GX/9Rmm5gafjNWj2X0=; b=wNFTdlBq9+piNNR1XJEMvpJZ+1rT/udqse533tPPSRGx4/cHnV377I7kas5GLAPLBt ox21l0RDoe/w5weqfreggNJUACq5idqdh8pTDwi+6wxEMXkBEj0oeD54kOoJPCkn1dap 75Hy8yBhLVh4/Ipozmwpx+kgaLI+LFyJ38m0ZcFNkcFC726W2meb5yjusoZlyvk7z6bs e6UySvMM9rC0cgDRthQxhqFMiqPh4pgF1bmUKwu2TkVSvJ7g++bc60hl2y7vJxnZs6tK OndTZ8FCoTGcSBR+DUhNTG6FyDRhJANDGE5In5diEKbhMFoQxDVkt0JvmfhNiegiAyCf vDKQ== 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=ffAk/uKFmYMud8oNMjB2hkT94GX/9Rmm5gafjNWj2X0=; b=Wd3gzutEr19aLaq4aDgcwxCKCcEZ1t6wRL7XhxP7Q3s4SukWmeXoS8yE06xN+SoWW9 lvRxhD25C1FrH13aXLj1caQy5uUCPho5PMAkW43ikdhG9CtzaGxz79NX5ZCXjGGM0ukI KguRdlgP+c153UIDsFYP8AsGzW3VgjOLXKj932hEpb/fO37PyOPc71+lNaqaqYxQUkJV 79GZqGVOf3k+9NOhSsg9gfHBdaEeppdpfzo7q+ExEGxbAkGIRcuseNjRlG+pdlvxUhdR ziaYMbO5Uk2F9k8hkXARyq9Ulc3BK5Jv7xFYaqprYGEEkkhMd2Sb72jsnYQ+5XlDrNds bbfA== X-Gm-Message-State: ACrzQf14Q0WCXNVyqZbW20Drv9mIwXpF3Q7g+a4QE/4t0cER59bs69gk OXTy7n4Vv6cgGCXMF8LSpRUK4bJs3gYXAJbQ X-Received: by 2002:a17:90b:3ec3:b0:20d:9da6:56c1 with SMTP id rm3-20020a17090b3ec300b0020d9da656c1mr21119024pjb.156.1666336610104; Fri, 21 Oct 2022 00:16:50 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.16.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:16:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland Subject: [PATCH v2 09/36] target/sparc: Avoid TCGV_{LOW,HIGH} Date: Fri, 21 Oct 2022 17:15:22 +1000 Message-Id: <20221021071549.2398137-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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" 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 2cbbe2396a..7e9631f004 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 Oct 21 07:15:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617140 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp821508pvb; Fri, 21 Oct 2022 01:34:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5EEeCsneZF1lh/NM4aWup8muehqUSiVk1pJZMI8EfoffFxFuNmairBLMOtp8luKsaNlCOZ X-Received: by 2002:a05:620a:4712:b0:6ee:d23c:326e with SMTP id bs18-20020a05620a471200b006eed23c326emr12803280qkb.340.1666341260680; Fri, 21 Oct 2022 01:34:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666341260; cv=none; d=google.com; s=arc-20160816; b=WgpTyLJh1VxxlcyhrhcijzIkdU69WM+4+vF6Gvzxlrm/0hHYz+riZamJyZb7UZC0Jw IKXCqGzUryTubi0xJBX10T8KlJ7bBixhhLbQ7+gvGA9sxNabuSS1aZx84nM13iaTdisT iao5w7QlYGDM6eMaqn9pnzCX5s/HatnZ6NV5yH7GpxOArdipel2jaDJ77gu9D/YKAnVN 9BMD3vuCRhsUmqtGdmJrwpQlGsKuyU8A1Vcp8XTiBkSSsVHdUXh0jnU0MFmrZp9BqDlH Hsx5/fwFNgisB8hoLCfNPeOzn7GhXMs1ejK/ZVPnDCsX8jQExQZWlrRBvFxGNtWIq1sW uPmg== 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=JuYObXlFmz1SmrGQdE1r0MOoxWD6WYua5nMC/+UaBVA=; b=YY3OAZSGriFbXNrOppwY95+M5OcuyLKb2ROpPmPQx+ZLzT8PwmkM2fHs5BGASZD0KK c1vm8p+18yejSBVa6qw+18FXDGDGi7gaoH9sMm3jOThp26RoXstRPTicZ1JVJ08lejEd 5Ih/dLA3OWk5B85iVd/Aio9s3Ns7DTvNI/O8ZY2CK523YXJSj/xSu6tcyhmBptqQuqjK zvVKRol2hA0tZTBD16z2lXEYSrr6HJ3SKwvGNr6AJuHLWlX0i8c7kuJi3/bxNthFTRRH bAj8p2nK3i3FVsrvy12J1Ekb6dmqK5D5/1Jny/77WmEySJteUBwP8Re+iZBBcbAjDPxg BKaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fNqdUS16; 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 t23-20020a37ea17000000b006eae0f39c0esi11693350qkj.549.2022.10.21.01.34.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 01:34:20 -0700 (PDT) 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=fNqdUS16; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnTt-00033w-CV for patch@linaro.org; Fri, 21 Oct 2022 04:34:20 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHA-0003Ah-Qi for patch@linaro.org; Fri, 21 Oct 2022 03:17:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmH5-00039P-3h for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:59 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmH0-0005d3-P8 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:58 -0400 Received: by mail-pj1-x102e.google.com with SMTP id ez6so1689430pjb.1 for ; Fri, 21 Oct 2022 00:16:53 -0700 (PDT) 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=JuYObXlFmz1SmrGQdE1r0MOoxWD6WYua5nMC/+UaBVA=; b=fNqdUS16CSPmNuUqAF51Na2aaujn8wyzVkoyTlQujG7W6D+887kBWLGgukONLCtCVP snNutcu3RSX7S5Ud/lw9ZKfx22XpsLDxeL0hEOPWMJ6Xq+jJsBOoUZhQcKM1V2wvI/PF n3l9OUbv0HKPWhlPRdkrFM0ixw+4sTAFGrwb3z0L4Le9dpumnU7Ko5tVGkNcNRFOmnUK lEWK9436B38Tpu3ejDBLqJpc/PEGE0n4yLC0v4FDzt2p/huFajx74WVctn5wwgIIUMyb j2qy2aq4+ZCKA1149POJOfLJpI1lTLPBoGG3lJm6terfSe0hpnNwFtAhaHQsBQIhnKtm QuKw== 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=JuYObXlFmz1SmrGQdE1r0MOoxWD6WYua5nMC/+UaBVA=; b=Vq6kRpWWyc/1MkTxV3sYj42Jkya/+KbsxJlTQ0n6fy6+8l/WHObMA1fa8CkC0ic4yu QGqHZs6r5e5IcuNgHsAx2nczUu/Nv/5al2/XoDpeUalWASBWhA15GtGMW1sJRIzbeLeL /HV71dU4iHNjFGr1/gOmfOFDJrsH/tpNI+9Dugbq+2DJgbxyVuoQJR4qxsGd/+f1R+yK gtoxh8WYSqS4DqhtmC2Cu1eCnLmYykZW3sM4spH2a5QwWKoQf2Cfvpjm5RoIfRr8HL9Q TYpT4IQPK1fr1iUFCwMI144bOCU5B5A9FoJM9USGY1e+OFeifpjcaTyMJ+fKvNuA6oDO /6OQ== X-Gm-Message-State: ACrzQf22pTqwNiEvxCfnjoLaNYvSqq/uqV8v9xXMNn0b2RQUAepCTcXh UxULC4gksobJpq5Eh+L2sAcbvNQWMVGcIC9F X-Received: by 2002:a17:90b:4a84:b0:20d:8953:5ab0 with SMTP id lp4-20020a17090b4a8400b0020d89535ab0mr55825022pjb.48.1666336612792; Fri, 21 Oct 2022 00:16:52 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.16.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:16:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 10/36] tcg: Move TCG_{LOW,HIGH} to tcg-internal.h Date: Fri, 21 Oct 2022 17:15:23 +1000 Message-Id: <20221021071549.2398137-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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" 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.h | 12 ------------ tcg/tcg-internal.h | 14 ++++++++++++++ tcg/tcg-op.c | 10 +--------- 3 files changed, 15 insertions(+), 21 deletions(-) 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.c b/tcg/tcg-op.c index 019fab00cc..3ed98ffa01 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) { From patchwork Fri Oct 21 07:15:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617114 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp788399pvb; Fri, 21 Oct 2022 00:19:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4o3uPe/sE/GaovbTaQB5wbfOK222H0Za2ImvDcXn2PkTnM6auOBJ9OBfFQEBOctLo0Exdh X-Received: by 2002:ac8:4e44:0:b0:399:efde:98c5 with SMTP id e4-20020ac84e44000000b00399efde98c5mr15038348qtw.640.1666336794812; Fri, 21 Oct 2022 00:19:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666336794; cv=none; d=google.com; s=arc-20160816; b=lrWm8qCE0KpHnfvLR7sonIiB10j9gwg5NH6qBxk/iYh8X8NteKiGFfEIhcQJDOPXXa nRiFg+b6fBl/0PDv5EjcqWqXGdu7BEXle8kslGf7klTNF/KHKp8/F6768TjJEmVqZ8iK NlrhHmVOhiBht4bi1RNLUXe88Zjm/EilxApSR8qHD6PQ4yhYfbp9s+oE7V00ttoWfC08 uQIkp6mBdfhvqShQ0zPLwN6adhKZGEkGXiY+k1xqYUploGSRJ/izafr+K43x4oY5a4lj bW8wlsHrQG2SMQm+1W/3zxg/uKY8Cl18l5a2ovlnAoA4exrUi6bpOpE5bxTxnRz9aShp gvew== 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=L8z30GASyjyVRHVSC+j+Ssl7AGNt135XvRhLazZAsug=; b=Z9RKVk/+lkO3SAVgAEoOrWINjlKthPV/ASlt03kTpWWgaW/5MAK5DJObb2oXwyfv6P CBPM1gTtyM0IaTeNtZDB6MEzAR9z/aave96hmpGNO8y1x8DjB20Fo7X2S+Fzvt7mKgZU EgRkyZDE+sxVAgI4TZX2ctm3w8bqKfSV+gFQzhlxnd/zcQmM9TurLUiDIAbJg/F1v0wz peX4+frJm41oFvgnIPumkMILzQudIimLhSmrirMLmu8Ay250U5DZ+ydIdL58UyAo8Jz2 1JhfDSH+WJ3BaPwDq6NTu586hp/WVXHaNu8CwdyGir1C9e4sT8x5OIEqudeUXkozM7+o 2RLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BJFs+JcN; 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 i11-20020a05620a248b00b006eea26123b6si13627477qkn.531.2022.10.21.00.19.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:19:54 -0700 (PDT) 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=BJFs+JcN; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmJu-0004X2-C0 for patch@linaro.org; Fri, 21 Oct 2022 03:19:54 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHE-0003C9-Uq for patch@linaro.org; Fri, 21 Oct 2022 03:17:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmH5-00039M-1Z for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:59 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmH3-0005gQ-8W for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:16:58 -0400 Received: by mail-pf1-x42f.google.com with SMTP id i3so1784917pfk.9 for ; Fri, 21 Oct 2022 00:16:56 -0700 (PDT) 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=L8z30GASyjyVRHVSC+j+Ssl7AGNt135XvRhLazZAsug=; b=BJFs+JcNM8Yh+Va2bMuv5w2uKT//TxeggMLjakhUrUKh3svwR1fqajAScoBtlJWK5b WeBBeriP4NQ2k7X72SY7tQViARtUx/UOkrk+YqVxZ8NU+NmQf5jALH+/bqcJkcrT2IJi Dy9GdLULUgWEnHZnaY1LznK8PWVo6teMKlOAwUIyUJCGO+obfV34vz529jnAdL+fWCI/ +sBIgxr0OgwN95IxJzUsHPc0DoyFJKjy9YFXT/Vgx9QQ8PKAOoz/s3W0enDsOGrd/+HY gBfXcfdXRN3LxVF9BaGbiN28RN4sdfBtdgpvteQdqAAxofFKhc82ltnzVlcRB+H1qW6+ BUiQ== 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=L8z30GASyjyVRHVSC+j+Ssl7AGNt135XvRhLazZAsug=; b=Xt2wDAQ3QAbP8fi2eGwANBEiy7qXeXBD6wlmVyZc3SPR/nVF6EyBk6EyHI+9+97Wsh fqs9/N4p8n25w9d6x7iNLe5LSEjGZ73G83J821jlOSI6F17bN4xB9McW74+8W+MbBQzo A+49JoB2tGBNJKHWGkYHOGrWtr1LXAvv/qeoWxqlqHw2DM54gVOgXVk3HjaiEU9Vy+5d PoW+sbBSsPuhXnZZ8ftfsy56KZW++DFgIP8QkdURljxejPjsRM0BwTMB4HKDPKLjrPhC 4xGDSanQAIr1r2dSHpcXG17rkmFBy81HVxvKhau9Us9Zfel+Fl9FZ05krp20d6VL2NyT 12dA== X-Gm-Message-State: ACrzQf3ZcpekNaAu8vVa4IUrwJnqGMo1BXrsGHFqcMA60wTqVU0pVxO1 LG0U6YOSarCE74c1h6Wa3J1xEWL9F2oCXum+ X-Received: by 2002:a05:6a00:cce:b0:565:cbe0:16c6 with SMTP id b14-20020a056a000cce00b00565cbe016c6mr17964614pfv.56.1666336615857; Fri, 21 Oct 2022 00:16:55 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.16.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:16:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 11/36] tcg: Add temp_subindex to TCGTemp Date: Fri, 21 Oct 2022 17:15:24 +1000 Message-Id: <20221021071549.2398137-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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" 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 6c4f949c85..135d9a9a0a 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 Oct 21 07:15:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617132 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp804380pvb; Fri, 21 Oct 2022 00:57:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7JuGMGoDJvFxoghZXLOlDzQxvsaNKqrSZu8nHrSDap7JkjSvIeb1n9KhtTQg8yc6EGJKq7 X-Received: by 2002:a05:620a:2015:b0:6ed:9fe5:40f7 with SMTP id c21-20020a05620a201500b006ed9fe540f7mr12262500qka.769.1666339029550; Fri, 21 Oct 2022 00:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666339029; cv=none; d=google.com; s=arc-20160816; b=egf/GAwTSA7wZQes7SZvY2LVgSzk/qoKXIXH5XAcjsIw8UrUKnNbB316Piv4GSvLJW lSHY4IDuSLETWPgxAW7l+Kcbed+1Yw9sac5oopoi6NI9jSvNsl1jNrgcTq1U/BewSs3x 7Ii1vRp+4rwD7vtLuz8dMKCr+nJZ9VkmhYhclzS1n9X02E/xXhQGUHveq/ajFJiJFSQB EDCIcGxLgHlK9H/f9kF0k0ATpvR6qq5l6znztbrykQHUABzkRTPsWjW+sxajDyF+AOFN DiB/nb6LCWMTyPF54scVkoLFUe5Q7d0pxIxR4HevyHFmq3gmBRhcGLdK5Ep3RMhHxIn+ mIlA== 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=AwWY0LmSatCRIwkg33bhhLxAFaDGQf8EaVCLJgJX9aU=; b=ftW+rYbe5SM0xkc/m7GRpPmT+HQqvcq4y6zNqqweojGDQr/AP5PRHvyaNqq+4yfHoO J5uEpvoG2qjkxuu0/fBu81g5TWUF+TovYi/s+TrWHTdYHhPYzTExWhDltU4SAs+yl006 GlkW2cxsXA1iDg4JzhHoEAqOf1ajJSXy3Lr9KT6qig274B8DIyW8C6dkpa+HRUT7wChD h1nalL1vwsam/TXblDDxLAy1lBLqReSAVXGuMsQukUbi2C7PV3vVS7DRHsG+2dOJ7YkC z/A5YTwJ+RphVE8EgythbN11Oc40DN+9xpAxB+hStdeFAmLPSyNDYfkX7eudupHpNbKv /+Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RUwyoiJk; 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 j190-20020a37b9c7000000b006be59d6b6f2si10703130qkf.458.2022.10.21.00.57.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:57:09 -0700 (PDT) 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=RUwyoiJk; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmtq-0001wW-RX for patch@linaro.org; Fri, 21 Oct 2022 03:57:09 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHK-0003Cd-Jd for patch@linaro.org; Fri, 21 Oct 2022 03:17:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmH7-0003Ai-OU for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:01 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmH6-0005go-4y for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:01 -0400 Received: by mail-pg1-x533.google.com with SMTP id b5so1801536pgb.6 for ; Fri, 21 Oct 2022 00:16:59 -0700 (PDT) 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=AwWY0LmSatCRIwkg33bhhLxAFaDGQf8EaVCLJgJX9aU=; b=RUwyoiJkbgSjWhd6l8SGRvriRE1hjRJlfuYU1qc5Ik606kiCjWQFUnYk+KZeA8pWrt rsKHTptNVUDsAMpgZYkYnPvC1A7OAFD+GMplcNakDTljb2KDCSuuxVezaYVQV6PqW70G 7unmG9fZHy9EDxnnwgh6M/h/zOkQf5pvv54BzkQWab55PCaVI1MEmjbgmjSoUXp4qe96 MS4YB9qpx48dk6jMoVrn1FTOZYcKr1VF7ZWzKrbuDp613kYwb+Souqubgd4SKyl4bDVN bYhydvfn6kdclXZ22+bt4A5WgQlqFzlfXgzLrZFlcJYfzx6JTt4GoZVwCd55Rt27udyg RAGg== 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=AwWY0LmSatCRIwkg33bhhLxAFaDGQf8EaVCLJgJX9aU=; b=7wJT+WeiArY3SIF1Y7BCegXnHPDXfU0kjpUgNno4WG8Oa2Z60LeLXBA83riTqBBCGC G6s6UBfGq/SiNOpp7b+GSTn/TxwTtOIp3wttDTcMtqm/mTARcbWMT7Skaix8v3yInnIP eoNIPVSptKeLtImtEfZ0dhU8M9vf+DrcdMd1WpafiQAyYYo7PNdlciSL+kuzHYaIbNg7 CDBDd6nO71vlgRWsL1ek+jaYyMj2mkURZfNyAtya6UEyu3ci1B/GImNgRwLiTllK3j/U szxxfDoWEhxhffdfdoS5OOVfXZxIDlRaKN/HW9Fuyv1yYUFC9EQTb3sFpDcM53BRiuF9 jtRQ== X-Gm-Message-State: ACrzQf1rI8pCjtwNfe58KoR65DR+DJLWftawBgZ9aqpTX88OkkdyTFTK EEJ7XKTgb64Rmth5EQhn2VevXvCNLI7okQUv X-Received: by 2002:aa7:809a:0:b0:567:6e2c:2e2a with SMTP id v26-20020aa7809a000000b005676e2c2e2amr14442105pff.56.1666336618558; Fri, 21 Oct 2022 00:16:58 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.16.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:16:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 12/36] tcg: Simplify calls to temp_sync vs mem_coherent Date: Fri, 21 Oct 2022 17:15:25 +1000 Message-Id: <20221021071549.2398137-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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" 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 135d9a9a0a..9fd58e46b9 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 Oct 21 07:15:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617124 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp799711pvb; Fri, 21 Oct 2022 00:46:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM72OAPl9FAn/V5ChIgpjdXX1WryFTiv7IOaSxPijDNYwU4Cotu64Kr6VTGeshfNdtC+j/wB X-Received: by 2002:ac8:5a44:0:b0:39d:d06:610d with SMTP id o4-20020ac85a44000000b0039d0d06610dmr5785256qta.363.1666338385148; Fri, 21 Oct 2022 00:46:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666338385; cv=none; d=google.com; s=arc-20160816; b=oFcIKvS0XFbNGAJkwbUO1XrgwG9bziI44P1KhGuZPKkCwD2sh54s2fEnib1iAjlGXl w7qB3uPI9dfvlTDBKY6s49WsTpqLrb9ls2gIMmN7ZeRHpQbYx15M5nEV9qJGqEQw9XGb KzFxhZJmpoVJOPOvfFB4g3Lxp3Cw4trz9oEEe3T5we/+0C6Di5mY+tPULK+2A+iHwM34 JZasaJjxu1qEF0T4pBonqQDJmIigY45CQCD+zy1wN6CSqVcdv+Us94SKdUl4KnavmS36 Okxhhoua0GN7x+dDNbGKyj9Kx/JZVQ49cfghnmUUPyp/5wwUhdVaCgNFLScnXXaSQSDi DVbw== 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=EHwHeycEZKxhFMLIOg3z57g+gF1F+0x/Q8WmhqVPueE=; b=dVxoaMpiDywF/mUgtTuPo6IoxctVT0ucjd1liD5ui8+0Qvlfo7xwCoIF/z7adUvQ4C GFiWdjw5nXPfmITLnntc0wJhjYYJ6SYxUH9D+1ZWGy8mnR8B/znc4vBkrcGjiM84j64Z ycAZx1o6NL6ZNl+Zgiyzv23YAkLCBkVIVhdjshe0HQKfXYsU5y1voax7WN1duFBSiHxy P7eKaqemTkmvMnVHvqa9eQUDMfOeQR0RdU/ava2FzZLl1LMlm7b4lazEov0N0YARiQxj /YeDado+IrMlnrf0u7NQs3K5xTN0GvDi+wBIu1RfMJuiyY+/V6+6NPV9XzzE4lh1P7ei cQkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sS4kO2CE; 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 i11-20020a05620a248b00b006eea26123b6si13652882qkn.531.2022.10.21.00.46.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:46:25 -0700 (PDT) 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=sS4kO2CE; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmjY-0004Q6-Ax for patch@linaro.org; Fri, 21 Oct 2022 03:46:24 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHl-0003JU-KA for patch@linaro.org; Fri, 21 Oct 2022 03:17:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHL-0003Cn-CH for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:15 -0400 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmHJ-0005nF-Hu for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:15 -0400 Received: by mail-oi1-x235.google.com with SMTP id l5so2285992oif.7 for ; Fri, 21 Oct 2022 00:17:13 -0700 (PDT) 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=EHwHeycEZKxhFMLIOg3z57g+gF1F+0x/Q8WmhqVPueE=; b=sS4kO2CEQGwTftcR6KEwzs2iQZ2S1ynFvV97+lAU51z/5KvMR4lJWlKk7weZD366fq sUQv9S5cVSMVxTo3xfA5jLEVrKhNWslhAeEB5TfYSyKkTM7KxHK3dAyFpxONbfIpB89R WkQFTNZQXuJLm8GnpppWictLC9ZcOmmObH/5O1E4jy3/nHYd6Tv59ynperg7CW8FTvn7 8TSujxQewWpFsyaRYlyZBXs/8R8CfnxPDPEf6+osiMBSK37rNtPKYba2JUvfIV+hoVwL W7iPElkAtFSU+6XCTQxOLdfA8IZRdlXwKEs9hGhCdUqcjNCG2R1y7vClweOk19RCW6D6 etGQ== 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=EHwHeycEZKxhFMLIOg3z57g+gF1F+0x/Q8WmhqVPueE=; b=41gWq+d6fJbLUP55Keh/QQFGDFDwYJKjU/HMHlvg+JJ+KXAX/79Q6TfugTkWyqCbOY To4WFVKFvzD1x+yQRcduRRl4JRnF03S6XBKSo4xu11G1JkGjIuICw9+wolAOJmjYGuXl 66OnYfkSEGhks/QZ0YiBwkMFAi2TbcVBr4luHQkanMMrZg84Iv2pelYIrEGe5E1JjXn9 fzheYKd3zLW20tZ+d+KoltqepyrbUM4GTlBqKTF2Jh5q927Fe9ELBl64h2A70VqXkLwg sGlrGi/pFYw1pnXj9Z3Mg15UOjg3yofHvOHD5vt/1t5kaikX+z8V3CF1F+9XvPeZkYiZ Qe0A== X-Gm-Message-State: ACrzQf3EnSdPh0I9n/+JkVaQYUI7shAfqBq35xJ8IfZKcfBmXl47hZ+B t54RSJMJ1uCz2as4HrU09Eenf24zWao/Z7ND X-Received: by 2002:a17:90b:1a88:b0:20d:8df0:ac63 with SMTP id ng8-20020a17090b1a8800b0020d8df0ac63mr52197225pjb.206.1666336621209; Fri, 21 Oct 2022 00:17:01 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.16.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 13/36] tcg: Allocate TCGTemp pairs in host memory order Date: Fri, 21 Oct 2022 17:15:26 +1000 Message-Id: <20221021071549.2398137-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::235; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x235.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" 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 --- 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 9fd58e46b9..73d8b33b06 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 Oct 21 07:15:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617161 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp840669pvb; Fri, 21 Oct 2022 02:17:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM58zTg5qRMqu0RXg8AmzCEyc/SovIWDBJ8xrL5CiL5YxtxWg4ZyMF3/oegML9r934qIDmgm X-Received: by 2002:a05:6214:1c85:b0:4af:9303:6d4b with SMTP id ib5-20020a0562141c8500b004af93036d4bmr15571697qvb.125.1666343878515; Fri, 21 Oct 2022 02:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666343878; cv=none; d=google.com; s=arc-20160816; b=D7GHEr5mIyVHkJn4ITJiNoGtykUP7kTqN63Iqs/sLZzO9g7Vf/oAENhrbXAIYHRBUU zhH8jUS3GtKu724PmIu79GspbE59Kik60ioBM2S9gCpjeC+cEa5y9rPb8EnV1af0HwWF nwx4aHFrim9lGHSYadtdf+J52ePI54VdT1fvuTMtFvJslNNujQ/gAEmT0yVkKcGdVDro HiaC+wo4o13act+imlrQplrH0ClG3i7sXXeD24YmpMlaLARyrccsmXnxAqR92LPz1vJx 3nx6g8rqkC24LEqhtMg6ISC91dETFCTsjtiuzgdjPkeAixrpSozaRzqwKc0CeeiMazJe H2cg== 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=X4jjFL2OUy04nPgptLMqSD82ASvQNavuRfnSXacyKk/F3Vpsds8ugeMuVB25jy6roa VPnN2DCG7Me0RzadAulbBQZ1BAYSsm8BFei9ltjQjgKwa658jkkEeasrp9uvhZSGctAz 9zI+ciO1xPu6Td6U6HoeF+BvjPN3LC4fM3H33PMIBQx4faPSZ6bQtKmkwWFwQj83ZXND /bhJcMuNmrsmnHDmCCICqrTO3Q3g9JHUZetYrsiEF9bPyitYqPlrl/5jOoqR96lRFGq8 WrzfmWtwjnhGTuEonNq1BDZiDIk6yH0GEhyEYitNfu9n2MjgkXLjynsx8r0ZndbNx8Jj N7Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aWiOU9Lx; 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 gc14-20020a056214230e00b004ad5e922f07si12413479qvb.563.2022.10.21.02.17.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 02:17:58 -0700 (PDT) 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=aWiOU9Lx; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oloA8-0005iv-43 for patch@linaro.org; Fri, 21 Oct 2022 05:17:56 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHd-0003G8-EJ for patch@linaro.org; Fri, 21 Oct 2022 03:17:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHN-0003Db-TM for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:18 -0400 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmHM-0005nj-7q for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:17 -0400 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-12c8312131fso2521955fac.4 for ; Fri, 21 Oct 2022 00:17:15 -0700 (PDT) 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=aWiOU9Lx4T67eUdWLOaIHDq++pP1sfM8xexmNl/yN19xZ5pC4hJj9c2PvKaYbsPqoz TgZH1md5djTl/ecR0pHLf7UohiyVfzmRuwtfbdZCQxr96Hb1jlz50vupvT5FcBtpI0cp x2CLX/de8o1YgAm6rAYp2x6HfpBZKT/kUk/mjsEXo+J8ZtoqvfyHThaBYVf3qH2p+V2Z kEHFVILdD/zAkZNeYZieMdobq+raP8jj1pro4n4ReaSspQzvNgl703YYBuknvDwD/2+T 2U1yw9ZG8zAF9nAfG8XZS3Dhb5i8GgON8bPfge+Q73iO7r+OSwM++SBt4OkLzomazX+H DHig== 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=z1N6N2QnRVuhSo/tlXSM7AJRXhuS08+vv4I993Ytg9QZpq/Wsntp/w1kRCrdIthZhu Vfo/cOdveDAqNnA+yje00CIXo3iIT7knvZAz45yK2dRvGdaQAqpNj7Fc2mMokCtYYQr1 pWTIUvQf2hDOScw6EIQmvcjZ48BZoDedTw699CHVQTOsJyUP4Q9N/nrGleA+6lqJsI5C wZqcUtvQ/sDPTa7x3iRdA/uqD0e5CijyFvxIcJzpwDyQ3phmWSFB0MUfWBPUcn28+H4p zCQiwVUEBEQlnYGT6EfOf+oJgZPrmY4kvVvpf9dSlxe/2xiUYFBieEum/M8cHt0cvNx6 Kx+g== X-Gm-Message-State: ACrzQf2inLBmE8j8RKY3wR7wKFpMKAy2ed+jgoqpr7lLkBXPzFfwJPZz kRKM171qro6hNyLKLkglATPArvffPRN1lgyy X-Received: by 2002:a17:90a:4594:b0:20b:23d5:8ead with SMTP id v20-20020a17090a459400b0020b23d58eadmr55276401pjg.127.1666336624385; Fri, 21 Oct 2022 00:17:04 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 14/36] tcg: Move TCG_TYPE_COUNT outside enum Date: Fri, 21 Oct 2022 17:15:27 +1000 Message-Id: <20221021071549.2398137-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::2f; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2f.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" 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 Oct 21 07:15:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617120 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp797904pvb; Fri, 21 Oct 2022 00:42:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7G8KSEjEwLDC6Ij52vPI7aKHPP0zGGvVuSIo7jeaYi4ITxMWSi47UewxTzeKJ87AtOo4eb X-Received: by 2002:a05:622a:83:b0:39c:fa14:efeb with SMTP id o3-20020a05622a008300b0039cfa14efebmr12813696qtw.643.1666338153543; Fri, 21 Oct 2022 00:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666338153; cv=none; d=google.com; s=arc-20160816; b=aUFU5MP5cJFioyJqr88OZj916QcxfoM4HY+NTm6RjKqXhAyV+9+z1junm4lgIN8TG3 UVirAFBXX6FPHb7yYKdIpvw+UlYdCDqciVCCFvgnopDt8gul4EpPX9UxvzeyPWWX+o+2 9c3bpVzw2Au/WkIaOlvlDzY/dp3s+v85L+N1X287y4x1L0qafJwLzR8vbuG/1iv8HAki udRg8t3Dx5oN+vDSRtPsDwL5pBEhh30xPZekWD5GkzLkczcsl25WenfoR15F3o4dI0l6 QebiLvR/ALTj3X5vprGpg9N8aiI9XBHLKJn/HyCwhhC8Z1x6gQ0qTUOwNjreJnvwdZdL UmeQ== 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=JONxt9CE65pjWaD+nTpNlKjL3nDuRwB7r5QiBKPwDCY=; b=xnTLc+6hWgkrjg6d2x5lrV3/LRepDhHQpVVIbQR6sh86aiDoAK0OxDB+vMHEjVtitG cEo7UUzdmt2pcetLfECYqZUNRhJX1j2LryldGWQW6Q1xNkwnkJa1lVvNb92hJQmsRAjP 0ghkImzVem06142OYEOoutNpL066gSZNE+xHGC6TPQqn1Sbem2hJR6l7gvTpP74lgyit sB3SVYVNlnZ3L6p9qKprV6zeRRmsObBLsc3x93b6G/h/bCvrva1XKeMWgPCiy+7k2FtC heybidMiPU6P+EyYkEJYDBCbymyCvhebZP8v4KZzJSlc7S13Ps0gCxrNeSinq+6yZUtw V6Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VABAGKaG; 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 k17-20020ac84791000000b00399cda33e61si11175526qtq.511.2022.10.21.00.42.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:42:33 -0700 (PDT) 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=VABAGKaG; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmfp-0006Mz-0U for patch@linaro.org; Fri, 21 Oct 2022 03:42:33 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHU-0003F0-EW for patch@linaro.org; Fri, 21 Oct 2022 03:17:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHG-0003CH-BJ for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:11 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmHE-0005kb-Fv for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:09 -0400 Received: by mail-pj1-x102b.google.com with SMTP id i3-20020a17090a3d8300b00212cf2e2af9so854516pjc.1 for ; Fri, 21 Oct 2022 00:17:08 -0700 (PDT) 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=JONxt9CE65pjWaD+nTpNlKjL3nDuRwB7r5QiBKPwDCY=; b=VABAGKaGx25IkbEfL0YUAnzAlz49KNPSwdhSN8lORyV5W4oMvfl237lql2virU41US jinc/H23DO4NskLnEamk54jreoJ1AYN7h2L1XZAyDQeDzJCgHnMxGuZcRBe+ue843Lo3 1zgMatg2W2t9XzCfY0UdozJ/mTPevHP4bPIF8cGWff8APMKAyAbdQjwxxlnt6oeupBd0 1QOYJC4lYbTOyapP5DqE1IIipyMc05L516aE5cLAOHuWtN/EiDZcQ8wDomlaKtCtqseh bqFSzt/t0cki/5nptwX5K1RUd7ODevRojnn01X2Ak3Xo6pmXQauznqBX10zZWjSFa9Hw R/JA== 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=JONxt9CE65pjWaD+nTpNlKjL3nDuRwB7r5QiBKPwDCY=; b=vpZ8+mwO7inLFPczGalCXbfNOLgybsjtDmaAtUKXEfTP1OK10CO8EBs6/1QFCMlSvj cRL13GZxvBNyAHiFZcn1F7tbiexmM/FJ284UPLue4YNHAYrdLDF/F2zaGPMP1GC3966G RXg5aaDpzbs6FTgSUzYi7Hz15/2WMDPuQ330Irz0VUOdxCe6OgkzeDljMLBZF75HzP8g 5A0ynT1yAY8aovC6TSxejuQgeylqVmZGQD0rMnQupJN9zwwt5EtZkA4ePwEzjbz353pG dvqk4oPaLYFENl9IuBJI0v3dxx+NNOlX9ZKWGk/age+uJQmLG1Sl85cW7igCdAX7SRB4 pJKg== X-Gm-Message-State: ACrzQf1CLoOB9n6W0ilmgs+V+jyzToApSBxb83lN8wktrBNGQtK40/ku MxFgVdqw8hHTJ5hdQZ+UzOiHKe6U+sFMWm6G X-Received: by 2002:a17:90b:4a0b:b0:20c:5ac8:1e2c with SMTP id kk11-20020a17090b4a0b00b0020c5ac81e2cmr20417930pjb.98.1666336627030; Fri, 21 Oct 2022 00:17:07 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 15/36] tcg: Introduce tcg_type_size Date: Fri, 21 Oct 2022 17:15:28 +1000 Message-Id: <20221021071549.2398137-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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" Add a helper function for computing the size of a type. Signed-off-by: Richard Henderson --- 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 73d8b33b06..48b517a856 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 Oct 21 07:15:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617115 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp788621pvb; Fri, 21 Oct 2022 00:20:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5hwhKgE099C3wwgHWTMlrkD8j2AOii7tVe01AKQtwvCmVKxhcBTSC7XBMjB4on0zo1YrOn X-Received: by 2002:a05:622a:1a85:b0:39b:d3cc:4714 with SMTP id s5-20020a05622a1a8500b0039bd3cc4714mr14974977qtc.310.1666336823234; Fri, 21 Oct 2022 00:20:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666336823; cv=none; d=google.com; s=arc-20160816; b=ITCpPb7h99QsNlPj7wYqjUvujtkaM8DB/w819HdMgTLrzTAJna9uxvZEoZObtzg+QO YUnOzEar3s7/KpVGfqDXi7XUjTkkNMU0RNwLn1RgSM6a0BxhU8Wlt3h6LwPlRsWlBPUz K1wldUBOUyoSHnblidjssFqxCxDIwR/vN7Ud0ncFcn7Hh+V68ts3ws4Oha51+ekpYrjN XHcrVQegtEqJV1JqT5Hh1pmJMKx41+H4rTuuYdoIQbWZQgyb6qCCK0tPzcVR3YGx7kvU poQGkxg23GIXfOlxoM8kehHp8Y5fgkwdYy+EzfkKm12rrO2KtWXRh4UBWeIou6FDZFMK 3Iag== 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=wZV5YeKWqXa0RRg5AiGpqeFNkrkfjYznGj72I0asKj0CnGGi2jioCttMWRT5vcd8WL UVTcPYMJZbhK2QmdOyik98fgH6B+9mDNTa+nEUnzQAClB/qG85QCAWjD0iJ06fdfvfcz Us2kr02RTe89qruatssUiR27kUFFshF7VSGLjdhw/Af5tMAwoNPGAmEIoKbydg4VjSST jhidYypqGqTxeWSw1sXJQwdcbgQ25eub/1SLjkSIlaZvtvFsa9ES10o4OMXX82dzSnar 3gc4ZRRB8EaKNGgl0aMwYFQJoow4AgHG+PvyEgaHwbz/owkLJx3tBcW/74P9mVdqslm3 QTFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o56kSLLB; 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 a5-20020ac81085000000b0039a372fbaaasi11277531qtj.32.2022.10.21.00.20.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:20:23 -0700 (PDT) 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=o56kSLLB; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmKM-0004sg-NW for patch@linaro.org; Fri, 21 Oct 2022 03:20:22 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHT-0003Ex-Jd for patch@linaro.org; Fri, 21 Oct 2022 03:17:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHI-0003Ch-Gq for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:15 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmHG-0005lv-UM for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:12 -0400 Received: by mail-pl1-x635.google.com with SMTP id p3so630944pld.10 for ; Fri, 21 Oct 2022 00:17:10 -0700 (PDT) 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=o56kSLLBNoFLwbAZl/9+QyojBjnZvDdrCEmWB4pFQbqQchdoTaoYJtrYZ8SRJj483s 8rWCrqwI38t/ySSTp/WgmRZ8MNUwC+0BqKCaNNxklIWVhK2YzvzBGtkHQiDFBpkNJTFq S583q8HDufFOMGDxB5ykaq1RYd5cS29jch4hPxXZclyandvA7PBR57fQgDAmBSRxr00W T/i/wNJf8aEbPf12hNPrKjT90nEgWZ2X4YCqZr4uj/QdEQX4YF/VZwviHdXcVkNy0GAZ zXwqByciq3f0aKxU71rKkAI2U98gWp7TGhZ/d4mUCaFGArInYrO6HtFY7pTMttAo+cG1 Fk/Q== 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=Vcw5H8GqEkcfyvLsNFqdvx6vKqP3JcMOnDWz35liqV8vNqe1cpdYdURPrzPXUyQjFV k6iSqPiG7qVIa8f5qLZCRf7bJx0U+OQH52kIjFCzeIGRkel1ewLhDYIQqSoryxfCAP12 UBbUorfPPRESp9yVp5JbXI4zrV7w7q9xQBYXxFCwy3HZQi+5dU038wawRPik1aNrC90B DN5R/Rgmt1ifKp34Ynp47LZJfn4HGgzSVUkv10WLXc+1z1Xda55xjSnjQkBZ8gqPybXV EpINyzZuULWkukkXrtEar3vjpjPAh6rdT8708/f+axdnHeGOtsDGRxHTESb6d+AXTU2K qenw== X-Gm-Message-State: ACrzQf2FTse5V0DKRTIW2W+RNFPndID50xRprjXaNVgyYGc9ZTbe3XtZ Ufl+9y4zFPlV7DEqtl8QXA/T9yjiduBpLiIE X-Received: by 2002:a17:90a:4983:b0:20a:9509:8347 with SMTP id d3-20020a17090a498300b0020a95098347mr56055297pjh.101.1666336629452; Fri, 21 Oct 2022 00:17:09 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 16/36] tcg: Introduce TCGCallReturnKind and TCGCallArgumentKind Date: Fri, 21 Oct 2022 17:15:29 +1000 Message-Id: <20221021071549.2398137-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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" 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 --- 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 Oct 21 07:15: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: 617142 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp821653pvb; Fri, 21 Oct 2022 01:34:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4OLW+hOuLcqY9I9U94tq6ZRMQ7BIYpUXrrorRYbpudijif95ODgRfQ2nIStSX8lxuwvsNb X-Received: by 2002:ac8:580c:0:b0:39c:e5fe:63b9 with SMTP id g12-20020ac8580c000000b0039ce5fe63b9mr15449515qtg.314.1666341281470; Fri, 21 Oct 2022 01:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666341281; cv=none; d=google.com; s=arc-20160816; b=0LF/mJ1rDpOUdo9mtmvUJTmEp6XXLE6dFQJkej/Wu9HcFh9k7HrEmB9LA8kqpKC3zu yR6mN0uaCC5KKZ5UibOg7CtBJFJDGeu1a+u/vRBtY8aeB5wKtf7DF153ROYgKAbU5z/2 02lr4XwcJiDAsgyXAsNaaHoBrX+5jLmmHy+cBUlU5VP2xrhwLx0yo2IV1CdG36zp0Ns2 aLbP74W74XWC7uo0Yr5lhC8AieC3Lb8Go6jvJQWmSWU0T0mAqx5yk94+r/1iKivVyVx7 g00RysEoQxpQcETTUGgyzQEIrxI7AMjfVZe1dbpIOMrj7+uxB6eZcq9XWFGsIFeoUWF8 AeZg== 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=NLYEAygg5zhZY8+MbyEmX2kcrfhvOHFDC88V+mEh+NI=; b=MUcE9NkGK1uNj3TOKm0wkAxEN8Xp3nJ7Wg7JIC1vAPSkSzB0VTTZgwyoBAuVpeX5aG mo2m2tASz0E/9qPprLkpN4iLQZial8O5D4HGcHMCJqgIh37ROs/FJ7zZMlP8sipDhFvC 0yDhPFlDdjxyqjIoKqjc6Wvomv57UQB2Hr+TMRFvviQhhAUyoOtCV3pudr9vQtWxZz2/ IhHiWg5h54UQTUsxflAI+Q/tfIJQx450X6rbVerTKCLz1ot7jJ3Cw3VcXV4vyG1eZRVj 5D8F3Zqj7rF1Ot2zk2Zjc1FibhrLXJ179tt6Mp0UpVjttVZjvioJkFAFAZ9dS37NtQ1b 0Sgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lOnE8ajt; 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 m18-20020a05620a24d200b006ea2d6a25d1si10711317qkn.414.2022.10.21.01.34.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 01:34:41 -0700 (PDT) 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=lOnE8ajt; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnU9-0003kh-Iy for patch@linaro.org; Fri, 21 Oct 2022 04:34:37 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHf-0003H9-Vl for patch@linaro.org; Fri, 21 Oct 2022 03:17:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHL-0003Cm-0n for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:15 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmHJ-0005kb-4O for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:14 -0400 Received: by mail-pj1-x102b.google.com with SMTP id i3-20020a17090a3d8300b00212cf2e2af9so854711pjc.1 for ; Fri, 21 Oct 2022 00:17:12 -0700 (PDT) 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=NLYEAygg5zhZY8+MbyEmX2kcrfhvOHFDC88V+mEh+NI=; b=lOnE8ajtZqASbxMKGR5GUyEL/vBzYgGa0Bm2xwfvCGGaRcq1tvXTs8zWBWtkBKHMBG kJ7cN8udI5ZOM8IloLJJ0sLB0Rd5RlmCNRaXbZ1k7CB1Ghsw+hedDOMfMqa9uBbn+pTM GCwEjKrgUnyhkKdWwK9oi5N/eN4l7hF5ZJnhray/gD0lgZ1EH++Bj9fdVoDeaiR9xGUW GXvyKzKH5wxII5LNfm6QfEXo2PvNi0IhcZ80mXe1T28prC5iNBrJyKnlOgD02lvbHnA2 og6Icx8st4sSZc7CrLYhEcXPiGqx9rFifcfRd5KR6TRZO59WxC6mFvsRIIoM1hczrwsf neCA== 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=NLYEAygg5zhZY8+MbyEmX2kcrfhvOHFDC88V+mEh+NI=; b=YZY8ZjkJHUSrDrkFKeCk87llW5ZFsiTsBdytfmyR02EWjwcxILlmXQPrpAa9JKLzgl /FvKS3W5qsFfjNk5VDOv2eH03pE3GtFCruDb0/cG+U1OrU1aeVeUNHBAQt4gL0RCgWjY 7dINqAo3YzRHIEe6k0UMOcpLI2Vz+JAT1FJ9YMSOrFt7vkRE9VxSS2qcvGoIhp1aYeC+ NoneBQmPdQFVDeba9ks8FeLkY1swxj8OAroQDnyWZJjSqGu8sDCtS6tLxIoOydSKCAvr dvtr9U/jzE+90aUpG92xsFBv/DBRKy4puK9EDdYu9lkMUeaHGPWD386Remej033LCzTu 71hg== X-Gm-Message-State: ACrzQf0CX8PWOMKls/CAyJdZ9sJ2u44fv48jZum55Pd0fQHH46gKvKe4 A2LO+Lx3yXTpcmSN1cxZxizLWNR/Wwo9/7xP X-Received: by 2002:a17:902:8541:b0:17f:6b27:7a75 with SMTP id d1-20020a170902854100b0017f6b277a75mr18151041plo.65.1666336632285; Fri, 21 Oct 2022 00:17:12 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 17/36] tcg: Replace TCG_TARGET_CALL_ALIGN_ARGS with TCG_TARGET_CALL_ARG_I64 Date: Fri, 21 Oct 2022 17:15:30 +1000 Message-Id: <20221021071549.2398137-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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" 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. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- 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 d58a6162f2..584cac3dc2 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -88,8 +88,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 48b517a856..9abff104bf 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 Oct 21 07:15: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: 617166 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp851312pvb; Fri, 21 Oct 2022 02:41:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5wTptLnCU4kFyCPg3c9zkzlXHtx8Iufp8qDmCZfC2xpkmR8WbQ4ysR7jbfVy3CVu7R4XjI X-Received: by 2002:a05:620a:2618:b0:6ea:908:120e with SMTP id z24-20020a05620a261800b006ea0908120emr12860722qko.645.1666345269113; Fri, 21 Oct 2022 02:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666345269; cv=none; d=google.com; s=arc-20160816; b=rnJuHB/Cf8gaWfokajLJvPS5aqGCrits3roYwvz8TgUElbeZpYOh1XqtWSXE1XrPBx sGLl5ZxtLp6nS87uapTosSVP0FsFyQTzfECbzfVRKnHmsqTctGy2DTWsj19UzMu6FJ8c oEn3V3LZBsyY/2gLW0OPM+hQWOE0DqbWVnTb2FEPQiEnGKQkB0FHWv/avTecqAjsAjU/ dOiLmhXZ3hbkmb0LEJfkhxsT7yt/Vjj+9KBBvWmzrWmUAKcMfuUAI7eBUPj06x/jnE0p 3VlloO+skidWPBAC2J8TtlThHRsyoK54TDlj3chd1tmrB1FdXfvCkb7G0mfvH5ZmWIhS o6nQ== 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=agyTV2jCK/77n3/Q34HNtG1TiDyGgsf/EB88ers/CYk=; b=u2NkLG9GTqWPqnuP7+DNnDHX1PIwYE5hrJlO/QXiMRpWjIGJS8QXDftYFcu9tmYhXe JXv4vfAnNAqDKqz/Gz8evj0Zc2MJtu61Go7tel1tZi6UIcktqbWf5X6b4t+90i5I11Gj KUsSzx6JsKGeBCfQWapq8C8E3gybr4PTcmVgarUq7zMjE2NQGEGQsbzfyQYVCcl0hcTU 8jOMeyijpfJgjBb1dzMeCm2pGlBM3BPsDxN+ET7Bt/4DOwT3sTDPWug1YMedbvVADSnZ gVDnwPMWMTkD6O10aatyKJrDn6Fc0j82S+zQkWRhimIIAGFtS/wzaeCVCy/sd8kNB4T4 Afgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U29KHWl+; 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 jt5-20020a05621427e500b004992ea03eebsi11430032qvb.198.2022.10.21.02.41.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 02:41:09 -0700 (PDT) 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=U29KHWl+; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oloWN-0000ep-Rw for patch@linaro.org; Fri, 21 Oct 2022 05:41:01 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHh-0003Ih-LG for patch@linaro.org; Fri, 21 Oct 2022 03:17:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHQ-0003ET-23 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:20 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmHN-0005nk-Mo for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:19 -0400 Received: by mail-pf1-x42d.google.com with SMTP id i3so1778293pfc.11 for ; Fri, 21 Oct 2022 00:17:15 -0700 (PDT) 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=agyTV2jCK/77n3/Q34HNtG1TiDyGgsf/EB88ers/CYk=; b=U29KHWl+r540B7yvK5UZVx2rV+GDA4jacqhmS29SUP/FUo/X6Yzu5fkFWhObQqZX9d gvvHnu4wizIrdeyEKivbd5H17J1dSnTGND+Szfrllw1DJo6BWJwBWD/96ztdjKetrJMO nolz4hFMAmk4N2wVYyWnMWd0hhni28ebTI+5Fggw6CsHG3qfvXuhOE9TIk0h1SBu13Q2 BvrB1RubbfFs1IuybA8XPQwE/l6Xhj6cO1soAQcOH7TNT46v3n6CRcya36QNknzBBgEY edtAX36S1WJ8xYpTBIvPonMp0yNpn+kIDOW8fDMacn55Qu5gcEFTmk5yBIO/9I8AuMEy j3dA== 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=agyTV2jCK/77n3/Q34HNtG1TiDyGgsf/EB88ers/CYk=; b=m+bjsQKF4hhq1o/7Pio6SAba+2ymNptvug1NanJOWzTO5bqOo8/vb8onhL/mTcGERN OMjgf/MD3bX3yJt4EBES/TorrYeVmMYIGeHjX7mNt10lVIuNGcp+naljil+gyRQtmo5s tbs70IPp5gA97L/YDYNCaNC5NdvMUzKFpT8/alBZKAiyGgKK5zaFhKR5qn4zwEUAZql9 +3qb32C7yRKqnmDEVQAmo3BFkbA3CAe5fNtxFQqyJQ6/CpK9EpnogAjAbea9nbOs6Uml nN6BxOakfluzStM7aNWQBWYKcPTXhIRY3mqNDYCWi1RvjmRMhmvIRWVi74hIEaUCpTRg AUww== X-Gm-Message-State: ACrzQf0an/HcuO3padhNVrssBGwGceR2I3nzv2eAX0o+Cw4E5l93W1Fp wxedFJF1VmWDE56SiN6BVyiaOnbScYvBMDnW X-Received: by 2002:a63:1041:0:b0:46e:c6eb:22ee with SMTP id 1-20020a631041000000b0046ec6eb22eemr216662pgq.442.1666336634737; Fri, 21 Oct 2022 00:17:14 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 18/36] tcg: Replace TCG_TARGET_EXTEND_ARGS with TCG_TARGET_CALL_ARG_I32 Date: Fri, 21 Oct 2022 17:15:31 +1000 Message-Id: <20221021071549.2398137-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" 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. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- 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 584cac3dc2..74fbb22dfd 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -89,6 +89,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 9abff104bf..d4960c62b5 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 Oct 21 07:15:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617163 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp843719pvb; Fri, 21 Oct 2022 02:24:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7/mT6jODXEejvR5sMupZ4sMh/lITrCfh+8dIoU1AhQXEtE9YnNqKusv3cUz0odliWlh/pv X-Received: by 2002:a05:620a:29d2:b0:6ee:cdf4:c141 with SMTP id s18-20020a05620a29d200b006eecdf4c141mr13067363qkp.236.1666344282267; Fri, 21 Oct 2022 02:24:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666344282; cv=none; d=google.com; s=arc-20160816; b=skdjURJBcvZ2AKrst36nJDrCQ5pPnkafhdCnANW+12cew20tF/N8ROo6gzV4LJiMNI 3r2Z6Diwz6gcnKVyFgWKf2Y5u7BWLFghqag81fuhSNSJpyq5AhEIUK4FDSjuI/s0zv21 l8fT7PQj0lVEBozoSFyvfCc7sYutlQfU0yrCJZyQ7aExv91fYu9GOF9dQJASBIIbEN36 Njp3k1wnM+JtYjCm8TuffUYr8yv5GZ1VIDY1MJF652Coz2NSqNarExU7KEQOQ0DBTk62 GAMdcLEmsfBfBe46YsjJdnnmyykmN7sAmZZd0bRj9xoylv3v8m1jkJO2JA8IAf32LGKC jMsw== 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=YL8W2fQ+28CPJzwzlqNSd9vlVmUOZrRLduSb6SVZ5pE=; b=MGtND9HvgXETTJ/I/3JPGZG1WvwDV4zHET26+eXK8ymtafXN5TpIlI3tSeKCaqxfLC /BqQzwJ+41BCGl9zvqe1vRfqwalbXksuUk7R3xYz3sQXdgSnRfCaz4QZfVz8YFoo9l/Y 1qvrc8hjIkw7OVQP/WSFsj6DqZqzmjMs0TVJegA7RqK5aojtDe2CVLTYRVAYxTeAt+GS pjSta42LLAAZ2WT8Q77UtGV/e+TirsmGo13UgzGS+0pBlIr7FhlIV0IGU2TJyJrawy32 QihqdPOWBO5Rk9sr6lbrnf6L3+CyhYYxhelj8Oz7aO7+Nuh1exovh0CloXlQBDN3dBGs NFew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CIgAbSny; 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 v6-20020a05620a440600b006bae5b577cbsi13592138qkp.259.2022.10.21.02.24.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 02:24:42 -0700 (PDT) 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=CIgAbSny; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oloGc-0008Ir-La for patch@linaro.org; Fri, 21 Oct 2022 05:24:41 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHe-0003Gq-S8 for patch@linaro.org; Fri, 21 Oct 2022 03:17:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHR-0003F1-Sk for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:23 -0400 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 1olmHP-0005oI-QF for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:21 -0400 Received: by mail-pl1-x633.google.com with SMTP id c24so1584919plo.3 for ; Fri, 21 Oct 2022 00:17:18 -0700 (PDT) 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=YL8W2fQ+28CPJzwzlqNSd9vlVmUOZrRLduSb6SVZ5pE=; b=CIgAbSny0mKIJfru330j4NH2hSkZFTeWyyqhgtsEM04xi8oGpFkhrYL20xPb4ohbCs JrBXRy9reoui42skjWfJSSANoHyzjRez0bTCsI3/QFDoF8a8vLAfS8C1ROtjO7a/+J/v 4+7Pz8X9v9vaWfkwaVHgSufnNlaugQTB+zn50PjQ1ndrO3kS+6pqt95RShBjJcUL/WGo qEbeSqsGTnnWfUUgmxFrGfwx7jdLpUcbNIeqBkGJwXzw4T5ghnNu0By31LvN71tFMTLD 6Gr2mt2yo3TdklZ6q4PHgOO09q/uoLCPQv9rkZBt094MJQaZ274ZWX1v7bqJlqVZRTFu UklQ== 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=YL8W2fQ+28CPJzwzlqNSd9vlVmUOZrRLduSb6SVZ5pE=; b=0epr44rspn7v26+2r5L+KFfSHv9+dRHw6chas71dm6mts07xtfis7hZqzTKyGWu9Nr ctW2nNlITF/KuCx3jmUCKbV0x6WKHBzul3lXSWgokDnTDUTnFkvznULupgklHMuyr70F 6JYKcNV0Jehx0kLxC4byyiuPSdsJC2JKcEPxd+NtykzJf9b9KCz4UY0alHpHr5ZKUXH9 hhFJxoyy4zhJkKzHPtDmi34pd8uVM+qMfiz+y33T/EqqwF4OEWIeGB/19u4agIyGd7KG Nejx6aXtm3+S3Ic3KeyVa2yDSqUbWBWre4O1WzqlmcV4jBs0cO2WNWoHhxf9SQsZYEXz mA3g== X-Gm-Message-State: ACrzQf1zmZe2mrOsxMBCrgz9qlmdXOo3PaWToORYonoQPTx8RaeG1WKD Wu76aQa1spz184Y+L4RjwJHwpX05hH8kC+ln X-Received: by 2002:a17:903:48e:b0:17e:ea4a:394e with SMTP id jj14-20020a170903048e00b0017eea4a394emr17417365plb.48.1666336637236; Fri, 21 Oct 2022 00:17:17 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 19/36] tcg: Use TCG_CALL_ARG_EVEN for TCI special case Date: Fri, 21 Oct 2022 17:15:32 +1000 Message-Id: <20221021071549.2398137-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-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" 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. 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 d4960c62b5..e0f5c6ea7b 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 Oct 21 07:15:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617119 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp794532pvb; Fri, 21 Oct 2022 00:34:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5qCq7D8LDBqKSgBBVqeqjsnplEdc+dHXNjJN5uZjG7Ns9aZYj8U+TksmEy+z6iZN/7Pubp X-Received: by 2002:a05:6214:caf:b0:4b1:7904:5425 with SMTP id s15-20020a0562140caf00b004b179045425mr15359471qvs.32.1666337673279; Fri, 21 Oct 2022 00:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666337673; cv=none; d=google.com; s=arc-20160816; b=ixk92KrlA2oAhq7c984xqwmPCfbDo5GAL5YqthsFLoaGCWiyMARG99BqzFeBDYb7rU qbhW9/fZZvzhEkauQpR5bqcfovkcQLkqt5wj7skuzTaBPwDgwXGYTxl6ftS0n2Y/fA5J QTFmjpyVrhTOvyDRXsAeMF1Lpwg1ZfkXwD4DTu1PemcSUh3x85mfjKLFtlQe1+Yaf8DP W5Vrh6+P11pSXQAdFmrzHXy9BYgNH/TliySqlpxlXzqecm/47ParDFix9OC3xNvm367C yzQodJCr/WqCMxwM3FrteqpSV7UXFYhaeOYseFZTcDnv1x5mSh8ds4eFtDmwENKtSNNV 121w== 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=V4SUZjAaozp75Gu5oXBaKguhljd88jPKuaDdX4HiKKo=; b=gj9Gvyw585PgZhpmUocLDiUXibNZVWxpp06XUbQF/16Uf55ZYDlHvzKCiXtkDAGziC mO9lbgMvVYUOKPoFg6F2e8jxuw3MhF9L9XBbMDIZTJdII/3qMWGaSZPQHFErakLtBjEh s4VVTvoEJqVpCCOqpo5MUt1P4/zyRyCQfQBaUrwuZu7YnCwvtaAjSNpB10X2l+WmX/hh 73Pyt7XMDRoep1MnH/mCGkel0Wj4uv3hqljsIjg9HzoABTqEqcaLhjwuS9n5IY3stHNt oiJcBot4AvDex5digWIdZb0wXPXAJOZY/tMMilj1TJtOkhwUA/Q6IV9j92uVDOhLF8AA ZRlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A2gVn0UU; 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 bj1-20020a05620a190100b006b9c31003cfsi12755003qkb.613.2022.10.21.00.34.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:34:33 -0700 (PDT) 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=A2gVn0UU; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmY4-0007vF-J8 for patch@linaro.org; Fri, 21 Oct 2022 03:34:32 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHi-0003Im-E6 for patch@linaro.org; Fri, 21 Oct 2022 03:17:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHV-0003Fq-QA for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:29 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmHR-0005or-Pe for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:25 -0400 Received: by mail-pf1-x431.google.com with SMTP id g28so1793335pfk.8 for ; Fri, 21 Oct 2022 00:17:21 -0700 (PDT) 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=V4SUZjAaozp75Gu5oXBaKguhljd88jPKuaDdX4HiKKo=; b=A2gVn0UUjyf4L9D9IFFi89P0EKyAgui2gLM7FpClHnTraeOvuDSj0IcT1DZ53u7GRU eYQt66cPXXDbCUYtLeYaA2G5CYdIgi0C68trD32xZSZRfVXwuY5QOHvreE2DbzpbOQBC ysFv+MtS7t3yJYiD+g2FFOuDyXmnvu3dVgJLK83XVjJ8E7LskFNGTS0rmk26XXoPeSCG uiKV/SSywuXxddHuF2idtVI65p8QSue9JwTIySm23vxMYBeMaCZ5b0h8bYQymk5pZhGo hCFilJMLqoELD5vUqugrV5nWtHcQ4tLMNaW+YVeCA4b5nZ2/F0NYD2CJ/75LGPxywC4f R11Q== 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=V4SUZjAaozp75Gu5oXBaKguhljd88jPKuaDdX4HiKKo=; b=BlzFsZhHKLpEqCR4VX4J092jO5jH+oAraHjVoAzP4+UBbo4lctpmxx2ReVwWd9UN2O CMJveGnR0sMJBQ0XH/pr2SAzQn5Vx8N4xmwMOuq2A6QfSmIX0hOlLYfjlxVY0klMOjWd GlsA8i3woTfEjdENGeDVUYvz7aAq72rHPtsQh3fTM1bgQ+q/h3YcJuUzyZ7JRQZ42zqi h04a/hIzh3D2q0wdjYhIY5VOrz+IQYBQ0dpYck1XpDKkZYZe6pvCIMmnvXhNA7tBLqQg v1pRpSYXWE3/p9C89Wa3Of2yVdhI2ZsWFvC+fKXpHzCpxNvpM6/msrebXPSKRlQVmpGj gA+w== X-Gm-Message-State: ACrzQf01jxOzjhUoyjxcs41Bsj3Od469/3K3ClRu3OGFQYdaFqggHq1R 4Sb7Sifh8B4ROqE53kNzlr1zgO65mPcEJ6k7 X-Received: by 2002:a05:6a00:1912:b0:564:f6be:11fd with SMTP id y18-20020a056a00191200b00564f6be11fdmr17554438pfi.32.1666336639968; Fri, 21 Oct 2022 00:17:19 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 20/36] tcg: Reorg function calls Date: Fri, 21 Oct 2022 17:15:33 +1000 Message-Id: <20221021071549.2398137-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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" 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. 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. Free the temporaries for extensions immediately. 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/tcg/tcg.h | 3 - tcg/tcg-internal.h | 17 +- tcg/tcg.c | 591 +++++++++++++++++++++++++++------------------ 3 files changed, 377 insertions(+), 234 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 8bcd60d0ed..8d0626c797 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -425,9 +425,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..097fef2325 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -42,11 +42,24 @@ typedef enum { TCG_CALL_ARG_EXTEND_S, /* ... as a sign-extended i64 */ } TCGCallArgumentKind; +typedef struct TCGCallArgumentLoc { + TCGCallArgumentKind kind : 8; + unsigned reg_slot : 8; + unsigned stk_slot : 8; + unsigned reg_n : 2; + unsigned arg_idx : 4; + unsigned tmp_subindex : 1; +} TCGCallArgumentLoc; + 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; + TCGCallArgumentLoc in[MAX_OPC_PARAM_IARGS * MAX_OPC_PARAM_PER_ARG]; } TCGHelperInfo; extern TCGContext tcg_init_ctx; diff --git a/tcg/tcg.c b/tcg/tcg.c index e0f5c6ea7b..713e692621 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,162 @@ static ffi_type * const typecode_to_ffi[8] = { }; #endif +typedef struct TCGCumulativeArgs { + int arg_idx; /* tcg_gen_callN args[] */ + int op_arg_idx; /* TCGOp op->args[] */ + int info_in_idx; /* TCGHelperInfo in[] */ + int reg_slot; /* tcg_target_call_iarg_regs[] */ + int stk_slot; /* TCG_TARGET_CALL_STACK_OFFSET + i*word */ + int max_reg_slot; + int max_stk_slot; +} TCGCumulativeArgs; + +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, + }; + + if (cum->reg_slot < cum->max_reg_slot) { + loc->reg_slot = cum->reg_slot++; + loc->reg_n = 1; + } else { + loc->stk_slot = cum->stk_slot++; + } + + cum->info_in_idx++; + cum->op_arg_idx++; +} + +static void layout_arg_normal_2(TCGCumulativeArgs *cum, TCGHelperInfo *info) +{ + TCGCallArgumentLoc *loc = &info->in[cum->info_in_idx]; + + /* Layout the pair using the same arg_idx... */ + layout_arg_1(cum, info, TCG_CALL_ARG_NORMAL); + layout_arg_1(cum, info, TCG_CALL_ARG_NORMAL); + + /* ... then adjust the second loc to the second subindex. */ + loc[1].tmp_subindex = 1; +} + +static void init_call_layout(TCGHelperInfo *info) +{ + unsigned typemask = info->typemask; + unsigned typecode; + TCGCumulativeArgs cum = { + .max_reg_slot = ARRAY_SIZE(tcg_target_call_iarg_regs), + .max_stk_slot = TCG_STATIC_CALL_ARGS_SIZE / sizeof(tcg_target_long), + }; + + /* + * 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)); + + /* + * The final two op->arg[] indexes are used for func & info. + * Account for that now to simplify the test below. + */ + cum.op_arg_idx = info->nr_out + 2; + + /* + * Parse and place function arguments. + */ + for (typemask >>= 3; typemask; typemask >>= 3, cum.arg_idx++) { + TCGCallArgumentKind kind; + TCGType type; + + typecode = typemask & 7; + switch (typecode) { + 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: + tcg_debug_assert(cum.max_reg_slot % 2 == 0); + if (cum.reg_slot < cum.max_reg_slot) { + cum.reg_slot += cum.reg_slot & 1; + } else { + cum.stk_slot += cum.stk_slot & 1; + } + /* fall through */ + case TCG_CALL_ARG_NORMAL: + switch (type) { + case TCG_TYPE_I32: + layout_arg_1(&cum, info, TCG_CALL_ARG_NORMAL); + break; + case TCG_TYPE_I64: + if (TCG_TARGET_REG_BITS == 32) { + layout_arg_normal_2(&cum, info); + } else { + layout_arg_1(&cum, info, TCG_CALL_ARG_NORMAL); + } + break; + default: + g_assert_not_reached(); + } + break; + case TCG_CALL_ARG_EXTEND: + kind = TCG_CALL_ARG_EXTEND_U + (typecode & 1); + /* fall through */ + case TCG_CALL_ARG_EXTEND_U: + case TCG_CALL_ARG_EXTEND_S: + assert(type == TCG_TYPE_I32); + layout_arg_1(&cum, info, kind); + 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 that we didn't overrun the output array. */ + assert(cum.op_arg_idx <= MAX_OPC_PARAM); + /* Validate the backend has preallocated enough space on stack. */ + assert(cum.stk_slot <= cum.max_stk_slot); +} + 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 +759,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 +1630,15 @@ 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); + void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) { - int i, real_args, nb_rets, pi; - unsigned typemask; + TCGOp *op = tcg_op_alloc(INDEX_op_call); const TCGHelperInfo *info; - TCGOp *op; + int i, n, pi = 0; info = g_hash_table_lookup(helper_table, (gpointer)func); - typemask = info->typemask; #ifdef CONFIG_PLUGIN /* detect non-plugin helpers */ @@ -1493,106 +1647,59 @@ 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->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); + tcg_temp_free_i64(temp); } - } - } - - op = tcg_emit_op(INDEX_op_call); - - 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; - /* Make sure the fields didn't overflow. */ - tcg_debug_assert(TCGOP_CALLI(op) == real_args); - tcg_debug_assert(pi <= ARRAY_SIZE(op->args)); - - 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]); - } - } - } + QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); } static void tcg_reg_alloc_start(TCGContext *s) @@ -1807,10 +1914,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 { @@ -2576,12 +2680,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) { @@ -2621,7 +2724,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; } } @@ -2629,31 +2732,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 (loc->reg_n) { + *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 (loc->reg_n) { + tcg_regset_set_reg(*la_temp_pref(ts), + tcg_target_call_iarg_regs[loc->reg_slot]); + } + break; + default: + break; } } } @@ -2922,21 +3053,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); + 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); - 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; } } @@ -4158,106 +4287,100 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const TCGOp *op) return true; } +static void load_arg_normal_1(TCGContext *s, const TCGCallArgumentLoc *loc, + TCGTemp *ts, TCGRegSet *allocated_regs) +{ + TCGReg reg; + + /* + * If 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. + */ + if (!loc->reg_n) { + 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 + + loc->stk_slot * sizeof(tcg_target_long)); + return; + } + + reg = tcg_target_call_iarg_regs[loc->reg_slot]; + + 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); +} + 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_1(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); @@ -4268,31 +4391,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 Oct 21 07:15:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617165 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp851000pvb; Fri, 21 Oct 2022 02:40:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5e8CkbIReGhIq/tzaV4gcHJ+aX4K+u0kOJmY7hVa0QOc2B7i/6+sP+fnEb/jOxvQ5I0Ekn X-Received: by 2002:a37:9ac8:0:b0:6ea:a959:3eb5 with SMTP id c191-20020a379ac8000000b006eaa9593eb5mr12795626qke.551.1666345231791; Fri, 21 Oct 2022 02:40:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666345231; cv=none; d=google.com; s=arc-20160816; b=Xs4vzn0ApZaptsPAhtmh12tmvSRsmrOB7BV9StLMHrthCoZCiu8Ga7EkCMuTiOr3+a r+4NoxnL5BGXcZ0QfHemXjFy6WL1GgCEkFAGZthP77dw36gYMWuTEO3ox9UbfOfDxQ9/ lSRcpNppU9MZeAVD+eojjy+Qpka/pIpvS03jv2Dw9OCUWiumBiRf76MopP0tx+tuuOqk YxwcWGwIYmdKm9v+Ws81HeGww0UNnWVPDPWzC0ezze1+hFfgsZUUJMGDb/Od4wAfUxRk GdxOLRkWeZLduZtaXCCnWHK06xe0usEKBgznCIZVQPHjS5aFaNXPfoxCWNmYc9N9aWgr 0EoQ== 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=+auU7PVqmG99ktmS6b3UEAfMFz0jKVdnqCCXndsje+Q=; b=CdZbPsITSVVfWs5sdRMSWlkZnxjPkmIMfYoV+76NnMvA6lJk4F+0BpQflHUlNc9tbk mqUueAnQB/frTNy2kXKd0igb4gS7YP/pmN6O4DJ5bixlEquflj30B/7qhJrGFyLckgGn 2smAaw294eIW9e1J4X7elzHMfI4iS5Oo+ejODgnk2/uhmeL30S924RQMc37wTVbdKd0y 3rWs0/E6YTHJb5CnO2e8l4aAO9HVm7Y7SngH5Afgeh/KKwl7Z10nxRA1sRZWW5aL+J6W gDPEelajPgz94B7UCeqap1pySbsnnD5vEOTXN7Efr/9fhpn7XRmfkNX+4WH3sgmj2g14 swqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sl3EGQqx; 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 t13-20020ad45bcd000000b0049641a2ffa7si11913958qvt.229.2022.10.21.02.40.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 02:40:31 -0700 (PDT) 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=Sl3EGQqx; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oloVy-000701-CK for patch@linaro.org; Fri, 21 Oct 2022 05:40:30 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHh-0003Ir-Jl for patch@linaro.org; Fri, 21 Oct 2022 03:17:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHW-0003Fu-V1 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:31 -0400 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 1olmHU-0005pB-BO for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:26 -0400 Received: by mail-pl1-x629.google.com with SMTP id n7so1594877plp.1 for ; Fri, 21 Oct 2022 00:17:23 -0700 (PDT) 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=+auU7PVqmG99ktmS6b3UEAfMFz0jKVdnqCCXndsje+Q=; b=Sl3EGQqxzdxMl403t1ZqDWlfhxS8htbbS1vuoGSurjKy1acoqEZ5jYFyds0bDN3y+J YInnz4xJOc499dIWSXa6AcmoHgSwCVdwIhSpSX5waToR0SF7D4pJZ1GPhY/qIozh1/Bk ROwS809d8nZI/wbKJDlGvzO/rXFiuYsnOCyrDtoXHJ2LH6nAAt1zrPVnU9xayujDV/Ua 7ICbW4n45fSv7zxqbODUq5B0CP+fQbmqsrdA3ZKLZg3OEGWH8vpVeRx2NLa4fGghViRy +m0oQbIP5Qx0OPDCTPEECbtwyiFKUrFjxRKuMuI4cMneAuAGSDjTbsS4coXb+Nf5B8ol BbPw== 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=+auU7PVqmG99ktmS6b3UEAfMFz0jKVdnqCCXndsje+Q=; b=Ko9kXhsroOv1faWOxtaVA/iV0rpsdCo8EKRmCw7grW7nr69gbYIR8j6CSu2DdebNET q2+p5N//3GrW6w4r+qGUcuu38KXb9PZo0rFFJb9kTTMBPAk2YwVsR+GwfLFEDXCAcf2/ w2hAGn+zdQULt+I/vixgv2s8ZW0nOjrGwzHXmGiSjw0c+/0pOQ7/U/q62k/lG4J88FNc NEgL2+pS118nBw0UmhMjdKSqQBF67x3xUJxct6MA5ATaBJXGwQO2KZmxnLq1DyGyghg8 H9ihBcIW0F6ruv+8sCyDskrZh3XXJx4ovtcXEmnxRXP/5von5bZH187+eJPSAZ+Bz1d4 4O5g== X-Gm-Message-State: ACrzQf3qhrQsoWZJ4tCNo7X10DNLwLfGGiJg+69caGkI3R6EHcXH0Npj Tl0tqgJo1T8HC7vlYOpz9WtYJ65gBc5LbHxr X-Received: by 2002:a17:90b:3588:b0:20b:590:46a2 with SMTP id mm8-20020a17090b358800b0020b059046a2mr20463567pjb.14.1666336642846; Fri, 21 Oct 2022 00:17:22 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 21/36] tcg: Move ffi_cif pointer into TCGHelperInfo Date: Fri, 21 Oct 2022 17:15:34 +1000 Message-Id: <20221021071549.2398137-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-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" 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 097fef2325..696dc66ada 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 /* @@ -54,6 +58,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 713e692621..a3a6968f76 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 (i = 0; i < nargs; ++i) { + int typecode = extract32(typemask, (i + 1) * 3, 3); + ca->args[i] = 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[] */ @@ -765,44 +820,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 (i = 0; i < nargs; ++i) { - int typecode = extract32(typemask, (i + 1) * 3, 3); - ca->args[i] = 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); @@ -4387,12 +4405,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 Oct 21 07:15:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617123 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp799395pvb; Fri, 21 Oct 2022 00:45:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Fgko5qiRiNhYGinxmqTqIMRLS/RBa0CIpp52RStu26f9Bi1FpjeyHHUq6E8to4qq8kqnw X-Received: by 2002:ac8:59c1:0:b0:39c:d5c3:6859 with SMTP id f1-20020ac859c1000000b0039cd5c36859mr15473862qtf.230.1666338346533; Fri, 21 Oct 2022 00:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666338346; cv=none; d=google.com; s=arc-20160816; b=rlHXhxg8dy1PbZ92THZHXf7IF5BG/LxQWo3irwc8Lq79ICt0kFqUV71w8lK9DCORde D+VCAMl55RrkvjPxC9kDhg+/C5DMJ4O7jbM58QC5hAGQM3jPcVOBcG06OC4DweCzzVCD P8ovJE/sRxJIWO5NwNUhj91B+lVd9tQEJ3n81+8AOb60S7Gm04oVPfRp6g/8kK+oQrLI JskSSOH9eLrmobcseBfbooyQyOzPkCqOkBlplIyTbH5pk6FPjRKFLH0TiIfqQdhjCn5x aV0MySpjcNIlYYPdpxAg0+Te3vC1bk0/aLVgPv/Hz4Q0JMXG4frBd+uV/m8uHxKhSn2y Cmtg== 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=jRraYrN7VevkThzpI1pDQIipRClwjcnorE3BJjtqVhA=; b=tkMLASG+c0hsMC7FG4LeK2kvAbmHcwwoSI0wzLj1fLAqC9GzXaZ3mmMv7btYHFQWir lkRmdmwIMl6bN2Rma79R1tZw79T2UHY1gc4ZFd5++SM8/hzB5GnW3Z7hqjxoQRqbtDAM KFbJChW0P4+x+vNeAuuJxZ/0E6kS2iAeeRe1djd/tKQD++WTGnDU/J0pKX3vQwUSNUWN URtqjE8zqA8po7vv5JFt/8AbKHKQgPscacmalUCdYPT07Z3G8ut3QNHeB9C+yN9J0PB3 cxgYHkHKMqFcXGScLx/3Ey0tAN+YQ20X5uYNcZy9hkMJRoiFjiPWMy8pgCeSv7lWU3Wv DdGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qDX1AyU8; 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 fw9-20020a05622a4a8900b0039cd899c345si11663937qtb.773.2022.10.21.00.45.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:45:46 -0700 (PDT) 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=qDX1AyU8; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmiv-0003aH-N9 for patch@linaro.org; Fri, 21 Oct 2022 03:45:45 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHi-0003J3-5p for patch@linaro.org; Fri, 21 Oct 2022 03:17:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHa-0003G9-7K for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:31 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmHX-0005pW-91 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:29 -0400 Received: by mail-pj1-x102e.google.com with SMTP id pb15so1654802pjb.5 for ; Fri, 21 Oct 2022 00:17:26 -0700 (PDT) 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=jRraYrN7VevkThzpI1pDQIipRClwjcnorE3BJjtqVhA=; b=qDX1AyU8FeLwtfCdvSjG6BOEMUAs67A0UenYkVx8S0+n7vX/0/wiBQzIRxrDLWEdve z7juLICsf6vi1clqaLFPOjR9zE6a8Wtik7tHAdgLH43pAYB0J3iDIKea/tshXdq73QZL rmI/5XUJdBz2o76cy2U5srpY/rz3arM3ZQpkgC2g/NE8KgJ3Xsdx1yJqbHrPktY6G6mr G2hN5Dbonx/OgBdJH/NfboYSohH+C06l/UEEGjn18sXb29JCIui122s4BStas4U4sE0G x8F6I8fgJpY0OkEHNJoKw/oM8pxfgGJf4IasodASFWczhHT8XBhaEUlH7r+EpC8UrHZd iFZA== 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=jRraYrN7VevkThzpI1pDQIipRClwjcnorE3BJjtqVhA=; b=Ap24Zz4COgSeTxRYwDuaP3Kn3YozPPq1e1p51qsVfvLRw3joUgUa5iPU6s2Haj/ZgN Y0pK0OAsAsn+HsLa2lEJzv8IuEsy86p1/qHbrSfolXnQbhiNOi1mfHGaMyqT1PV7I9Qv n7nmt02nf8a5l0ORGvAmisFBo22xLlpNVqrgdZrmsfWIodMGmcwBFCo8I9BeA592RYi1 5RF9nvj25HtT6g0Wvl9yRtqT7hPErQxacg3AUuXMh6anNJv/4DIJaDxAjdhOUZjFSuX+ tzD+r3V0Fxoe6cqF/FeRl3vi7ILcO8Qhapydvj5+4/eqem4NixgfvVQ/+x5FrKmrkCGo pong== X-Gm-Message-State: ACrzQf1k9YMo9hj6TRTgP4Zcx+EOCWCsQ+07xSx69z1/1G0wiwJg5zXq 5Ws7fckRAPfAW0fit5dukW0o/3uxjJ2HGWwe X-Received: by 2002:a17:902:e804:b0:186:5736:2b70 with SMTP id u4-20020a170902e80400b0018657362b70mr11939648plg.127.1666336645871; Fri, 21 Oct 2022 00:17:25 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 22/36] tcg: Add TCGHelperInfo argument to tcg_out_call Date: Fri, 21 Oct 2022 17:15:35 +1000 Message-Id: <20221021071549.2398137-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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" 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 | 19 ++++++++++--------- 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, 50 insertions(+), 38 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index a3a6968f76..082482341b 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); @@ -4404,11 +4400,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 d997f7922a..e8184fe001 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1336,22 +1336,23 @@ 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) +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)) { 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, reg); } } +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) { @@ -1599,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 { @@ -1625,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 a3debf6da7..98da264f16 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 f3d7441e06..b07b30b9fc 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -562,8 +562,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 Oct 21 07:15:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617118 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp794340pvb; Fri, 21 Oct 2022 00:33:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5p2V9xvJj2YCMa9fIcOXSx2OiXf11Gso5MGJlXDHcAuxlBcjb8rSqHUAnQrYabqVfwsBkY X-Received: by 2002:a05:620a:440a:b0:6ec:d931:652d with SMTP id v10-20020a05620a440a00b006ecd931652dmr12241659qkp.344.1666337639375; Fri, 21 Oct 2022 00:33:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666337639; cv=none; d=google.com; s=arc-20160816; b=PAhTzbO1uLeN/zH9zQSasQJXOewlXEhK7/nRPMM6fTJ3XcpcEWHUjwPkdv2fxjppdn 7HWwT/dlMurHHnv+/gijNA7EXfvY8Pr6v44yLWQDOnSl2D0IWmUitfZbgGgx13Y+4As8 vcNb5tU7kxqhmw0GjWf+Fzqf79wdNByuPAuhhiT12blliZo/PCzjHov33+A8oaSIg5ue 5PRGqytR9ey6gm2TLB83gbCinAkW8gLmSFdcGz2GIrMcZLmGISx9xp2twcG8VIaYHEpT zPoVrX+Se33B8l7ikc+/Pc7ZdfELmEnATc3k881eK0mVOQgr40DSv+f3QnYMrF6dpPo1 ihKg== 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=SfazqaVq/Md711XTgHXaB4eXQUcEJfZf9rE0mqnfz88=; b=uh4UiWJm9X+XgrWSEa0da57pylaZoALZdW5IGbPXBSQ5T3wA1FTPGNTqf+Zctv2ge2 T7CGcojBGE5xK7ebuY2XEolY6wSLfDSEnFbvcEdRx+KDlsK7hW2s1FuVZ9Cp3UxmNUlf gfjmeQ7BrgRt9OKzTor8RP7zsNcWm5FLucUIyx5utXAUrZLVBDVHLxW5k7GsAFYdEuxV o6QNtO51gdWoxTQCWaKk7ehpdotNDUMn0wYqb2wBg9s0/d0fdoTnVTQTRWZ5BOE3RKtI CHJpJ5rwhcSd0ZDUong767XXEmC8bQlUrGpLpiAIHsAIqHlQ5z/0aWTRMEi82uOf4Lys 6bUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bX8u8yMM; 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 fw6-20020a056214238600b0049904e31195si12132541qvb.24.2022.10.21.00.33.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:33:59 -0700 (PDT) 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=bX8u8yMM; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmXU-0006uA-6n for patch@linaro.org; Fri, 21 Oct 2022 03:33:57 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHi-0003JE-Al for patch@linaro.org; Fri, 21 Oct 2022 03:17:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHc-0003HH-85 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:32 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmHa-0005pw-Cx for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:31 -0400 Received: by mail-pl1-x634.google.com with SMTP id d24so1584851pls.4 for ; Fri, 21 Oct 2022 00:17:29 -0700 (PDT) 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=SfazqaVq/Md711XTgHXaB4eXQUcEJfZf9rE0mqnfz88=; b=bX8u8yMMLpscGHMN3svAsaWpB5mG6Rwt+7dnXucOIwfjlS7erxhpRNQIwc/AG++tnk 8TX6b4dOjIBocV2Kd4oM1OPTj2KiRXoxotqW/zWWX5eWSsdn7OArL4nFAjybw/zucPCF TKpBrhEHBQer1bolMwwwMhrR4fnKXE+v3q15TTZFyCWB5j+8cCs+Mo3P4m5ShhTECBWd Ps/v8v/OlDah3bohctPu1P+94CowCE/VSuC6LYpff2C4rcvHIchACzIM4vCeTMlJp8fd XGmrau/0B0pXoZF4ZtN6coRHPDQNIdIcOtcPxcPu/Ijts2fFuoXIM7aeXHQT9KxM9Dg/ 8iuw== 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=SfazqaVq/Md711XTgHXaB4eXQUcEJfZf9rE0mqnfz88=; b=wph0EcaHAzTo1x5lFXrQ54Gc4Q9kZO5eJePEyiwwCD2tbqriPb3sDjbrawfjXUMxpA nkiGhvLLicJtp6IA/b+inQiJjSsuMyvD/tHROfbRcJUV4Fxg2BpJRPi2L0Pk0aMrvGN1 P3yAeI9sMGJPEmJOgF2eqaWzatNjDjELQ4clPyOccHt0R7Icg+znoBA7U/E4/JbNI0Xj ZqYEcdcquhBrkq1ONc/1TuoN2xJNGd2GD6oHQosSxHzEn6X4VORCPsAPF32aHwTIZPsH GAyG9KuWhlv5CBUQArPX5ql34tHuvMKGBQ4nkyEe2yGabbtmKdOnyOyZgeYpf6b+1Jme AhhA== X-Gm-Message-State: ACrzQf1v/QyHZ7pKl/rFv0W9qb5dCVinwHPGRM0G0Un+y4FYiGrnkHRw bOaJ8zl3duK6WtD9fzy876gIveMZsDS0xKkm X-Received: by 2002:a17:90a:ad08:b0:212:d5f1:e0c6 with SMTP id r8-20020a17090aad0800b00212d5f1e0c6mr298457pjq.228.1666336648587; Fri, 21 Oct 2022 00:17:28 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 23/36] tcg: Define TCG_TYPE_I128 and related helper macros Date: Fri, 21 Oct 2022 17:15:36 +1000 Message-Id: <20221021071549.2398137-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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" 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 | 28 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h index e242fed46e..9753df8e80 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 8d0626c797..88fb4f1d17 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -38,18 +38,15 @@ /* 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). */ +/* + * A Call op needs up to 4 + 2N parameters. + * (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 @@ -289,6 +286,7 @@ typedef struct TCGPool { typedef enum TCGType { TCG_TYPE_I32, TCG_TYPE_I64, + TCG_TYPE_I128, TCG_TYPE_V64, TCG_TYPE_V128, @@ -370,13 +368,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. @@ -396,6 +395,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 Oct 21 07:15:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617131 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp804330pvb; Fri, 21 Oct 2022 00:57:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4NxU1NHL1oazZhVjK9M2kq1XFNSZg5tWsyhkOual7GaccRhkkDXWM3HahOGDGq07JbtxTw X-Received: by 2002:a05:6214:19e7:b0:4b9:ca97:c249 with SMTP id q7-20020a05621419e700b004b9ca97c249mr4732203qvc.113.1666339023513; Fri, 21 Oct 2022 00:57:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666339023; cv=none; d=google.com; s=arc-20160816; b=Xpb+H+LXpSHGW63mp8WAfDCYVq3vF0ExJmKCE8x1Bb8eng1prt2H/rL46PIqISFtF6 j1PInGuKD4sFl8In3/6WaZGEWNUJSKocvWryf+XFCOBeUpMrFhwiOAJ1d4iXHZj4CrDA lQmI0hQ8P/bnKtdY5Vz1t3fwNOrqQAcp3nSkmBjzKnTbwc4iAIOkcQAUCROWxsZI+oQX x7bIogN5yQ15Lmtu5nUV8ODqPhriqOJFFkBDXng8SAVQkHRSxWfHq3YGUzqB0w5Sqi++ q1xVw4r+gfXqUbNt3R2gLgXUMS3sZ8SKp4dq3LpQJ4alAAVgsBGtMw6Sglf/UZIOF2Zg RCtg== 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=QmH6UfzNb2W5B+qTcQwkyCbKbOPU702ATit26UV60EY=; b=Ge/sqe5Z1te1ap6mU2SHsVB0Vbta3+ImAkajZhTQh2oSrXNWHlZFxJUWGy6KVGBuN3 YRvtqPnfHUBv5YlzcHz2/inszyHExBj+oEvYRbUs6MR/C2nuFQR9Irkxh7F3dNbYVjmA fic0XB3zrj4qVzIaE4hvP1RiAQSvEVJJPZ5Wor3LcFstI04PqiTX8T7ZDocVklCVyPjk KSz3Vd3bG5ds6NvQ3v509O3BObDovU+1zrRShi2Mu0s7H/fgf9bsPvk77FxFgyctmLGa Q2uRcr5xpQLxY34AT+smQwRCk2o4wedXQ7Vy9bVjetWq6fADim78dyGgwvKWM+tSzMaM eLdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ki9emwlV; 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 v3-20020a05620a0f0300b006bb46869eeasi12999458qkl.699.2022.10.21.00.57.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:57:03 -0700 (PDT) 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=ki9emwlV; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmtl-0001tO-FS for patch@linaro.org; Fri, 21 Oct 2022 03:57:01 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHw-0003OT-G9 for patch@linaro.org; Fri, 21 Oct 2022 03:17:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHe-0003JC-ND for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:39 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmHc-0005qM-Ni for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:34 -0400 Received: by mail-pg1-x52c.google.com with SMTP id r18so1779661pgr.12 for ; Fri, 21 Oct 2022 00:17:32 -0700 (PDT) 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=QmH6UfzNb2W5B+qTcQwkyCbKbOPU702ATit26UV60EY=; b=ki9emwlVEZUCD573+rG9GBqYzDqWR1fX5n/GrKUsgfeKd7a0X/+NgeEpI0GijnJS2B tqmzoqx3oak54aomDijbRvrfnMKEzfMzu5WOiRcQxLPIMwvhmYkR534c3+lKPPtM+8F8 m9fKqFP95uoaV1m43yG4j5VzJoRmCD9vqRJfsGEPll4g3XrvLAL5ACpY5ztZf6TfGIjI nL1X2YgEQNqHCh5P0QLOLH8ivuV2iAP5AoEHUVJLtqA5Q57jmj5Pgd0bwsYbTiQFdmZh MKHi1U5lS0aHasDCNpAWqHE558uMjhrW/19ILQsoVjzcqHrbDioUUTYxeNhOpXZsJrMr /2uA== 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=QmH6UfzNb2W5B+qTcQwkyCbKbOPU702ATit26UV60EY=; b=2pjDR3MWnPDdLuqyYKssSR9BiT4IXNHx8G8AcY9uVrrKnGASNuRzIErkf1TR7it3y8 WAMzJeKt5mZAuBFFjTk0JVp0U5Zd2lCT7cfg8eKBroI7B6gQffyK8g0HU5OLHRMOghG4 1QgGLJfc0zwaUjeEnzMZE9Tcw+QihNAPI08dxCZX1HVpdW3EsNgX+Ag+Y90EDWooifvI CldkvHDZFLt4OTxtUpu7IaFJsMto/PCMBE3H+O5yQsnQhnpPt/MI4gIusOYi2x2Hc2ph 0MHO8wYzra8L+q1HPToUYdpWuwlWs2zbx5B+394hfH6Xm4+IAZbROJ4/xMFWcEVgIUqZ vDAQ== X-Gm-Message-State: ACrzQf2LlO5/vbNEaD1L+c9TD6Zg3HU6rCgYGDYPOTv7mU3O5sJrRls0 UQVPDjhIqay4uXcToE0Skpo3Z+1fpp/f3jRm X-Received: by 2002:a05:6a00:170a:b0:563:a40a:b5e1 with SMTP id h10-20020a056a00170a00b00563a40ab5e1mr17849748pfc.40.1666336651063; Fri, 21 Oct 2022 00:17:31 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 24/36] tcg: Add TCG_CALL_{RET,ARG}_NORMAL_4 Date: Fri, 21 Oct 2022 17:15:37 +1000 Message-Id: <20221021071549.2398137-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.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" These will be used by some 32-bit hosts to pass and return i128. Not yet used, because allocation is not yet enabled. Signed-off-by: Richard Henderson --- tcg/tcg-internal.h | 2 + tcg/tcg.c | 127 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 128 insertions(+), 1 deletion(-) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index 696dc66ada..7d4f7049be 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_NORMAL_4, /* for i128, by 4 registers */ } TCGCallReturnKind; typedef enum { @@ -44,6 +45,7 @@ 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_NORMAL_4, /* for i128, like normal with 4 slots */ } TCGCallArgumentKind; typedef struct TCGCallArgumentLoc { diff --git a/tcg/tcg.c b/tcg/tcg.c index 082482341b..fdafb30579 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -658,6 +658,30 @@ static void layout_arg_normal_2(TCGCumulativeArgs *cum, TCGHelperInfo *info) loc[1].tmp_subindex = 1; } +static void layout_arg_normal_4(TCGCumulativeArgs *cum, TCGHelperInfo *info) +{ + TCGCallArgumentLoc *loc = &info->in[cum->info_in_idx]; + int reg_n = MIN(4, cum->max_reg_slot - cum->reg_slot); + + *loc = (TCGCallArgumentLoc){ + .kind = TCG_CALL_ARG_NORMAL_4, + .arg_idx = cum->arg_idx, + }; + + if (reg_n > 0) { + loc->reg_slot = cum->reg_slot; + loc->reg_n = reg_n; + cum->reg_slot += reg_n; + } + if (reg_n < 4) { + loc->stk_slot = cum->stk_slot; + cum->stk_slot += 4 - reg_n; + } + + cum->info_in_idx++; + cum->op_arg_idx++; +} + static void init_call_layout(TCGHelperInfo *info) { unsigned typemask = info->typemask; @@ -686,10 +710,29 @@ static void init_call_layout(TCGHelperInfo *info) info->nr_out = 64 / TCG_TARGET_REG_BITS; info->out_kind = TCG_CALL_RET_NORMAL; break; + case dh_typecode_i128: + /* + * No matter the call return method, we must have all of + * the temp subindexes in the call for liveness. + */ + info->nr_out = TCG_TARGET_REG_BITS == 32 ? 1 : 2; + info->out_kind = TCG_CALL_RET_NORMAL; /* TODO */ + switch (/* TODO */ TCG_CALL_RET_NORMAL) { + case TCG_CALL_RET_NORMAL: + if (TCG_TARGET_REG_BITS == 32) { + assert(ARRAY_SIZE(tcg_target_call_oarg_regs) >= 4); + info->out_kind = TCG_CALL_RET_NORMAL_4; + } else { + assert(ARRAY_SIZE(tcg_target_call_oarg_regs) >= 2); + } + break; + default: + g_assert_not_reached(); + } + break; default: g_assert_not_reached(); } - assert(info->nr_out <= ARRAY_SIZE(tcg_target_call_oarg_regs)); /* * The final two op->arg[] indexes are used for func & info. @@ -745,6 +788,13 @@ static void init_call_layout(TCGHelperInfo *info) layout_arg_1(&cum, info, TCG_CALL_ARG_NORMAL); } break; + case TCG_TYPE_I128: + if (TCG_TARGET_REG_BITS == 32) { + layout_arg_normal_4(&cum, info); + } else { + layout_arg_normal_2(&cum, info); + } + break; default: g_assert_not_reached(); } @@ -1687,6 +1737,7 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) switch (loc->kind) { case TCG_CALL_ARG_NORMAL: + case TCG_CALL_ARG_NORMAL_4: op->args[pi++] = temp_arg(ts); break; @@ -4301,6 +4352,41 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const TCGOp *op) return true; } +static void copy_to_stk_i128(TCGContext *s, int stk_slot, TCGTemp *ts, + int slot, TCGRegSet allocated_regs) +{ + int stk_off = TCG_TARGET_CALL_STACK_OFFSET + + stk_slot * sizeof(tcg_target_long); + + if (TCG_TARGET_REG_BITS == 32) { + TCGReg scratch; + + tcg_debug_assert(ts->type == TCG_TYPE_I128); + tcg_debug_assert(ts->val_type == TEMP_VAL_MEM); + tcg_debug_assert(ts->mem_allocated); + + scratch = tcg_reg_alloc(s, tcg_target_available_regs[TCG_TYPE_I32], + allocated_regs, 0, false); + + for (; slot < 4; slot++) { + tcg_out_ld(s, TCG_TYPE_I32, scratch, + ts->mem_base->reg, ts->mem_offset + slot * 4); + tcg_out_st(s, TCG_TYPE_I32, scratch, + TCG_REG_CALL_STACK, stk_off + slot * 4); + } + } else { + tcg_debug_assert(ts->base_type == TCG_TYPE_I128); + tcg_debug_assert(ts->temp_subindex == 0); + + for (; slot < 2; slot++) { + temp_load(s, &ts[slot], tcg_target_available_regs[TCG_TYPE_I64], + allocated_regs, 0); + tcg_out_st(s, TCG_TYPE_I64, ts[slot].reg, + TCG_REG_CALL_STACK, stk_off + slot * 8); + } + } +} + static void load_arg_normal_1(TCGContext *s, const TCGCallArgumentLoc *loc, TCGTemp *ts, TCGRegSet *allocated_regs) { @@ -4346,6 +4432,24 @@ static void load_arg_normal_1(TCGContext *s, const TCGCallArgumentLoc *loc, tcg_regset_set_reg(*allocated_regs, reg); } +static void load_arg_normal_4(TCGContext *s, const TCGCallArgumentLoc *loc, + TCGTemp *ts, TCGRegSet *allocated_regs) +{ + int reg_n = loc->reg_n; + + if (reg_n != 4) { + copy_to_stk_i128(s, loc->stk_slot, ts, reg_n, *allocated_regs); + } + + for (reg_n--; reg_n >= 0; reg_n--) { + TCGReg reg = tcg_target_call_iarg_regs[loc->reg_slot + reg_n]; + + tcg_out_ld(s, TCG_TYPE_I32, reg, + ts->mem_base->reg, ts->mem_offset + reg_n * 4); + tcg_regset_set_reg(*allocated_regs, reg); + } +} + static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) { const int nb_oargs = TCGOP_CALLO(op); @@ -4369,6 +4473,9 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) case TCG_CALL_ARG_EXTEND_S: load_arg_normal_1(s, loc, ts, &allocated_regs); break; + case TCG_CALL_ARG_NORMAL_4: + load_arg_normal_4(s, loc, ts, &allocated_regs); + break; default: g_assert_not_reached(); } @@ -4422,6 +4529,24 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) s->reg_to_temp[reg] = ts; } break; + + case TCG_CALL_RET_NORMAL_4: + tcg_debug_assert(TCG_TARGET_REG_BITS == 32); + { + TCGTemp *ts = arg_temp(op->args[0]); + + tcg_debug_assert(ts->type == TCG_TYPE_I128); + if (!ts->mem_allocated) { + temp_allocate_frame(s, ts); + } + for (i = 0; i < 4; i++) { + tcg_out_st(s, TCG_TYPE_I32, tcg_target_call_oarg_regs[i], + ts->mem_base->reg, ts->mem_offset + i * 4); + } + ts->val_type = TEMP_VAL_MEM; + } + break; + default: g_assert_not_reached(); } From patchwork Fri Oct 21 07:15:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617135 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp814864pvb; Fri, 21 Oct 2022 01:19:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5kJJrzSvGGmD77Tri6SQE7EJhR44GXe+/oeTqdbM5zURS14/2s9ezaFttl0TNgub9PxG51 X-Received: by 2002:a05:620a:450c:b0:6ee:af91:60b2 with SMTP id t12-20020a05620a450c00b006eeaf9160b2mr13527048qkp.480.1666340363797; Fri, 21 Oct 2022 01:19:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666340363; cv=none; d=google.com; s=arc-20160816; b=yZ+N9ebw2wzjPmpCFJKpV+HQZPihsikDFQJwCff4ALFBm+YVuIvouRQ5WfANY2MVxb zj5N30M+MJZCx82XSO8Z6yAJROquqtlh1P9wrAB/uLSJ/1hPocqhsBt7wA1poetXZZ5U Zk/tf2/DVv3DYd/onOH7JqcFsqJ3y7jpLJa4t/bbgYNYWjYAHfjpjKqV3GYfZLFBjFAW Nr7bm6/NUbZM+0dH96587A5ejAls34iCt2pEaw7aHJJ/5ksqjaX7AIHpSzvWoxJ69SxB 2BENwVDWDevRV8Pu12Mk+tyELUHryEk03aFxLmYb4bF3zPLqrflzaInQyA71LoLAwolw OEeA== 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=OjjeRZqVgFS5dG8LiFwvWFyG3e2GWcohg60z62TsQR8=; b=bojisPdFQRdaJYRHS/6MuFr5g1GG4uh6kskMUWMm2Gjpe0DVZISVKlMomDl8PXn1Oi JE50CjQjJ3CBadlBC1Dc4VhSxZFmCU5el5HLIvaVuqI8kufFFrMBMuANHpnf47JmogND XzwFFjNY922WFEpIjqRb7yWUZlgF5DjZWtM8GqUlyaQL+u5bAw+FCXez2jXQOHETFKWX 55ef5cB89Ti0YqXx3FrFMizcuILwlX7G1jOdrpJD0sl8mX3O9Oe3dNGCcFy89J0TVtJQ 6nB2PNPHD09EQUqTOebnpZWvd5p8uxJLf2q2kBa0zsH2TNM6eYuRqVdRBilp8eQjIjrH gJ+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vc3SisG5; 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 j2-20020a05621419c200b004b1881a7fb0si12726707qvc.348.2022.10.21.01.19.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 01:19:23 -0700 (PDT) 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=vc3SisG5; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnFS-0007R5-B5 for patch@linaro.org; Fri, 21 Oct 2022 04:19:22 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHt-0003Nx-9Q for patch@linaro.org; Fri, 21 Oct 2022 03:17:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHi-0003JZ-Pd for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:39 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmHg-0005ql-HA for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:37 -0400 Received: by mail-pj1-x1035.google.com with SMTP id pq16so1688573pjb.2 for ; Fri, 21 Oct 2022 00:17:34 -0700 (PDT) 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=OjjeRZqVgFS5dG8LiFwvWFyG3e2GWcohg60z62TsQR8=; b=vc3SisG52ZoENCc5L2xvztXdwByJKUyB6W7xey56r5xJ7HDHv86p9lwcUwrQctSn+G TiRvzQg66llEi0Km5X2ZgHEhxRa3sntQgWaaFQ2XU2+L0FjAeYk87DEjHeJBfl4GAmmu 5+c4azojyEkor8FPF8JoJ9rROFGdBwoNZ//OsbJnLxrzIaGpdE8EbTiF5iHKh1rnhrtJ 7Sz2knr824Qoheb6doET24TxhjCwhYlCilGCShS//e9A0p5K1yDt+g15ET1IdcDnQMhm sYcwFeporECwnhFAQE8YtxwMPAmAjYwv7mL44Pr1BKkJjL8CZoBscFHNma/xj+ij622D zZnA== 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=OjjeRZqVgFS5dG8LiFwvWFyG3e2GWcohg60z62TsQR8=; b=hwzppSy2OCahhUfYB0jMAuWF8VUFcSOyW3Bp+VGQ/ufd2LSA8V+VIn51i4imvq1wek Bg/AJrA6LXkM0qGRLkBNnVPmGb8wEc7+9CQcgZGpzXFqiZqQdTbWBse6iqdqkb5ZthJn 78hea9hdL731kGLbldfmxVTi1Oc/cN0PLBHkPs11LrjeD69MgVCBpid+JZu7prOw2dHF i79NGGx4xX4WJ1w3xVOSoNE2nwZQAr41t4iBlgH8DSVB8RVAOVanwH+RVV4l0CeNNrGu a4m7fOJF6P7ylPgewtoPWqjBzM0ldL74s+9obG9DxhCG7AWg4xeRVp/dtYiJrLDAf7AK U96w== X-Gm-Message-State: ACrzQf0Q12ZUIe/e10oNa8iv5kuZ92sEOc+DBZ/mOjowboKRGnjojFxC gj4dOltiPkZaLC2l4I8rYivXSfajHpzbNZDw X-Received: by 2002:a17:902:c40b:b0:17f:9636:9014 with SMTP id k11-20020a170902c40b00b0017f96369014mr17682451plk.150.1666336653883; Fri, 21 Oct 2022 00:17:33 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 25/36] tcg: Allocate objects contiguously in temp_allocate_frame Date: Fri, 21 Oct 2022 17:15:38 +1000 Message-Id: <20221021071549.2398137-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-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" 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 fdafb30579..a3538edffa 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3318,11 +3318,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; @@ -3353,13 +3354,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 Oct 21 07:15: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: 617164 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp850209pvb; Fri, 21 Oct 2022 02:38:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7bQrYkXThxwzofEWC2Xt495vbThkydjafwGAajXZPaKEgspxIVl4CCKsKDL4M96eVgfW1e X-Received: by 2002:a05:6214:d8c:b0:4b1:7bfa:1f93 with SMTP id e12-20020a0562140d8c00b004b17bfa1f93mr15742767qve.70.1666345125930; Fri, 21 Oct 2022 02:38:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666345125; cv=none; d=google.com; s=arc-20160816; b=pg2Y+Ozq0q//BakHQtqjvxhQNDD4Nb6lefyj81BLDanojPS0zSpNOoEJxn9K2jceOi 2js4m8QILGVEx0vegURlldbeEo7iXLwd4HV6IRPKplmm4tTp2U+JEFu3G3YT0Arqn0Le s/L5fdqncLAqeU1w9qFKcDjBdDUUeQYbeox4v8H6ROo2VpxcJt0JuuWe7FJxHN68gMnp OKs5dS1eRE+rRQrktaKeZdGlN8Q2DEPweOihCuNxieAu7oYSgGmeqKBAgcOjWJp7dWi+ jjnIFSPmMtlkcdXTMiOaA9iuv08yU0LDcdZpp3LjTVFAfREa3JipB7TV7oFuZTVN+KT9 Z4kw== 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=vW1Lxg6CwvbDnPeTBg9Qp/nP+UFsiQKcS3I0rXp2/DI=; b=IAIaQAMTg1q4Uh0P/VIrMhwzMr0Cq+RV9V4P6edSSptEohpdQw9JvV5HuL4IvoEkZ0 20SHMPl3UbAv2pAD5B/tTk9ULWocaq822anSPc08IvZ1nyKS/z2GtYCJFnAl115Kgmf6 aKsS08ksr8XB9P+l/6mPMa9vSlo17CwtcebrI9kf9OVyzjHOD/g/8zCUMN5h9PFbmn/l WYQBIFi3HgcGFn5gFnEfOsDwQYoR0yoGdbG/N0WWDpJ6InCbjQ5zlFMrVNeGPQxWJDN/ 1WzudIdhzZtYuHPQB2koE/br4Lo8FqTL/Gm/exf3B+UjAVKN/u5No/fiipNQ0/pT4BvP bAIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oGTG6l2Z; 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 h23-20020ac846d7000000b0039cc35ab4bbsi11084713qto.634.2022.10.21.02.38.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 02:38:45 -0700 (PDT) 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=oGTG6l2Z; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oloUG-0002rk-AF for patch@linaro.org; Fri, 21 Oct 2022 05:38:44 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmIB-0003Tm-1P for patch@linaro.org; Fri, 21 Oct 2022 03:18:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHo-0003Ml-M0 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:45 -0400 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 1olmHj-0005qy-Hk for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:42 -0400 Received: by mail-pf1-x436.google.com with SMTP id p14so1811154pfq.5 for ; Fri, 21 Oct 2022 00:17:38 -0700 (PDT) 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=vW1Lxg6CwvbDnPeTBg9Qp/nP+UFsiQKcS3I0rXp2/DI=; b=oGTG6l2ZqJ3yp4u7YloIjrC6+78p38fVJ5Kz9/aQfQNOb6z8k+pY3RYD0ChbYScr2I bJsM10GE2GQwqgPfzMc1yYvcmPGFG0E83aw8nRavpUE7T1sy84P440+/Bf36hk5eLJDO Eb+/zUTW0G4gGrX7RoMvotFtNLxMikT1wuc5apzF8MK9s04MC77ZvsWucOTmsUmSEips 5mGMjqxwrIDOd/odq2GJ0z4DqrxWbGAeWpXZl5Dc6mKXtUOvaF0SqcucKdO1yEy2M9wy 3TQDCv334Rkle7BVh5bSo6MeqeHJuilW9Oa1TT3NWiSBUTvkjvH4s3v8idGn+j1yigTL oMIw== 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=vW1Lxg6CwvbDnPeTBg9Qp/nP+UFsiQKcS3I0rXp2/DI=; b=lLVJKe0dMtmXxLAJshxpqKnURwbvm8FUStZxsAhyWAOeDDMFq8MeccVFFM3z/wujyI BWOkoYvNFhOsqCU6Y0bDzCpuBoirRfO01c3oz5fxeHkU7/X1GQooGRTerwedq9YOdgC4 DX+F9p17FULctU2vIE3S89YfGRWwXjTIL9xAmCD+N7vexrHZqnDTIVEVqNbLpdd4JImY Hr7aMBn2PuFBTqrGAiX6tNJQaHBbljHDjwLtT1Yq4WVR6URp4xXH7q35s9HgklsMOP8h U9UDbO5jxjVPCzMi14zJAZ9dIn5FsaMv7itnjcUgd7NQ71gC+caoWPMZ6tGGy82Y/OjQ ud+w== X-Gm-Message-State: ACrzQf2XLpbDvMqcggZTv7+b7uo3pZqRYSTRQNthUYCzy5ZRb19s/gbl PzD5LXDi9nQ7BBMrqpYH+A+aZjUTax9wPb5u X-Received: by 2002:a05:6a00:148a:b0:566:10d8:9404 with SMTP id v10-20020a056a00148a00b0056610d89404mr17969202pfu.84.1666336656289; Fri, 21 Oct 2022 00:17:36 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 26/36] tcg: Introduce tcg_out_addi_ptr Date: Fri, 21 Oct 2022 17:15:39 +1000 Message-Id: <20221021071549.2398137-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-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: -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" Implement the function for arm, i386, and s390x, which will use it. Add stubs for all other backends. Signed-off-by: Richard Henderson --- 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 a3538edffa..10d239d15c 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 e8184fe001..f089a74f0e 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 98da264f16..967bf307b8 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 b07b30b9fc..8bf02a96e9 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -561,6 +561,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 Oct 21 07:15:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617157 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp831506pvb; Fri, 21 Oct 2022 02:00:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM59Ng4uCFBfz9gruncTOvnhvpKONfgSYgcQWOkXSx00dPzKTFWLsnVGAZArYG8ptHV6odJ8 X-Received: by 2002:a05:622a:14ca:b0:39c:fc5f:6a6b with SMTP id u10-20020a05622a14ca00b0039cfc5f6a6bmr11887031qtx.562.1666342802812; Fri, 21 Oct 2022 02:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666342802; cv=none; d=google.com; s=arc-20160816; b=ihPtThN+a1pntrQA8Cat0MimH98ypmVQV59Xjd5xOn/Jk2SowRgle02jfFZRPYnfev ATct2SQC5GkAXfB0C1w/FIXSf3fu+pl7tWUbE0cLz890IblO2hbPTancNZIyF1uYxjZW 5ChmB8N63RR1NyxjaXwI1jUoPjeXj3kzXjkoQ7unLj34/+JwyjyGxGpdYpxxPG7QSSv8 M/VtLQFikG767MagvB345VdNUndeSKB0Ph+qUyMq49KVPORwT530y3FDhxU6ITF8oQwn A9nfgCmbXK++c3jAaQ1yobZaRf2lUdyC6G+rPGP/WxaH2PZYGUkr6EZ8R2PUGMXYIrdR QLHw== 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=bYHLJSZ/Z67z205wwObfO5u8lWYWwszfdw4ZjqYh6JI=; b=c/Y5ZbcxnccAnOrKO90TGQ7KpFPFnuSCAFCMW93dIF4zqw3kWqAUH4D7kNw8SNpJHb 8+ZRH+11NdedJs1fnA04h9+dc9v8cpPyCS79BBL+Er8oVIn5iSuhjsdn8QUnMvKPqlRT UQtqYUW/65SeaDmKPYuTqOBwld2kRfJMngffCVvku7CGZWTLegEQxy0fd5oo64zfCFuT O6EECH9E4A5aSPtrKxcQ/rgVgF/riztOPnh/8KEbx862XFMe75/b+H6R5oZ2YeuQhvqD oECFoPEC28xi8eHObt8kApyEFaQ7TH9qbdfqm0lKQwPMUf6Rtv/5g3F6r2NxXuMu44V2 aRAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ARILSVvZ; 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 b7-20020ac87547000000b0035d696d54basi11172623qtr.151.2022.10.21.02.00.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 02:00:02 -0700 (PDT) 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=ARILSVvZ; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnsn-0005tI-NT for patch@linaro.org; Fri, 21 Oct 2022 05:00:01 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmIJ-0003gU-6B for patch@linaro.org; Fri, 21 Oct 2022 03:18:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmI1-0003PA-Ty for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:58 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmHl-0005or-L4 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:57 -0400 Received: by mail-pf1-x431.google.com with SMTP id g28so1793921pfk.8 for ; Fri, 21 Oct 2022 00:17:39 -0700 (PDT) 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=bYHLJSZ/Z67z205wwObfO5u8lWYWwszfdw4ZjqYh6JI=; b=ARILSVvZTHlfg37iB64yDeFTYasAzrUYLZKD12V4rr6AgIJdBF6OS/J5FRTnfISkbn eX/vlZhApi1sL0pSjYUZcs7OLQbqv764VCmpauYZ6zwggTlr7Hwu90pBiXqCGXDw7ywE pMzR6jDhkmHyMpweYRgHIHyVPf4t7EJQYYCP+nK8bswrmJc7ujc4AlYpMYmAxfFSvudY UFsGIURENvNY6XLdP1j1/EhP8OfkLqF6vX9Rhzj8XzD/h1GD9D8khMAjLewkiuawAfce lkHg/5JNwBE3MluL6PxWHUK5mphmysLF8iWj1E/f403RFrtyXboql882f44wdLu0G7FD 0J5Q== 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=bYHLJSZ/Z67z205wwObfO5u8lWYWwszfdw4ZjqYh6JI=; b=iGmA+xKypS47s6RDGjGeF85KnRRRGu32ROlDu5FrycAndKsFBtAphqTmaUcdT9ZWxq 2GWcscW9IREJaQkR/WOa4QqdwEyDL95bLXbBXV7kNfdQ71mavgRvfYtKj5FWyHzoJmsu M/mqVF3DN/h9TMAyKahX1y5OzYcH92PgcstleAWJyOlujvIB8NgdRQ0toFU3USmZRk9+ BaXyYogXN77UFXctXt4QGkkYbz4VDmcigkvJtg8Stj1BQkAENsZb4cVvW7VKH/RvAlB9 wk5kKPoRXYUTYhLT47L57cEmUrTE97CsOb6B0W7tV6iGMkCL12lGzhcV/6+8wv1ThmKv VZGw== X-Gm-Message-State: ACrzQf3H7t+jDaIPxf8Go3V6CdqZ0ghNycFRFlu4TmsPh8BiPzBF1lSB /Q/i6EiW5pIBLn6oMZtza8J7dkO/FiqwkYFh X-Received: by 2002:a05:6a00:4396:b0:563:6fd7:9c98 with SMTP id bt22-20020a056a00439600b005636fd79c98mr18239388pfb.13.1666336659055; Fri, 21 Oct 2022 00:17:39 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 27/36] tcg: Add TCG_CALL_{RET,ARG}_BY_REF Date: Fri, 21 Oct 2022 17:15:40 +1000 Message-Id: <20221021071549.2398137-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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" These will be used by some hosts, 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 | 10 ++-- tcg/tcg.c | 124 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 129 insertions(+), 5 deletions(-) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index 7d4f7049be..1fe7bd7d5d 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_NORMAL_4, /* for i128, by 4 registers */ + TCG_CALL_RET_BY_REF, /* for i128, by reference as first arg */ } TCGCallReturnKind; typedef enum { @@ -46,12 +47,15 @@ typedef enum { TCG_CALL_ARG_EXTEND_U, /* ... as a zero-extended i64 */ TCG_CALL_ARG_EXTEND_S, /* ... as a sign-extended i64 */ TCG_CALL_ARG_NORMAL_4, /* for i128, like normal with 4 slots */ + TCG_CALL_ARG_BY_REF, /* ... by reference, first */ + TCG_CALL_ARG_BY_REF_2, /* ... by reference, second */ } TCGCallArgumentKind; typedef struct TCGCallArgumentLoc { - TCGCallArgumentKind kind : 8; - unsigned reg_slot : 8; - unsigned stk_slot : 8; + TCGCallArgumentKind kind : 4; + unsigned reg_slot : 6; + unsigned stk_slot : 6; + unsigned ref_slot : 6; unsigned reg_n : 2; unsigned arg_idx : 4; unsigned tmp_subindex : 1; diff --git a/tcg/tcg.c b/tcg/tcg.c index 10d239d15c..0e141807c6 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]); @@ -684,6 +683,34 @@ static void layout_arg_normal_4(TCGCumulativeArgs *cum, TCGHelperInfo *info) cum->op_arg_idx++; } +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 the top of TCG_STATIC_CALL_ARGS_SIZE. + */ + cum->max_stk_slot -= n; + loc[0].ref_slot = cum->max_stk_slot; + + /* Any other subindex is present for liveness. */ + if (TCG_TARGET_REG_BITS == 64) { + loc[1] = (TCGCallArgumentLoc){ + .kind = TCG_CALL_ARG_BY_REF_2, + .arg_idx = cum->arg_idx, + .tmp_subindex = 1, + }; + cum->info_in_idx++; + cum->op_arg_idx++; + } +} + static void init_call_layout(TCGHelperInfo *info) { unsigned typemask = info->typemask; @@ -728,6 +755,18 @@ static void init_call_layout(TCGHelperInfo *info) assert(ARRAY_SIZE(tcg_target_call_oarg_regs) >= 2); } 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. + */ + if (cum.max_reg_slot == 0) { + cum.stk_slot = 1; + } else { + cum.reg_slot = 1; + } + break; default: g_assert_not_reached(); } @@ -765,6 +804,10 @@ static void init_call_layout(TCGHelperInfo *info) type = TCG_TYPE_PTR; kind = TCG_CALL_ARG_NORMAL; break; + case dh_typecode_i128: + type = TCG_TYPE_I128; + kind = TCG_CALL_ARG_NORMAL; /* TODO */ + break; default: g_assert_not_reached(); } @@ -809,6 +852,10 @@ static void init_call_layout(TCGHelperInfo *info) assert(type == TCG_TYPE_I32); layout_arg_1(&cum, info, kind); break; + case TCG_CALL_ARG_BY_REF: + assert(type == TCG_TYPE_I128); + layout_arg_by_ref(&cum, info); + break; default: g_assert_not_reached(); } @@ -1740,6 +1787,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_NORMAL_4: + case TCG_CALL_ARG_BY_REF: + case TCG_CALL_ARG_BY_REF_2: op->args[pi++] = temp_arg(ts); break; @@ -4466,6 +4515,27 @@ static void load_arg_normal_4(TCGContext *s, const TCGCallArgumentLoc *loc, } } +static void load_arg_by_ref(TCGContext *s, const TCGCallArgumentLoc *loc, + TCGReg ref_base, int ref_off, + TCGRegSet *allocated_regs) +{ + TCGReg reg; + + if (loc->reg_n) { + reg = tcg_target_call_iarg_regs[loc->reg_slot]; + tcg_out_addi_ptr(s, reg, ref_base, ref_off); + tcg_regset_set_reg(*allocated_regs, reg); + } else { + int stk_off = TCG_TARGET_CALL_STACK_OFFSET + + loc->stk_slot * sizeof(tcg_target_long); + + 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, stk_off); + } +} + static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) { const int nb_oargs = TCGOP_CALLO(op); @@ -4475,6 +4545,19 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) TCGRegSet allocated_regs = s->reserved_regs; int i; + /* + * The callee is allowed to clobber memory associated with + * structure pass by-reference. Therefore we must make copies. + * Do this first, before we start allocating argument regs. + */ + for (i = 0; i < nb_iargs; ++i) { + const TCGCallArgumentLoc *loc = &info->in[i]; + if (loc->kind == TCG_CALL_ARG_BY_REF) { + TCGTemp *ts = arg_temp(op->args[nb_oargs + i]); + copy_to_stk_i128(s, loc->ref_slot, ts, 0, allocated_regs); + } + } + /* * Move inputs into place in reverse order, * so that we place stacked arguments first. @@ -4492,6 +4575,15 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) case TCG_CALL_ARG_NORMAL_4: load_arg_normal_4(s, loc, ts, &allocated_regs); break; + case TCG_CALL_ARG_BY_REF: + load_arg_by_ref(s, loc, 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_2: + /* nothing to do */ + break; default: g_assert_not_reached(); } @@ -4523,6 +4615,26 @@ 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) { + static const TCGCallArgumentLoc ret_loc = { + .reg_n = ARRAY_SIZE(tcg_target_call_iarg_regs) != 0 + }; + 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); + } + load_arg_by_ref(s, &ret_loc, 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. */ @@ -4563,6 +4675,14 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) } 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 Oct 21 07:15: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: 617137 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp816528pvb; Fri, 21 Oct 2022 01:22:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ccjJEQHbwof7TsMf+TfYroDCwguQsJy+BYYHUdlEAKkalfh6Jd8JRIXeuRQGXkMFF/7te X-Received: by 2002:a37:58d:0:b0:6eb:4148:bed2 with SMTP id 135-20020a37058d000000b006eb4148bed2mr13114727qkf.284.1666340573473; Fri, 21 Oct 2022 01:22:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666340573; cv=none; d=google.com; s=arc-20160816; b=vkFGQbE8Q8I0wX3yUHDnDJbgYufGY2wqwxGD60k2i7d41P4f46OfdthbjRUznhszmh ScHYxWCXYmrKg7dKYebbs7reA86g6SrHZjpXbdhCzrxsgqi5CrS+bjk2YxAC9yhwoNKi qQZqEP8I4e/SEz8YlpZacCh+b76Nqj9K3b0uK3bw7qL/UBrvhJKeCx7VYzuMo1pouimr sJgomOUMGjTbFmora7eXtnvnfqs8DEy4puIDM+RaatENLGR9777T01vnsjm1Q/C8MkkW RW6pSpYmHM2tdOlFblEtWrL2EeziRCEX8wdAHgWCC5+BM5niJH7Sjr5//sHpG9EwvDW0 b3pA== 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=6QnxmV1dby1iR3mkwH2QL8QXFFRTM/J6GCNHdOO2/bk=; b=VAUiN5sVs/NeHMT2T1b4eya+0q3MvMVuQbGIGw8xfySxjcLt86F+05mGUWZ/kqdGTN H7jFW4W3rtUdoYeOpFCJep8ICPekYVk41mVVsq+IpUPiupUXjuMiV0GbANPG3AWvJN4Q Dgy/53W8QAavBqg6BqnOuTT9QtFqSZph0qkbxdcaJMlKWtkCUsksfGlG+/ngKP13ZQH2 sAs6s3GCRu7VEMBVAXgs8Ru6VlZfUKEmeJgPHJn1ry5cDJpF9sLlDLWe+EUZetyWqSNi /6vKvw3YhZyTWtmdGwMoDPyWXTSGUueUMtSJ/QygAIi+CS+aptgRVEKbTML7Nio2xXqd R3Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OSEMIhto; 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 c7-20020ad45ae7000000b004b826ee2a42si2351964qvh.592.2022.10.21.01.22.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 01:22:53 -0700 (PDT) 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=OSEMIhto; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnIq-0005dR-KN for patch@linaro.org; Fri, 21 Oct 2022 04:22:52 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmIA-0003TK-9F for patch@linaro.org; Fri, 21 Oct 2022 03:18:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHr-0003Ny-Bs for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:48 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmHn-0005sF-F9 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:47 -0400 Received: by mail-pj1-x1030.google.com with SMTP id a5-20020a17090aa50500b002008eeb040eso4514766pjq.1 for ; Fri, 21 Oct 2022 00:17:42 -0700 (PDT) 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=6QnxmV1dby1iR3mkwH2QL8QXFFRTM/J6GCNHdOO2/bk=; b=OSEMIhtojYB8VdX23E6yLUQGR8d3GIuUerci0rp6643o/k4cQ35uSXnUEof3BG+HVk vR8XNahrk2a+SJZGDnZSzO6GmSdA2FUctxtHCLDXccnsBJdHMQV+comMsSyD/BCN+fFI Tunrtn1eIM2F+r9z5dJHYzbrztFuHDmF7NuU46Y2nNsOGrr6oWfvPs3e4kI+ZKi/jTZX hI9PvOsGpOFzd/LTCv7KfL3TBKHksfKS/ThDbPr2PntcbpWjWB5y0kE8Gz9zwmV6Xin8 qUQIR3l4QsCpMpuyg4qCpeheaEIjxTQYHGqLYH4wqVy+wfum5Cg0NjC0exO74SNxELtn CXdA== 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=6QnxmV1dby1iR3mkwH2QL8QXFFRTM/J6GCNHdOO2/bk=; b=Z55Srne20G2ibyVplsH9Jk9hLYWY6sZBcTyS9+OkhoXtyba2HkgtxHEuh0YQPBm9nj OPZ7n31JxgkV6kf8Bg2SExt9YHFbR+EKGvGIpTj1O7Tj1zhj3mN2SoJEVYYSZLTgKes6 4MSSaOUS168LVmv1PTz/51JGxhuxdrO/8Xw18GYEWR918wIB7szHbh3WWirWjiF/yrz2 XLp2R/oaLPgh5JDkWyu6f/mA44vTUuEMr8ZFoEN1Xzkkr3OZC/CSMEygZKTOaxOXdYJK 5Et7YHjrk4lDOxOIwmz2NZdqKzh92JNI5+DTP/o0GX4hvJpZVzhHAnlJ57KqzxYe8EtS V3lQ== X-Gm-Message-State: ACrzQf1iyroQf/fK0Kb4SI8ArVXUAqXvDcTAnUYErA7ANuWM/oV6JUi2 2qaSe8v3GAzmRawle9k535IKtfMY0cZY7rJb X-Received: by 2002:a17:902:d4c9:b0:186:822e:d030 with SMTP id o9-20020a170902d4c900b00186822ed030mr223383plg.33.1666336661757; Fri, 21 Oct 2022 00:17:41 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 28/36] tcg: Introduce tcg_target_call_oarg_reg Date: Fri, 21 Oct 2022 17:15:41 +1000 Message-Id: <20221021071549.2398137-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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" Replace the flat array tcg_target_call_oarg_regs[] with a function call including the TCGCallReturnKind. Signed-off-by: Richard Henderson --- tcg/tcg.c | 14 ++++++++------ tcg/aarch64/tcg-target.c.inc | 10 +++++++--- tcg/arm/tcg-target.c.inc | 9 ++++++--- tcg/i386/tcg-target.c.inc | 22 ++++++++++++++++------ 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 | 11 +++++------ 11 files changed, 78 insertions(+), 49 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 0e141807c6..25dc3c9f8f 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); @@ -749,11 +750,11 @@ static void init_call_layout(TCGHelperInfo *info) switch (/* TODO */ TCG_CALL_RET_NORMAL) { case TCG_CALL_RET_NORMAL: if (TCG_TARGET_REG_BITS == 32) { - assert(ARRAY_SIZE(tcg_target_call_oarg_regs) >= 4); info->out_kind = TCG_CALL_RET_NORMAL_4; - } else { - assert(ARRAY_SIZE(tcg_target_call_oarg_regs) >= 2); } + /* Query the register now to trigger any assert early. */ + (void)tcg_target_call_oarg_reg(info->out_kind, + 127 / TCG_TARGET_REG_BITS); break; case TCG_CALL_RET_BY_REF: /* @@ -2826,7 +2827,7 @@ 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]. */ + /* Not used -- it will be tcg_target_call_oarg_reg(). */ op->output_pref[i] = 0; } @@ -4642,7 +4643,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)); @@ -4668,7 +4669,8 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) temp_allocate_frame(s, ts); } for (i = 0; i < 4; i++) { - tcg_out_st(s, TCG_TYPE_I32, tcg_target_call_oarg_regs[i], + tcg_out_st(s, TCG_TYPE_I32, + tcg_target_call_oarg_reg(TCG_CALL_RET_NORMAL_4, i), ts->mem_base->reg, ts->mem_offset + i * 4); } ts->val_type = TEMP_VAL_MEM; diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index f089a74f0e..dc99fa3257 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..41d3af517d 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -79,9 +79,12 @@ 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(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..82c8491152 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -109,12 +109,22 @@ 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: + switch (slot) { + case 0: + return TCG_REG_EAX; + case 1: + return TCG_REG_EDX; + } + break; + default: + break; + } + 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 967bf307b8..2efefe863e 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 8bf02a96e9..914806c216 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -204,12 +204,11 @@ 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(slot >= 0 && slot <= 3); + return TCG_REG_R0 + slot; +} #ifdef CONFIG_DEBUG_TCG static const char *const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { From patchwork Fri Oct 21 07:15: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: 617143 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp822363pvb; Fri, 21 Oct 2022 01:36:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM50F5EVIEPk0L17jgBCOEif4FfJ87dWp7Hi3NrVpoAIaLp08yzUDif9fLEqzkERTqwS1FUd X-Received: by 2002:ac8:5b05:0:b0:399:9b82:77b4 with SMTP id m5-20020ac85b05000000b003999b8277b4mr15133041qtw.681.1666341396538; Fri, 21 Oct 2022 01:36:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666341396; cv=none; d=google.com; s=arc-20160816; b=txvhcSFr4FRIf1V1whKlpOEGaUrRSneCN1OK1EOqss87ldbyVsOczoapuUNVzi6/QK RVGqB7e3g+/bAhKHHWN3mRuWmIrbwL3SY8Act+gLXroQ3JoGZL9RrWYVE786dF+3sZVU QVMWuGJHkLgnJaOoZinC5/Nj8iDS0kRQIMFBXhCRCfFBo666UH9S01Gz302d71c6YSaI wXr0OtHmjpdtbrACBIIaWz+h5ySAY3bB3UEgDpaMiVVjJyfk9G9TqMyH9gw+43gDD9NI J8FQav0ocVb8/iLHutIEFsnlNk/Jjm67TijPIspIsxgOo9ZEWDb/JVuKSw6a0Wem2ly9 0DbA== 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=75+xsYOAtaVg4plBJLa7rmgReN2/m1syY7D3SMY10mk=; b=MfDK5XxHQCflCuQ9jacuo2kklSU/oCko8qfHeMpOAPznnRgeUY6HQck3m1ne1WIjNf Pu2A38K7tes1Sh2TUd7j9eXaZKtmOuwVsQHd8SVf/F0DhKpPtb+bKmde8anhlAIpKJiU wbIzk3gIX3SHpbyQ1PlyS0rM9DUFUdcbw3RDGy6NB4tc0RHmbdIf5XE9qmOM/L559TNe /VvvzqowCW6RRvD+nB6uHQx+aFqhFjpcBInz8X/78ayr8w2FyVmWFV2mSZoCwMGyPvvZ KC8vAcqDKbU13OlHuvWtvYz2p6CH3BgkJZcwj7toysDtHryYpDqo4qlFRI8btZBev0X+ 5JMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=en7DZ46n; 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 10-20020a0562140cca00b004b1aafe878bsi11647918qvx.463.2022.10.21.01.36.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 01:36:36 -0700 (PDT) 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=en7DZ46n; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnW7-0004Vf-GV for patch@linaro.org; Fri, 21 Oct 2022 04:36:35 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmI6-0003Rb-MP for patch@linaro.org; Fri, 21 Oct 2022 03:18:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHw-0003Or-87 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:55 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmHp-0005to-MR for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:49 -0400 Received: by mail-pf1-x42d.google.com with SMTP id i3so1786490pfk.9 for ; Fri, 21 Oct 2022 00:17:45 -0700 (PDT) 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=75+xsYOAtaVg4plBJLa7rmgReN2/m1syY7D3SMY10mk=; b=en7DZ46n7+VDSX6OmK4TJjT6CN6NAoaJ1/nzueUdUTE2VVqjCacCQ4hsIsXUiSXVvx 0AbGqvRAnUdXjDxv12Ga05HRxMgkvNh1FMdZMwiiH90lw9xCD/id56mhtLsTanNK5M0e A9hCqArpkfH04Eh24VZDTeQN2kzOxttMhubohiHgO6/3OMhRf+osrfGYuyb1mqOn9dno 2GdtVqdziPAaWz4LyVaow7hxvepmK/g1bAI62Mk3L3PWWVyAVuwKwpUqeTSZTKTXeAQu EPdAy7hTuZV2LQkkAMR4U48+9BuwzxXqWf0AV3c0T01BjVJCz3pCuhKphIuUUESVo3sR cSbA== 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=75+xsYOAtaVg4plBJLa7rmgReN2/m1syY7D3SMY10mk=; b=cUYH5md9VstYvaM8kLJmArB8SYSVFFCelMDmr6wL4Ko+oVVXUiyxUTxXChXKdNpvB9 KFHt/XPzTv75wezwgxOO7dvrGXF6CCi+HZdgO54W49mm+2+aDucbuXoAvhVGEJ/vhEWa HDIzvYOkLG9vnbMH68+AZwgc5TRi/Z1YsEd/vBOKjfeKEN9XLSLBsxaqBU6epBLMjdh7 KkuMZDEnTt01gZEkZmwKXV6GxWuPDdlacbE0AfxogQKNcP1xQCcJjT9dRrhTlvJniwlv UVsyJGszQI1HTPV/Z7+k8U7DNk11B6Pc/LxMHnxZ4QzvBgcSRLAtX1+l/CqgftXIF5QH RUDg== X-Gm-Message-State: ACrzQf3z/W0I/w7XEIpIrbvg/6v6SFhR2amT671mYaz9P34aHNXaZT1K ka9XePMbeyh/2xN77gbCpv64Rv9wrRMmmqjJ X-Received: by 2002:a63:5a0c:0:b0:46a:fcba:862c with SMTP id o12-20020a635a0c000000b0046afcba862cmr15020890pgb.187.1666336664381; Fri, 21 Oct 2022 00:17:44 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 29/36] tcg: Add TCG_CALL_RET_BY_VEC Date: Fri, 21 Oct 2022 17:15:42 +1000 Message-Id: <20221021071549.2398137-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" 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 | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index 1fe7bd7d5d..44ef51ca30 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -38,6 +38,7 @@ typedef enum { TCG_CALL_RET_NORMAL, /* by registers */ TCG_CALL_RET_NORMAL_4, /* for i128, by 4 registers */ TCG_CALL_RET_BY_REF, /* for i128, by reference as first arg */ + TCG_CALL_RET_BY_VEC, /* for i128, by vector register */ } TCGCallReturnKind; typedef enum { diff --git a/tcg/tcg.c b/tcg/tcg.c index 25dc3c9f8f..9ec5b85f44 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -768,6 +768,8 @@ static void init_call_layout(TCGHelperInfo *info) cum.reg_slot = 1; } break; + case TCG_CALL_RET_BY_VEC: + break; default: g_assert_not_reached(); } @@ -4685,6 +4687,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->type == TCG_TYPE_I128); + 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 + i * 4); + ts->val_type = TEMP_VAL_MEM; + } + break; + default: g_assert_not_reached(); } From patchwork Fri Oct 21 07:15: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: 617145 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp823092pvb; Fri, 21 Oct 2022 01:38:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5+L/V0P5etJl2YICDgRj7S8nO3l36smZNA+xN2c3qFlw/cs29vM+KK1ZJy8iZQMgR/dGPo X-Received: by 2002:a05:620a:f10:b0:6cf:c0a6:5b1a with SMTP id v16-20020a05620a0f1000b006cfc0a65b1amr12441493qkl.121.1666341501937; Fri, 21 Oct 2022 01:38:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666341501; cv=none; d=google.com; s=arc-20160816; b=XZoFTHMVVhZd2pGWc/LrNtdtw//EAZ5RV5+u2JFvweF45XhdHrr1e7PCja7S8ZcTbF cL5b2IENYtO32j1D4lkCw4BuyYCeuCQUg5FFGf4FUY6dMBImOq36GAXGg4oOsCuWGmcW 8wMldDIa6N/dvr5AISbCEmOFda0ib0pCAlewRO4WY0NXlu/tLyS1s66r+aTGpHkPC20T 2yiMrK4Cma6iuuaklA5NmfW9A/z8FDuTHJmtBhC9uwqo2v+klvzHGCMY8XdJAzbJonYa 5rMTnRf3JksREKRoaex2AIsgbWm54PS9bL2lshR9HonqlDhQHjAvnszZRoa8WO1fvW0O tPFg== 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=otax3boOrkJbpvJnQWAvehNepZr14GD0jCowiyMr4Ww=; b=EvbwsLML9cet4fjCGepIjP6V/9ytaDhD1W/aYKZjbpWgieX3QZnu1ApUkzaY5x85aR yP552z0bsha+s7flLeXeGXP6aMq44BCMjfPK7BPR00nrEzYTC2osow8VLesWUiQRwJ1G eLFnLDzxWO8mKYRvTffYcFWYtLoP7Q/wIt5H5W6C2q0ZWpH4NEA2XbGlewRpHMP2Alst VUiAF5+cEZfPuqIsj6okzP1lvZgOTdAKrjzZeqNk9R+chg8AvBns7pzJsapjUt4dtFVp 0NVQb/6Am/i4G3R3TD/FCpVMrN4AXNSq1utfZzs1w0/tV3PWSLrsVfrQdn1ivnj51MAg TY+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kmAPj91q; 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 a1-20020a0562140c2100b00496fd123f0asi11140582qvd.272.2022.10.21.01.38.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 01:38:21 -0700 (PDT) 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=kmAPj91q; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnXo-0007Ib-9J for patch@linaro.org; Fri, 21 Oct 2022 04:38:20 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmI6-0003Rd-T7 for patch@linaro.org; Fri, 21 Oct 2022 03:18:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHz-0003P0-PW for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:58 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmHt-0005uL-62 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:55 -0400 Received: by mail-pl1-x62d.google.com with SMTP id l4so1567477plb.8 for ; Fri, 21 Oct 2022 00:17:48 -0700 (PDT) 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=otax3boOrkJbpvJnQWAvehNepZr14GD0jCowiyMr4Ww=; b=kmAPj91qi3D0giv3FOtbx2trwu39E0vY25Zvn7e19+MMcbdcixfQIF0T6gCI8Qs93K MBtW5P7CNBGKHdgpAlwNPK/AKxBl3GSwK5d22ApbgKvRDCG3Oi9xRUkIsX1ZemrkQq3L IWAvt7NL+KZCwq12QpZTNgWQ+YfTA/TVUwSblTxODjBig3DnVkLoKYoWTr3EvrzqMG5f ncaNn47rHziLmVbjIjJEYqAJ2ci0mfkh4Ir4uR0ViIy6zFO5GJXbo3Fnh9NeD73h8P/P sFw1wNFeJC/ixSEuhAY9EMCcfVHs3lffNUrCCw9/nnubY3syEtCAC+krDC4800MCyHXc RVBg== 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=otax3boOrkJbpvJnQWAvehNepZr14GD0jCowiyMr4Ww=; b=Owx9ApC+kLAsTyHMlwff/GIdTCpF6IEWjDaiaRopYhTGdj7mkx13ZoVzqxNb8Y/Gcd t7WB0B5zJpOCptrSBGEIF1JiWttDDsjHuYiZSM3jwANCyUHDN2+moor3+TR9dvdH4BD9 euExwP7/5hWtMDRv7US5mDKSy055whUcHgZgzIiRfvvLVH7rFnNLCbyRBq4yNGFEncJx qr4LQjXYYabEsWMFMoLxRTg7cz7fkrsYI+WQyz/D4kBdx11Y28ljcdT05LHLAx1G5QMS OKxOQRPohaOz/Itrj4pT1Gd6M8Rcbwwz8IQl+zYoCEcBtZCH34fjAl7wUQ9EHg4l5AER Fw1g== X-Gm-Message-State: ACrzQf2kN7XAmjSymA3plSbhRmJhx5g/RNVQS6gYwbQ1t1R8cDAdcnLH smXmaSS5WuT4GXQuqwhLqxQ5Y6q/UdzVGtUa X-Received: by 2002:a17:903:1053:b0:185:37cb:da04 with SMTP id f19-20020a170903105300b0018537cbda04mr18269080plc.108.1666336666859; Fri, 21 Oct 2022 00:17:46 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 30/36] include/qemu/int128: Use Int128 structure for TCI Date: Fri, 21 Oct 2022 17:15:43 +1000 Message-Id: <20221021071549.2398137-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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, T_SPF_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" 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 | 34 ++++++++++++++++++++++++-------- include/qemu/int128.h | 18 ++++++++++++++--- util/int128.c | 42 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 11 deletions(-) diff --git a/include/qemu/atomic128.h b/include/qemu/atomic128.h index d179c05ede..5ba53f2f10 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 @@ -153,7 +169,8 @@ static inline Int128 atomic16_read(Int128 *ptr) if (have_atomic128) { asm("vmovdqa %1, %0" : "=x" (ret) : "m" (*ptr)); } else { - ret = atomic16_cmpxchg(ptr, 0, 0); + Int128 z = int128_make64(0); + ret = atomic16_cmpxchg(ptr, z, z); } return ret; } @@ -167,7 +184,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)); } } @@ -176,7 +193,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) @@ -185,7 +203,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..a062284025 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,12 @@ static inline void bswap128s(Int128 *s) #define INT128_MAX int128_make128(UINT64_MAX, INT64_MAX) #define INT128_MIN int128_make128(0, INT64_MIN) +#ifdef CONFIG_INT128 +typedef union { + Int128 s; + __int128_t i; + __uint128_t u; +} 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 Oct 21 07:15:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617154 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp829947pvb; Fri, 21 Oct 2022 01:56:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7y9xo2RpSun1WbBHzwo8WiPolJh6AVTlv7JATnDn3JqSlHNkk+t7Id+MkMco+LJW9+0i3I X-Received: by 2002:ac8:4d5b:0:b0:39c:b6d2:b631 with SMTP id x27-20020ac84d5b000000b0039cb6d2b631mr15221628qtv.487.1666342587937; Fri, 21 Oct 2022 01:56:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666342587; cv=none; d=google.com; s=arc-20160816; b=daSbDn9pbIYdfEGR/+f2uBgN3FRsXuA1UXYT5qf9crwBhlw9OKqGmG/cqA9CzHCT7G txfiK+1CWD978i3Om5HpeoRaZ4XrM/Txe/9k1UTez9rslandqmg8QFNUaFEqc/S6Lgy0 pBJoOhMpsfUXeClR/z3kCTDaWY+0jFAIahY8STJOV6RWs/Bu+8hWvTJT7e5gFF5+v3W9 n02CT9Q5XMkyzVgY14mDmiAB2deRhnsQd/+54Y5pKANzLkZMscQCkee8uG1dHIsLK4Xu UazLCVMFyT8pkoV/wUzJ8Fv+cZLgykVeswrPXjtBGI+xUQjJEd0BmbApNfsEiR8FJrbe 7NqA== 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=lLnD6XwJTmW9yrKiJSoQgxFQEO0sDHADUyXUWB1TLM0=; b=TocMEy6jLvQBda8GeaGeko11MR1oJb3MkXPxoXaYFWPIyKg3EWRSt5e84WcHQkWb7J NqlO+xO/L6I+6ckERj0ohXQzrk89Mm6K1Hug7ZTIRhTUgq6OREGE2b134jNM78vxWOoj d4TLAEPravsJOJ/co3u8QDvMWgY6p8rs/Xpt17mb+5vfIo3rWLkPRAYsKFpES9Whxyes QxyRqb0+T4TkmgSQmlDz3SMnKn6UyWijZu/6qshL/6LO0X9DzzTKDLAH7VG/PZ7+Qi6F bULW/Ai6mR+pZSiKOF23+IWdnw4Jm85T1XUMA1+gLJjt2fPzuveFS0hCSLTZrJzMqBAQ NlAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sUyarQfI; 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 jt13-20020a05621427ed00b0047962d5ee41si11990939qvb.20.2022.10.21.01.56.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 01:56:27 -0700 (PDT) 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=sUyarQfI; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnpI-0003kP-La for patch@linaro.org; Fri, 21 Oct 2022 04:56:25 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmIE-0003aK-7U for patch@linaro.org; Fri, 21 Oct 2022 03:18:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmHz-0003Ox-07 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:56 -0400 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 1olmHu-0005uX-Ub for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:54 -0400 Received: by mail-pl1-x62f.google.com with SMTP id 10so1624762pli.0 for ; Fri, 21 Oct 2022 00:17:50 -0700 (PDT) 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=lLnD6XwJTmW9yrKiJSoQgxFQEO0sDHADUyXUWB1TLM0=; b=sUyarQfIbw3q46Wh+JXz723n+4A/ESoDQG0DHNgqhjYvF0E9UQEdikgVh2Ir4IATXX WWbTasQyjtr1/5YUS7fF048ROwOTEtD+x9m1SfiqxGzRMwzNl0Qf6+p4SrERJyl1Lu9F Q9kR8J6j+QLK5O929H6bRM16JBTcpw8UNl+9Xh634oM/0W1F3MD84bZQW9A/Epgr5eDd /YHc7URMjJkzY34YuouAoqHTFEqaTdWLvMGVBKtI5pmL/AMWEz1LS9GHSdsSYA+WzuUK cMVcMuY8oQo3+R3AJfXu6vtNobVUoHjHnKacOdlidGJ/wxbjdfSQ9AT3PL1H7QDu8vpn ubmw== 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=lLnD6XwJTmW9yrKiJSoQgxFQEO0sDHADUyXUWB1TLM0=; b=6XzePgahtoxr0BcEjq/Tlj5ERWGtVkizrBxqmioxcIZf2J93llHFtNqcZA0bFmPAqg 5w4jf0oZQT5lxHf1QfJC/EAHo6KeIcFPiax0E/W3dfLrjAE+1COPKs6WIZTOftBAJ6nn Fy6WBg8xhVR9jtnLlELccnp9cQIpaGlJMF6nn8q7fxCAp/HeFAAir4TSw7zRshan0Q54 /RYyyoYotpokIdgDvi42cdHHKyVdRRZKVCRA/YtJsVtq4t4LPOExBIiMZEINAFrDDlcC KjqR+z+wnxGbaExQegHEbAe6R+opOZJx9USmLabXTuozvezuhWH6QwE3JdgEF3gq+2CI EfYw== X-Gm-Message-State: ACrzQf3T872PiAkcfBimncWt8pp78iSppcK/Oh+vGPIY3vlZS3IayXVW 6O9TYmIKoZk7nhlzJE+EfQNeZKA2ZP7y9g7f X-Received: by 2002:a17:902:f7cf:b0:17f:9081:a3f7 with SMTP id h15-20020a170902f7cf00b0017f9081a3f7mr17734395plw.3.1666336669259; Fri, 21 Oct 2022 00:17:49 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 31/36] tcg/i386: Add TCG_TARGET_CALL_{RET,ARG}_I128 Date: Fri, 21 Oct 2022 17:15:44 +1000 Message-Id: <20221021071549.2398137-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-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" 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 | 32 +++++++++++++++++++++++++++++++- 2 files changed, 41 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 82c8491152..3b0c567270 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -120,6 +120,13 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) return TCG_REG_EDX; } break; +#ifdef _WIN64 + case TCG_CALL_RET_BY_VEC: + if (slot == 0) { + return TCG_REG_XMM0; + } + break; +#endif default: break; } @@ -1194,9 +1201,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: /* @@ -1683,6 +1697,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 Oct 21 07:15: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: 617121 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp799220pvb; Fri, 21 Oct 2022 00:45:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7FxQgGVAjMjoj2yQ5P3EUkMqudwMU+FW0OC/onQki1RDsEbQfHukPclAjbFVACJ6wIKBZc X-Received: by 2002:a05:622a:181:b0:39c:bd89:7b9 with SMTP id s1-20020a05622a018100b0039cbd8907b9mr15082519qtw.590.1666338325893; Fri, 21 Oct 2022 00:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666338325; cv=none; d=google.com; s=arc-20160816; b=Q79TjIl+u0xv2rtqr74QwvCOqDg44xjmmo242Y669Ysi9ZTISgqjFXrz2yzbnpKJgb KSwm05nj4Mhda95M0Y3I57C74pEvdsyC5850IKIZ5UmkQI6/rw6Z6Qz2QEqw7a0CI1iY qsWGju/NcCxwbhHwrgYaMc2SGqRr+TLz8wsTJo44ZAVWreK3MAbS9jDZ9mzcAwoQbGbP pjwyzNHNcqS7Gq5Q3tXfdboAMJn6fqICWbSP55PULvjbqmIv1h1x7b0NTaHtQYZlsd+L 8ROLYSu5iATYtn8SVHU5dFK8NicpHwmGfp2Q1pSCe872tpg/GwB0F/QnUsjBgOF60KY7 4ahg== 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=PPW7RSSNm9yil/F5lJhRwPcfplDAlAe1JqivFknlUJ0=; b=SJwF/0FsMAt2j1m/qrACgp9jsmxnDNjejMIfbPkq7OC0AAXnELBzTt/hxLLtS8Kprf azBqhSWamC9t+q/UL50WYyxRfDLwsPGGRm8J1EO7s8XG0L/NM1IGBh3kd9wafITGi9Jm T1KLOU/kafuQ290n1WVGxSBAr4SjW3SVU+U46TMTrHBL7wF8jnYUCfqjuu6E38LHbvT9 58mpqJT7ITfJzNUEU7+GajjPmZcvQeDFrBLEgkZRy2N7tQfM3ROLUBmWTVFa1sUac3K1 Hgcg2pGPO5HrxnHuyuLdnmkwTHf7cxsl0L1EaAusBxo5rAbZwXXGknTnHh1XLjqP5wZ1 b7HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KVx1hoYK; 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 fz18-20020a05622a5a9200b0035cb983c5ffsi11769515qtb.257.2022.10.21.00.45.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:45:25 -0700 (PDT) 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=KVx1hoYK; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmib-0002KR-6Z for patch@linaro.org; Fri, 21 Oct 2022 03:45:25 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmIF-0003cT-7g for patch@linaro.org; Fri, 21 Oct 2022 03:18:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmI9-0003XS-HB for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:18:05 -0400 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 1olmI7-0005wH-Rj for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:18:05 -0400 Received: by mail-pj1-x1029.google.com with SMTP id f8-20020a17090a664800b00212464cd49fso2010687pjm.4 for ; Fri, 21 Oct 2022 00:18:03 -0700 (PDT) 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=PPW7RSSNm9yil/F5lJhRwPcfplDAlAe1JqivFknlUJ0=; b=KVx1hoYK9RucxTU5TRva3rsIRf8/C2gqKErQVQt04WFNvoKlU0O5zcN247LNvL4cWy 3Dh/e0Ytl+zfRRAIjOAj3Bny0hhhmmjezkZSewBjdK4K2waBNuEZOynrtPpxTM4nOkL9 3Ju5pjBJYtClYVF/kH0Yfc3huDBwiTTUM4UVyYz3QullshaV/Hoz3/TdsraGSoewsPll wPqTCpSA/wuCZzYcpS0iKePO1zMlTW/F1nlOpTS9UA9THLG0xdXkKkuRytLClScL66kH cWMrMbAhmu4ZAqoDSyTawBV+biiqqjqKoBeI4EDzewOu2ETuq35/u4GMspxwlvBDl746 2KbA== 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=PPW7RSSNm9yil/F5lJhRwPcfplDAlAe1JqivFknlUJ0=; b=wL4c9D7cf1yJJ3df+Z3/150pKu++DI5/L8WV8Nkh7dk92IK/a6XtgiSc0xsLePaZMx Fy79PTFNqmEy3k/8fP7uwIrqBiGQpSfou+v5P6+j12dpCkTA1zP2TIxOHQp8AyADol9C I6bQJm3ZZ3lAU65hU4z0H/2bYBP53HuJ2KuLXKS/9UG150TC4WmCK7h/4nCex7pt9ClP gUTN8ix7877H4wVGTNTIwdv3laLs6Fk8oDEenGh6WTFIzyE+oOWfQeFkb9i6OKQ5NUj8 lsHtGzJZlZeSzXwJ3NKRmF17EskktZRIix36KAtT6oFgxqCeuVVamOIvDZJIa/hPM/3Z nrMw== X-Gm-Message-State: ACrzQf1GPXJ0f1jUHwOx0FYCzX0twawjZkLG9mVYgAXv4EPEZ7lCbNPk BwNJAUXWPoAi3KItachNJ9YFxmXSXPbq1UcA X-Received: by 2002:a17:902:7d87:b0:17f:9cd0:2e03 with SMTP id a7-20020a1709027d8700b0017f9cd02e03mr17919783plm.164.1666336671798; Fri, 21 Oct 2022 00:17:51 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 32/36] tcg/tci: Fix big-endian return register ordering Date: Fri, 21 Oct 2022 17:15:45 +1000 Message-Id: <20221021071549.2398137-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-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" 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 bdfac83492..114dece206 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -521,27 +521,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 Oct 21 07:15:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617156 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp830809pvb; Fri, 21 Oct 2022 01:58:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ik1ahkKmNSMt2A29n0lAxZIuPvLWZ+qNAHm2rEYkQuW08c4g4xMDuJTXBHIuPtoXRzdZo X-Received: by 2002:a37:a9d7:0:b0:6eb:2696:727a with SMTP id s206-20020a37a9d7000000b006eb2696727amr13115334qke.8.1666342713096; Fri, 21 Oct 2022 01:58:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666342713; cv=none; d=google.com; s=arc-20160816; b=RfuiBC+EG0u05MWe+yKg9xXyWDPZU5pUpWL4GuXKmT/qR2ssM0l2oUEODUFsXSgrwB 8f969b+LhOT2gZ8p/u7+NKdUXLZ/wMfk9m/6ZKgZFovp5x8FkmDczNPVsXPfM+GQTU/m Fz2JZu+Ar00PnRLkzismIW22YyhNl0oAJgjm/tyoj2UzvphwUJHW7d4NAVhzi+pNQk8f iGT5mhAuGolrowiUZGuDnTu6fPwwO/gwH6JhUE8pzYcDehT9MKc/8iNtq2gYKfUFmJrB gclljiazrGsbb3pV0MT4Jq8lfFxUtICyOu80l02mv6m1jPyAA60QTvHPRBcuQDbXYveq g7Eg== 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=QVoRiK3j5+lRW7rSsEPFl7/tCZVXuMds/nbUBLlYc34=; b=04koJuwhetXUHuRVh0F7BoHXz/VkKTy/reIAqkk3vtNbZrrHy5dfSUKc0Izxfll53i OV/odEQzqn2+QhrbnKFkskRTE79SppsLwPcqQJS7wUOBV6SR3n9S8VBjrnTkpUFgp+c8 Qq8sBadaHZvRCJl8ZVYUonbwfqtXA4vGwT5ezgud3JfzbqX6OR3tiLBgC7GJ5I9JW3qt lnfgUj4iSXLSf0rFle4cuJAgj5C9uLmBzGuRxdvsad8CYLPQl1tA8kCdTH3RetLfb5uJ LsNco4gI+JmcWLF81gcCpuHpEMcud3Jg8Lp3+jVMXM4dm37AWUx4cMqsZ0Mr0EsLNs0G h6qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BWOPbD2J; 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 z17-20020ac86b91000000b00399c1eccbc5si10819731qts.239.2022.10.21.01.58.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 01:58:33 -0700 (PDT) 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=BWOPbD2J; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnrM-0000UQ-5m for patch@linaro.org; Fri, 21 Oct 2022 04:58:32 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmIE-0003b6-O9 for patch@linaro.org; Fri, 21 Oct 2022 03:18:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmI2-0003PB-Nc for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:58 -0400 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 1olmHz-0005v1-R5 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:17:57 -0400 Received: by mail-pj1-x102d.google.com with SMTP id x1-20020a17090ab00100b001fda21bbc90so5828054pjq.3 for ; Fri, 21 Oct 2022 00:17:55 -0700 (PDT) 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=QVoRiK3j5+lRW7rSsEPFl7/tCZVXuMds/nbUBLlYc34=; b=BWOPbD2JWL4tLyCjs8EhKb0h27+hbV56lUF7t6EXeS5Eb5fxHI5Ru3NsHPUiu4/HKk GEgus5m3iVkBYgHQS2eaUG4J0Ag1/71gHKu8Iv2t7wVhDjMD4E/tSFi9eUz/sVGhTYPi gOZtbXjn9X0mJiDOhYP5Yt4SiGxTfwnk8Hr+DZexe48V+FEnX1jEjhFLNtvePi+D4RT7 1aW26yU9GunccHcO12YPftxlXgBMHG85ixTUIoWd4aOZSQOfheOYnJaaJgZGVagrsS96 X0tpr7NPe27p5MpLICeCB3ln3i9O84KjRokdmSKvZ0Kj7tzO1U++tDAdobycy8Oc3Bk3 Ff2w== 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=QVoRiK3j5+lRW7rSsEPFl7/tCZVXuMds/nbUBLlYc34=; b=6AaVL8nAgHHxc0ZOZ0M6WgzMgKhjPnYnj1IlIUjspwBSuhNLDPa/FTTK9dNFK84+2a H8o2UPb9gXAuT7iluwJo5voEXMCJheWUVTiE7gA5SYppo+NeQjiCv6GuxGtHjQaWL1OJ 8P75RXNxxefNX6vsjvTMgSRneMbykxBc/8UL8tzT+LfwCCVWV0KaQ59TKVgVumHhU3uE Iu6BoGxJeKw4jp0KQOpABCyFVWMcpHzOmbaVc5IinRu/ZdUW6y6D2UbQwrwy3ErGccw9 sVjtNNRLHUpRMd9cmUkHMiuIFuCcVnjuzOdrtZIh7dmQaLqKp/uCJQ/zDtODvC8yk3oy dVAA== X-Gm-Message-State: ACrzQf0vmypjg7U8IMert6O9kho1RoWvuBTM9xadnaqxkKZ0K/MLdImh LMspRYrMQjGtUPc5cgtATcMznVUO3Ds0d88b X-Received: by 2002:a17:902:8212:b0:182:2f14:f6de with SMTP id x18-20020a170902821200b001822f14f6demr18194450pln.38.1666336674297; Fri, 21 Oct 2022 00:17:54 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 33/36] tcg/tci: Add TCG_TARGET_CALL_{RET,ARG}_I128 Date: Fri, 21 Oct 2022 17:15:46 +1000 Message-Id: <20221021071549.2398137-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-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" 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 Reviewed-by: Philippe Mathieu-Daudé --- tcg/tci/tcg-target.h | 3 +++ tcg/tcg.c | 18 ++++++++++++++++ tcg/tci.c | 45 ++++++++++++++++++++-------------------- tcg/tci/tcg-target.c.inc | 8 +++---- 4 files changed, 48 insertions(+), 26 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 9ec5b85f44..f921a5ca24 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(); } diff --git a/tcg/tci.c b/tcg/tci.c index 114dece206..9154a3f22b 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -471,12 +471,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 (;;) { @@ -499,26 +496,27 @@ 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_OPC_PARAM_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; + tci_assert(n <= MAX_OPC_PARAM_IARGS); + 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) { @@ -543,6 +541,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 914806c216..a20a983422 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -576,11 +576,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 Oct 21 07:15: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: 617129 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp803486pvb; Fri, 21 Oct 2022 00:54:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM77EfGXKiNfuF0oTWZ+TZRMrU2ASh+fTwhoGrGMRpPTgSHjIOmxkHUmtrpAjjOnrKG154uq X-Received: by 2002:a05:622a:51:b0:39a:3854:5a34 with SMTP id y17-20020a05622a005100b0039a38545a34mr15301417qtw.143.1666338899031; Fri, 21 Oct 2022 00:54:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666338899; cv=none; d=google.com; s=arc-20160816; b=uUXhmpv9GwE7RlFd2ycU+hVDGjGFK5h1znunWJpfA1n+NS/nTEWxX6tijiTaXJ2EWe F9umXkfbMJSRTbufQ+vGv5sPZp4PAOBue8znBo+bQ0j1i1BkpEXKUAe9V+ygyloOVb6G 6txHuTIWoEons9jE5ESJleZhzfXlabpzEgBL/O7DnMRspRpXE+1spn3SUtzuc0Cf3LsO tnjXHe797T2V3fxIPvUpvp10qTS+zbDtx3sCjs1NRPcH9eICa3JGpzm1egd3I1rEU7nf Fdqqudo1y9DWAQc/SPzr/SCrhy6prg9LnqdmWBZeO6inLjiEc7WidUS3C6ESr22C0o3p izyg== 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=6MECj/5wfaqJXkyCl06/YPafA19dUtMTe/s1ymy0xIM=; b=cSTwpkG9tNfnl6Ko7RDYGMHmJ4s5PF76h/El+ACnlz41cA2xxGe0jcB71CXnzcB/Fe JU7NsCo0Ra4UaZTAhg6KmZNGWZsmQkVyURPyhJDx/LLLKSXXYAAVT2bvc5jwF5DriXbA cU3acyotCGYFLGartj1Dh1UBhPaNGE3O6t5kBpCsmaSGBfo9X3ttgECtX188aj1MQO6k zBpzlZfX3abGl62nFbNFjWRYNDU4s07SnkBiBYVBUJ58XejyjB3XN+dRLHVM4xsDLS4B V7YP1mIBHh4AFcj0ATQe98y/sTn1l6LYM5ngKYrcOnxacL2jRua0wx3kDbr6Udg0ZGFH VtzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CrlTmmx3; 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 11-20020a05621420cb00b004acc649925fsi2615506qve.479.2022.10.21.00.54.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 00:54:59 -0700 (PDT) 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=CrlTmmx3; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmrj-0006Wh-Jm for patch@linaro.org; Fri, 21 Oct 2022 03:54:51 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmI9-0003Sz-Je for patch@linaro.org; Fri, 21 Oct 2022 03:18:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmI4-0003Ry-EZ for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:18:00 -0400 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 1olmI2-0005vR-F8 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:18:00 -0400 Received: by mail-pl1-x633.google.com with SMTP id u6so1552755plq.12 for ; Fri, 21 Oct 2022 00:17:57 -0700 (PDT) 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=6MECj/5wfaqJXkyCl06/YPafA19dUtMTe/s1ymy0xIM=; b=CrlTmmx3I7+eSr7GU/ObuF0y85aF3WFpnwnCr5iRag0VCAM4mZrQuahh5c1wxRfoqJ B/AEJ6VogTdb9N4YndC6jScUK2agdqUcC5cPu0c9G8QMyT2PCm3WMi5+5YBrp/yVT+/m MG/EOhoYHC8sV6dHErvRzlL9iju3l1USrsZ+7sUCdExKlrQva1hejV5tD14QIvBz15Sn 5DXgV9SFx8nkBRsc6zYD5vj4WBVOUOtj8QZswVkfew2Af7DF974aP4gSgh1an4KultjK sEw9PBqiSNST5T08BM7kUk5uIvoryi4hZ36lyVF3xzKFM95JVEvIPx6hOj+opYWfrYdQ jcgA== 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=6MECj/5wfaqJXkyCl06/YPafA19dUtMTe/s1ymy0xIM=; b=xwKHXZwMXszwi5aISLRpqlU57tlbwoBRAG+3HbmP0hxDo4EnGEycSbgTpvbd7Tl9CP Ih/iPJ04mD4fXnC0shtakhi6vYumw0YNgTOS1P4E2E8DCFM6F3din1ZQHGORQAmZsPEf mbz8iNiZCItvTl5i/4A1NonaXMfXvM0Jm9CuzcVGfNTbSyPRThpZL2ABVX+xdlw75BkE dv2dBHcSWxzmYLY2q41GQHP3uVGqZshzkENtQJnX4YsHl/8WDSj3Hr9lDVvJFNLqd3vd PJQ/xFJcGN5sGqT5s76r5Dgu+j/WESYO74S8Q0SXLHiMagv9UKmf5R5bpWsso7ZBcNJ/ F6lg== X-Gm-Message-State: ACrzQf2J+VyJcPScsOoiiKeLN2b5ySmC/VpUgvJUgXWEFWwthMF+zsNI ZAD2jKNWcn5TXIHkwaNhrQzsNyePgDnLNdMu X-Received: by 2002:a17:90b:4b10:b0:20c:c3a8:38e with SMTP id lx16-20020a17090b4b1000b0020cc3a8038emr20112935pjb.195.1666336676966; Fri, 21 Oct 2022 00:17:56 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 34/36] tcg: Add TCG_TARGET_CALL_{RET,ARG}_I128 Date: Fri, 21 Oct 2022 17:15:47 +1000 Message-Id: <20221021071549.2398137-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-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" Fill in the parameters for the host ABI for Int128 for those backends which require no extra modification. Signed-off-by: Richard Henderson --- 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 | 11 ++++++----- tcg/ppc/tcg-target.c.inc | 3 +++ 9 files changed, 24 insertions(+), 5 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 74fbb22dfd..54e3478355 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -91,6 +91,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 f921a5ca24..7cde82f12d 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -760,12 +760,13 @@ static void init_call_layout(TCGHelperInfo *info) break; case dh_typecode_i128: /* - * No matter the call return method, we must have all of - * the temp subindexes in the call for liveness. + * For 32-bit hosts, do not split out individual temps. + * For 64-bit hosts, we need to add both temps for liveness + * no matter the backend calling convention. */ info->nr_out = TCG_TARGET_REG_BITS == 32 ? 1 : 2; - 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: if (TCG_TARGET_REG_BITS == 32) { info->out_kind = TCG_CALL_RET_NORMAL_4; @@ -827,7 +828,7 @@ static void init_call_layout(TCGHelperInfo *info) break; case dh_typecode_i128: type = TCG_TYPE_I128; - kind = TCG_CALL_ARG_NORMAL; /* TODO */ + kind = TCG_TARGET_CALL_ARG_I128; break; default: g_assert_not_reached(); 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 Oct 21 07:15: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: 617158 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp833460pvb; Fri, 21 Oct 2022 02:03:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6y89Bs3sX32itVGH93LSfuil6UT45bhoBnPdQg+f0bs0h+REw5gE7hORaVqQqti3qR5HZh X-Received: by 2002:a37:4247:0:b0:6e7:6992:93c4 with SMTP id p68-20020a374247000000b006e7699293c4mr12591924qka.696.1666343018944; Fri, 21 Oct 2022 02:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666343018; cv=none; d=google.com; s=arc-20160816; b=Ny3IsbjGlI7Y/LIk2MkFB2YOJB9LwTQh6pmujNaYW5NCoPpi3Nfs8SwIPsEqIVmgrf KvXp4htkg5cj+a8rgMWCR9mEeiW/HOP6lgyc2zI5A9ivT02HNo6CbBIvSuA6RFaPEZJb f2ZiPjSaBfdMQOLvEvSw0upVSg8lZGYUdP03c8nqJOEOCEoiHz1ML0pLgbLIdwlzxdEa 8hGY0xJXFJGxlC1K2Rfz0I99X690IJhfWckiJCyxI2eKDet5+gVmUlTtweJA2pmqnMs6 MrKDopeeFiJGnbsomeAzqinNGgucKWNEnYP214ik9VgBh0le/Ln3o86H/9GV9lGw3jpJ OAZw== 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=PgG5Fqrssx+hkjV71ieV43u3E3Admzr0DyJnKERg/wk=; b=CqJ26R6d9dz0XTEb1vAVTVIZNjsxYZ1O2xkg+/kqo/BJ+D/I0wqSuFlmRSpulzBodH YgtFh0ZfiQrCsr81J9asU+vb4adEr9HnCWtsP1N4jUKoRZvCn64Hk67zGlqzxCfmeOgf kvrogsIur+3Cd5glChM30MZHpvFFXKsF9QMoh1yilaZF8aePnGT7zULOPf+vexuAYfyM vGKhLQwm+g9wcuDxiEFif4iM8RyxJoixPDMDjbtv1QJzjYMswKMKqt2BRBBHTVmrx1xK BMo3PUh+XXdRMTMewD31ybHQT3drg9c/LI4nGTw1ai4kzBxsPosQrf+uXS+MHJdWAbj2 +dGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uTjEO3S+; 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 j5-20020a05620a410500b006ce8a7187d1si12136166qko.36.2022.10.21.02.03.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 02:03:38 -0700 (PDT) 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=uTjEO3S+; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnwC-0004B5-T4 for patch@linaro.org; Fri, 21 Oct 2022 05:03:34 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmIE-0003bV-P4 for patch@linaro.org; Fri, 21 Oct 2022 03:18:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmI7-0003Tb-4S for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:18:03 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1olmI5-0005vu-1i for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:18:02 -0400 Received: by mail-pf1-x42d.google.com with SMTP id 67so1768210pfz.12 for ; Fri, 21 Oct 2022 00:18:00 -0700 (PDT) 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=PgG5Fqrssx+hkjV71ieV43u3E3Admzr0DyJnKERg/wk=; b=uTjEO3S+5D2iCzyR9gxlKziNgg/CVVxBavm+mGgXMCLCOw8k19pHpw7VemSUDD1sVd 6WzWgZ6/1oPuEkiGg/OQluP9Ctd5Evs3dNHJKKv+AXtdzhhnHyuk1rRuZcsA+IJM0pgU 6ZsDetv0Z7G7YmyaW6wbfxP68wbdjsrrKP4q2lRzKw0UfNcHDUGuIX0jNa5MwYy1Ft1v Wzf6C0qsdDKPQI97g582jw1rRmX2I23ym2Vt1oOBTXEGDX4kny6Vt2Th3MZTW8W5adT5 jFjECOeOy1mAkZbwvBwDmoh6f0NduRGVUWwbO/xfMz/cBaaIMLRFNQuSpM7PylXopFxn gsuw== 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=PgG5Fqrssx+hkjV71ieV43u3E3Admzr0DyJnKERg/wk=; b=lbrdpp8BFpm3gqi5857h4ruOfLqbpRXNC8tfj/ash/EbtKP8QuI4qXpBR+43JumWyB OR1IDCYnVc9DJI7Kz/ScW+0M4GhYgCP+i5YQUMBQh4I9TYiLYvaaGfhOeK9EmHmtUzF8 OrX6U2liLFS9OFUSPeQexKrkdts2hMhdaHuf0SCZuhYGYu18nYBtNsETiD/BkQqJggE8 +uwaW15JtMqQBavgC53cs09l671LkAIXu6uOBv8sPeLZQuIowaKGgp5gytmUzxfjdLPm oYWCfR/DFVzAEtkX+rbELQ9+lWTX6YiVOzkj4akJAkX8rkfvcb+dsFzZgNYrCoxq0LS+ UOPA== X-Gm-Message-State: ACrzQf2xHzuyxjvVn5HlpMQV61A/i40eZDODw/KlkXEKClYIq/87ZfAG PrWc9BsPeFRfd4ott7ekpwNNSVSuNfImIGog X-Received: by 2002:a63:5703:0:b0:439:14a8:52b with SMTP id l3-20020a635703000000b0043914a8052bmr14521561pgb.500.1666336679704; Fri, 21 Oct 2022 00:17:59 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.17.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:17:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 35/36] tcg: Add temp allocation for TCGv_i128 Date: Fri, 21 Oct 2022 17:15:48 +1000 Message-Id: <20221021071549.2398137-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" 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 | 32 +++++++++++++++++++++++++++----- 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 88fb4f1d17..db2e10610d 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -701,6 +701,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); @@ -721,6 +726,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)); @@ -742,6 +752,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); @@ -864,6 +879,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)); @@ -912,6 +932,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 7cde82f12d..adf592ac96 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1250,18 +1250,39 @@ TCGTemp *tcg_temp_new_internal(TCGType type, bool temp_local) tcg_debug_assert(ts->base_type == type); tcg_debug_assert(ts->kind == kind); } else { + bool want_pair = false; + TCGType half = type; + + switch (type) { + case TCG_TYPE_I32: + case TCG_TYPE_V64: + case TCG_TYPE_V128: + case TCG_TYPE_V256: + break; + case TCG_TYPE_I64: + half = TCG_TYPE_I32; + want_pair = TCG_TARGET_REG_BITS == 32; + break; + case TCG_TYPE_I128: + half = TCG_TYPE_I64; + want_pair = TCG_TARGET_REG_BITS == 64; + break; + default: + g_assert_not_reached(); + } + ts = tcg_temp_alloc(s); - if (TCG_TARGET_REG_BITS == 32 && type == TCG_TYPE_I64) { + if (want_pair) { TCGTemp *ts2 = tcg_temp_alloc(s); ts->base_type = type; - ts->type = TCG_TYPE_I32; + ts->type = half; 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->base_type = type; + ts2->type = half; ts2->temp_allocated = 1; ts2->temp_subindex = 1; ts2->kind = kind; @@ -2773,7 +2794,7 @@ static void la_cross_call(TCGContext *s, int nt) for (i = 0; i < nt; i++) { TCGTemp *ts = &s->temps[i]; - if (!(ts->state & TS_DEAD)) { + if (ts->type != TCG_TYPE_I128 && !(ts->state & TS_DEAD)) { TCGRegSet *pset = la_temp_pref(ts); TCGRegSet set = *pset; @@ -3404,6 +3425,7 @@ 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. */ From patchwork Fri Oct 21 07:15: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: 617155 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp830455pvb; Fri, 21 Oct 2022 01:57:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM76cEVD+PrmCIubTOMiPjhMms9ob8Kass6wFEie6m+e2pqWttPEsf42fieVue1VebY+umzE X-Received: by 2002:ac8:5ec9:0:b0:39c:f5a3:2fec with SMTP id s9-20020ac85ec9000000b0039cf5a32fecmr15739870qtx.86.1666342661861; Fri, 21 Oct 2022 01:57:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666342661; cv=none; d=google.com; s=arc-20160816; b=GjZzjN7mpwbQhgHI/NV13AUXYg/2IZNEewYYuuALxkP4qMgMllff7CQ33Y/0P5ZATP 0rYmCuXzY6UMbQ2U3Xic/Dn9mlIEjNmIQ6JE8NKQAkD1F28hg0jzRxxnwn8MMUj8/aan SRG1WXh8CUNSFNycR7uTKgNvvtopaRts7ehuRCfSbYkIBOoarZgqNO9Kw56Ri0ZMOc/9 rkCpkSYu2Awnu/FpGXjQoSTxuS92cQNsJiOf1/pGX2FXe/Go8Bx8lQB5imWrvmbhfBwM hy4DaY9auGq4SuOT0pDqECY+mCr+7tun392eoy5hC0K3KjK8OsceSbvxCMC0KBouXWYw Drag== 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=wp/4CM/qsbuV4ZCuidIv3Ny+CUT3ruhHsC9wYblkvAU=; b=sMuy2ZJ1Ug9qmqeVp2mgBL1r/6+br3jl+oGs3saApYc4LVzGukyikl5FY7MM+bLiWv MGrNpfkjNmBmUgS42LN5zkSAN9+Wo1Zfnj1PO+ZUNYG/8H2qB497etjm4rnj3tKhvKCZ htI8UTAl7S8YfK7az7vTpsF/QF5sjXonzJWaKRecwvw7oasyPYPU81xlZq7eTOc78fgT XeRiUTRu4ahwFQucB8+RlKHMiF/w8NaeUJlo/CTf6J8BOiRa45m2CKRg1x/rlhqucRQL go+wuz6szDgq63/xRshikPhL1CyJS0h1+2O8RVG/DrDJh5nsbM//IweOTYpMHQ8XJO3w kspg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KlZPyMGy; 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 h5-20020a05620a244500b006ed1e68ccb4si13425242qkn.627.2022.10.21.01.57.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Oct 2022 01:57:41 -0700 (PDT) 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=KlZPyMGy; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnqS-00075b-4b for patch@linaro.org; Fri, 21 Oct 2022 04:57:38 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmIJ-0003hf-OR for patch@linaro.org; Fri, 21 Oct 2022 03:18:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olmIA-0003Y3-02 for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:18:06 -0400 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 1olmI7-0005wL-UW for qemu-devel@nongnu.org; Fri, 21 Oct 2022 03:18:05 -0400 Received: by mail-pg1-x530.google.com with SMTP id g129so177947pgc.7 for ; Fri, 21 Oct 2022 00:18:03 -0700 (PDT) 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=wp/4CM/qsbuV4ZCuidIv3Ny+CUT3ruhHsC9wYblkvAU=; b=KlZPyMGyK/J9Fu+pplc/X7YHjibXQF65uwT4/lMB3cZqXu+NKBF8euRK1qcfClXpGN +83ePMkeDAKE3oMjrF5zFxOrpVq8doRJuCfCgnH4DXUCNNGX/O9Bx1B+gasE09kS+Ti/ sQi7Z8ryHyUq1N6p0KixyYlUNX7Ofl/Oz99ycBErZnEkF560H5fP9ixKXcgxm/eSxBLH 5autcQW+qOk46dvwomgzofmVq6Sg7I2Qvr8mWR8o6bP/Mdjf2c+tWWM/qDwkRSUSx8gy DOOopQoFbIfZJYeoCXu3/rl2kdfltIZDvi4hzshL4cdKFWh3JwJXUn5y/eWIL7pOWqGE BL7Q== 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=wp/4CM/qsbuV4ZCuidIv3Ny+CUT3ruhHsC9wYblkvAU=; b=B+GYkHvrGi5LFtl4PmEMIJIVmZ6E3ExShpQ92+MmtZ4douoeF/+sP9gG83T36X4hnX gWh83tIKF0/LKGMxcFPZO7KWd0BMKGRcaDwgdTP61BUCMNo1tQTT7af8tZFieBwqr3qP MSWPR7jiL6BiYjOhjT9dfTvnTRhbCs5bOLyaLJp2rdpQSdX+pmdxqT3rD5Deb2aZg7nP Id17Ly5KNPK3rJAV1nsmGt0uri5eXwzpzNIDWdvK/UPCEItycq1CrpIHtegI+mlC/Yl2 qxsis4W/3pUtj8UePjpLW+j9td9HQnUJTFlPBOkpgHSa0Ki+QyIpyGOE3tR5AA54lZuq HmoA== X-Gm-Message-State: ACrzQf0O8QLH+9lh5Pqgw1BCS25ikj1oq0rtIA8e1btvL5ei7+Sid9Co sHiMTSglnkG4e+mDS96g8a+Xc+3ssIfEZ4e6 X-Received: by 2002:a63:6c07:0:b0:457:523c:4bd0 with SMTP id h7-20020a636c07000000b00457523c4bd0mr15117557pgc.101.1666336682365; Fri, 21 Oct 2022 00:18:02 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id q9-20020a638c49000000b0041cd5ddde6fsm13003327pgn.76.2022.10.21.00.18.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 00:18:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 36/36] tcg: Add tcg_gen_extr_i128_i64, tcg_gen_concat_i64_i128 Date: Fri, 21 Oct 2022 17:15:49 +1000 Message-Id: <20221021071549.2398137-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021071549.2398137-1-richard.henderson@linaro.org> References: <20221021071549.2398137-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" Add code generation functions for data movement between TCGv_i128 and TCGv_i64. Signed-off-by: Richard Henderson --- include/tcg/tcg-op.h | 3 ++ include/tcg/tcg-opc.h | 4 ++ tcg/tcg-internal.h | 12 ++++++ tcg/tcg-op.c | 35 ++++++++++++++++++ tcg/tcg.c | 85 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 139 insertions(+) diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h index 209e168305..2ce2ff28c9 100644 --- a/include/tcg/tcg-op.h +++ b/include/tcg/tcg-op.h @@ -735,6 +735,9 @@ 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_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/include/tcg/tcg-opc.h b/include/tcg/tcg-opc.h index dd444734d9..6211fb3242 100644 --- a/include/tcg/tcg-opc.h +++ b/include/tcg/tcg-opc.h @@ -158,6 +158,10 @@ DEF(extrh_i64_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_extrh_i64_i32) | (TCG_TARGET_REG_BITS == 32 ? TCG_OPF_NOT_PRESENT : 0)) +/* For 32-bit host only, implemented generically using ld/st/mov. */ +DEF(extr_i128_i32, 1, 1, 1, TCG_OPF_NOT_PRESENT) +DEF(concat4_i32_i128, 1, 4, 0, TCG_OPF_NOT_PRESENT) + DEF(brcond_i64, 0, 2, 2, TCG_OPF_BB_END | TCG_OPF_COND_BRANCH | IMPL64) DEF(ext8s_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext8s_i64)) DEF(ext16s_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext16s_i64)) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index 44ef51ca30..8112a0a491 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -110,9 +110,21 @@ static inline TCGv_i32 TCGV_HIGH(TCGv_i64 t) { return temp_tcgv_i32(tcgv_i64_temp(t) + !HOST_BIG_ENDIAN); } +extern TCGv_i64 TCGV128_LOW(TCGv_i128) + QEMU_ERROR("64-bit code path is reachable"); +extern TCGv_i64 TCGV128_HIGH(TCGv_i128) + QEMU_ERROR("64-bit code path is reachable"); #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"); +static inline TCGv_i64 TCGV128_LOW(TCGv_i128 t) +{ + return temp_tcgv_i64(tcgv_i128_temp(t) + HOST_BIG_ENDIAN); +} +static inline TCGv_i64 TCGV128_HIGH(TCGv_i128 t) +{ + return temp_tcgv_i64(tcgv_i128_temp(t) + !HOST_BIG_ENDIAN); +} #endif #endif /* TCG_INTERNAL_H */ diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 3ed98ffa01..6031fa89c2 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2718,6 +2718,41 @@ 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) +{ + if (TCG_TARGET_REG_BITS == 32) { + TCGArg a_arg = tcgv_i128_arg(arg); + int be = HOST_BIG_ENDIAN ? 0xc : 0; + + tcg_gen_op3(INDEX_op_extr_i128_i32, tcgv_i32_arg(TCGV_LOW(lo)), + a_arg, 0x0 ^ be); + tcg_gen_op3(INDEX_op_extr_i128_i32, tcgv_i32_arg(TCGV_HIGH(lo)), + a_arg, 0x4 ^ be); + tcg_gen_op3(INDEX_op_extr_i128_i32, tcgv_i32_arg(TCGV_LOW(hi)), + a_arg, 0x8 ^ be); + tcg_gen_op3(INDEX_op_extr_i128_i32, tcgv_i32_arg(TCGV_HIGH(hi)), + a_arg, 0xc ^ be); + } else { + 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) +{ + if (TCG_TARGET_REG_BITS == 32) { + tcg_gen_op5(INDEX_op_concat4_i32_i128, + tcgv_i128_arg(ret), + tcgv_i32_arg(TCGV_LOW(lo)), + tcgv_i32_arg(TCGV_HIGH(lo)), + tcgv_i32_arg(TCGV_LOW(hi)), + tcgv_i32_arg(TCGV_HIGH(hi))); + } else { + tcg_gen_mov_i64(TCGV128_LOW(ret), lo); + tcg_gen_mov_i64(TCGV128_HIGH(ret), hi); + } +} + /* QEMU specific operations. */ void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx) diff --git a/tcg/tcg.c b/tcg/tcg.c index adf592ac96..6974564f49 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3949,6 +3949,85 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) } } +/* + * Specialized code generation for TCG_TYPE_I128 on 32-bit host. + * Here, 128-bit values are *always* in memory, never regs or constants. + * Move 32-bit pieces into and out of the 128-bit memory slot. + */ +static void tcg_reg_alloc_exrl_i128_i32(TCGContext *s, const TCGOp *op) +{ + const TCGLifeData arg_life = op->life; + TCGTemp *ots = arg_temp(op->args[0]); + TCGTemp *its = arg_temp(op->args[1]); + TCGArg ofs = op->args[2]; + TCGReg reg; + + assert(TCG_TARGET_REG_BITS == 32); + tcg_debug_assert(ots->type == TCG_TYPE_I32); + tcg_debug_assert(!temp_readonly(ots)); + tcg_debug_assert(its->type == TCG_TYPE_I128); + tcg_debug_assert(its->val_type == TEMP_VAL_MEM); + tcg_debug_assert(ofs < 16); + tcg_debug_assert((ofs & 3) == 0); + + if (ots->val_type == TEMP_VAL_REG) { + reg = ots->reg; + } else { + reg = tcg_reg_alloc(s, tcg_target_available_regs[TCG_TYPE_I32], + s->reserved_regs, op->output_pref[0], + ots->indirect_base); + ots->val_type = TEMP_VAL_REG; + ots->reg = reg; + s->reg_to_temp[reg] = ots; + } + + tcg_out_ld(s, TCG_TYPE_I32, reg, + its->mem_base->reg, its->mem_offset + ofs); + ots->mem_coherent = 0; + + if (IS_DEAD_ARG(1)) { + temp_dead(s, its); + } +} + +static void tcg_reg_alloc_concat4_i32_i128(TCGContext *s, const TCGOp *op) +{ + const TCGLifeData arg_life = op->life; + TCGTemp *ots = arg_temp(op->args[0]); + int be = HOST_BIG_ENDIAN ? 0xc : 0; + + assert(TCG_TARGET_REG_BITS == 32); + tcg_debug_assert(ots->type == TCG_TYPE_I128); + tcg_debug_assert(!temp_readonly(ots)); + tcg_debug_assert(NEED_SYNC_ARG(0)); + + if (!ots->mem_allocated) { + temp_allocate_frame(s, ots); + } + + for (int i = 0; i < 4; ++i) { + TCGTemp *its = arg_temp(op->args[i + 1]); + int ofs = ots->mem_offset + ((i * 4) ^ be); + + if (its->val_type == TEMP_VAL_CONST && + IS_DEAD_ARG(i + 1) && + tcg_out_sti(s, TCG_TYPE_I32, its->val, ots->mem_base->reg, ofs)) { + continue; + } + + temp_load(s, its, tcg_target_available_regs[TCG_TYPE_I32], + s->reserved_regs, 0); + tcg_out_st(s, TCG_TYPE_I32, its->reg, ots->mem_base->reg, ofs); + + if (IS_DEAD_ARG(i + 1)) { + temp_dead(s, its); + } + } + + ots->val_type = TEMP_VAL_MEM; + ots->mem_coherent = 1; +} + /* * Specialized code generation for INDEX_op_dup_vec. */ @@ -5009,6 +5088,12 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, target_ulong pc_start) case INDEX_op_mov_vec: tcg_reg_alloc_mov(s, op); break; + case INDEX_op_extr_i128_i32: + tcg_reg_alloc_exrl_i128_i32(s, op); + break; + case INDEX_op_concat4_i32_i128: + tcg_reg_alloc_concat4_i32_i128(s, op); + break; case INDEX_op_dup_vec: tcg_reg_alloc_dup(s, op); break;