From patchwork Sat Dec 24 23:57:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 636688 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp931796pvb; Sat, 24 Dec 2022 16:09:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXs4wZ5Sf7WhZaq/dpWXRUpuwi3jw8HaO+FELdikOhx2ZvUKs7btmtU5m9/ejJvx2YYQz6bL X-Received: by 2002:a0c:e410:0:b0:52b:e27f:edfa with SMTP id o16-20020a0ce410000000b0052be27fedfamr16981156qvl.27.1671926971125; Sat, 24 Dec 2022 16:09:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671926971; cv=none; d=google.com; s=arc-20160816; b=CPw06hdz/HJXzT5yvu6o/9H8llrfA2Ci71x7CrkpRjeE+LvR9jvMzawOnS3lv8S1m1 /DBs5RBC1bEjMfkTsx2LUd271spY0yZ/4hm0dPhBD12M+aWB/JjqRdto+/DOKNCIphAP vnWqU64VtPejHEvaPD11TLM1v9OTGY9Hm6N4BcWjZUBX07IYGsC25yuCKNox8rKf3k9y RKH5CKPc7pm3/GkvjDAx/V81mrnSEc37GjrlUzKgLbOkCGJ2yXzFfEcIu2lMZL19/WQz 9nlU88elUqLd+Lvd7GPH5FrmsUGgqVUabZOFUECZiqSBkPJujG2ri3/nkCqs5HkBpvLT MddA== 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=3PNalx9xC9o37R0T2TRvL9fvT6DAngOYvV1/eVoQctk=; b=yxJiRJft8l7Lsv5JIgblWr2EYau7UY9eP7mgLy0Qb43BXI5uAgSHHsA8zdfqx02xz4 QeyzDi9oa6cvtXNaGZiqNZQDoL3NJo3ZsJUU9JGcvHYsHGCQq1z/sAn1qm7l+k0r5vx5 pfUQSsaa6no3IwYfdF8PEEdoKH17HyR2Gdk0mv6d9lBKgE0DHpbtadlvH4hLkb449Hdb y4KBP0AfpbDmi4t6opyS99H0wP59FId+cWC0FfvTcSGLL5ufRpbonnWc+CtkiL0Cjlmd YOAFviuu0MihAp+BUCOFi3JpE4GcYqAzQ5SRSVFdftnJnh2cT9ZtV3Ts8md38y9/1Mto 0Hmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="iiBm/1iz"; 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 o9-20020a05620a110900b006ff1c35c093si2515267qkk.302.2022.12.24.16.09.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 24 Dec 2022 16:09:31 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="iiBm/1iz"; 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 1p9EP4-0002tT-8z; Sat, 24 Dec 2022 18:58:10 -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 1p9EOl-0002P5-4n for qemu-devel@nongnu.org; Sat, 24 Dec 2022 18:57:52 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p9EOi-0006Jy-OL for qemu-devel@nongnu.org; Sat, 24 Dec 2022 18:57:50 -0500 Received: by mail-pj1-x1032.google.com with SMTP id ge16so4312198pjb.5 for ; Sat, 24 Dec 2022 15:57:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3PNalx9xC9o37R0T2TRvL9fvT6DAngOYvV1/eVoQctk=; b=iiBm/1izNBrdardKXJtEhew5V5LimT7uyQsGF1o5TOfhEV43XEFPJ+5Go5F8du6g+0 WJQG5QiBMIffrB4BGDiCkZ5TxxmLKHOJK2pCPEZlc8NEeHHK8I+9Gw11n3ohtSXEWxRR v0gctMSj3jYa+Pj3d5VerwuqhQ9ta9MnkZfmj1fY9lP5sLrrRdz9PJ8Ivrpr2NsnKzM8 n/H2M0YQ+XK6BvgSn6F1X7xOVpPHBBAesekIVEVyuGqdZIMmTuF74j3gy9cn81zgZDfy U+NANuZWdABpgt2QYIvrQKe/eCwcShxuYdz18/7glmtLua/mJA375ygwDZJgH09WDfuf wIbg== 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=3PNalx9xC9o37R0T2TRvL9fvT6DAngOYvV1/eVoQctk=; b=V3cRnGL85IXbGfXbmYcsbkC8yVDx7MkyEjhCAhwXfc+0dTY4n2AjTTU8E5ULLIEKn9 i45+P4b8OlyV3knzI/V87FrgFCZmIvpxvVF+Nv2xDWxe/yyBbx1K3PvHW9OqCALvPmpN cA1rucKkE6JT50PJVUSMx5LyzlUcF6ghm71ILT4yT+sbD4LMi8JWoQiI6N5iFhFDYNNz sj52JcraNJqSqjgWpNqPlWitaQE9U4p5C0+HEIoBC5mJXyrfyzcwvG7AsEAP23xjGoO5 AzzVkBo+Yesu5mypEqEiu/R5tsw25fBmw19vj5lKmHwQHdLQrBiaGhaJOyB9OEQzKPkA FFSQ== X-Gm-Message-State: AFqh2kovc6v1skFSzq0ZryWpfy58Mgo5Rhd8NTqGMOFTiEYjurY9r4WO tzEWO76vO5t+RZ7a+xq/+0tmaBmyig4MDJES X-Received: by 2002:a17:902:e952:b0:192:4ce1:3687 with SMTP id b18-20020a170902e95200b001924ce13687mr17659658pll.52.1671926268021; Sat, 24 Dec 2022 15:57:48 -0800 (PST) Received: from stoup.. (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id cp12-20020a170902e78c00b00187022627d7sm4599716plb.36.2022.12.24.15.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Dec 2022 15:57:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, philmd@linaro.org Subject: [PATCH v5 27/43] tcg: Introduce tcg_type_size Date: Sat, 24 Dec 2022 15:57:04 -0800 Message-Id: <20221224235720.842093-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221224235720.842093-1-richard.henderson@linaro.org> References: <20221224235720.842093-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Add a helper function for computing the size of a type. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 16 ++++++++++++++++ tcg/tcg.c | 27 ++++++++++++--------------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index f2da340bb9..8bcd60d0ed 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -319,6 +319,22 @@ typedef enum TCGType { #endif } TCGType; +/** + * tcg_type_size + * @t: type + * + * Return the size of the type in bytes. + */ +static inline int tcg_type_size(TCGType t) +{ + unsigned i = t; + if (i >= TCG_TYPE_V64) { + tcg_debug_assert(i < TCG_TYPE_COUNT); + i -= TCG_TYPE_V64 - 1; + } + return 4 << i; +} + /** * get_alignment_bits * @memop: MemOp value diff --git a/tcg/tcg.c b/tcg/tcg.c index dbf4e864eb..12676268a2 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3038,22 +3038,22 @@ static bool liveness_pass_2(TCGContext *s) static void temp_allocate_frame(TCGContext *s, TCGTemp *ts) { - intptr_t off, size, align; + int size = tcg_type_size(ts->type); + int align; + intptr_t off; switch (ts->type) { case TCG_TYPE_I32: - size = align = 4; + align = 4; break; case TCG_TYPE_I64: case TCG_TYPE_V64: - size = align = 8; + align = 8; break; case TCG_TYPE_V128: - size = align = 16; - break; case TCG_TYPE_V256: /* Note that we do not require aligned storage for V256. */ - size = 32, align = 16; + align = 16; break; default: g_assert_not_reached(); @@ -3593,8 +3593,8 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TCGOp *op) TCGRegSet dup_out_regs, dup_in_regs; TCGTemp *its, *ots; TCGType itype, vtype; - intptr_t endian_fixup; unsigned vece; + int lowpart_ofs; bool ok; ots = arg_temp(op->args[0]); @@ -3662,15 +3662,12 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TCGOp *op) /* fall through */ case TEMP_VAL_MEM: -#if HOST_BIG_ENDIAN - endian_fixup = itype == TCG_TYPE_I32 ? 4 : 8; - endian_fixup -= 1 << vece; -#else - endian_fixup = 0; -#endif - /* Attempt to dup directly from the input memory slot. */ + lowpart_ofs = 0; + if (HOST_BIG_ENDIAN) { + lowpart_ofs = tcg_type_size(itype) - (1 << vece); + } if (tcg_out_dupm_vec(s, vtype, vece, ots->reg, its->mem_base->reg, - its->mem_offset + endian_fixup)) { + its->mem_offset + lowpart_ofs)) { goto done; } /* Load the input into the destination vector register. */