From patchwork Thu Sep 7 22:40:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 111971 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp720388qge; Thu, 7 Sep 2017 15:41:53 -0700 (PDT) X-Received: by 10.200.40.27 with SMTP id 27mr1387694qtq.148.1504824113459; Thu, 07 Sep 2017 15:41:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504824113; cv=none; d=google.com; s=arc-20160816; b=K4Ji+qSf3z7Iumcrk+SnZzcgdb3v4xSAetDVzky2EmTXnQwMCVsAFtTxZOfsCTSZEQ 2p1tsl/2bL/yeGKouyqYRC/FL6x1dutBamb5qcQ9RoBD/eR5zE0nSfc2BHtrHYirHoQV 1Zp/Un91inJxz/YyI693nRhaeRduBfkCK/8hrPydiKJ6+CFKsxwn5n2w/kxahBRBC01k iSW+5Edc0M9GYOAXqWK1CB/LPozI9KIYC8DuErBXINYi1iUr55vHwKF4xhQJM9jlmHFg xwSJhu+J9VJiiniNw5WHk25bAHo39r8hfRkLQlgsk1Z5auucNgqyXYD8xLC42TW3g9jc 00EA== 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=oyI5YSLX1e92RjCHfsEWw9AulBFo8RWIJPmlBultFFM=; b=rJVRWr2B6zZ+mM67MHBK9tCbXvLgasDhp4xr31K0XV434iEAEfAy3ptqbkXVDxGDWk YIzH2rhWdUFhtNRbAsOgUM2WCwk4BRQhWU65wVH8swVGC/T06SStGgh2Syjwwnlj8fwe aMbipNlzmZie9YTFOZpfybP+gim/OjhwvL0VbH/ZPtkVvF07c5f0+4H8PYqMJm38M69S x+g/zdHF8S5cwPycUY5GMxiHQ2J1pBfE+bsPYYnZJeN9VO8BIk2Dr/XiSpKyrZf4No0h d9CQ128W9hGMHS5AKMvndj7VBhKJzHxCgDFwWuRyFUqk8RX8FMloxYvr83+LeEWsGAeI MerA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PIKpuhUK; 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 61si488914qtg.119.2017.09.07.15.41.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 15:41:53 -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=PIKpuhUK; 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]:42518 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dq5Ud-0003Bn-5b for patch@linaro.org; Thu, 07 Sep 2017 18:41:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dq5U3-000369-GA for qemu-devel@nongnu.org; Thu, 07 Sep 2017 18:41:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dq5Ty-0008DF-Jc for qemu-devel@nongnu.org; Thu, 07 Sep 2017 18:41:15 -0400 Received: from mail-pg0-x22c.google.com ([2607:f8b0:400e:c05::22c]:37895) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dq5Ty-0008C0-BN for qemu-devel@nongnu.org; Thu, 07 Sep 2017 18:41:10 -0400 Received: by mail-pg0-x22c.google.com with SMTP id v66so1788427pgb.5 for ; Thu, 07 Sep 2017 15:41:10 -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=oyI5YSLX1e92RjCHfsEWw9AulBFo8RWIJPmlBultFFM=; b=PIKpuhUKOZHlwiaDmyMEaOKOpsvHB8dTCxeqBlty/hWy0tSU885F+wlpuulnFDmNvn /jV6zg1WsTpSQ3+070mcpttW6nkPMDs8Z2a8Hai3gs+W4Ie1UOMtFPKrxfad3lCSOgr7 xYDanSt5p2QhhSMlMhLLUJ7J9dMRkLwjSj3E8= 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=oyI5YSLX1e92RjCHfsEWw9AulBFo8RWIJPmlBultFFM=; b=OdrnqWCcJLaQMstqRtVY/zE8z5hIRIMXYNa/W7ouID4oGGaXDW523HPp1ddgFbyjh2 7CRTwKPrYfW5RgEF/zFHMmMgbMeb4O11sEnqVsMmSToRKb9CEztj/erBlzkrcixAHxXT mMar1pgNIw0zDSZPiz0uMnODl741I4RwKy0hAACvTJ/yHnvopX74VxqEGVoQzV49NVTI qB0oAgknqlIPFcxBJmtlNp7EC7UE0ee0lV8JqjTTFmIDzS5vyQ/bEr5oCcVh95Nftyl0 7Q3ZcPIuNvDQY4O6QAqeNs6aSWHSLe4PO86r/o5Y0W3a5uRQKDKqLQ6nW3caNvOI5gwP NwgA== X-Gm-Message-State: AHPjjUgh45D+sb9OhxiTLzMk6SyXvUDlPt2VskJ0JK75PzsCVNyNqYSM +4J+3Cq/al4yX8L7FvSffg== X-Google-Smtp-Source: ADKCNb7+HSU0Xs3a9D0YfO+yKlMhCWAeRIK/U6R0fSNsABv0LeV6c3l0XURlFJApHd6Q874iGaDvNw== X-Received: by 10.99.181.23 with SMTP id y23mr934634pge.191.1504824069009; Thu, 07 Sep 2017 15:41:09 -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 h19sm770678pfh.142.2017.09.07.15.41.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Sep 2017 15:41:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 15:40:38 -0700 Message-Id: <20170907224051.21518-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170907224051.21518-1-richard.henderson@linaro.org> References: <20170907224051.21518-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::22c Subject: [Qemu-devel] [PULL 10/23] tcg/s390: Use constant pool for xori 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Signed-off-by: Richard Henderson --- tcg/s390/tcg-target.inc.c | 77 ++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 37 deletions(-) -- 2.13.5 diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c index 83fac71c31..b0b34fa5ab 100644 --- a/tcg/s390/tcg-target.inc.c +++ b/tcg/s390/tcg-target.inc.c @@ -39,11 +39,9 @@ #define TCG_CT_CONST_S16 0x100 #define TCG_CT_CONST_S32 0x200 -#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 +#define TCG_CT_CONST_U31 0x400 +#define TCG_CT_CONST_S33 0x800 +#define TCG_CT_CONST_ZERO 0x1000 /* Several places within the instruction set 0 means "no register" rather than TCG_REG_R0. */ @@ -234,6 +232,7 @@ typedef enum S390Opcode { RXY_STRVG = 0xe32f, RXY_STRVH = 0xe33f, RXY_STY = 0xe350, + RXY_XG = 0xe382, RX_A = 0x5a, RX_C = 0x59, @@ -424,12 +423,6 @@ static const char *target_parse_constraint(TCGArgConstraint *ct, case 'J': ct->ct |= TCG_CT_CONST_S32; break; - case 'N': - ct->ct |= TCG_CT_CONST_NN16; - break; - case 'M': - ct->ct |= TCG_CT_CONST_NN32; - break; case 'C': /* ??? We have no insight here into whether the comparison is signed or unsigned. The COMPARE IMMEDIATE insn uses a 32-bit @@ -474,10 +467,6 @@ 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_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) { @@ -1062,14 +1051,40 @@ static void tgen_ori(TCGContext *s, TCGType type, TCGReg dest, uint64_t val) } } -static void tgen64_xori(TCGContext *s, TCGReg dest, tcg_target_ulong val) +static void tgen_xori(TCGContext *s, TCGType type, TCGReg dest, uint64_t val) { - /* Perform the xor by parts. */ - if (val & 0xffffffff) { - tcg_out_insn(s, RIL, XILF, dest, val); + /* Try all 48-bit insns that can perform it in one go. */ + if (s390_facilities & FACILITY_EXT_IMM) { + if ((val & 0xffffffff00000000ull) == 0) { + tcg_out_insn(s, RIL, XILF, dest, val); + return; + } + if ((val & 0x00000000ffffffffull) == 0) { + tcg_out_insn(s, RIL, XIHF, dest, val >> 32); + return; + } } - if (val > 0xffffffff) { - tcg_out_insn(s, RIL, XIHF, dest, val >> 31 >> 1); + + /* Use the constant pool if USE_REG_TB, but not for small constants. */ + if (maybe_out_small_movi(s, type, TCG_TMP0, val)) { + if (type == TCG_TYPE_I32) { + tcg_out_insn(s, RR, XR, dest, TCG_TMP0); + } else { + tcg_out_insn(s, RRE, XGR, dest, TCG_TMP0); + } + } else if (USE_REG_TB) { + tcg_out_insn(s, RXY, XG, dest, TCG_REG_TB, TCG_REG_NONE, 0); + new_pool_label(s, val, R_390_20, s->code_ptr - 2, + -(intptr_t)s->code_gen_ptr); + } else { + /* Perform the xor by parts. */ + tcg_debug_assert(s390_facilities & FACILITY_EXT_IMM); + if (val & 0xffffffff) { + tcg_out_insn(s, RIL, XILF, dest, val); + } + if (val > 0xffffffff) { + tcg_out_insn(s, RIL, XIHF, dest, val >> 32); + } } } @@ -1889,7 +1904,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, a0 = args[0], a1 = args[1], a2 = (uint32_t)args[2]; if (const_args[2]) { tcg_out_mov(s, TCG_TYPE_I32, a0, a1); - tgen64_xori(s, a0, a2); + tgen_xori(s, TCG_TYPE_I32, a0, a2); } else if (a0 == a1) { tcg_out_insn(s, RR, XR, args[0], args[2]); } else { @@ -2121,7 +2136,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, a0 = args[0], a1 = args[1], a2 = args[2]; if (const_args[2]) { tcg_out_mov(s, TCG_TYPE_I64, a0, a1); - tgen64_xori(s, a0, a2); + tgen_xori(s, TCG_TYPE_I64, a0, a2); } else if (a0 == a1) { tcg_out_insn(s, RRE, XGR, a0, a2); } else { @@ -2313,12 +2328,9 @@ 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_r_rM = { .args_ct_str = { "r", "r", "rM" } }; - 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_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 @@ -2360,6 +2372,8 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) case INDEX_op_and_i64: case INDEX_op_or_i32: case INDEX_op_or_i64: + case INDEX_op_xor_i32: + case INDEX_op_xor_i64: return (s390_facilities & FACILITY_DISTINCT_OPS ? &r_r_ri : &r_0_ri); case INDEX_op_mul_i32: @@ -2370,17 +2384,6 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) case INDEX_op_mul_i64: return (s390_facilities & FACILITY_GEN_INST_EXT ? &r_0_rJ : &r_0_rI); - 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 - ? (s390_facilities & FACILITY_DISTINCT_OPS ? &r_r_ri : &r_0_ri) - : &r_0_r); - case INDEX_op_xor_i64: - return (s390_facilities & FACILITY_EXT_IMM - ? (s390_facilities & FACILITY_DISTINCT_OPS ? &r_r_rM : &r_0_rM) - : &r_0_r); - case INDEX_op_shl_i32: case INDEX_op_shr_i32: case INDEX_op_sar_i32: