From patchwork Wed Oct 25 07:26:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 737839 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp149374wrq; Wed, 25 Oct 2023 00:29:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOa5vmOe3XqNErVEPg/6I4AA4ODgWiT4YdsR58fKaNuq0dwBCSPgam6MN4L+wJr4aSaBDB X-Received: by 2002:a05:600c:1e20:b0:407:5de2:ea4d with SMTP id ay32-20020a05600c1e2000b004075de2ea4dmr15823573wmb.13.1698218986404; Wed, 25 Oct 2023 00:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698218986; cv=none; d=google.com; s=arc-20160816; b=T5txCtBJpL2ie1NiA7bubOC6TsLjvLAaPNF3lKVlZS5yqT6zyZdepNk/T2eyjXLpUX Bl+/iqYpdFmxBBJNIIN2cQcULtbJB7HKS4ps4srXGjRMNtHeIffOEAyB0BvJS7WRmOEM n5gL5gOZEGMUM4Uwqcd24Ic5QBrVC1ukEYzatf7V/lf8fV8gKMebnudLopVQknh+H05B VFvW/5PvrkVsZ0d2vzaEjewhaIEHtDKxkjJMf9aEz8XNQuHwJphlZX9/lXWx4PQRK3zG EF6M5V1waEXpbyiv6teN6G1o6NROdLoOnbP/P7gHgEK5bd2K2OZZBpyswZ+Y7KKtoAjR DH5Q== 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=iO7a+DcsBv1QUswJrwtg846br5OcYCcDIc2AiP9uJP0=; fh=ycigHkwOPieh2u5PmcA89sNk/qPD1ZkdDlL8Mchfvw8=; b=XYoBsuPsKYyld0c5NGdXHyiGDhyD6Aa6PUgyyNeDmskd8PU6BQDVtNoMEulKvW/AAb JC8eZiGCOI0Z+p3fbDwsGs5aLYnMBbRVErQadLGGbpnZZtBwgRd6bC319p+YfXoRQ3L5 cO4lVsZmpGDLGjmECOHrNJW37CAiO+WG/+cp5cIKuRqKrhykCsUT7+iApDDfgQyH+NuZ YxlR+J96oQwhYcxuQVJBRno2yM/7cjWCpLwFeCbaE+IwhShlbhodhNS2qbbD3H6NHgY5 qdXAiJ602JhOXUeX8vT2V7yF4OH/laF96iLE+GvjWQntP5u3aoYqj9C/b1wBplexYqR/ 8msw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GQ2pgiuI; 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 bd6-20020a05600c1f0600b003fee51323e9si6101517wmb.45.2023.10.25.00.29.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2023 00:29:46 -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=GQ2pgiuI; 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 1qvYIT-0000BM-A1; Wed, 25 Oct 2023 03:27:21 -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 1qvYIS-0000B3-D0 for qemu-devel@nongnu.org; Wed, 25 Oct 2023 03:27:20 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qvYIQ-0004fM-Kw for qemu-devel@nongnu.org; Wed, 25 Oct 2023 03:27:20 -0400 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-27db9fdec0dso4706232a91.0 for ; Wed, 25 Oct 2023 00:27:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698218837; x=1698823637; darn=nongnu.org; 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=iO7a+DcsBv1QUswJrwtg846br5OcYCcDIc2AiP9uJP0=; b=GQ2pgiuIqFnAQK8yH3/6DCFEbsbdIQU2c3yO+VUYknQMfUfcMeNLwoorsGdzxvdkUC p7UQF7P2f2Y+eD19VHQlYz2a/2u3/aaVEAGdHbYOJb1Cx+YNAxmYfzzSDx73Em20l4MD sNIRHClMEaKOU8TTJy4lgWZiQ2qnEVZ8b3KEbYD7Im1WpcS4MMmLCTlUq9xIgwd47i/V eQOa6ofxOATvkMvnllRB1+BHZFpQfgbw5kIXnOeAUqxdgLMNyV2k7umkqbZ73DV8mGMZ p5qBS7kmiqL9C0I+9G4/g/mdXx+4TFxwtNi7ElWai+UdM7Vky5R/s+6slD7odW5OWHKV vi/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698218837; x=1698823637; 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=iO7a+DcsBv1QUswJrwtg846br5OcYCcDIc2AiP9uJP0=; b=RFaypAUi6oLkuCqQytwMIqK3vViYntZzowyY4kR1LqgReo0DmpcnoHZHApiVrVUR18 DUJFxwrxTkAEyyBS57KEstooAnIBGbLzkWR6NxjOBP4RtvC7zMV6d2JycdvhK6sqWbxL D5saCAqyK+XNG674GEhXs5V4Ysu+ckek4NNIcodK2n0bEngGJ8MhXtFO/5VmL0pictBm iJXOuCOTWTH+/YvEkfvOwFxwnNmB/S1rDKuvBSYL+t5Cag2amkb8zdSgokqajjPIyPU/ S1QTZDo7Que0PUNakkSxD8hG+r0tRTDU2m4JZ6xDUJazlqmCNJK3wZMeF9kldV1S1hPR AxDQ== X-Gm-Message-State: AOJu0Yx4XGkQdnPsxXqu+KO0pdfVIzAclRDwcrT58g0qZ94x+n4hVsiK Sv/Ri/ABvQRHZqkWPx6UKsGwaqyl1BP0Qb58etg= X-Received: by 2002:a17:90a:8c2:b0:27f:df1a:caab with SMTP id 2-20020a17090a08c200b0027fdf1acaabmr745289pjn.21.1698218837255; Wed, 25 Oct 2023 00:27:17 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id ji5-20020a170903324500b001b06c106844sm8578661plb.151.2023.10.25.00.27.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 00:27:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 09/29] tcg/arm: Support TCG_COND_TST{EQ,NE} Date: Wed, 25 Oct 2023 00:26:47 -0700 Message-Id: <20231025072707.833943-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231025072707.833943-1-richard.henderson@linaro.org> References: <20231025072707.833943-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.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 Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.c.inc | 59 ++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index fc78566494..344143cd10 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1190,6 +1190,33 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) } } +static TCGCond tcg_out_cmp(TCGContext *s, TCGCond cond, TCGReg a, + TCGArg b, int b_const) +{ + if (!is_tst_cond(cond)) { + tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, a, b, b_const); + return cond; + } + + cond = tcg_tst_eqne_cond(cond); + if (b_const) { + int imm12 = encode_imm(b); + + /* + * The compare constraints allow rIN, but TST does not support N. + * Be prepared to load the constant into a scratch register. + */ + if (imm12 >= 0) { + tcg_out_dat_imm(s, COND_AL, ARITH_TST, 0, a, imm12); + return cond; + } + tcg_out_movi32(s, COND_AL, TCG_REG_TMP, b); + b = TCG_REG_TMP; + } + tcg_out_dat_reg(s, COND_AL, ARITH_TST, 0, a, b, SHIFT_IMM_LSL(0)); + return cond; +} + static TCGCond tcg_out_cmp2(TCGContext *s, const TCGArg *args, const int *const_args) { @@ -1217,6 +1244,13 @@ static TCGCond tcg_out_cmp2(TCGContext *s, const TCGArg *args, tcg_out_dat_rI(s, COND_EQ, ARITH_CMP, 0, al, bl, const_bl); return cond; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + /* Similar, but with TST instead of CMP. */ + tcg_out_dat_rI(s, COND_AL, ARITH_TST, 0, ah, bh, const_bh); + tcg_out_dat_rI(s, COND_EQ, ARITH_TST, 0, al, bl, const_bl); + return tcg_tst_eqne_cond(cond); + case TCG_COND_LT: case TCG_COND_GE: /* We perform a double-word subtraction and examine the result. @@ -1805,9 +1839,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, /* Constraints mean that v2 is always in the same register as dest, * so we only need to do "if condition passed, move v1 to dest". */ - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[1], args[2], const_args[2]); - tcg_out_dat_rIK(s, tcg_cond_to_arm_cond[args[5]], ARITH_MOV, + c = tcg_out_cmp(s, args[5], args[1], args[2], const_args[2]); + tcg_out_dat_rIK(s, tcg_cond_to_arm_cond[c], ARITH_MOV, ARITH_MVN, args[0], 0, args[3], const_args[3]); break; case INDEX_op_add_i32: @@ -1957,25 +1990,21 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_brcond_i32: - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[0], args[1], const_args[1]); - tcg_out_goto_label(s, tcg_cond_to_arm_cond[args[2]], - arg_label(args[3])); + c = tcg_out_cmp(s, args[2], args[0], args[1], const_args[1]); + tcg_out_goto_label(s, tcg_cond_to_arm_cond[c], arg_label(args[3])); break; case INDEX_op_setcond_i32: - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[1], args[2], const_args[2]); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[args[3]], + c = tcg_out_cmp(s, args[3], args[1], args[2], const_args[2]); + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[c], ARITH_MOV, args[0], 0, 1); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(args[3])], + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(c)], ARITH_MOV, args[0], 0, 0); break; case INDEX_op_negsetcond_i32: - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[1], args[2], const_args[2]); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[args[3]], + c = tcg_out_cmp(s, args[3], args[1], args[2], const_args[2]); + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[c], ARITH_MVN, args[0], 0, 0); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(args[3])], + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(c)], ARITH_MOV, args[0], 0, 0); break;