From nobody Tue Feb 10 00:59:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504709669054600.0857887457709; Wed, 6 Sep 2017 07:54:29 -0700 (PDT) Received: from localhost ([::1]:36541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpbim-0000Up-2w for importer@patchew.org; Wed, 06 Sep 2017 10:54:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpbeO-0005T6-4r for qemu-devel@nongnu.org; Wed, 06 Sep 2017 10:49:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpbeM-0000IV-TK for qemu-devel@nongnu.org; Wed, 06 Sep 2017 10:49:56 -0400 Received: from mail-pg0-x232.google.com ([2607:f8b0:400e:c05::232]:32782) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpbeM-0000ID-Kw for qemu-devel@nongnu.org; Wed, 06 Sep 2017 10:49:54 -0400 Received: by mail-pg0-x232.google.com with SMTP id t3so15708435pgt.0 for ; Wed, 06 Sep 2017 07:49:54 -0700 (PDT) Received: from bigtime.twiddle.net (97-126-108-236.tukw.qwest.net. [97.126.108.236]) by smtp.gmail.com with ESMTPSA id h1sm3467646pfg.153.2017.09.06.07.49.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Sep 2017 07:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2xI+Bv3Slue+8/Kr/D6CnEnYyj7+r0K2GR4PNLIeK1w=; b=B58WItzzpHolVSZDYnLf7nL9QAgdUNmPqjqUa7FRej+r/+noFFF9V6DQ0BRsDyQQ1z XoUdbKVS2fhehsJ5ZG0ikMn2plv2hhBwttnJgjwgXFSFEFyojSMDYnEDyPofqFCn0IYD EtzulzH0K7LyofX+FJtCKXeikjQ26u3xm4CEI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2xI+Bv3Slue+8/Kr/D6CnEnYyj7+r0K2GR4PNLIeK1w=; b=Eg2PhROjz//cuJ684iG4/187Sk1lVQjRgLbB12apeIgZ+8qmEDRJb+PBMOQ9KBwFBK HMwpdR62bIYuXGU/rWK8FnENHLsZbwpxi7GYp868QaHlFQ7Pgt7xBHq9r03afxRXoSqt i4ko7CGiW8ZbXUiYUNKQ7uym6sOf+McQRA9HoRnya18PQnoecn3bQZ67z9M84Ad64Wwd pZTG4s7UVu2UGjUKOv2ab/s0KzX6j0oWGUj3Uz7Q2a2hSuMssicpDx0FrAViilvCdfmY YKlrOhhvAMeLRg1VvW5khpsKjPIKfAFdgOx9DHK3a5ULK1SAGcafINhCOYqgM+Pqntlf iLmQ== X-Gm-Message-State: AHPjjUhiBLas9VTRCk80svOBMhtzRSFKWWp4IepqjR4/+XnqiPHBoIBd qVepr7xoeffeL7J+XPxzMA== X-Google-Smtp-Source: ADKCNb7/9XATXFaKFdgrMfr2ObytWceBlG02T7C90ViX7JQsUGcAh1tTzoHhB4p7sBi1tnYNS2nybQ== X-Received: by 10.99.121.66 with SMTP id u63mr7796176pgc.72.1504709393311; Wed, 06 Sep 2017 07:49:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 6 Sep 2017 07:49:34 -0700 Message-Id: <20170906144940.30880-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170906144940.30880-1-richard.henderson@linaro.org> References: <20170906144940.30880-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::232 Subject: [Qemu-devel] [PULL 08/14] tcg/s390: Merge cmpi facilities check to tcg_target_op_def X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Acked-by: Cornelia Huck Signed-off-by: Richard Henderson --- tcg/s390/tcg-target.inc.c | 68 +++++++++++++++++++++----------------------= ---- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c index d34649eb13..e075b4844a 100644 --- a/tcg/s390/tcg-target.inc.c +++ b/tcg/s390/tcg-target.inc.c @@ -41,7 +41,7 @@ #define TCG_CT_CONST_MULI 0x100 #define TCG_CT_CONST_ORI 0x200 #define TCG_CT_CONST_XORI 0x400 -#define TCG_CT_CONST_CMPI 0x800 +#define TCG_CT_CONST_U31 0x800 #define TCG_CT_CONST_ADLI 0x1000 #define TCG_CT_CONST_ZERO 0x2000 =20 @@ -398,7 +398,18 @@ static const char *target_parse_constraint(TCGArgConst= raint *ct, ct->ct |=3D TCG_CT_CONST_XORI; break; case 'C': - ct->ct |=3D TCG_CT_CONST_CMPI; + /* ??? We have no insight here into whether the comparison is + signed or unsigned. The COMPARE IMMEDIATE insn uses a 32-bit + signed immediate, and the COMPARE LOGICAL IMMEDIATE insn uses + a 32-bit unsigned immediate. If we were to use the (semi) + obvious "val =3D=3D (int32_t)val" we would be enabling unsigned + comparisons vs very large numbers. The only solution is to + take the intersection of the ranges. */ + /* ??? Another possible solution is to simply lie and allow all + constants here and force the out-of-range values into a temp + register in tgen_cmp when we have knowledge of the actual + comparison code in use. */ + ct->ct |=3D TCG_CT_CONST_U31; break; case 'Z': ct->ct |=3D TCG_CT_CONST_ZERO; @@ -463,35 +474,6 @@ static int tcg_match_xori(TCGType type, tcg_target_lon= g val) return 1; } =20 -/* Imediates to be used with comparisons. */ - -static int tcg_match_cmpi(TCGType type, tcg_target_long val) -{ - if (s390_facilities & FACILITY_EXT_IMM) { - /* The COMPARE IMMEDIATE instruction is available. */ - if (type =3D=3D TCG_TYPE_I32) { - /* We have a 32-bit immediate and can compare against anything= . */ - return 1; - } else { - /* ??? We have no insight here into whether the comparison is - signed or unsigned. The COMPARE IMMEDIATE insn uses a 32-b= it - signed immediate, and the COMPARE LOGICAL IMMEDIATE insn us= es - a 32-bit unsigned immediate. If we were to use the (semi) - obvious "val =3D=3D (int32_t)val" we would be enabling unsi= gned - comparisons vs very large numbers. The only solution is to - take the intersection of the ranges. */ - /* ??? Another possible solution is to simply lie and allow all - constants here and force the out-of-range values into a temp - register in tgen_cmp when we have knowledge of the actual - comparison code in use. */ - return val >=3D 0 && val <=3D 0x7fffffff; - } - } else { - /* Only the LOAD AND TEST instruction is available. */ - return val =3D=3D 0; - } -} - /* Immediates to be used with add2/sub2. */ =20 static int tcg_match_add2i(TCGType type, tcg_target_long val) @@ -537,8 +519,8 @@ static int tcg_target_const_match(tcg_target_long val, = TCGType type, return tcg_match_ori(type, val); } else if (ct & TCG_CT_CONST_XORI) { return tcg_match_xori(type, val); - } else if (ct & TCG_CT_CONST_CMPI) { - return tcg_match_cmpi(type, val); + } else if (ct & TCG_CT_CONST_U31) { + return val >=3D 0 && val <=3D 0x7fffffff; } else if (ct & TCG_CT_CONST_ZERO) { return val =3D=3D 0; } @@ -2252,7 +2234,9 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpc= ode op) static const TCGTargetOpDef r_r =3D { .args_ct_str =3D { "r", "r" } }; static const TCGTargetOpDef r_L =3D { .args_ct_str =3D { "r", "L" } }; static const TCGTargetOpDef L_L =3D { .args_ct_str =3D { "L", "L" } }; + static const TCGTargetOpDef r_ri =3D { .args_ct_str =3D { "r", "ri" } = }; static const TCGTargetOpDef r_rC =3D { .args_ct_str =3D { "r", "rC" } = }; + static const TCGTargetOpDef r_rZ =3D { .args_ct_str =3D { "r", "rZ" } = }; static const TCGTargetOpDef r_r_ri =3D { .args_ct_str =3D { "r", "r", = "ri" } }; static const TCGTargetOpDef r_0_ri =3D { .args_ct_str =3D { "r", "0", = "ri" } }; static const TCGTargetOpDef r_0_rK =3D { .args_ct_str =3D { "r", "0", = "rK" } }; @@ -2320,8 +2304,10 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOp= code op) return &r_r_ri; =20 case INDEX_op_brcond_i32: + /* Without EXT_IMM, only the LOAD AND TEST insn is available. */ + return (s390_facilities & FACILITY_EXT_IMM ? &r_ri : &r_rZ); case INDEX_op_brcond_i64: - return &r_rC; + return (s390_facilities & FACILITY_EXT_IMM ? &r_rC : &r_rZ); =20 case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: @@ -2366,16 +2352,22 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGO= pcode op) case INDEX_op_setcond_i32: case INDEX_op_setcond_i64: { - static const TCGTargetOpDef setc + /* Without EXT_IMM, only the LOAD AND TEST insn is available. = */ + static const TCGTargetOpDef setc_z + =3D { .args_ct_str =3D { "r", "r", "rZ" } }; + static const TCGTargetOpDef setc_c =3D { .args_ct_str =3D { "r", "r", "rC" } }; - return &setc; + return (s390_facilities & FACILITY_EXT_IMM ? &setc_c : &setc_z= ); } case INDEX_op_movcond_i32: case INDEX_op_movcond_i64: { - static const TCGTargetOpDef movc + /* Without EXT_IMM, only the LOAD AND TEST insn is available. = */ + static const TCGTargetOpDef movc_z + =3D { .args_ct_str =3D { "r", "r", "rZ", "r", "0" } }; + static const TCGTargetOpDef movc_c =3D { .args_ct_str =3D { "r", "r", "rC", "r", "0" } }; - return &movc; + return (s390_facilities & FACILITY_EXT_IMM ? &movc_c : &movc_z= ); } case INDEX_op_div2_i32: case INDEX_op_div2_i64: --=20 2.13.5