From patchwork Tue Feb 11 00:40:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Simpson X-Patchwork-Id: 1236080 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=quicinc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcdkim header.b=chyht1bF; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Gkzm5vZzz9s3x for ; Tue, 11 Feb 2020 12:03:32 +1100 (AEDT) Received: from localhost ([::1]:41852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j1Jxa-0002Fw-Mq for incoming@patchwork.ozlabs.org; Mon, 10 Feb 2020 20:03:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34226) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j1Jcp-0002ZU-E3 for qemu-devel@nongnu.org; Mon, 10 Feb 2020 19:42:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j1Jcn-0002j8-IU for qemu-devel@nongnu.org; Mon, 10 Feb 2020 19:42:03 -0500 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:3639) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j1Jcn-0004qc-7T for qemu-devel@nongnu.org; Mon, 10 Feb 2020 19:42:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1581381721; x=1612917721; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2pFlcoEDjym2STmm3IgPduT0fK693EEOjfJOkHI6FrA=; b=chyht1bFIzZqlpqLl43SJi7WCpSTCYeI706uCyhpr2R2h72ofzJCn53V NuR1f3KFhvEOXUkjUKAXCyfDMKZF7JM32LpB+dQ5puJiN6y44HEZA/Vah Jsxrr6uq9aVL8PwNidzOT4DeNbnQtL3vLEJQ4OGCb6HjYEh55EedTcPyh c=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-01.qualcomm.com with ESMTP; 10 Feb 2020 16:41:04 -0800 Received: from vu-tsimpson-aus.qualcomm.com (HELO vu-tsimpson1-aus.qualcomm.com) ([10.222.150.1]) by ironmsg03-sd.qualcomm.com with ESMTP; 10 Feb 2020 16:41:03 -0800 Received: by vu-tsimpson1-aus.qualcomm.com (Postfix, from userid 47164) id C57B11B5F; Mon, 10 Feb 2020 18:41:03 -0600 (CST) From: Taylor Simpson To: qemu-devel@nongnu.org Subject: [RFC PATCH 64/66] Hexagon HVX TCG generation Date: Mon, 10 Feb 2020 18:40:42 -0600 Message-Id: <1581381644-13678-65-git-send-email-tsimpson@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1581381644-13678-1-git-send-email-tsimpson@quicinc.com> References: <1581381644-13678-1-git-send-email-tsimpson@quicinc.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 199.106.114.38 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Taylor Simpson --- target/hexagon/genptr.c | 1 + target/hexagon/genptr_helpers.h | 189 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 190 insertions(+) diff --git a/target/hexagon/genptr.c b/target/hexagon/genptr.c index 30319b5..3da0018 100644 --- a/target/hexagon/genptr.c +++ b/target/hexagon/genptr.c @@ -26,6 +26,7 @@ #include "opcodes.h" #include "translate.h" #include "macros.h" +#include "mmvec/macros.h" #include "genptr_helpers.h" #include "helper_overrides.h" diff --git a/target/hexagon/genptr_helpers.h b/target/hexagon/genptr_helpers.h index b8bdcf4..66f67e5 100644 --- a/target/hexagon/genptr_helpers.h +++ b/target/hexagon/genptr_helpers.h @@ -830,4 +830,193 @@ static inline void gen_lshiftr_4_4u(TCGv dst, TCGv src, int32_t shift_amt) } } +static inline uint32_t new_temp_vreg_offset(DisasContext *ctx, int num) +{ + uint32_t offset = + 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 += num; + return offset; +} + +static inline uint32_t new_temp_qreg_offset(DisasContext *ctx) +{ + uint32_t offset = + 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 = offsetof(CPUHexagonState, QRegs[(num)]); + TCGv_ptr src = 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(TCGv_ptr var, int num, int vtmp) +{ + TCGv zero = tcg_const_tl(0); + TCGv offset_future = + tcg_const_tl(offsetof(CPUHexagonState, future_VRegs[num])); + TCGv offset_vregs = + tcg_const_tl(offsetof(CPUHexagonState, VRegs[num])); + TCGv offset_tmp_vregs = + tcg_const_tl(offsetof(CPUHexagonState, tmp_VRegs[num])); + TCGv offset = tcg_temp_new(); + TCGv_ptr offset_ptr = tcg_temp_new_ptr(); + TCGv_ptr ptr_src = tcg_temp_new_ptr(); + TCGv new_written = tcg_temp_new(); + TCGv tmp_written = tcg_temp_new(); + + /* + * new_written = (hex_VRegs_select >> num) & 1; + * offset = 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 = (hex_VRegs_updated_tmp >> num) & 1; + * if (tmp_written) offset = 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 == EXT_TMP) { + TCGv vregs_updated = tcg_temp_new(); + TCGv temp = tcg_temp_new(); + + /* + * vregs_updated = hex_VRegs_updates & (1 << num); + * if (vregs_updated) { + * offset = offset_future; + * hex_VRegs_updated ^= (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); + gen_memcpy(var, ptr_src, sizeof(mmvector_t)); + + 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_ptr(ptr_src); + tcg_temp_free(new_written); + tcg_temp_free(tmp_written); +} + +static inline void gen_read_vreg_pair(TCGv_ptr var, int num, int vtmp) +{ + TCGv_ptr v0 = tcg_temp_new_ptr(); + TCGv_ptr v1 = 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 = tcg_temp_local_new(); + TCGLabel *label_end = 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 = tcg_const_tl(1 << num); + TCGv_ptr dst = tcg_temp_new_ptr(); + if (vnew != EXT_TMP) { + tcg_gen_or_tl(hex_VRegs_updated, hex_VRegs_updated, mask); + } + if (vnew == EXT_NEW) { + tcg_gen_or_tl(hex_VRegs_select, hex_VRegs_select, mask); + } + if (vnew == EXT_TMP) { + tcg_gen_or_tl(hex_VRegs_updated_tmp, hex_VRegs_updated_tmp, mask); + } + tcg_gen_addi_ptr(dst, cpu_env, + offsetof(CPUHexagonState, future_VRegs[num])); + gen_memcpy(dst, var, sizeof(mmvector_t)); + if (vnew == EXT_TMP) { + TCGv_ptr src = 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 = tcg_temp_local_new_ptr(); + TCGv_ptr v1 = 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 = tcg_temp_local_new(); + TCGLabel *label_end = 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 = 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