From patchwork Wed May 3 06:57:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 678660 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp908952wrs; Wed, 3 May 2023 00:24:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4zMg9V6bPq9sqkW3lLPaUO3bsrhUDa72OfEsNMygPie8a6Kt6TA2seYWaoQ+DHXpEtXoRm X-Received: by 2002:ac8:5cd1:0:b0:3ba:2203:6c92 with SMTP id s17-20020ac85cd1000000b003ba22036c92mr31046436qta.10.1683098647657; Wed, 03 May 2023 00:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683098647; cv=none; d=google.com; s=arc-20160816; b=p4e504oW9PDjD4J6zXt8X2cCgIMOjloGqrcyNEAjctKX+aU/i6STgtq9SthUJ1hqCy XpaQGcJSH2X7shRxYAvGoE5WUFgFhNDFRC+lpGnYGcfK7IwN084AHMIJHbJ+68eOXY1R tzB89uwvHeMo2S9NCYkgw86v3RILi5i5Lx7GdPhjy9AUqszQKmnlpa01+MMYST4Qp/mp wjo1yEcws99rTgZcMTZ24Di3B7b+s75JasHHgm8TynExS5a6lPA5bljRyuWJ4Ig4ufZK EBzVA6YJQ2z7hHmc1gWwJiuE59l81FjKQjHiC0RB6ePJPW11p/3q4W7UB1z2VZWYJUDV WH9A== 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=rivgwXGbdDw6Y7e7EyPZeewGUUT+LzpYCC2kVwog6co=; b=HY+HFgtVoBiwDZN0gGmu8zQwol4mSJoMBrI7lzQKWpUbYNWKOgfja3G7kI6NXnuFuO J6Vkmhvr6NlX4tO61j33OnD+qOiJGIfF5khXHVngC8+88BgJgKIwr27DSvd2OHPvTRiN +4bvK27qEvEWpMChDr8vsMVq/Q5ggWndo2BQz1SZOOOOcNBg/RBzeawMilVcLoljZmT3 7hmL5C8H7DB/MCvwku9nAqSayRUM+lZzivU0E+lzi/7+Xfs4BSmbfY0jvwUlxvDZ15cY Dg8veFmyBIjczO8prrRPv0uh8++9244tBjnWebdmDn7z9VOEzyzOMmj7mWF2F4P+o5wm OwUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JtYdNU9s; 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 j6-20020a05620a288600b0074e16ae307bsi18257167qkp.384.2023.05.03.00.24.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 May 2023 00:24:07 -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=JtYdNU9s; 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 1pu6SK-0001Ru-HC; Wed, 03 May 2023 02:59: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 1pu6Rk-00009v-HC for qemu-devel@nongnu.org; Wed, 03 May 2023 02:58:46 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450: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 1pu6R2-0001tt-7m for qemu-devel@nongnu.org; Wed, 03 May 2023 02:58:35 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-2fe3fb8e25fso3016997f8f.0 for ; Tue, 02 May 2023 23:57:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683097074; x=1685689074; 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=rivgwXGbdDw6Y7e7EyPZeewGUUT+LzpYCC2kVwog6co=; b=JtYdNU9sN5zax56+w/nOFwtjzYm9235USCd/ASxff05LCQz460gWS1GRAVI2/flN31 m/TNJkfaxEnFeQYjDgLn6xHTIte+B+AsUCY5S4iEw/gYgYsaes3DwiOuis4UR+j797QF lE3ySWMRgnzADQUqpMBguWhJdMB0UjNlZgt8TeSFjN9YZwn6ZNqW5uYZBowmdWqtR9wm bjQVT7lbI6KZc0hvgHCUo4GXM33UoGTCY8WAFSb1plVD+TKTfcgCZFSPDJ+j8/5qtWSe Y2J4qAUmMiyScoOwehyBvl01EppLXS9u7tzLfkXgiaeGC8h/rWVJ2tQmgSDSCo1C02Ai /vSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683097074; x=1685689074; 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=rivgwXGbdDw6Y7e7EyPZeewGUUT+LzpYCC2kVwog6co=; b=GSI+4tcSAS+1VUbmZOfP8ULQWW7+nKruAfytISVldCi4+Go1byZ7YhW7KkCPyvRexl zEsSCRyU6w4qAdKhnNfnQDipqkEFm+QV0lkg2bKKAHo1EkiV36eGRmo7Pe3Bm19AHQB/ f9+r6nMGfDPoz2vgoqNOwF6EwedBmomh8bsmC8gN1tU4Iwr10KVudxLXD0+BetDV/rhy 2PfRjtxC2QU0/GP1xY1q/E38kzSBMi09tt+vg2+We8Zd5BUZluTSZVZWh6ofjIukTljJ BbZZjMBnLG/rGZK4HztcnhebyMWdydPzoqjQhxIMOGMFvuob/VPLOZghXspORqLv6ztF 30Gg== X-Gm-Message-State: AC+VfDyI2VjSCq36wCWzKPu0SEQkjXpjlLMcG8CS+lwczkKOsUwoydv/ Za1OdN1G+zrzzXesq3+O233QoUVeExcwQf03bjK1nQ== X-Received: by 2002:adf:f4c9:0:b0:306:27bc:f906 with SMTP id h9-20020adff4c9000000b0030627bcf906mr7861196wrp.67.1683097074610; Tue, 02 May 2023 23:57:54 -0700 (PDT) Received: from stoup.Home ([2a02:c7c:74db:8d00:c01d:9d74:b630:9087]) by smtp.gmail.com with ESMTPSA id f6-20020a5d6646000000b002f6dafef040sm32796617wrw.12.2023.05.02.23.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 May 2023 23:57:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: git@xen0n.name, philmd@linaro.org, qemu-arm@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v4 31/54] tcg: Replace REG_P with arg_loc_reg_p Date: Wed, 3 May 2023 07:57:06 +0100 Message-Id: <20230503065729.1745843-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230503065729.1745843-1-richard.henderson@linaro.org> References: <20230503065729.1745843-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 An inline function is safer than a macro, and REG_P was rather too generic. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tcg-internal.h | 4 ---- tcg/tcg.c | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index e542a4e9b7..0f1ba01a9a 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -58,10 +58,6 @@ typedef struct TCGCallArgumentLoc { unsigned tmp_subindex : 2; } TCGCallArgumentLoc; -/* Avoid "unsigned < 0 is always false" Werror, when iarg_regs is empty. */ -#define REG_P(L) \ - ((int)(L)->arg_slot < (int)ARRAY_SIZE(tcg_target_call_iarg_regs)) - typedef struct TCGHelperInfo { void *func; const char *name; diff --git a/tcg/tcg.c b/tcg/tcg.c index 6f5daaee5f..fa28db0188 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -806,6 +806,16 @@ static void init_ffi_layouts(void) } #endif /* CONFIG_TCG_INTERPRETER */ +static inline bool arg_slot_reg_p(unsigned arg_slot) +{ + /* + * Split the sizeof away from the comparison to avoid Werror from + * "unsigned < 0 is always false", when iarg_regs is empty. + */ + unsigned nreg = ARRAY_SIZE(tcg_target_call_iarg_regs); + return arg_slot < nreg; +} + typedef struct TCGCumulativeArgs { int arg_idx; /* tcg_gen_callN args[] */ int info_in_idx; /* TCGHelperInfo in[] */ @@ -3231,7 +3241,7 @@ liveness_pass_1(TCGContext *s) case TCG_CALL_ARG_NORMAL: case TCG_CALL_ARG_EXTEND_U: case TCG_CALL_ARG_EXTEND_S: - if (REG_P(loc)) { + if (arg_slot_reg_p(loc->arg_slot)) { *la_temp_pref(ts) = 0; break; } @@ -3258,7 +3268,7 @@ liveness_pass_1(TCGContext *s) case TCG_CALL_ARG_NORMAL: case TCG_CALL_ARG_EXTEND_U: case TCG_CALL_ARG_EXTEND_S: - if (REG_P(loc)) { + if (arg_slot_reg_p(loc->arg_slot)) { tcg_regset_set_reg(*la_temp_pref(ts), tcg_target_call_iarg_regs[loc->arg_slot]); } @@ -4833,7 +4843,7 @@ static void load_arg_stk(TCGContext *s, int stk_slot, TCGTemp *ts, static void load_arg_normal(TCGContext *s, const TCGCallArgumentLoc *l, TCGTemp *ts, TCGRegSet *allocated_regs) { - if (REG_P(l)) { + if (arg_slot_reg_p(l->arg_slot)) { TCGReg reg = tcg_target_call_iarg_regs[l->arg_slot]; load_arg_reg(s, reg, ts, *allocated_regs); tcg_regset_set_reg(*allocated_regs, reg);