From nobody Thu Nov 13 22:09:57 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=1582911097; cv=none; d=zohomail.com; s=zohoarc; b=ai67pGagfi33oCGZKmyN8VV0yY5MRKvJ4YuBvfZp7gWxR6duSCdMOfBw09edYRFBKbCYPT0G1O1qOZ0jhE8Ux3iilyEM6Q1qJxfCcsEpMh14IPgk55vTPHwQkqQay2CU2ddqgQXsBMlbDEbcCorCLfHzgDcMCu5HjBZzIRMcyzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582911097; 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=rnfObRLyN7fHIjMEd1r4pmNjDobjdLU2Nomjtp6lJEA=; b=GUmP9G5HVLh5C2FvhsGoNaPx9CSYMENAzT2PQydBDdter6ZJqtHVp/3cje43244JkBwDil6NJrFYjpFjAy+X9SK8TB5mjmMC3CIoxpP2cN7BjN1fFw28JCtNXepkrxNrHfyeLdoPY4dS2GsYqVEVbYaSV9p8qPgFomifqSkUx4I= 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 1582911097361693.7988647905754; Fri, 28 Feb 2020 09:31:37 -0800 (PST) Received: from localhost ([::1]:51412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7jU7-0002pF-PH for importer@patchew.org; Fri, 28 Feb 2020 12:31:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58145) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7ilL-0004JK-Qr for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:45:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7ilJ-0006Qq-QN for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:45:19 -0500 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:27049) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7ilJ-0005V5-Az for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:45:17 -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:32 -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:31 -0800 Received: by vu-tsimpson1-aus.qualcomm.com (Postfix, from userid 47164) id 1A74C11AF; Fri, 28 Feb 2020 10:44:31 -0600 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1582908317; x=1614444317; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rnfObRLyN7fHIjMEd1r4pmNjDobjdLU2Nomjtp6lJEA=; b=wXGxpvOu9CF/35SIKYbbMCChT5a/jwED+blhS9eMcPW/bugUygOHpCR6 PypFonEu8XqzPOOEzfJcxZN4vnhqq7q9OvkjJ1oz+MiHNYKN4bes2sajU OnL8GKnEMsbqor1jfNp8GEcFeenN9yNfLbnHML7iBYXQX2ykwuadz1Y0n s=; From: Taylor Simpson To: qemu-devel@nongnu.org Subject: [RFC PATCH v2 38/67] Hexagon TCG generation helpers - step 5 Date: Fri, 28 Feb 2020 10:43:34 -0600 Message-Id: <1582908244-304-39-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) Helpers for instructions overriden for optimization Signed-off-by: Taylor Simpson --- target/hexagon/genptr_helpers.h | 314 ++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 314 insertions(+) diff --git a/target/hexagon/genptr_helpers.h b/target/hexagon/genptr_helper= s.h index 9917d72..e342f29 100644 --- a/target/hexagon/genptr_helpers.h +++ b/target/hexagon/genptr_helpers.h @@ -530,4 +530,318 @@ static inline void gen_cond_return(TCGv pred, TCGv ad= dr) tcg_temp_free(zero); } =20 +static inline void gen_loop0r(TCGv RsV, int riV, insn_t *insn) +{ + TCGv tmp =3D tcg_temp_new(); + fIMMEXT(riV); + fPCALIGN(riV); + /* fWRITE_LOOP_REGS0( fREAD_PC()+riV, RsV); */ + tcg_gen_addi_tl(tmp, hex_gpr[HEX_REG_PC], riV); + gen_log_reg_write(HEX_REG_LC0, RsV, insn->slot, 0); + gen_log_reg_write(HEX_REG_SA0, tmp, insn->slot, 0); + fSET_LPCFG(0); + tcg_temp_free(tmp); +} + +static inline void gen_loop1r(TCGv RsV, int riV, insn_t *insn) +{ + TCGv tmp =3D tcg_temp_new(); + fIMMEXT(riV); + fPCALIGN(riV); + /* fWRITE_LOOP_REGS1( fREAD_PC()+riV, RsV); */ + tcg_gen_addi_tl(tmp, hex_gpr[HEX_REG_PC], riV); + gen_log_reg_write(HEX_REG_LC1, RsV, insn->slot, 0); + gen_log_reg_write(HEX_REG_SA1, tmp, insn->slot, 0); + tcg_temp_free(tmp); +} + +static inline void gen_compare(TCGCond cond, TCGv res, TCGv arg1, TCGv arg= 2) +{ + TCGv one =3D tcg_const_tl(0xff); + TCGv zero =3D tcg_const_tl(0); + + tcg_gen_movcond_tl(cond, res, arg1, arg2, one, zero); + + tcg_temp_free(one); + tcg_temp_free(zero); +} + +static inline void gen_comparei(TCGCond cond, TCGv res, TCGv arg1, int arg= 2) +{ + TCGv tmp =3D tcg_const_tl(arg2); + gen_compare(cond, res, arg1, tmp); + tcg_temp_free(tmp); +} + +static inline void gen_compare_i64(TCGCond cond, TCGv res, + TCGv_i64 arg1, TCGv_i64 arg2) +{ + TCGv_i64 one =3D tcg_const_i64(0xff); + TCGv_i64 zero =3D tcg_const_i64(0); + TCGv_i64 temp =3D tcg_temp_new_i64(); + + tcg_gen_movcond_i64(cond, temp, arg1, arg2, one, zero); + tcg_gen_extrl_i64_i32(res, temp); + tcg_gen_andi_tl(res, res, 0xff); + + tcg_temp_free_i64(one); + tcg_temp_free_i64(zero); + tcg_temp_free_i64(temp); +} + +static inline void gen_cmpnd_cmp_jmp(int pnum, TCGCond cond, bool sense, + TCGv arg1, TCGv arg2, int pc_off) +{ + TCGv new_pc =3D tcg_temp_new(); + TCGv pred =3D tcg_temp_new(); + TCGv zero =3D tcg_const_tl(0); + TCGv one =3D tcg_const_tl(1); + + tcg_gen_addi_tl(new_pc, hex_gpr[HEX_REG_PC], pc_off); + gen_compare(cond, pred, arg1, arg2); + gen_log_pred_write(pnum, pred); + if (!sense) { + tcg_gen_xori_tl(pred, pred, 0xff); + } + + /* If there are multiple branches in a packet, ignore the second one */ + tcg_gen_movcond_tl(TCG_COND_NE, pred, hex_branch_taken, zero, zero, pr= ed); + + tcg_gen_movcond_tl(TCG_COND_NE, hex_next_PC, pred, zero, + new_pc, hex_next_PC); + tcg_gen_movcond_tl(TCG_COND_NE, hex_branch_taken, pred, zero, + one, hex_branch_taken); + + tcg_temp_free(new_pc); + tcg_temp_free(pred); + tcg_temp_free(zero); + tcg_temp_free(one); +} + +static inline void gen_cmpnd_cmpi_jmp(int pnum, TCGCond cond, bool sense, + TCGv arg1, int arg2, int pc_off) +{ + TCGv tmp =3D tcg_const_tl(arg2); + gen_cmpnd_cmp_jmp(pnum, cond, sense, arg1, tmp, pc_off); + tcg_temp_free(tmp); + +} + +static inline void gen_cmpnd_cmp_n1_jmp(int pnum, TCGCond cond, bool sense, + TCGv arg, int pc_off) +{ + gen_cmpnd_cmpi_jmp(pnum, cond, sense, arg, -1, pc_off); +} + + +static inline void gen_jump(int pc_off) +{ + TCGv new_pc =3D tcg_temp_new(); + tcg_gen_addi_tl(new_pc, hex_gpr[HEX_REG_PC], pc_off); + gen_write_new_pc(new_pc); + tcg_temp_free(new_pc); +} + +static inline void gen_cond_jumpr(TCGv pred, TCGv dst_pc) +{ + TCGv zero =3D tcg_const_tl(0); + TCGv one =3D tcg_const_tl(1); + TCGv new_pc =3D tcg_temp_new(); + + tcg_gen_movcond_tl(TCG_COND_EQ, new_pc, pred, zero, hex_next_PC, dst_p= c); + + /* If there are multiple jumps in a packet, only the first one is take= n */ + tcg_gen_movcond_tl(TCG_COND_NE, hex_next_PC, hex_branch_taken, zero, + hex_next_PC, new_pc); + tcg_gen_movcond_tl(TCG_COND_EQ, hex_branch_taken, pred, zero, + hex_branch_taken, one); + + tcg_temp_free(zero); + tcg_temp_free(one); + tcg_temp_free(new_pc); +} + +static inline void gen_cond_jump(TCGv pred, int pc_off) +{ + TCGv new_pc =3D tcg_temp_new(); + + tcg_gen_addi_tl(new_pc, hex_gpr[HEX_REG_PC], pc_off); + gen_cond_jumpr(pred, new_pc); + + tcg_temp_free(new_pc); +} + +static inline void gen_call(int pc_off) +{ + gen_log_reg_write(HEX_REG_LR, hex_next_PC, 4, false); + gen_jump(pc_off); +} + +static inline void gen_callr(TCGv new_pc) +{ + gen_log_reg_write(HEX_REG_LR, hex_next_PC, 4, false); + gen_write_new_pc(new_pc); +} + +static inline void gen_endloop0(void) +{ + TCGv lpcfg =3D tcg_temp_local_new(); + + GET_USR_FIELD(USR_LPCFG, lpcfg); + + /* + * if (lpcfg =3D=3D 1) { + * hex_new_pred_value[3] =3D 0xff; + * hex_pred_written |=3D 1 << 3; + * } + */ + TCGLabel *label1 =3D gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_NE, lpcfg, 1, label1); + { + tcg_gen_movi_tl(hex_new_pred_value[3], 0xff); + tcg_gen_ori_tl(hex_pred_written, hex_pred_written, 1 << 3); + } + gen_set_label(label1); + + /* + * if (lpcfg) { + * SET_USR_FIELD(USR_LPCFG, lpcfg - 1); + * } + */ + TCGLabel *label2 =3D gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_EQ, lpcfg, 0, label2); + { + tcg_gen_subi_tl(lpcfg, lpcfg, 1); + SET_USR_FIELD(USR_LPCFG, lpcfg); + } + gen_set_label(label2); + + /* + * if (hex_gpr[HEX_REG_LC0] > 1) { + * hex_next_PC =3D hex_gpr[HEX_REG_SA0]; + * hex_branch_taken =3D 1; + * hex_gpr[HEX_REG_LC0] =3D hex_gpr[HEX_REG_LC0] - 1; + * } + */ + TCGLabel *label3 =3D gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC0], 1, label3); + { + tcg_gen_mov_tl(hex_next_PC, hex_gpr[HEX_REG_SA0]); + tcg_gen_movi_tl(hex_branch_taken, 1); + TCGv lc0 =3D tcg_temp_local_new(); + tcg_gen_mov_tl(lc0, hex_gpr[HEX_REG_LC0]); + tcg_gen_subi_tl(lc0, lc0, 1); + tcg_gen_mov_tl(hex_new_value[HEX_REG_LC0], lc0); + tcg_temp_free(lc0); + } + gen_set_label(label3); + + tcg_temp_free(lpcfg); +} + +static inline void gen_endloop1(void) +{ + /* + * if (hex_gpr[HEX_REG_LC1] > 1) { + * hex_next_PC =3D hex_gpr[HEX_REG_SA1]; + * hex_branch_taken =3D 1; + * hex_gpr[HEX_REG_LC1] =3D hex_gpr[HEX_REG_LC1] - 1; + * } + */ + TCGLabel *label =3D gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC1], 1, label); + { + tcg_gen_mov_tl(hex_next_PC, hex_gpr[HEX_REG_SA1]); + tcg_gen_movi_tl(hex_branch_taken, 1); + TCGv lc1 =3D tcg_temp_local_new(); + tcg_gen_mov_tl(lc1, hex_gpr[HEX_REG_LC1]); + tcg_gen_subi_tl(lc1, lc1, 1); + tcg_gen_mov_tl(hex_new_value[HEX_REG_LC1], lc1); + tcg_temp_free(lc1); + } + gen_set_label(label); +} + +static inline void gen_ashiftr_4_4s(TCGv dst, TCGv src, int32_t shift_amt) +{ + tcg_gen_sari_tl(dst, src, shift_amt); +} + +static inline void gen_ashiftl_4_4s(TCGv dst, TCGv src, int32_t shift_amt) +{ + if (shift_amt >=3D 64) { + tcg_gen_movi_tl(dst, 0); + } else { + tcg_gen_shli_tl(dst, src, shift_amt); + } +} + +static inline void gen_cmp_jumpnv(TCGCond cond, int rnum, TCGv src, int pc= _off) +{ + TCGv pred =3D tcg_temp_new(); + tcg_gen_setcond_tl(cond, pred, hex_new_value[rnum], src); + gen_cond_jump(pred, pc_off); + tcg_temp_free(pred); +} + +static inline void gen_cmpi_jumpnv(TCGCond cond, int rnum, int src, int pc= _off) +{ + TCGv pred =3D tcg_temp_new(); + tcg_gen_setcondi_tl(cond, pred, hex_new_value[rnum], src); + gen_cond_jump(pred, pc_off); + tcg_temp_free(pred); +} + +static inline void gen_asl_r_r_or(TCGv RxV, TCGv RsV, TCGv RtV) +{ + TCGv zero =3D tcg_const_tl(0); + TCGv shift_amt =3D tcg_temp_new(); + TCGv_i64 shift_amt_i64 =3D tcg_temp_new_i64(); + TCGv_i64 shift_left_val_i64 =3D tcg_temp_new_i64(); + TCGv shift_left_val =3D tcg_temp_new(); + TCGv_i64 shift_right_val_i64 =3D tcg_temp_new_i64(); + TCGv shift_right_val =3D tcg_temp_new(); + TCGv or_val =3D tcg_temp_new(); + + /* Sign extend 7->32 bits */ + tcg_gen_shli_tl(shift_amt, RtV, 32 - 7); + tcg_gen_sari_tl(shift_amt, shift_amt, 32 - 7); + tcg_gen_ext_i32_i64(shift_amt_i64, shift_amt); + + tcg_gen_ext_i32_i64(shift_left_val_i64, RsV); + tcg_gen_shl_i64(shift_left_val_i64, shift_left_val_i64, shift_amt_i64); + tcg_gen_extrl_i64_i32(shift_left_val, shift_left_val_i64); + + /* ((-(SHAMT)) - 1) */ + tcg_gen_neg_i64(shift_amt_i64, shift_amt_i64); + tcg_gen_subi_i64(shift_amt_i64, shift_amt_i64, 1); + + tcg_gen_ext_i32_i64(shift_right_val_i64, RsV); + tcg_gen_sar_i64(shift_right_val_i64, shift_right_val_i64, shift_amt_i6= 4); + tcg_gen_sari_i64(shift_right_val_i64, shift_right_val_i64, 1); + tcg_gen_extrl_i64_i32(shift_right_val, shift_right_val_i64); + + tcg_gen_movcond_tl(TCG_COND_GE, or_val, shift_amt, zero, + shift_left_val, shift_right_val); + tcg_gen_or_tl(RxV, RxV, or_val); + + tcg_temp_free(zero); + tcg_temp_free(shift_amt); + tcg_temp_free_i64(shift_amt_i64); + tcg_temp_free_i64(shift_left_val_i64); + tcg_temp_free(shift_left_val); + tcg_temp_free_i64(shift_right_val_i64); + tcg_temp_free(shift_right_val); + tcg_temp_free(or_val); +} + +static inline void gen_lshiftr_4_4u(TCGv dst, TCGv src, int32_t shift_amt) +{ + if (shift_amt >=3D 64) { + tcg_gen_movi_tl(dst, 0); + } else { + tcg_gen_shri_tl(dst, src, shift_amt); + } +} + #endif --=20 2.7.4