From patchwork Tue May 23 13:52:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 684968 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1736615wrt; Tue, 23 May 2023 07:03:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Fikh0m5d1I5K4AjB3SSWe/qTKO4enRkqu8ZLPfgjJMgup347ZFpMw9P/y7eLdHfgS7Zz7 X-Received: by 2002:a05:620a:6008:b0:75b:23a1:3ed with SMTP id dw8-20020a05620a600800b0075b23a103edmr4676445qkb.3.1684850630960; Tue, 23 May 2023 07:03:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684850630; cv=none; d=google.com; s=arc-20160816; b=Y3QfiuDH8fCqfU3hFrR6uIJjgMuE9lqs76RK4oo4ov2bdp08beTFRD3xrDjCupgCon 6uPN8X2+x6EbPYkRKqbfV5VTaiMK6rZiEF0xbDRWU1O7Ua21kC49U1uUM2LjqSRopODa uMMHRy9ajZ51JmddkiT109D/5cy40sNOHE85f7l+jAPd8rCAp1/Xyq4tVGMBNj5HlK4R oQo4KbudkqDEEPaQtnxoAwUdA+L0KcCKsQ05XZu0+FjbaN6ODq+u6t2RzJ9v6p5SFVuv ZaeRMLeCrffAg/PmB/aaHoseNwuIH8kU7NILvjRCEyQnMb3u6RJ79ITU6PusJ6F3/KCo JJjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=f6ed1FqxBisHvzO2Ats72ofMAbjCaP6iPUvqaHHft5E=; b=0YiVKNCko72K9LupmSOus38BZ/ImnpxKfQ1tz3lUCQWO8Tk1MgFO0svr+1gsoJ9vqi k+TdNT9V9U4jWzHTiCyuvw3anqlJyC3JbdETRiljXzpL0/k/UKebd2PNzH6i6D53O6Hm +R6UYTioAfc9y0KhGF4z2aL6E76V1AVx/biBjBl7zN3FQpZ9J2MLTaekJj5/GytOeBIG FNXztjeRyyTQ4Dt0ZBEZlIr968/eVJ/cUGRLtn8SGdr6kGQT3h+BXfMHTbjaqWg0p23h WoemsmXhXgtEULjV6eM+59vVN0BM9S3Si3H1S4JsnCTpEXqz4KNMhaXEWr3yct8DCeeU uoVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oruelD3s; 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 g15-20020a05620a13cf00b007591ec09759si4107667qkl.624.2023.05.23.07.03.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 May 2023 07:03:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oruelD3s; 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 1q1ST6-0006Xr-8R; Tue, 23 May 2023 09:54:28 -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 1q1SSP-0004zm-AB for qemu-devel@nongnu.org; Tue, 23 May 2023 09:53:46 -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 1q1SSN-00034Z-K9 for qemu-devel@nongnu.org; Tue, 23 May 2023 09:53:45 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-64d3fbb8c1cso4743710b3a.3 for ; Tue, 23 May 2023 06:53:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684850022; x=1687442022; 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=f6ed1FqxBisHvzO2Ats72ofMAbjCaP6iPUvqaHHft5E=; b=oruelD3sU3wSANPCy3BUHVkx8CSpEfNcG2MAWyYYJt06dvNqLSv9sFO5rdN6wPgIgK txqQVv+m9Npnhq65XnQFwhONo3mnrIFJ4IqNdniKYdYVmjpJcMo3ALvNPZP3BQUY+JxC VjPcV3e3p97HIqRfOF6MQbIRyDZZQGDPsvxURnLJNw56aNe57ucxS89K1qKC8XqwqgJC YtlKzwu6/pkSNnYfS3Q2AQ7JQD4u2YpTknoJxXdWt+IJoDl8fksrn0ufNEkW1CBAeHCs yL3n3+dRL7z4J6Vmk5mbabES6IfX2R2uCv2mPPyvaAHSk1EVp4EyMtFhjyiOBeONaGEa b0Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684850022; x=1687442022; 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=f6ed1FqxBisHvzO2Ats72ofMAbjCaP6iPUvqaHHft5E=; b=htx4oaqtfAvgWVoTH2kUX6nBYCM/fExhT7frxoz9U0LY5yOe5lSMCNj8scnUn3jJYw jroesa11aJp3IoYUPmvzDCJ9Imiq7SL202pw6aQPoHbUJzxVm1gm5Je+f9RpGxYsS7FD YMiMJpefTp5Ewlrm+eldaR4YFTqF4Yf2E4372a8PUIfah+dtr0F28UowoeHhg9zpv9KI DdHNEsP0dpiLZVJrfpKG6i/hGJQd2GxjgZ9pWJtVYD5q3yFhnT/O6HROvIBzqOrSi7n0 zoJ6z7rl+g1gm+Qcr9ieGX29ZJ96+kl6KmaugnJCc2WV/bWaotdZXGa2UfvmCGJiYM9Z XsdQ== X-Gm-Message-State: AC+VfDwvmuJQCSllCJ2t0xHweRu0sODumT8i1KYd4TeRmwomkkHDRbki roIGwbcgO0RhmFmsuCbBN3IsPX3uW2d00GwkPhc= X-Received: by 2002:a05:6a20:3947:b0:10c:7916:f9f6 with SMTP id r7-20020a056a20394700b0010c7916f9f6mr2687163pzg.52.1684850022193; Tue, 23 May 2023 06:53:42 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:c13a:d73:4f88:3654]) by smtp.gmail.com with ESMTPSA id b8-20020aa78708000000b0064d27a28451sm5796111pfo.100.2023.05.23.06.53.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 06:53:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 22/52] tcg: Move temp_idx and tcgv_i32_temp debug out of line Date: Tue, 23 May 2023 06:52:52 -0700 Message-Id: <20230523135322.678948-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523135322.678948-1-richard.henderson@linaro.org> References: <20230523135322.678948-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Removes a multiplicty of calls to __assert_fail, saving up to 360kiB of .text space as measured on an x86_64 host. Old New Less %Change 9257272 8888680 368592 3.98% qemu-system-aarch64 6100968 5911832 189136 3.10% qemu-system-riscv64 5839112 5707032 132080 2.26% qemu-system-mips 4447608 4341752 105856 2.38% qemu-system-s390x Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 30 ++++++++++++++++-------------- tcg/tcg.c | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 34035dab81..64c10a63f3 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -630,13 +630,6 @@ static inline void *tcg_splitwx_to_rw(const void *rx) } #endif -static inline size_t temp_idx(TCGTemp *ts) -{ - ptrdiff_t n = ts - tcg_ctx->temps; - tcg_debug_assert(n >= 0 && n < tcg_ctx->nb_temps); - return n; -} - static inline TCGArg temp_arg(TCGTemp *ts) { return (uintptr_t)ts; @@ -647,16 +640,25 @@ static inline TCGTemp *arg_temp(TCGArg a) return (TCGTemp *)(uintptr_t)a; } -/* Using the offset of a temporary, relative to TCGContext, rather than - its index means that we don't use 0. That leaves offset 0 free for - a NULL representation without having to leave index 0 unused. */ +#ifdef CONFIG_DEBUG_TCG +size_t temp_idx(TCGTemp *ts); +TCGTemp *tcgv_i32_temp(TCGv_i32 v); +#else +static inline size_t temp_idx(TCGTemp *ts) +{ + return ts - tcg_ctx->temps; +} + +/* + * Using the offset of a temporary, relative to TCGContext, rather than + * its index means that we don't use 0. That leaves offset 0 free for + * a NULL representation without having to leave index 0 unused. + */ static inline TCGTemp *tcgv_i32_temp(TCGv_i32 v) { - uintptr_t o = (uintptr_t)v; - TCGTemp *t = (void *)tcg_ctx + o; - tcg_debug_assert(offsetof(TCGContext, temps[temp_idx(t)]) == o); - return t; + return (void *)tcg_ctx + (uintptr_t)v; } +#endif static inline TCGTemp *tcgv_i64_temp(TCGv_i64 v) { diff --git a/tcg/tcg.c b/tcg/tcg.c index 7c5cc6c800..bd276f1d32 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1805,6 +1805,25 @@ TCGv_vec tcg_constant_vec_matching(TCGv_vec match, unsigned vece, int64_t val) return tcg_constant_vec(t->base_type, vece, val); } +#ifdef CONFIG_DEBUG_TCG +size_t temp_idx(TCGTemp *ts) +{ + ptrdiff_t n = ts - tcg_ctx->temps; + assert(n >= 0 && n < tcg_ctx->nb_temps); + return n; +} + +TCGTemp *tcgv_i32_temp(TCGv_i32 v) +{ + uintptr_t o = (uintptr_t)v - offsetof(TCGContext, temps); + + assert(o < sizeof(TCGTemp) * tcg_ctx->nb_temps); + assert(o % sizeof(TCGTemp) == 0); + + return (void *)tcg_ctx + (uintptr_t)v; +} +#endif /* CONFIG_DEBUG_TCG */ + /* Return true if OP may appear in the opcode stream. Test the runtime variable that controls each opcode. */ bool tcg_op_supported(TCGOpcode op)