From patchwork Tue Aug 29 20:47:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 111251 Delivered-To: patch@linaro.org Received: by 10.140.95.112 with SMTP id h103csp1924941qge; Tue, 29 Aug 2017 13:48:32 -0700 (PDT) X-Received: by 10.200.36.48 with SMTP id c45mr7260385qtc.263.1504039712676; Tue, 29 Aug 2017 13:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504039712; cv=none; d=google.com; s=arc-20160816; b=T1Q5EkiYPTKpFCzuCJ4rpxZw9kikFcUbxe6glR9RtC0VJkQ4D74re1HWbFMDED2DwN eFT7tpTHkYeC4MEJCuhM3nJaps4hKfzLxb+GotauHsP36/6t9NM1O4MBedGaJl6a22sm SyTylPJlVsOEeNWOKhiYfMNycycA/wUV2a4lIrOfdJYYSPx7HwTEbB3lZVqCqc6gW661 Wo1yDchOu6Xbv0XRaFkpXJaidJFVr1w6Nq+bTeY0Wf7xXuxH3QWYkFbW8cQYmYQ+AZ+0 +onvxvOcMnYHE6JxHnx6xI7eqTjlXfRkxLwgJRn1ZKH9Q+4P9pYx4iAX5l3O8ZOmZo4M JwiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=IkhOz8fuRRbqd88aKtALrzqnsmouosc8HzWR3BAvgGo=; b=Q2U9MLW6aug861LU0ZAu5hYBB7cnAGzU0HF8+ZSwhrAohZaqZ2VDc540+KbllpzPB8 MTn6Bu9VZXNB68I6ha9rbXq7Aj7Sm5EMlYBvcDcs42RhmDhY+2dZxgKOilzAkjNbTv8e sCUytOqnxnsGyE6VrOr8C2lwq7S7g/d2JWumZS9boFXt2WjOE+wdlYEZZ7LZUONwS3wn Ae1SQtYINy687atmxgzok40qdE/DCLB5h6Fv5XX2C19b5jShpcwNhfkXNBu0mmXymqF5 Y0tKg0AxsBnGhftbPaKyJlQlyKON0lBQApxZaFLtbeaM6+u6/Uoycq/hIUsNSMBN7eFA 6PBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iMIjUXj5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d26si3743522qte.7.2017.08.29.13.48.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 29 Aug 2017 13:48:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iMIjUXj5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmnR0-0002RH-Ek for patch@linaro.org; Tue, 29 Aug 2017 16:48:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmnQe-0002Qj-Ce for qemu-devel@nongnu.org; Tue, 29 Aug 2017 16:48:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmnQc-0001Tn-TK for qemu-devel@nongnu.org; Tue, 29 Aug 2017 16:48:08 -0400 Received: from mail-pg0-x22e.google.com ([2607:f8b0:400e:c05::22e]:38035) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dmnQc-0001TR-M5 for qemu-devel@nongnu.org; Tue, 29 Aug 2017 16:48:06 -0400 Received: by mail-pg0-x22e.google.com with SMTP id b8so13996915pgn.5 for ; Tue, 29 Aug 2017 13:48:06 -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=IkhOz8fuRRbqd88aKtALrzqnsmouosc8HzWR3BAvgGo=; b=iMIjUXj5JgBytASQIkrvzL+ci3mugMs0cs9RVGei3DZAWe8yXJvz2k/LfVgqxHk7cv FP0mwRVJlwvt45Ir7RCEL6+i/xyIw3FPkAOEGnyvrN/taQlIf3Dc8IqssFF/bIs9mV8/ 90jW/CLMh7UninvYgiZzwf0dtdM2+qVUVmi9c= 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=IkhOz8fuRRbqd88aKtALrzqnsmouosc8HzWR3BAvgGo=; b=WBV5S7mq+SYdcbV/E3wwmq4Dhklos/fIH4yXf6nwZ1trpSQEuV04AYdak9SABvVOTc SxzUmPQK9Ge/kvC1taOzGzhyVsSl/OzEWKLylL2O0LjrLEizQK0HEFXSGxo4XnXrL3E1 19/+k4t7yMZqibGGvWDlWHBbPGsiTbYymtj/mTyVKqu2l2qbChhOiqgmnMLJTlQNoZQ+ WqnnsNwEUDp/YXlVggEDQ23A+ZK1wFj4fsrdSNUKb2NvcRBYK/GsvffzjVoxCRinWAVN QQHEVX5mDFKSopb77c2WdbwCbjfRYzYNr+pvAfrNavP00qm4MfkTHSXFlR5KZB+Oo+nc Ez1w== X-Gm-Message-State: AHYfb5hPD+NguLN6tbhYPQcjIfzZMzWT/Z53O6ZvizHrxXtqmacvl4QO GNHb3iw1Sw0PLJH6DhzvAA== X-Received: by 10.99.0.211 with SMTP id 202mr1448497pga.405.1504039685335; Tue, 29 Aug 2017 13:48:05 -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 i84sm6633646pfj.139.2017.08.29.13.48.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Aug 2017 13:48:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 29 Aug 2017 13:47:53 -0700 Message-Id: <20170829204759.6853-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170829204759.6853-1-richard.henderson@linaro.org> References: <20170829204759.6853-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::22e Subject: [Qemu-devel] [PATCH 2/8] 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: borntraeger@de.ibm.com, cohuck@redhat.com, agraf@suse.de, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Signed-off-by: Richard Henderson --- tcg/s390/tcg-target.inc.c | 68 +++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 38 deletions(-) -- 2.13.5 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 @@ -398,7 +398,18 @@ static const char *target_parse_constraint(TCGArgConstraint *ct, ct->ct |= TCG_CT_CONST_XORI; break; case 'C': - ct->ct |= 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 == (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 |= TCG_CT_CONST_U31; break; case 'Z': ct->ct |= TCG_CT_CONST_ZERO; @@ -463,35 +474,6 @@ static int tcg_match_xori(TCGType type, tcg_target_long val) return 1; } -/* 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 == 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-bit - signed immediate, and the COMPARE LOGICAL IMMEDIATE insn uses - a 32-bit unsigned immediate. If we were to use the (semi) - obvious "val == (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. */ - return val >= 0 && val <= 0x7fffffff; - } - } else { - /* Only the LOAD AND TEST instruction is available. */ - return val == 0; - } -} - /* Immediates to be used with add2/sub2. */ 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 >= 0 && val <= 0x7fffffff; } else if (ct & TCG_CT_CONST_ZERO) { return val == 0; } @@ -2252,7 +2234,9 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) static const TCGTargetOpDef r_r = { .args_ct_str = { "r", "r" } }; static const TCGTargetOpDef r_L = { .args_ct_str = { "r", "L" } }; static const TCGTargetOpDef L_L = { .args_ct_str = { "L", "L" } }; + static const TCGTargetOpDef r_ri = { .args_ct_str = { "r", "ri" } }; static const TCGTargetOpDef r_rC = { .args_ct_str = { "r", "rC" } }; + static const TCGTargetOpDef r_rZ = { .args_ct_str = { "r", "rZ" } }; static const TCGTargetOpDef r_r_ri = { .args_ct_str = { "r", "r", "ri" } }; static const TCGTargetOpDef r_0_ri = { .args_ct_str = { "r", "0", "ri" } }; static const TCGTargetOpDef r_0_rK = { .args_ct_str = { "r", "0", "rK" } }; @@ -2320,8 +2304,10 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) return &r_r_ri; 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); case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: @@ -2366,16 +2352,22 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode 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 + = { .args_ct_str = { "r", "r", "rZ" } }; + static const TCGTargetOpDef setc_c = { .args_ct_str = { "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 + = { .args_ct_str = { "r", "r", "rZ", "r", "0" } }; + static const TCGTargetOpDef movc_c = { .args_ct_str = { "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: