From patchwork Tue Aug 29 20:47:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 111256 Delivered-To: patch@linaro.org Received: by 10.140.95.112 with SMTP id h103csp1929288qge; Tue, 29 Aug 2017 13:52:51 -0700 (PDT) X-Received: by 10.237.53.115 with SMTP id b48mr7341549qte.299.1504039971423; Tue, 29 Aug 2017 13:52:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504039971; cv=none; d=google.com; s=arc-20160816; b=uufc4Ck1JweXNVP5MAz/5DYRlMZwyGS8jdAUZZQnvKWhTagl7nFtYP/TPK+yUoodFX T7KLoagg5Pt3e5LYrmm7P3dd2sNNUdIVDmifA/sFd2tqeGaDbldfMVH9K8sayzLWtBa0 JVZDO0SiKsiPQjTUPXB63yfv895+LP2J1kK3f3tu+JkL7PvEuMQRFdm/aV9ifgN51QCU gMWJVJxDKs7qtvs6zFhH+ofWTj560VjzEGBplp8pwFBGloBMtviLXt24umYi2naCjVkn QiPUb03SfpNlOHHy1qI8hw1NftnoIq+7QX6sK/dOXYMJURZ6WUoYcFCV4QAC8WpL6WrS HGDA== 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=z1QnsbS9MFumUozer0g7J9ZIxQh46hRZoXAWdZEeU2g=; b=a0Hkv8psmYAb2nth5qWXegatYHuH9wGb+e4smloQdFWqFkE2+sriLro+XwiPRtnft+ nFGLLar9fah+daZ5OeHXA8xqeNYzJLxAzrv8Hng54bpwB2mfHFcI2hPvTM9Ef6LERaA0 We8C856pKyFOIxQr7ghyUPv7Yx8Tyrpn6189uazkPdor/nuRjdV5MQXXrZFkLm8xp1Am 5JJi3/dDVWQp/brenozPFd3U5oXa1D93+oagOh6WYnKFWPbwwWyLey8eZ8yOLu1TLIW+ m2oUOYupzJbCAEAKGoQEG6oo8DcIrCCET2IvdrYTjuCugxvbx/V0smCVu7MpJMNBLV3e Tpxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BYS8IDyG; 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 u38si3782326qta.225.2017.08.29.13.52.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 29 Aug 2017 13:52:51 -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=BYS8IDyG; 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]:46910 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmnVB-0005xA-4Z for patch@linaro.org; Tue, 29 Aug 2017 16:52:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmnQj-0002TK-7x for qemu-devel@nongnu.org; Tue, 29 Aug 2017 16:48:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmnQh-0001VY-Po for qemu-devel@nongnu.org; Tue, 29 Aug 2017 16:48:13 -0400 Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]:33569) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dmnQh-0001VD-H9 for qemu-devel@nongnu.org; Tue, 29 Aug 2017 16:48:11 -0400 Received: by mail-pg0-x22a.google.com with SMTP id t3so14084237pgt.0 for ; Tue, 29 Aug 2017 13:48:11 -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=z1QnsbS9MFumUozer0g7J9ZIxQh46hRZoXAWdZEeU2g=; b=BYS8IDyGqL9lFbuMXw/72Hkdt/wOItGzn8WhJo4y9vNsHZMf0jDNVNoLaOjH8ilV8g EpMOLztN8HkxAWFqZ+wvc6rBSKVz4fvZYmbmyVuo83RzzvJov2lkTghl1E1w40e/ihNC PCyq75faA7KCODU0fpYUqUcr1P4Qp9mhYgDFA= 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=z1QnsbS9MFumUozer0g7J9ZIxQh46hRZoXAWdZEeU2g=; b=U6h1rGGrlhHnW+tpRFnIIbjQJEt6zqv17VdsUURo4/SlukmKGc6y+f3zb4FRi3wog4 pOW2QdyIw1xbOcXs47HMahiL1uwSB8B5OPynCrerHZY0qIENE0AxG98/GWdb7Q7VxXjP w/FlyEPnJ05z0OIKDJQm5XGld93+X9N88b3CCbcybYwSqSBRqCTyb4QTgyYag+7K2OV2 PlFRrjD/OEasAW0kDoQRKfvQZGBxqLxI7Aciv8NhaqGyeQRf4xp23yQR7+97IdLuvHnQ aywx+SPuZS47UIuPpn2GWOhXgdhD0qrxQEuToapz1lNJflnTavHsW7AyPHZq4Lz/8etE lkWQ== X-Gm-Message-State: AHYfb5gCFDr0pBvldLQug2pVQfkJHTbaEEOLIRg3xR806QAs+UKTeMVS AH6x6NpppHbvnCNnpU5GGw== X-Received: by 10.98.14.194 with SMTP id 63mr1619222pfo.80.1504039690175; Tue, 29 Aug 2017 13:48:10 -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.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Aug 2017 13:48:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 29 Aug 2017 13:47:56 -0700 Message-Id: <20170829204759.6853-6-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::22a Subject: [Qemu-devel] [PATCH 5/8] tcg/s390: Merge ori+xori 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 | 101 +++++++++++++++------------------------------- 1 file changed, 33 insertions(+), 68 deletions(-) -- 2.13.5 diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c index 6b08ccea6d..5414c9d879 100644 --- a/tcg/s390/tcg-target.inc.c +++ b/tcg/s390/tcg-target.inc.c @@ -40,8 +40,8 @@ #define TCG_CT_CONST_S16 0x100 #define TCG_CT_CONST_S32 0x200 -#define TCG_CT_CONST_ORI 0x400 -#define TCG_CT_CONST_XORI 0x800 +#define TCG_CT_CONST_NN16 0x400 +#define TCG_CT_CONST_NN32 0x800 #define TCG_CT_CONST_U31 0x1000 #define TCG_CT_CONST_S33 0x2000 #define TCG_CT_CONST_ZERO 0x4000 @@ -395,11 +395,11 @@ static const char *target_parse_constraint(TCGArgConstraint *ct, case 'J': ct->ct |= TCG_CT_CONST_S32; break; - case 'O': - ct->ct |= TCG_CT_CONST_ORI; + case 'N': + ct->ct |= TCG_CT_CONST_NN16; break; - case 'X': - ct->ct |= TCG_CT_CONST_XORI; + case 'M': + ct->ct |= TCG_CT_CONST_NN32; break; case 'C': /* ??? We have no insight here into whether the comparison is @@ -424,60 +424,6 @@ static const char *target_parse_constraint(TCGArgConstraint *ct, return ct_str; } -/* Immediates to be used with logical OR. This is an optimization only, - since a full 64-bit immediate OR can always be performed with 4 sequential - OI[LH][LH] instructions. What we're looking for is immediates that we - can load efficiently, and the immediate load plus the reg-reg OR is - smaller than the sequential OI's. */ - -static int tcg_match_ori(TCGType type, tcg_target_long val) -{ - if (s390_facilities & FACILITY_EXT_IMM) { - if (type == TCG_TYPE_I32) { - /* All 32-bit ORs can be performed with 1 48-bit insn. */ - return 1; - } - } - - /* Look for negative values. These are best to load with LGHI. */ - if (val < 0) { - if (val == (int16_t)val) { - return 0; - } - if (s390_facilities & FACILITY_EXT_IMM) { - if (val == (int32_t)val) { - return 0; - } - } - } - - return 1; -} - -/* Immediates to be used with logical XOR. This is almost, but not quite, - only an optimization. XOR with immediate is only supported with the - extended-immediate facility. That said, there are a few patterns for - which it is better to load the value into a register first. */ - -static int tcg_match_xori(TCGType type, tcg_target_long val) -{ - if ((s390_facilities & FACILITY_EXT_IMM) == 0) { - return 0; - } - - if (type == TCG_TYPE_I32) { - /* All 32-bit XORs can be performed with 1 48-bit insn. */ - return 1; - } - - /* Look for negative values. These are best to load with LGHI. */ - if (val < 0 && val == (int32_t)val) { - return 0; - } - - return 1; -} - /* Test if a constant matches the constraint. */ static int tcg_target_const_match(tcg_target_long val, TCGType type, const TCGArgConstraint *arg_ct) @@ -499,10 +445,10 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type, return val == (int32_t)val; } else if (ct & TCG_CT_CONST_S33) { return val >= -0xffffffffll && val <= 0xffffffffll; - } else if (ct & TCG_CT_CONST_ORI) { - 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_NN16) { + return !(val < 0 && val == (int16_t)val); + } else if (ct & TCG_CT_CONST_NN32) { + return !(val < 0 && val == (int32_t)val); } else if (ct & TCG_CT_CONST_U31) { return val >= 0 && val <= 0x7fffffff; } else if (ct & TCG_CT_CONST_ZERO) { @@ -2222,11 +2168,12 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) 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_r = { .args_ct_str = { "r", "0", "r" } }; static const TCGTargetOpDef r_0_ri = { .args_ct_str = { "r", "0", "ri" } }; static const TCGTargetOpDef r_0_rI = { .args_ct_str = { "r", "0", "rI" } }; static const TCGTargetOpDef r_0_rJ = { .args_ct_str = { "r", "0", "rJ" } }; - static const TCGTargetOpDef r_0_rO = { .args_ct_str = { "r", "0", "rO" } }; - static const TCGTargetOpDef r_0_rX = { .args_ct_str = { "r", "0", "rX" } }; + static const TCGTargetOpDef r_0_rN = { .args_ct_str = { "r", "0", "rN" } }; + static const TCGTargetOpDef r_0_rM = { .args_ct_str = { "r", "0", "rM" } }; static const TCGTargetOpDef a2_r = { .args_ct_str = { "r", "r", "0", "1", "r", "r" } }; static const TCGTargetOpDef a2_ri @@ -2275,11 +2222,29 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) return (s390_facilities & FACILITY_GEN_INST_EXT ? &r_0_rJ : &r_0_rI); case INDEX_op_or_i32: + /* The use of [iNM] constraints are optimization only, since a full + 64-bit immediate OR can always be performed with 4 sequential + OI[LH][LH] instructions. By rejecting certain negative ranges, + the immediate load plus the reg-reg OR is smaller. */ + return (s390_facilities & FACILITY_EXT_IMM + ? &r_0_ri + : &r_0_rN); case INDEX_op_or_i64: - return &r_0_rO; + return (s390_facilities & FACILITY_EXT_IMM + ? &r_0_rM + : &r_0_rN); + case INDEX_op_xor_i32: + /* Without EXT_IMM, no immediates are supported. Otherwise, + rejecting certain negative ranges leads to smaller code. */ + return (s390_facilities & FACILITY_EXT_IMM + ? &r_0_ri + : &r_0_r); case INDEX_op_xor_i64: - return &r_0_rX; + return (s390_facilities & FACILITY_EXT_IMM + ? &r_0_rM + : &r_0_r); + case INDEX_op_and_i32: case INDEX_op_and_i64: return &r_0_ri;