From patchwork Tue Aug 29 20:47:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 111259 Delivered-To: patch@linaro.org Received: by 10.140.95.112 with SMTP id h103csp1936654qge; Tue, 29 Aug 2017 14:00:12 -0700 (PDT) X-Received: by 10.55.48.71 with SMTP id w68mr7163131qkw.345.1504040412941; Tue, 29 Aug 2017 14:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504040412; cv=none; d=google.com; s=arc-20160816; b=QB9Hfg2fNC6IxZMft2LCvXXo2LVttrJswvMob0ivL8ipY2yjTWXL+IaoGi34BTS+r1 DQ0f4hWt4l9yHrIAwc0wZ37Q+BTMSCPzm7lWdAIAAWrUaZVLQbHJAZpHfSB0amN1F0dq zOshZgrLJzR6rEj+Sw3hlrjjOqMSwQv2biqf37Xi5+qx8fOqyBJiyjZLt5UFHRzMoeD7 hHFnK8XXAQ26QzJobq52CA3qf1M271nzAdIsEI96Bn+90FxTa9M0RgkSnMu5dPrOdMuP V3DpDHUH8JvqwQprRCl/HDbqfKgfvRY17Z8HjenhRRXHoLQN+CK+KOfJmNa/Sk/zn2wi K+OQ== 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=kDmH5DemrkbAsivBHhbt4U1wgoxR7gHo6X6o0mKr35Y=; b=NLmsh376391OTDyEi6Jep2tbcZg/8s781cuxt3D8ujoo7zDzwwXBxgLCBv3+XjTnKj 1kPZLfRvVT+VJDJ0U6HuLPM9GqzqdD2rudGaciY2ET05lS+O1ajnOteM83xd29tpo+QO NOT1Bskgp/X2brazVtYWNp8eOL964UyIZ8VN0a1DfoVm1KuD53ydSZ7V+sRPbbTy+osd rE6sPklbPZHN4bp90t6dPWhudLjoOThx8QkBFwL/CCv+8HG2w8XbU/Jl4PkkkjZYoBz6 KostQoTX8YRtz4UWiEYC5/J2pP7MQjOp8Cc9GCw1DpYyguIQ38pZbBW+AUkddzYgrIO3 viXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hECew1pg; 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 30si3724091qtv.153.2017.08.29.14.00.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 29 Aug 2017 14:00:12 -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=hECew1pg; 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]:46948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmncI-0004L9-LG for patch@linaro.org; Tue, 29 Aug 2017 17:00:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmnQn-0002Xg-UW for qemu-devel@nongnu.org; Tue, 29 Aug 2017 16:48:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmnQk-0001WE-Sk for qemu-devel@nongnu.org; Tue, 29 Aug 2017 16:48:18 -0400 Received: from mail-pg0-x235.google.com ([2607:f8b0:400e:c05::235]:35710) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dmnQk-0001W3-K2 for qemu-devel@nongnu.org; Tue, 29 Aug 2017 16:48:14 -0400 Received: by mail-pg0-x235.google.com with SMTP id 63so13983565pgc.2 for ; Tue, 29 Aug 2017 13:48:14 -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=kDmH5DemrkbAsivBHhbt4U1wgoxR7gHo6X6o0mKr35Y=; b=hECew1pgXDIyJF5AHC3RS8bJYqymq5Xtc2Fm53p3a2MFnOuOEv/UMNdMS9xXN40eq5 +/tPYfcKxL/otNj+razhKZcHza+dLa4FHNNS+UI5fuz78MLz5/A+6nTVfQs8ZvpYcZfU KF93wsR2tgcVpw8GBROjjEk3yu40+L8lc7vtE= 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=kDmH5DemrkbAsivBHhbt4U1wgoxR7gHo6X6o0mKr35Y=; b=s8s8ji2QtBMoxwHaO2W6haFO8bFt6gchdUti9uuTkbcJcwolLRzsiGTRCmRBrIAkCu 00Q3Sp0002/nNKfyTr8Bh+lilYNoEf+64Yf77lUctm8toT8/HCRbiDMcVioKu8vbJRBc EGVU78Q2p9KC0YTpP0kUTzHwOEkG4MzU6gFRAAvreIfNp91qvMDsKQJWhnJWjdMLGZGu UmxPOAt4DbWelSK/n/WrFUdJQMOcZMeTgd0GbmRcU/jmcd27bZ6R6VO8LFT470CGvsz9 ERyJrCVhSZHGp0drtIJo2yjqr3bOW+blV2hMFv1tvVgjcdXAePMG5NPSwy5vxOPQsJTu VoKA== X-Gm-Message-State: AHYfb5hqfDCjYwQalhDxOexwgCTukK7FP9t4jF3CKNOK/kMsJRo5geIY EfKgapTCbcwaRdfihknBQw== X-Received: by 10.84.218.14 with SMTP id q14mr1950239pli.286.1504039693220; Tue, 29 Aug 2017 13:48:13 -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.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Aug 2017 13:48:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 29 Aug 2017 13:47:58 -0700 Message-Id: <20170829204759.6853-8-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::235 Subject: [Qemu-devel] [PATCH 7/8] tcg/s390: Use load-on-condition-2 facility 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 This allows LOAD HALFWORD IMMEDIATE ON CONDITION, eliminating one insn in some common cases. Signed-off-by: Richard Henderson --- tcg/s390/tcg-target.h | 1 + tcg/s390/tcg-target.inc.c | 79 +++++++++++++++++++++++++++++++++++++---------- 2 files changed, 63 insertions(+), 17 deletions(-) -- 2.13.5 diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index 1b5eb22c26..81fc179459 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -59,6 +59,7 @@ typedef enum TCGReg { #define FACILITY_LOAD_ON_COND (1ULL << (63 - 45)) #define FACILITY_FAST_BCR_SER FACILITY_LOAD_ON_COND #define FACILITY_DISTINCT_OPS FACILITY_LOAD_ON_COND +#define FACILITY_LOAD_ON_COND2 (1ULL << (63 - 53)) extern uint64_t s390_facilities; diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c index a80b07db65..0de968fde2 100644 --- a/tcg/s390/tcg-target.inc.c +++ b/tcg/s390/tcg-target.inc.c @@ -122,6 +122,7 @@ typedef enum S390Opcode { RIE_CLGIJ = 0xec7d, RIE_CLRJ = 0xec77, RIE_CRJ = 0xec76, + RIE_LOCGHI = 0xec46, RIE_RISBG = 0xec55, RRE_AGR = 0xb908, @@ -495,6 +496,13 @@ static void tcg_out_insn_RI(TCGContext *s, S390Opcode op, TCGReg r1, int i2) tcg_out32(s, (op << 16) | (r1 << 20) | (i2 & 0xffff)); } +static void tcg_out_insn_RIE(TCGContext *s, S390Opcode op, TCGReg r1, + int i2, int m3) +{ + tcg_out16(s, (op & 0xff00) | (r1 << 4) | m3); + tcg_out32(s, (i2 << 16) | (op & 0xff)); +} + static void tcg_out_insn_RIL(TCGContext *s, S390Opcode op, TCGReg r1, int i2) { tcg_out16(s, op | (r1 << 4)); @@ -1063,7 +1071,20 @@ static void tgen_setcond(TCGContext *s, TCGType type, TCGCond cond, TCGReg dest, TCGReg c1, TCGArg c2, int c2const) { int cc; + bool have_loc; + /* With LOC2, we can always emit the minimum 3 insns. */ + if (s390_facilities & FACILITY_LOAD_ON_COND2) { + /* Emit: d = 0, d = (cc ? 1 : d). */ + cc = tgen_cmp(s, type, cond, c1, c2, c2const, false); + tcg_out_movi(s, TCG_TYPE_I64, dest, 0); + tcg_out_insn(s, RIE, LOCGHI, dest, 1, cc); + return; + } + + have_loc = (s390_facilities & FACILITY_LOAD_ON_COND) != 0; + + /* For HAVE_LOC, only the path through do_greater is smaller. */ switch (cond) { case TCG_COND_GTU: case TCG_COND_GT: @@ -1076,6 +1097,9 @@ static void tgen_setcond(TCGContext *s, TCGType type, TCGCond cond, return; case TCG_COND_GEU: + if (have_loc) { + goto do_loc; + } do_geu: /* We need "real" carry semantics, so use SUBTRACT LOGICAL instead of COMPARE LOGICAL. This may need an extra move. */ @@ -1105,10 +1129,17 @@ static void tgen_setcond(TCGContext *s, TCGType type, TCGCond cond, return; case TCG_COND_LEU: + if (have_loc) { + goto do_loc; + } + /* fallthru */ case TCG_COND_LTU: case TCG_COND_LT: /* Swap operands so that we can use GEU/GTU/GT. */ if (c2const) { + if (have_loc) { + goto do_loc; + } tcg_out_movi(s, type, TCG_TMP0, c2); c2 = c1; c2const = 0; @@ -1133,6 +1164,9 @@ static void tgen_setcond(TCGContext *s, TCGType type, TCGCond cond, break; case TCG_COND_EQ: + if (have_loc) { + goto do_loc; + } /* X == 0 is X <= 0 is 0 >= X. */ if (c2const && c2 == 0) { tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 0); @@ -1148,33 +1182,39 @@ static void tgen_setcond(TCGContext *s, TCGType type, TCGCond cond, } cc = tgen_cmp(s, type, cond, c1, c2, c2const, false); - if (s390_facilities & FACILITY_LOAD_ON_COND) { - /* Emit: d = 0, t = 1, d = (cc ? t : d). */ - tcg_out_movi(s, TCG_TYPE_I64, dest, 0); - tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 1); - tcg_out_insn(s, RRF, LOCGR, dest, TCG_TMP0, cc); - } else { - /* Emit: d = 1; if (cc) goto over; d = 0; over: */ - tcg_out_movi(s, type, dest, 1); - tcg_out_insn(s, RI, BRC, cc, (4 + 4) >> 1); - tcg_out_movi(s, type, dest, 0); - } + /* Emit: d = 1; if (cc) goto over; d = 0; over: */ + tcg_out_movi(s, type, dest, 1); + tcg_out_insn(s, RI, BRC, cc, (4 + 4) >> 1); + tcg_out_movi(s, type, dest, 0); + return; + + do_loc: + cc = tgen_cmp(s, type, cond, c1, c2, c2const, false); + /* Emit: d = 0, t = 1, d = (cc ? t : d). */ + tcg_out_movi(s, TCG_TYPE_I64, dest, 0); + tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 1); + tcg_out_insn(s, RRF, LOCGR, dest, TCG_TMP0, cc); } static void tgen_movcond(TCGContext *s, TCGType type, TCGCond c, TCGReg dest, - TCGReg c1, TCGArg c2, int c2const, TCGReg r3) + TCGReg c1, TCGArg c2, int c2const, + TCGArg v3, int v3const) { int cc; if (s390_facilities & FACILITY_LOAD_ON_COND) { cc = tgen_cmp(s, type, c, c1, c2, c2const, false); - tcg_out_insn(s, RRF, LOCGR, dest, r3, cc); + if (v3const) { + tcg_out_insn(s, RIE, LOCGHI, dest, v3, cc); + } else { + tcg_out_insn(s, RRF, LOCGR, dest, v3, cc); + } } else { c = tcg_invert_cond(c); cc = tgen_cmp(s, type, c, c1, c2, c2const, false); /* Emit: if (cc) goto over; dest = r3; over: */ tcg_out_insn(s, RI, BRC, cc, (4 + 4) >> 1); - tcg_out_insn(s, RRE, LGR, dest, r3); + tcg_out_insn(s, RRE, LGR, dest, v3); } } @@ -1937,7 +1977,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_movcond_i32: tgen_movcond(s, TCG_TYPE_I32, args[5], args[0], args[1], - args[2], const_args[2], args[3]); + args[2], const_args[2], args[3], const_args[3]); break; case INDEX_op_qemu_ld_i32: @@ -2170,7 +2210,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_movcond_i64: tgen_movcond(s, TCG_TYPE_I64, args[5], args[0], args[1], - args[2], const_args[2], args[3]); + args[2], const_args[2], args[3], const_args[3]); break; OP_32_64(deposit): @@ -2391,7 +2431,12 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) = { .args_ct_str = { "r", "r", "rZ", "r", "0" } }; static const TCGTargetOpDef movc_c = { .args_ct_str = { "r", "r", "rC", "r", "0" } }; - return (s390_facilities & FACILITY_EXT_IMM ? &movc_c : &movc_z); + static const TCGTargetOpDef movc_l + = { .args_ct_str = { "r", "r", "rC", "rI", "0" } }; + return (s390_facilities & FACILITY_EXT_IMM + ? (s390_facilities & FACILITY_LOAD_ON_COND2 + ? &movc_l : &movc_c) + : &movc_z); } case INDEX_op_div2_i32: case INDEX_op_div2_i64: