From patchwork Thu Jan 26 04:37:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 647041 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp57944pvb; Wed, 25 Jan 2023 20:39:19 -0800 (PST) X-Google-Smtp-Source: AK7set+gjG4FFcldKvKyVsestQz2xeaufqRUjzd/hGhHsSRXRTKK0GT3h1tk/um75E2r/M2hWJbL X-Received: by 2002:ac8:5ad0:0:b0:3b6:8ad1:3be9 with SMTP id d16-20020ac85ad0000000b003b68ad13be9mr9239124qtd.32.1674707959292; Wed, 25 Jan 2023 20:39:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674707959; cv=none; d=google.com; s=arc-20160816; b=r8FB4OlHd0f3kZQjKXgaHAQvMp1zv2kpMUb/6ZxAWmYZp6oNoQ96KIUtZdJUkXWjlb mKRGx8a4VdskD/9tVL93IzHqIzMiB9BlwAwSgZ5dumy+5TNto1m8kaZNf+TUl+QLh4jX J0Awhlgeh8BOs3mNHaIs9EdyBlPnF5QafHxvWyg7S5RyMrRJd+V6WFt3y/iyjp7b0qYt V0ZFrHZuyObBR2rYsH99sEbEZ9xufujRp0sJ7dYHtFMsrjpwko42yhvcNTqX/3PxJTPl 7nxyDp6RKoPmznjkrBorMZKwStqJnpVwLfgotlX/KqW9xY0PzZ51O0CKt4r6XlA2nXeN AZHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LFuKtqFYTzofUHvDSF4HQif+epQY9AXs3XWktrGzXD4=; b=PN8DjNT1GpnBVLV7U9FuzIc2npk0AA8loAmZQPLYaDRmfAp2zY9SDxLvUk1hcgIawj CvkQbChGsDhx+zynw8eKg5gn9OYt6Wb6q1+2aiQbYXaL3oEXKpFY7kfoYjNzHSXg6TIK fTLD37E1hDLYo8wpoxNALpdmWCI1y/S1NQYCV/R7t6kSDV/hdC1XJIORlqID0x6iI28Z v5Axoy/NPQ2ZYqrjxXn+6hQ6i0PfGswPydLFsvUFp1yeEP9euAI49fGWIc+BClmyFXrH YjbwxDeI7EN9wOTUeiHs0jBDu7CyzWElz75qxmBa5vcSHbWzslRt59aBMgkBuXkDDjAH dDpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dR63xNwc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id pc21-20020a05620a841500b006fba891058asi324054qkn.486.2023.01.25.20.39.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Jan 2023 20:39:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dR63xNwc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKu29-00009Z-TO; Wed, 25 Jan 2023 23:38:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKu29-00009K-1M for qemu-devel@nongnu.org; Wed, 25 Jan 2023 23:38:45 -0500 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 1pKu27-0004RI-AL for qemu-devel@nongnu.org; Wed, 25 Jan 2023 23:38:44 -0500 Received: by mail-pl1-x634.google.com with SMTP id 5so927509plo.3 for ; Wed, 25 Jan 2023 20:38:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LFuKtqFYTzofUHvDSF4HQif+epQY9AXs3XWktrGzXD4=; b=dR63xNwcFesK6pPwGhQvOaGuUP9jxliTSlTtjvrQvZ0vaknRo9+ZygHvyltTDAeglq b5bAJ5/0Ab7g5G6qHYyGxUIAmUhBJjDqpB3ns3iN7zigPVFIDlrvGRQMlSTC4yUjVaij mwa7OzM9fzP7y8S6vDSeUmer0CPr0STqs4S10WrbAI46dryMKgNLxQHxFjikhTVDjwPI xKaeC6okneVOb/TUjVZ6rzm0vFVBEnSbkrCSLhUSjur2WhGH3fcDnazwQbnryPEeyAuV +EdUQLygqW/0EeiZKAGjzj9rPMJm8Rb07b8OxW88hIf26PZfpXk8HOgnIsI7yWqGLcW1 AI7Q== 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=LFuKtqFYTzofUHvDSF4HQif+epQY9AXs3XWktrGzXD4=; b=M7fZW+JdJSSJ0hBXhQTH7iZKPuoL68+gBnG0K0vtymirGS7lV66AypBK4PyTnar6iA N0qmhRDGQ5e/msYaYystgBMDAgTQ8HrBV8K47Z1GSzqRVVOVnSRUSJqbaUfUiTErUvwV HBSgMATNk4pjhnirwbAMzXZuB5DTcseep9Dc9UROTL3R5xlOjIpGpG0AXSIPnWYUv+hS Xu/xVBFZpJ3dVqiNKWb0LYREH17auFJNilrOjApd0C6oxXwG4f4VjkbcczeG42Obwkhn VvlmK/YYAJl2vMC/F6fOrMcQJLu8cSe8t/KSDPNjo31OuJiZx50gSbQzCpNGwQV9d5yY wlgA== X-Gm-Message-State: AO0yUKVXxzLsD4M1bTS901X+p3eF7MuefD/t96BDxbFF6K2i4naPnCIB gdTzqVyyp4l0I+Rf0Y9cUOXoP7OoN6ZoZ58xZj4= X-Received: by 2002:a17:90a:1d7:b0:22b:b0cb:2925 with SMTP id 23-20020a17090a01d700b0022bb0cb2925mr765392pjd.30.1674707921748; Wed, 25 Jan 2023 20:38:41 -0800 (PST) Received: from stoup.. (rrcs-173-197-98-118.west.biz.rr.com. [173.197.98.118]) by smtp.gmail.com with ESMTPSA id s62-20020a17090a69c400b00228e56d375asm233376pjj.33.2023.01.25.20.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 20:38:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v5 09/36] tcg/i386: Add TCG_TARGET_CALL_{RET,ARG}_I128 Date: Wed, 25 Jan 2023 18:37:57 -1000 Message-Id: <20230126043824.54819-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230126043824.54819-1-richard.henderson@linaro.org> References: <20230126043824.54819-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Fill in the parameters for the host ABI for Int128. Adjust tcg_target_call_oarg_reg for _WIN64, and tcg_out_call for i386 sysv. Allow TCG_TYPE_V128 stores without AVX enabled. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- tcg/i386/tcg-target.h | 10 ++++++++++ tcg/i386/tcg-target.c.inc | 30 +++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 5797a55ea0..d4f2a6f8c2 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -100,6 +100,16 @@ typedef enum { #endif #define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL +#if defined(_WIN64) +# define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_BY_REF +# define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_BY_VEC +#elif TCG_TARGET_REG_BITS == 64 +# define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_NORMAL +# define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_NORMAL +#else +# define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_NORMAL +# define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_BY_REF +#endif extern bool have_bmi1; extern bool have_popcnt; diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 2f0a9521bf..883ced8168 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -115,6 +115,11 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) case TCG_CALL_RET_NORMAL: tcg_debug_assert(slot >= 0 && slot <= 1); return slot ? TCG_REG_EDX : TCG_REG_EAX; +#ifdef _WIN64 + case TCG_CALL_RET_BY_VEC: + tcg_debug_assert(slot == 0); + return TCG_REG_XMM0; +#endif default: g_assert_not_reached(); } @@ -1188,9 +1193,16 @@ static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, * The gvec infrastructure is asserts that v128 vector loads * and stores use a 16-byte aligned offset. Validate that the * final pointer is aligned by using an insn that will SIGSEGV. + * + * This specific instance is also used by TCG_CALL_RET_BY_VEC, + * for _WIN64, which must have SSE2 but may not have AVX. */ tcg_debug_assert(arg >= 16); - tcg_out_vex_modrm_offset(s, OPC_MOVDQA_WxVx, arg, 0, arg1, arg2); + if (have_avx1) { + tcg_out_vex_modrm_offset(s, OPC_MOVDQA_WxVx, arg, 0, arg1, arg2); + } else { + tcg_out_modrm_offset(s, OPC_MOVDQA_WxVx, arg, arg1, arg2); + } break; case TCG_TYPE_V256: /* @@ -1677,6 +1689,22 @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest, const TCGHelperInfo *info) { tcg_out_branch(s, 1, dest); + +#ifndef _WIN32 + if (TCG_TARGET_REG_BITS == 32 && info->out_kind == TCG_CALL_RET_BY_REF) { + /* + * The sysv i386 abi for struct return places a reference as the + * first argument of the stack, and pops that argument with the + * return statement. Since we want to retain the aligned stack + * pointer for the callee, we do not want to actually push that + * argument before the call but rely on the normal store to the + * stack slot. But we do need to compensate for the pop in order + * to reset our correct stack pointer value. + * Pushing a garbage value back onto the stack is quickest. + */ + tcg_out_push(s, TCG_REG_EAX); + } +#endif } static void tcg_out_jmp(TCGContext *s, const tcg_insn_unit *dest)