From patchwork Fri Feb 28 16:43:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Simpson X-Patchwork-Id: 11413069 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C636F924 for ; Fri, 28 Feb 2020 17:33:00 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8DF5724699 for ; Fri, 28 Feb 2020 17:33:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="A6oW84fp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DF5724699 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=quicinc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:51460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7jVT-0006NR-Ie for patchwork-qemu-devel@patchwork.kernel.org; Fri, 28 Feb 2020 12:32:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58348) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7im0-0005Zd-8m for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:46:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7ily-000783-8J for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:46:00 -0500 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:27035) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7ilx-0005Ug-QS for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:45:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1582908357; x=1614444357; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q5aIV7ecl3r0K3V9trKTrERFci7vyJdEogS9DpK5o1w=; b=A6oW84fpwmAeG8IsDYWIu+WAjTK0qXsmEh8XAn3FE5biEWXOaHMtN5Sy oqYm9Di33emOQvro2FxvELl9YkhF9sCj+Q8MrWebHkXnQVLNKPmlEklWl nb8QB9bbylB4XOZf6trxfkTeN07tTzCadfxBYEaJ4B4exWHBt2PVMpZXv Y=; 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:33 -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:32 -0800 Received: by vu-tsimpson1-aus.qualcomm.com (Postfix, from userid 47164) id 1CE1A1163; Fri, 28 Feb 2020 10:44:32 -0600 (CST) From: Taylor Simpson To: qemu-devel@nongnu.org Subject: [RFC PATCH v2 50/67] Hexagon TCG generation - step 12 Date: Fri, 28 Feb 2020 10:43:46 -0600 Message-Id: <1582908244-304-51-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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Override miscellaneous instructions identified during profiling Signed-off-by: Taylor Simpson --- target/hexagon/helper_overrides.h | 296 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 296 insertions(+) diff --git a/target/hexagon/helper_overrides.h b/target/hexagon/helper_overrides.h index ad9a88c..b796ced 100644 --- a/target/hexagon/helper_overrides.h +++ b/target/hexagon/helper_overrides.h @@ -1551,4 +1551,300 @@ #define fWRAP_J2_jumptnewpt(GENHLPR, SHORTCODE) \ gen_cond_jump(PuN, riV) +/* + * New value compare & jump instructions + * if ([!]COND(r0.new, r1) jump:t address + * if ([!]COND(r0.new, #7) jump:t address + */ +#define fWRAP_J4_cmpgt_f_jumpnv_t(GENHLPR, SHORTCODE) \ + gen_cmp_jumpnv(TCG_COND_LE, NsX, RtV, riV) +#define fWRAP_J4_cmpeq_f_jumpnv_nt(GENHLPR, SHORTCODE) \ + gen_cmp_jumpnv(TCG_COND_NE, NsX, RtV, riV) +#define fWRAP_J4_cmpgt_t_jumpnv_t(GENHLPR, SHORTCODE) \ + gen_cmp_jumpnv(TCG_COND_GT, NsX, RtV, riV) +#define fWRAP_J4_cmpeqi_t_jumpnv_nt(GENHLPR, SHORTCODE) \ + gen_cmpi_jumpnv(TCG_COND_EQ, NsX, UiV, riV) +#define fWRAP_J4_cmpltu_f_jumpnv_t(GENHLPR, SHORTCODE) \ + gen_cmp_jumpnv(TCG_COND_GEU, NsX, RtV, riV) +#define fWRAP_J4_cmpgtui_t_jumpnv_t(GENHLPR, SHORTCODE) \ + gen_cmpi_jumpnv(TCG_COND_GTU, NsX, UiV, riV) +#define fWRAP_J4_cmpeq_f_jumpnv_t(GENHLPR, SHORTCODE) \ + gen_cmp_jumpnv(TCG_COND_NE, NsX, RtV, riV) +#define fWRAP_J4_cmpeqi_f_jumpnv_t(GENHLPR, SHORTCODE) \ + gen_cmpi_jumpnv(TCG_COND_NE, NsX, UiV, riV) +#define fWRAP_J4_cmpgtu_t_jumpnv_t(GENHLPR, SHORTCODE) \ + gen_cmp_jumpnv(TCG_COND_GTU, NsX, RtV, riV) +#define fWRAP_J4_cmpgtu_f_jumpnv_t(GENHLPR, SHORTCODE) \ + gen_cmp_jumpnv(TCG_COND_LEU, NsX, RtV, riV) +#define fWRAP_J4_cmplt_t_jumpnv_t(GENHLPR, SHORTCODE) \ + gen_cmp_jumpnv(TCG_COND_LT, NsX, RtV, riV) + +/* r0 = r1 ; jump address */ +#define fWRAP_J4_jumpsetr(GENHLPR, SHORTCODE) \ + do { \ + tcg_gen_mov_tl(RdV, RsV); \ + gen_jump(riV); \ + } while (0) + +/* r0 = lsr(r1, #5) */ +#define fWRAP_S2_lsr_i_r(GENHLPR, SHORTCODE) \ + fLSHIFTR(RdV, RsV, IMMNO(0), 4_4) + +/* r0 += lsr(r1, #5) */ +#define fWRAP_S2_lsr_i_r_acc(GENHLPR, SHORTCODE) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + fLSHIFTR(tmp, RsV, IMMNO(0), 4_4); \ + tcg_gen_add_tl(RxV, RxV, tmp); \ + tcg_temp_free(tmp); \ + } while (0) + +/* r0 ^= lsr(r1, #5) */ +#define fWRAP_S2_lsr_i_r_xacc(GENHLPR, SHORTCODE) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + fLSHIFTR(tmp, RsV, IMMNO(0), 4_4); \ + tcg_gen_xor_tl(RxV, RxV, tmp); \ + tcg_temp_free(tmp); \ + } while (0) + +/* r0 = asr(r1, #5) */ +#define fWRAP_S2_asr_i_r(GENHLPR, SHORTCODE) \ + fASHIFTR(RdV, RsV, IMMNO(0), 4_4) + +/* r0 = addasl(r1, r2, #3) */ +#define fWRAP_S2_addasl_rrri(GENHLPR, SHORTCODE) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + fASHIFTL(tmp, RsV, IMMNO(0), 4_4); \ + tcg_gen_add_tl(RdV, RtV, tmp); \ + tcg_temp_free(tmp); \ + } while (0) + +/* r0 |= asl(r1, r2) */ +#define fWRAP_S2_asl_r_r_or(GENHLPR, SHORTCODE) \ + gen_asl_r_r_or(RxV, RsV, RtV) + +/* r0 = asl(r1, #5) */ +#define fWRAP_S2_asl_i_r(GENHLPR, SHORTCODE) \ + fASHIFTL(RdV, RsV, IMMNO(0), 4_4) + +/* r0 |= asl(r1, #5) */ +#define fWRAP_S2_asl_i_r_or(GENHLPR, SHORTCODE) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + fASHIFTL(tmp, RsV, IMMNO(0), 4_4); \ + tcg_gen_or_tl(RxV, RxV, tmp); \ + tcg_temp_free(tmp); \ + } while (0) + +/* r0 = vsplatb(r1) */ +#define fWRAP_S2_vsplatrb(GENHLPR, SHORTCODE) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + int i; \ + tcg_gen_movi_tl(RdV, 0); \ + tcg_gen_andi_tl(tmp, RsV, 0xff); \ + for (i = 0; i < 4; i++) { \ + tcg_gen_shli_tl(RdV, RdV, 8); \ + tcg_gen_or_tl(RdV, RdV, tmp); \ + } \ + tcg_temp_free(tmp); \ + } while (0) + +#define fWRAP_SA1_seti(GENHLPR, SHORTCODE) \ + tcg_gen_movi_tl(RdV, IMMNO(0)) + +#define fWRAP_S2_insert(GENHLPR, SHORTCODE) \ + tcg_gen_deposit_i32(RxV, RxV, RsV, IMMNO(1), IMMNO(0)) + +#define fWRAP_S2_extractu(GENHLPR, SHORTCODE) \ + tcg_gen_extract_i32(RdV, RsV, IMMNO(1), IMMNO(0)) + +#define fWRAP_A2_combinew(GENHLPR, SHORTCODE) \ + tcg_gen_concat_i32_i64(RddV, RtV, RsV) +#define fWRAP_A2_combineii(GENHLPR, SHORTCODE) \ + do { \ + TCGv tmp_lo = tcg_const_tl(SiV); \ + TCGv tmp_hi = tcg_const_tl(siV); \ + tcg_gen_concat_i32_i64(RddV, tmp_lo, tmp_hi); \ + tcg_temp_free(tmp_lo); \ + tcg_temp_free(tmp_hi); \ + } while (0) +#define fWRAP_A4_combineri(GENHLPR, SHORTCODE) \ + do { \ + TCGv tmp_lo = tcg_const_tl(siV); \ + tcg_gen_concat_i32_i64(RddV, tmp_lo, RsV); \ + tcg_temp_free(tmp_lo); \ + } while (0) +#define fWRAP_A4_combineir(GENHLPR, SHORTCODE) \ + do { \ + TCGv tmp_hi = tcg_const_tl(siV); \ + tcg_gen_concat_i32_i64(RddV, RsV, tmp_hi); \ + tcg_temp_free(tmp_hi); \ + } while (0) +#define fWRAP_A4_combineii(GENHLPR, SHORTCODE) \ + do { \ + TCGv tmp_lo = tcg_const_tl(UiV); \ + TCGv tmp_hi = tcg_const_tl(siV); \ + tcg_gen_concat_i32_i64(RddV, tmp_lo, tmp_hi); \ + tcg_temp_free(tmp_lo); \ + tcg_temp_free(tmp_hi); \ + } while (0) + +#define fWRAP_SA1_combine0i(GENHLPR, SHORTCODE) \ + do { \ + TCGv tmp_lo = tcg_const_tl(uiV); \ + TCGv zero = tcg_const_tl(0); \ + tcg_gen_concat_i32_i64(RddV, tmp_lo, zero); \ + tcg_temp_free(tmp_lo); \ + tcg_temp_free(zero); \ + } while (0) + +/* r0 = or(#8, asl(r1, #5)) */ +#define fWRAP_S4_ori_asl_ri(GENHLPR, SHORTCODE) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + tcg_gen_shli_tl(tmp, RxV, IMMNO(1)); \ + tcg_gen_ori_tl(RxV, tmp, IMMNO(0)); \ + tcg_temp_free(tmp); \ + } while (0) + +/* r0 = add(r1, sub(#6, r2)) */ +#define fWRAP_S4_subaddi(GENHLPR, SHORTCODE) \ + do { \ + tcg_gen_sub_tl(RdV, RsV, RuV); \ + tcg_gen_addi_tl(RdV, RdV, IMMNO(0)); \ + } while (0) + +#define fWRAP_SA1_inc(GENHLPR, SHORTCODE) \ + tcg_gen_addi_tl(RdV, RsV, 1) + +#define fWRAP_SA1_dec(GENHLPR, SHORTCODE) \ + tcg_gen_subi_tl(RdV, RsV, 1) + +/* if (p0.new) r0 = #0 */ +#define fWRAP_SA1_clrtnew(GENHLPR, SHORTCODE) \ + do { \ + TCGv mask = tcg_temp_new(); \ + TCGv zero = tcg_const_tl(0); \ + tcg_gen_movi_tl(RdV, 0); \ + tcg_gen_movi_tl(mask, 1 << insn->slot); \ + tcg_gen_or_tl(mask, hex_slot_cancelled, mask); \ + tcg_gen_movcond_tl(TCG_COND_EQ, hex_slot_cancelled, \ + hex_new_pred_value[0], zero, \ + mask, hex_slot_cancelled); \ + tcg_temp_free(mask); \ + tcg_temp_free(zero); \ + } while (0) + +/* r0 = add(r1 , mpyi(#6, r2)) */ +#define fWRAP_M4_mpyri_addr_u2(GENHLPR, SHORTCODE) \ + do { \ + tcg_gen_muli_tl(RdV, RsV, IMMNO(0)); \ + tcg_gen_add_tl(RdV, RuV, RdV); \ + } while (0) + +/* Predicated add instructions */ +#define WRAP_padd(PRED, ADD) \ + do { \ + TCGv LSB = tcg_temp_new(); \ + TCGv mask = tcg_temp_new(); \ + TCGv zero = tcg_const_tl(0); \ + PRED; \ + ADD; \ + tcg_gen_movi_tl(mask, 1 << insn->slot); \ + tcg_gen_or_tl(mask, hex_slot_cancelled, mask); \ + tcg_gen_movcond_tl(TCG_COND_NE, hex_slot_cancelled, LSB, zero, \ + hex_slot_cancelled, mask); \ + tcg_temp_free(LSB); \ + tcg_temp_free(mask); \ + tcg_temp_free(zero); \ + } while (0) + +#define fWRAP_A2_paddt(GENHLPR, SHORTCODE) \ + WRAP_padd(fLSBOLD(PuV), tcg_gen_add_tl(RdV, RsV, RtV)) +#define fWRAP_A2_paddf(GENHLPR, SHORTCODE) \ + WRAP_padd(fLSBOLDNOT(PuV), tcg_gen_add_tl(RdV, RsV, RtV)) +#define fWRAP_A2_paddit(GENHLPR, SHORTCODE) \ + WRAP_padd(fLSBOLD(PuV), tcg_gen_addi_tl(RdV, RsV, IMMNO(0))) +#define fWRAP_A2_paddif(GENHLPR, SHORTCODE) \ + WRAP_padd(fLSBOLDNOT(PuV), tcg_gen_addi_tl(RdV, RsV, IMMNO(0))) +#define fWRAP_A2_padditnew(GENHLPR, SHORTCODE) \ + WRAP_padd(fLSBNEW(PuN), tcg_gen_addi_tl(RdV, RsV, IMMNO(0))) + +/* Conditional move instructions */ +#define fWRAP_COND_MOVE(VAL, COND) \ + do { \ + TCGv LSB = tcg_temp_new(); \ + TCGv zero = tcg_const_tl(0); \ + TCGv mask = tcg_temp_new(); \ + TCGv value = tcg_const_tl(siV); \ + VAL; \ + tcg_gen_movcond_tl(COND, RdV, LSB, zero, value, zero); \ + tcg_gen_movi_tl(mask, 1 << insn->slot); \ + tcg_gen_movcond_tl(TCG_COND_EQ, mask, LSB, zero, mask, zero); \ + tcg_gen_or_tl(hex_slot_cancelled, hex_slot_cancelled, mask); \ + tcg_temp_free(LSB); \ + tcg_temp_free(zero); \ + tcg_temp_free(mask); \ + tcg_temp_free(value); \ + } while (0) + +#define fWRAP_C2_cmoveit(GENHLPR, SHORTCODE) \ + fWRAP_COND_MOVE(fLSBOLD(PuV), TCG_COND_NE) +#define fWRAP_C2_cmovenewit(GENHLPR, SHORTCODE) \ + fWRAP_COND_MOVE(fLSBNEW(PuN), TCG_COND_NE) +#define fWRAP_C2_cmovenewif(GENHLPR, SHORTCODE) \ + fWRAP_COND_MOVE(fLSBNEWNOT(PuN), TCG_COND_NE) + +/* p0 = tstbit(r0, #5) */ +#define fWRAP_S2_tstbit_i(GENHLPR, SHORTCODE) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + tcg_gen_andi_tl(tmp, RsV, (1 << IMMNO(0))); \ + gen_8bitsof(PdV, tmp); \ + tcg_temp_free(tmp); \ + } while (0) + +/* p0 = !tstbit(r0, #5) */ +#define fWRAP_S4_ntstbit_i(GENHLPR, SHORTCODE) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + tcg_gen_andi_tl(tmp, RsV, (1 << IMMNO(0))); \ + gen_8bitsof(PdV, tmp); \ + tcg_gen_xori_tl(PdV, PdV, 0xff); \ + tcg_temp_free(tmp); \ + } while (0) + +/* r0 = setbit(r1, #5) */ +#define fWRAP_S2_setbit_i(GENHLPR, SHORTCODE) \ + tcg_gen_ori_tl(RdV, RsV, 1 << IMMNO(0)) + +/* r0 += add(r1, #8) */ +#define fWRAP_M2_accii(GENHLPR, SHORTCODE) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + tcg_gen_add_tl(tmp, RxV, RsV); \ + tcg_gen_addi_tl(RxV, tmp, IMMNO(0)); \ + tcg_temp_free(tmp); \ + } while (0) + +/* p0 = bitsclr(r1, #6) */ +#define fWRAP_C2_bitsclri(GENHLPR, SHORTCODE) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + TCGv zero = tcg_const_tl(0); \ + tcg_gen_andi_tl(tmp, RsV, IMMNO(0)); \ + gen_compare(TCG_COND_EQ, PdV, tmp, zero); \ + tcg_temp_free(tmp); \ + tcg_temp_free(zero); \ + } while (0) + +#define fWRAP_SL2_jumpr31(GENHLPR, SHORTCODE) \ + gen_write_new_pc(hex_gpr[HEX_REG_LR]) + +#define fWRAP_SL2_jumpr31_tnew(GENHLPR, SHORTCODE) \ + gen_cond_jumpr(hex_new_pred_value[0], hex_gpr[HEX_REG_LR]) + #endif