From patchwork Thu Jan 14 02:16:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 362809 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp74042jap; Wed, 13 Jan 2021 18:33:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJztsCJqzL7llrzWnbIzG9nvsovOjwax1LyDOLDeWfT02XQOvcH0Fp6e1b3mgHREH+AqxeLe X-Received: by 2002:a25:68c4:: with SMTP id d187mr674668ybc.371.1610591612794; Wed, 13 Jan 2021 18:33:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610591612; cv=none; d=google.com; s=arc-20160816; b=osW9p6Kcp7I4zKlLV99sDDXwcdz3CZYoC8hNTpllyKyjJSFn10embL7alVGp0k9I3Z RxVOiCXkWluBoR6v0B1QNvGEsBJGDzikT8cX7ZAKkEDOh/kSYETaYD8kKDnuFQoHOtgW hQbgN4GfBIRD8DD+SGVg9T4mEIiHNpYuEwZhIrmvrcyb2J9zUt/q0hmCb4rYXqY/32U6 yFbLIR+mDFs2v3ISATUxd6RwSMVgiuRuXbuwJ1GacwfgxQyCDk2XNZ6a/k5QKZOM7Hzv HIVLcon4be5i/44QOgPdo4cpl/glVQAgnKMAOnUdEa/xRqu0hTN6XonmfuM62L7VqMp5 ngdQ== 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=rT+Iuuo6F5MmSbW+tCwYHH0uffarzjIWxAQZUPXloBE=; b=MlSO3a0cDwac08zhmZJ51aTec4PIGKa2SzSCWRnqEN4DGGD8FxWs2579ry1hdiJIDn i2L0+0VSwGenup+I0J5lmeMcmzzdq6KBc22cyMcsgCs+jfQBld5xJuPJyOtWOElXMU3k bnAqM6fmSzsfiNv0991XTcXikFSTJnilfTOidJy9kWlvQhqZcRV5lY0pbjCpPUH+khqL A6qcDLuZlIA+DMrpfRDP7zN3MiaQWO3y3k6iFIFe7vlTvmM41ZBjmXoFM/NcCTJ8np6U Ba0KvEEnzq1gAOsBvA7Dk5eZk2jSQ9I9GCNbdDO8maepsIxoGfdPOJNwIEggplw9qK+5 c+cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y6hG41jd; 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 m74si4843649ybm.161.2021.01.13.18.33.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Jan 2021 18:33:32 -0800 (PST) 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=Y6hG41jd; 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]:51058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzsS4-0005gR-BF for patch@linaro.org; Wed, 13 Jan 2021 21:33:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzsCe-0003iE-0A for qemu-devel@nongnu.org; Wed, 13 Jan 2021 21:17:36 -0500 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:44813) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kzsCc-0003W5-5B for qemu-devel@nongnu.org; Wed, 13 Jan 2021 21:17:35 -0500 Received: by mail-pg1-x52e.google.com with SMTP id p18so2719673pgm.11 for ; Wed, 13 Jan 2021 18:17:31 -0800 (PST) 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=rT+Iuuo6F5MmSbW+tCwYHH0uffarzjIWxAQZUPXloBE=; b=Y6hG41jdqPNKzMoC6o/aASUZ9GhUjfgMebpnBtllxYk0dBWH5lmjkrHCXaehtKFGi3 NBmDITjKTkHejB0u8MYEsXVOH7YqLlEwD/YrZTXebxcQUDxTqGheuWYaT7X/OL1l6Qz6 8TZGc90q1AfYR4NyiavkJD272aW+JqGtCU+bLIZ5suITPROL+q6Z2FHaYoIBn0Qr5x49 G46c74ZpykSul82qMcrLO6eCiMUx5ekqapsxgN25M8Dc8DdhXKOt9EAr5tiGir/UQ3qz fFXZKC/SeJX9bF0Dk62H5VsjF/wU+ru+//CqlEnvPhJ5S+NNkxd0Eg6rz7LRgKqan0QV t8SA== 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=rT+Iuuo6F5MmSbW+tCwYHH0uffarzjIWxAQZUPXloBE=; b=N9kgkBO7XTwOgrRlYnuN6s/nA76bIYwNl1FwtTLoKFtaa8CrNNI53TWtRkfHPS0HC9 ZDEwKfX0k6jhYVwF8awVmWRkZXxFt9HGcx5O/eS6Rr6NFbTDiyrGD5DU35z7OeT8Pp9Z W4Pl/CBNxEBPdJ/4UmA+y/EG8tk0GZ79cZQ7MzS0Mm7IBXdZ2yUtlN7ygXDxbcYiQTaB c4SIbtKlopcGQkYZnegp4WrD28S9HVP1OkYQyju+rxq+2Avjm+zFpfS+CGYyH9Z9fw1x k0nCxeTqv/DTtmmv0WPKvvJmYDePmtfPaSktMnlqEieLnj0ZbBEEIQNOFmaVV+JhodGn 8r8w== X-Gm-Message-State: AOAM530GG5/ywl0LnCbAx39v7CNjrAMUJ8gKFG92P4L3oA0HAsWIDr3I GuQpbfuE2eMolM3LFNH/ZiUFIawkFMBRcA== X-Received: by 2002:a63:5d7:: with SMTP id 206mr5118347pgf.384.1610590650093; Wed, 13 Jan 2021 18:17:30 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id i7sm3771687pfc.50.2021.01.13.18.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 18:17:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 19/24] tcg: Add tcg_reg_alloc_dup2 Date: Wed, 13 Jan 2021 16:16:49 -1000 Message-Id: <20210114021654.647242-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210114021654.647242-1-richard.henderson@linaro.org> References: <20210114021654.647242-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There are several ways we can expand a vector dup of a 64-bit element on a 32-bit host. Signed-off-by: Richard Henderson --- tcg/tcg.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) -- 2.25.1 diff --git a/tcg/tcg.c b/tcg/tcg.c index 5b0e42be91..8f8badb61c 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -4084,6 +4084,98 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) } } +static bool tcg_reg_alloc_dup2(TCGContext *s, const TCGOp *op) +{ + const TCGLifeData arg_life = op->life; + TCGTemp *ots, *itsl, *itsh; + TCGType vtype = TCGOP_VECL(op) + TCG_TYPE_V64; + + /* This opcode is only valid for 32-bit hosts, for 64-bit elements. */ + tcg_debug_assert(TCG_TARGET_REG_BITS == 32); + tcg_debug_assert(TCGOP_VECE(op) == MO_64); + + ots = arg_temp(op->args[0]); + itsl = arg_temp(op->args[1]); + itsh = arg_temp(op->args[2]); + + /* ENV should not be modified. */ + tcg_debug_assert(!temp_readonly(ots)); + + /* Allocate the output register now. */ + if (ots->val_type != TEMP_VAL_REG) { + TCGRegSet allocated_regs = s->reserved_regs; + TCGRegSet dup_out_regs = + tcg_op_defs[INDEX_op_dup_vec].args_ct[0].regs; + + /* Make sure to not spill the input registers. */ + if (!IS_DEAD_ARG(1) && itsl->val_type == TEMP_VAL_REG) { + tcg_regset_set_reg(allocated_regs, itsl->reg); + } + if (!IS_DEAD_ARG(2) && itsh->val_type == TEMP_VAL_REG) { + tcg_regset_set_reg(allocated_regs, itsh->reg); + } + + ots->reg = tcg_reg_alloc(s, dup_out_regs, allocated_regs, + op->output_pref[0], ots->indirect_base); + ots->val_type = TEMP_VAL_REG; + ots->mem_coherent = 0; + s->reg_to_temp[ots->reg] = ots; + } + + /* Promote dup2 of immediates to dupi_vec. */ + if (itsl->val_type == TEMP_VAL_CONST && itsh->val_type == TEMP_VAL_CONST) { + uint64_t val = deposit64(itsl->val, 32, 32, itsh->val); + MemOp vece = MO_64; + + if (val == dup_const(MO_8, val)) { + vece = MO_8; + } else if (val == dup_const(MO_16, val)) { + vece = MO_16; + } else if (val == dup_const(MO_32, val)) { + vece = MO_32; + } + + tcg_out_dupi_vec(s, vtype, vece, ots->reg, val); + goto done; + } + + /* If the two inputs form one 64-bit value, try dupm_vec. */ + if (itsl + 1 == itsh && itsl->base_type == TCG_TYPE_I64) { + if (!itsl->mem_coherent) { + temp_sync(s, itsl, s->reserved_regs, 0, 0); + } + if (!itsh->mem_coherent) { + temp_sync(s, itsh, s->reserved_regs, 0, 0); + } +#ifdef HOST_WORDS_BIGENDIAN + TCGTemp *its = itsh; +#else + TCGTemp *its = itsl; +#endif + if (tcg_out_dupm_vec(s, vtype, MO_64, ots->reg, + its->mem_base->reg, its->mem_offset)) { + goto done; + } + } + + /* Fall back to generic expansion. */ + return false; + + done: + if (IS_DEAD_ARG(1)) { + temp_dead(s, itsl); + } + if (IS_DEAD_ARG(2)) { + temp_dead(s, itsh); + } + if (NEED_SYNC_ARG(0)) { + temp_sync(s, ots, s->reserved_regs, 0, IS_DEAD_ARG(0)); + } else if (IS_DEAD_ARG(0)) { + temp_dead(s, ots); + } + return true; +} + #ifdef TCG_TARGET_STACK_GROWSUP #define STACK_DIR(x) (-(x)) #else @@ -4501,6 +4593,11 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) case INDEX_op_call: tcg_reg_alloc_call(s, op); break; + case INDEX_op_dup2_vec: + if (tcg_reg_alloc_dup2(s, op)) { + break; + } + /* fall through */ default: /* Sanity check that we've not introduced any unhandled opcodes. */ tcg_debug_assert(tcg_op_supported(opc));