From patchwork Sat Jun 26 05:02:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 467419 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2136616jao; Fri, 25 Jun 2021 22:05:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfUq48IdtT8Pf4DEN6C1DywsuA3FiHpk3Xuml0p5xD2KrzF3TQsfIcSh8D8DHZZerZV7yX X-Received: by 2002:a37:64c1:: with SMTP id y184mr12056806qkb.154.1624683916607; Fri, 25 Jun 2021 22:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624683916; cv=none; d=google.com; s=arc-20160816; b=hz0RJCArETr6zC+UBV+pQGvyIybhY9t2cIwTFYf3IbetV/wQBZUGrAaXP3zLJH02kQ J+W9AUTxQOnewxYwSN9+CPZNmNuJkptK9N2I7bI1BWLnYgZoIJYs5kwGKDthaRDjq3Hu r4nN0Q3Fteq7OgpFZUA52aZcB/V+mXe8/GVKBOPHHzjjFAzj8nS4ek/MBd2H3eh003ii K54SkEs/BCBKWwMGXueE/eGKrLPpUxnG7Q4E8ZOG/hLCnEBKOXst1dC2SsmWEmWansB1 OMqO4wj+LnGG6DjaGMn/q/Pn3r3euUCRRegou/kk+FQN0/qzvYbLec05rMXavex6rkQn kqHA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=5RsDo5LOvqHfddwDWLUBaPmdje4xPxYC9ARF5xmGDlE=; b=PlCzdFzAQbl5jCfghmsqoDOQoUiuyGTtJ616dQahGygq4xGl0VI9dgACpTKkcAaym8 Qlbopnw/vGpU5GGzPoWcoqrWC+p7CUAdBaMAZGTsE9b+yXyETRfXEA0Q8huFL3P6hLcP MZPKJNMupuS4w3VDxu09agmkl4pO7Pnzkzo1CCZUynlpbVIp7teBBPIRqh5FZwG/hcIO gkuIr0ocYIL//H5qy74Ptbu0AoyYUNz67UR0U/wkG/m25OsD7JTzBV1RaxzSFwCnVZZ1 BDzHDvDdpz7Nxu/r5pFSnTiD/x0Hbi0i7B2tpcO70j7fZSkRaFyWcx76R+PDkiKF19Xg OGDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bNMoAUkg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v11si3063930qtc.147.2021.06.25.22.05.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Jun 2021 22:05:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bNMoAUkg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lx0VI-0004GK-4H for patch@linaro.org; Sat, 26 Jun 2021 01:05:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lx0TL-0006qV-Nl for qemu-devel@nongnu.org; Sat, 26 Jun 2021 01:03:15 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:33582) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lx0TI-0008E1-68 for qemu-devel@nongnu.org; Sat, 26 Jun 2021 01:03:15 -0400 Received: by mail-pf1-x42f.google.com with SMTP id s14so7866025pfg.0 for ; Fri, 25 Jun 2021 22:03: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 :mime-version:content-transfer-encoding; bh=5RsDo5LOvqHfddwDWLUBaPmdje4xPxYC9ARF5xmGDlE=; b=bNMoAUkgFs5oi9tfKZcsGVyTbdZnz5OZz3X/4Vuep7USfxmG++T3M++JVClyXtnm6Z 7X2ujjTxATisxb35PQz0h/VfqcHCEFLmftVpTu6gS/ss6F7djhGXJwNBwdvZkrW74ryX npNyHg+V/PbWj7GGp/ichpOvO4MuPXzp2mYj4QP6XduF4oOQnkhDW9XR54+Q6feYg7HD JS6PGu47ezlJQWo4Q2/TePWk5i+dai8LbTrG03GNPJBkMEQqBEeJ/81qBcDRYUlpfvXP zpEB7OP0sanKtLy8Scr2iOestN84VNbm9J/lLBlvluKoC4T1qHRwUqDRrGqa+o7xR2nA mq5Q== 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:mime-version:content-transfer-encoding; bh=5RsDo5LOvqHfddwDWLUBaPmdje4xPxYC9ARF5xmGDlE=; b=oin7YnBh0Fnu5ecZfqPtAxOIcyKjKHzBsxHwUuQgNDoZkR1cDYJE3onsI/HuuOE4dO bagWVl5Ael17ppUBwPG/rxZbjTN5tF1KX6EgzfVEH4/kGnrmYnCa0mieVdTikfLsMXla 2mI0XOqNnMBblOxf8tBcgWjbzE0qUzrb5w+LY5CcVxnD66QgM+923YT+PXlPb1OHPcwA TOUT2ISe41mBukoAHG6xHKUCChwebwfX2OT5JqSYAA/Uj9daAmrIHg6UY6sy1CQyrphB TuTWmPOEAOPYOKo/jobWMkjmSwndzijvNGHtnzbCpfEL3ZNawamr2RrZKellVxlThjgJ qlTQ== X-Gm-Message-State: AOAM531Nr1q5qUWfTkKpffJ/y2cxpHXJFoOcGdGdtV0ug8hjfv+TkInU EVBfY4tCiFLSHQaTO7/7eAk3K/uRwztVng== X-Received: by 2002:a62:7a49:0:b029:302:c04b:36d1 with SMTP id v70-20020a627a490000b0290302c04b36d1mr13897942pfc.27.1624683790956; Fri, 25 Jun 2021 22:03:10 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id c62sm7389768pfa.12.2021.06.25.22.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 22:03:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 05/16] tcg/s390x: Implement tcg_out_ld/st for vector types Date: Fri, 25 Jun 2021 22:02:56 -0700 Message-Id: <20210626050307.2408505-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210626050307.2408505-1-richard.henderson@linaro.org> References: <20210626050307.2408505-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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: , Cc: david@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/s390x/tcg-target.c.inc | 122 +++++++++++++++++++++++++++++++++---- 1 file changed, 110 insertions(+), 12 deletions(-) -- 2.25.1 diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index 18233c628d..b6ea129e14 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -265,6 +265,12 @@ typedef enum S390Opcode { RX_STC = 0x42, RX_STH = 0x40, + VRX_VL = 0xe706, + VRX_VLLEZ = 0xe704, + VRX_VST = 0xe70e, + VRX_VSTEF = 0xe70b, + VRX_VSTEG = 0xe70a, + NOP = 0x0707, } S390Opcode; @@ -529,6 +535,31 @@ static void tcg_out_insn_RSY(TCGContext *s, S390Opcode op, TCGReg r1, #define tcg_out_insn_RX tcg_out_insn_RS #define tcg_out_insn_RXY tcg_out_insn_RSY +static int RXB(TCGReg v1, TCGReg v2, TCGReg v3, TCGReg v4) +{ + /* + * Shift bit 4 of each regno to its corresponding bit of RXB. + * RXB itself begins at bit 8 of the instruction so 8 - 4 = 4 + * is the left-shift of the 4th operand. + */ + return ((v1 & 0x10) << (4 + 3)) + | ((v2 & 0x10) << (4 + 2)) + | ((v3 & 0x10) << (4 + 1)) + | ((v4 & 0x10) << (4 + 0)); +} + +static void tcg_out_insn_VRX(TCGContext *s, S390Opcode op, TCGReg v1, + TCGReg b2, TCGReg x2, intptr_t d2, int m3) +{ + tcg_debug_assert(v1 >= TCG_REG_V0 && v1 <= TCG_REG_V31); + tcg_debug_assert(d2 >= 0 && d2 <= 0xfff); + tcg_debug_assert(x2 <= TCG_REG_R15); + tcg_debug_assert(b2 <= TCG_REG_R15); + tcg_out16(s, (op & 0xff00) | ((v1 & 15) << 4) | x2); + tcg_out16(s, (b2 << 12) | d2); + tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, 0, 0) | (m3 << 12)); +} + /* Emit an opcode with "type-checking" of the format. */ #define tcg_out_insn(S, FMT, OP, ...) \ glue(tcg_out_insn_,FMT)(S, glue(glue(FMT,_),OP), ## __VA_ARGS__) @@ -705,25 +736,92 @@ static void tcg_out_mem(TCGContext *s, S390Opcode opc_rx, S390Opcode opc_rxy, } } +static void tcg_out_vrx_mem(TCGContext *s, S390Opcode opc_vrx, + TCGReg data, TCGReg base, TCGReg index, + tcg_target_long ofs, int m3) +{ + if (ofs < 0 || ofs >= 0x1000) { + if (ofs >= -0x80000 && ofs < 0x80000) { + tcg_out_insn(s, RXY, LAY, TCG_TMP0, base, index, ofs); + base = TCG_TMP0; + index = TCG_REG_NONE; + ofs = 0; + } else { + tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, ofs); + if (index != TCG_REG_NONE) { + tcg_out_insn(s, RRE, AGR, TCG_TMP0, index); + } + index = TCG_TMP0; + ofs = 0; + } + } + tcg_out_insn_VRX(s, opc_vrx, data, base, index, ofs, m3); +} /* load data without address translation or endianness conversion */ -static inline void tcg_out_ld(TCGContext *s, TCGType type, TCGReg data, - TCGReg base, intptr_t ofs) +static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg data, + TCGReg base, intptr_t ofs) { - if (type == TCG_TYPE_I32) { - tcg_out_mem(s, RX_L, RXY_LY, data, base, TCG_REG_NONE, ofs); - } else { - tcg_out_mem(s, 0, RXY_LG, data, base, TCG_REG_NONE, ofs); + switch (type) { + case TCG_TYPE_I32: + if (likely(data < 16)) { + tcg_out_mem(s, RX_L, RXY_LY, data, base, TCG_REG_NONE, ofs); + break; + } + tcg_out_vrx_mem(s, VRX_VLLEZ, data, base, TCG_REG_NONE, ofs, MO_32); + break; + + case TCG_TYPE_I64: + if (likely(data < 16)) { + tcg_out_mem(s, 0, RXY_LG, data, base, TCG_REG_NONE, ofs); + break; + } + /* fallthru */ + + case TCG_TYPE_V64: + tcg_out_vrx_mem(s, VRX_VLLEZ, data, base, TCG_REG_NONE, ofs, MO_64); + break; + + case TCG_TYPE_V128: + /* Hint quadword aligned. */ + tcg_out_vrx_mem(s, VRX_VL, data, base, TCG_REG_NONE, ofs, 4); + break; + + default: + g_assert_not_reached(); } } -static inline void tcg_out_st(TCGContext *s, TCGType type, TCGReg data, - TCGReg base, intptr_t ofs) +static void tcg_out_st(TCGContext *s, TCGType type, TCGReg data, + TCGReg base, intptr_t ofs) { - if (type == TCG_TYPE_I32) { - tcg_out_mem(s, RX_ST, RXY_STY, data, base, TCG_REG_NONE, ofs); - } else { - tcg_out_mem(s, 0, RXY_STG, data, base, TCG_REG_NONE, ofs); + switch (type) { + case TCG_TYPE_I32: + if (likely(data < 16)) { + tcg_out_mem(s, RX_ST, RXY_STY, data, base, TCG_REG_NONE, ofs); + } else { + tcg_out_vrx_mem(s, VRX_VSTEF, data, base, TCG_REG_NONE, ofs, 1); + } + break; + + case TCG_TYPE_I64: + if (likely(data < 16)) { + tcg_out_mem(s, 0, RXY_STG, data, base, TCG_REG_NONE, ofs); + break; + } + /* fallthru */ + + case TCG_TYPE_V64: + tcg_out_vrx_mem(s, VRX_VSTEG, data, base, TCG_REG_NONE, ofs, 0); + break; + + case TCG_TYPE_V128: + /* Hint quadword aligned. */ + tcg_out_vrx_mem(s, VRX_VST, data, base, TCG_REG_NONE, ofs, 4); + break; + + default: + g_assert_not_reached(); } }