From nobody Thu Nov 13 22:05:03 2025 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail header.i=@quicinc.com; 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=fail(p=none dis=none) header.from=quicinc.com ARC-Seal: i=1; a=rsa-sha256; t=1582910771; cv=none; d=zohomail.com; s=zohoarc; b=HF/ELxd0ZZvSpy1DzCgwDoGejX7DO0JVcpSSm22T0zZv9LqnOkeTg0knwC7IzCK/dl4Aj73vfo49c3KrCoIhC2L+aFzysBm5+PW6Rv0qJfG+SFRxGbqjeWxouSL2a5M7zFJxm0xhHTThXtyIy7TkJBsqE9TaTnpDV0dYnJMGXNY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582910771; h=Content-Type:Content-Transfer-Encoding:Cc: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=0Lk5Fy/33WLGZ59ho7toXn1vR/XTO3mvmC68TZkGQ0o=; b=m1jE1zaBlkWqK/2BQp/4RWIiogPcKEQBZDBJh//jBTW3V7zQLZQS/Y9v/7TuHfwZEjRnNnP2fObPjGJ3OpE/gg0gABd+HqgCBpwJAKbfScVPB1hdSU+eiRpeB5/GS6IguQuMBbGFL/V4fAnx0VQsCJxYI0/uepmKaCsW+LWTlH0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@quicinc.com; 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=fail 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 1582910771611460.98519568653944; Fri, 28 Feb 2020 09:26:11 -0800 (PST) Received: from localhost ([::1]:51274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7jOs-0002vj-3d for importer@patchew.org; Fri, 28 Feb 2020 12:26:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58575) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7imP-0005pn-7h for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:46:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7imM-0007RP-KZ for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:46:24 -0500 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:27026) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7imK-0005U4-Vn for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:46:21 -0500 Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-02.qualcomm.com with ESMTP; 28 Feb 2020 08:44:34 -0800 Received: from vu-tsimpson-aus.qualcomm.com (HELO vu-tsimpson1-aus.qualcomm.com) ([10.222.150.1]) by ironmsg01-sd.qualcomm.com with ESMTP; 28 Feb 2020 08:44:34 -0800 Received: by vu-tsimpson1-aus.qualcomm.com (Postfix, from userid 47164) id 16EE211AF; Fri, 28 Feb 2020 10:44:34 -0600 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1582908381; x=1614444381; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0Lk5Fy/33WLGZ59ho7toXn1vR/XTO3mvmC68TZkGQ0o=; b=T43vuveVqTqb0AvzeiyuIlgAzS6+/QSwklpucNfPS+04Wv91CDHfwkqi A7Rltsmzd7EgVaa6y7z+iWZjbKfKdubiAAgzzldGIUTh3WpUS5sJM+u9k Ggue+gZePo3dmfP5bN40YfnplLVb/Kxz98xxAAyZUX4mfgAiqOpXNTLo6 E=; From: Taylor Simpson To: qemu-devel@nongnu.org Subject: [RFC PATCH v2 65/67] Hexagon HVX TCG generation Date: Fri, 28 Feb 2020 10:44:01 -0600 Message-Id: <1582908244-304-66-git-send-email-tsimpson@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582908244-304-1-git-send-email-tsimpson@quicinc.com> References: <1582908244-304-1-git-send-email-tsimpson@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 199.106.114.39 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: riku.voipio@iki.fi, richard.henderson@linaro.org, laurent@vivier.eu, Taylor Simpson , philmd@redhat.com, aleksandar.m.mail@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Taylor Simpson --- target/hexagon/genptr_helpers.h | 202 ++++++++++++++++++++++++++++++++++++= ++++ target/hexagon/genptr.c | 1 + 2 files changed, 203 insertions(+) diff --git a/target/hexagon/genptr_helpers.h b/target/hexagon/genptr_helper= s.h index e342f29..84479f8 100644 --- a/target/hexagon/genptr_helpers.h +++ b/target/hexagon/genptr_helpers.h @@ -844,4 +844,206 @@ static inline void gen_lshiftr_4_4u(TCGv dst, TCGv sr= c, int32_t shift_amt) } } =20 +static inline uint32_t new_temp_vreg_offset(DisasContext *ctx, int num) +{ + uint32_t offset =3D + offsetof(CPUHexagonState, temp_vregs[ctx->ctx_temp_vregs_idx]); + + HEX_DEBUG_LOG("new_temp_vreg_offset: %d\n", ctx->ctx_temp_vregs_idx); + g_assert(ctx->ctx_temp_vregs_idx + num - 1 < TEMP_VECTORS_MAX); + ctx->ctx_temp_vregs_idx +=3D num; + return offset; +} + +static inline uint32_t new_temp_qreg_offset(DisasContext *ctx) +{ + uint32_t offset =3D + offsetof(CPUHexagonState, temp_qregs[ctx->ctx_temp_qregs_idx]); + + HEX_DEBUG_LOG("new_temp_qreg_offset: %d\n", ctx->ctx_temp_qregs_idx); + g_assert(ctx->ctx_temp_qregs_idx < TEMP_VECTORS_MAX); + ctx->ctx_temp_qregs_idx++; + return offset; +} + +static inline void gen_read_qreg(TCGv_ptr var, int num, int vtmp) +{ + uint32_t offset =3D offsetof(CPUHexagonState, QRegs[(num)]); + TCGv_ptr src =3D tcg_temp_new_ptr(); + tcg_gen_addi_ptr(src, cpu_env, offset); + gen_memcpy(var, src, sizeof(mmqreg_t)); + tcg_temp_free_ptr(src); +} + +static inline void gen_read_vreg_ptr_src(TCGv_ptr ptr_src, int num, int vt= mp) +{ + TCGv zero =3D tcg_const_tl(0); + TCGv offset_future =3D + tcg_const_tl(offsetof(CPUHexagonState, future_VRegs[num])); + TCGv offset_vregs =3D + tcg_const_tl(offsetof(CPUHexagonState, VRegs[num])); + TCGv offset_tmp_vregs =3D + tcg_const_tl(offsetof(CPUHexagonState, tmp_VRegs[num])); + TCGv offset =3D tcg_temp_new(); + TCGv_ptr offset_ptr =3D tcg_temp_new_ptr(); + TCGv new_written =3D tcg_temp_new(); + TCGv tmp_written =3D tcg_temp_new(); + + /* + * new_written =3D (hex_VRegs_select >> num) & 1; + * offset =3D new_written ? offset_future, offset_vregs; + */ + tcg_gen_shri_tl(new_written, hex_VRegs_select, num); + tcg_gen_andi_tl(new_written, new_written, 1); + tcg_gen_movcond_tl(TCG_COND_NE, offset, new_written, zero, + offset_future, offset_vregs); + + /* + * tmp_written =3D (hex_VRegs_updated_tmp >> num) & 1; + * if (tmp_written) offset =3D offset_tmp_vregs; + */ + tcg_gen_shri_tl(tmp_written, hex_VRegs_updated_tmp, num); + tcg_gen_andi_tl(tmp_written, tmp_written, 1); + tcg_gen_movcond_tl(TCG_COND_NE, offset, tmp_written, zero, + offset_tmp_vregs, offset); + + if (vtmp =3D=3D EXT_TMP) { + TCGv vregs_updated =3D tcg_temp_new(); + TCGv temp =3D tcg_temp_new(); + + /* + * vregs_updated =3D hex_VRegs_updates & (1 << num); + * if (vregs_updated) { + * offset =3D offset_future; + * hex_VRegs_updated ^=3D (1 << num); + * } + */ + tcg_gen_andi_tl(vregs_updated, hex_VRegs_updated, 1 << num); + tcg_gen_movcond_tl(TCG_COND_NE, offset, vregs_updated, zero, + offset_future, offset); + tcg_gen_xori_tl(temp, hex_VRegs_updated, 1 << num); + tcg_gen_movcond_tl(TCG_COND_NE, hex_VRegs_updated, vregs_updated, = zero, + temp, hex_VRegs_updated); + + tcg_temp_free(vregs_updated); + tcg_temp_free(temp); + } + + tcg_gen_ext_i32_ptr(offset_ptr, offset); + tcg_gen_add_ptr(ptr_src, cpu_env, offset_ptr); + + tcg_temp_free(zero); + tcg_temp_free(offset_future); + tcg_temp_free(offset_vregs); + tcg_temp_free(offset_tmp_vregs); + tcg_temp_free(offset); + tcg_temp_free_ptr(offset_ptr); + tcg_temp_free(new_written); + tcg_temp_free(tmp_written); +} + +static inline void gen_read_vreg_readonly(TCGv_ptr var, int num, int vtmp) +{ + TCGv_ptr ptr_src =3D tcg_temp_new_ptr(); + gen_read_vreg_ptr_src(ptr_src, num, vtmp); + tcg_gen_addi_ptr(var, ptr_src, 0); + tcg_temp_free_ptr(ptr_src); +} + +static inline void gen_read_vreg(TCGv_ptr var, int num, int vtmp) +{ + TCGv_ptr ptr_src =3D tcg_temp_new_ptr(); + gen_read_vreg_ptr_src(ptr_src, num, vtmp); + gen_memcpy(var, ptr_src, sizeof(mmvector_t)); + tcg_temp_free_ptr(ptr_src); +} + +static inline void gen_read_vreg_pair(TCGv_ptr var, int num, int vtmp) +{ + TCGv_ptr v0 =3D tcg_temp_new_ptr(); + TCGv_ptr v1 =3D tcg_temp_new_ptr(); + tcg_gen_addi_ptr(v0, var, offsetof(mmvector_pair_t, v[0])); + gen_read_vreg(v0, num ^ 0, vtmp); + tcg_gen_addi_ptr(v1, var, offsetof(mmvector_pair_t, v[1])); + gen_read_vreg(v1, num ^ 1, vtmp); + tcg_temp_free_ptr(v0); + tcg_temp_free_ptr(v1); +} + +static inline void gen_log_vreg_write(TCGv_ptr var, int num, int vnew, + int slot_num) +{ + TCGv cancelled =3D tcg_temp_local_new(); + TCGLabel *label_end =3D gen_new_label(); + + /* Don't do anything if the slot was cancelled */ + gen_slot_cancelled_check(cancelled, slot_num); + tcg_gen_brcondi_tl(TCG_COND_NE, cancelled, 0, label_end); + { + TCGv mask =3D tcg_const_tl(1 << num); + TCGv_ptr dst =3D tcg_temp_new_ptr(); + if (vnew !=3D EXT_TMP) { + tcg_gen_or_tl(hex_VRegs_updated, hex_VRegs_updated, mask); + } + if (vnew =3D=3D EXT_NEW) { + tcg_gen_or_tl(hex_VRegs_select, hex_VRegs_select, mask); + } + if (vnew =3D=3D EXT_TMP) { + tcg_gen_or_tl(hex_VRegs_updated_tmp, hex_VRegs_updated_tmp, ma= sk); + } + tcg_gen_addi_ptr(dst, cpu_env, + offsetof(CPUHexagonState, future_VRegs[num])); + gen_memcpy(dst, var, sizeof(mmvector_t)); + if (vnew =3D=3D EXT_TMP) { + TCGv_ptr src =3D tcg_temp_new_ptr(); + tcg_gen_addi_ptr(dst, cpu_env, + offsetof(CPUHexagonState, tmp_VRegs[num])); + tcg_gen_addi_ptr(src, cpu_env, + offsetof(CPUHexagonState, future_VRegs[num])); + gen_memcpy(dst, src, sizeof(mmvector_t)); + tcg_temp_free_ptr(src); + } + tcg_temp_free(mask); + tcg_temp_free_ptr(dst); + } + gen_set_label(label_end); + + tcg_temp_free(cancelled); +} + +static inline void gen_log_vreg_write_pair(TCGv_ptr var, int num, int vnew, + int slot_num) +{ + TCGv_ptr v0 =3D tcg_temp_local_new_ptr(); + TCGv_ptr v1 =3D tcg_temp_local_new_ptr(); + tcg_gen_addi_ptr(v0, var, offsetof(mmvector_pair_t, v[0])); + gen_log_vreg_write(v0, num ^ 0, vnew, slot_num); + tcg_gen_addi_ptr(v1, var, offsetof(mmvector_pair_t, v[1])); + gen_log_vreg_write(v1, num ^ 1, vnew, slot_num); + tcg_temp_free_ptr(v0); + tcg_temp_free_ptr(v1); +} + +static inline void gen_log_qreg_write(TCGv_ptr var, int num, int vnew, + int slot_num) +{ + TCGv cancelled =3D tcg_temp_local_new(); + TCGLabel *label_end =3D gen_new_label(); + + /* Don't do anything if the slot was cancelled */ + gen_slot_cancelled_check(cancelled, slot_num); + tcg_gen_brcondi_tl(TCG_COND_NE, cancelled, 0, label_end); + { + TCGv_ptr dst =3D tcg_temp_new_ptr(); + tcg_gen_addi_ptr(dst, cpu_env, + offsetof(CPUHexagonState, future_QRegs[num])); + gen_memcpy(dst, var, sizeof(mmqreg_t)); + tcg_gen_ori_tl(hex_QRegs_updated, hex_QRegs_updated, 1 << num); + tcg_temp_free_ptr(dst); + } + gen_set_label(label_end); + + tcg_temp_free(cancelled); +} + #endif diff --git a/target/hexagon/genptr.c b/target/hexagon/genptr.c index 6b9cc0d..588360d 100644 --- a/target/hexagon/genptr.c +++ b/target/hexagon/genptr.c @@ -25,6 +25,7 @@ #include "opcodes.h" #include "translate.h" #include "macros.h" +#include "mmvec/macros.h" #include "genptr_helpers.h" #include "helper_overrides.h" =20 --=20 2.7.4