From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666337206; cv=none; d=zohomail.com; s=zohoarc; b=eaxDYvbAzhtLY3F2OT540RhvZ2Yms5LzwX9EJf36zGo+e+LD7ela9XawAStN3QRcdUJ98EqvxtWRlMPYnrYEYLPu4hFvOAq6BDXqhB5X7EWkN6E+MkmHThMTBc09HTCAO3AHphdm+HBPcCQMnWRbG8I5kRif+D5ShnQQCWtBY+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666337206; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PB3nAjYqPE0Ri3rKlsMJ9c6TgJjZ6GaMPRBD/PmouBs=; b=THvT3CVabwdbLux/XmrO2ZVgeBSbL0pjT8+osQwgeWtWinCm4mTeTCFWa7pIKMHlC8MAQxxEn2y6CJg9mXCsAqajr1j6qjWfwsOkdUEPQPlE1jWXkwhY4jnDLxKTU8ddy5w82K7uFqs0jQKryHt491z7KrOzqiI4KfzOt1t3kl8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666337206606800.8197098693169; Fri, 21 Oct 2022 00:26:46 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmQX-0000rS-Lh for importer@patchew.org; Fri, 21 Oct 2022 03:26:45 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmGy-00034b-Io for importer@patchew.org; Fri, 21 Oct 2022 03:16: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 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) 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) 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-Google-Smtp-Source: AMsMyM44y3Ts+nrPZ04xJVnsNbDi18EzSkue2wf714aJRpe+iHJH4j4Xa4Yt/Xt8kuIJPSqNu+8Qhw== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666337207784100001 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=3D104688 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 va= l) : [l] "r"(l), [h] "r"(h)); } =20 +# define HAVE_ATOMIC128 1 +#elif !defined(CONFIG_USER_ONLY) && defined(__x86_64__) +/* + * The latest Intel SDM has added: + * Processors that enumerate support for Intel=C2=AE 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" : "=3Dx" (ret) : "m" (*ptr)); + } else { + ret =3D atomic16_cmpxchg(ptr, 0, 0); + } + return ret; +} + +static inline void atomic16_set(Int128 *ptr, Int128 val) +{ + if (have_atomic128) { + asm("vmovdqa %1, %0" : "=3Dm" (*ptr) : "x" (val)); + } else { + Int128 old =3D *ptr, cmp; + do { + cmp =3D old; + old =3D atomic16_cmpxchg(ptr, cmp, val); + } while (old !=3D 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=C2=AE 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 !=3D signature_INTEL_ecx) { + return; /* Not an Intel product */ + } + + __cpuid(1, a, b, c, d); + if ((c & (bit_AVX | bit_OSXSAVE)) !=3D (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" : "=3Da" (xcrl), "=3Dd" (xcrh) : "c" (0)); + if ((xcrl & 6) !=3D 6) { + return; /* AVX not enabled by OS */ + } + + have_atomic128 =3D 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') --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666337120; cv=none; d=zohomail.com; s=zohoarc; b=jBAait9F6jDOgF9roPVElyc/MC9V5ntRqREnoz7jpxgR/lddM33BsJNwMA0mRBhMT5HoKbTheQHdg4LWy9sBap7SI5W8EdI6cnyMEzyUGqiSI3ABDf7tn/c6d5LJh/EPGl1xUbA1hqJ+FKllbkf1ZVN2R9M5blE8pJ8ixrpi8Gs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666337120; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0N2X3V1riRQReX4ltI4ULsG1O5wdgfurbMkc7ES3gzU=; b=Hm+w1daNugBXm5L3N3EYSR02opD9QMgKQMTTkIgvbMvkkRLFkkjiKcSQuQNMfD9GIszaTqJGmwI4Fklm8sBKBi7iDLXYLK4XIRKJQetjk4SIRtarZxUHrS5cWdsNgXlCEezL6wn+Su11WeUUVsBsH/fNCS8okIPx4H621Q/Z6Co= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666337120272275.53882028946157; Fri, 21 Oct 2022 00:25:20 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmP9-0007hA-7Q for importer@patchew.org; Fri, 21 Oct 2022 03:25:19 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmGz-00035J-Kj for importer@patchew.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 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) 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) 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-Google-Smtp-Source: AMsMyM7uM0kiMvzsz1s07Gx7WR8xFygdsCw6Du0UixvMR0T7PHr4nnaC9heODnqcikDcFu+S2H91IA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666337122772100001 Content-Type: text/plain; charset="utf-8" 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=C3=A9 --- 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 TCG= Op *op) =20 /* satisfy input constraints */=20 for (k =3D 0; k < nb_iargs; k++) { - TCGRegSet i_preferred_regs, o_preferred_regs; + TCGRegSet i_preferred_regs; + bool allocate_new_reg; =20 i =3D def->args_ct[nb_oargs + k].sort_index; arg =3D op->args[i]; @@ -3621,9 +3622,12 @@ static void tcg_reg_alloc_op(TCGContext *s, const TC= GOp *op) continue; } =20 - i_preferred_regs =3D o_preferred_regs =3D 0; + reg =3D ts->reg; + i_preferred_regs =3D 0; + allocate_new_reg =3D false; + if (arg_ct->ialias) { - o_preferred_regs =3D op->output_pref[arg_ct->alias_index]; + i_preferred_regs =3D op->output_pref[arg_ct->alias_index]; =20 /* * If the input is readonly, then it cannot also be an @@ -3632,30 +3636,23 @@ static void tcg_reg_alloc_op(TCGContext *s, const T= CGOp *op) * register and move it. */ if (temp_readonly(ts) || !IS_DEAD_ARG(i)) { - goto allocate_in_reg; + allocate_new_reg =3D true; + } else if (ts->val_type =3D=3D TEMP_VAL_REG) { + /* + * Check if the current register has already been + * allocated for another input. + */ + allocate_new_reg =3D 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 =3D=3D TEMP_VAL_REG) { - reg =3D ts->reg; - for (int k2 =3D 0; k2 < k; k2++) { - int i2 =3D def->args_ct[nb_oargs + k2].sort_index; - if (def->args_ct[i2].ialias && reg =3D=3D new_args[i2]= ) { - goto allocate_in_reg; - } - } - } - i_preferred_regs =3D o_preferred_regs; } =20 - temp_load(s, ts, arg_ct->regs, i_allocated_regs, i_preferred_regs); - reg =3D ts->reg; + if (!allocate_new_reg) { + temp_load(s, ts, arg_ct->regs, i_allocated_regs, i_preferred_r= egs); + reg =3D ts->reg; + allocate_new_reg =3D !tcg_regset_test_reg(arg_ct->regs, reg); + } =20 - 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 TCG= Op *op) temp_load(s, ts, tcg_target_available_regs[ts->type], i_allocated_regs, 0); reg =3D 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 --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666337568; cv=none; d=zohomail.com; s=zohoarc; b=hqf2WuAXZpw3fmYOeYfA3hNPm/nff9qMVw3K8znOd1uJRObK/dWGSUazap+Zd+nBOC8Dz/7CAJL0MsMl+ZaQckLYvtXLAvq8NFxKjHHS7vTIMB4KwK5bRpYku+rZMdwyDjOZJ0YVu54UyYNDlc6OM3QH56CS4kxPzSNjPPoOl5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666337568; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=x7WYQtCAL6ZzGFr7jsOhX+NZYzn5szp042JeNsGxFIQ=; b=jTHgldOaBcqmXxH3CW6uAi+A/F31MCmpJvHoTGx4pJy9s1Lll7qWd7vbMAj2UFZ2eqdlfnkBS3BvQdpJdmV1ZP4dzPsK2l+w73t+q27yLxi1IYUoX1jL6jpspwGysOYS4Bs6uGLyE2A0zNaFwcOoexY6EV7Jr20mSAUJtDzCrsQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666337568164400.6437763327698; Fri, 21 Oct 2022 00:32:48 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmWK-00053S-BB for importer@patchew.org; Fri, 21 Oct 2022 03:32:45 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmH0-00035d-NE for importer@patchew.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 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) 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) 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-Google-Smtp-Source: AMsMyM6cQyOu/LXXtxtGmf1zuKOrDwxrjCXfeyQg2roaE4EmWJ54eNMdf1zulcOBJO1NxI3noo07Gw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666337568795100001 Content-Type: text/plain; charset="utf-8" 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, bo= ol have_prefs) static int get_constraint_priority(const TCGOpDef *def, int k) { const TCGArgConstraint *arg_ct =3D &def->args_ct[k]; - int n; + int n =3D ctpop64(arg_ct->regs); =20 - if (arg_ct->oalias) { - /* an alias is equivalent to a single register */ - n =3D 1; - } else { - n =3D 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 =3D=3D 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; } =20 /* sort from highest priority to lowest */ @@ -2028,7 +2045,8 @@ static void process_op_defs(TCGContext *s) for (op =3D 0; op < NB_OPS; op++) { TCGOpDef *def =3D &tcg_op_defs[op]; const TCGTargetOpDef *tdefs; - int i, nb_args; + bool saw_alias_pair =3D false; + int i, o, i2, o2, nb_args; =20 if (def->flags & TCG_OPF_NOT_PRESENT) { continue; @@ -2050,58 +2068,175 @@ static void process_op_defs(TCGContext *s) =20 for (i =3D 0; i < nb_args; i++) { const char *ct_str =3D tdefs->args_ct_str[i]; + bool input_p =3D i >=3D def->nb_oargs; + /* Incomplete TCGTargetOpDef entry. */ tcg_debug_assert(ct_str !=3D NULL); =20 - while (*ct_str !=3D '\0') { - switch(*ct_str) { - case '0' ... '9': - { - int oarg =3D *ct_str - '0'; - tcg_debug_assert(ct_str =3D=3D tdefs->args_ct_str[= i]); - tcg_debug_assert(oarg < def->nb_oargs); - tcg_debug_assert(def->args_ct[oarg].regs !=3D 0); - def->args_ct[i] =3D def->args_ct[oarg]; - /* The output sets oalias. */ - def->args_ct[oarg].oalias =3D true; - def->args_ct[oarg].alias_index =3D i; - /* The input sets ialias. */ - def->args_ct[i].ialias =3D true; - def->args_ct[i].alias_index =3D oarg; - } - ct_str++; - break; - case '&': - def->args_ct[i].newreg =3D true; - ct_str++; - break; + switch (*ct_str) { + case '0' ... '9': + o =3D *ct_str - '0'; + tcg_debug_assert(input_p); + tcg_debug_assert(o < def->nb_oargs); + tcg_debug_assert(def->args_ct[o].regs !=3D 0); + tcg_debug_assert(!def->args_ct[o].oalias); + def->args_ct[i] =3D def->args_ct[o]; + /* The output sets oalias. */ + def->args_ct[o].oalias =3D 1; + def->args_ct[o].alias_index =3D i; + /* The input sets ialias. */ + def->args_ct[i].ialias =3D 1; + def->args_ct[i].alias_index =3D o; + if (def->args_ct[i].pair) { + saw_alias_pair =3D true; + } + tcg_debug_assert(ct_str[1] =3D=3D '\0'); + continue; + + case '&': + tcg_debug_assert(!input_p); + def->args_ct[i].newreg =3D 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 =3D i - 1; + tcg_debug_assert(!def->args_ct[o].pair); + tcg_debug_assert(!def->args_ct[o].ct); + def->args_ct[i] =3D (TCGArgConstraint){ + .pair =3D 2, + .pair_index =3D o, + .regs =3D def->args_ct[o].regs << 1, + }; + def->args_ct[o].pair =3D 1; + def->args_ct[o].pair_index =3D i; + tcg_debug_assert(ct_str[1] =3D=3D '\0'); + continue; + + case 'm': /* minus */ + /* Allocate to the register before the previous. */ + tcg_debug_assert(i > (input_p ? def->nb_oargs : 0)); + o =3D i - 1; + tcg_debug_assert(!def->args_ct[o].pair); + tcg_debug_assert(!def->args_ct[o].ct); + def->args_ct[i] =3D (TCGArgConstraint){ + .pair =3D 1, + .pair_index =3D o, + .regs =3D def->args_ct[o].regs >> 1, + }; + def->args_ct[o].pair =3D 2; + def->args_ct[o].pair_index =3D i; + tcg_debug_assert(ct_str[1] =3D=3D '\0'); + continue; + } + + do { + switch (*ct_str) { case 'i': def->args_ct[i].ct |=3D TCG_CT_CONST; - ct_str++; break; =20 /* Include all of the target-specific constraints. */ =20 #undef CONST #define CONST(CASE, MASK) \ - case CASE: def->args_ct[i].ct |=3D MASK; ct_str++; break; + case CASE: def->args_ct[i].ct |=3D MASK; break; #define REGS(CASE, MASK) \ - case CASE: def->args_ct[i].regs |=3D MASK; ct_str++; break; + case CASE: def->args_ct[i].regs |=3D MASK; break; =20 #include "tcg-target-con-str.h" =20 #undef REGS #undef CONST default: + case '0' ... '9': + case '&': + case 'p': + case 'm': /* Typo in TCGTargetOpDef constraint. */ g_assert_not_reached(); } - } + } while (*++ct_str !=3D '\0'); } =20 /* TCGTargetOpDef entry with too much information? */ tcg_debug_assert(i =3D=3D TCG_MAX_OP_ARGS || tdefs->args_ct_str[i]= =3D=3D NULL); =20 + /* + * 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 inpu= ts. + * + * 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 allocati= on + * phase, nothing happens with the second half of the input pair. + * + * Case 2 is handled by setting the second input to pair=3D3, the + * first output to pair=3D3, and the pair_index'es to match. + */ + if (saw_alias_pair) { + for (i =3D 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 =3D def->args_ct[i].alias_index; + o2 =3D def->args_ct[o].pair_index; + tcg_debug_assert(def->args_ct[o].pair =3D=3D 1); + tcg_debug_assert(def->args_ct[o2].pair =3D=3D 2); + if (def->args_ct[o2].oalias) { + /* Case 1a */ + i2 =3D def->args_ct[o2].alias_index; + tcg_debug_assert(def->args_ct[i2].pair =3D=3D 2); + def->args_ct[i2].pair_index =3D i; + def->args_ct[i].pair_index =3D i2; + } else { + /* Case 1b */ + def->args_ct[i].pair_index =3D i; + } + break; + case 2: + o =3D def->args_ct[i].alias_index; + o2 =3D def->args_ct[o].pair_index; + tcg_debug_assert(def->args_ct[o].pair =3D=3D 2); + tcg_debug_assert(def->args_ct[o2].pair =3D=3D 1); + if (def->args_ct[o2].oalias) { + /* Case 1a */ + i2 =3D def->args_ct[o2].alias_index; + tcg_debug_assert(def->args_ct[i2].pair =3D=3D 1); + def->args_ct[i2].pair_index =3D i; + def->args_ct[i].pair_index =3D i2; + } else { + /* Case 2 */ + def->args_ct[i].pair =3D 3; + def->args_ct[o2].pair =3D 3; + def->args_ct[i].pair_index =3D o2; + def->args_ct[o2].pair_index =3D 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(); } =20 +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 =3D 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] =3D required_regs & ~(allocated_regs | (allocated_regs >> 1)= ); + tcg_debug_assert(reg_ct[1] !=3D 0); + reg_ct[0] =3D reg_ct[1] & preferred_regs; + + order =3D 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 =3D reg_ct[0] =3D=3D 0 || reg_ct[0] =3D=3D reg_ct[1]; + + /* + * Minimize the number of flushes by looking for 2 free registers firs= t, + * then a single flush, then two flushes. + */ + for (fmin =3D 2; fmin >=3D 0; fmin--) { + for (j =3D k; j < 2; j++) { + TCGRegSet set =3D reg_ct[j]; + + for (i =3D 0; i < n; i++) { + TCGReg reg =3D order[i]; + + if (tcg_regset_test_reg(set, reg)) { + int f =3D !s->reg_to_temp[reg] + !s->reg_to_temp[reg += 1]; + if (f >=3D 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 regi= ster 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 TC= GOp *op) =20 /* satisfy input constraints */=20 for (k =3D 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; =20 i =3D def->args_ct[nb_oargs + k].sort_index; arg =3D op->args[i]; @@ -3624,43 +3807,142 @@ static void tcg_reg_alloc_op(TCGContext *s, const = TCGOp *op) =20 reg =3D ts->reg; i_preferred_regs =3D 0; + i_required_regs =3D arg_ct->regs; allocate_new_reg =3D false; + copyto_new_reg =3D false; =20 - if (arg_ct->ialias) { + switch (arg_ct->pair) { + case 0: /* not paired */ + if (arg_ct->ialias) { + i_preferred_regs =3D 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 =3D true; + } else if (ts->val_type =3D=3D TEMP_VAL_REG) { + /* + * Check if the current register has already been + * allocated for another input. + */ + allocate_new_reg =3D + 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 =3D ts->reg; + allocate_new_reg =3D !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 =3D tcg_reg_alloc(s, i_required_regs, i_allocated_regs, + i_preferred_regs, ts->indirect_base); + copyto_new_reg =3D true; + } + break; + + case 1: + /* First of an input pair; if i1 =3D=3D i2, the second is an o= utput. */ + i1 =3D i; + i2 =3D 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 =3D true; + ts2 =3D i1 !=3D i2 ? arg_temp(op->args[i2]) : NULL; + + if (arg_ct->ialias) { + i_preferred_regs =3D op->output_pref[arg_ct->alias_index]; + if (IS_DEAD_ARG(i1) && + IS_DEAD_ARG(i2) && + !temp_readonly(ts) && + ts->val_type =3D=3D 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 =3D=3D TEMP_VAL_REG && + ts2->reg =3D=3D reg + 1 + : s->reg_to_temp[reg + 1] =3D=3D NULL)) { + allocate_new_reg =3D false; + } + } else { + /* Without aliasing, the pair must also be an input. */ + tcg_debug_assert(ts2); + if (ts->val_type =3D=3D TEMP_VAL_REG && + ts2->val_type =3D=3D TEMP_VAL_REG && + ts2->reg =3D=3D reg + 1 && + tcg_regset_test_reg(i_required_regs, reg)) { + allocate_new_reg =3D false; + } + } + if (allocate_new_reg) { + reg =3D tcg_reg_alloc_pair(s, i_required_regs, i_allocated= _regs, + 0, ts->indirect_base); + if (ts->val_type !=3D TEMP_VAL_REG) { + temp_load(s, ts, (TCGRegSet)1 << reg, i_allocated_regs= , 0); + } else { + copyto_new_reg =3D true; + } + } + break; + + case 2: /* pair second */ + reg =3D new_args[arg_ct->pair_index] + 1; + i_required_regs =3D (TCGRegSet)1 << reg; + temp_load(s, ts, i_required_regs, i_allocated_regs, 0); + allocate_new_reg =3D ts->reg !=3D reg; + break; + + case 3: /* ialias with second output, no first input */ + tcg_debug_assert(arg_ct->ialias); i_preferred_regs =3D op->output_pref[arg_ct->alias_index]; =20 - /* - * 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 =3D true; - } else if (ts->val_type =3D=3D TEMP_VAL_REG) { - /* - * Check if the current register has already been - * allocated for another input. - */ - allocate_new_reg =3D tcg_regset_test_reg(i_allocated_regs,= reg); + allocate_new_reg =3D true; + if (IS_DEAD_ARG(i) && + ts->val_type =3D=3D 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 =3D false; } + if (allocate_new_reg) { + reg =3D 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 +=3D 1; + if (ts->val_type !=3D TEMP_VAL_REG) { + temp_load(s, ts, (TCGRegSet)1 << reg, i_allocated_regs= , 0); + } else { + copyto_new_reg =3D true; + } + } + break; + + default: + g_assert_not_reached(); } =20 - if (!allocate_new_reg) { - temp_load(s, ts, arg_ct->regs, i_allocated_regs, i_preferred_r= egs); - reg =3D ts->reg; - allocate_new_reg =3D !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 =3D 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 TCG= Op *op) const_args[i] =3D 0; tcg_regset_set_reg(i_allocated_regs, reg); } - =20 + /* mark dead temporaries and free the associated registers */ for (i =3D 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 TCG= Op *op) } =20 /* satisfy the output constraints */ - for(k =3D 0; k < nb_oargs; k++) { + for (k =3D 0; k < nb_oargs; k++) { i =3D def->args_ct[k].sort_index; arg =3D op->args[i]; arg_ct =3D &def->args_ct[i]; @@ -3712,15 +3994,46 @@ static void tcg_reg_alloc_op(TCGContext *s, const T= CGOp *op) /* ENV should not be modified. */ tcg_debug_assert(!temp_readonly(ts)); =20 - if (arg_ct->oalias && !const_args[arg_ct->alias_index]) { - reg =3D new_args[arg_ct->alias_index]; - } else if (arg_ct->newreg) { - reg =3D tcg_reg_alloc(s, arg_ct->regs, - i_allocated_regs | o_allocated_regs, - op->output_pref[k], ts->indirect_base); - } else { - reg =3D 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 =3D new_args[arg_ct->alias_index]; + } else if (arg_ct->newreg) { + reg =3D tcg_reg_alloc(s, arg_ct->regs, + i_allocated_regs | o_allocated_reg= s, + op->output_pref[k], ts->indirect_b= ase); + } else { + reg =3D tcg_reg_alloc(s, arg_ct->regs, o_allocated_reg= s, + op->output_pref[k], ts->indirect_b= ase); + } + break; + + case 1: /* first of pair */ + tcg_debug_assert(!arg_ct->newreg); + if (arg_ct->oalias) { + reg =3D new_args[arg_ct->alias_index]; + break; + } + reg =3D tcg_reg_alloc_pair(s, arg_ct->regs, o_allocated_re= gs, + op->output_pref[k], ts->indirect_= base); + break; + + case 2: /* second of pair */ + tcg_debug_assert(!arg_ct->newreg); + if (arg_ct->oalias) { + reg =3D new_args[arg_ct->alias_index]; + } else { + reg =3D 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 =3D 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 =3D=3D TEMP_VAL_REG) { @@ -3728,12 +4041,12 @@ static void tcg_reg_alloc_op(TCGContext *s, const T= CGOp *op) } ts->val_type =3D TEMP_VAL_REG; ts->reg =3D reg; + s->reg_to_temp[reg] =3D ts; /* * Temp value is modified, so the value kept in memory is * potentially not the same. */ ts->mem_coherent =3D 0; - s->reg_to_temp[reg] =3D ts; new_args[i] =3D reg; } } --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666338035; cv=none; d=zohomail.com; s=zohoarc; b=ZE6kbsbiUJN8qxHbHpzBF2aHNNRoS9nX4EO0nLJOHEJxB31+kvPBWZPTA89gAckxZZl5Zcq/SD3TdMf3SarYHooc4RO29UzdJtmZRDa2HBJWLwnJ510kLiyh6fI5zKGFIdShsaeeVxg1WIQRgzkfVsy5CIn20W5wILmL+WKH75k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666338035; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+XZZb+kD5PLDfiZzYREY/FqgovJZfyA/XfR3p9NEW64=; b=oK3PEjM7y65KcSfDbl5mOGgDrujsXeDMKybjlYbn0PlAgBJ4sRibhPe0pKu/BEeidjk3a24oAXGk4G6rS/bbfTdXywMUJbxA1JJE4m9C2hSD+IEceUXlqu7Umh0w9N25kNkCrbCGAKSM4T0q2OFdbaY4EgYXf7gJaSLbMaNvJDI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166633803498639.894080547196495; Fri, 21 Oct 2022 00:40:34 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmds-0003i4-Sm for importer@patchew.org; Fri, 21 Oct 2022 03:40:32 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmGx-00033g-5j for importer@patchew.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 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) 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) 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-Google-Smtp-Source: AMsMyM7+v6sVXyMr4DETckzRXRdpLJl9BYaWkvY3oLTnGCylqomIASL9vC9GDgGZ9RUHAVqIv60aLA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666338035378100001 Content-Type: text/plain; charset="utf-8" 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 */ =20 /* * 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, TCGOpc= ode opc, break; =20 case INDEX_op_div2_i32: - tcg_out_insn(s, RR, DR, TCG_REG_R2, args[4]); + tcg_debug_assert(args[0] =3D=3D args[2]); + tcg_debug_assert(args[1] =3D=3D args[3]); + tcg_debug_assert((args[1] & 1) =3D=3D 0); + tcg_debug_assert(args[0] =3D=3D 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] =3D=3D args[2]); + tcg_debug_assert(args[1] =3D=3D args[3]); + tcg_debug_assert((args[1] & 1) =3D=3D 0); + tcg_debug_assert(args[0] =3D=3D args[1] + 1); + tcg_out_insn(s, RRE, DLR, args[1], args[4]); break; =20 case INDEX_op_shl_i32: @@ -2515,17 +2523,30 @@ static inline void tcg_out_op(TCGContext *s, TCGOpc= ode opc, break; =20 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] =3D=3D args[2]); + tcg_debug_assert(args[1] =3D=3D args[3]); + tcg_debug_assert((args[1] & 1) =3D=3D 0); + tcg_debug_assert(args[0] =3D=3D 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] =3D=3D args[2]); + tcg_debug_assert(args[1] =3D=3D args[3]); + tcg_debug_assert((args[1] & 1) =3D=3D 0); + tcg_debug_assert(args[0] =3D=3D 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] =3D=3D args[2]); + tcg_debug_assert((args[1] & 1) =3D=3D 0); + tcg_debug_assert(args[0] =3D=3D args[1] + 1); + tcg_out_insn(s, RRE, MLGR, args[1], args[3]); break; =20 case INDEX_op_shl_i64: @@ -3220,10 +3241,10 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGO= pcode 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); =20 case INDEX_op_mulu2_i64: - return C_O2_I2(b, a, 0, r); + return C_O2_I2(o, m, 0, r); =20 case INDEX_op_add2_i32: case INDEX_op_sub2_i32: --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666337381669954.840420694709; Fri, 21 Oct 2022 00:29:41 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmTM-0002S0-Ay for importer@patchew.org; Fri, 21 Oct 2022 03:29:40 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmGz-00035L-Vx for importer@patchew.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 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) 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) 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-Google-Smtp-Source: AMsMyM7utyYVycrM+Fjq32Z/nCwkOByUH8lwHJ4x8U3K7dqQJHP7rcdcTSnknE5JdzzHxZIN/Af7ow== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1666337382835100001 Content-Type: text/plain; charset="utf-8" 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) =20 /* 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, Mem= Op 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 aligne= d. */ + tcg_debug_assert((datalo & 1) =3D=3D 0); + tcg_debug_assert(datahi =3D=3D datalo + 1); /* LDRD requires alignment; double-check that. */ - if (get_alignment_bits(opc) >=3D MO_64 - && (datalo & 1) =3D=3D 0 && datahi =3D=3D datalo + 1) { + if (get_alignment_bits(opc) >=3D MO_64) { /* * Rm (the second address op) must not overlap Rt or Rt + 1. * Since datalo is aligned, we can simplify the test via align= ment. @@ -1742,9 +1744,11 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, Me= mOp 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 aligne= d. */ + tcg_debug_assert((datalo & 1) =3D=3D 0); + tcg_debug_assert(datahi =3D=3D datalo + 1); /* LDRD requires alignment; double-check that. */ - if (get_alignment_bits(opc) >=3D MO_64 - && (datalo & 1) =3D=3D 0 && datahi =3D=3D datalo + 1) { + if (get_alignment_bits(opc) >=3D MO_64) { tcg_out_ldrd_8(s, COND_AL, datalo, addrlo, 0); } else if (datalo =3D=3D addrlo) { tcg_out_ld32_12(s, COND_AL, datahi, addrlo, 4); @@ -1826,9 +1830,11 @@ static void tcg_out_qemu_st_index(TCGContext *s, ARM= Cond 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 aligne= d. */ + tcg_debug_assert((datalo & 1) =3D=3D 0); + tcg_debug_assert(datahi =3D=3D datalo + 1); /* STRD requires alignment; double-check that. */ - if (get_alignment_bits(opc) >=3D MO_64 - && (datalo & 1) =3D=3D 0 && datahi =3D=3D datalo + 1) { + if (get_alignment_bits(opc) >=3D 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, Me= mOp 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 aligne= d. */ + tcg_debug_assert((datalo & 1) =3D=3D 0); + tcg_debug_assert(datahi =3D=3D datalo + 1); /* STRD requires alignment; double-check that. */ - if (get_alignment_bits(opc) >=3D MO_64 - && (datalo & 1) =3D=3D 0 && datahi =3D=3D datalo + 1) { + if (get_alignment_bits(opc) >=3D 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(TCGO= pcode op) case INDEX_op_qemu_ld_i32: return TARGET_LONG_BITS =3D=3D 32 ? C_O1_I1(r, l) : C_O1_I2(r, l, = l); case INDEX_op_qemu_ld_i64: - return TARGET_LONG_BITS =3D=3D 32 ? C_O2_I1(r, r, l) : C_O2_I2(r, = r, l, l); + return TARGET_LONG_BITS =3D=3D 32 ? C_O2_I1(e, p, l) : C_O2_I2(e, = p, l, l); case INDEX_op_qemu_st_i32: return TARGET_LONG_BITS =3D=3D 32 ? C_O0_I2(s, s) : C_O0_I3(s, s, = s); case INDEX_op_qemu_st_i64: - return TARGET_LONG_BITS =3D=3D 32 ? C_O0_I3(s, s, s) : C_O0_I4(s, = s, s, s); + return TARGET_LONG_BITS =3D=3D 32 ? C_O0_I3(S, p, s) : C_O0_I4(S, = p, s, s); =20 case INDEX_op_st_vec: return C_O0_I2(w, r); --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666337168; cv=none; d=zohomail.com; s=zohoarc; b=fN8yOnB4boKgL3yOXrNNy4p987RkNA0nJbhZWYjWKoWapzMN6EBKuQM8qYvL/86YPv2SnPCrpEL1PWZkn7plEzCEugsiuGKvzrc3qD0o9oU89JdBO26MdkryMiG88IWefchRrGEsmk5iy7rQiVazqaw8EW3BXaFIstvAcCTjt6A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666337168; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3WQZzPRazLKJGEWz/VuQ3kFYrNgQhqvNUOfet5eTrD4=; b=VNxr+qwrlnPMkd2x+lIfSOcVfky7akMU7WVib5GXQukCIPOepjG/C7Y2pftYl/ITK2QhzrAlow1ESecK/aY3b9jfFkuYM8Pmo70b4zRwVWTQUeqAypFjC/lk07MYb6JRSHC3o6+sS7nUkvJUShFygjl1p76LDup5yfEwVxWOmPs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666337168180940.5796031722258; Fri, 21 Oct 2022 00:26:08 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmPv-0008SU-15 for importer@patchew.org; Fri, 21 Oct 2022 03:26:07 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmGy-00034S-DR for importer@patchew.org; Fri, 21 Oct 2022 03:16: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 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) 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) 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-Google-Smtp-Source: AMsMyM5/GVvtAKm0WSXpxG6o30zONxhUJKM05Ga6efhnjp1NIMnbWena+BYQNN6y2wGS5Yx6w5VNEQ== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666337169715100001 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=C3=A9 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 =3D 'tci' + config_host +=3D { 'CONFIG_TCG_INTERPRETER': 'y' } elif host_arch =3D=3D 'x86_64' tcg_arch =3D 'i386' elif host_arch =3D=3D 'ppc64' @@ -2507,9 +2508,6 @@ foreach target : target_dirs if sym =3D=3D 'CONFIG_TCG' or target in accelerator_targets.get(sym, [= ]) config_target +=3D { sym: 'y' } config_all +=3D { sym: 'y' } - if sym =3D=3D 'CONFIG_TCG' and tcg_arch =3D=3D 'tci' - config_target +=3D { 'CONFIG_TCG_INTERPRETER': 'y' } - endif if target in modular_tcg config_target +=3D { 'CONFIG_TCG_MODULAR': 'y' } else --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666337198; cv=none; d=zohomail.com; s=zohoarc; b=B/3FVqj2dDCN+o2GaHLay3atlQLK7qjIZk7mvYWbaMLkOZItt3EMc+jU6Q5fku2Itf2EdVO7kwIA39p3LLI1L8q9vrjHS6rJ87bcRI8SoLUdMXuW9yF+R9X7+uL5B3AO7JzSdavgMRMqCaNo/QCPVpcG6Eap7EsqQGH6t2vsz1k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666337198; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6W8q5KR3SkNfvwFl20KCGR9C9fb12M8X2VM4t5Cdh0w=; b=Nat7CNyEYtQMTRotG4CMNSvR/hEKm0DkKQMhZA/CHYlPEy9Ow9n2ofNI9fkAHPN0X2smNC/36S29lvyfhRAXwGE5hlpivBR07UOwtDLgFx6YW1hErWHJDKPOCSkRIVdwbsOtlqWg/p9gUzemoYlmbqwsdkujpv4PzbCuY34DELA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166633719874539.030619068065675; Fri, 21 Oct 2022 00:26:38 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmQP-0000iS-Pu for importer@patchew.org; Fri, 21 Oct 2022 03:26:37 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmH1-00036a-FC for importer@patchew.org; Fri, 21 Oct 2022 03:16:55 -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) 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) 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-Google-Smtp-Source: AMsMyM4m1L6mKKfmpqvepu6ExqTTrlcfQehywqK7spmOz7nAl1l/hessk7ZPPjmJaRrlC7rLphA/Uw== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666337199817100001 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=C3=A9 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 =20 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; =20 #define use_armv7_instructions (__ARM_ARCH >=3D 7 || arm_arch >=3D 7) =20 -#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 nar= gs, TCGTemp **args) } =20 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 !=3D defined(TCG_TARGET_STACK_GROWSUP) - op->args[pi++] =3D temp_arg(args[i] + 1); - op->args[pi++] =3D temp_arg(args[i]); -#else - op->args[pi++] =3D temp_arg(args[i]); - op->args[pi++] =3D temp_arg(args[i] + 1); -#endif + op->args[pi++] =3D temp_arg(args[i] + HOST_BIG_ENDIAN); + op->args[pi++] =3D temp_arg(args[i] + !HOST_BIG_ENDIAN); real_args +=3D 2; continue; } @@ -4166,12 +4149,6 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const = TCGOp *op) return true; } =20 -#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 =3D TCGOP_CALLO(op); @@ -4211,18 +4188,13 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp= *op) stack_offset =3D TCG_TARGET_CALL_STACK_OFFSET; for (i =3D nb_regs; i < nb_iargs; i++) { arg =3D op->args[nb_oargs + i]; -#ifdef TCG_TARGET_STACK_GROWSUP - stack_offset -=3D sizeof(tcg_target_long); -#endif if (arg !=3D TCG_CALL_DUMMY_ARG) { ts =3D 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_off= set); } -#ifndef TCG_TARGET_STACK_GROWSUP stack_offset +=3D sizeof(tcg_target_long); -#endif } =20 /* assign input registers */ --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666338421; cv=none; d=zohomail.com; s=zohoarc; b=PgD4PM3jSY/2nxC7nCd+cr9yJKQBhxBuDD6Bh8uCoXUTcoqgpvtE0ppm09nY5CgcNiY/Dn0i9NgBELLZspUO9GiLveNPTH08bJ2acGH0c17ItkzgnNuB1UpZv2PGzGBLqHv9GmDkEz7HJfERqYrSoS/SHVXW+s2gm9moS/8sbC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666338421; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1fcBWbZUmm5Jnpz4Izudl/A6K0HNswQpl9r23JhxDb4=; b=V77bfJUkAXUklBTT7ntQtEMUxqDRzQrZ0TQSmEpFe2JaEPxfHXiwUFytxXcAHSCObYpVNbgcy/qnbIhLa0oHCChaMRseZfeK74ENfFENaO1psELGahHFzcLZ7po9KHg8R3wz06NGGkra2VuXKt5NVJ/Zz2ZxMRlMSAGGj66P7Bs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666338421844676.4628618392924; Fri, 21 Oct 2022 00:47:01 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmk8-0005EI-QH for importer@patchew.org; Fri, 21 Oct 2022 03:47:00 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmH2-000372-UT for importer@patchew.org; Fri, 21 Oct 2022 03:16:56 -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) 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) 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-Google-Smtp-Source: AMsMyM6ZZ8uwxVUssJYFoiI0aynJfeYUtKGIvorm5BkZRpzN4HiAzG7U7hrlOz9dLhoUaeEz6X7h+g== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666338423763100001 Content-Type: text/plain; charset="utf-8" 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 =3D 1; cpu->nr_threads =3D 1; + cpu->cflags_next_tb =3D -1; =20 qemu_mutex_init(&cpu->work_mutex); QSIMPLEQ_INIT(&cpu->work_list); --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666340697; cv=none; d=zohomail.com; s=zohoarc; b=BdEQ0Jw6rG2gWKEm262+j/UnG8I/sn1D3RTvbBFTKV4aIbtzcdi879e/fqo4DY0j03LxTwhGEKMmOkd2ATOV2MZkS5qlUq6oODU3Q0t9WxJPJaEddifL7tgmVTPAkTvIl1nZtCPMvVWH8xNdz2hwgpTr6R41t9m7GsiXO2WSuqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666340697; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ffAk/uKFmYMud8oNMjB2hkT94GX/9Rmm5gafjNWj2X0=; b=DwjNLkERUoLZVhwBH61RLU4Tt8nN+Wa8CBEJq5NkjIGgbbM54uS/RNu8xUWCbtFZyHV4Yi0al5Pm9Up4FOHlZDUWmA2e0ZhL1lIPm1ZWux05O14fVjdwOf9ajFUGXI6S9Mh/QwvIS04DU/ZDPns1NQEasmO1dpdq1pLnZ90YUtQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666340697769265.35960148737513; Fri, 21 Oct 2022 01:24:57 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnKp-00086q-6m for importer@patchew.org; Fri, 21 Oct 2022 04:24:55 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmH6-00039K-Bs for importer@patchew.org; Fri, 21 Oct 2022 03:17:00 -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) 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) 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-Google-Smtp-Source: AMsMyM4Wzq8Q/rtLPXZyFSbWxGyfEG+aV9DcZsNL2XvUb5AQoBgdGvM7d76JAVRRcHKhHcaq1apq9Q== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666340698891100001 Content-Type: text/plain; charset="utf-8" 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 =3D=3D 32 - if (src & 1) { - return TCGV_LOW(cpu_fpr[src / 2]); - } else { - return TCGV_HIGH(cpu_fpr[src / 2]); - } -#else TCGv_i32 ret =3D 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, unsi= gned int src) tcg_gen_extrh_i64_i32(ret, cpu_fpr[src / 2]); } return ret; -#endif } =20 static void gen_store_fpr_F(DisasContext *dc, unsigned int dst, TCGv_i32 v) { -#if TCG_TARGET_REG_BITS =3D=3D 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 =3D (TCGv_i64)v; + TCGv_i64 t =3D 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); } =20 --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666338334; cv=none; d=zohomail.com; s=zohoarc; b=SaOptCnOPvoWu+z0n776+tXmqMAE8T/9Q2a1uD64RNfjvL9t9dP5VeCzBM/qpxIjsNe08KJGPLjkIQ0MrO5FQosPsnfRKT8Ex46y2RxnwJjoZm9d2Wns9D7dcH2Bt0ySPfNkodeWbsyxmbe4YXq7c5nUNl0Uvry6vb3DdPjbPNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666338334; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JuYObXlFmz1SmrGQdE1r0MOoxWD6WYua5nMC/+UaBVA=; b=ecKZUEoT81TvOP8QJLQtwKejNEAKdAad5DKoiosAhKe6n2fG4fgjDEErAjw8XZP3zZgBXKfLZiGCENRURMvHqx+pCu+0pSgr9rrq2EfR713cC1YdODpZ1TRsZHJohoUo8jvofXIs0fn58opLuAlvoJhLjix6hw/UPAPKu+LcdQs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166633833447960.03109720451732; Fri, 21 Oct 2022 00:45:34 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmii-0002jD-VT for importer@patchew.org; Fri, 21 Oct 2022 03:45:33 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHC-0003Bv-Iz for importer@patchew.org; Fri, 21 Oct 2022 03:17: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 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) 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) 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-Google-Smtp-Source: AMsMyM51FEqgTzjUwcopVQFw3Na1Y5f80VyiVTNwjd7cgJK1fnx0kTKOML9ECaNCoGp2wrzpp35Xbw== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666338335760100001 Move the error-generating fallback from tcg-op.c, and replace "_link_error" with modern QEMU_ERROR markup. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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); } =20 -#if TCG_TARGET_REG_BITS =3D=3D 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; } =20 +#if TCG_TARGET_REG_BITS =3D=3D 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 reachab= le"); +extern TCGv_i32 TCGV_HIGH(TCGv_i64) QEMU_ERROR("32-bit code path is reacha= ble"); +#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" =20 -/* 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 =3D=3D 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 =20 void tcg_gen_op1(TCGOpcode opc, TCGArg a1) { --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666339483; cv=none; d=zohomail.com; s=zohoarc; b=N6637Ci666edUOGHKuW6iPGyAj2NYHeqmrqIu8oYMgkzcbU7UYMDu4afcoUIHgCDTZmvxF4s/q6KkuLqDf6w8mYnB7n6EYpdFv9cilkE0GK2/Z9ke94lgpmJbRJngBNq9GC/OfCBQAz9NbBBzHYqvZnUoLvUDZuGfBXkiEsGXcw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666339483; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L8z30GASyjyVRHVSC+j+Ssl7AGNt135XvRhLazZAsug=; b=kXyw33dCTcmam0jX9MQcidARx4cy+QCHIN5YlVD5DoFAk/nJzAeJxmDRpxv++LnKb7dT6VnyFTpgo1lI/Zgy5gnQHcD4DGSK51pE6sP/xqb6TdJft/u0ALyTFYa0ZPC7hMgJkaZ1WWvVp0rzEmqaaLSaO1MJLxNze7jrKpYNMKw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666339483420878.4751209089408; Fri, 21 Oct 2022 01:04:43 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oln1G-000786-6T for importer@patchew.org; Fri, 21 Oct 2022 04:04:42 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHG-0003CG-JI for importer@patchew.org; Fri, 21 Oct 2022 03:17: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 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) 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) 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-Google-Smtp-Source: AMsMyM6+D0TDl59avP5gnozkz8Yw9Tw1A9lcN0sH6gXAjS0z2lwt2Ul0C2Dwcj5G2K+uS0HhN+//8w== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666339485538100001 Record the location of a TCGTemp within a larger object. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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; =20 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 =3D 1; ts2->mem_base =3D base_ts; ts2->mem_offset =3D offset + (1 - bigendian) * 4; + ts2->temp_subindex =3D 1; pstrcpy(buf, sizeof(buf), name); pstrcat(buf, sizeof(buf), "_1"); ts2->name =3D strdup(buf); @@ -973,6 +974,7 @@ TCGTemp *tcg_temp_new_internal(TCGType type, bool temp_= local) ts2->base_type =3D TCG_TYPE_I64; ts2->type =3D TCG_TYPE_I32; ts2->temp_allocated =3D 1; + ts2->temp_subindex =3D 1; ts2->kind =3D kind; } else { ts->base_type =3D type; @@ -1091,6 +1093,7 @@ TCGTemp *tcg_constant_internal(TCGType type, int64_t = val) ts2->type =3D TCG_TYPE_I32; ts2->kind =3D TEMP_CONST; ts2->temp_allocated =3D 1; + ts2->temp_subindex =3D 1; ts2->val =3D val >> 32; } else { ts->base_type =3D type; --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666348261; cv=none; d=zohomail.com; s=zohoarc; b=BeLTgrZVFGMzpvW0uS5+JBSukRQYj2Asndr5n7CJ0Ix14eXrhmLNFARYxOJEWyUcZtnwbzSMCiE/O1rX97DU4M9bRxCZQI9Z6NxyHdFx50btwU30POnXYV2rxe09/SHivlGO+Wd25DOBbfwp33fdT43/4Lg11k+P1bLKxurLRKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666348261; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AwWY0LmSatCRIwkg33bhhLxAFaDGQf8EaVCLJgJX9aU=; b=W7fK1ey3cpUIw7LZZFKOWyEFPkIAXRElUK+7G3j+EE8WhRwFqBPQoMAVyQxJvA/67roS0PMuFzK1S2Q23to/eSrd7WJ5bZQ1uJl9gqUZ6C4sTz0WmQ1/voElt3Dgs8I2Z+1gtSFKuz4XQTm/laC1mnM4N9QShLBhXY2IdAoPI0w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666348261567598.988648970619; Fri, 21 Oct 2022 03:31:01 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olpIm-0005Yr-Ih for importer@patchew.org; Fri, 21 Oct 2022 06:30:57 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHM-0003Cl-8z for importer@patchew.org; Fri, 21 Oct 2022 03:17:16 -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) 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) 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-Google-Smtp-Source: AMsMyM7HO6YU3gFYPcFDOjiBeSCpFNfnmmEldrMb3aBgln33vI8PGmUaRCxE+T3hkL4PrL0vqqoAsw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666348262771100001 Content-Type: text/plain; charset="utf-8" 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) =20 /* If the two inputs form one 64-bit value, try dupm_vec. */ if (itsl + 1 =3D=3D itsh && itsl->base_type =3D=3D 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 =3D itsh; #else --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666339123; cv=none; d=zohomail.com; s=zohoarc; b=bS+neRg5gT4eLGeVtdKLR87G1DMZgVtL5AFIhe8ez5S7bewBLBgvWpHw6sEr5kny1As6lfjZb16oPZUel1FnsKH1dBC4x/cGYRrj4jR/hS8wsArIhfcc372U3EUegtHBUY6XMA5riPb94nrV8cQWU6fLvcK6uAj8b5FKHK9piiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666339123; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EHwHeycEZKxhFMLIOg3z57g+gF1F+0x/Q8WmhqVPueE=; b=Ki4hhwi5xSY5LDNLxpZjIgFxE36cJ5EqfEB4Y6m3BjxLlFkU8jcOAuKpRCtFMEkT9bFZaM5HLOhXqYAdxeW0s4bojazYOb+39TEKnGh9i/wdH1SSymwDrgOaKuZv9p2RkYUX6TylhXJWP2qewqZ+/dDLl4kcvYatEJAjnvrK+/c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666339123133178.47830935850936; Fri, 21 Oct 2022 00:58:43 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmvS-0006jC-3I for importer@patchew.org; Fri, 21 Oct 2022 03:58:42 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHn-0003L0-P9 for importer@patchew.org; Fri, 21 Oct 2022 03:17:43 -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) 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) 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-Google-Smtp-Source: AMsMyM64iR5zEmwIdU5eCzjN40F1h6q5FH8ug6K+Zq8MUF1MU2uurVlYvPK4aZWue4oM1ZN0FSqSzw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666339125412100001 Content-Type: text/plain; charset="utf-8" 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 =3D=3D 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 reachab= le"); 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, TCG= v_ptr base, TCGContext *s =3D tcg_ctx; TCGTemp *base_ts =3D tcgv_ptr_temp(base); TCGTemp *ts =3D tcg_global_alloc(s); - int indirect_reg =3D 0, bigendian =3D 0; -#if HOST_BIG_ENDIAN - bigendian =3D 1; -#endif + int indirect_reg =3D 0; =20 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 =3D indirect_reg; ts->mem_allocated =3D 1; ts->mem_base =3D base_ts; - ts->mem_offset =3D offset + bigendian * 4; + ts->mem_offset =3D offset; pstrcpy(buf, sizeof(buf), name); pstrcat(buf, sizeof(buf), "_0"); ts->name =3D strdup(buf); @@ -926,7 +923,7 @@ TCGTemp *tcg_global_mem_new_internal(TCGType type, TCGv= _ptr base, ts2->indirect_reg =3D indirect_reg; ts2->mem_allocated =3D 1; ts2->mem_base =3D base_ts; - ts2->mem_offset =3D offset + (1 - bigendian) * 4; + ts2->mem_offset =3D offset + 4; ts2->temp_subindex =3D 1; pstrcpy(buf, sizeof(buf), name); pstrcat(buf, sizeof(buf), "_1"); @@ -1072,37 +1069,43 @@ TCGTemp *tcg_constant_internal(TCGType type, int64_= t val) =20 ts =3D g_hash_table_lookup(h, &val); if (ts =3D=3D NULL) { + int64_t *val_ptr; + ts =3D tcg_temp_alloc(s); =20 if (TCG_TARGET_REG_BITS =3D=3D 32 && type =3D=3D TCG_TYPE_I64) { TCGTemp *ts2 =3D tcg_temp_alloc(s); =20 + tcg_debug_assert(ts2 =3D=3D ts + 1); + ts->base_type =3D TCG_TYPE_I64; ts->type =3D TCG_TYPE_I32; ts->kind =3D TEMP_CONST; ts->temp_allocated =3D 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 =3D val; =20 - tcg_debug_assert(ts2 =3D=3D ts + 1); ts2->base_type =3D TCG_TYPE_I64; ts2->type =3D TCG_TYPE_I32; ts2->kind =3D TEMP_CONST; ts2->temp_allocated =3D 1; ts2->temp_subindex =3D 1; - ts2->val =3D 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 =3D val; + ts[!HOST_BIG_ENDIAN].val =3D val >> 32; + val_ptr =3D &ts[HOST_BIG_ENDIAN].val; } else { ts->base_type =3D type; ts->type =3D type; ts->kind =3D TEMP_CONST; ts->temp_allocated =3D 1; ts->val =3D val; + val_ptr =3D &ts->val; } - g_hash_table_insert(h, &ts->val, ts); + g_hash_table_insert(h, val_ptr, ts); } =20 return ts; @@ -1514,13 +1517,8 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nar= gs, TCGTemp **args) pi =3D 0; if (ret !=3D NULL) { if (TCG_TARGET_REG_BITS < 64 && (typemask & 6) =3D=3D dh_typecode_= i64) { -#if HOST_BIG_ENDIAN - op->args[pi++] =3D temp_arg(ret + 1); - op->args[pi++] =3D temp_arg(ret); -#else op->args[pi++] =3D temp_arg(ret); op->args[pi++] =3D temp_arg(ret + 1); -#endif nb_rets =3D 2; } else { op->args[pi++] =3D temp_arg(ret); @@ -1554,8 +1552,8 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int narg= s, TCGTemp **args) } =20 if (TCG_TARGET_REG_BITS < 64 && is_64bit) { - op->args[pi++] =3D temp_arg(args[i] + HOST_BIG_ENDIAN); - op->args[pi++] =3D temp_arg(args[i] + !HOST_BIG_ENDIAN); + op->args[pi++] =3D temp_arg(args[i]); + op->args[pi++] =3D temp_arg(args[i] + 1); real_args +=3D 2; continue; } @@ -4116,14 +4114,14 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const= TCGOp *op) } =20 /* If the two inputs form one 64-bit value, try dupm_vec. */ - if (itsl + 1 =3D=3D itsh && itsl->base_type =3D=3D 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 =3D itsh; -#else - TCGTemp *its =3D itsl; -#endif + if (itsl->temp_subindex =3D=3D HOST_BIG_ENDIAN && + itsh->temp_subindex =3D=3D !HOST_BIG_ENDIAN && + itsl =3D=3D itsh + (HOST_BIG_ENDIAN ? 1 : -1)) { + TCGTemp *its =3D 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; --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666342453; cv=none; d=zohomail.com; s=zohoarc; b=laKwja4XwL/9Sk6S4nqToIpe0rb5FPvlrPcZxN3ilHIGkQCQcS9iVp6ZEdwvgkQpz0cTlVyD4yvpi4ofhaDkOsJk6YflkSDAsSE+1Fr/tKgK3cdl7YdyG+NSdA3sGBz5ujZR1GPKW22QCgcv094JuBhSE0zWfDHADLLN3PKt0oE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666342453; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g+8yoDAKtbWcn6kd6zbMcipsZN6xB1eyyko6EmQwVd4=; b=CunIlHqAuPTBDLIp9FrrG/tldP7IuVrAKcnVs4D80Uf+Q+mAl90bNzmb3/gxPWt46bFS3e6zdufHcBVrOVud3aErxP/TB41hdb392BAGXlJRUhxrB4tiwYU1LESFOxaaJPc8Llgavkkemg2lM9Vgs4M0N3BZxXYKEIRM9EA42RE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666342453921158.8737666779167; Fri, 21 Oct 2022 01:54:13 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnn9-00084h-AN for importer@patchew.org; Fri, 21 Oct 2022 04:54:11 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHf-0003J1-Nj for importer@patchew.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 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) 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) 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-Google-Smtp-Source: AMsMyM6x8efw6TeFrkwQUDLYbrRnoAOPla3z5qQFIsTxTV/yC5nnV7KU8508w3T+NF5F1D9ATMq/Mg== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666342455556100001 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=C3=A9 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, =20 - TCG_TYPE_COUNT, /* number of different types */ + /* Number of different types (integer not enum) */ +#define TCG_TYPE_COUNT (TCG_TYPE_V256 + 1) =20 /* An alias for the size of the host register. */ #if TCG_TARGET_REG_BITS =3D=3D 32 --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666339075; cv=none; d=zohomail.com; s=zohoarc; b=V3aST0pJPUVaJaCajRayc84Aqwj+sCyeR60yrJGiLrb8mqYhBGfU1kL2a8PiLqZrXZecmW4d8hM1jO8I8xwxwd4fpJpTfH0Z7z8nqcF2vXV3tOyiRrzZRipw4nRRHicHLY6IfEpni2zu82GEOX7yQlJMAenhzXMzl4E5YcDVTng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666339075; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JONxt9CE65pjWaD+nTpNlKjL3nDuRwB7r5QiBKPwDCY=; b=RQ4HMQ0Hr75c6Tlvi1P4cctNIc3IbjWo3CnbhAozvo/x8TadvnjULo6LJWjJxVID+CPM26zisphpccuQ/jTW4aHrLzzdVT+pehqZf3yE/s2dR/vA69S6qtc6Cx482sMpVZfOmxkLPzsfvpb0/WVizRb/CcwEd0M/EYrq04U5QhM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666339075389471.8138134116864; Fri, 21 Oct 2022 00:57:55 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmue-0003Fh-Ol for importer@patchew.org; Fri, 21 Oct 2022 03:57:52 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHW-0003Ff-Dt for importer@patchew.org; Fri, 21 Oct 2022 03:17:26 -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) 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) 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-Google-Smtp-Source: AMsMyM6Sh603TYee2sO0Lc1QHwbz2+IebEccL2YigTd6+YcyCiaSr553x3dulocC0u/fHuAPWamDlw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666339077240100001 Content-Type: text/plain; charset="utf-8" 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; =20 +/** + * tcg_type_size + * @t: type + * + * Return the size of the type in bytes. + */ +static inline int tcg_type_size(TCGType t) +{ + unsigned i =3D t; + if (i >=3D TCG_TYPE_V64) { + tcg_debug_assert(i < TCG_TYPE_COUNT); + i -=3D 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) =20 static void temp_allocate_frame(TCGContext *s, TCGTemp *ts) { - intptr_t off, size, align; + int size =3D tcg_type_size(ts->type); + int align; + intptr_t off; =20 switch (ts->type) { case TCG_TYPE_I32: - size =3D align =3D 4; + align =3D 4; break; case TCG_TYPE_I64: case TCG_TYPE_V64: - size =3D align =3D 8; + align =3D 8; break; case TCG_TYPE_V128: - size =3D align =3D 16; - break; case TCG_TYPE_V256: /* Note that we do not require aligned storage for V256. */ - size =3D 32, align =3D 16; + align =3D 16; break; default: g_assert_not_reached(); @@ -3641,8 +3641,8 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TC= GOp *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; =20 ots =3D arg_temp(op->args[0]); @@ -3711,14 +3711,12 @@ static void tcg_reg_alloc_dup(TCGContext *s, const = TCGOp *op) /* fall through */ =20 case TEMP_VAL_MEM: -#if HOST_BIG_ENDIAN - endian_fixup =3D itype =3D=3D TCG_TYPE_I32 ? 4 : 8; - endian_fixup -=3D 1 << vece; -#else - endian_fixup =3D 0; -#endif + lowpart_ofs =3D 0; + if (HOST_BIG_ENDIAN) { + lowpart_ofs =3D 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= ); --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666340328; cv=none; d=zohomail.com; s=zohoarc; b=SlhV3JNUru848poeFtWKsf3w6h5j9UYJ9WKV+PuyWDPDTZFapX8FB3OY9xoR6+eFMnvANHNCu/hap6+2LUdAj4qDpa7E93yc7ljaDe0e7xQO9dXShc5rfh9l6V8XKL6x3ywwBFPh1Tijwnycahzt85oM7QRpaOxCaRPjT9ElFyY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666340328; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5vQArXkcT1RDMZRTO1vvTA3LiXCIJpRLbh9UK0Nx/ps=; b=kVowhul5Zi2Q5RtShG3fx7Eim62BcmmZ4UIfd67Jlz4/QdcOAnXOvu2UTrpJbSU5ioW/kqns6JRe+wR0vwQuNwzPH94oHusqVrT51mRxueAhW852Nxr330xg2JqmwqoR6a+Vh8Qj8MnVjoohtp7h+BXMAwFttPa9R5p+g02zf+4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666340328455985.4946345552762; Fri, 21 Oct 2022 01:18:48 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnEt-0006Mk-9l for importer@patchew.org; Fri, 21 Oct 2022 04:18:47 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHV-0003Fc-Dz for importer@patchew.org; Fri, 21 Oct 2022 03:17:25 -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) 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) 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-Google-Smtp-Source: AMsMyM6E+ZomfEvKVL2L+hTMTBuv5UCAnvoCRt2XdCs/PYZL8AO5AUh2QhFwfWca2yNQo/4D+ZEf8w== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666340330193100001 Content-Type: text/plain; charset="utf-8" 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 @@ =20 #define TCG_HIGHWATER 1024 =20 +/* + * 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; --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666338353; cv=none; d=zohomail.com; s=zohoarc; b=RbAEGOMv3WMLX5ldVvzSRxUMHMEQTNSlBPOcbtAth0R6HedHEIEOCiYMBQaSB9UGZUU3DU1TZHPDFyPOLdLtSlEHRhuY3dsPpA/a4yNe7mzosk3s6mxgWPwfDz7jtPBSGSt6v2Gybg57QA5r2PxwtL4Hxz5mRbkKb6URvjOz5eY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666338353; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NLYEAygg5zhZY8+MbyEmX2kcrfhvOHFDC88V+mEh+NI=; b=VaBGRXDLE8C3C3BqQbOZOZ4PdqYbNoFJovueYP03iU2kNearBnAkAb8emGp9AhS5YFI3LaoFqwu12RYRm2OOQNM51DS5y0wxgIkeiRdz2CupldY2ysE6yzA7YkdnvW8pPtMUl7JXbPpURv55MZEerjgz21eoXNYHgThteOuucbg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666338353990532.1861590614562; Fri, 21 Oct 2022 00:45:53 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmj2-0003rC-Bv for importer@patchew.org; Fri, 21 Oct 2022 03:45:52 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHi-0003JQ-5C for importer@patchew.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 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) 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) 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-Google-Smtp-Source: AMsMyM75Ukkr0r8b/sldpZnlmpAfZ9iQTZIF7IBh8GCr8g/DIUKukeI84/13aFkEjASvpSXBeURXEA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666338355521100001 Content-Type: text/plain; charset="utf-8" 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=C3=A9 --- 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 =20 /* 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; =20 /* 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 =20 /* 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 =20 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 =20 /* 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 =3D=3D _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 =20 /* MOVN/MOVZ instructions detection */ #if (defined(__mips_isa_rev) && (__mips_isa_rev >=3D 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 =3D=3D 32 +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN +#else +#define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL +#endif =20 /* 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 =20 #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 =20 #if defined(__VIS__) && __VIS__ >=3D 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 =3D=3D 32 +# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN +#else +# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL +#endif =20 #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 nar= gs, TCGTemp **args) * for passing off to ffi_call. */ want_align =3D true; -#elif defined(TCG_TARGET_CALL_ALIGN_ARGS) +#else /* Some targets want aligned 64 bit args */ - want_align =3D is_64bit; + if (is_64bit) { + want_align =3D TCG_TARGET_CALL_ARG_I64 =3D=3D TCG_CALL_ARG_EVE= N; + } #endif =20 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=20 =20 #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 =20 /* For some memory operations, we need a scratch that isn't R0. For the A= IX @@ -2202,9 +2204,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) lo =3D lb->addrlo_reg; hi =3D lb->addrhi_reg; if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { -#ifdef TCG_TARGET_CALL_ALIGN_ARGS - arg |=3D 1; -#endif + arg |=3D (TCG_TARGET_CALL_ARG_I64 =3D=3D 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 =3D lb->addrlo_reg; hi =3D lb->addrhi_reg; if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { -#ifdef TCG_TARGET_CALL_ALIGN_ARGS - arg |=3D 1; -#endif + arg |=3D (TCG_TARGET_CALL_ARG_I64 =3D=3D 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 =3D=3D 32) { switch (s_bits) { case MO_64: -#ifdef TCG_TARGET_CALL_ALIGN_ARGS - arg |=3D 1; -#endif + arg |=3D (TCG_TARGET_CALL_ARG_I64 =3D=3D 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, TCG= LabelQemuLdst *l) =20 if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { TCGReg arg =3D TCG_REG_R4; -#ifdef TCG_TARGET_CALL_ALIGN_ARGS - arg |=3D 1; -#endif + + arg |=3D (TCG_TARGET_CALL_ARG_I64 =3D=3D TCG_CALL_ARG_EVEN); if (l->addrlo_reg !=3D arg) { tcg_out_mov(s, TCG_TYPE_I32, arg, l->addrhi_reg); tcg_out_mov(s, TCG_TYPE_I32, arg + 1, l->addrlo_reg); --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666343297; cv=none; d=zohomail.com; s=zohoarc; b=VyJDev0Q7xx3OYSH49scLtTYBsNYO6MMZUAIgbt+2S9qNlikiBNmUI42pxIArDXKHFVu0VkHjm6/zb0vAD88pLkTlT/r8HLVS3zq1N2UCOw0DW4rgXNCHOj0Z38QsgVI3nyQOniV1tndSW2B5Em3pI4Vh+TKwsr3W9Xbq9CArxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666343297; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=agyTV2jCK/77n3/Q34HNtG1TiDyGgsf/EB88ers/CYk=; b=CETF4SZrLtD9oQk9ssAGcU8Yo0emBGGWJQwg1YZMkhAuSOpSzzlYyiUtTCjaSIVn4Jalom0KCL1POfzIgdzOh8GnpYn15iyOFjqADYQKD1E693/ya+2QC+NlKiGT1dR6DyqNV1H3BvnzSifSPwZ1C4E++QiO5Uru1x3BzVeUdpo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666343297557679.7896701227675; Fri, 21 Oct 2022 02:08:17 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olo0f-0008JF-Mi for importer@patchew.org; Fri, 21 Oct 2022 05:08:13 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHj-0003JT-OY for importer@patchew.org; Fri, 21 Oct 2022 03:17:39 -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) 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) 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-Google-Smtp-Source: AMsMyM4fMaFqUKg9P2Engrnvd+F9tyeoO+Rg//V53D/eOOJT2g/l42vWMho4UyT2awJD84yHrktxWQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666343299643100001 Content-Type: text/plain; charset="utf-8" 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=C3=A9 --- 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 =20 /* 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 =20 /* 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 =20 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 =20 /* 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 =20 /* MOVN/MOVZ instructions detection */ #if (defined(__mips_isa_rev) && (__mips_isa_rev >=3D 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 =3D=3D 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 =20 -#define TCG_TARGET_EXTEND_ARGS 1 #define TCG_TARGET_HAS_MEMORY_BSWAP 1 =20 #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 =20 #if defined(__VIS__) && __VIS__ >=3D 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 =3D=3D 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 na= rgs, TCGTemp **args) } #endif =20 -#if defined(TCG_TARGET_EXTEND_ARGS) && TCG_TARGET_REG_BITS =3D=3D 64 - for (i =3D 0; i < nargs; ++i) { - int argtype =3D extract32(typemask, (i + 1) * 3, 3); - bool is_32bit =3D (argtype & ~1) =3D=3D dh_typecode_i32; - bool is_signed =3D argtype & 1; + if (TCG_TARGET_CALL_ARG_I32 =3D=3D TCG_CALL_ARG_EXTEND) { + for (i =3D 0; i < nargs; ++i) { + int argtype =3D extract32(typemask, (i + 1) * 3, 3); + bool is_32bit =3D (argtype & ~1) =3D=3D dh_typecode_i32; + bool is_signed =3D argtype & 1; =20 - if (is_32bit) { - TCGv_i64 temp =3D tcg_temp_new_i64(); - TCGv_i32 orig =3D 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 =3D tcg_temp_new_i64(); + TCGv_i32 orig =3D 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] =3D tcgv_i64_temp(temp); } - args[i] =3D tcgv_i64_temp(temp); } } -#endif /* TCG_TARGET_EXTEND_ARGS */ =20 op =3D tcg_emit_op(INDEX_op_call); =20 @@ -1571,16 +1571,16 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int na= rgs, TCGTemp **args) tcg_debug_assert(TCGOP_CALLI(op) =3D=3D real_args); tcg_debug_assert(pi <=3D ARRAY_SIZE(op->args)); =20 -#if defined(TCG_TARGET_EXTEND_ARGS) && TCG_TARGET_REG_BITS =3D=3D 64 - for (i =3D 0; i < nargs; ++i) { - int argtype =3D extract32(typemask, (i + 1) * 3, 3); - bool is_32bit =3D (argtype & ~1) =3D=3D dh_typecode_i32; + if (TCG_TARGET_CALL_ARG_I32 =3D=3D TCG_CALL_ARG_EXTEND) { + for (i =3D 0; i < nargs; ++i) { + int argtype =3D extract32(typemask, (i + 1) * 3, 3); + bool is_32bit =3D (argtype & ~1) =3D=3D dh_typecode_i32; =20 - if (is_32bit) { - tcg_temp_free_internal(args[i]); + if (is_32bit) { + tcg_temp_free_internal(args[i]); + } } } -#endif /* TCG_TARGET_EXTEND_ARGS */ } =20 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=20 =20 +#if TCG_TARGET_REG_BITS =3D=3D 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 co= unt) =20 /* Parameters for function call generation, used in tcg.c. */ #define TCG_TARGET_STACK_ALIGN 16 -#define TCG_TARGET_EXTEND_ARGS 1 =20 #ifdef _CALL_AIX # define LINK_AREA_SIZE (6 * SZR) --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666341157; cv=none; d=zohomail.com; s=zohoarc; b=kOo7A0TbT7yHkCzX7I4V67vPJJJ0GDOSotPbk7aQarDqS7Fa7f1NN7oWNoWkL3i8MRW2LNaKiaT5BZk+qc2W0OoW7MTgpoH9vkjVvi/btvc+n8i/78b0vNKTWHeoUGJWiFv5W7tw3CkpmjAnMqcj4i3X4NCyXPkh6MIplBWf1eY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666341157; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YL8W2fQ+28CPJzwzlqNSd9vlVmUOZrRLduSb6SVZ5pE=; b=h50lg0NiPiaZF+xnUiQKoEL+XQFuE45HVog/YOabeav1TrJKggeAwfPXvziBqwcr1/hE7R9A6Ru4Q2RkfDuYn5i4zqoeZfm216mYnovh9gmKTgRA3Bn2M/RaElZCIFPA+jQ8am1kef8FP2wQVjnQlV63CQFOtTtufkvCVwu4vaw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666341157871970.8772872473195; Fri, 21 Oct 2022 01:32:37 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnSF-0001f6-J6 for importer@patchew.org; Fri, 21 Oct 2022 04:32:36 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHg-0003JI-JN for importer@patchew.org; Fri, 21 Oct 2022 03:17:36 -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) 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) 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-Google-Smtp-Source: AMsMyM5d1uuaOLM+v5TE0LHmDE6kIzhnTLWs/8tPM5BvJ/D/+LNkcQlqYFVKDbsXzMPrabmHrtHzeA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666341160135100001 Content-Type: text/plain; charset="utf-8" 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 =3D=3D 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 =20 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 na= rgs, TCGTemp **args) real_args =3D 0; for (i =3D 0; i < nargs; i++) { int argtype =3D extract32(typemask, (i + 1) * 3, 3); - bool is_64bit =3D (argtype & ~1) =3D=3D dh_typecode_i64; - bool want_align =3D false; + TCGCallArgumentKind kind; + TCGType type; =20 -#if defined(CONFIG_TCG_INTERPRETER) - /* - * Align all arguments, so that they land in predictable places - * for passing off to ffi_call. - */ - want_align =3D true; -#else - /* Some targets want aligned 64 bit args */ - if (is_64bit) { - want_align =3D TCG_TARGET_CALL_ARG_I64 =3D=3D TCG_CALL_ARG_EVE= N; - } -#endif - - if (TCG_TARGET_REG_BITS < 64 && want_align && (real_args & 1)) { - op->args[pi++] =3D TCG_CALL_DUMMY_ARG; - real_args++; + switch (argtype) { + case dh_typecode_i32: + case dh_typecode_s32: + type =3D TCG_TYPE_I32; + kind =3D TCG_TARGET_CALL_ARG_I32; + break; + case dh_typecode_i64: + case dh_typecode_s64: + type =3D TCG_TYPE_I64; + kind =3D TCG_TARGET_CALL_ARG_I64; + break; + case dh_typecode_ptr: + type =3D TCG_TYPE_PTR; + kind =3D TCG_CALL_ARG_NORMAL; + break; + default: + g_assert_not_reached(); } =20 - if (TCG_TARGET_REG_BITS < 64 && is_64bit) { + switch (kind) { + case TCG_CALL_ARG_EVEN: + if (real_args & 1) { + op->args[pi++] =3D TCG_CALL_DUMMY_ARG; + real_args++; + } + /* fall through */ + case TCG_CALL_ARG_NORMAL: + if (TCG_TARGET_REG_BITS =3D=3D 32 && type =3D=3D TCG_TYPE_I64)= { + op->args[pi++] =3D temp_arg(args[i]); + op->args[pi++] =3D temp_arg(args[i] + 1); + real_args +=3D 2; + break; + } op->args[pi++] =3D temp_arg(args[i]); - op->args[pi++] =3D temp_arg(args[i] + 1); - real_args +=3D 2; - continue; + real_args++; + break; + default: + g_assert_not_reached(); } - - op->args[pi++] =3D temp_arg(args[i]); - real_args++; } op->args[pi++] =3D (uintptr_t)func; op->args[pi++] =3D (uintptr_t)info; --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666338646; cv=none; d=zohomail.com; s=zohoarc; b=NNloUp3TFtra5TxyGwtPVFkcmjsZhe7WdD6Mo23myzGaR6K7wvaMfTTLwt5edhLd/nxnV4nryJo9vKlCXtJo96aDOFRl96+BXavx8/GU7cgJozF2fuZniizrQ+n4Nzn/BhBYEtEIFTvWH4U88PIbmhhWONXrClBnJ8mtUR36sYQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666338646; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=V4SUZjAaozp75Gu5oXBaKguhljd88jPKuaDdX4HiKKo=; b=mitLVSq7h43nVorzUjaaaQg/qrljjhdtY4vpLyHJfsRJt6lAT/XTbj6Vfyup5lRPz5Vpj64fbS7BmUkOikbU2+oMpsTdROiegGwhuuxGGkP4zP8I9RelcBu58r/a24NgcfL0Hzt2U3Qx0JhsVqtAmZsQytfVPNlYXdMdZj8ZEdc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666338646676634.6808767459107; Fri, 21 Oct 2022 00:50:46 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmnk-0002oE-E2 for importer@patchew.org; Fri, 21 Oct 2022 03:50:44 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHl-0003Jd-3i for importer@patchew.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 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) 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) 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-Google-Smtp-Source: AMsMyM5xWHWPGMKEZJYKgUtTJ2jZ4SUlswoNwGTyUpOUuSWGNXF4E9VJ1J7aTW7QgRqZp9IF0tNaaQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666338647317100001 Content-Type: text/plain; charset="utf-8" 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) =20 -/* 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; =20 +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; =20 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) =20 #include "exec/helper-proto.h" =20 -static const TCGHelperInfo all_helpers[] =3D { +static TCGHelperInfo all_helpers[] =3D { #include "exec/helper-tcg.h" }; static GHashTable *helper_table; @@ -564,6 +564,162 @@ static ffi_type * const typecode_to_ffi[8] =3D { }; #endif =20 +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 =3D &info->in[cum->info_in_idx]; + + *loc =3D (TCGCallArgumentLoc){ + .kind =3D kind, + .arg_idx =3D cum->arg_idx, + }; + + if (cum->reg_slot < cum->max_reg_slot) { + loc->reg_slot =3D cum->reg_slot++; + loc->reg_n =3D 1; + } else { + loc->stk_slot =3D cum->stk_slot++; + } + + cum->info_in_idx++; + cum->op_arg_idx++; +} + +static void layout_arg_normal_2(TCGCumulativeArgs *cum, TCGHelperInfo *inf= o) +{ + TCGCallArgumentLoc *loc =3D &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 =3D 1; +} + +static void init_call_layout(TCGHelperInfo *info) +{ + unsigned typemask =3D info->typemask; + unsigned typecode; + TCGCumulativeArgs cum =3D { + .max_reg_slot =3D ARRAY_SIZE(tcg_target_call_iarg_regs), + .max_stk_slot =3D TCG_STATIC_CALL_ARGS_SIZE / sizeof(tcg_target_lo= ng), + }; + + /* + * Parse and place any function return value. + */ + typecode =3D typemask & 7; + switch (typecode) { + case dh_typecode_void: + info->nr_out =3D 0; + break; + case dh_typecode_i32: + case dh_typecode_s32: + case dh_typecode_ptr: + info->nr_out =3D 1; + info->out_kind =3D TCG_CALL_RET_NORMAL; + break; + case dh_typecode_i64: + case dh_typecode_s64: + info->nr_out =3D 64 / TCG_TARGET_REG_BITS; + info->out_kind =3D TCG_CALL_RET_NORMAL; + break; + default: + g_assert_not_reached(); + } + assert(info->nr_out <=3D 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 =3D info->nr_out + 2; + + /* + * Parse and place function arguments. + */ + for (typemask >>=3D 3; typemask; typemask >>=3D 3, cum.arg_idx++) { + TCGCallArgumentKind kind; + TCGType type; + + typecode =3D typemask & 7; + switch (typecode) { + case dh_typecode_i32: + case dh_typecode_s32: + type =3D TCG_TYPE_I32; + kind =3D TCG_TARGET_CALL_ARG_I32; + break; + case dh_typecode_i64: + case dh_typecode_s64: + type =3D TCG_TYPE_I64; + kind =3D TCG_TARGET_CALL_ARG_I64; + break; + case dh_typecode_ptr: + type =3D TCG_TYPE_PTR; + kind =3D 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 =3D=3D 0); + if (cum.reg_slot < cum.max_reg_slot) { + cum.reg_slot +=3D cum.reg_slot & 1; + } else { + cum.stk_slot +=3D 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 =3D=3D 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 =3D TCG_CALL_ARG_EXTEND_U + (typecode & 1); + /* fall through */ + case TCG_CALL_ARG_EXTEND_U: + case TCG_CALL_ARG_EXTEND_S: + assert(type =3D=3D TCG_TYPE_I32); + layout_arg_1(&cum, info, kind); + break; + default: + g_assert_not_reached(); + } + } + info->nr_in =3D cum.info_in_idx; + + /* Validate that we didn't overrun the input array. */ + assert(cum.info_in_idx <=3D ARRAY_SIZE(info->in)); + /* Validate that we didn't overrun the output array. */ + assert(cum.op_arg_idx <=3D MAX_OPC_PARAM); + /* Validate the backend has preallocated enough space on stack. */ + assert(cum.stk_slot <=3D 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 =3D g_hash_table_new(NULL, NULL); =20 for (i =3D 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) } } =20 -/* 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 =3D tcg_op_alloc(INDEX_op_call); const TCGHelperInfo *info; - TCGOp *op; + int i, n, pi =3D 0; =20 info =3D g_hash_table_lookup(helper_table, (gpointer)func); - typemask =3D info->typemask; =20 #ifdef CONFIG_PLUGIN /* detect non-plugin helpers */ @@ -1493,106 +1647,59 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int n= args, TCGTemp **args) } #endif =20 - if (TCG_TARGET_CALL_ARG_I32 =3D=3D TCG_CALL_ARG_EXTEND) { - for (i =3D 0; i < nargs; ++i) { - int argtype =3D extract32(typemask, (i + 1) * 3, 3); - bool is_32bit =3D (argtype & ~1) =3D=3D dh_typecode_i32; - bool is_signed =3D argtype & 1; + TCGOP_CALLO(op) =3D n =3D info->nr_out; + switch (n) { + case 0: + tcg_debug_assert(ret =3D=3D NULL); + break; + case 1: + tcg_debug_assert(ret !=3D NULL); + op->args[pi++] =3D temp_arg(ret); + break; + case 2: + tcg_debug_assert(ret !=3D NULL); + tcg_debug_assert(ret->temp_subindex =3D=3D 0); + op->args[pi++] =3D temp_arg(ret); + op->args[pi++] =3D temp_arg(ret + 1); + break; + default: + g_assert_not_reached(); + } =20 - if (is_32bit) { + TCGOP_CALLI(op) =3D n =3D info->nr_in; + for (i =3D 0; i < n; i++) { + const TCGCallArgumentLoc *loc =3D &info->in[i]; + TCGTemp *ts =3D args[loc->arg_idx] + loc->tmp_subindex; + + switch (loc->kind) { + case TCG_CALL_ARG_NORMAL: + op->args[pi++] =3D temp_arg(ts); + break; + + case TCG_CALL_ARG_EXTEND_U: + case TCG_CALL_ARG_EXTEND_S: + { TCGv_i64 temp =3D tcg_temp_new_i64(); - TCGv_i32 orig =3D temp_tcgv_i32(args[i]); - if (is_signed) { + TCGv_i32 orig =3D temp_tcgv_i32(ts); + + if (loc->kind =3D=3D TCG_CALL_ARG_EXTEND_S) { tcg_gen_ext_i32_i64(temp, orig); } else { tcg_gen_extu_i32_i64(temp, orig); } - args[i] =3D tcgv_i64_temp(temp); + op->args[pi++] =3D tcgv_i64_arg(temp); + tcg_temp_free_i64(temp); } - } - } - - op =3D tcg_emit_op(INDEX_op_call); - - pi =3D 0; - if (ret !=3D NULL) { - if (TCG_TARGET_REG_BITS < 64 && (typemask & 6) =3D=3D dh_typecode_= i64) { - op->args[pi++] =3D temp_arg(ret); - op->args[pi++] =3D temp_arg(ret + 1); - nb_rets =3D 2; - } else { - op->args[pi++] =3D temp_arg(ret); - nb_rets =3D 1; - } - } else { - nb_rets =3D 0; - } - TCGOP_CALLO(op) =3D nb_rets; - - real_args =3D 0; - for (i =3D 0; i < nargs; i++) { - int argtype =3D extract32(typemask, (i + 1) * 3, 3); - TCGCallArgumentKind kind; - TCGType type; - - switch (argtype) { - case dh_typecode_i32: - case dh_typecode_s32: - type =3D TCG_TYPE_I32; - kind =3D TCG_TARGET_CALL_ARG_I32; break; - case dh_typecode_i64: - case dh_typecode_s64: - type =3D TCG_TYPE_I64; - kind =3D TCG_TARGET_CALL_ARG_I64; - break; - case dh_typecode_ptr: - type =3D TCG_TYPE_PTR; - kind =3D TCG_CALL_ARG_NORMAL; - break; - default: - g_assert_not_reached(); - } =20 - switch (kind) { - case TCG_CALL_ARG_EVEN: - if (real_args & 1) { - op->args[pi++] =3D TCG_CALL_DUMMY_ARG; - real_args++; - } - /* fall through */ - case TCG_CALL_ARG_NORMAL: - if (TCG_TARGET_REG_BITS =3D=3D 32 && type =3D=3D TCG_TYPE_I64)= { - op->args[pi++] =3D temp_arg(args[i]); - op->args[pi++] =3D temp_arg(args[i] + 1); - real_args +=3D 2; - break; - } - op->args[pi++] =3D temp_arg(args[i]); - real_args++; - break; default: g_assert_not_reached(); } } op->args[pi++] =3D (uintptr_t)func; op->args[pi++] =3D (uintptr_t)info; - TCGOP_CALLI(op) =3D real_args; =20 - /* Make sure the fields didn't overflow. */ - tcg_debug_assert(TCGOP_CALLI(op) =3D=3D real_args); - tcg_debug_assert(pi <=3D ARRAY_SIZE(op->args)); - - if (TCG_TARGET_CALL_ARG_I32 =3D=3D TCG_CALL_ARG_EXTEND) { - for (i =3D 0; i < nargs; ++i) { - int argtype =3D extract32(typemask, (i + 1) * 3, 3); - bool is_32bit =3D (argtype & ~1) =3D=3D dh_typecode_i32; - - if (is_32bit) { - tcg_temp_free_internal(args[i]); - } - } - } + QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); } =20 static void tcg_reg_alloc_start(TCGContext *s) @@ -1807,10 +1914,7 @@ static void tcg_dump_ops(TCGContext *s, FILE *f, boo= l have_prefs) } for (i =3D 0; i < nb_iargs; i++) { TCGArg arg =3D op->args[nb_oargs + i]; - const char *t =3D ""; - if (arg !=3D TCG_CALL_DUMMY_ARG) { - t =3D tcg_get_arg_str(s, buf, sizeof(buf), arg); - } + const char *t =3D tcg_get_arg_str(s, buf, sizeof(buf), arg= ); col +=3D 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 =3D tcg_call_info(op); + int call_flags =3D tcg_call_flags(op); =20 nb_oargs =3D TCGOP_CALLO(op); nb_iargs =3D TCGOP_CALLI(op); - call_flags =3D tcg_call_flags(op); =20 /* 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 =3D nb_oargs; i < nb_iargs + nb_oargs; i++) { ts =3D arg_temp(op->args[i]); - if (ts && ts->state & TS_DEAD) { + if (ts->state & TS_DEAD) { arg_life |=3D 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); =20 - nb_call_regs =3D 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 rever= se + * order so that if a temp is used more than once, the sta= ck + * reset to max happens before the register reset to 0. + */ + for (i =3D nb_iargs - 1; i >=3D 0; i--) { + const TCGCallArgumentLoc *loc =3D &info->in[i]; + ts =3D arg_temp(op->args[nb_oargs + i]); =20 - /* Input arguments are live for preceding opcodes. */ - for (i =3D 0; i < nb_iargs; i++) { - ts =3D arg_temp(op->args[i + nb_oargs]); - if (ts && ts->state & TS_DEAD) { - /* For those arguments that die, and will be alloc= ated - * in registers, clear the register set for that a= rg, - * to be filled in below. For args that will be on - * the stack, reset to any available reg. - */ - *la_temp_pref(ts) - =3D (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) =3D 0; + break; + } + /* fall through */ + default: + *la_temp_pref(ts) =3D + tcg_target_available_regs[ts->type]; + break; + } ts->state &=3D ~TS_DEAD; } } =20 - /* For each input argument, add its input register to pref= s. - If a temp is used once, this produces a single set bit.= */ - for (i =3D 0; i < MIN(nb_call_regs, nb_iargs); i++) { - ts =3D 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 pref= s. + * 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 =3D 0; i < nb_iargs; i++) { + const TCGCallArgumentLoc *loc =3D &info->in[i]; + ts =3D 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 =3D nb_oargs; i < nb_iargs + nb_oargs; i++) { arg_ts =3D arg_temp(op->args[i]); - if (arg_ts) { - dir_ts =3D arg_ts->state_ptr; - if (dir_ts && arg_ts->state =3D=3D TS_DEAD) { - TCGOpcode lopc =3D (arg_ts->type =3D=3D TCG_TYPE_I32 - ? INDEX_op_ld_i32 - : INDEX_op_ld_i64); - TCGOp *lop =3D tcg_op_insert_before(s, op, lopc); + dir_ts =3D arg_ts->state_ptr; + if (dir_ts && arg_ts->state =3D=3D TS_DEAD) { + TCGOpcode lopc =3D (arg_ts->type =3D=3D TCG_TYPE_I32 + ? INDEX_op_ld_i32 + : INDEX_op_ld_i64); + TCGOp *lop =3D tcg_op_insert_before(s, op, lopc); =20 - lop->args[0] =3D temp_arg(dir_ts); - lop->args[1] =3D temp_arg(arg_ts->mem_base); - lop->args[2] =3D arg_ts->mem_offset; + lop->args[0] =3D temp_arg(dir_ts); + lop->args[1] =3D temp_arg(arg_ts->mem_base); + lop->args[2] =3D arg_ts->mem_offset; =20 - /* Loaded, but synced with memory. */ - arg_ts->state =3D TS_MEM; - } + /* Loaded, but synced with memory. */ + arg_ts->state =3D TS_MEM; } } =20 @@ -4158,106 +4287,100 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, con= st TCGOp *op) return true; } =20 +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 =3D tcg_target_call_iarg_regs[loc->reg_slot]; + + if (ts->val_type =3D=3D TEMP_VAL_REG) { + if (ts->reg !=3D 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 =3D 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 =3D TCGOP_CALLO(op); const int nb_iargs =3D TCGOP_CALLI(op); const TCGLifeData arg_life =3D 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 =3D tcg_call_info(op); + TCGRegSet allocated_regs =3D s->reserved_regs; + int i; =20 - func_addr =3D tcg_call_func(op); - info =3D tcg_call_info(op); - flags =3D info->flags; + /* + * Move inputs into place in reverse order, + * so that we place stacked arguments first. + */ + for (i =3D nb_iargs - 1; i >=3D 0; --i) { + const TCGCallArgumentLoc *loc =3D &info->in[i]; + TCGTemp *ts =3D arg_temp(op->args[nb_oargs + i]); =20 - nb_regs =3D ARRAY_SIZE(tcg_target_call_iarg_regs); - if (nb_regs > nb_iargs) { - nb_regs =3D nb_iargs; - } - - /* assign stack slots first */ - call_stack_size =3D (nb_iargs - nb_regs) * sizeof(tcg_target_long); - call_stack_size =3D (call_stack_size + TCG_TARGET_STACK_ALIGN - 1) &=20 - ~(TCG_TARGET_STACK_ALIGN - 1); - allocate_args =3D (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 =3D TCG_TARGET_CALL_STACK_OFFSET; - for (i =3D nb_regs; i < nb_iargs; i++) { - arg =3D op->args[nb_oargs + i]; - if (arg !=3D TCG_CALL_DUMMY_ARG) { - ts =3D 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_off= set); - } - stack_offset +=3D sizeof(tcg_target_long); - } - =20 - /* assign input registers */ - allocated_regs =3D s->reserved_regs; - for (i =3D 0; i < nb_regs; i++) { - arg =3D op->args[nb_oargs + i]; - if (arg !=3D TCG_CALL_DUMMY_ARG) { - ts =3D arg_temp(arg); - reg =3D tcg_target_call_iarg_regs[i]; - - if (ts->val_type =3D=3D TEMP_VAL_REG) { - if (ts->reg !=3D 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 =3D 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(); } } - =20 - /* mark dead temporaries and free the associated registers */ + + /* Mark dead temporaries and free the associated registers. */ for (i =3D nb_oargs; i < nb_iargs + nb_oargs; i++) { if (IS_DEAD_ARG(i)) { temp_dead(s, arg_temp(op->args[i])); } } - =20 - /* clobber call registers */ + + /* Clobber call registers. */ for (i =3D 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); } } =20 - /* 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 =3D (gpointer)(uintptr_t)info->typemask; ffi_cif *cif =3D g_hash_table_lookup(ffi_table, hash); assert(cif !=3D 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 =20 - /* assign output registers and emit moves if needed */ - for(i =3D 0; i < nb_oargs; i++) { - arg =3D op->args[i]; - ts =3D arg_temp(arg); + /* Assign output registers and emit moves if needed. */ + switch (info->out_kind) { + case TCG_CALL_RET_NORMAL: + for (i =3D 0; i < nb_oargs; i++) { + TCGTemp *ts =3D arg_temp(op->args[i]); + TCGReg reg =3D tcg_target_call_oarg_regs[i]; =20 - /* ENV should not be modified. */ - tcg_debug_assert(!temp_readonly(ts)); + /* ENV should not be modified. */ + tcg_debug_assert(!temp_readonly(ts)); =20 - reg =3D tcg_target_call_oarg_regs[i]; - tcg_debug_assert(s->reg_to_temp[reg] =3D=3D NULL); - if (ts->val_type =3D=3D TEMP_VAL_REG) { - s->reg_to_temp[ts->reg] =3D NULL; + tcg_debug_assert(s->reg_to_temp[reg] =3D=3D NULL); + if (ts->val_type =3D=3D TEMP_VAL_REG) { + s->reg_to_temp[ts->reg] =3D NULL; + } + ts->val_type =3D TEMP_VAL_REG; + ts->reg =3D reg; + ts->mem_coherent =3D 0; + s->reg_to_temp[reg] =3D ts; } - ts->val_type =3D TEMP_VAL_REG; - ts->reg =3D reg; - ts->mem_coherent =3D 0; - s->reg_to_temp[reg] =3D ts; + break; + default: + g_assert_not_reached(); + } + + /* Flush or discard output registers as needed. */ + for (i =3D 0; i < nb_oargs; i++) { + TCGTemp *ts =3D 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); } --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666341050; cv=none; d=zohomail.com; s=zohoarc; b=ip4MxPZvRwfFa4J7o1dyXEeRifOy659GU5DaKnI/RGxbR/0IOr9214xkdSkqse/ApUixeufeKbmKEUG+8sJFPMw7mxB5UllCFaF7LWWwyfZ0Rc4kFhCkEzjojXpYtOivYFgD3KTqGaIvWxbfk9rcXrmlZw6QZtq6l3FoHW5jJYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666341050; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+auU7PVqmG99ktmS6b3UEAfMFz0jKVdnqCCXndsje+Q=; b=Y9lXXbHF2vakMUjU8zyiuj0nAglsYNwHBypmygeCNczWT70An4g2JKlrFigyCs1LLmSglvphCY9xHiKGuqVcUlee56tvyZHoIhVd1MJIftyjx+IUOL47QfUmVDfr9Uj7UL/NvQiGLM0WePTVRe87+Xk14dpXNFPIsNO3fGtBhAY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666341050363139.257072232597; Fri, 21 Oct 2022 01:30:50 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnQW-0000C6-Ne for importer@patchew.org; Fri, 21 Oct 2022 04:30:48 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHj-0003JV-K0 for importer@patchew.org; Fri, 21 Oct 2022 03:17:39 -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) 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) 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-Google-Smtp-Source: AMsMyM6dx5ZqjEK4Xi5ENJZybd7I86IGoFg9mvZQ4+j2AParnSkf+ssYERkhjJ9+dJ9mH0DrGrpDrg== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666341051407100001 Content-Type: text/plain; charset="utf-8" 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 =20 +#ifdef CONFIG_TCG_INTERPRETER +#include +#endif + #define TCG_HIGHWATER 1024 =20 /* @@ -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" =20 -#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[] =3D { static GHashTable *helper_table; =20 #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(); +} =20 -static ffi_type * const typecode_to_ffi[8] =3D { - [dh_typecode_void] =3D &ffi_type_void, - [dh_typecode_i32] =3D &ffi_type_uint32, - [dh_typecode_s32] =3D &ffi_type_sint32, - [dh_typecode_i64] =3D &ffi_type_uint64, - [dh_typecode_s64] =3D &ffi_type_sint64, - [dh_typecode_ptr] =3D &ffi_type_pointer, -}; -#endif +static void init_ffi_layouts(void) +{ + /* g_direct_hash/equal for direct comparisons on uint32_t. */ + GHashTable *ffi_table =3D g_hash_table_new(NULL, NULL); + + for (int i =3D 0; i < ARRAY_SIZE(all_helpers); ++i) { + TCGHelperInfo *info =3D &all_helpers[i]; + unsigned typemask =3D info->typemask; + gpointer hash =3D (gpointer)(uintptr_t)typemask; + struct { + ffi_cif cif; + ffi_type *args[]; + } *ca; + ffi_status status; + int nargs; + ffi_cif *cif; + + cif =3D g_hash_table_lookup(ffi_table, hash); + if (cif) { + info->cif =3D cif; + continue; + } + + /* Ignoring the return type, find the last non-zero field. */ + nargs =3D 32 - clz32(typemask >> 3); + nargs =3D DIV_ROUND_UP(nargs, 3); + + ca =3D g_malloc0(sizeof(*ca) + nargs * sizeof(ffi_type *)); + ca->cif.rtype =3D typecode_to_ffi(typemask & 7); + ca->cif.nargs =3D nargs; + + if (nargs !=3D 0) { + ca->cif.arg_types =3D ca->args; + for (i =3D 0; i < nargs; ++i) { + int typecode =3D extract32(typemask, (i + 1) * 3, 3); + ca->args[i] =3D typecode_to_ffi(typecode); + } + } + + status =3D ffi_prep_cif(&ca->cif, FFI_DEFAULT_ABI, nargs, + ca->cif.rtype, ca->cif.arg_types); + assert(status =3D=3D FFI_OK); + + cif =3D &ca->cif; + info->cif =3D cif; + g_hash_table_insert(ffi_table, hash, (gpointer)cif); + } + + g_hash_table_destroy(ffi_table); +} +#endif /* CONFIG_TCG_INTERPRETER */ =20 typedef struct TCGCumulativeArgs { int arg_idx; /* tcg_gen_callN args[] */ @@ -765,44 +820,7 @@ static void tcg_context_init(unsigned max_cpus) } =20 #ifdef CONFIG_TCG_INTERPRETER - /* g_direct_hash/equal for direct comparisons on uint32_t. */ - ffi_table =3D g_hash_table_new(NULL, NULL); - for (i =3D 0; i < ARRAY_SIZE(all_helpers); ++i) { - struct { - ffi_cif cif; - ffi_type *args[]; - } *ca; - uint32_t typemask =3D all_helpers[i].typemask; - gpointer hash =3D (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 =3D 32 - clz32(typemask >> 3); - nargs =3D DIV_ROUND_UP(nargs, 3); - - ca =3D g_malloc0(sizeof(*ca) + nargs * sizeof(ffi_type *)); - ca->cif.rtype =3D typecode_to_ffi[typemask & 7]; - ca->cif.nargs =3D nargs; - - if (nargs !=3D 0) { - ca->cif.arg_types =3D ca->args; - for (i =3D 0; i < nargs; ++i) { - int typecode =3D extract32(typemask, (i + 1) * 3, 3); - ca->args[i] =3D typecode_to_ffi[typecode]; - } - } - - status =3D ffi_prep_cif(&ca->cif, FFI_DEFAULT_ABI, nargs, - ca->cif.rtype, ca->cif.arg_types); - assert(status =3D=3D FFI_OK); - - g_hash_table_insert(ffi_table, hash, (gpointer)&ca->cif); - } + init_ffi_layouts(); #endif =20 tcg_target_init(s); @@ -4387,12 +4405,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp = *op) } =20 #ifdef CONFIG_TCG_INTERPRETER - { - gpointer hash =3D (gpointer)(uintptr_t)info->typemask; - ffi_cif *cif =3D g_hash_table_lookup(ffi_table, hash); - assert(cif !=3D 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 --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666346986; cv=none; d=zohomail.com; s=zohoarc; b=ZHzChvru/Bjps8DKeYDOEkhB8rvOvknAg0VlsKtepDx1bsnzH9bgkibE8QvZcOcLTk6aRetZ7OwOmwhysJ0wwKSbv6Vhao0AJhe4Leg0kLoxX046g9h4v1PtE0hyBvEQzX7upmobqPOENx7ZavhzF5tTlW8Qtb9jAWrCUikuKrg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666346986; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jRraYrN7VevkThzpI1pDQIipRClwjcnorE3BJjtqVhA=; b=CCwv/bgU7x4M4MXR6RA3qi3UkwtWTb2bdUpphSgn0a+tzo20ERlYvquEXjs0y5VhnqYPP8i6E8bHq4cUR3NTBFh/YgzGkwv/T0whpcBhv3zznna854SBfAOUOCSjDnNiZ+WG9XBw87NTXLSLcH89xyY0Cw0buQ/Y6F2hzF3Q4vQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166634698651746.86528708271851; Fri, 21 Oct 2022 03:09:46 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oloyF-0007P3-Lm for importer@patchew.org; Fri, 21 Oct 2022 06:09:43 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHk-0003JX-NZ for importer@patchew.org; Fri, 21 Oct 2022 03:17:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 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) 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) 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-Google-Smtp-Source: AMsMyM6aU2kgmHGGw0qSX+UU2xNRJMZW9vm65d9K11F9L5wU73SOGG5yAGLqG9Vck5KkDYL+CWiK8Q== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666346988681100001 This eliminates an ifdef for TCI, and will be required for expanding the call for TCGv_i128. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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, TC= GReg 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); } =20 -#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); =20 /* 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) } } =20 -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 =3D tcg_pcrel_diff(s, target) >> 2; if (offset =3D=3D 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); } } =20 +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 =3D=3D 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 =3D=3D 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 =3D (intptr_t)addr; ptrdiff_t disp =3D tcg_pcrel_diff(s, addr); @@ -1150,6 +1150,12 @@ static void tcg_out_call(TCGContext *s, const tcg_in= sn_unit *addr) tcg_out_blx_reg(s, COND_AL, TCG_REG_TMP); } =20 +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 =3D tcg_out_arg_reg32(s, argreg, TCG_REG_R14); =20 /* 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]); =20 datalo =3D lb->datalo_reg; datahi =3D 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, c= onst tcg_insn_unit *dest) } } =20 -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); } =20 - 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)]); =20 data_reg =3D 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_i= nsn_unit *arg, bool tail) } } =20 -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, TC= GLabelQemuLdst *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); =20 - tcg_out_call(s, qemu_ld_helpers[size]); + tcg_out_call_int(s, qemu_ld_helpers[size], false); =20 switch (opc & MO_SSIZE) { case MO_SB: @@ -821,7 +822,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TC= GLabelQemuLdst *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); =20 - tcg_out_call(s, qemu_st_helpers[size]); + tcg_out_call_int(s, qemu_st_helpers[size], false); =20 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) } } =20 -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 } =20 -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); =20 - 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)]); =20 lo =3D lb->datalo_reg; hi =3D 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); =20 - 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)]); =20 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_i= nsn_unit *arg, bool tail) } } =20 -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); =20 - 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) =3D=3D MO_64, l->datalo_reg, a0); =20 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); =20 - tcg_out_call(s, qemu_st_helpers[opc & MO_SIZE]); + tcg_out_call_int(s, qemu_st_helpers[opc & MO_SIZE], false); =20 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); } =20 -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 =3D tcg_pcrel_diff(s, dest) >> 1; if (off =3D=3D (int32_t)off) { @@ -1702,6 +1702,12 @@ static void tcg_out_call(TCGContext *s, const tcg_in= sn_unit *dest) } } =20 +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); =20 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)]); =20 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 t= cg_insn_unit *dest, } } =20 -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, } =20 static void tcg_out_call(TCGContext *s, const tcg_insn_unit *func, - ffi_cif *cif) + const TCGHelperInfo *info) { + ffi_cif *cif =3D info->cif; tcg_insn_unit insn =3D 0; uint8_t which; =20 --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666344762; cv=none; d=zohomail.com; s=zohoarc; b=efv5bcqboZ4hGxzmLZdPuiWSeOKkN0ZrzBSFEBqxq2V50o80xWJ82f6f08rVzs6AdQqhmnJX2DhKTN3YnGKhTs8IiZAxQPByenZG/HbYgTaRmh+be4YxaADd1eowcXek5z6dFTQM0iDq6lxpEIfjA/G++TQ5q0ZJWW3RsEox2Jw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666344762; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SfazqaVq/Md711XTgHXaB4eXQUcEJfZf9rE0mqnfz88=; b=j9R91lOjfikdYpPUOFjgI1Ls8eMkeMak4h5GGvauQcUH17zQC/LsiFx5efcjvr/0myvJDXcV8Xh1mk+4hWK/ExNhl9xNLrAARpz9Qrap2K1vVObHaY6IPCK6DEemL29K0P073B+4KrUdsxrzbsw9/WKpBUI6MwkMKG/MLqptopo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666344762396729.979456385494; Fri, 21 Oct 2022 02:32:42 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oloON-0004C8-Da for importer@patchew.org; Fri, 21 Oct 2022 05:32:39 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHk-0003Ja-9w for importer@patchew.org; Fri, 21 Oct 2022 03:17:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 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) 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) 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-Google-Smtp-Source: AMsMyM6s9/Ai85Fa1KuPZUkyU5ivbfyyIHMWP1w0RFumg1/b+3EHU3WTH2C/kGwHjt8Z9WoTvidbTQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666344763912100001 Content-Type: text/plain; charset="utf-8" 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)) =20 @@ -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)) =20 @@ -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)) =20 @@ -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 @@ =20 #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 =20 -#if HOST_LONG_BITS =3D=3D 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) =20 -/* A Call op needs up to 4 + 2N parameters on 32-bit archs, - * and up to 4 + N parameters on 64-bit archs - * (N =3D number of input arguments + output arguments). */ +/* + * A Call op needs up to 4 + 2N parameters. + * (N =3D number of input arguments + output arguments). + */ #define MAX_OPC_PARAM (4 + (MAX_OPC_PARAM_PER_ARG * MAX_OPC_PARAM_ARGS)) =20 #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, =20 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. =20 @@ -396,6 +395,7 @@ typedef tcg_target_ulong TCGArg; =20 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; --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666337463; cv=none; d=zohomail.com; s=zohoarc; b=lZBLtRLilWzlRdTwulIlXcraOATwEmKDEjmjBbYJyvo9Kq0mWRFtQkudgGMe4zAFAys+0BZIXeW2WYwULU0if4dLEXAyvhMu0blBx7y0bA8WU7u1V9oSR1YO+BZ8aTnAn/IHpgfsBvhsMM/dDTtWpyZbuMhdsVb5aOXjL9q6MFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666337463; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QmH6UfzNb2W5B+qTcQwkyCbKbOPU702ATit26UV60EY=; b=OMNurzNKqXvZ7mEiXxXL0U6JMqSpVpcSpOUalKpyIelCiwDQa/dJiQhwxhyW3BTwkhH8mbjPgrDeM4iYodkQFBCuHCCHDLsP9tl47B7KgRdBtZoz6unJcn4aV7nD3Sw3uqMV2lyfKqCVYZ4jVirseVpLhqNKMX0ENq+LkRDkF6E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666337463406627.8676331080396; Fri, 21 Oct 2022 00:31:03 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmUb-00043S-CN for importer@patchew.org; Fri, 21 Oct 2022 03:30:58 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHy-0003Ot-7O for importer@patchew.org; Fri, 21 Oct 2022 03:17: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 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) 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) 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-Google-Smtp-Source: AMsMyM6gLhf/RCqrBT/GuwfUArs6jH21eGEE/ws4fvTr2YOAGEsGd9MR+fs4BJdJP7LPn3jyoQs7YQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666337465096100001 Content-Type: text/plain; charset="utf-8" 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; =20 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; =20 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 =3D 1; } =20 +static void layout_arg_normal_4(TCGCumulativeArgs *cum, TCGHelperInfo *inf= o) +{ + TCGCallArgumentLoc *loc =3D &info->in[cum->info_in_idx]; + int reg_n =3D MIN(4, cum->max_reg_slot - cum->reg_slot); + + *loc =3D (TCGCallArgumentLoc){ + .kind =3D TCG_CALL_ARG_NORMAL_4, + .arg_idx =3D cum->arg_idx, + }; + + if (reg_n > 0) { + loc->reg_slot =3D cum->reg_slot; + loc->reg_n =3D reg_n; + cum->reg_slot +=3D reg_n; + } + if (reg_n < 4) { + loc->stk_slot =3D cum->stk_slot; + cum->stk_slot +=3D 4 - reg_n; + } + + cum->info_in_idx++; + cum->op_arg_idx++; +} + static void init_call_layout(TCGHelperInfo *info) { unsigned typemask =3D info->typemask; @@ -686,10 +710,29 @@ static void init_call_layout(TCGHelperInfo *info) info->nr_out =3D 64 / TCG_TARGET_REG_BITS; info->out_kind =3D 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 =3D TCG_TARGET_REG_BITS =3D=3D 32 ? 1 : 2; + info->out_kind =3D TCG_CALL_RET_NORMAL; /* TODO */ + switch (/* TODO */ TCG_CALL_RET_NORMAL) { + case TCG_CALL_RET_NORMAL: + if (TCG_TARGET_REG_BITS =3D=3D 32) { + assert(ARRAY_SIZE(tcg_target_call_oarg_regs) >=3D 4); + info->out_kind =3D TCG_CALL_RET_NORMAL_4; + } else { + assert(ARRAY_SIZE(tcg_target_call_oarg_regs) >=3D 2); + } + break; + default: + g_assert_not_reached(); + } + break; default: g_assert_not_reached(); } - assert(info->nr_out <=3D ARRAY_SIZE(tcg_target_call_oarg_regs)); =20 /* * 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 =3D=3D 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 narg= s, TCGTemp **args) =20 switch (loc->kind) { case TCG_CALL_ARG_NORMAL: + case TCG_CALL_ARG_NORMAL_4: op->args[pi++] =3D temp_arg(ts); break; =20 @@ -4301,6 +4352,41 @@ static bool tcg_reg_alloc_dup2(TCGContext *s, const = TCGOp *op) return true; } =20 +static void copy_to_stk_i128(TCGContext *s, int stk_slot, TCGTemp *ts, + int slot, TCGRegSet allocated_regs) +{ + int stk_off =3D TCG_TARGET_CALL_STACK_OFFSET + + stk_slot * sizeof(tcg_target_long); + + if (TCG_TARGET_REG_BITS =3D=3D 32) { + TCGReg scratch; + + tcg_debug_assert(ts->type =3D=3D TCG_TYPE_I128); + tcg_debug_assert(ts->val_type =3D=3D TEMP_VAL_MEM); + tcg_debug_assert(ts->mem_allocated); + + scratch =3D tcg_reg_alloc(s, tcg_target_available_regs[TCG_TYPE_I3= 2], + 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 =3D=3D TCG_TYPE_I128); + tcg_debug_assert(ts->temp_subindex =3D=3D 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 T= CGCallArgumentLoc *loc, tcg_regset_set_reg(*allocated_regs, reg); } =20 +static void load_arg_normal_4(TCGContext *s, const TCGCallArgumentLoc *loc, + TCGTemp *ts, TCGRegSet *allocated_regs) +{ + int reg_n =3D loc->reg_n; + + if (reg_n !=3D 4) { + copy_to_stk_i128(s, loc->stk_slot, ts, reg_n, *allocated_regs); + } + + for (reg_n--; reg_n >=3D 0; reg_n--) { + TCGReg reg =3D 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 =3D 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] =3D ts; } break; + + case TCG_CALL_RET_NORMAL_4: + tcg_debug_assert(TCG_TARGET_REG_BITS =3D=3D 32); + { + TCGTemp *ts =3D arg_temp(op->args[0]); + + tcg_debug_assert(ts->type =3D=3D TCG_TYPE_I128); + if (!ts->mem_allocated) { + temp_allocate_frame(s, ts); + } + for (i =3D 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 =3D TEMP_VAL_MEM; + } + break; + default: g_assert_not_reached(); } --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666341497; cv=none; d=zohomail.com; s=zohoarc; b=MSYRnzDZvR0gBtTUcbNC8ks04xMAEEHG+1GZNYiJkJnXwApSjQwE2n0p8HDHFoCTweR6mgOt1HhRjes2JY9egSMMYiTs8f3KtpKCbfgPbeMUjPonEu2+70TWcXINUfBU3PsPli61gSRZUTrRXXAp9Tm043QEdfuQMwCD9h1J9zU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666341497; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OjjeRZqVgFS5dG8LiFwvWFyG3e2GWcohg60z62TsQR8=; b=mziov1F7sEqwiwK4578rS2PsoF9zRBJPKE/2CG1PySvkynGvyPqKqIGCjlEKCbTLSyV0iqGyP6PqiD9KmnDiRiH7OfUvze5Cvjo/ot5aBbxDsKCsOhxeyjuOnium4zh9mV5vREToZi98HNYmZAT2dQv/zc1eMZLSMThE1eqFay0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666341497373889.6784506196791; Fri, 21 Oct 2022 01:38:17 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnXi-0006iT-AV for importer@patchew.org; Fri, 21 Oct 2022 04:38:16 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmHu-0003OS-T4 for importer@patchew.org; Fri, 21 Oct 2022 03:17: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 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) 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) 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-Google-Smtp-Source: AMsMyM712DFSjGduUHLj5nggeKYzVw4mQah6b7yO6+TSerGlxu/OTYUg+Jct20OfXmUJrWfikb0Jxw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666341498328100001 Content-Type: text/plain; charset="utf-8" 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) =20 static void temp_allocate_frame(TCGContext *s, TCGTemp *ts) { - int size =3D tcg_type_size(ts->type); - int align; intptr_t off; + int size, align; =20 - switch (ts->type) { + /* When allocating an object, look at the full type. */ + size =3D tcg_type_size(ts->base_type); + switch (ts->base_type) { case TCG_TYPE_I32: align =3D 4; break; @@ -3353,13 +3354,26 @@ static void temp_allocate_frame(TCGContext *s, TCGT= emp *ts) tcg_raise_tb_overflow(s); } s->current_frame_offset =3D off + size; - - ts->mem_offset =3D off; #if defined(__sparc__) - ts->mem_offset +=3D TCG_TARGET_STACK_BIAS; + off +=3D TCG_TARGET_STACK_BIAS; #endif - ts->mem_base =3D s->frame_temp; - ts->mem_allocated =3D 1; + + /* If the object was subdivided, assign memory to all the parts. */ + if (ts->base_type !=3D ts->type) { + int part_size =3D tcg_type_size(ts->type); + int part_count =3D size / part_size; + + ts -=3D ts->temp_subindex; + for (int i =3D 0; i < part_count; ++i) { + ts[i].mem_offset =3D off + i * part_size; + ts[i].mem_base =3D s->frame_temp; + ts[i].mem_allocated =3D 1; + } + } else { + ts->mem_offset =3D off; + ts->mem_base =3D s->frame_temp; + ts->mem_allocated =3D 1; + } } =20 static void temp_load(TCGContext *, TCGTemp *, TCGRegSet, TCGRegSet, TCGRe= gSet); --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666345363; cv=none; d=zohomail.com; s=zohoarc; b=Cywz794PyE3KQG2rJhsp4q2mPjCNrBwBMypNI9u2va6RmG1fpUxlN2I0DgECLesR9Eo3rs+D8yYZayDdUXHajmlhf7JK8xTc85l5M74ebIns7GxCQl/WTGqdrGaCdiwYnSNf37tAGROIn+w72ffPe7bD7NkABreP81cKGnAatK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666345363; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vW1Lxg6CwvbDnPeTBg9Qp/nP+UFsiQKcS3I0rXp2/DI=; b=WuLb6WHdY5CpCqyPfSLOvpbsp2d+29rMZa4Cc2k9GeGgDSCxkaDLevGENHVNBCPHRt4jC1q9xle9Q+PDgIT0MS6owak38cvKvoOsI8QREhdm5YUR3mj8EcnT3YuqD/Wo+E4fs1mFdfgyiD6/FTCmMrQeOwgKvo8AYX5hjl5T3vU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666345363893436.88298968238655; Fri, 21 Oct 2022 02:42:43 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oloY6-0005jz-4S for importer@patchew.org; Fri, 21 Oct 2022 05:42:42 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmID-0003bn-7R for importer@patchew.org; Fri, 21 Oct 2022 03:18:09 -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) 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) 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-Google-Smtp-Source: AMsMyM67mfLxZXTln6htvhcTy3lmaguG5I+6JjxgdNyDSdEcDKXt882aCOPmkcRt1ir1+U0IsMhbxA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666345365354100001 Content-Type: text/plain; charset="utf-8" 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, TCG= Reg ret, TCGReg arg1, static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg ar= g); 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_lon= g) + __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); } =20 +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 =20 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); } =20 +static void tcg_out_addi_ptr(TCGContext *s, TCGReg rd, TCGReg rs, + tcg_target_long imm) +{ + int enc, opc =3D ARITH_ADD; + + /* All of the easiest immediates to encode are positive. */ + if (imm < 0) { + imm =3D -imm; + opc =3D ARITH_SUB; + } + enc =3D encode_imm(imm); + if (enc >=3D 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 r= h) { 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, } } =20 +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 =3D=3D 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 =3D=3D (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, } } =20 +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, } } =20 +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 fla= gs) { /* 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, } } =20 +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); } =20 +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, TCGTyp= e type, TCGArg val, return false; } =20 +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); } =20 +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, } } =20 +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) { --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666342713; cv=none; d=zohomail.com; s=zohoarc; b=iHr48r4Yxn1bfVcEtf1JfNbGgYnM2eqeozab3wDOdm0MBHSAM+TpFhYY4uswwU+Qz/Pv4av0rkZQMkaN6gL0K2ZtXcm+gaxa1gNFLmNAYarJsGwr28IrLhhp7DknDaQUKmV+IFZY3LMnskpflv5ymK3e9hxvS50bhIjuwMyGry0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666342713; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bYHLJSZ/Z67z205wwObfO5u8lWYWwszfdw4ZjqYh6JI=; b=RVrtp1REDkS8f3RIQ4KgExrFUgvg2HB4f8rxVszR5pjTC+IUgb8qTocXWZVSP42jYBlQA8RO8GdFvOj/Sxe70rNPMNa2p68wYolDeFHrDkXlEgn1x0VObSzqXpxglLHqKhyHu6iAZjXePMtAHLeHTUT3rjH48HBp7tM4LotDgWw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666342713515752.8689355361819; Fri, 21 Oct 2022 01:58:33 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnrM-0000Tw-2w for importer@patchew.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 1olmIL-0003jL-4W for importer@patchew.org; Fri, 21 Oct 2022 03:18:17 -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) 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) 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-Google-Smtp-Source: AMsMyM5WOpqZKpUJp/YRIFQqUL8UWKrjKqjRhOW8P0blvgRoydwF486cX0USKznv49FhhiIGsvsmTQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666342715948100001 Content-Type: text/plain; charset="utf-8" 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; =20 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; =20 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, TCG= Reg ret, TCGReg arg1, static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg ar= g); 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_lon= g) - __attribute__((unused)); +static void tcg_out_addi_ptr(TCGContext *s, TCGReg, TCGReg, tcg_target_lon= g); 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++; } =20 +static void layout_arg_by_ref(TCGCumulativeArgs *cum, TCGHelperInfo *info) +{ + TCGCallArgumentLoc *loc =3D &info->in[cum->info_in_idx]; + int n =3D 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 -=3D n; + loc[0].ref_slot =3D cum->max_stk_slot; + + /* Any other subindex is present for liveness. */ + if (TCG_TARGET_REG_BITS =3D=3D 64) { + loc[1] =3D (TCGCallArgumentLoc){ + .kind =3D TCG_CALL_ARG_BY_REF_2, + .arg_idx =3D cum->arg_idx, + .tmp_subindex =3D 1, + }; + cum->info_in_idx++; + cum->op_arg_idx++; + } +} + static void init_call_layout(TCGHelperInfo *info) { unsigned typemask =3D info->typemask; @@ -728,6 +755,18 @@ static void init_call_layout(TCGHelperInfo *info) assert(ARRAY_SIZE(tcg_target_call_oarg_regs) >=3D 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 =3D=3D 0) { + cum.stk_slot =3D 1; + } else { + cum.reg_slot =3D 1; + } + break; default: g_assert_not_reached(); } @@ -765,6 +804,10 @@ static void init_call_layout(TCGHelperInfo *info) type =3D TCG_TYPE_PTR; kind =3D TCG_CALL_ARG_NORMAL; break; + case dh_typecode_i128: + type =3D TCG_TYPE_I128; + kind =3D TCG_CALL_ARG_NORMAL; /* TODO */ + break; default: g_assert_not_reached(); } @@ -809,6 +852,10 @@ static void init_call_layout(TCGHelperInfo *info) assert(type =3D=3D TCG_TYPE_I32); layout_arg_1(&cum, info, kind); break; + case TCG_CALL_ARG_BY_REF: + assert(type =3D=3D 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 narg= s, 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++] =3D temp_arg(ts); break; =20 @@ -4466,6 +4515,27 @@ static void load_arg_normal_4(TCGContext *s, const T= CGCallArgumentLoc *loc, } } =20 +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 =3D 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 =3D TCG_TARGET_CALL_STACK_OFFSET + + loc->stk_slot * sizeof(tcg_target_long); + + reg =3D 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 =3D TCGOP_CALLO(op); @@ -4475,6 +4545,19 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp = *op) TCGRegSet allocated_regs =3D s->reserved_regs; int i; =20 + /* + * 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 =3D 0; i < nb_iargs; ++i) { + const TCGCallArgumentLoc *loc =3D &info->in[i]; + if (loc->kind =3D=3D TCG_CALL_ARG_BY_REF) { + TCGTemp *ts =3D 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); } =20 + /* + * 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 =3D=3D TCG_CALL_RET_BY_REF) { + static const TCGCallArgumentLoc ret_loc =3D { + .reg_n =3D ARRAY_SIZE(tcg_target_call_iarg_regs) !=3D 0 + }; + TCGTemp *ts =3D arg_temp(op->args[0]); + + tcg_debug_assert(ts->base_type =3D=3D TCG_TYPE_I128); + tcg_debug_assert(ts->temp_subindex =3D=3D 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); =20 /* Assign output registers and emit moves if needed. */ @@ -4563,6 +4675,14 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp = *op) } break; =20 + case TCG_CALL_RET_BY_REF: + /* The callee has performed a write through the reference. */ + for (i =3D 0; i < nb_oargs; i++) { + TCGTemp *ts =3D arg_temp(op->args[i]); + ts->val_type =3D TEMP_VAL_MEM; + } + break; + default: g_assert_not_reached(); } --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666338760; cv=none; d=zohomail.com; s=zohoarc; b=OIlQQx+AARTRuNFlQeX6YyEbHs6+OLHINGohE7AP5czFOEPBZpM2LE7kP3f09uwqNOl6bSIe3uK7eoIFjdn22AsBQRWCsiI2GJAoEKq1sBWao9Rex7ZrtnxtNaxSa1hnEvJADwoRohZ55XxTzhSx+qCySi7xU/D9DMHaxTBaUgc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666338760; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6QnxmV1dby1iR3mkwH2QL8QXFFRTM/J6GCNHdOO2/bk=; b=RSJPU+hD7bDMSq7nvEbkjMLC/MCow9kWDVLBiaZIkUl9hOgCnT2M9+ZSoyPHvcANVzX/OSqyi31l0Fn3AShquh2ftv4tOkeBlJOAiqyiCoFcu83QnFigg8KRJAiwh5XnmLacgopUAv3AZaxvT4MmgGJWF1RFALH97Xr2lJVFp0s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666338760760214.16831175407674; Fri, 21 Oct 2022 00:52:40 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmpa-0004fC-MA for importer@patchew.org; Fri, 21 Oct 2022 03:52:38 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmIC-0003aG-L7 for importer@patchew.org; Fri, 21 Oct 2022 03:18: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 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) 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) 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-Google-Smtp-Source: AMsMyM71IeOWqLT17IJPq/CuuamUe+hJVwLIO1GubCij0iAfw0B554riJcrrFD2XlQziIRmf/1ey2g== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666338761442100001 Content-Type: text/plain; charset="utf-8" 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, TC= GArg 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 =3D=3D 32) { - assert(ARRAY_SIZE(tcg_target_call_oarg_regs) >=3D 4); info->out_kind =3D TCG_CALL_RET_NORMAL_4; - } else { - assert(ARRAY_SIZE(tcg_target_call_oarg_regs) >=3D 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 =3D TS_DEAD; la_reset_pref(ts); =20 - /* 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] =3D 0; } =20 @@ -4642,7 +4643,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *= op) case TCG_CALL_RET_NORMAL: for (i =3D 0; i < nb_oargs; i++) { TCGTemp *ts =3D arg_temp(op->args[i]); - TCGReg reg =3D tcg_target_call_oarg_regs[i]; + TCGReg reg =3D tcg_target_call_oarg_reg(TCG_CALL_RET_NORMAL, i= ); =20 /* 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 =3D 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 =3D 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] =3D { 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] =3D { - TCG_REG_X0 -}; + +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(kind =3D=3D TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot >=3D 0 && slot <=3D 1); + return TCG_REG_X0 + slot; +} =20 #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[] =3D { static const int tcg_target_call_iarg_regs[4] =3D { TCG_REG_R0, TCG_REG_R1, TCG_REG_R2, TCG_REG_R3 }; -static const int tcg_target_call_oarg_regs[2] =3D { - TCG_REG_R0, TCG_REG_R1 -}; + +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(slot >=3D 0 && slot <=3D 3); + return TCG_REG_R0 + slot; +} =20 #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[] =3D { #endif }; =20 -static const int tcg_target_call_oarg_regs[] =3D { - TCG_REG_EAX, -#if TCG_TARGET_REG_BITS =3D=3D 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(); +} =20 /* 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[] =3D { TCG_REG_A7, }; =20 -static const int tcg_target_call_oarg_regs[] =3D { - TCG_REG_A0, - TCG_REG_A1, -}; +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(kind =3D=3D TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot >=3D 0 && slot <=3D 1); + return TCG_REG_A0 + slot; +} =20 #ifndef CONFIG_SOFTMMU #define USE_GUEST_BASE (guest_base !=3D 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[] =3D { #endif }; =20 -static const TCGReg tcg_target_call_oarg_regs[2] =3D { - TCG_REG_V0, - TCG_REG_V1 -}; +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(kind =3D=3D TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot >=3D 0 && slot <=3D 1); + return TCG_REG_V0 + slot; +} =20 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[] =3D { TCG_REG_R10 }; =20 -static const int tcg_target_call_oarg_regs[] =3D { - TCG_REG_R3, - TCG_REG_R4 -}; +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(kind =3D=3D TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot >=3D 0 && slot <=3D 1); + return TCG_REG_R3 + slot; +} =20 static const int tcg_target_callee_save_regs[] =3D { #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[] =3D { TCG_REG_A7, }; =20 -static const int tcg_target_call_oarg_regs[] =3D { - TCG_REG_A0, - TCG_REG_A1, -}; +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(kind =3D=3D TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot >=3D 0 && slot <=3D 1); + return TCG_REG_A0 + slot; +} =20 #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[] =3D { TCG_REG_R6, }; =20 -static const int tcg_target_call_oarg_regs[] =3D { - TCG_REG_R2, -}; +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(kind =3D=3D TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot =3D=3D 0); + return TCG_REG_R2; +} =20 #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] =3D { TCG_REG_O5, }; =20 -static const int tcg_target_call_oarg_regs[] =3D { - 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 =3D=3D TCG_CALL_RET_NORMAL); + tcg_debug_assert(slot >=3D 0 && slot <=3D 3); + return TCG_REG_O0 + slot; +} =20 #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[] =3D { /* No call arguments via registers. All will be stored on the "stack". */ static const int tcg_target_call_iarg_regs[] =3D { }; =20 -static const int tcg_target_call_oarg_regs[] =3D { - TCG_REG_R0, -#if TCG_TARGET_REG_BITS =3D=3D 32 - TCG_REG_R1 -#endif -}; +static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) +{ + tcg_debug_assert(slot >=3D 0 && slot <=3D 3); + return TCG_REG_R0 + slot; +} =20 #ifdef CONFIG_DEBUG_TCG static const char *const tcg_target_reg_names[TCG_TARGET_NB_REGS] =3D { --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666340366; cv=none; d=zohomail.com; s=zohoarc; b=AeBFgdgvJuxGDH+C+t0afBHHMO0StY+lBcS3h6+v+42XbZbqnk77mzAiWC29lTpaPSItiOQv1f5ZsQ2K624MBAs9ElVU1eyIWi2ahT4gLf6i5uhFfvYeMnnD3G3/vrcjlReklI88cfSs3O629p06gR+uahC6HjZ85hUEEttrP9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666340366; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=75+xsYOAtaVg4plBJLa7rmgReN2/m1syY7D3SMY10mk=; b=jA9f2inruuNvrdlpA9Q/FshPWcaFKpGcZAeIc9al1yi14NqdZQ3Y9ZiKbHMEQuWVbW5PXKf2jJ5QS2S9S/O2TNT8ztS0DqoKArZQ0cAprkCU6gTp2H1OM2be6lE9fDh6V+aTNYXR28ncC4Mxqusi4oHXVdjhzaWT6mWbeOzMd3I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666340366160609.2699714755701; Fri, 21 Oct 2022 01:19:26 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnFT-0007YC-Qa for importer@patchew.org; Fri, 21 Oct 2022 04:19:24 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmI9-0003Td-0H for importer@patchew.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 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) 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) 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-Google-Smtp-Source: AMsMyM5bzNT96xpxlRFAGKPk5+690XR0OOpgbVX/JbZ9ajcjfqHmgObO4I6htf6Xc9nrqPQx6/a3gA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666340368297100001 Content-Type: text/plain; charset="utf-8" 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; =20 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 =3D 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; =20 + case TCG_CALL_RET_BY_VEC: + { + TCGTemp *ts =3D arg_temp(op->args[0]); + + tcg_debug_assert(ts->type =3D=3D 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 =3D TEMP_VAL_MEM; + } + break; + default: g_assert_not_reached(); } --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666340168; cv=none; d=zohomail.com; s=zohoarc; b=NLYTDymf47MEt/erShFudk3N9E0DIpqCW+6wRJtywL+g7q2mz1N24QLGpcPFnTbuT+kJOyoymBNNnywHmXLjZAk10UUpxA8J51feFpxyX3TQY9G2/33OIStE0KCtk7euiEObw/0pJxYa8tuGLhp4iIqjg+YmaWGJW/U7wSspvPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666340168; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=otax3boOrkJbpvJnQWAvehNepZr14GD0jCowiyMr4Ww=; b=ksIoDI6ILVjVK80zlKmq8jpkBYgQAmVqy6AaLOZOBrZbljIZUdzMiBrWcEPJ3wP33SLIfAYXp4NUe+N7SwQV5/yobmV5KvVU21rzEURF8dGllk/jNj1cz0zZfiCcYgvZsCCqPryxkjSrc+EBLUpORVxhtry4Dr1c/jtBICSv2fI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666340168469794.1029619139588; Fri, 21 Oct 2022 01:16:08 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnCJ-000241-8t for importer@patchew.org; Fri, 21 Oct 2022 04:16:07 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmI9-0003Tw-AM for importer@patchew.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 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) 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) 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-Google-Smtp-Source: AMsMyM5zyYHG7gzzDm55KjVWmuxszL+cprADfH82lnVApHPo3rNa0dVaTufcvrZ+JBIHFXTufamqmg== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666340170287100001 Content-Type: text/plain; charset="utf-8" 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 =3D cmp; + n.s =3D new; + r.i =3D 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 =3D cmp; + n.s =3D new; + r.i =3D __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 =3D qatomic_read__nocheck((__int128_t *)ptr); + return r.s; } =20 static inline void atomic16_set(Int128 *ptr, Int128 val) { - qatomic_set__nocheck(ptr, val); + Int128Alias v; + + v.s =3D val; + qatomic_set__nocheck((__int128_t *)ptr, v.i); } =20 # define HAVE_ATOMIC128 1 @@ -153,7 +169,8 @@ static inline Int128 atomic16_read(Int128 *ptr) if (have_atomic128) { asm("vmovdqa %1, %0" : "=3Dx" (ret) : "m" (*ptr)); } else { - ret =3D atomic16_cmpxchg(ptr, 0, 0); + Int128 z =3D int128_make64(0); + ret =3D atomic16_cmpxchg(ptr, z, z); } return ret; } @@ -167,7 +184,7 @@ static inline void atomic16_set(Int128 *ptr, Int128 val) do { cmp =3D old; old =3D atomic16_cmpxchg(ptr, cmp, val); - } while (old !=3D cmp); + } while (int128_ne(old, cmp)); } } =20 @@ -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 =3D int128_make64(0); + return atomic16_cmpxchg(ptr, z, z); } =20 static inline void atomic16_set(Int128 *ptr, Int128 val) @@ -185,7 +203,7 @@ static inline void atomic16_set(Int128 *ptr, Int128 val) do { cmp =3D old; old =3D atomic16_cmpxchg(ptr, cmp, val); - } while (old !=3D cmp); + } while (int128_ne(old, cmp)); } =20 # 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 @@ =20 #include "qemu/bswap.h" =20 -#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; =20 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 */ =20 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) =20 +#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; } =20 +#elif defined(CONFIG_TCG_INTERPRETER) + +Int128 int128_divu(Int128 a_s, Int128 b_s) +{ + Int128Alias r, a, b; + + a.s =3D a_s; + b.s =3D b_s; + r.u =3D a.u / b.u; + return r.s; +} + +Int128 int128_remu(Int128 a_s, Int128 b_s) +{ + Int128Alias r, a, b; + + a.s =3D a_s; + b.s =3D b_s; + r.u =3D a.u % b.u; + return r.s; +} + +Int128 int128_divs(Int128 a_s, Int128 b_s) +{ + Int128Alias r, a, b; + + a.s =3D a_s; + b.s =3D b_s; + r.i =3D a.i / b.i; + return r.s; +} + +Int128 int128_rems(Int128 a_s, Int128 b_s) +{ + Int128Alias r, a, b; + + a.s =3D a_s; + b.s =3D b_s; + r.i =3D a.i % b.i; + return r.s; +} + #endif --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666339934; cv=none; d=zohomail.com; s=zohoarc; b=hRnGb0SK2Nm91BRKi0UhjLYP6M2kTWFk602RhE3QYe8c6SsKatb/SCh2bAWZqNtmY1vschowHg+jWgBOk5OVcUw132M5D81OQd/IE5j12H/5E7h16Y8Qsy+7FC/QWJfupeMY05WFPW2nY1CCKPq5ax6tOUo9K/Nd83qKfOALmho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666339934; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lLnD6XwJTmW9yrKiJSoQgxFQEO0sDHADUyXUWB1TLM0=; b=ZFo/oWP+X+PfDFEle4rHesKwRsu1fBlJ14mK8fB68JDWW38h8zk3115ZbmGudLml8cPxGQp7pw6QI0HWhaomx7hqBYEXzHD30LfzMQH6iAjSseUWPEPzLsj/oIk32vJBlEIwrW95mZxyGov3FVxqNRySCrxLqQnnSVRoXjDixw4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666339934356537.159762941002; Fri, 21 Oct 2022 01:12:14 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oln8R-0005WP-2s for importer@patchew.org; Fri, 21 Oct 2022 04:12:12 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmIG-0003dv-Bc for importer@patchew.org; Fri, 21 Oct 2022 03:18:12 -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) 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) 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-Google-Smtp-Source: AMsMyM67FSLQqMlHRE450SrbPeluq9rHmNeBXaezUpsw/EamBSuApdr9dDUaaV0MHiyngpUYsDGleQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666339936407100001 Content-Type: text/plain; charset="utf-8" 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 =3D=3D 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 =20 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(TCGCallReturnKi= nd kind, int slot) return TCG_REG_EDX; } break; +#ifdef _WIN64 + case TCG_CALL_RET_BY_VEC: + if (slot =3D=3D 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 >=3D 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, arg= 2); + } 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_in= sn_unit *dest, const TCGHelperInfo *info) { tcg_out_branch(s, 1, dest); + +#ifndef _WIN32 + if (TCG_TARGET_REG_BITS =3D=3D 32 && info->out_kind =3D=3D TCG_CALL_RE= T_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 } =20 static void tcg_out_jmp(TCGContext *s, const tcg_insn_unit *dest) --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666347257; cv=none; d=zohomail.com; s=zohoarc; b=UNCcG6rkQ7HmTIKEBGmM0kAzKsdsG1Esebjsx9dq5JcbQimyjDpblPpfvHSRO1uosFRxi69Maj74Uha9dTYCVo8Q5XsgZWTj3DbbGvL3SqtzdrPSU3u4KPQVV1XNMWlmWWtaSOBVBrgUw0QJdXECAGVnRWYRS7e+PLvtjonZYZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666347257; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PPW7RSSNm9yil/F5lJhRwPcfplDAlAe1JqivFknlUJ0=; b=Tr4y5aiKmIWYvnjQlZ8d3nzpTfi1w8E08qa2fsSyHdtpgIRtOWoXThAZc9on07CzTWEB5baqk0rGFFwUWQX2uxlJfiUM0HCjdO7CQbyKkCA+ak10COofjsJg8q1QYf+D3K2QDIP3psbQWFxNENIw2EgoJiHVw3ITCp2QWKR85yA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666347257491298.39522373247235; Fri, 21 Oct 2022 03:14:17 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olp2S-0000tr-IA for importer@patchew.org; Fri, 21 Oct 2022 06:14:14 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmIH-0003g3-Fn for importer@patchew.org; Fri, 21 Oct 2022 03:18:13 -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) 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) 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-Google-Smtp-Source: AMsMyM5ZoQq2aSEsCTy3gmTI3iC9W90MgOWYoVCLTJ1f0oFdRonvTfeX7G/hUjLHLFWBLOj1LSPIng== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666347258769100001 Content-Type: text/plain; charset="utf-8" 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(CPUArchSt= ate *env, ffi_call(pptr[1], pptr[0], stack, call_slots); } =20 - /* 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) =3D=3D 4) { - regs[TCG_REG_R0] =3D *(uint32_t *)stack; - break; - } - /* fall through */ - case 2: /* uint64_t */ - if (TCG_TARGET_REG_BITS =3D=3D 32) { - tci_write_reg64(regs, TCG_REG_R1, TCG_REG_R0, stack[0]= ); + if (sizeof(ffi_arg) =3D=3D 8) { + regs[TCG_REG_R0] =3D (uint32_t)stack[0]; } else { - regs[TCG_REG_R0] =3D stack[0]; + regs[TCG_REG_R0] =3D *(uint32_t *)stack; } break; + case 2: /* uint64_t */ + /* + * For TCG_TARGET_REG_BITS =3D=3D 32, the register pair + * must stay in host memory order. + */ + memcpy(®s[TCG_REG_R0], stack, 8); + break; default: g_assert_not_reached(); } --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666346907; cv=none; d=zohomail.com; s=zohoarc; b=a83OnSLTVxoA9wVUsMLSPipu2CJff0nIHhZTAUkzJ84O7HFgYQWnjYqi1GqPJ3a5HZBCPLUTjdB1emQHMMQh1u9vZ+Q/HqvUY/cD+wBEGhcFY+RKk0ZeNnpnXgvMcZ757aylsUE2cKTudgRVw3bDPFbo2uesiGf8yQ6OMREqhvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666346907; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QVoRiK3j5+lRW7rSsEPFl7/tCZVXuMds/nbUBLlYc34=; b=K4tbvjgDgQqmcKsrym3IiGZLrAVX8OA2fSCWpiNO3a2dRm6wbnnmcsHH+mhLCiF3ORBgTXoZ6MKrf7UcNlBoY2kOop5uVaCpait8XW002ZI3LBUrEbS4q0IdrDt7nyGcxHwpwFMYbb7iiULfdw0L97SvcjsZJzUuqvFIXOUWs7s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666346907180728.8545471744857; Fri, 21 Oct 2022 03:08:27 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olowy-0004ac-NX for importer@patchew.org; Fri, 21 Oct 2022 06:08:24 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmIH-0003f5-56 for importer@patchew.org; Fri, 21 Oct 2022 03:18:13 -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) 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) 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-Google-Smtp-Source: AMsMyM6QzMF/sBY7SaoiNhVnOtM+rmAF/D39GN84rULe5b/Dhgeoyy7lEa4/y1+rS05EhZn7F3g3bA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666346908295100001 Content-Type: text/plain; charset="utf-8" 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=C3=A9 --- 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 =3D=3D 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 =20 #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] =3D { + &ffi_type_uint64, + &ffi_type_uint64, + NULL + }; + static ffi_type ffi_type_i128 =3D { + .size =3D 16, + .alignment =3D __alignof__(Int128), + .type =3D FFI_TYPE_STRUCT, + .elements =3D 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(CPUArchSta= te *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)]; =20 regs[TCG_AREG0] =3D (tcg_target_ulong)env; regs[TCG_REG_CALL_STACK] =3D (uintptr_t)stack; - /* Other call_slots entries initialized at first use (see below). */ - call_slots[0] =3D NULL; tci_assert(tb_ptr); =20 for (;;) { @@ -499,26 +496,27 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchSt= ate *env, =20 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] =3D=3D NULL)) { - for (int i =3D 0; i < ARRAY_SIZE(call_slots); ++i) { - call_slots[i] =3D &stack[i]; - } - } - - tci_args_nl(insn, tb_ptr, &len, &ptr); - - /* Helper functions may need to access the "return address" */ - tci_tb_ptr =3D (uintptr_t)tb_ptr; - { - void **pptr =3D 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 =3D ((void **)ptr)[0]; + cif =3D ((void **)ptr)[1]; + + n =3D cif->nargs; + tci_assert(n <=3D MAX_OPC_PARAM_IARGS); + for (i =3D s =3D 0; i < n; ++i) { + ffi_type *t =3D cif->arg_types[i]; + call_slots[i] =3D &stack[s]; + s +=3D DIV_ROUND_UP(t->size, 8); + } + + /* Helper functions may need to access the "return address= " */ + tci_tb_ptr =3D (uintptr_t)tb_ptr; + ffi_call(cif, func, stack, call_slots); } =20 switch (len) { @@ -543,6 +541,9 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchStat= e *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_ins= n_unit *func, =20 if (cif->rtype =3D=3D &ffi_type_void) { which =3D 0; - } else if (cif->rtype->size =3D=3D 4) { - which =3D 1; } else { - tcg_debug_assert(cif->rtype->size =3D=3D 8); - which =3D 2; + tcg_debug_assert(cif->rtype->size =3D=3D 4 || + cif->rtype->size =3D=3D 8 || + cif->rtype->size =3D=3D 16); + which =3D ctz32(cif->rtype->size) - 1; } new_pool_l2(s, 20, s->code_ptr, 0, (uintptr_t)func, (uintptr_t)cif); insn =3D deposit32(insn, 0, 8, INDEX_op_call); --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666344609; cv=none; d=zohomail.com; s=zohoarc; b=eWjuxbBtRouSDFcyd7FswsBTbVKzaGeoYMf0j5vrlg+8+8ZE29lVOhA5AWF5FnpztGSifTDYbbdAvpM91jvZxAGonPXBGEC+3WHff6yfbzK4sQVYgG6mtDkwrL84k9bu8Mf2tvUpYRbtmjBJ5pjv8osgzWtXf1ZLFOA9KLYo1Iw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666344609; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6MECj/5wfaqJXkyCl06/YPafA19dUtMTe/s1ymy0xIM=; b=VZjKJSRvIp5jJ0NACDFSjcRzRb3h7hNhI+MOPJDblWgPcXs1PRmf1OnaNxSljBPcP/lqtOKfbUiz7rgIcK/Rf9JbQvv+2Fzet0GwDrRF6wECI0106KcbjCSEU3vGC/6KQCXcNfXE2VjAIhHoZMdLJJn92tYvUVOlc5A5I2qo5wg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666344609797610.5960840703555; Fri, 21 Oct 2022 02:30:09 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oloLv-0006DL-Qp for importer@patchew.org; Fri, 21 Oct 2022 05:30:08 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmIB-0003YN-Qe for importer@patchew.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 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) 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) 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-Google-Smtp-Source: AMsMyM5c5fdM1c5/yS7iOKJ7b+f4A2Vpg4IwzJx+zi7gSP0c8CJirnFLOwgu+3NSgC7FWOROxnR+VA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666344610971100001 Content-Type: text/plain; charset="utf-8" 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 =20 /* 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 =20 /* 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 =20 /* 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 =20 /* MOVN/MOVZ instructions detection */ #if (defined(__mips_isa_rev) && (__mips_isa_rev >=3D 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 =3D=3D 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 =20 /* 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 =20 #define TCG_TARGET_HAS_MEMORY_BSWAP 1 =20 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 =20 #if defined(__VIS__) && __VIS__ >=3D 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 =3D TCG_TARGET_REG_BITS =3D=3D 32 ? 1 : 2; - info->out_kind =3D TCG_CALL_RET_NORMAL; /* TODO */ - switch (/* TODO */ TCG_CALL_RET_NORMAL) { + info->out_kind =3D TCG_TARGET_CALL_RET_I128; + switch (TCG_TARGET_CALL_RET_I128) { case TCG_CALL_RET_NORMAL: if (TCG_TARGET_REG_BITS =3D=3D 32) { info->out_kind =3D TCG_CALL_RET_NORMAL_4; @@ -827,7 +828,7 @@ static void init_call_layout(TCGHelperInfo *info) break; case dh_typecode_i128: type =3D TCG_TYPE_I128; - kind =3D TCG_CALL_ARG_NORMAL; /* TODO */ + kind =3D 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 =20 /* For some memory operations, we need a scratch that isn't R0. For the A= IX calling convention, we can re-use the TOC register since we'll be reloa= ding --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666340276; cv=none; d=zohomail.com; s=zohoarc; b=mQ32EVCzrQa6+avFhyj8dBd9J/l3QP+4yQCXcn+CIHZXN5siic29fktkN6EtC9eq13YQk7iMmbFcA3ZWddQ1ayh3zFxV1TFDjWR2VevNY+LcUxJ/UCZlz8hZMSze45zqq+iAd1s+RjXvju5tqJnjJU6ug7LT4n5dPuwe90zNuXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666340276; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PgG5Fqrssx+hkjV71ieV43u3E3Admzr0DyJnKERg/wk=; b=SRvbudEeF440Yx9riBZj5lXwSnrXyoZUoMTNw/ySbZqE49dJOhpTCQPI8mjOtl5bL/9dtjL0ByOAKnAYIIVsFaCSFaOweYprsb4uuM2WHDHeCOWBnUd1RWJirCdsGcSdaNQqi57aotMzIB52GmxEtvnDlDAQdbf79tZ/fmEGE14= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666340276804693.9854812068884; Fri, 21 Oct 2022 01:17:56 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnE2-0004sh-E7 for importer@patchew.org; Fri, 21 Oct 2022 04:17:54 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmIG-0003fT-Tq for importer@patchew.org; Fri, 21 Oct 2022 03:18:12 -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) 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) 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-Google-Smtp-Source: AMsMyM4tAS36muBNk+er0pd2SQzmFntHouV1gGH1AYJC7Vim9T51qZ5SfeYgPuN1fsbJupB97KuPpw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666340277803100001 Content-Type: text/plain; charset="utf-8" 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); } =20 +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)); } =20 +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); } =20 +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)); } =20 +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); } =20 +static inline TCGv_i128 tcg_temp_new_i128(void) +{ + TCGTemp *t =3D 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 =3D 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 offse= t, 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 t= emp_local) tcg_debug_assert(ts->base_type =3D=3D type); tcg_debug_assert(ts->kind =3D=3D kind); } else { + bool want_pair =3D false; + TCGType half =3D 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 =3D TCG_TYPE_I32; + want_pair =3D TCG_TARGET_REG_BITS =3D=3D 32; + break; + case TCG_TYPE_I128: + half =3D TCG_TYPE_I64; + want_pair =3D TCG_TARGET_REG_BITS =3D=3D 64; + break; + default: + g_assert_not_reached(); + } + ts =3D tcg_temp_alloc(s); - if (TCG_TARGET_REG_BITS =3D=3D 32 && type =3D=3D TCG_TYPE_I64) { + if (want_pair) { TCGTemp *ts2 =3D tcg_temp_alloc(s); =20 ts->base_type =3D type; - ts->type =3D TCG_TYPE_I32; + ts->type =3D half; ts->temp_allocated =3D 1; ts->kind =3D kind; =20 tcg_debug_assert(ts2 =3D=3D ts + 1); - ts2->base_type =3D TCG_TYPE_I64; - ts2->type =3D TCG_TYPE_I32; + ts2->base_type =3D type; + ts2->type =3D half; ts2->temp_allocated =3D 1; ts2->temp_subindex =3D 1; ts2->kind =3D kind; @@ -2773,7 +2794,7 @@ static void la_cross_call(TCGContext *s, int nt) =20 for (i =3D 0; i < nt; i++) { TCGTemp *ts =3D &s->temps[i]; - if (!(ts->state & TS_DEAD)) { + if (ts->type !=3D TCG_TYPE_I128 && !(ts->state & TS_DEAD)) { TCGRegSet *pset =3D la_temp_pref(ts); TCGRegSet set =3D *pset; =20 @@ -3404,6 +3425,7 @@ static void temp_allocate_frame(TCGContext *s, TCGTem= p *ts) case TCG_TYPE_V64: align =3D 8; break; + case TCG_TYPE_I128: case TCG_TYPE_V128: case TCG_TYPE_V256: /* Note that we do not require aligned storage for V256. */ --=20 2.34.1 From nobody Sat May 4 16:28:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666342782; cv=none; d=zohomail.com; s=zohoarc; b=WshTdeIA9FfaW/V8fLU06qNHYL9e4vo76GsyUkiaGHDgdntg9ofyrT4EKtcSAYpsaA0vithM6gYq0fb+9L8RK+hcIhXNDM68bPc3biaAEd1xdWHYShVf1hhaldrXVuXSxkQqPEPpQTkOhw2OGZjPhDI7vz4v9tTGmnVnbCvLXCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666342782; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wp/4CM/qsbuV4ZCuidIv3Ny+CUT3ruhHsC9wYblkvAU=; b=MmFPfVhFu8CtjN8d1IX6NASnXYonw7ig0UMnCZTCgkRbpx+s5af6gwa4qFL8O25YWeO4cKRMUW3oyLoMyZtU6ciUamFu/f4uvZ1tGacuRisaD0wQs4rwde5Gp/3b2fsNGo9ocO9w3WCtEdm4oKiRwjOszE6imXW8JtdFdScCRqc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666342782116892.5831418125803; Fri, 21 Oct 2022 01:59:42 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olnsR-00057q-2N for importer@patchew.org; Fri, 21 Oct 2022 04:59:40 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olmIL-0003kM-HI for importer@patchew.org; Fri, 21 Oct 2022 03:18:17 -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) 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) 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-Google-Smtp-Source: AMsMyM5WX5J+n9GtVLJA2zESQ4901VER/fvAdQbyG3q1KxIZzrWZnbfkZBxlQDtKykhZDW650kW42Q== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666342783970100001 Content-Type: text/plain; charset="utf-8" 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); =20 +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_i6= 4 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 =3D=3D 32 ? TCG_OPF_NOT_PRESENT : 0)) =20 +/* 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 reachab= le"); extern TCGv_i32 TCGV_HIGH(TCGv_i64) QEMU_ERROR("32-bit code path is reacha= ble"); +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 =20 #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, TC= Gv_i64 arg) tcg_gen_shri_i64(hi, arg, 32); } =20 +void tcg_gen_extr_i128_i64(TCGv_i64 lo, TCGv_i64 hi, TCGv_i128 arg) +{ + if (TCG_TARGET_REG_BITS =3D=3D 32) { + TCGArg a_arg =3D tcgv_i128_arg(arg); + int be =3D 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 =3D=3D 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. */ =20 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 T= CGOp *op) } } =20 +/* + * 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 =3D op->life; + TCGTemp *ots =3D arg_temp(op->args[0]); + TCGTemp *its =3D arg_temp(op->args[1]); + TCGArg ofs =3D op->args[2]; + TCGReg reg; + + assert(TCG_TARGET_REG_BITS =3D=3D 32); + tcg_debug_assert(ots->type =3D=3D TCG_TYPE_I32); + tcg_debug_assert(!temp_readonly(ots)); + tcg_debug_assert(its->type =3D=3D TCG_TYPE_I128); + tcg_debug_assert(its->val_type =3D=3D TEMP_VAL_MEM); + tcg_debug_assert(ofs < 16); + tcg_debug_assert((ofs & 3) =3D=3D 0); + + if (ots->val_type =3D=3D TEMP_VAL_REG) { + reg =3D ots->reg; + } else { + reg =3D tcg_reg_alloc(s, tcg_target_available_regs[TCG_TYPE_I32], + s->reserved_regs, op->output_pref[0], + ots->indirect_base); + ots->val_type =3D TEMP_VAL_REG; + ots->reg =3D reg; + s->reg_to_temp[reg] =3D ots; + } + + tcg_out_ld(s, TCG_TYPE_I32, reg, + its->mem_base->reg, its->mem_offset + ofs); + ots->mem_coherent =3D 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 =3D op->life; + TCGTemp *ots =3D arg_temp(op->args[0]); + int be =3D HOST_BIG_ENDIAN ? 0xc : 0; + + assert(TCG_TARGET_REG_BITS =3D=3D 32); + tcg_debug_assert(ots->type =3D=3D 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 =3D 0; i < 4; ++i) { + TCGTemp *its =3D arg_temp(op->args[i + 1]); + int ofs =3D ots->mem_offset + ((i * 4) ^ be); + + if (its->val_type =3D=3D 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 =3D TEMP_VAL_MEM; + ots->mem_coherent =3D 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; --=20 2.34.1