From nobody Tue Nov 18 09:20:15 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1608927810; cv=none; d=zohomail.com; s=zohoarc; b=Lc1FJBp5W0QTZgaC5mofIdQ+hIfZGfr+rLrHPmuSxDVBbLpV2vZcHl6uiXR/2wsGYHRRgl+8hbEwYzQfVFonQRUzTXaR1ut7+Xu4EyreN9TVuK1xDULtT+jElZ9Y450P5QcbawQpvmPFUF4nJvNobtvZyumQkdk9HznGg8R63H8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608927810; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ybgxSgF17wnGwAL3lO0iHlUSyPDecVyF741ftLcDrKk=; b=VsGBeLvKGZRLH9X5sOMmBu6UwuzPlZ7oOegdk1+KDR2iY+txv7IRL1CYJvSwBPwU2aliNh7um4tP+ZhuRYqVDC/3hDWSW9c6w6kf4Gky85FvoxOpx8mPS1u3vKiiz635S596TgczZ4ulW7dFcBwmclsBmvHEVBAZ4gkCrMdriCQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1608927810532834.2746573529945; Fri, 25 Dec 2020 12:23:30 -0800 (PST) Received: from localhost ([::1]:58524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kstcX-0004rr-O5 for importer@patchew.org; Fri, 25 Dec 2020 15:23:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kstZL-00032s-D9 for qemu-devel@nongnu.org; Fri, 25 Dec 2020 15:20:11 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:53072) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kstZH-0005BC-SV for qemu-devel@nongnu.org; Fri, 25 Dec 2020 15:20:11 -0500 Received: by mail-pj1-x102d.google.com with SMTP id v1so2680476pjr.2 for ; Fri, 25 Dec 2020 12:20:07 -0800 (PST) Received: from localhost.localdomain (174-21-150-71.tukw.qwest.net. [174.21.150.71]) by smtp.gmail.com with ESMTPSA id l8sm5816497pjt.32.2020.12.25.12.20.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Dec 2020 12:20:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ybgxSgF17wnGwAL3lO0iHlUSyPDecVyF741ftLcDrKk=; b=WDTF/oC8Qy6eTqsc+72CsrZYboaWQ0kMkvA8ywA/wGxGKzhVSgpJPHu92X5oZjfYBP aIGy4dUTnOO6JVppyZnLsVc79P5NifbVRt0oNJ/zdh9j5zHrulyMFGNzWMdjkYvchjXc nzYX8xZ8l0FoExdE8AcXYpoNyfzcECkB9N4N5YFI35C3RIs8XZB/0bkYkWvykd2JD55/ Xb1JNOrls/azbTmMf64pj54NX6lJakE5nbXSWXdiluUq3I9nAFXvaXpxjk3qU23mwUfs 88CjcYFktn3MSyqv41ygoqIikjo59+d0SReAx4vn2QYH/qGlHpM+QbfNKIZ+bXfFEB3s BP8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ybgxSgF17wnGwAL3lO0iHlUSyPDecVyF741ftLcDrKk=; b=naHXzdMccaQKFFn2ljLyDob7KfMYV/3kMtF9atFoHl0oRbTLsfRDkKmJMl9u2cFfKU 781TnqfQP8ezbPScZgnqZp/5zRj3xT1SREhROXk6gmQe+rWPaR3wH10fUCZO/Qq5sYyB 1E6o2dplfnDoLYhXStzCaSKkPqbM/ZQLnvE86NDyUkGVhJfUaknu965jwIBweux20eH4 0GhXdWxeysnjmvviXAGYKD67sR+4lkhipubjWRTtIBvntmet7iPB3p2Q03rTpJdcaG94 soEnt0Br3Fkxfx/P1OMwA1THNI5EJUymyXJp+/7qWqntTrLULT7bphLirjy15ElHrDFT wOXw== X-Gm-Message-State: AOAM531p98KOGbWUOFDxWMDUe5W0OOwfnWiDy7UKnbCJkm2PI7hKjhAd fDpGkhLcWa9GdYiU/fiCvFURQUtw0ZFbew== X-Google-Smtp-Source: ABdhPJw2rGNAAiSDc3RoBsq7qFYcCKWz/WyI/5/S9xZg0sKlj/sdBW0w1OsKLk7utHHu2Ju4qA4phw== X-Received: by 2002:a17:90a:c085:: with SMTP id o5mr10082704pjs.210.1608927606283; Fri, 25 Dec 2020 12:20:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 07/16] tcg/s390x: Implement tcg_out_dup*_vec Date: Fri, 25 Dec 2020 12:19:47 -0800 Message-Id: <20201225201956.692861-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201225201956.692861-1-richard.henderson@linaro.org> References: <20201225201956.692861-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- tcg/s390x/tcg-target.c.inc | 122 ++++++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 3 deletions(-) diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index 50113dbdd7..808d50190f 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -250,13 +250,20 @@ typedef enum S390Opcode { RX_STC =3D 0x42, RX_STH =3D 0x40, =20 + VRIa_VGBM =3D 0xe744, + VRIa_VREPI =3D 0xe745, + VRIb_VGM =3D 0xe746, + VRIc_VREP =3D 0xe74d, + VRRa_VLR =3D 0xe756, + VRRf_VLVGP =3D 0xe762, =20 VRSb_VLVG =3D 0xe722, VRSc_VLGV =3D 0xe721, =20 VRX_VL =3D 0xe706, VRX_VLLEZ =3D 0xe704, + VRX_VLREP =3D 0xe705, VRX_VST =3D 0xe70e, VRX_VSTEF =3D 0xe70b, VRX_VSTEG =3D 0xe70a, @@ -535,6 +542,34 @@ static int RXB(TCGReg v1, TCGReg v2, TCGReg v3, TCGReg= v4) | ((v4 & 16) << (4 - 3)); } =20 +static void tcg_out_insn_VRIa(TCGContext *s, S390Opcode op, + TCGReg v1, uint16_t i2, int m3) +{ + tcg_debug_assert(v1 >=3D TCG_REG_V0 && v1 <=3D TCG_REG_V31); + tcg_out16(s, (op & 0xff00) | ((v1 & 15) << 4)); + tcg_out16(s, i2); + tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, 0, 0) | (m3 << 12)); +} + +static void tcg_out_insn_VRIb(TCGContext *s, S390Opcode op, + TCGReg v1, uint8_t i2, uint8_t i3, int m4) +{ + tcg_debug_assert(v1 >=3D TCG_REG_V0 && v1 <=3D TCG_REG_V31); + tcg_out16(s, (op & 0xff00) | ((v1 & 15) << 4)); + tcg_out16(s, (i2 << 8) | (i3 & 0xff)); + tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, 0, 0) | (m4 << 12)); +} + +static void tcg_out_insn_VRIc(TCGContext *s, S390Opcode op, + TCGReg v1, uint16_t i2, TCGReg v3, int m4) +{ + tcg_debug_assert(v1 >=3D TCG_REG_V0 && v1 <=3D TCG_REG_V31); + tcg_debug_assert(v3 >=3D TCG_REG_V0 && v3 <=3D TCG_REG_V31); + tcg_out16(s, (op & 0xff00) | ((v1 & 15) << 4) | (v3 & 15)); + tcg_out16(s, i2); + tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, v3, 0) | (m4 << 12)); +} + static void tcg_out_insn_VRRa(TCGContext *s, S390Opcode op, TCGReg v1, TCGReg v2, int m3) { @@ -544,6 +579,17 @@ static void tcg_out_insn_VRRa(TCGContext *s, S390Opcod= e op, tcg_out32(s, (op & 0x00ff) | RXB(v1, v2, 0, 0) | (m3 << 12)); } =20 +static void tcg_out_insn_VRRf(TCGContext *s, S390Opcode op, + TCGReg v1, TCGReg r2, TCGReg r3) +{ + tcg_debug_assert(v1 >=3D TCG_REG_V0 && v1 <=3D TCG_REG_V31); + tcg_debug_assert(r2 <=3D TCG_REG_R15); + tcg_debug_assert(r3 <=3D TCG_REG_R15); + tcg_out16(s, (op & 0xff00) | ((v1 & 15) << 4) | r2); + tcg_out16(s, r3 << 12); + tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, 0, 0)); +} + static void tcg_out_insn_VRSb(TCGContext *s, S390Opcode op, TCGReg v1, intptr_t d2, TCGReg b2, TCGReg r3, int m4) { @@ -2462,19 +2508,89 @@ static inline void tcg_out_op(TCGContext *s, TCGOpc= ode opc, static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, TCGReg dst, TCGReg src) { - g_assert_not_reached(); + if (src < 16) { + /* Replicate general register into two MO_64. */ + tcg_out_insn(s, VRRf, VLVGP, dst, src, src); + if (vece =3D=3D MO_64) { + return true; + } + } + + /* + * Recall that the "standard" integer, within a vector, is the + * rightmost element of the leftmost doubleword, a-la VLLEZ. + */ + tcg_out_insn(s, VRIc, VREP, dst, (8 >> vece) - 1, src, vece); + return true; } =20 static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, TCGReg dst, TCGReg base, intptr_t offset) { - g_assert_not_reached(); + tcg_out_vrx_mem(s, VRX_VLREP, dst, base, TCG_REG_NONE, offset, vece); + return true; } =20 static void tcg_out_dupi_vec(TCGContext *s, TCGType type, unsigned vece, TCGReg dst, int64_t val) { - g_assert_not_reached(); + int i, mask, msb, lsb; + + /* Look for int16_t elements. */ + if (vece <=3D MO_16 || + (vece =3D=3D MO_32 ? (int32_t)val : val) =3D=3D (int16_t)val) { + tcg_out_insn(s, VRIa, VREPI, dst, val, vece); + return; + } + + /* Look for bit masks. */ + if (vece =3D=3D MO_32) { + if (risbg_mask((int32_t)val)) { + /* Handle wraparound by swapping msb and lsb. */ + if ((val & 0x80000001u) =3D=3D 0x80000001u) { + msb =3D 32 - ctz32(~val); + lsb =3D clz32(~val) - 1; + } else { + msb =3D clz32(val); + lsb =3D 31 - ctz32(val); + } + tcg_out_insn(s, VRIb, VGM, dst, lsb, msb, MO_32); + return; + } + } else { + if (risbg_mask(val)) { + /* Handle wraparound by swapping msb and lsb. */ + if ((val & 0x8000000000000001ull) =3D=3D 0x8000000000000001ull= ) { + /* Handle wraparound by swapping msb and lsb. */ + msb =3D 64 - ctz64(~val); + lsb =3D clz64(~val) - 1; + } else { + msb =3D clz64(val); + lsb =3D 63 - ctz64(val); + } + tcg_out_insn(s, VRIb, VGM, dst, lsb, msb, MO_64); + return; + } + } + + /* Look for all bytes 0x00 or 0xff. */ + for (i =3D mask =3D 0; i < 8; i++) { + uint8_t byte =3D val >> (i * 8); + if (byte =3D=3D 0xff) { + mask |=3D 1 << i; + } else if (byte !=3D 0) { + break; + } + } + if (i =3D=3D 8) { + tcg_out_insn(s, VRIa, VGBM, dst, mask * 0x0101, 0); + return; + } + + /* Otherwise, stuff it in the constant pool. */ + tcg_out_insn(s, RIL, LARL, TCG_TMP0, 0); + new_pool_label(s, val, R_390_PC32DBL, s->code_ptr - 2, 2); + tcg_out_insn(s, VRX, VLREP, dst, TCG_TMP0, TCG_REG_NONE, 0, MO_64); } =20 static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, --=20 2.25.1