From patchwork Tue Apr 11 01:04:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 672310 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:184:0:0:0:0 with SMTP id p4csp537179wrx; Mon, 10 Apr 2023 18:12:05 -0700 (PDT) X-Google-Smtp-Source: AKy350bVeOqf3tyIEhmLu82eqf5bRNVLq4DJEAzjcO/bKquTeX05/g5CC95R1FVUS2ukFTjWXLrq X-Received: by 2002:a05:622a:1048:b0:3b9:b817:e9a8 with SMTP id f8-20020a05622a104800b003b9b817e9a8mr21935224qte.27.1681175524804; Mon, 10 Apr 2023 18:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681175524; cv=none; d=google.com; s=arc-20160816; b=rqhEzc/sLNVVMKseeQNUwpWvEaHql46TWTDhFMScdMoEZvP8gHgRqSh3Lw6bj2Ahbz KwWrFfYC+bFB2KZMqBa76XsDXGYMecgaPLTZ/YZ5B274mQ2MNQGo0mI0dm7+yyfYjr2y mKDL9B0yBNdBl8vL0bxhOgc3OrCaa9UVw80lj//m8OLgC0lj1x/Y6VWmMFXIwhhosoyS aVVVcRbJLIbMdOhd3wxFd26Kqi/jqU7i0e1YghANLcEEUM+Jv2sfvwgj4i1a+NOhFhDF rN2QuKuC0LgByGYDAjhii5zIvpilXNreaaWOVvfVr0IYTppsvQfuWzvh2s9skbrGTNcG qWzg== 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=dLv/eAbI6tQ0am4/yuJPeuSznEA4VOjwICoxSl+rb4g=; b=ExyYt2NBUKMejz2iHDU0LzJOpkwd6I0NwLlmfrOaEcOspb0xIpq6SilYsQN0WrVJXc nOQhTvhcFwRSUy0Wlhnb//blCq2ZhIS5wgcQmxi3/BA3PdIoX57dVueCx9ePDN6u+hbE juT+w7Pqo8J9LQeQ800PdBqJ3KBI/lLHgdt+M4cW7sm0duRL4Dm6Pkm/1ZGwKhMb1f5M 9QblPny3PkEp9E25hEA1pYN88Lz9UHmQAg/vkYdnw9U/9tjpIDluTluQHA3qrygR4fHJ CKGo9c2Ox2YTAw86aB1wc+xVLI9L9XTWcQ5FzfXv/hTEPaPHOImAOTiTqENCci8jXY/z utAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Chsx+orG; 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 t5-20020a05622a01c500b003e4d8f255c7si8451135qtw.378.2023.04.10.18.12.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Apr 2023 18:12:04 -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=Chsx+orG; 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 1pm2TK-0007Um-UR; Mon, 10 Apr 2023 21:06:59 -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 1pm2T8-00064s-PL for qemu-devel@nongnu.org; Mon, 10 Apr 2023 21:06:46 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pm2T6-0000V7-En for qemu-devel@nongnu.org; Mon, 10 Apr 2023 21:06:46 -0400 Received: by mail-pl1-x629.google.com with SMTP id o2so6255963plg.4 for ; Mon, 10 Apr 2023 18:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681175204; 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=dLv/eAbI6tQ0am4/yuJPeuSznEA4VOjwICoxSl+rb4g=; b=Chsx+orGqCuQiAWcYAYXnuHCzV+AMJ2Jy5PpTW2n46j9xcfTGSQjTX1bqGZmsPf+BY QEKTyvX1EFLlzE3cq7BUpg2lJO8RBWkYdZwleaQg4MK75ypMhMEqpkdIBGLhxTWgVV9u KCn7TmYfEFh53Gk5JU0mh2vfHZDoOZeFw6pn5Zbk1GjuEugrmkkdkCFZhoql5N6L10Yv tdCHbqT4EG55njsT//pRwYHJiBKEiolZWdZIJFwHufm0/DUC930QvhEh3ikG+64Isg0F jc8b4lMcRyNZxi24vRs7t6pzpG1/0SplDYr8nOJJT0nd1jIyBDdwdX4YY6bNEtOWG+qn PhcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681175204; 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=dLv/eAbI6tQ0am4/yuJPeuSznEA4VOjwICoxSl+rb4g=; b=d0Tk+Eg7kGzVz4JPHn9jhMP2Be44G2K/BjmFWiSX8TqpwGrrzFYFzEMxZXCDI9cj8l 72n6QrWDo4rIMjuhu27gJL1g5GKL99DHMs9mSGM8hYcEvWic/sSf6lARkSBSiX2bEKFx O4DR07FMnFIMNin+Dc5d441j1JhBNVYh2/tOL1RLMZyVLKph2XuzjuMIkQyejk1BmcaG 2LbWjzSQx25dVFMnuIsgHAPqMYYfnjxnWERt9YPFXZXjecD3ngyLIFWeUHckoeqrg9sA Ny272bQ5efrNAYLnV3cCHswQEURXM4sF/rPFLEq3X5GOcs9UvQbI/JhQrHU+Mb8BtUZM iIog== X-Gm-Message-State: AAQBX9cB/a6SEGrWM6BRfXcnCJSvOMoFKMOHrbaAa3RDQW76GvTy9lWX 75Afm/VFtLTp9mnT3pW60m+XznzA0/8fnlzo9YPVGQ== X-Received: by 2002:a05:6a20:2d9a:b0:e9:5b0a:e8f2 with SMTP id bf26-20020a056a202d9a00b000e95b0ae8f2mr7414502pzb.35.1681175203771; Mon, 10 Apr 2023 18:06:43 -0700 (PDT) Received: from stoup.WiFi.IPv4InfoBelow (h146.238.133.40.static.ip.windstream.net. [40.133.238.146]) by smtp.gmail.com with ESMTPSA id s10-20020a65690a000000b0051b0e564963sm1320291pgq.49.2023.04.10.18.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 18:06:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org, qemu-ppc@nongnu.org Subject: [PATCH v2 32/54] tcg: Replace REG_P with arg_loc_reg_p Date: Mon, 10 Apr 2023 18:04:50 -0700 Message-Id: <20230411010512.5375-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230411010512.5375-1-richard.henderson@linaro.org> References: <20230411010512.5375-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.google.com X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 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, SUSPICIOUS_RECIPS=2.51 autolearn=no 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. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- 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);