From patchwork Fri Dec 2 05:39:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 630197 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp715338pvb; Thu, 1 Dec 2022 21:41:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf5R6HVdtsimeGOtCJP8TJwdzUTj7UqrD91TxjkUZammbP8TNkxsCO0kzNBlCN2NgKn7Dkfp X-Received: by 2002:ac8:734d:0:b0:3a5:2784:f462 with SMTP id q13-20020ac8734d000000b003a52784f462mr48539258qtp.590.1669959673940; Thu, 01 Dec 2022 21:41:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669959673; cv=none; d=google.com; s=arc-20160816; b=gJUxGj7Et6RY0UtnzGIFOuvRNRQuZuCbLOvcOrgcjprzyUrrrAWax6chxefPop4p3Y VifL+uXdw3mJZk5XkaBbU5qdHFBT3yzTRVFXYNiZvTJuzUFLHNGJdagwRCPRsvlrX8QQ lFsrwXAIFzun1s+5DYJqrXAzdLKIhQe2m/9h0ZH4pq6kpKYQemDWGdCjpgEiI8C+RvkQ bilwl6OZMwNwd68gxCaips3A7Mo5INOAGaoDPDja/jhsaDKb4Lbsxhr1/EGMM2SJ1a5D todM6ybyf5nNwCL6canzm+FlPUrfbxRr+U0QZuiBecoOctdJ7KTxMW/tiJ9E7TIdovLF AGsg== 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=K00u0Px9SnlSkUg49TmVgzbaWjYpCzRGNS6saRYbcAYtjvCu5UcWaXojPOeEtLUrP1 vQyR9kAFIZR7tgezthhPbRIQgvLOHuDns2pmHih1O7d4SwC5PmVuEBmmOVgY8boYQoxl Bmxp1iSF6hUzYP2jbolwnz9y/lrdUOGElWioOUCKvFRlvS3QfBO/8NePXrEjdEg9WG0e jj6ZSJh7bfYQYY+6StlpVr2/ZQySgOADjvd65jfuxxLfnGGhUqiisD5aKzBGbBIVCios hc/IfSyFnqLUTst0kYqG1YsS+14SQ+K9O/yNmBtjQPKRkTtxhg7UWTZPiEp5eSCEQ9gv h/bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GiwqymHt; 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 o15-20020a0562140e4f00b004a7b5720af7si3415282qvc.260.2022.12.01.21.41.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Dec 2022 21:41:13 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GiwqymHt; 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 1p0ymc-0002eY-6y; Fri, 02 Dec 2022 00:40:22 -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 1p0ymb-0002eK-8i for qemu-devel@nongnu.org; Fri, 02 Dec 2022 00:40:21 -0500 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p0ymZ-0003My-Eq for qemu-devel@nongnu.org; Fri, 02 Dec 2022 00:40:20 -0500 Received: by mail-pg1-x532.google.com with SMTP id 62so3525488pgb.13 for ; Thu, 01 Dec 2022 21:40:19 -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=GiwqymHt8LAh9jA+y7sv/yHuUQ9/o++2EPCQeFgzMCt0lyKzXvleeaIKmjj24tdGWM 1Pq5ZJAN1k/CiZ8lyqntyscRtev5olhRiS7+vV4MWojVtlTZINMqcgHhK8v8q/iwAVm8 6xVj5D2sOHA51vbxryR6YPIYEQUxwz3n9SQlaEXnAYZ9l1PqP2W01hECEHbLRQi7MBhh V4+RvsPF3EgZaAoaN5h3hOi2olOUrc9GEk2zQp/Bw8AEd07rHbgRySywAOtAhU5hHqda ZoMlhhG3xOnajHuU79JAqrN52YWFl+r017ujPExjo4up17ELAaKUXF7EJPgDOqx/T/PQ nVEA== 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=ap51f5mB+GmCZDb57obU46MTum1Ap852gr27vAaKlp1XeLHNd69hmolwqr8O+AXSw0 OWbNw+J8UjHvwd+cEmN5Pl+mAj/III73CUnscS4ytgwR4GP/C5bxi3pcuocuHDz54Rr6 /icTwK2GBW1KbxPehot4iDpjlxo5MX8MTyiQHUPRzlD/jcFU/8bMdNgZDrsRRY7hJBtn PKYJpR8bfALJLfByCa4hbQNZCywYKAMoDJ1EtWvboBdIzz7OPjBLAlKzP/mwtPo7lcGV TjGMBHEKnY40wDXvASjjRExzWh9aS1FhNYx4VHUI81dRsLkRFrVgfGdwTKQ9Q+Xo3mYP DvNw== X-Gm-Message-State: ANoB5pmYb63nBrO0cbmVG+8lKvKKokBPDOsOxpSlTaPvxQpt0wP3PxWT 7JdOlswepqIhry9LbOGzAvT852vLAHhqKrSg X-Received: by 2002:a62:d10b:0:b0:575:ad52:ba94 with SMTP id z11-20020a62d10b000000b00575ad52ba94mr14981954pfg.74.1669959618148; Thu, 01 Dec 2022 21:40:18 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:e3cc:2e37:17d4:f1d5]) by smtp.gmail.com with ESMTPSA id d12-20020a170903230c00b00186f0f59c85sm4637075plh.235.2022.12.01.21.40.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 21:40:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 18/34] tcg: Introduce tcg_type_size Date: Thu, 1 Dec 2022 21:39:42 -0800 Message-Id: <20221202053958.223890-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221202053958.223890-1-richard.henderson@linaro.org> References: <20221202053958.223890-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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. */