QEMU MIPS ASE DSP support
v7 cover QEMU MIPS ASE DSP support
This is MIPS ASE DSP instructions support for QEMU. These instructions are grouped according to "Chapter 4. MIPS DSP ASE Instruction Summary" in MIPS ASE DSP manual [1][2].
[1] MIPS32® Architecture for Programmers VolumeIV-e: The MIPS® DSP Application-Specific Extension to the MIPS32®Architecture
http://www.mips.com/products/product-materials/processor/mips-architecture/
[2] MIPS64® Architecture for Programmers VolumeIV-e: The MIPS® DSP Application-Specific Extention to the MIPS64® Architecture
http://www.mips.com/products/product-materials/processor/mips-architecture/
---
Version History:
v7:
Addressed Aurelien's review comments:
- make hflags check for dsp, use check_dsp[r2]() instead of check_insn
- directly use cpu_dspctrl as the second argument in branch instructions
- factorizing some check_dsp() code one level
- remove unnecessary save_cpu_state() from load instructions
- resolve conflicts between MIPS DSP and loongson2e better
- make repl* more clean
v6:
Addressed Siarhei Siamashka's review comments:
- make internal function mipsdsp_mul_u8_u16 more clean
- fix MFHI MFLO MTHI MTLO, make mips64 linux run OK
v5:
Addressed Richard's review comments:
- bug shooting with --enanle-debug-tcg
- add check_insn for each DSP instructions
- MIPS64 ASE DSP support
v4:
Addressed Richard's review comments:
- split transalte.
- tested on i386 machine.
- delete all global env usage so that we don't need to include dyngen-exec.h.
- fix DEF_HELPER_FLAGS_N error.
- fix all ERRORS and WARNINGS found by ./scripts/checkpatch.pl.
- make sample if() code clearer.
- combine helper_cmpgu_cond_* and helper_cmpgdu_cond_*.
- fix bitrev.
- implement repl* and load with no helper.
- using TCG_COND_GE instead of TCG_COND_GT in OPC_BPOSGE32.
Thanks WeiRen for prereviewing and lots of suggestion.
v3:
Addressed Peter's review comments:
- split these changes into more patches.
- add "ULL" suffix for constants which are more than 32 bits wide.
Addressed WeiRen's review comments:
- split these changes into 12 patches.
- more suitable subject and description for every patch.
Addressed Richard's review comments:
- use DEF_HELPER_FLAGS_N instead of DEF_HELPER_N in some insns.
- put most DSP helpers into dsp_helper.c
- fix two testcases error.
v2:
Addressed Stefan's review comments:
- fixed coding style.
- changed acc into unsigned int form int and no initialization in translation.
- added return value in testcases.
v1:
- add MIPS ASE DSP Support.
Jia Liu (14):
target-mips-ase-dsp: Add internal functions
target-mips-ase-dsp: Add dsp resources access check
target-mips-ase-dsp: Use correct acc value to index cpu_HI/cpu_LO
rather than using a fix number
target-mips-ase-dsp: Add branch instructions
target-mips-ase-dsp: Add load instructions
target-mips-ase-dsp: Add arithmetic instructions
target-mips-ase-dsp: Add GPR-based shift instructions
target-mips-ase-dsp: Add multiply instructions
target-mips-ase-dsp: Add bit/manipulation instructions
target-mips-ase-dsp: Add compare-pick instructions
target-mips-ase-dsp: Add DSP accumulator instructions
target-mips-ase-dsp: Add MIPS DSP processors
target-mips-ase-dsp: Add testcases
target-mips-ase-dsp: Change TODO file
linux-user/main.c | 6 + target-mips/Makefile.objs | 2 +- target-mips/TODO | 2 - target-mips/cpu.h | 8 +- target-mips/dsp_helper.c | 8261 ++++++++++++++++++++++++ target-mips/helper.c | 3 + target-mips/helper.h | 396 ++ target-mips/op_helper.c | 19 + target-mips/translate.c | 2989 ++++++++- target-mips/translate_init.c | 55 + tests/tcg/mips/mips32-dsp/Makefile | 134 + tests/tcg/mips/mips32-dsp/absq_s_ph.c | 31 + tests/tcg/mips/mips32-dsp/absq_s_w.c | 37 + tests/tcg/mips/mips32-dsp/addq_ph.c | 30 + tests/tcg/mips/mips32-dsp/addq_s_ph.c | 30 + tests/tcg/mips/mips32-dsp/addsc.c | 30 + tests/tcg/mips/mips32-dsp/addu_qb.c | 30 + tests/tcg/mips/mips32-dsp/addu_s_qb.c | 30 + tests/tcg/mips/mips32-dsp/addwc.c | 30 + tests/tcg/mips/mips32-dsp/bitrev.c | 20 + tests/tcg/mips/mips32-dsp/bposge32.c | 44 + tests/tcg/mips/mips32-dsp/cmp_eq_ph.c | 35 + tests/tcg/mips/mips32-dsp/cmp_le_ph.c | 35 + tests/tcg/mips/mips32-dsp/cmp_lt_ph.c | 35 + tests/tcg/mips/mips32-dsp/cmpgu_eq_qb.c | 31 + tests/tcg/mips/mips32-dsp/cmpgu_le_qb.c | 31 + tests/tcg/mips/mips32-dsp/cmpgu_lt_qb.c | 31 + tests/tcg/mips/mips32-dsp/cmpu_eq_qb.c | 35 + tests/tcg/mips/mips32-dsp/cmpu_le_qb.c | 35 + tests/tcg/mips/mips32-dsp/cmpu_lt_qb.c | 35 + tests/tcg/mips/mips32-dsp/dpaq_s_w_ph.c | 31 + tests/tcg/mips/mips32-dsp/dpaq_sa_l_w.c | 31 + tests/tcg/mips/mips32-dsp/dpau_h_qbl.c | 27 + tests/tcg/mips/mips32-dsp/dpau_h_qbr.c | 27 + tests/tcg/mips/mips32-dsp/dpsq_s_w_ph.c | 27 + tests/tcg/mips/mips32-dsp/dpsq_sa_l_w.c | 31 + tests/tcg/mips/mips32-dsp/dpsu_h_qbl.c | 27 + tests/tcg/mips/mips32-dsp/dpsu_h_qbr.c | 27 + tests/tcg/mips/mips32-dsp/extp.c | 44 + tests/tcg/mips/mips32-dsp/extpdp.c | 46 + tests/tcg/mips/mips32-dsp/extpdpv.c | 47 + tests/tcg/mips/mips32-dsp/extpv.c | 45 + tests/tcg/mips/mips32-dsp/extr_r_w.c | 25 + tests/tcg/mips/mips32-dsp/extr_rs_w.c | 25 + tests/tcg/mips/mips32-dsp/extr_s_h.c | 25 + tests/tcg/mips/mips32-dsp/extr_w.c | 25 + tests/tcg/mips/mips32-dsp/extrv_r_w.c | 29 + tests/tcg/mips/mips32-dsp/extrv_rs_w.c | 29 + tests/tcg/mips/mips32-dsp/extrv_s_h.c | 29 + tests/tcg/mips/mips32-dsp/extrv_w.c | 29 + tests/tcg/mips/mips32-dsp/insv.c | 23 + tests/tcg/mips/mips32-dsp/lbux.c | 25 + tests/tcg/mips/mips32-dsp/lhx.c | 25 + tests/tcg/mips/mips32-dsp/lwx.c | 25 + tests/tcg/mips/mips32-dsp/madd.c | 31 + tests/tcg/mips/mips32-dsp/maddu.c | 31 + tests/tcg/mips/mips32-dsp/main.c | 6 + tests/tcg/mips/mips32-dsp/maq_s_w_phl.c | 31 + tests/tcg/mips/mips32-dsp/maq_s_w_phr.c | 31 + tests/tcg/mips/mips32-dsp/maq_sa_w_phl.c | 31 + tests/tcg/mips/mips32-dsp/maq_sa_w_phr.c | 31 + tests/tcg/mips/mips32-dsp/mfhi.c | 21 + tests/tcg/mips/mips32-dsp/mflo.c | 21 + tests/tcg/mips/mips32-dsp/modsub.c | 30 + tests/tcg/mips/mips32-dsp/msub.c | 30 + tests/tcg/mips/mips32-dsp/msubu.c | 30 + tests/tcg/mips/mips32-dsp/mthi.c | 21 + tests/tcg/mips/mips32-dsp/mthlip.c | 34 + tests/tcg/mips/mips32-dsp/mtlo.c | 21 + tests/tcg/mips/mips32-dsp/muleq_s_w_phr.c | 40 + tests/tcg/mips/mips32-dsp/muleu_s_ph_qbl.c | 25 + tests/tcg/mips/mips32-dsp/muleu_s_ph_qbr.c | 25 + tests/tcg/mips/mips32-dsp/mulq_rs_ph.c | 25 + tests/tcg/mips/mips32-dsp/mult.c | 24 + tests/tcg/mips/mips32-dsp/multu.c | 24 + tests/tcg/mips/mips32-dsp/packrl_ph.c | 21 + tests/tcg/mips/mips32-dsp/pick_ph.c | 23 + tests/tcg/mips/mips32-dsp/pick_qb.c | 23 + tests/tcg/mips/mips32-dsp/preceq_w_phl.c | 20 + tests/tcg/mips/mips32-dsp/preceq_w_phr.c | 20 + tests/tcg/mips/mips32-dsp/precequ_ph_qbl.c | 20 + tests/tcg/mips/mips32-dsp/precequ_ph_qbla.c | 20 + tests/tcg/mips/mips32-dsp/precequ_ph_qbr.c | 20 + tests/tcg/mips/mips32-dsp/precequ_ph_qbra.c | 20 + tests/tcg/mips/mips32-dsp/preceu_ph_qbl.c | 20 + tests/tcg/mips/mips32-dsp/preceu_ph_qbla.c | 20 + tests/tcg/mips/mips32-dsp/preceu_ph_qbr.c | 20 + tests/tcg/mips/mips32-dsp/preceu_ph_qbra.c | 20 + tests/tcg/mips/mips32-dsp/precrq_ph_w.c | 21 + tests/tcg/mips/mips32-dsp/precrq_qb_ph.c | 21 + tests/tcg/mips/mips32-dsp/precrq_rs_ph_w.c | 21 + tests/tcg/mips/mips32-dsp/precrqu_s_qb_ph.c | 21 + tests/tcg/mips/mips32-dsp/raddu_w_qb.c | 20 + tests/tcg/mips/mips32-dsp/rddsp.c | 54 + tests/tcg/mips/mips32-dsp/repl_ph.c | 23 + tests/tcg/mips/mips32-dsp/repl_qb.c | 16 + tests/tcg/mips/mips32-dsp/replv_ph.c | 19 + tests/tcg/mips/mips32-dsp/replv_qb.c | 19 + tests/tcg/mips/mips32-dsp/shilo.c | 27 + tests/tcg/mips/mips32-dsp/shilov.c | 29 + tests/tcg/mips/mips32-dsp/shll_ph.c | 24 + tests/tcg/mips/mips32-dsp/shll_qb.c | 23 + tests/tcg/mips/mips32-dsp/shll_s_ph.c | 24 + tests/tcg/mips/mips32-dsp/shll_s_w.c | 24 + tests/tcg/mips/mips32-dsp/shllv_ph.c | 25 + tests/tcg/mips/mips32-dsp/shllv_qb.c | 24 + tests/tcg/mips/mips32-dsp/shllv_s_ph.c | 25 + tests/tcg/mips/mips32-dsp/shllv_s_w.c | 25 + tests/tcg/mips/mips32-dsp/shra_ph.c | 20 + tests/tcg/mips/mips32-dsp/shra_r_ph.c | 20 + tests/tcg/mips/mips32-dsp/shra_r_w.c | 20 + tests/tcg/mips/mips32-dsp/shrav_ph.c | 21 + tests/tcg/mips/mips32-dsp/shrav_r_ph.c | 21 + tests/tcg/mips/mips32-dsp/shrav_r_w.c | 21 + tests/tcg/mips/mips32-dsp/shrl_qb.c | 20 + tests/tcg/mips/mips32-dsp/shrlv_qb.c | 21 + tests/tcg/mips/mips32-dsp/subq_ph.c | 25 + tests/tcg/mips/mips32-dsp/subq_s_ph.c | 25 + tests/tcg/mips/mips32-dsp/subq_s_w.c | 25 + tests/tcg/mips/mips32-dsp/subu_qb.c | 25 + tests/tcg/mips/mips32-dsp/subu_s_qb.c | 25 + tests/tcg/mips/mips32-dsp/wrdsp.c | 54 + tests/tcg/mips/mips32-dspr2/Makefile | 72 + tests/tcg/mips/mips32-dspr2/absq_s_qb.c | 35 + tests/tcg/mips/mips32-dspr2/addqh_ph.c | 30 + tests/tcg/mips/mips32-dspr2/addqh_r_ph.c | 30 + tests/tcg/mips/mips32-dspr2/addqh_r_w.c | 34 + tests/tcg/mips/mips32-dspr2/addqh_w.c | 34 + tests/tcg/mips/mips32-dspr2/addu_ph.c | 30 + tests/tcg/mips/mips32-dspr2/addu_s_ph.c | 30 + tests/tcg/mips/mips32-dspr2/adduh_qb.c | 30 + tests/tcg/mips/mips32-dspr2/adduh_r_qb.c | 30 + tests/tcg/mips/mips32-dspr2/append.c | 30 + tests/tcg/mips/mips32-dspr2/balign.c | 30 + tests/tcg/mips/mips32-dspr2/cmpgdu_eq_qb.c | 37 + tests/tcg/mips/mips32-dspr2/cmpgdu_le_qb.c | 37 + tests/tcg/mips/mips32-dspr2/cmpgdu_lt_qb.c | 37 + tests/tcg/mips/mips32-dspr2/dpa_w_ph.c | 27 + tests/tcg/mips/mips32-dspr2/dpaqx_s_w_ph.c | 57 + tests/tcg/mips/mips32-dspr2/dpaqx_sa_w_ph.c | 31 + tests/tcg/mips/mips32-dspr2/dpax_w_ph.c | 27 + tests/tcg/mips/mips32-dspr2/dps_w_ph.c | 27 + tests/tcg/mips/mips32-dspr2/dpsqx_s_w_ph.c | 31 + tests/tcg/mips/mips32-dspr2/dpsqx_sa_w_ph.c | 31 + tests/tcg/mips/mips32-dspr2/dpsx_w_ph.c | 27 + tests/tcg/mips/mips32-dspr2/mul_ph.c | 25 + tests/tcg/mips/mips32-dspr2/mul_s_ph.c | 25 + tests/tcg/mips/mips32-dspr2/muleq_s_w_phl.c | 40 + tests/tcg/mips/mips32-dspr2/mulq_rs_w.c | 36 + tests/tcg/mips/mips32-dspr2/mulq_s_ph.c | 25 + tests/tcg/mips/mips32-dspr2/mulq_s_w.c | 36 + tests/tcg/mips/mips32-dspr2/mulsa_w_ph.c | 29 + tests/tcg/mips/mips32-dspr2/mulsaq_s_w_ph.c | 29 + tests/tcg/mips/mips32-dspr2/precr_qb_ph.c | 21 + tests/tcg/mips/mips32-dspr2/precr_sra_ph_w.c | 32 + tests/tcg/mips/mips32-dspr2/precr_sra_r_ph_w.c | 32 + tests/tcg/mips/mips32-dspr2/prepend.c | 30 + tests/tcg/mips/mips32-dspr2/shra_qb.c | 30 + tests/tcg/mips/mips32-dspr2/shra_r_qb.c | 30 + tests/tcg/mips/mips32-dspr2/shrav_qb.c | 32 + tests/tcg/mips/mips32-dspr2/shrav_r_qb.c | 32 + tests/tcg/mips/mips32-dspr2/shrl_ph.c | 20 + tests/tcg/mips/mips32-dspr2/shrlv_ph.c | 21 + tests/tcg/mips/mips32-dspr2/subqh_ph.c | 21 + tests/tcg/mips/mips32-dspr2/subqh_r_ph.c | 21 + tests/tcg/mips/mips32-dspr2/subqh_r_w.c | 21 + tests/tcg/mips/mips32-dspr2/subqh_w.c | 21 + tests/tcg/mips/mips32-dspr2/subu_ph.c | 25 + tests/tcg/mips/mips32-dspr2/subu_s_ph.c | 25 + tests/tcg/mips/mips32-dspr2/subuh_qb.c | 21 + tests/tcg/mips/mips32-dspr2/subuh_r_qb.c | 21 + tests/tcg/mips/mips64-dsp/Makefile | 304 + tests/tcg/mips/mips64-dsp/absq_s_ob.c | 63 + tests/tcg/mips/mips64-dsp/absq_s_ph.c | 37 + tests/tcg/mips/mips64-dsp/absq_s_pw.c | 66 + tests/tcg/mips/mips64-dsp/absq_s_qh.c | 40 + tests/tcg/mips/mips64-dsp/absq_s_w.c | 48 + tests/tcg/mips/mips64-dsp/addq_ph.c | 37 + tests/tcg/mips/mips64-dsp/addq_pw.c | 26 + tests/tcg/mips/mips64-dsp/addq_qh.c | 28 + tests/tcg/mips/mips64-dsp/addq_s_ph.c | 37 + tests/tcg/mips/mips64-dsp/addq_s_pw.c | 45 + tests/tcg/mips/mips64-dsp/addq_s_qh.c | 26 + tests/tcg/mips/mips64-dsp/addsc.c | 37 + tests/tcg/mips/mips64-dsp/addu_ob.c | 27 + tests/tcg/mips/mips64-dsp/addu_qb.c | 37 + tests/tcg/mips/mips64-dsp/addu_s_ob.c | 27 + tests/tcg/mips/mips64-dsp/addu_s_qb.c | 38 + tests/tcg/mips/mips64-dsp/addwc.c | 37 + tests/tcg/mips/mips64-dsp/bitrev.c | 23 + tests/tcg/mips/mips64-dsp/bposge32.c | 50 + tests/tcg/mips/mips64-dsp/bposge64.c | 50 + tests/tcg/mips/mips64-dsp/cmp_eq_ph.c | 42 + tests/tcg/mips/mips64-dsp/cmp_eq_pw.c | 27 + tests/tcg/mips/mips64-dsp/cmp_eq_qh.c | 27 + tests/tcg/mips/mips64-dsp/cmp_le_ph.c | 40 + tests/tcg/mips/mips64-dsp/cmp_le_pw.c | 27 + tests/tcg/mips/mips64-dsp/cmp_le_qh.c | 27 + tests/tcg/mips/mips64-dsp/cmp_lt_ph.c | 41 + tests/tcg/mips/mips64-dsp/cmp_lt_pw.c | 27 + tests/tcg/mips/mips64-dsp/cmp_lt_qh.c | 27 + tests/tcg/mips/mips64-dsp/cmpgu_eq_ob.c | 24 + tests/tcg/mips/mips64-dsp/cmpgu_eq_qb.c | 38 + tests/tcg/mips/mips64-dsp/cmpgu_le_ob.c | 24 + tests/tcg/mips/mips64-dsp/cmpgu_le_qb.c | 37 + tests/tcg/mips/mips64-dsp/cmpgu_lt_ob.c | 24 + tests/tcg/mips/mips64-dsp/cmpgu_lt_qb.c | 38 + tests/tcg/mips/mips64-dsp/cmpu_eq_ob.c | 27 + tests/tcg/mips/mips64-dsp/cmpu_eq_qb.c | 42 + tests/tcg/mips/mips64-dsp/cmpu_le_ob.c | 26 + tests/tcg/mips/mips64-dsp/cmpu_le_qb.c | 41 + tests/tcg/mips/mips64-dsp/cmpu_lt_ob.c | 26 + tests/tcg/mips/mips64-dsp/cmpu_lt_qb.c | 42 + tests/tcg/mips/mips64-dsp/dappend.c | 37 + tests/tcg/mips/mips64-dsp/dextp.c | 33 + tests/tcg/mips/mips64-dsp/dextpdp.c | 37 + tests/tcg/mips/mips64-dsp/dextpdpv.c | 38 + tests/tcg/mips/mips64-dsp/dextpv.c | 34 + tests/tcg/mips/mips64-dsp/dextr_l.c | 27 + tests/tcg/mips/mips64-dsp/dextr_r_l.c | 32 + tests/tcg/mips/mips64-dsp/dextr_r_w.c | 32 + tests/tcg/mips/mips64-dsp/dextr_rs_l.c | 31 + tests/tcg/mips/mips64-dsp/dextr_rs_w.c | 31 + tests/tcg/mips/mips64-dsp/dextr_s_h.c | 31 + tests/tcg/mips/mips64-dsp/dextr_w.c | 27 + tests/tcg/mips/mips64-dsp/dextrv_l.c | 28 + tests/tcg/mips/mips64-dsp/dextrv_r_l.c | 33 + tests/tcg/mips/mips64-dsp/dextrv_r_w.c | 33 + tests/tcg/mips/mips64-dsp/dextrv_rs_l.c | 32 + tests/tcg/mips/mips64-dsp/dextrv_rs_w.c | 32 + tests/tcg/mips/mips64-dsp/dextrv_s_h.c | 32 + tests/tcg/mips/mips64-dsp/dextrv_w.c | 28 + tests/tcg/mips/mips64-dsp/dinsv.c | 25 + tests/tcg/mips/mips64-dsp/dmadd.c | 57 + tests/tcg/mips/mips64-dsp/dmaddu.c | 56 + tests/tcg/mips/mips64-dsp/dmsub.c | 59 + tests/tcg/mips/mips64-dsp/dmsubu.c | 59 + tests/tcg/mips/mips64-dsp/dmthlip.c | 32 + tests/tcg/mips/mips64-dsp/dpaq_s_w_ph.c | 32 + tests/tcg/mips/mips64-dsp/dpaq_s_w_qh.c | 57 + tests/tcg/mips/mips64-dsp/dpaq_sa_l_pw.c | 62 + tests/tcg/mips/mips64-dsp/dpaq_sa_l_w.c | 32 + tests/tcg/mips/mips64-dsp/dpau_h_obl.c | 59 + tests/tcg/mips/mips64-dsp/dpau_h_obr.c | 59 + tests/tcg/mips/mips64-dsp/dpau_h_qbl.c | 29 + tests/tcg/mips/mips64-dsp/dpau_h_qbr.c | 29 + tests/tcg/mips/mips64-dsp/dpsq_s_w_ph.c | 29 + tests/tcg/mips/mips64-dsp/dpsq_s_w_qh.c | 33 + tests/tcg/mips/mips64-dsp/dpsq_sa_l_pw.c | 39 + tests/tcg/mips/mips64-dsp/dpsq_sa_l_w.c | 32 + tests/tcg/mips/mips64-dsp/dpsu_h_obl.c | 32 + tests/tcg/mips/mips64-dsp/dpsu_h_obr.c | 32 + tests/tcg/mips/mips64-dsp/dpsu_h_qbl.c | 29 + tests/tcg/mips/mips64-dsp/dpsu_h_qbr.c | 29 + tests/tcg/mips/mips64-dsp/dshilo.c | 31 + tests/tcg/mips/mips64-dsp/dshilov.c | 32 + tests/tcg/mips/mips64-dsp/extp.c | 50 + tests/tcg/mips/mips64-dsp/extpdp.c | 51 + tests/tcg/mips/mips64-dsp/extpdpv.c | 52 + tests/tcg/mips/mips64-dsp/extpv.c | 51 + tests/tcg/mips/mips64-dsp/extr_r_w.c | 27 + tests/tcg/mips/mips64-dsp/extr_rs_w.c | 27 + tests/tcg/mips/mips64-dsp/extr_s_h.c | 27 + tests/tcg/mips/mips64-dsp/extr_w.c | 27 + tests/tcg/mips/mips64-dsp/extrv_r_w.c | 31 + tests/tcg/mips/mips64-dsp/extrv_rs_w.c | 31 + tests/tcg/mips/mips64-dsp/extrv_s_h.c | 31 + tests/tcg/mips/mips64-dsp/extrv_w.c | 31 + tests/tcg/mips/mips64-dsp/head.S | 16 + tests/tcg/mips/mips64-dsp/insv.c | 26 + tests/tcg/mips/mips64-dsp/io.h | 22 + tests/tcg/mips/mips64-dsp/lbux.c | 27 + tests/tcg/mips/mips64-dsp/ldx.c | 27 + tests/tcg/mips/mips64-dsp/lhx.c | 27 + tests/tcg/mips/mips64-dsp/lwx.c | 27 + tests/tcg/mips/mips64-dsp/madd.c | 33 + tests/tcg/mips/mips64-dsp/maddu.c | 33 + tests/tcg/mips/mips64-dsp/maq_s_l_pwl.c | 56 + tests/tcg/mips/mips64-dsp/maq_s_l_pwr.c | 56 + tests/tcg/mips/mips64-dsp/maq_s_w_phl.c | 33 + tests/tcg/mips/mips64-dsp/maq_s_w_phr.c | 33 + tests/tcg/mips/mips64-dsp/maq_s_w_qhll.c | 62 + tests/tcg/mips/mips64-dsp/maq_s_w_qhlr.c | 62 + tests/tcg/mips/mips64-dsp/maq_s_w_qhrl.c | 63 + tests/tcg/mips/mips64-dsp/maq_s_w_qhrr.c | 63 + tests/tcg/mips/mips64-dsp/maq_sa_w_phl.c | 33 + tests/tcg/mips/mips64-dsp/maq_sa_w_phr.c | 33 + tests/tcg/mips/mips64-dsp/maq_sa_w_qhll.c | 62 + tests/tcg/mips/mips64-dsp/maq_sa_w_qhlr.c | 64 + tests/tcg/mips/mips64-dsp/maq_sa_w_qhrl.c | 64 + tests/tcg/mips/mips64-dsp/maq_sa_w_qhrr.c | 64 + tests/tcg/mips/mips64-dsp/mfhi.c | 24 + tests/tcg/mips/mips64-dsp/mflo.c | 24 + tests/tcg/mips/mips64-dsp/mips_boot.lds | 31 + tests/tcg/mips/mips64-dsp/modsub.c | 37 + tests/tcg/mips/mips64-dsp/msub.c | 32 + tests/tcg/mips/mips64-dsp/msubu.c | 32 + tests/tcg/mips/mips64-dsp/mthi.c | 24 + tests/tcg/mips/mips64-dsp/mthlip.c | 35 + tests/tcg/mips/mips64-dsp/mtlo.c | 22 + tests/tcg/mips/mips64-dsp/muleq_s_pw_qhl.c | 55 + tests/tcg/mips/mips64-dsp/muleq_s_pw_qhr.c | 24 + tests/tcg/mips/mips64-dsp/muleq_s_w_phr.c | 45 + tests/tcg/mips/mips64-dsp/muleu_s_ph_qbl.c | 27 + tests/tcg/mips/mips64-dsp/muleu_s_ph_qbr.c | 27 + tests/tcg/mips/mips64-dsp/muleu_s_qh_obl.c | 25 + tests/tcg/mips/mips64-dsp/muleu_s_qh_obr.c | 25 + tests/tcg/mips/mips64-dsp/mulq_rs_ph.c | 27 + tests/tcg/mips/mips64-dsp/mulq_rs_qh.c | 33 + tests/tcg/mips/mips64-dsp/mulsaq_s_l_pw.c | 59 + tests/tcg/mips/mips64-dsp/mulsaq_s_w_qh.c | 57 + tests/tcg/mips/mips64-dsp/mult.c | 26 + tests/tcg/mips/mips64-dsp/multu.c | 26 + tests/tcg/mips/mips64-dsp/packrl_ph.c | 24 + tests/tcg/mips/mips64-dsp/packrl_pw.c | 24 + tests/tcg/mips/mips64-dsp/pick_ob.c | 27 + tests/tcg/mips/mips64-dsp/pick_ph.c | 26 + tests/tcg/mips/mips64-dsp/pick_pw.c | 28 + tests/tcg/mips/mips64-dsp/pick_qb.c | 26 + tests/tcg/mips/mips64-dsp/pick_qh.c | 28 + tests/tcg/mips/mips64-dsp/preceq_l_pwl.c | 24 + tests/tcg/mips/mips64-dsp/preceq_l_pwr.c | 24 + tests/tcg/mips/mips64-dsp/preceq_pw_qhl.c | 21 + tests/tcg/mips/mips64-dsp/preceq_pw_qhla.c | 23 + tests/tcg/mips/mips64-dsp/preceq_pw_qhr.c | 21 + tests/tcg/mips/mips64-dsp/preceq_pw_qhra.c | 23 + tests/tcg/mips/mips64-dsp/preceq_w_phl.c | 23 + tests/tcg/mips/mips64-dsp/preceq_w_phr.c | 23 + tests/tcg/mips/mips64-dsp/precequ_ph_qbl.c | 23 + tests/tcg/mips/mips64-dsp/precequ_ph_qbla.c | 23 + tests/tcg/mips/mips64-dsp/precequ_ph_qbr.c | 23 + tests/tcg/mips/mips64-dsp/precequ_ph_qbra.c | 23 + tests/tcg/mips/mips64-dsp/precequ_qh_obl.c | 22 + tests/tcg/mips/mips64-dsp/precequ_qh_obla.c | 22 + tests/tcg/mips/mips64-dsp/precequ_qh_obr.c | 24 + tests/tcg/mips/mips64-dsp/precequ_qh_obra.c | 24 + tests/tcg/mips/mips64-dsp/preceu_ph_qbl.c | 23 + tests/tcg/mips/mips64-dsp/preceu_ph_qbla.c | 23 + tests/tcg/mips/mips64-dsp/preceu_ph_qbr.c | 23 + tests/tcg/mips/mips64-dsp/preceu_ph_qbra.c | 23 + tests/tcg/mips/mips64-dsp/preceu_qh_obl.c | 22 + tests/tcg/mips/mips64-dsp/preceu_qh_obla.c | 22 + tests/tcg/mips/mips64-dsp/preceu_qh_obr.c | 23 + tests/tcg/mips/mips64-dsp/preceu_qh_obra.c | 23 + tests/tcg/mips/mips64-dsp/precr_ob_qh.c | 25 + tests/tcg/mips/mips64-dsp/precr_sra_qh_pw.c | 40 + tests/tcg/mips/mips64-dsp/precr_sra_r_qh_pw.c | 40 + tests/tcg/mips/mips64-dsp/precrq_ob_qh.c | 25 + tests/tcg/mips/mips64-dsp/precrq_ph_w.c | 24 + tests/tcg/mips/mips64-dsp/precrq_pw_l.c | 25 + tests/tcg/mips/mips64-dsp/precrq_qb_ph.c | 24 + tests/tcg/mips/mips64-dsp/precrq_qh_pw.c | 25 + tests/tcg/mips/mips64-dsp/precrq_rs_ph_w.c | 24 + tests/tcg/mips/mips64-dsp/precrq_rs_qh_pw.c | 25 + tests/tcg/mips/mips64-dsp/precrqu_s_ob_qh.c | 27 + tests/tcg/mips/mips64-dsp/precrqu_s_qb_ph.c | 24 + tests/tcg/mips/mips64-dsp/prependd.c | 37 + tests/tcg/mips/mips64-dsp/prependw.c | 37 + tests/tcg/mips/mips64-dsp/printf.c | 266 + tests/tcg/mips/mips64-dsp/raddu_l_ob.c | 22 + tests/tcg/mips/mips64-dsp/raddu_w_qb.c | 23 + tests/tcg/mips/mips64-dsp/rddsp.c | 53 + tests/tcg/mips/mips64-dsp/repl_ob.c | 21 + tests/tcg/mips/mips64-dsp/repl_ph.c | 30 + tests/tcg/mips/mips64-dsp/repl_pw.c | 34 + tests/tcg/mips/mips64-dsp/repl_qb.c | 19 + tests/tcg/mips/mips64-dsp/repl_qh.c | 34 + tests/tcg/mips/mips64-dsp/replv_ob.c | 23 + tests/tcg/mips/mips64-dsp/replv_ph.c | 22 + tests/tcg/mips/mips64-dsp/replv_pw.c | 23 + tests/tcg/mips/mips64-dsp/replv_qb.c | 22 + tests/tcg/mips/mips64-dsp/shilo.c | 29 + tests/tcg/mips/mips64-dsp/shilov.c | 31 + tests/tcg/mips/mips64-dsp/shll_ob.c | 26 + tests/tcg/mips/mips64-dsp/shll_ph.c | 26 + tests/tcg/mips/mips64-dsp/shll_pw.c | 26 + tests/tcg/mips/mips64-dsp/shll_qb.c | 26 + tests/tcg/mips/mips64-dsp/shll_qh.c | 26 + tests/tcg/mips/mips64-dsp/shll_s_ph.c | 26 + tests/tcg/mips/mips64-dsp/shll_s_pw.c | 26 + tests/tcg/mips/mips64-dsp/shll_s_qh.c | 26 + tests/tcg/mips/mips64-dsp/shll_s_w.c | 26 + tests/tcg/mips/mips64-dsp/shllv_ob.c | 27 + tests/tcg/mips/mips64-dsp/shllv_ph.c | 27 + tests/tcg/mips/mips64-dsp/shllv_pw.c | 27 + tests/tcg/mips/mips64-dsp/shllv_qb.c | 27 + tests/tcg/mips/mips64-dsp/shllv_qh.c | 27 + tests/tcg/mips/mips64-dsp/shllv_s_ph.c | 27 + tests/tcg/mips/mips64-dsp/shllv_s_pw.c | 27 + tests/tcg/mips/mips64-dsp/shllv_s_qh.c | 27 + tests/tcg/mips/mips64-dsp/shllv_s_w.c | 27 + tests/tcg/mips/mips64-dsp/shra_ob.c | 22 + tests/tcg/mips/mips64-dsp/shra_ph.c | 23 + tests/tcg/mips/mips64-dsp/shra_pw.c | 22 + tests/tcg/mips/mips64-dsp/shra_qh.c | 24 + tests/tcg/mips/mips64-dsp/shra_r_ob.c | 22 + tests/tcg/mips/mips64-dsp/shra_r_ph.c | 23 + tests/tcg/mips/mips64-dsp/shra_r_pw.c | 22 + tests/tcg/mips/mips64-dsp/shra_r_qh.c | 23 + tests/tcg/mips/mips64-dsp/shra_r_w.c | 23 + tests/tcg/mips/mips64-dsp/shrav_ph.c | 24 + tests/tcg/mips/mips64-dsp/shrav_pw.c | 23 + tests/tcg/mips/mips64-dsp/shrav_qh.c | 24 + tests/tcg/mips/mips64-dsp/shrav_r_ph.c | 24 + tests/tcg/mips/mips64-dsp/shrav_r_pw.c | 23 + tests/tcg/mips/mips64-dsp/shrav_r_qh.c | 24 + tests/tcg/mips/mips64-dsp/shrav_r_w.c | 24 + tests/tcg/mips/mips64-dsp/shrl_ob.c | 23 + tests/tcg/mips/mips64-dsp/shrl_qb.c | 23 + tests/tcg/mips/mips64-dsp/shrl_qh.c | 22 + tests/tcg/mips/mips64-dsp/shrlv_ob.c | 24 + tests/tcg/mips/mips64-dsp/shrlv_qb.c | 24 + tests/tcg/mips/mips64-dsp/shrlv_qh.c | 23 + tests/tcg/mips/mips64-dsp/subq_ph.c | 27 + tests/tcg/mips/mips64-dsp/subq_pw.c | 44 + tests/tcg/mips/mips64-dsp/subq_qh.c | 26 + tests/tcg/mips/mips64-dsp/subq_s_ph.c | 27 + tests/tcg/mips/mips64-dsp/subq_s_pw.c | 45 + tests/tcg/mips/mips64-dsp/subq_s_qh.c | 44 + tests/tcg/mips/mips64-dsp/subq_s_w.c | 27 + tests/tcg/mips/mips64-dsp/subu_ob.c | 26 + tests/tcg/mips/mips64-dsp/subu_qb.c | 27 + tests/tcg/mips/mips64-dsp/subu_s_ob.c | 26 + tests/tcg/mips/mips64-dsp/subu_s_qb.c | 27 + tests/tcg/mips/mips64-dsp/wrdsp.c | 48 + tests/tcg/mips/mips64-dspr2/.directory | 2 + tests/tcg/mips/mips64-dspr2/Makefile | 117 + tests/tcg/mips/mips64-dspr2/absq_s_qb.c | 42 + tests/tcg/mips/mips64-dspr2/addqh_ph.c | 35 + tests/tcg/mips/mips64-dspr2/addqh_r_ph.c | 35 + tests/tcg/mips/mips64-dspr2/addqh_r_w.c | 38 + tests/tcg/mips/mips64-dspr2/addqh_w.c | 39 + tests/tcg/mips/mips64-dspr2/addu_ph.c | 35 + tests/tcg/mips/mips64-dspr2/addu_qh.c | 41 + tests/tcg/mips/mips64-dspr2/addu_s_ph.c | 35 + tests/tcg/mips/mips64-dspr2/addu_s_qh.c | 41 + tests/tcg/mips/mips64-dspr2/adduh_ob.c | 21 + tests/tcg/mips/mips64-dspr2/adduh_qb.c | 35 + tests/tcg/mips/mips64-dspr2/adduh_r_ob.c | 21 + tests/tcg/mips/mips64-dspr2/adduh_r_qb.c | 35 + tests/tcg/mips/mips64-dspr2/append.c | 35 + tests/tcg/mips/mips64-dspr2/balign.c | 35 + tests/tcg/mips/mips64-dspr2/cmpgdu_eq_ob.c | 26 + tests/tcg/mips/mips64-dspr2/cmpgdu_eq_qb.c | 41 + tests/tcg/mips/mips64-dspr2/cmpgdu_le_ob.c | 26 + tests/tcg/mips/mips64-dspr2/cmpgdu_le_qb.c | 48 + tests/tcg/mips/mips64-dspr2/cmpgdu_lt_ob.c | 26 + tests/tcg/mips/mips64-dspr2/cmpgdu_lt_qb.c | 48 + tests/tcg/mips/mips64-dspr2/dbalign.c | 23 + tests/tcg/mips/mips64-dspr2/dpa_w_ph.c | 32 + tests/tcg/mips/mips64-dspr2/dpa_w_qh.c | 56 + tests/tcg/mips/mips64-dspr2/dpaqx_s_w_ph.c | 74 + tests/tcg/mips/mips64-dspr2/dpaqx_sa_w_ph.c | 42 + tests/tcg/mips/mips64-dspr2/dpax_w_ph.c | 32 + tests/tcg/mips/mips64-dspr2/dps_w_ph.c | 28 + tests/tcg/mips/mips64-dspr2/dps_w_qh.c | 55 + tests/tcg/mips/mips64-dspr2/dpsqx_s_w_ph.c | 31 + tests/tcg/mips/mips64-dspr2/dpsqx_sa_w_ph.c | 30 + tests/tcg/mips/mips64-dspr2/dpsx_w_ph.c | 28 + tests/tcg/mips/mips64-dspr2/head.S | 16 + tests/tcg/mips/mips64-dspr2/io.h | 22 + tests/tcg/mips/mips64-dspr2/mips_boot.lds | 31 + tests/tcg/mips/mips64-dspr2/mul_ph.c | 26 + tests/tcg/mips/mips64-dspr2/mul_s_ph.c | 26 + tests/tcg/mips/mips64-dspr2/muleq_s_w_phl.c | 42 + tests/tcg/mips/mips64-dspr2/mulq_rs_w.c | 40 + tests/tcg/mips/mips64-dspr2/mulq_s_ph.c | 26 + tests/tcg/mips/mips64-dspr2/mulq_s_w.c | 40 + tests/tcg/mips/mips64-dspr2/mulsa_w_ph.c | 30 + tests/tcg/mips/mips64-dspr2/mulsaq_s_w_ph.c | 30 + tests/tcg/mips/mips64-dspr2/precr_qb_ph.c | 23 + tests/tcg/mips/mips64-dspr2/precr_sra_ph_w.c | 37 + tests/tcg/mips/mips64-dspr2/precr_sra_r_ph_w.c | 37 + tests/tcg/mips/mips64-dspr2/prepend.c | 35 + tests/tcg/mips/mips64-dspr2/printf.c | 266 + tests/tcg/mips/mips64-dspr2/shra_qb.c | 35 + tests/tcg/mips/mips64-dspr2/shra_r_qb.c | 35 + tests/tcg/mips/mips64-dspr2/shrav_ob.c | 22 + tests/tcg/mips/mips64-dspr2/shrav_qb.c | 37 + tests/tcg/mips/mips64-dspr2/shrav_r_ob.c | 22 + tests/tcg/mips/mips64-dspr2/shrav_r_qb.c | 37 + tests/tcg/mips/mips64-dspr2/shrl_ph.c | 22 + tests/tcg/mips/mips64-dspr2/shrlv_ph.c | 23 + tests/tcg/mips/mips64-dspr2/subqh_ph.c | 23 + tests/tcg/mips/mips64-dspr2/subqh_r_ph.c | 23 + tests/tcg/mips/mips64-dspr2/subqh_r_w.c | 23 + tests/tcg/mips/mips64-dspr2/subqh_w.c | 23 + tests/tcg/mips/mips64-dspr2/subu_ph.c | 26 + tests/tcg/mips/mips64-dspr2/subu_qh.c | 24 + tests/tcg/mips/mips64-dspr2/subu_s_ph.c | 25 + tests/tcg/mips/mips64-dspr2/subu_s_qh.c | 24 + tests/tcg/mips/mips64-dspr2/subuh_ob.c | 23 + tests/tcg/mips/mips64-dspr2/subuh_qb.c | 23 + tests/tcg/mips/mips64-dspr2/subuh_r_ob.c | 23 + tests/tcg/mips/mips64-dspr2/subuh_r_qb.c | 23 + 495 files changed, 27393 insertions(+), 129 deletions(-) create mode 100644 target-mips/dsp_helper.c create mode 100644 tests/tcg/mips/mips32-dsp/Makefile create mode 100644 tests/tcg/mips/mips32-dsp/absq_s_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/absq_s_w.c create mode 100644 tests/tcg/mips/mips32-dsp/addq_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/addq_s_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/addsc.c create mode 100644 tests/tcg/mips/mips32-dsp/addu_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/addu_s_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/addwc.c create mode 100644 tests/tcg/mips/mips32-dsp/bitrev.c create mode 100644 tests/tcg/mips/mips32-dsp/bposge32.c create mode 100644 tests/tcg/mips/mips32-dsp/cmp_eq_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/cmp_le_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/cmp_lt_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/cmpgu_eq_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/cmpgu_le_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/cmpgu_lt_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/cmpu_eq_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/cmpu_le_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/cmpu_lt_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/dpaq_s_w_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/dpaq_sa_l_w.c create mode 100644 tests/tcg/mips/mips32-dsp/dpau_h_qbl.c create mode 100644 tests/tcg/mips/mips32-dsp/dpau_h_qbr.c create mode 100644 tests/tcg/mips/mips32-dsp/dpsq_s_w_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/dpsq_sa_l_w.c create mode 100644 tests/tcg/mips/mips32-dsp/dpsu_h_qbl.c create mode 100644 tests/tcg/mips/mips32-dsp/dpsu_h_qbr.c create mode 100644 tests/tcg/mips/mips32-dsp/extp.c create mode 100644 tests/tcg/mips/mips32-dsp/extpdp.c create mode 100644 tests/tcg/mips/mips32-dsp/extpdpv.c create mode 100644 tests/tcg/mips/mips32-dsp/extpv.c create mode 100644 tests/tcg/mips/mips32-dsp/extr_r_w.c create mode 100644 tests/tcg/mips/mips32-dsp/extr_rs_w.c create mode 100644 tests/tcg/mips/mips32-dsp/extr_s_h.c create mode 100644 tests/tcg/mips/mips32-dsp/extr_w.c create mode 100644 tests/tcg/mips/mips32-dsp/extrv_r_w.c create mode 100644 tests/tcg/mips/mips32-dsp/extrv_rs_w.c create mode 100644 tests/tcg/mips/mips32-dsp/extrv_s_h.c create mode 100644 tests/tcg/mips/mips32-dsp/extrv_w.c create mode 100644 tests/tcg/mips/mips32-dsp/insv.c create mode 100644 tests/tcg/mips/mips32-dsp/lbux.c create mode 100644 tests/tcg/mips/mips32-dsp/lhx.c create mode 100644 tests/tcg/mips/mips32-dsp/lwx.c create mode 100644 tests/tcg/mips/mips32-dsp/madd.c create mode 100644 tests/tcg/mips/mips32-dsp/maddu.c create mode 100644 tests/tcg/mips/mips32-dsp/main.c create mode 100644 tests/tcg/mips/mips32-dsp/maq_s_w_phl.c create mode 100644 tests/tcg/mips/mips32-dsp/maq_s_w_phr.c create mode 100644 tests/tcg/mips/mips32-dsp/maq_sa_w_phl.c create mode 100644 tests/tcg/mips/mips32-dsp/maq_sa_w_phr.c create mode 100644 tests/tcg/mips/mips32-dsp/mfhi.c create mode 100644 tests/tcg/mips/mips32-dsp/mflo.c create mode 100644 tests/tcg/mips/mips32-dsp/modsub.c create mode 100644 tests/tcg/mips/mips32-dsp/msub.c create mode 100644 tests/tcg/mips/mips32-dsp/msubu.c create mode 100644 tests/tcg/mips/mips32-dsp/mthi.c create mode 100644 tests/tcg/mips/mips32-dsp/mthlip.c create mode 100644 tests/tcg/mips/mips32-dsp/mtlo.c create mode 100644 tests/tcg/mips/mips32-dsp/muleq_s_w_phr.c create mode 100644 tests/tcg/mips/mips32-dsp/muleu_s_ph_qbl.c create mode 100644 tests/tcg/mips/mips32-dsp/muleu_s_ph_qbr.c create mode 100644 tests/tcg/mips/mips32-dsp/mulq_rs_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/mult.c create mode 100644 tests/tcg/mips/mips32-dsp/multu.c create mode 100644 tests/tcg/mips/mips32-dsp/packrl_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/pick_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/pick_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/preceq_w_phl.c create mode 100644 tests/tcg/mips/mips32-dsp/preceq_w_phr.c create mode 100644 tests/tcg/mips/mips32-dsp/precequ_ph_qbl.c create mode 100644 tests/tcg/mips/mips32-dsp/precequ_ph_qbla.c create mode 100644 tests/tcg/mips/mips32-dsp/precequ_ph_qbr.c create mode 100644 tests/tcg/mips/mips32-dsp/precequ_ph_qbra.c create mode 100644 tests/tcg/mips/mips32-dsp/preceu_ph_qbl.c create mode 100644 tests/tcg/mips/mips32-dsp/preceu_ph_qbla.c create mode 100644 tests/tcg/mips/mips32-dsp/preceu_ph_qbr.c create mode 100644 tests/tcg/mips/mips32-dsp/preceu_ph_qbra.c create mode 100644 tests/tcg/mips/mips32-dsp/precrq_ph_w.c create mode 100644 tests/tcg/mips/mips32-dsp/precrq_qb_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/precrq_rs_ph_w.c create mode 100644 tests/tcg/mips/mips32-dsp/precrqu_s_qb_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/raddu_w_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/rddsp.c create mode 100644 tests/tcg/mips/mips32-dsp/repl_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/repl_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/replv_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/replv_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/shilo.c create mode 100644 tests/tcg/mips/mips32-dsp/shilov.c create mode 100644 tests/tcg/mips/mips32-dsp/shll_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/shll_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/shll_s_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/shll_s_w.c create mode 100644 tests/tcg/mips/mips32-dsp/shllv_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/shllv_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/shllv_s_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/shllv_s_w.c create mode 100644 tests/tcg/mips/mips32-dsp/shra_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/shra_r_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/shra_r_w.c create mode 100644 tests/tcg/mips/mips32-dsp/shrav_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/shrav_r_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/shrav_r_w.c create mode 100644 tests/tcg/mips/mips32-dsp/shrl_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/shrlv_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/subq_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/subq_s_ph.c create mode 100644 tests/tcg/mips/mips32-dsp/subq_s_w.c create mode 100644 tests/tcg/mips/mips32-dsp/subu_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/subu_s_qb.c create mode 100644 tests/tcg/mips/mips32-dsp/wrdsp.c create mode 100644 tests/tcg/mips/mips32-dspr2/Makefile create mode 100644 tests/tcg/mips/mips32-dspr2/absq_s_qb.c create mode 100644 tests/tcg/mips/mips32-dspr2/addqh_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/addqh_r_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/addqh_r_w.c create mode 100644 tests/tcg/mips/mips32-dspr2/addqh_w.c create mode 100644 tests/tcg/mips/mips32-dspr2/addu_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/addu_s_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/adduh_qb.c create mode 100644 tests/tcg/mips/mips32-dspr2/adduh_r_qb.c create mode 100644 tests/tcg/mips/mips32-dspr2/append.c create mode 100644 tests/tcg/mips/mips32-dspr2/balign.c create mode 100644 tests/tcg/mips/mips32-dspr2/cmpgdu_eq_qb.c create mode 100644 tests/tcg/mips/mips32-dspr2/cmpgdu_le_qb.c create mode 100644 tests/tcg/mips/mips32-dspr2/cmpgdu_lt_qb.c create mode 100644 tests/tcg/mips/mips32-dspr2/dpa_w_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/dpaqx_s_w_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/dpaqx_sa_w_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/dpax_w_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/dps_w_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/dpsqx_s_w_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/dpsqx_sa_w_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/dpsx_w_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/mul_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/mul_s_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/muleq_s_w_phl.c create mode 100644 tests/tcg/mips/mips32-dspr2/mulq_rs_w.c create mode 100644 tests/tcg/mips/mips32-dspr2/mulq_s_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/mulq_s_w.c create mode 100644 tests/tcg/mips/mips32-dspr2/mulsa_w_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/mulsaq_s_w_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/precr_qb_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/precr_sra_ph_w.c create mode 100644 tests/tcg/mips/mips32-dspr2/precr_sra_r_ph_w.c create mode 100644 tests/tcg/mips/mips32-dspr2/prepend.c create mode 100644 tests/tcg/mips/mips32-dspr2/shra_qb.c create mode 100644 tests/tcg/mips/mips32-dspr2/shra_r_qb.c create mode 100644 tests/tcg/mips/mips32-dspr2/shrav_qb.c create mode 100644 tests/tcg/mips/mips32-dspr2/shrav_r_qb.c create mode 100644 tests/tcg/mips/mips32-dspr2/shrl_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/shrlv_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/subqh_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/subqh_r_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/subqh_r_w.c create mode 100644 tests/tcg/mips/mips32-dspr2/subqh_w.c create mode 100644 tests/tcg/mips/mips32-dspr2/subu_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/subu_s_ph.c create mode 100644 tests/tcg/mips/mips32-dspr2/subuh_qb.c create mode 100644 tests/tcg/mips/mips32-dspr2/subuh_r_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/Makefile create mode 100644 tests/tcg/mips/mips64-dsp/absq_s_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/absq_s_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/absq_s_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/absq_s_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/absq_s_w.c create mode 100644 tests/tcg/mips/mips64-dsp/addq_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/addq_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/addq_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/addq_s_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/addq_s_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/addq_s_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/addsc.c create mode 100644 tests/tcg/mips/mips64-dsp/addu_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/addu_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/addu_s_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/addu_s_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/addwc.c create mode 100644 tests/tcg/mips/mips64-dsp/bitrev.c create mode 100644 tests/tcg/mips/mips64-dsp/bposge32.c create mode 100644 tests/tcg/mips/mips64-dsp/bposge64.c create mode 100644 tests/tcg/mips/mips64-dsp/cmp_eq_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/cmp_eq_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/cmp_eq_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/cmp_le_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/cmp_le_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/cmp_le_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/cmp_lt_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/cmp_lt_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/cmp_lt_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/cmpgu_eq_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/cmpgu_eq_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/cmpgu_le_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/cmpgu_le_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/cmpgu_lt_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/cmpgu_lt_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/cmpu_eq_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/cmpu_eq_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/cmpu_le_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/cmpu_le_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/cmpu_lt_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/cmpu_lt_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/dappend.c create mode 100644 tests/tcg/mips/mips64-dsp/dextp.c create mode 100644 tests/tcg/mips/mips64-dsp/dextpdp.c create mode 100644 tests/tcg/mips/mips64-dsp/dextpdpv.c create mode 100644 tests/tcg/mips/mips64-dsp/dextpv.c create mode 100644 tests/tcg/mips/mips64-dsp/dextr_l.c create mode 100644 tests/tcg/mips/mips64-dsp/dextr_r_l.c create mode 100644 tests/tcg/mips/mips64-dsp/dextr_r_w.c create mode 100644 tests/tcg/mips/mips64-dsp/dextr_rs_l.c create mode 100644 tests/tcg/mips/mips64-dsp/dextr_rs_w.c create mode 100644 tests/tcg/mips/mips64-dsp/dextr_s_h.c create mode 100644 tests/tcg/mips/mips64-dsp/dextr_w.c create mode 100644 tests/tcg/mips/mips64-dsp/dextrv_l.c create mode 100644 tests/tcg/mips/mips64-dsp/dextrv_r_l.c create mode 100644 tests/tcg/mips/mips64-dsp/dextrv_r_w.c create mode 100644 tests/tcg/mips/mips64-dsp/dextrv_rs_l.c create mode 100644 tests/tcg/mips/mips64-dsp/dextrv_rs_w.c create mode 100644 tests/tcg/mips/mips64-dsp/dextrv_s_h.c create mode 100644 tests/tcg/mips/mips64-dsp/dextrv_w.c create mode 100644 tests/tcg/mips/mips64-dsp/dinsv.c create mode 100644 tests/tcg/mips/mips64-dsp/dmadd.c create mode 100644 tests/tcg/mips/mips64-dsp/dmaddu.c create mode 100644 tests/tcg/mips/mips64-dsp/dmsub.c create mode 100644 tests/tcg/mips/mips64-dsp/dmsubu.c create mode 100644 tests/tcg/mips/mips64-dsp/dmthlip.c create mode 100644 tests/tcg/mips/mips64-dsp/dpaq_s_w_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/dpaq_s_w_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/dpaq_sa_l_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/dpaq_sa_l_w.c create mode 100644 tests/tcg/mips/mips64-dsp/dpau_h_obl.c create mode 100644 tests/tcg/mips/mips64-dsp/dpau_h_obr.c create mode 100644 tests/tcg/mips/mips64-dsp/dpau_h_qbl.c create mode 100644 tests/tcg/mips/mips64-dsp/dpau_h_qbr.c create mode 100644 tests/tcg/mips/mips64-dsp/dpsq_s_w_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/dpsq_s_w_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/dpsq_sa_l_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/dpsq_sa_l_w.c create mode 100644 tests/tcg/mips/mips64-dsp/dpsu_h_obl.c create mode 100644 tests/tcg/mips/mips64-dsp/dpsu_h_obr.c create mode 100644 tests/tcg/mips/mips64-dsp/dpsu_h_qbl.c create mode 100644 tests/tcg/mips/mips64-dsp/dpsu_h_qbr.c create mode 100644 tests/tcg/mips/mips64-dsp/dshilo.c create mode 100644 tests/tcg/mips/mips64-dsp/dshilov.c create mode 100644 tests/tcg/mips/mips64-dsp/extp.c create mode 100644 tests/tcg/mips/mips64-dsp/extpdp.c create mode 100644 tests/tcg/mips/mips64-dsp/extpdpv.c create mode 100644 tests/tcg/mips/mips64-dsp/extpv.c create mode 100644 tests/tcg/mips/mips64-dsp/extr_r_w.c create mode 100644 tests/tcg/mips/mips64-dsp/extr_rs_w.c create mode 100644 tests/tcg/mips/mips64-dsp/extr_s_h.c create mode 100644 tests/tcg/mips/mips64-dsp/extr_w.c create mode 100644 tests/tcg/mips/mips64-dsp/extrv_r_w.c create mode 100644 tests/tcg/mips/mips64-dsp/extrv_rs_w.c create mode 100644 tests/tcg/mips/mips64-dsp/extrv_s_h.c create mode 100644 tests/tcg/mips/mips64-dsp/extrv_w.c create mode 100644 tests/tcg/mips/mips64-dsp/head.S create mode 100644 tests/tcg/mips/mips64-dsp/insv.c create mode 100644 tests/tcg/mips/mips64-dsp/io.h create mode 100644 tests/tcg/mips/mips64-dsp/lbux.c create mode 100644 tests/tcg/mips/mips64-dsp/ldx.c create mode 100644 tests/tcg/mips/mips64-dsp/lhx.c create mode 100644 tests/tcg/mips/mips64-dsp/lwx.c create mode 100644 tests/tcg/mips/mips64-dsp/madd.c create mode 100644 tests/tcg/mips/mips64-dsp/maddu.c create mode 100644 tests/tcg/mips/mips64-dsp/maq_s_l_pwl.c create mode 100644 tests/tcg/mips/mips64-dsp/maq_s_l_pwr.c create mode 100644 tests/tcg/mips/mips64-dsp/maq_s_w_phl.c create mode 100644 tests/tcg/mips/mips64-dsp/maq_s_w_phr.c create mode 100644 tests/tcg/mips/mips64-dsp/maq_s_w_qhll.c create mode 100644 tests/tcg/mips/mips64-dsp/maq_s_w_qhlr.c create mode 100644 tests/tcg/mips/mips64-dsp/maq_s_w_qhrl.c create mode 100644 tests/tcg/mips/mips64-dsp/maq_s_w_qhrr.c create mode 100644 tests/tcg/mips/mips64-dsp/maq_sa_w_phl.c create mode 100644 tests/tcg/mips/mips64-dsp/maq_sa_w_phr.c create mode 100644 tests/tcg/mips/mips64-dsp/maq_sa_w_qhll.c create mode 100644 tests/tcg/mips/mips64-dsp/maq_sa_w_qhlr.c create mode 100644 tests/tcg/mips/mips64-dsp/maq_sa_w_qhrl.c create mode 100644 tests/tcg/mips/mips64-dsp/maq_sa_w_qhrr.c create mode 100644 tests/tcg/mips/mips64-dsp/mfhi.c create mode 100644 tests/tcg/mips/mips64-dsp/mflo.c create mode 100644 tests/tcg/mips/mips64-dsp/mips_boot.lds create mode 100644 tests/tcg/mips/mips64-dsp/modsub.c create mode 100644 tests/tcg/mips/mips64-dsp/msub.c create mode 100644 tests/tcg/mips/mips64-dsp/msubu.c create mode 100644 tests/tcg/mips/mips64-dsp/mthi.c create mode 100644 tests/tcg/mips/mips64-dsp/mthlip.c create mode 100644 tests/tcg/mips/mips64-dsp/mtlo.c create mode 100644 tests/tcg/mips/mips64-dsp/muleq_s_pw_qhl.c create mode 100644 tests/tcg/mips/mips64-dsp/muleq_s_pw_qhr.c create mode 100644 tests/tcg/mips/mips64-dsp/muleq_s_w_phr.c create mode 100644 tests/tcg/mips/mips64-dsp/muleu_s_ph_qbl.c create mode 100644 tests/tcg/mips/mips64-dsp/muleu_s_ph_qbr.c create mode 100644 tests/tcg/mips/mips64-dsp/muleu_s_qh_obl.c create mode 100644 tests/tcg/mips/mips64-dsp/muleu_s_qh_obr.c create mode 100644 tests/tcg/mips/mips64-dsp/mulq_rs_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/mulq_rs_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/mulsaq_s_l_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/mulsaq_s_w_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/mult.c create mode 100644 tests/tcg/mips/mips64-dsp/multu.c create mode 100644 tests/tcg/mips/mips64-dsp/packrl_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/packrl_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/pick_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/pick_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/pick_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/pick_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/pick_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/preceq_l_pwl.c create mode 100644 tests/tcg/mips/mips64-dsp/preceq_l_pwr.c create mode 100644 tests/tcg/mips/mips64-dsp/preceq_pw_qhl.c create mode 100644 tests/tcg/mips/mips64-dsp/preceq_pw_qhla.c create mode 100644 tests/tcg/mips/mips64-dsp/preceq_pw_qhr.c create mode 100644 tests/tcg/mips/mips64-dsp/preceq_pw_qhra.c create mode 100644 tests/tcg/mips/mips64-dsp/preceq_w_phl.c create mode 100644 tests/tcg/mips/mips64-dsp/preceq_w_phr.c create mode 100644 tests/tcg/mips/mips64-dsp/precequ_ph_qbl.c create mode 100644 tests/tcg/mips/mips64-dsp/precequ_ph_qbla.c create mode 100644 tests/tcg/mips/mips64-dsp/precequ_ph_qbr.c create mode 100644 tests/tcg/mips/mips64-dsp/precequ_ph_qbra.c create mode 100644 tests/tcg/mips/mips64-dsp/precequ_qh_obl.c create mode 100644 tests/tcg/mips/mips64-dsp/precequ_qh_obla.c create mode 100644 tests/tcg/mips/mips64-dsp/precequ_qh_obr.c create mode 100644 tests/tcg/mips/mips64-dsp/precequ_qh_obra.c create mode 100644 tests/tcg/mips/mips64-dsp/preceu_ph_qbl.c create mode 100644 tests/tcg/mips/mips64-dsp/preceu_ph_qbla.c create mode 100644 tests/tcg/mips/mips64-dsp/preceu_ph_qbr.c create mode 100644 tests/tcg/mips/mips64-dsp/preceu_ph_qbra.c create mode 100644 tests/tcg/mips/mips64-dsp/preceu_qh_obl.c create mode 100644 tests/tcg/mips/mips64-dsp/preceu_qh_obla.c create mode 100644 tests/tcg/mips/mips64-dsp/preceu_qh_obr.c create mode 100644 tests/tcg/mips/mips64-dsp/preceu_qh_obra.c create mode 100644 tests/tcg/mips/mips64-dsp/precr_ob_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/precr_sra_qh_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/precr_sra_r_qh_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/precrq_ob_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/precrq_ph_w.c create mode 100644 tests/tcg/mips/mips64-dsp/precrq_pw_l.c create mode 100644 tests/tcg/mips/mips64-dsp/precrq_qb_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/precrq_qh_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/precrq_rs_ph_w.c create mode 100644 tests/tcg/mips/mips64-dsp/precrq_rs_qh_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/precrqu_s_ob_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/precrqu_s_qb_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/prependd.c create mode 100644 tests/tcg/mips/mips64-dsp/prependw.c create mode 100644 tests/tcg/mips/mips64-dsp/printf.c create mode 100644 tests/tcg/mips/mips64-dsp/raddu_l_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/raddu_w_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/rddsp.c create mode 100644 tests/tcg/mips/mips64-dsp/repl_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/repl_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/repl_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/repl_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/repl_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/replv_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/replv_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/replv_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/replv_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/shilo.c create mode 100644 tests/tcg/mips/mips64-dsp/shilov.c create mode 100644 tests/tcg/mips/mips64-dsp/shll_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/shll_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/shll_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/shll_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/shll_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/shll_s_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/shll_s_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/shll_s_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/shll_s_w.c create mode 100644 tests/tcg/mips/mips64-dsp/shllv_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/shllv_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/shllv_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/shllv_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/shllv_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/shllv_s_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/shllv_s_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/shllv_s_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/shllv_s_w.c create mode 100644 tests/tcg/mips/mips64-dsp/shra_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/shra_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/shra_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/shra_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/shra_r_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/shra_r_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/shra_r_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/shra_r_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/shra_r_w.c create mode 100644 tests/tcg/mips/mips64-dsp/shrav_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/shrav_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/shrav_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/shrav_r_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/shrav_r_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/shrav_r_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/shrav_r_w.c create mode 100644 tests/tcg/mips/mips64-dsp/shrl_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/shrl_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/shrl_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/shrlv_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/shrlv_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/shrlv_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/subq_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/subq_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/subq_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/subq_s_ph.c create mode 100644 tests/tcg/mips/mips64-dsp/subq_s_pw.c create mode 100644 tests/tcg/mips/mips64-dsp/subq_s_qh.c create mode 100644 tests/tcg/mips/mips64-dsp/subq_s_w.c create mode 100644 tests/tcg/mips/mips64-dsp/subu_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/subu_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/subu_s_ob.c create mode 100644 tests/tcg/mips/mips64-dsp/subu_s_qb.c create mode 100644 tests/tcg/mips/mips64-dsp/wrdsp.c create mode 100644 tests/tcg/mips/mips64-dspr2/.directory create mode 100644 tests/tcg/mips/mips64-dspr2/Makefile create mode 100644 tests/tcg/mips/mips64-dspr2/absq_s_qb.c create mode 100644 tests/tcg/mips/mips64-dspr2/addqh_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/addqh_r_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/addqh_r_w.c create mode 100644 tests/tcg/mips/mips64-dspr2/addqh_w.c create mode 100644 tests/tcg/mips/mips64-dspr2/addu_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/addu_qh.c create mode 100644 tests/tcg/mips/mips64-dspr2/addu_s_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/addu_s_qh.c create mode 100644 tests/tcg/mips/mips64-dspr2/adduh_ob.c create mode 100644 tests/tcg/mips/mips64-dspr2/adduh_qb.c create mode 100644 tests/tcg/mips/mips64-dspr2/adduh_r_ob.c create mode 100644 tests/tcg/mips/mips64-dspr2/adduh_r_qb.c create mode 100644 tests/tcg/mips/mips64-dspr2/append.c create mode 100644 tests/tcg/mips/mips64-dspr2/balign.c create mode 100644 tests/tcg/mips/mips64-dspr2/cmpgdu_eq_ob.c create mode 100644 tests/tcg/mips/mips64-dspr2/cmpgdu_eq_qb.c create mode 100644 tests/tcg/mips/mips64-dspr2/cmpgdu_le_ob.c create mode 100644 tests/tcg/mips/mips64-dspr2/cmpgdu_le_qb.c create mode 100644 tests/tcg/mips/mips64-dspr2/cmpgdu_lt_ob.c create mode 100644 tests/tcg/mips/mips64-dspr2/cmpgdu_lt_qb.c create mode 100644 tests/tcg/mips/mips64-dspr2/dbalign.c create mode 100644 tests/tcg/mips/mips64-dspr2/dpa_w_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/dpa_w_qh.c create mode 100644 tests/tcg/mips/mips64-dspr2/dpaqx_s_w_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/dpaqx_sa_w_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/dpax_w_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/dps_w_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/dps_w_qh.c create mode 100644 tests/tcg/mips/mips64-dspr2/dpsqx_s_w_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/dpsqx_sa_w_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/dpsx_w_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/head.S create mode 100644 tests/tcg/mips/mips64-dspr2/io.h create mode 100644 tests/tcg/mips/mips64-dspr2/mips_boot.lds create mode 100644 tests/tcg/mips/mips64-dspr2/mul_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/mul_s_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/muleq_s_w_phl.c create mode 100644 tests/tcg/mips/mips64-dspr2/mulq_rs_w.c create mode 100644 tests/tcg/mips/mips64-dspr2/mulq_s_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/mulq_s_w.c create mode 100644 tests/tcg/mips/mips64-dspr2/mulsa_w_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/mulsaq_s_w_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/precr_qb_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/precr_sra_ph_w.c create mode 100644 tests/tcg/mips/mips64-dspr2/precr_sra_r_ph_w.c create mode 100644 tests/tcg/mips/mips64-dspr2/prepend.c create mode 100644 tests/tcg/mips/mips64-dspr2/printf.c create mode 100644 tests/tcg/mips/mips64-dspr2/shra_qb.c create mode 100644 tests/tcg/mips/mips64-dspr2/shra_r_qb.c create mode 100644 tests/tcg/mips/mips64-dspr2/shrav_ob.c create mode 100644 tests/tcg/mips/mips64-dspr2/shrav_qb.c create mode 100644 tests/tcg/mips/mips64-dspr2/shrav_r_ob.c create mode 100644 tests/tcg/mips/mips64-dspr2/shrav_r_qb.c create mode 100644 tests/tcg/mips/mips64-dspr2/shrl_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/shrlv_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/subqh_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/subqh_r_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/subqh_r_w.c create mode 100644 tests/tcg/mips/mips64-dspr2/subqh_w.c create mode 100644 tests/tcg/mips/mips64-dspr2/subu_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/subu_qh.c create mode 100644 tests/tcg/mips/mips64-dspr2/subu_s_ph.c create mode 100644 tests/tcg/mips/mips64-dspr2/subu_s_qh.c create mode 100644 tests/tcg/mips/mips64-dspr2/subuh_ob.c create mode 100644 tests/tcg/mips/mips64-dspr2/subuh_qb.c create mode 100644 tests/tcg/mips/mips64-dspr2/subuh_r_ob.c create mode 100644 tests/tcg/mips/mips64-dspr2/subuh_r_qb.c
Signature · 1 line
1.7.9.5
PATCH v7 1/14 target-mips-ase-dsp: Add internal functions
Add internal functions using by MIPS ASE DSP instructions.
--- target-mips/Makefile.objs | 2 +- target-mips/dsp_helper.c | 1277 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1278 insertions(+), 1 deletion(-) create mode 100644 target-mips/dsp_helper.c
target-mips/Makefile.objs +1 -1
@@ -1,4 +1,4 @@ -obj-y += translate.o op_helper.o helper.o cpu.o +obj-y += translate.o dsp_helper.o op_helper.o helper.o cpu.o obj-$(CONFIG_SOFTMMU) += machine.o $(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
target-mips/dsp_helper.c new file +1277 -0
1,277 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v7 01/14] target-mips-ase-dsp: Add internal functions
Quoted 8 lines · Jia Liu
Add internal functions using by MIPS ASE DSP instructions.
Signed-off-by Jia Liu <[email protected]>--- target-mips/Makefile.objs | 2 +- target-mips/dsp_helper.c | 1277 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1278 insertions(+), 1 deletion(-) create mode 100644 target-mips/dsp_helper.c
As a general comment, I think the code is too verbose. For example the following code:
| uint16_t tempA, tempB, temp; | | tempA = a; | tempB = b; | temp = tempA + tempB;
can be replaced by:
| uint16_t temp; | | temp = (uint16_t)a + (uint16_t)b;
This way it's shorter and easier to read.
Quoted 688 lines
target-mips/Makefile.objs +1
-1@@ -1,4 +1,4 @@ -obj-y += translate.o op_helper.o helper.o cpu.o +obj-y += translate.o dsp_helper.o op_helper.o helper.o cpu.o obj-$(CONFIG_SOFTMMU) += machine.o $(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)target-mips/dsp_helper.c new file +672
-0@@ -0,0 +1,1277 @@ +/* +* MIPS ASE DSP Instruction emulation helpers for QEMU. +* +* Copyright (c) 2012 Jia Liu <[email protected]> +* Dongxue Zhang <[email protected]> +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "cpu.h" +#include "helper.h" + +/*** MIPS DSP internal functions begin ***/ +static inline int not_word_value (target_long value) +{ +target_ulong temp; + + temp = (target_long)(int32_t)(value &0xFFFFFFFF ); +if (value == temp) { +return 0 ; + }else { +return 1 ; + } +} + +static inline void set_DSPControl_overflow_flag (CPUMIPSState *env, +uint32_t flag,int position) +{ + env->active_tc.DSPControl |= (target_ulong )flag << position; +} + +static inline void set_DSPControl_carryflag (CPUMIPSState *env,uint32_t flag) +{ + env->active_tc.DSPControl |= (target_ulong )flag <<13 ; +} + +static inline uint32_t get_DSPControl_carryflag (CPUMIPSState *env) +{ +uint32_t flag; + + flag = (env->active_tc.DSPControl >>13 ) &0x01 ; + +return flag; +} + +static inline void set_DSPControl_24 (CPUMIPSState *env,uint32_t flag,int len) +{ +uint32_t filter; + + filter = ((0x01 << len) -1 ) <<24 ; + filter = ~filter; + + env->active_tc.DSPControl &= filter; + env->active_tc.DSPControl |= (target_ulong )flag <<24 ; +} + +static inline uint32_t get_DSPControl_24 (CPUMIPSState *env,int len) +{ +uint32_t cond; +uint32_t filter; + + filter = (0x01 << len) -1 ; + + cond = (env->active_tc.DSPControl >>24 ) & filter; + +return cond; +} + +static inline void set_DSPControl_pos (CPUMIPSState *env,uint32_t pos) +{ +target_ulong dspc; + + dspc = env->active_tc.DSPControl; +#ifndef TARGET_MIPS64 + dspc = dspc &0xFFFFFFC0 ; + dspc |= pos; +#else + dspc = dspc &0xFFFFFF80 ; + dspc |= pos; +#endif + env->active_tc.DSPControl = dspc; +} + +static inline uint32_t get_DSPControl_pos (CPUMIPSState *env) +{ +target_ulong dspc; +uint32_t pos; + + dspc = env->active_tc.DSPControl; + +#ifndef TARGET_MIPS64 + pos = dspc &0x3F ; +#else + pos = dspc &0x7F ; +#endif + +return pos; +} + +static inline void set_DSPControl_efi (CPUMIPSState *env,uint32_t flag) +{ + env->active_tc.DSPControl &=0xFFFFBFFF ; + env->active_tc.DSPControl |= (target_ulong )flag <<14 ; +} + +/* get abs value */ +static inline int8_t mipsdsp_sat_abs_u8 (CPUMIPSState *env,uint8_t a) +{ +int8_t temp; + temp = a; + +if (a ==0x80 ) { +set_DSPControl_overflow_flag (env,1 ,20 ); + temp =0x7f ; + }else { +if ((a &0x80 ) ==0x80 ) { + temp = -temp; + } + } + +return temp; +} + +static inline int16_t mipsdsp_sat_abs_u16 (CPUMIPSState *env,uint16_t a) +{ +int16_t temp; + temp = a; + +if (a ==0x8000 ) { +set_DSPControl_overflow_flag (env,1 ,20 ); + temp =0x7fff ; + }else { +if ((a &0x8000 ) ==0x8000 ) { + temp = -temp; + } + } + +return temp; +} + +static inline int32_t mipsdsp_sat_abs_u32 (CPUMIPSState *env,uint32_t a) +{ +int32_t temp; + temp = a; + +if (a ==0x80000000 ) { +set_DSPControl_overflow_flag (env,1 ,20 ); + temp =0x7FFFFFFF ; + }else { +if ((a &0x80000000 ) ==0x80000000 ) { + temp = -temp; + } + } + +return temp; +} + +/* get sum value */ +static inline int16_t mipsdsp_add_i16 (CPUMIPSState *env,int16_t a,int16_t b) +{ +int16_t tempS; +int32_t tempI, temp15, temp16; + + tempS = a + b; + tempI = a + b; + temp15 = (tempI &0x8000 ) >>15 ; + temp16 = (tempI &0x10000 ) >>16 ; + +if (temp15 != temp16) { +set_DSPControl_overflow_flag (env,1 ,20 ); + } + +return tempS; +} + +static inline int16_t mipsdsp_sat_add_i16 (CPUMIPSState *env, +int16_t a,int16_t b) +{ +int16_t tempS; +int32_t tempI, temp15, temp16; + + tempS = a + b; + tempI = (int32_t )a + (int32_t )b; + temp15 = (tempI &0x8000 ) >>15 ; + temp16 = (tempI &0x10000 ) >>16 ; + +if (temp15 != temp16) { +if (temp16 ==0 ) { + tempS =0x7FFF ; + }else { + tempS =0x8000 ; + } +set_DSPControl_overflow_flag (env,1 ,20 ); + } + +return tempS; +} + +static inline int32_t mipsdsp_sat_add_i32 (CPUMIPSState *env, +int32_t a,int32_t b) +{ +int32_t tempI; +int64_t tempL, temp31, temp32; + + tempI = a + b; + tempL = (int64_t )a + (int64_t )b; + temp31 = (tempL &0x80000000 ) >>31 ; + temp32 = (tempL &0x100000000ull ) >>32 ; + +if (temp31 != temp32) { +if (temp32 ==0 ) { + tempI =0x7FFFFFFF ; + }else { + tempI =0x80000000 ; + } +set_DSPControl_overflow_flag (env,1 ,20 ); + } + +return tempI; +} + +static inline uint8_t mipsdsp_add_u8 (CPUMIPSState *env,uint8_t a,uint8_t b) +{ +uint8_t result; +uint16_t tempA, tempB, temp; + + tempA = a; + tempB = b; + temp = tempA + tempB; + result = temp &0xFF ; + +if ((temp &0x0100 ) ==0x0100 ) { +set_DSPControl_overflow_flag (env,1 ,20 ); + } + +return result; +} + +static inline uint16_t mipsdsp_add_u16 (CPUMIPSState *env, +uint16_t a,uint16_t b) +{ +uint16_t result; +uint32_t tempA, tempB, temp; + + tempA = a; + tempB = b; + temp = tempA + tempB; + result = temp &0xFFFF ; + +if ((temp &0x00010000 ) ==0x00010000 ) { +set_DSPControl_overflow_flag (env,1 ,20 ); + } + +return result; +} + +static inline uint8_t mipsdsp_sat_add_u8 (CPUMIPSState *env, +uint8_t a,uint8_t b) +{ +uint8_t result; +uint16_t tempA, tempB, temp; + + tempA = a; + tempB = b; + temp = tempA + tempB; + result = temp &0xFF ; + +if ((0x0100 & temp) ==0x0100 ) { + result =0xFF ; +set_DSPControl_overflow_flag (env,1 ,20 ); + } + +return result; +} + +static inline uint16_t mipsdsp_sat_add_u16 (CPUMIPSState *env, +uint16_t a,uint16_t b) +{ +uint16_t result; +uint32_t tempA, tempB, temp; + + tempA = a; + tempB = b; + temp = tempA + tempB; + result = temp &0xFFFF ; + +if ((0x00010000 & temp) ==0x00010000 ) { + result =0xFFFF ; +set_DSPControl_overflow_flag (env,1 ,20 ); + } + +return result; +} + +static inline int32_t mipsdsp_sat32_acc_q31 (CPUMIPSState *env, +int32_t acc,int32_t a) +{ +int64_t tempA, temp; +int32_t temp32, temp31, result; +int64_t temp_sum; + +#ifndef TARGET_MIPS64 + temp = ((uint64_t )env->active_tc.HI[acc] <<32 ) | + (uint64_t )env->active_tc.LO[acc]; +#else + temp = (uint64_t )env->active_tc.LO[acc]; +#endif + tempA = (int64_t )a; + + temp_sum = tempA + temp; + + temp32 = (temp_sum >>32 ) &0x01 ; + temp31 = (temp_sum >>31 ) &0x01 ; + result = temp_sum &0xFFFFFFFF ; + +if (temp32 != temp31) { +if (temp32 ==0 ) { + result =0x80000000 ; + }else { + result =0x7FFFFFFF ; + } +set_DSPControl_overflow_flag (env,1 ,16 + acc); + } + +return result; +} + +/* a[0] is LO, a[1] is HI. */ +static inline void mipsdsp_sat64_acc_add_q63 (CPUMIPSState *env, +int64_t *ret, +int32_t ac, +int64_t *a) +{ +uint32_t temp64, temp63; +int64_t temp[3 ]; +int64_t acc[3 ]; +int64_t temp_sum; + + temp[0 ] = a[0 ]; + temp[1 ] = a[1 ]; +if (((temp[1 ] >>63 ) &0x01 ) ==0 ) { + temp[2 ] =0x00 ; + }else { + temp[2 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; +if (((acc[1 ] >>63 ) &0x01 ) ==0 ) { + acc[2 ] =0x00 ; + }else { + acc[2 ] =0xFFFFFFFFFFFFFFFFull ; + } + + temp_sum = temp[0 ] + acc[0 ]; +if (((uint64_t )temp_sum < (uint64_t )temp[0 ]) && + ((uint64_t )temp_sum < (uint64_t )acc[0 ])) { + temp[1 ] +=1 ; +if (temp[1 ] ==0 ) { + temp[2 ] +=1 ; + } + } + temp[0 ] = temp_sum; + + temp_sum = temp[1 ] + acc[1 ]; +if (((uint64_t )temp_sum < (uint64_t )temp[1 ]) && + ((uint64_t )temp_sum < (uint64_t )acc[1 ])) { + temp[2 ] +=1 ; + } + + temp[1 ] = temp_sum; + temp[2 ] += acc[2 ]; + temp64 = temp[1 ] &0x01 ; + temp63 = (temp[0 ] >>63 ) &0x01 ; + +if (temp64 != temp63) { +if (temp64 ==1 ) { + ret[0 ] =0x8000000000000000ull ; + ret[1 ] =0xFFFFFFFFFFFFFFFFull ; + }else { + ret[0 ] =0x0 ; + ret[1 ] =0x7FFFFFFFFFFFFFFFull ; + } +set_DSPControl_overflow_flag (env,1 ,16 + ac); + }else { + ret[0 ] = temp[0 ]; + ret[1 ] = temp[1 ]; + } +} + +/* a[0] is LO, a[1] is HI. */ +static inline void mipsdsp_sat64_acc_sub_q63 (CPUMIPSState *env, +int64_t *ret, +int32_t ac, +int64_t *a) +{ +uint32_t temp64, temp63; +int64_t temp[3 ]; +int64_t acc[3 ]; +int64_t temp_sum; + + temp[0 ] = a[0 ]; + temp[1 ] = a[1 ]; +if (((temp[1 ] >>63 ) &0x01 ) ==0 ) { + temp[2 ] =0x00 ; + }else { + temp[2 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; +if (((acc[1 ] >>63 ) &0x01 ) ==0 ) { + acc[2 ] =0x00 ; + }else { + acc[2 ] =0xFFFFFFFFFFFFFFFFull ; + } + + temp_sum = acc[0 ] - temp[0 ]; +if ((uint64_t )temp_sum > (uint64_t )acc[0 ]) { + acc[1 ] -=1 ; +if (acc[1 ] ==0xFFFFFFFFFFFFFFFFull ) { + acc[2 ] -=1 ; + } + } + acc[0 ] = temp_sum; + + temp_sum = acc[1 ] - temp[1 ]; +if ((uint64_t )temp_sum > (uint64_t )acc[1 ]) { + acc[2 ] -=1 ; + } + acc[1 ] = temp_sum; + acc[2 ] -= temp[2 ]; + + temp64 = acc[1 ] &0x01 ; + temp63 = (acc[0 ] >>63 ) &0x01 ; + +if (temp64 != temp63) { +if (temp64 ==1 ) { + ret[0 ] =0x8000000000000000ull ; + ret[1 ] =0xFFFFFFFFFFFFFFFFull ; + }else { + ret[0 ] =0x0 ; + ret[1 ] =0x7FFFFFFFFFFFFFFFull ; + } +set_DSPControl_overflow_flag (env,1 ,16 + ac); + }else { + ret[0 ] = acc[0 ]; + ret[1 ] = acc[1 ]; + } +} + +static inline int32_t mipsdsp_mul_i16_i16 (CPUMIPSState *env, +int16_t a,int16_t b) +{ +int32_t temp, tempA, tempB; + + tempA = a; + tempB = b; + temp = tempA * tempB; + +if ((temp >0x7FFF ) || (temp <0xFFFF8000 )) { +set_DSPControl_overflow_flag (env,1 ,21 ); + } + temp &=0x0000FFFF ; + +return temp; +} + +static inline int32_t mipsdsp_sat16_mul_i16_i16 (CPUMIPSState *env, +int16_t a,int16_t b) +{ +int32_t temp, tempA, tempB; + + tempA = a; + tempB = b; + temp = tempA * tempB; + +if (temp >0x7FFF ) { + temp =0x00007FFF ; +set_DSPControl_overflow_flag (env,1 ,21 ); + }else if (temp <0x00007FFF ) { + temp =0xFFFF8000 ; +set_DSPControl_overflow_flag (env,1 ,21 ); + } + temp &=0x0000FFFF ; + +return temp; +} + +static inline int32_t mipsdsp_mul_q15_q15_overflowflag21 (CPUMIPSState *env, +uint16_t a,uint16_t b) +{ +int16_t tempA, tempB; +int32_t temp; + + tempA = a; + tempB = b; + +if ((a ==0x8000 ) && (b ==0x8000 )) { + temp =0x7FFFFFFF ; +set_DSPControl_overflow_flag (env,1 ,21 ); + }else { + temp = ((int32_t )tempA * (int32_t )tempB) <<1 ; + } + +return temp; +} + +/* right shift */ +static inline int16_t mipsdsp_rshift1_add_q16 (int16_t a,int16_t b) +{ +int32_t temp, tempA, tempB; +int16_t result; + + tempA = a; + tempB = b; + temp = tempA + tempB; + result = (temp >>1 ) &0xFFFF ; + +return result; +} + +/* round right shift */ +static inline int16_t mipsdsp_rrshift1_add_q16 (int16_t a,int16_t b) +{ +int32_t temp, tempA, tempB; +int16_t result; + + tempA = a; + tempB = b; + temp = tempA + tempB; + temp +=1 ; + result = (temp >>1 ) &0xFFFF ; + +return result; +} + +static inline int32_t mipsdsp_rshift1_add_q32 (int32_t a,int32_t b) +{ +int64_t temp, tempA, tempB; +int32_t result; + + tempA = a; + tempB = b; + temp = tempA + tempB; + result = (temp >>1 ) &0xFFFFFFFF ; + +return result; +} + +static inline int32_t mipsdsp_rrshift1_add_q32 (int32_t a,int32_t b) +{ +int64_t temp, tempA, tempB; +int32_t result; + tempA = a; + tempB = b; + + temp = tempA + tempB; + temp +=1 ; + result = (temp >>1 ) &0xFFFFFFFF ; + +return result; +} + +static inline uint8_t mipsdsp_rshift1_add_u8 (uint8_t a,uint8_t b) +{ +uint16_t tempA, tempB, temp; +uint8_t result; + + tempA = a; + tempB = b; + temp = tempA + tempB; + result = (temp >>1 ) &0x00FF ; + +return result; +} + +static inline uint8_t mipsdsp_rrshift1_add_u8 (uint8_t a,uint8_t b) +{ +uint16_t tempA, tempB, temp; +uint8_t result; + + tempA = a; + tempB = b; + temp = tempA + tempB +1 ; + result = (temp >>1 ) &0x00FF ; + +return result; +} + +static inline int64_t mipsdsp_rashift_short_acc (CPUMIPSState *env, +int32_t ac, +int32_t shift) +{ +int32_t sign, temp31; +int64_t temp, acc; + + sign = (env->active_tc.HI[ac] >>31 ) &0x01 ; + acc = ((int64_t )env->active_tc.HI[ac] <<32 ) | + ((int64_t )env->active_tc.LO[ac] &0xFFFFFFFF ); +if (shift ==0 ) { + temp = acc; + }else { +if (sign ==0 ) { + temp = (((int64_t )0x01 << (32 - shift +1 )) -1 ) & (acc >> shift); + }else { + temp = ((((int64_t )0x01 << (shift +1 )) -1 ) << (32 - shift)) | + (acc >> shift); + } + } + + temp31 = (temp >>31 ) &0x01 ; +if (sign != temp31) { +set_DSPControl_overflow_flag (env,1 ,23 ); + } + +return temp; +} + +/* 128 bits long. p[0] is LO, p[1] is HI. */ +static inline void mipsdsp__rashift_short_acc (CPUMIPSState *env, +int64_t *p, +int32_t ac, +int32_t shift) +{ +int64_t acc; + + acc = ((int64_t )env->active_tc.HI[ac] <<32 ) | + ((int64_t )env->active_tc.LO[ac] &0xFFFFFFFF ); +if (shift ==0 ) { + p[0 ] = acc <<1 ; + p[1 ] = (acc >>63 ) &0x01 ; + }else { + p[0 ] = acc >> (shift -1 ); + p[1 ] =0 ; + } +} + +/* 128 bits long. p[0] is LO, p[1] is HI */ +static inline void mipsdsp_rashift_acc (CPUMIPSState *env, +uint64_t *p, +uint32_t ac, +uint32_t shift) +{ +uint64_t tempB, tempA; + + tempB = env->active_tc.HI[ac]; + tempA = env->active_tc.LO[ac]; + shift = shift &0x1F ; + +if (shift ==0 ) { + p[1 ] = tempB; + p[0 ] = tempA; + }else { + p[0 ] = (tempB << (64 - shift)) | (tempA >> shift); + p[1 ] = (int64_t )tempB >> shift; + } +} + +/* FIXME +* if ( shift5..0 = 0 ) then +* temp128..0 ← ( HI[ac]0 || LO[ac]63..0 || 0 )
target-mips/dsp_helper.c line 682
Quoted 10 lines
target-mips/dsp_helper.c new file +10
-0+* else +* sign ← HI[ac]63 +* temp128..0 ← +* signshift || (( HI[ac]63..0 || LO[ac]63..0 ) >> shift5..0) || +* LO[ac]shift-1 +* endif +* return temp128..0 +* endfunction _shiftAccRightArithmetic +*/ +/* 128 bits long. p[0] is LO, p[1] is HI , p[2] is sign of HI.*/
Is it planned to fix that?
target-mips/dsp_helper.c line 686
Quoted 4 lines
target-mips/dsp_helper.c new file +4
-0+static inline void mipsdsp__rashift_acc (CPUMIPSState *env, +uint64_t *p, +uint32_t ac, +uint32_t shift)
The name of this function differs from the above by a double underscore only. I think a better name should be found, describing the difference between these functions.
Quoted 6 lines
target-mips/dsp_helper.c new file +6
-0+{ +uint64_t tempB, tempA; + + tempB = env->active_tc.HI[ac]; + tempA = env->active_tc.LO[ac]; + shift = shift &0x3F ;
target-mips/dsp_helper.c line 702
Quoted 10 lines
target-mips/dsp_helper.c new file +10
-0+ +if (shift ==0 ) { + p[2 ] = tempB >>63 ; + p[1 ] = (tempB <<1 ) | (tempA >>63 ); + p[0 ] = tempA <<1 ; + }else { + p[0 ] = (tempB << (64 - shift)) | (tempA >> shift); + p[1 ] = (int64_t )tempB >> shift; +if (((tempB >>63 ) &0x01 ) ==1 ) { + p[2 ] =0xFfffFfffFfffFfffull ;
~0ull is probably easier to read than this mixed case constant.
Quoted 41 lines
target-mips/dsp_helper.c new file +41
-0+ }else { + p[2 ] =0x0 ; + } + } +} + +static inline int32_t mipsdsp_mul_q15_q15 (CPUMIPSState *env, +int32_t ac,uint16_t a,uint16_t b) +{ +uint16_t tempA, tempB; +int32_t temp; + + tempA = a; + tempB = b; + +if ((a ==0x8000 ) && (b ==0x8000 )) { + temp =0x7FFFFFFF ; +set_DSPControl_overflow_flag (env,1 ,16 + ac); + }else { + temp = ((uint32_t )tempA * (uint32_t )tempB) <<1 ; + } + +return temp; +} + +static inline int64_t mipsdsp_mul_q31_q31 (CPUMIPSState *env, +int32_t ac,uint32_t a,uint32_t b) +{ +uint32_t tempA, tempB; +uint64_t temp; + + tempA = a; + tempB = b; + +if ((a ==0x80000000 ) && (b ==0x80000000 )) { + temp =0x7FFFFFFFFFFFFFFFull ; +set_DSPControl_overflow_flag (env,1 ,16 + ac); + }else { + temp = ((uint64_t )tempA * (uint64_t )tempB) <<1 ; + } +
target-mips/dsp_helper.c line 753
Quoted 10 lines
target-mips/dsp_helper.c new file +10
-0+return temp; +} + +static inline uint16_t mipsdsp_mul_u8_u8 (uint8_t a,uint8_t b) +{ +uint16_t temp; + temp = (uint16_t )a * (uint16_t )b; + +return temp; +}
You can even write:
| return (uint16_t)a * b
and avoid the temp variable. But in that case I think this should be just written as this in the code instead of using an helper.
Quoted 17 lines
target-mips/dsp_helper.c new file +17
-0+static inline uint16_t mipsdsp_mul_u8_u16 (CPUMIPSState *env, +uint8_t a,uint16_t b) +{ +uint16_t tempS; +uint32_t tempI, tempA, tempB; + + tempA = a; + tempB = b; + tempI = tempA * tempB; +if (tempI >0x0000FFFF ) { + tempI =0x0000FFFF ; +set_DSPControl_overflow_flag (env,1 ,21 ); + } + tempS = tempI &0x0000FFFF ; + +return tempS; +}
target-mips/dsp_helper.c line 781
Quoted 10 lines
target-mips/dsp_helper.c new file +10
-0+ +static inline uint64_t mipsdsp_mul_u32_u32 (CPUMIPSState *env, +uint32_t a,uint32_t b) +{ +uint64_t temp; + + temp = (uint64_t )a * (uint64_t )b; + +return temp; +}
same remark than as for mipsdsp_mul_u8_u8.
Quoted 109 lines
target-mips/dsp_helper.c new file +109
-0+static inline int16_t mipsdsp_rndq15_mul_q15_q15 (CPUMIPSState *env, +uint16_t a,uint16_t b) +{ +uint16_t result; +uint32_t temp; + +if ((a ==0x8000 ) && (b ==0x8000 )) { + temp =0x7FFF0000 ; +set_DSPControl_overflow_flag (env,1 ,21 ); + }else { + temp = (a * b) <<1 ; + temp = temp +0x00008000 ; + } + result = (temp &0xFFFF0000 ) >>16 ; + +return result; +} + +static inline int32_t mipsdsp_sat16_mul_q15_q15 (CPUMIPSState *env, +uint16_t a,uint16_t b) +{ +int16_t tempA, tempB; +int32_t temp; + + tempA = a; + tempB = b; + +if ((a ==0x8000 ) && (b ==0x8000 )) { + temp =0x7FFF0000 ; +set_DSPControl_overflow_flag (env,1 ,21 ); + }else { + temp = ((uint32_t )tempA * (uint32_t )tempB); + temp = temp <<1 ; + } + temp = (temp >>16 ) &0x0000FFFF ; + +return temp; +} + +static inline uint16_t mipsdsp_trunc16_sat16_round (CPUMIPSState *env, +uint32_t a) +{ +uint16_t result; +uint32_t temp32, temp31; +int64_t temp; + + temp = (int32_t )a +0x00008000 ; + temp32 = (temp >>32 ) &0x01 ; + temp31 = (temp >>31 ) &0x01 ; + +if (temp32 != temp31) { + temp =0x7FFFFFFF ; +set_DSPControl_overflow_flag (env,1 ,22 ); + } + result = (temp >>16 ) &0xFFFF ; + +return result; +} + +static inline uint8_t mipsdsp_sat8_reduce_precision (CPUMIPSState *env, +uint16_t a) +{ +uint8_t result; +uint16_t mag; +uint32_t sign; + + sign = (a >>15 ) &0x01 ; + mag = a &0x7FFF ; + +if (sign ==0 ) { +if (mag >0x7F80 ) { + result =0xFF ; +set_DSPControl_overflow_flag (env,1 ,22 ); + }else { + result = (mag >>7 ) &0xFFFF ; + } + }else { + result =0x00 ; +set_DSPControl_overflow_flag (env,1 ,22 ); + } + +return result; +} + +static inline uint8_t mipsdsp_lshift8 (CPUMIPSState *env,uint8_t a,uint8_t s) +{ +uint8_t sign; +uint8_t temp, discard; + +if (s ==0 ) { + temp = a; + }else { + sign = (a >>7 ) &0x01 ; + temp = a << s; +if (sign !=0 ) { + discard = (((0x01 << (8 - s)) -1 ) << s) | + ((a >> (6 - (s -1 ))) & ((0x01 << s) -1 )); + }else { + discard = a >> (6 - (s -1 )); + } + +if (discard !=0x00 ) { +set_DSPControl_overflow_flag (env,1 ,22 ); + } + } + +return temp; +} +
target-mips/dsp_helper.c line 901
Quoted 10 lines
target-mips/dsp_helper.c new file +10
-0+static inline uint8_t mipsdsp_rshift8 (uint8_t a,uint8_t s) +{ +uint8_t temp; +if (s ==0 ) { + temp = a; + }else { + temp = a >> s; + } +return temp; +}
The if is useless here, this is already handled by the C standard. I guess you can therefore just get rid of the inline function.
Quoted 103 lines
target-mips/dsp_helper.c new file +103
-0+static inline uint16_t mipsdsp_lshift16 (CPUMIPSState *env, +uint16_t a,uint8_t s) +{ +uint8_t sign; +uint16_t temp, discard; + +if (s ==0 ) { + temp = a; + }else { + sign = (a >>15 ) &0x01 ; + temp = a << s; +if (sign !=0 ) { + discard = (((0x01 << (16 - s)) -1 ) << s) | + ((a >> (14 - (s -1 ))) & ((0x01 << s) -1 )); + }else { + discard = a >> (14 - (s -1 )); + } + +if ((discard !=0x0000 ) && (discard !=0xFFFF )) { +set_DSPControl_overflow_flag (env,1 ,22 ); + } + } + +return temp; +} + + +static inline uint32_t mipsdsp_lshift32 (CPUMIPSState *env, +uint32_t a,uint8_t s) +{ +uint32_t temp, discard; + +if (s ==0 ) { + temp = a; + }else { + temp = a << s; + discard = (int32_t )a >> (31 - (s -1 )); + +if ((discard !=0x00000000 ) && (discard !=0xFFFFFFFF )) { +set_DSPControl_overflow_flag (env,1 ,22 ); + } + } + +return temp; +} + +static inline uint16_t mipsdsp_sat16_lshift (CPUMIPSState *env, +uint16_t a,uint8_t s) +{ +uint8_t sign; +uint16_t temp, discard; + +if (s ==0 ) { + temp = a; + }else { + sign = (a >>15 ) &0x01 ; + temp = a << s; +if (sign !=0 ) { + discard = (((0x01 << (16 - s)) -1 ) << s) | + ((a >> (14 - (s -1 ))) & ((0x01 << s) -1 )); + }else { + discard = a >> (14 - (s -1 )); + } + +if ((discard !=0x0000 ) && (discard !=0xFFFF )) { + temp = (sign ==0 ) ?0x7FFF :0x8000 ; +set_DSPControl_overflow_flag (env,1 ,22 ); + } + } + +return temp; +} + +static inline uint32_t mipsdsp_sat32_lshift (CPUMIPSState *env, +uint32_t a,uint8_t s) +{ +uint8_t sign; +uint32_t temp, discard; + +if (s ==0 ) { + temp = a; + }else { + sign = (a >>31 ) &0x01 ; + temp = a << s; +if (sign !=0 ) { + discard = (((0x01 << (32 - s)) -1 ) << s) | + ((a >> (30 - (s -1 ))) & ((0x01 << s) -1 )); + }else { + discard = a >> (30 - (s -1 )); + } + +if ((discard !=0x00000000 ) && (discard !=0xFFFFFFFF )) { + temp = (sign ==0 ) ?0x7FFFFFFF :0x80000000 ; +set_DSPControl_overflow_flag (env,1 ,22 ); + } + } + +return temp; +} + +static inline uint16_t mipsdsp_rashift16 (uint16_t a,uint8_t s) +{ +int16_t i, temp;
target-mips/dsp_helper.c line 1015
Quoted 10 lines
target-mips/dsp_helper.c new file +10
-0+ + i = a; +if (s ==0 ) { + temp = a; + }else { + temp = i >> s; + } + +return temp; +}
Same remark as for mipsdsp_rshift8. Also please use a cast instead of an intermediate value.
Quoted 20 lines
target-mips/dsp_helper.c new file +20
-0+static inline uint16_t mipsdsp_rnd16_rashift (uint16_t a,uint8_t s) +{ +int16_t i, result; +uint32_t temp; + + i = a; +if (s ==0 ) { + temp = (uint32_t )a <<1 ; + }else { + temp = (int32_t )i >> (s -1 ); + } + temp = temp +1 ; + result = temp >>1 ; + +return result; +} + +static inline uint32_t mipsdsp_rashift32 (uint32_t a,uint8_t s) +{ +int32_t i, temp;
target-mips/dsp_helper.c line 1046
Quoted 10 lines
target-mips/dsp_helper.c new file +10
-0+ + i = a; +if (s ==0 ) { + temp = a; + }else { + temp = i >> s; + } + +return temp; +}
Same remark.
Quoted 234 lines
target-mips/dsp_helper.c new file +230
-0+static inline uint32_t mipsdsp_rnd32_rashift (uint32_t a,uint8_t s) +{ +int32_t i; +int64_t temp; +uint32_t result; + + i = a; +if (s ==0 ) { + temp = a <<1 ; + }else { + temp = (int64_t )i >> (s -1 ); + } + temp +=1 ; + result = (temp >>1 ) &0x00000000FFFFFFFFull ; + +return result; +} + +static inline uint16_t mipsdsp_sub_i16 (CPUMIPSState *env,int16_t a,int16_t b) +{ +uint8_t temp16, temp15; +uint16_t result; +int32_t temp; + + temp = (int32_t )a - (int32_t )b; + temp16 = (temp >>16 ) &0x01 ; + temp15 = (temp >>15 ) &0x01 ; +if (temp16 != temp15) { +set_DSPControl_overflow_flag (env,1 ,20 ); + } + result = temp &0x0000FFFF ; + +return result; +} + +static inline uint16_t mipsdsp_sat16_sub (CPUMIPSState *env, +int16_t a,int16_t b) +{ +uint8_t temp16, temp15; +uint16_t result; +int32_t temp; + + temp = (int32_t )a - (int32_t )b; + temp16 = (temp >>16 ) &0x01 ; + temp15 = (temp >>15 ) &0x01 ; +if (temp16 != temp15) { +if (temp16 ==0 ) { + temp =0x7FFF ; + }else { + temp =0x8000 ; + } +set_DSPControl_overflow_flag (env,1 ,20 ); + } + result = temp &0x0000FFFF ; + +return result; +} + +static inline uint32_t mipsdsp_sat32_sub (CPUMIPSState *env, +int32_t a,int32_t b) +{ +uint8_t temp32, temp31; +uint32_t result; +int64_t temp; + + temp = (int64_t )a - (int64_t )b; + temp32 = (temp >>32 ) &0x01 ; + temp31 = (temp >>31 ) &0x01 ; +if (temp32 != temp31) { +if (temp32 ==0 ) { + temp =0x7FFFFFFF ; + }else { + temp =0x80000000 ; + } +set_DSPControl_overflow_flag (env,1 ,20 ); + } + result = temp &0x00000000FFFFFFFFull ; + +return result; +} + +static inline uint16_t mipsdsp_rshift1_sub_q16 (int16_t a,int16_t b) +{ +int32_t temp; +uint16_t result; + + temp = (int32_t )a - (int32_t )b; + result = (temp >>1 ) &0x0000FFFF ; + +return result; +} + +static inline uint16_t mipsdsp_rrshift1_sub_q16 (int16_t a,int16_t b) +{ +int32_t temp; +uint16_t result; + + temp = (int32_t )a - (int32_t )b; + temp +=1 ; + result = (temp >>1 ) &0x0000FFFF ; + +return result; +} + +static inline uint32_t mipsdsp_rshift1_sub_q32 (int32_t a,int32_t b) +{ +int64_t temp; +uint32_t result; + + temp = (int64_t )a - (int64_t )b; + result = (temp >>1 ) &0x00000000FFFFFFFFull ; + +return result; +} + +static inline uint32_t mipsdsp_rrshift1_sub_q32 (int32_t a,int32_t b) +{ +int64_t temp; +uint32_t result; + + temp = (int64_t )a - (int64_t )b; + temp +=1 ; + result = (temp >>1 ) &0x00000000FFFFFFFFull ; + +return result; +} + +static inline uint16_t mipsdsp_sub_u16_u16 (CPUMIPSState *env, +uint16_t a,uint16_t b) +{ +uint8_t temp16; +uint16_t result; +uint32_t temp; + + temp = (uint32_t )a - (uint32_t )b; + temp16 = (temp >>16 ) &0x01 ; +if (temp16 ==1 ) { +set_DSPControl_overflow_flag (env,1 ,20 ); + } + result = temp &0x0000FFFF ; +return result; +} + +static inline uint16_t mipsdsp_satu16_sub_u16_u16 (CPUMIPSState *env, +uint16_t a,uint16_t b) +{ +uint8_t temp16; +uint16_t result; +uint32_t temp; + + temp = (uint32_t )a - (uint32_t )b; + temp16 = (temp >>16 ) &0x01 ; + +if (temp16 ==1 ) { + temp =0x0000 ; +set_DSPControl_overflow_flag (env,1 ,20 ); + } + result = temp &0x0000FFFF ; + +return result; +} + +static inline uint8_t mipsdsp_sub_u8 (CPUMIPSState *env,uint8_t a,uint8_t b) +{ +uint8_t result, temp8; +uint16_t temp; + + temp = (uint16_t )a - (uint16_t )b; + temp8 = (temp >>8 ) &0x01 ; +if (temp8 ==1 ) { +set_DSPControl_overflow_flag (env,1 ,20 ); + } + result = temp &0x00FF ; + +return result; +} + +static inline uint8_t mipsdsp_satu8_sub (CPUMIPSState *env,uint8_t a,uint8_t b) +{ +uint8_t result, temp8; +uint16_t temp; + + temp = (uint16_t )a - (uint16_t )b; + temp8 = (temp >>8 ) &0x01 ; +if (temp8 ==1 ) { + temp =0x00 ; +set_DSPControl_overflow_flag (env,1 ,20 ); + } + result = temp &0x00FF ; + +return result; +} + +static inline uint32_t mipsdsp_sub32 (CPUMIPSState *env,int32_t a,int32_t b) +{ +uint32_t result, temp32, temp31; +int64_t temp; + + temp = (int64_t )a - (int64_t )b; + temp32 = (temp >>32 ) &0x01 ; + temp31 = (temp >>31 ) &0x01 ; +if (temp32 != temp31) { +set_DSPControl_overflow_flag (env,1 ,20 ); + } + result = temp &0xFFFFFFFF ; + +return result; +} + +static inline int32_t mipsdsp_add_i32 (CPUMIPSState *env,int32_t a,int32_t b) +{ +int32_t result; +int32_t temp32, temp31; +int64_t aL, bL; +int64_t temp; + + aL = (int64_t )a; + bL = (int64_t )b; + temp = aL + bL; + + temp32 = (temp >>32 ) &0x01 ; + temp31 = (temp >>31 ) &0x01 ; +if (temp32 != temp31) { +set_DSPControl_overflow_flag (env,1 ,20 ); + } + result = temp &0xFFFFFFFF ; + +return result; +} +/*** MIPS DSP internal functions end ***/ Signature · 1 line
1.7.9.5
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v7 2/14 target-mips-ase-dsp: Add dsp resources access check
In reply to Jia LiuAdd MIPS ASE DSP resources access check.
--- linux-user/main.c | 6 ++++++ target-mips/cpu.h | 8 ++++++-- target-mips/helper.c | 3 +++ target-mips/op_helper.c | 19 +++++++++++++++++++ target-mips/translate.c | 23 +++++++++++++++++++++++ 5 files changed, 57 insertions(+), 2 deletions(-)
linux-user/main.c +6 -0
@@ -2294,6 +2294,12 @@ done_syscall:queue_signal (env, info.si_signo, &info); }break ; +case EXCP_DSPDIS : + info.si_signo =TARGET_SIGILL ; + info.si_errno =0 ; + info.si_code =TARGET_ILL_ILLOPC ; +queue_signal (env, info.si_signo, &info); +break ;default :// error: fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
target-mips/cpu.h +6 -2
@@ -415,7 +415,7 @@ struct CPUMIPSState {int error_code;uint32_t hflags;/* CPU State */ /* TMASK defines different execution modes */ -#define MIPS_HFLAG_TMASK 0x007FF +#define MIPS_HFLAG_TMASK 0xC07FF#define MIPS_HFLAG_MODE 0x00007/* execution modes */ /* The KSU flags must be the lowest bits in hflags. The flag order must be the same as defined for CP0 Status. This allows to use
@@ -453,6 +453,9 @@ struct CPUMIPSState {#define MIPS_HFLAG_BDS32 0x10000/* branch requires 32-bit delay slot */ #define MIPS_HFLAG_BX 0x20000/* branch exchanges execution mode */ #define MIPS_HFLAG_BMASK (MIPS_HFLAG_BMASK_BASE | MIPS_HFLAG_BMASK_EXT) +/* MIPS DSP resources access. */ +#define MIPS_HFLAG_DSP 0x40000/* Enable access to MIPS DSP resources. */ +#define MIPS_HFLAG_DSPR2 0x80000/* Enable access to MIPS DSPR2 resources. */ target_ulong btarget;/* Jump / branch target */ target_ulong bcond;/* Branch condition (if needed) */
@@ -610,8 +613,9 @@ enum {EXCP_MDMX ,EXCP_C2E ,EXCP_CACHE ,/* 32 */ +EXCP_DSPDIS , - EXCP_LAST = EXCP_CACHE, + EXCP_LAST = EXCP_DSPDIS, };/* Dummy exception for conditional stores. */ #define EXCP_SC 0x100
target-mips/helper.c +3 -0
@@ -592,6 +592,9 @@ void do_interrupt (CPUMIPSState *env)case EXCP_THREAD : cause =25 ; goto set_EPC; +case EXCP_DSPDIS : + cause =26 ; + goto set_EPC;case EXCP_CACHE : cause =30 ;if (env->CP0_Status & (1 << CP0St_BEV)) {
target-mips/op_helper.c +19 -0
@@ -62,6 +62,25 @@ static inline void compute_hflags(CPUMIPSState *env)if (env->CP0_Status & (1 << CP0St_FR)) { env->hflags |=MIPS_HFLAG_F64 ; } +if (env->insn_flags &ASE_DSP ) { +/* Enables access MIPS DSP resources +on processors implementing one of these ASEs. If the MIPS DSP ASE is +not implemented, this bit must be ignored on write and read as +zero. */ +if (env->CP0_Status & (1 << CP0St_MX)) { + env->hflags |=MIPS_HFLAG_DSP ; + } + + }else if (env->insn_flags &ASE_DSPR2 ) { +/* Enables access MIPS DSP resources +on processors implementing one of these ASEs. If the MIPS DSP ASE is +not implemented, this bit must be ignored on write and read as +zero. */ +if (env->CP0_Status & (1 << CP0St_MX)) { + env->hflags |=MIPS_HFLAG_DSP |MIPS_HFLAG_DSPR2 ; + } + + }if (env->insn_flags &ISA_MIPS32R2 ) {if (env->active_fpu.fcr0 & (1 <<FCR0_F64 )) { env->hflags |=MIPS_HFLAG_COP1X ;
target-mips/translate.c +23 -0
@@ -824,6 +824,24 @@ static inline void check_cp1_registers(DisasContext *ctx, int regs)generate_exception (ctx,EXCP_RI ); } +/* Verify that the processor is running with DSP instructions enabled. +This is enabled by CP0 Status register MX(24) bit. +*/ + +static inline void check_dsp (DisasContext *ctx) +{ +if (unlikely (!(ctx->hflags &MIPS_HFLAG_DSP ))) { +generate_exception (ctx,EXCP_DSPDIS ); + } +} + +static inline void check_dspr2 (DisasContext *ctx) +{ +if (unlikely (!(ctx->hflags &MIPS_HFLAG_DSPR2 ))) { +generate_exception (ctx,EXCP_DSPDIS ); + } +} +/* This code generates a "reserved instruction" exception if the CPU does not support the instruction set corresponding to flags. */ static inline void check_insn (CPUMIPSState *env,DisasContext *ctx,int flags)
@@ -12861,6 +12879,11 @@ void cpu_state_reset(CPUMIPSState *env) env->hflags |= MIPS_HFLAG_64; }#endif +if (env->cpu_model->insn_flags &ASE_DSPR2 ) { + env->hflags |=MIPS_HFLAG_DSP |MIPS_HFLAG_DSPR2 ; + }else if (env->cpu_model->insn_flags &ASE_DSP ) { + env->hflags |=MIPS_HFLAG_DSP ; + } env->exception_index =EXCP_NONE ; }
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v7 02/14] target-mips-ase-dsp: Add dsp resources access check
Quoted 93 lines · Jia Liu
Add MIPS ASE DSP resources access check.
Signed-off-by Jia Liu <[email protected]>--- linux-user/main.c | 6 ++++++ target-mips/cpu.h | 8 ++++++-- target-mips/helper.c | 3 +++ target-mips/op_helper.c | 19 +++++++++++++++++++ target-mips/translate.c | 23 +++++++++++++++++++++++ 5 files changed, 57 insertions(+), 2 deletions(-)linux-user/main.c +6
-0@@ -2294,6 +2294,12 @@ done_syscall:queue_signal (env, info.si_signo, &info); }break ; +case EXCP_DSPDIS : + info.si_signo =TARGET_SIGILL ; + info.si_errno =0 ; + info.si_code =TARGET_ILL_ILLOPC ; +queue_signal (env, info.si_signo, &info); +break ;default :// error: fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",target-mips/cpu.h +6
-2@@ -415,7 +415,7 @@ struct CPUMIPSState {int error_code;uint32_t hflags;/* CPU State */ /* TMASK defines different execution modes */ -#define MIPS_HFLAG_TMASK 0x007FF +#define MIPS_HFLAG_TMASK 0xC07FF#define MIPS_HFLAG_MODE 0x00007/* execution modes */ /* The KSU flags must be the lowest bits in hflags. The flag order must be the same as defined for CP0 Status. This allows to use @@ -453,6 +453,9 @@ struct CPUMIPSState {#define MIPS_HFLAG_BDS32 0x10000/* branch requires 32-bit delay slot */ #define MIPS_HFLAG_BX 0x20000/* branch exchanges execution mode */ #define MIPS_HFLAG_BMASK (MIPS_HFLAG_BMASK_BASE | MIPS_HFLAG_BMASK_EXT) +/* MIPS DSP resources access. */ +#define MIPS_HFLAG_DSP 0x40000/* Enable access to MIPS DSP resources. */ +#define MIPS_HFLAG_DSPR2 0x80000/* Enable access to MIPS DSPR2 resources. */ target_ulong btarget;/* Jump / branch target */ target_ulong bcond;/* Branch condition (if needed) */ @@ -610,8 +613,9 @@ enum {EXCP_MDMX ,EXCP_C2E ,EXCP_CACHE ,/* 32 */ +EXCP_DSPDIS , - EXCP_LAST = EXCP_CACHE, + EXCP_LAST = EXCP_DSPDIS, };/* Dummy exception for conditional stores. */ #define EXCP_SC 0x100target-mips/helper.c +3
-0@@ -592,6 +592,9 @@ void do_interrupt (CPUMIPSState *env)case EXCP_THREAD : cause =25 ; goto set_EPC; +case EXCP_DSPDIS : + cause =26 ; + goto set_EPC;case EXCP_CACHE : cause =30 ;if (env->CP0_Status & (1 << CP0St_BEV)) {target-mips/op_helper.c +9
-0@@ -62,6 +62,25 @@ static inline void compute_hflags(CPUMIPSState *env)if (env->CP0_Status & (1 << CP0St_FR)) { env->hflags |=MIPS_HFLAG_F64 ; } +if (env->insn_flags &ASE_DSP ) { +/* Enables access MIPS DSP resources +on processors implementing one of these ASEs. If the MIPS DSP ASE is +not implemented, this bit must be ignored on write and read as +zero. */ +if (env->CP0_Status & (1 << CP0St_MX)) { + env->hflags |=MIPS_HFLAG_DSP ; + } +
target-mips/op_helper.c static inline void compute_hflags(CPUMIPSState *env) · line 83
Quoted 10 lines
target-mips/op_helper.c +10
-0+ }else if (env->insn_flags &ASE_DSPR2 ) { +/* Enables access MIPS DSP resources +on processors implementing one of these ASEs. If the MIPS DSP ASE is +not implemented, this bit must be ignored on write and read as +zero. */ +if (env->CP0_Status & (1 << CP0St_MX)) { + env->hflags |=MIPS_HFLAG_DSP |MIPS_HFLAG_DSPR2 ; + } + + }
This check is wrong on CPUs having both DSP and DSPR2 support, as the second test will never be reached.
Also there is no need to check if the instruction are supported (at least for ASE_DSP), as for each CPU CP0_Status_rw_bitmask ensures that only supported bits can be written.
Quoted 33 lines
target-mips/op_helper.c +0
-0if (env->insn_flags &ISA_MIPS32R2 ) {if (env->active_fpu.fcr0 & (1 <<FCR0_F64 )) { env->hflags |=MIPS_HFLAG_COP1X ;target-mips/translate.c +18
-0@@ -824,6 +824,24 @@ static inline void check_cp1_registers(DisasContext *ctx, int regs)generate_exception (ctx,EXCP_RI ); } +/* Verify that the processor is running with DSP instructions enabled. +This is enabled by CP0 Status register MX(24) bit. +*/ + +static inline void check_dsp (DisasContext *ctx) +{ +if (unlikely (!(ctx->hflags &MIPS_HFLAG_DSP ))) { +generate_exception (ctx,EXCP_DSPDIS ); + } +} + +static inline void check_dspr2 (DisasContext *ctx) +{ +if (unlikely (!(ctx->hflags &MIPS_HFLAG_DSPR2 ))) { +generate_exception (ctx,EXCP_DSPDIS ); + } +} +/* This code generates a "reserved instruction" exception if the CPU does not support the instruction set corresponding to flags. */ static inline void check_insn (CPUMIPSState *env,DisasContext *ctx,int flags)
target-mips/translate.c void cpu_state_reset(CPUMIPSState *env) · line 12886
Quoted 8 lines
target-mips/translate.c +5
-0@@ -12861,6 +12879,11 @@ void cpu_state_reset(CPUMIPSState *env) env->hflags |= MIPS_HFLAG_64; }#endif +if (env->cpu_model->insn_flags &ASE_DSPR2 ) { + env->hflags |=MIPS_HFLAG_DSP |MIPS_HFLAG_DSPR2 ; + }else if (env->cpu_model->insn_flags &ASE_DSP ) { + env->hflags |=MIPS_HFLAG_DSP ; + }
You can put two distinct if there without else, so that the fact that ASE_DSPR2 implies ASE_DSP is not hardcoded (though it is unlikely to change).
Quoted 7 lines
target-mips/translate.c +0
-0env->exception_index =EXCP_NONE ; }Signature · 1 line
1.7.9.5
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v7 3/14 target-mips-ase-dsp: Use correct acc value to index cpu_HI/cpu_LO rather than using a fix number
In reply to Jia LiuUse correct acc value to index cpu_HI/cpu_LO rather than using a fix number.
--- target-mips/translate.c | 134 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 107 insertions(+), 27 deletions(-)
target-mips/translate.c +107 -27
@@ -5,6 +5,7 @@* Copyright (c) 2006 Marius Groeger (FPU operations) * Copyright (c) 2006 Thiemo Seufer (MIPS32R2 support) * Copyright (c) 2009 CodeSourcery (MIPS16 and microMIPS support) +* Copyright (c) 2012 Jia Liu & Dongxue Zhang (MIPS ASE DSP support) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public
@@ -1990,33 +1991,87 @@ static void gen_shift (CPUMIPSState *env, DisasContext *ctx, uint32_t opc,static void gen_HILO (DisasContext *ctx,uint32_t opc,int reg) {const char *opn ="hilo" ; +unsigned int acc;if (reg ==0 && (opc ==OPC_MFHI || opc ==OPC_MFLO )) {/* Treat as NOP. */ MIPS_DEBUG ("NOP" );return ; } + +if (opc ==OPC_MFHI || opc ==OPC_MFLO ) { + acc = ((ctx->opcode) >>21 ) &0x03 ; + }else { + acc = ((ctx->opcode) >>11 ) &0x03 ; + } + +if (acc !=0 ) { +check_dsp (ctx); + } +switch (opc) {case OPC_MFHI : -tcg_gen_mov_tl (cpu_gpr[reg], cpu_HI[0 ]); +#if defined(TARGET_MIPS64 ) +if (acc ==0 ) { +tcg_gen_mov_tl (cpu_gpr[reg], cpu_HI[acc]); + }else { +tcg_gen_ext32s_tl (cpu_gpr[reg], cpu_HI[acc]); + } +#else +tcg_gen_mov_tl (cpu_gpr[reg], cpu_HI[acc]); +#endif opn ="mfhi" ;break ;case OPC_MFLO : -tcg_gen_mov_tl (cpu_gpr[reg], cpu_LO[0 ]); +#if defined(TARGET_MIPS64 ) +if (acc ==0 ) { +tcg_gen_mov_tl (cpu_gpr[reg], cpu_LO[acc]); + }else { +tcg_gen_ext32s_tl (cpu_gpr[reg], cpu_LO[acc]); + } +#else +tcg_gen_mov_tl (cpu_gpr[reg], cpu_LO[acc]); +#endif opn ="mflo" ;break ;case OPC_MTHI : -if (reg !=0 ) -tcg_gen_mov_tl (cpu_HI[0 ], cpu_gpr[reg]); -else -tcg_gen_movi_tl (cpu_HI[0 ],0 ); +#if defined(TARGET_MIPS64 ) +if (reg !=0 ) { +if (acc ==0 ) { +tcg_gen_mov_tl (cpu_HI[acc], cpu_gpr[reg]); + }else { +tcg_gen_ext32s_tl (cpu_HI[acc], cpu_gpr[reg]); + } + }else { +tcg_gen_movi_tl (cpu_HI[acc],0 ); + } +#else +if (reg !=0 ) { +tcg_gen_mov_tl (cpu_HI[acc], cpu_gpr[reg]); + }else { +tcg_gen_movi_tl (cpu_HI[acc],0 ); + } +#endif opn ="mthi" ;break ;case OPC_MTLO : -if (reg !=0 ) -tcg_gen_mov_tl (cpu_LO[0 ], cpu_gpr[reg]); -else -tcg_gen_movi_tl (cpu_LO[0 ],0 ); +#if defined(TARGET_MIPS64 ) +if (reg !=0 ) { +if (acc ==0 ) { +tcg_gen_mov_tl (cpu_LO[acc], cpu_gpr[reg]); + }else { +tcg_gen_ext32s_tl (cpu_LO[acc], cpu_gpr[reg]); + } + }else { +tcg_gen_movi_tl (cpu_LO[acc],0 ); + } +#else +if (reg !=0 ) { +tcg_gen_mov_tl (cpu_LO[acc], cpu_gpr[reg]); + }else { +tcg_gen_movi_tl (cpu_LO[acc],0 ); + } +#endif opn ="mtlo" ;break ; }
@@ -2029,6 +2084,7 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, {const char *opn ="mul/div" ;TCGv t0, t1; +unsigned int acc;switch (opc) {case OPC_DIV :
@@ -2091,6 +2147,10 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, {TCGv_i64 t2 =tcg_temp_new_i64 ();TCGv_i64 t3 =tcg_temp_new_i64 (); + acc = ((ctx->opcode) >>11 ) &0x03 ; +if (acc !=0 ) { +check_dsp (ctx); + }tcg_gen_ext_tl_i64 (t2, t0);tcg_gen_ext_tl_i64 (t3, t1);
@@ -2100,8 +2160,8 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc,tcg_gen_shri_i64 (t2, t2,32 );tcg_gen_trunc_i64_tl (t1, t2);tcg_temp_free_i64 (t2); -tcg_gen_ext32s_tl (cpu_LO[0 ], t0); -tcg_gen_ext32s_tl (cpu_HI[0 ], t1); +tcg_gen_ext32s_tl (cpu_LO[acc], t0); +tcg_gen_ext32s_tl (cpu_HI[acc], t1); } opn ="mult" ;break ;
@@ -2109,6 +2169,10 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, {TCGv_i64 t2 =tcg_temp_new_i64 ();TCGv_i64 t3 =tcg_temp_new_i64 (); + acc = ((ctx->opcode) >>11 ) &0x03 ; +if (acc !=0 ) { +check_dsp (ctx); + }tcg_gen_ext32u_tl (t0, t0);tcg_gen_ext32u_tl (t1, t1);
@@ -2120,8 +2184,8 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc,tcg_gen_shri_i64 (t2, t2,32 );tcg_gen_trunc_i64_tl (t1, t2);tcg_temp_free_i64 (t2); -tcg_gen_ext32s_tl (cpu_LO[0 ], t0); -tcg_gen_ext32s_tl (cpu_HI[0 ], t1); +tcg_gen_ext32s_tl (cpu_LO[acc], t0); +tcg_gen_ext32s_tl (cpu_HI[acc], t1); } opn ="multu" ;break ;
@@ -2168,41 +2232,49 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, {TCGv_i64 t2 =tcg_temp_new_i64 ();TCGv_i64 t3 =tcg_temp_new_i64 (); + acc = ((ctx->opcode) >>11 ) &0x03 ; +if (acc !=0 ) { +check_dsp (ctx); + }tcg_gen_ext_tl_i64 (t2, t0);tcg_gen_ext_tl_i64 (t3, t1);tcg_gen_mul_i64 (t2, t2, t3); -tcg_gen_concat_tl_i64 (t3, cpu_LO[0 ], cpu_HI[0 ]); +tcg_gen_concat_tl_i64 (t3, cpu_LO[acc], cpu_HI[acc]);tcg_gen_add_i64 (t2, t2, t3);tcg_temp_free_i64 (t3);tcg_gen_trunc_i64_tl (t0, t2);tcg_gen_shri_i64 (t2, t2,32 );tcg_gen_trunc_i64_tl (t1, t2);tcg_temp_free_i64 (t2); -tcg_gen_ext32s_tl (cpu_LO[0 ], t0); -tcg_gen_ext32s_tl (cpu_HI[0 ], t1); +tcg_gen_ext32s_tl (cpu_LO[acc], t0); +tcg_gen_ext32s_tl (cpu_HI[acc], t1); } opn ="madd" ;break ;case OPC_MADDU : - { + {TCGv_i64 t2 =tcg_temp_new_i64 ();TCGv_i64 t3 =tcg_temp_new_i64 (); + acc = ((ctx->opcode) >>11 ) &0x03 ; +if (acc !=0 ) { +check_dsp (ctx); + }tcg_gen_ext32u_tl (t0, t0);tcg_gen_ext32u_tl (t1, t1);tcg_gen_extu_tl_i64 (t2, t0);tcg_gen_extu_tl_i64 (t3, t1);tcg_gen_mul_i64 (t2, t2, t3); -tcg_gen_concat_tl_i64 (t3, cpu_LO[0 ], cpu_HI[0 ]); +tcg_gen_concat_tl_i64 (t3, cpu_LO[acc], cpu_HI[acc]);tcg_gen_add_i64 (t2, t2, t3);tcg_temp_free_i64 (t3);tcg_gen_trunc_i64_tl (t0, t2);tcg_gen_shri_i64 (t2, t2,32 );tcg_gen_trunc_i64_tl (t1, t2);tcg_temp_free_i64 (t2); -tcg_gen_ext32s_tl (cpu_LO[0 ], t0); -tcg_gen_ext32s_tl (cpu_HI[0 ], t1); +tcg_gen_ext32s_tl (cpu_LO[acc], t0); +tcg_gen_ext32s_tl (cpu_HI[acc], t1); } opn ="maddu" ;break ;
@@ -2210,19 +2282,23 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, {TCGv_i64 t2 =tcg_temp_new_i64 ();TCGv_i64 t3 =tcg_temp_new_i64 (); + acc = ((ctx->opcode) >>11 ) &0x03 ; +if (acc !=0 ) { +check_dsp (ctx); + }tcg_gen_ext_tl_i64 (t2, t0);tcg_gen_ext_tl_i64 (t3, t1);tcg_gen_mul_i64 (t2, t2, t3); -tcg_gen_concat_tl_i64 (t3, cpu_LO[0 ], cpu_HI[0 ]); +tcg_gen_concat_tl_i64 (t3, cpu_LO[acc], cpu_HI[acc]);tcg_gen_sub_i64 (t2, t3, t2);tcg_temp_free_i64 (t3);tcg_gen_trunc_i64_tl (t0, t2);tcg_gen_shri_i64 (t2, t2,32 );tcg_gen_trunc_i64_tl (t1, t2);tcg_temp_free_i64 (t2); -tcg_gen_ext32s_tl (cpu_LO[0 ], t0); -tcg_gen_ext32s_tl (cpu_HI[0 ], t1); +tcg_gen_ext32s_tl (cpu_LO[acc], t0); +tcg_gen_ext32s_tl (cpu_HI[acc], t1); } opn ="msub" ;break ;
@@ -2230,21 +2306,25 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, {TCGv_i64 t2 =tcg_temp_new_i64 ();TCGv_i64 t3 =tcg_temp_new_i64 (); + acc = ((ctx->opcode) >>11 ) &0x03 ; +if (acc !=0 ) { +check_dsp (ctx); + }tcg_gen_ext32u_tl (t0, t0);tcg_gen_ext32u_tl (t1, t1);tcg_gen_extu_tl_i64 (t2, t0);tcg_gen_extu_tl_i64 (t3, t1);tcg_gen_mul_i64 (t2, t2, t3); -tcg_gen_concat_tl_i64 (t3, cpu_LO[0 ], cpu_HI[0 ]); +tcg_gen_concat_tl_i64 (t3, cpu_LO[acc], cpu_HI[acc]);tcg_gen_sub_i64 (t2, t3, t2);tcg_temp_free_i64 (t3);tcg_gen_trunc_i64_tl (t0, t2);tcg_gen_shri_i64 (t2, t2,32 );tcg_gen_trunc_i64_tl (t1, t2);tcg_temp_free_i64 (t2); -tcg_gen_ext32s_tl (cpu_LO[0 ], t0); -tcg_gen_ext32s_tl (cpu_HI[0 ], t1); +tcg_gen_ext32s_tl (cpu_LO[acc], t0); +tcg_gen_ext32s_tl (cpu_HI[acc], t1); } opn ="msubu" ;break ;
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v7 03/14] target-mips-ase-dsp: Use correct acc value to index cpu_HI/cpu_LO rather than using a fix number
Quoted 43 lines · Jia Liu
Use correct acc value to index cpu_HI/cpu_LO rather than using a fix number.
Signed-off-by Jia Liu <[email protected]>--- target-mips/translate.c | 134 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 107 insertions(+), 27 deletions(-)target-mips/translate.c +13
-0@@ -5,6 +5,7 @@* Copyright (c) 2006 Marius Groeger (FPU operations) * Copyright (c) 2006 Thiemo Seufer (MIPS32R2 support) * Copyright (c) 2009 CodeSourcery (MIPS16 and microMIPS support) +* Copyright (c) 2012 Jia Liu & Dongxue Zhang (MIPS ASE DSP support) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -1990,33 +1991,87 @@ static void gen_shift (CPUMIPSState *env, DisasContext *ctx, uint32_t opc,static void gen_HILO (DisasContext *ctx,uint32_t opc,int reg) {const char *opn ="hilo" ; +unsigned int acc;if (reg ==0 && (opc ==OPC_MFHI || opc ==OPC_MFLO )) {/* Treat as NOP. */ MIPS_DEBUG ("NOP" );return ; } + +if (opc ==OPC_MFHI || opc ==OPC_MFLO ) { + acc = ((ctx->opcode) >>21 ) &0x03 ; + }else { + acc = ((ctx->opcode) >>11 ) &0x03 ; + } + +if (acc !=0 ) { +check_dsp (ctx); + } +switch (opc) {case OPC_MFHI :
target-mips/translate.c static void gen_shift (CPUMIPSState *env, DisasContext *ctx, uint32_t opc, · line 2022
Quoted 10 lines
target-mips/translate.c +9
-1-tcg_gen_mov_tl (cpu_gpr[reg], cpu_HI[0 ]); +#if defined(TARGET_MIPS64 ) +if (acc ==0 ) { +tcg_gen_mov_tl (cpu_gpr[reg], cpu_HI[acc]); + }else { +tcg_gen_ext32s_tl (cpu_gpr[reg], cpu_HI[acc]); + } +#else +tcg_gen_mov_tl (cpu_gpr[reg], cpu_HI[acc]); +#endif
This kind of code can be written:
#if defined(TARGET_MIPS64)
if (acc != 0) {
tcg_gen_ext32s_tl(cpu_gpr[reg], cpu_HI[acc]);
} else
#endif
{
tcg_gen_mov_tl(cpu_gpr[reg], cpu_HI[acc]);
}Quoted 219 lines
target-mips/translate.c +83
-24opn ="mfhi" ;break ;case OPC_MFLO : -tcg_gen_mov_tl (cpu_gpr[reg], cpu_LO[0 ]); +#if defined(TARGET_MIPS64 ) +if (acc ==0 ) { +tcg_gen_mov_tl (cpu_gpr[reg], cpu_LO[acc]); + }else { +tcg_gen_ext32s_tl (cpu_gpr[reg], cpu_LO[acc]); + } +#else +tcg_gen_mov_tl (cpu_gpr[reg], cpu_LO[acc]); +#endif opn ="mflo" ;break ;case OPC_MTHI : -if (reg !=0 ) -tcg_gen_mov_tl (cpu_HI[0 ], cpu_gpr[reg]); -else -tcg_gen_movi_tl (cpu_HI[0 ],0 ); +#if defined(TARGET_MIPS64 ) +if (reg !=0 ) { +if (acc ==0 ) { +tcg_gen_mov_tl (cpu_HI[acc], cpu_gpr[reg]); + }else { +tcg_gen_ext32s_tl (cpu_HI[acc], cpu_gpr[reg]); + } + }else { +tcg_gen_movi_tl (cpu_HI[acc],0 ); + } +#else +if (reg !=0 ) { +tcg_gen_mov_tl (cpu_HI[acc], cpu_gpr[reg]); + }else { +tcg_gen_movi_tl (cpu_HI[acc],0 ); + } +#endif opn ="mthi" ;break ;case OPC_MTLO : -if (reg !=0 ) -tcg_gen_mov_tl (cpu_LO[0 ], cpu_gpr[reg]); -else -tcg_gen_movi_tl (cpu_LO[0 ],0 ); +#if defined(TARGET_MIPS64 ) +if (reg !=0 ) { +if (acc ==0 ) { +tcg_gen_mov_tl (cpu_LO[acc], cpu_gpr[reg]); + }else { +tcg_gen_ext32s_tl (cpu_LO[acc], cpu_gpr[reg]); + } + }else { +tcg_gen_movi_tl (cpu_LO[acc],0 ); + } +#else +if (reg !=0 ) { +tcg_gen_mov_tl (cpu_LO[acc], cpu_gpr[reg]); + }else { +tcg_gen_movi_tl (cpu_LO[acc],0 ); + } +#endif opn ="mtlo" ;break ; }@@ -2029,6 +2084,7 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, {const char *opn ="mul/div" ;TCGv t0, t1; +unsigned int acc;switch (opc) {case OPC_DIV :@@ -2091,6 +2147,10 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, {TCGv_i64 t2 =tcg_temp_new_i64 ();TCGv_i64 t3 =tcg_temp_new_i64 (); + acc = ((ctx->opcode) >>11 ) &0x03 ; +if (acc !=0 ) { +check_dsp (ctx); + }tcg_gen_ext_tl_i64 (t2, t0);tcg_gen_ext_tl_i64 (t3, t1);@@ -2100,8 +2160,8 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc,tcg_gen_shri_i64 (t2, t2,32 );tcg_gen_trunc_i64_tl (t1, t2);tcg_temp_free_i64 (t2); -tcg_gen_ext32s_tl (cpu_LO[0 ], t0); -tcg_gen_ext32s_tl (cpu_HI[0 ], t1); +tcg_gen_ext32s_tl (cpu_LO[acc], t0); +tcg_gen_ext32s_tl (cpu_HI[acc], t1); } opn ="mult" ;break ;@@ -2109,6 +2169,10 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, {TCGv_i64 t2 =tcg_temp_new_i64 ();TCGv_i64 t3 =tcg_temp_new_i64 (); + acc = ((ctx->opcode) >>11 ) &0x03 ; +if (acc !=0 ) { +check_dsp (ctx); + }tcg_gen_ext32u_tl (t0, t0);tcg_gen_ext32u_tl (t1, t1);@@ -2120,8 +2184,8 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc,tcg_gen_shri_i64 (t2, t2,32 );tcg_gen_trunc_i64_tl (t1, t2);tcg_temp_free_i64 (t2); -tcg_gen_ext32s_tl (cpu_LO[0 ], t0); -tcg_gen_ext32s_tl (cpu_HI[0 ], t1); +tcg_gen_ext32s_tl (cpu_LO[acc], t0); +tcg_gen_ext32s_tl (cpu_HI[acc], t1); } opn ="multu" ;break ;@@ -2168,41 +2232,49 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, {TCGv_i64 t2 =tcg_temp_new_i64 ();TCGv_i64 t3 =tcg_temp_new_i64 (); + acc = ((ctx->opcode) >>11 ) &0x03 ; +if (acc !=0 ) { +check_dsp (ctx); + }tcg_gen_ext_tl_i64 (t2, t0);tcg_gen_ext_tl_i64 (t3, t1);tcg_gen_mul_i64 (t2, t2, t3); -tcg_gen_concat_tl_i64 (t3, cpu_LO[0 ], cpu_HI[0 ]); +tcg_gen_concat_tl_i64 (t3, cpu_LO[acc], cpu_HI[acc]);tcg_gen_add_i64 (t2, t2, t3);tcg_temp_free_i64 (t3);tcg_gen_trunc_i64_tl (t0, t2);tcg_gen_shri_i64 (t2, t2,32 );tcg_gen_trunc_i64_tl (t1, t2);tcg_temp_free_i64 (t2); -tcg_gen_ext32s_tl (cpu_LO[0 ], t0); -tcg_gen_ext32s_tl (cpu_HI[0 ], t1); +tcg_gen_ext32s_tl (cpu_LO[acc], t0); +tcg_gen_ext32s_tl (cpu_HI[acc], t1); } opn ="madd" ;break ;case OPC_MADDU : - { + {TCGv_i64 t2 =tcg_temp_new_i64 ();TCGv_i64 t3 =tcg_temp_new_i64 (); + acc = ((ctx->opcode) >>11 ) &0x03 ; +if (acc !=0 ) { +check_dsp (ctx); + }tcg_gen_ext32u_tl (t0, t0);tcg_gen_ext32u_tl (t1, t1);tcg_gen_extu_tl_i64 (t2, t0);tcg_gen_extu_tl_i64 (t3, t1);tcg_gen_mul_i64 (t2, t2, t3); -tcg_gen_concat_tl_i64 (t3, cpu_LO[0 ], cpu_HI[0 ]); +tcg_gen_concat_tl_i64 (t3, cpu_LO[acc], cpu_HI[acc]);tcg_gen_add_i64 (t2, t2, t3);tcg_temp_free_i64 (t3);tcg_gen_trunc_i64_tl (t0, t2);tcg_gen_shri_i64 (t2, t2,32 );tcg_gen_trunc_i64_tl (t1, t2);tcg_temp_free_i64 (t2); -tcg_gen_ext32s_tl (cpu_LO[0 ], t0); -tcg_gen_ext32s_tl (cpu_HI[0 ], t1); +tcg_gen_ext32s_tl (cpu_LO[acc], t0); +tcg_gen_ext32s_tl (cpu_HI[acc], t1); } opn ="maddu" ;break ;@@ -2210,19 +2282,23 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, {TCGv_i64 t2 =tcg_temp_new_i64 ();TCGv_i64 t3 =tcg_temp_new_i64 (); + acc = ((ctx->opcode) >>11 ) &0x03 ; +if (acc !=0 ) { +check_dsp (ctx); + }tcg_gen_ext_tl_i64 (t2, t0);tcg_gen_ext_tl_i64 (t3, t1);tcg_gen_mul_i64 (t2, t2, t3); -tcg_gen_concat_tl_i64 (t3, cpu_LO[0 ], cpu_HI[0 ]); +tcg_gen_concat_tl_i64 (t3, cpu_LO[acc], cpu_HI[acc]);tcg_gen_sub_i64 (t2, t3, t2);tcg_temp_free_i64 (t3);tcg_gen_trunc_i64_tl (t0, t2);tcg_gen_shri_i64 (t2, t2,32 );tcg_gen_trunc_i64_tl (t1, t2);tcg_temp_free_i64 (t2); -tcg_gen_ext32s_tl (cpu_LO[0 ], t0); -tcg_gen_ext32s_tl (cpu_HI[0 ], t1); +tcg_gen_ext32s_tl (cpu_LO[acc], t0); +tcg_gen_ext32s_tl (cpu_HI[acc], t1); } opn ="msub" ;break ;@@ -2230,21 +2306,25 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, {TCGv_i64 t2 =tcg_temp_new_i64 ();TCGv_i64 t3 =tcg_temp_new_i64 (); + acc = ((ctx->opcode) >>11 ) &0x03 ; +if (acc !=0 ) { +check_dsp (ctx); + }tcg_gen_ext32u_tl (t0, t0);tcg_gen_ext32u_tl (t1, t1);tcg_gen_extu_tl_i64 (t2, t0);tcg_gen_extu_tl_i64 (t3, t1);tcg_gen_mul_i64 (t2, t2, t3); -tcg_gen_concat_tl_i64 (t3, cpu_LO[0 ], cpu_HI[0 ]); +tcg_gen_concat_tl_i64 (t3, cpu_LO[acc], cpu_HI[acc]);tcg_gen_sub_i64 (t2, t3, t2);tcg_temp_free_i64 (t3);tcg_gen_trunc_i64_tl (t0, t2);
target-mips/translate.c static void gen_muldiv (DisasContext *ctx, uint32_t opc, · line 2330
Quoted 10 lines
target-mips/translate.c +2
-2tcg_gen_shri_i64 (t2, t2,32 );tcg_gen_trunc_i64_tl (t1, t2);tcg_temp_free_i64 (t2); -tcg_gen_ext32s_tl (cpu_LO[0 ], t0); -tcg_gen_ext32s_tl (cpu_HI[0 ], t1); +tcg_gen_ext32s_tl (cpu_LO[acc], t0); +tcg_gen_ext32s_tl (cpu_HI[acc], t1); } opn ="msubu" ;break ;
Except the minor nitpick above, this patch looks fine.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v7 4/14 target-mips-ase-dsp: Add branch instructions
In reply to Jia LiuAdd MIPS ASE DSP Branch instructions.
--- target-mips/translate.c | 50 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-)
target-mips/translate.c +46 -4
@@ -332,6 +332,14 @@ enum { OPC_DSHD = (0x05 << 6) | OPC_DBSHFL, }; +/* MIPS DSP REGIMM opcodes */ +enum { +OPC_BPOSGE32 = (0x1C <<16 ) |OPC_REGIMM , +#if defined(TARGET_MIPS64 ) +OPC_BPOSGE64 = (0x1D <<16 ) |OPC_REGIMM , +#endif +}; +/* Coprocessor 0 (rs field) */ #define MASK_CP0 (op) MASK_OP_MAJOR(op) | (op & (0x1F << 21))
@@ -2841,6 +2849,22 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc, } btgt = ctx->pc + insn_bytes + offset;break ; +case OPC_BPOSGE32 : +#if defined(TARGET_MIPS64 ) +tcg_gen_andi_tl (t0, cpu_dspctrl,0x7F ); +#else +tcg_gen_andi_tl (t0, cpu_dspctrl,0x3F ); +#endif + bcond_compute =1 ; + btgt = ctx->pc + insn_bytes + offset; +break ; +#if defined(TARGET_MIPS64 ) +case OPC_BPOSGE64 : +tcg_gen_andi_tl (t0, cpu_dspctrl,0x7F ); + bcond_compute =1 ; + btgt = ctx->pc + insn_bytes + offset; +break ; +#endif case OPC_J :case OPC_JAL :case OPC_JALX :
@@ -3029,6 +3053,16 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc,tcg_gen_setcondi_tl (TCG_COND_LT , bcond, t0,0 );MIPS_DEBUG ("bltzl %s, " TARGET_FMT_lx, regnames[rs], btgt); goto likely; +case OPC_BPOSGE32 : +tcg_gen_setcondi_tl (TCG_COND_GE , bcond, t0,32 ); +MIPS_DEBUG ("bposge32 %s, " TARGET_FMT_lx, t0, btgt); + goto not_likely; +#if defined(TARGET_MIPS64 ) +case OPC_BPOSGE64 : +tcg_gen_setcondi_tl (TCG_COND_GE , bcond, t0,64 ); +MIPS_DEBUG ("bposge64 %s, " TARGET_FMT_lx, t0, btgt); + goto not_likely; +#endif case OPC_BLTZALS :case OPC_BLTZAL : ctx->hflags |= (opc == OPC_BLTZALS
@@ -11284,10 +11318,6 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx, (ctx->opcode >> 18) & 0x7, imm << 1); *is_branch =1 ;break ; -case BPOSGE64 : -case BPOSGE32 : -/* MIPS DSP: not implemented */ -/* Fall through */ default :MIPS_INVAL ("pool32i" );generate_exception (ctx,EXCP_RI );
@@ -12196,6 +12226,18 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)check_insn (env, ctx,ISA_MIPS32R2 );/* Treat as NOP. */ break ; +case OPC_BPOSGE32 :/* MIPS DSP branch */ +check_dsp (ctx); +gen_compute_branch (ctx, op1,4 ,-1 ,-2 , (int32_t )imm <<2 ); + *is_branch =1 ; +break ; +#if defined(TARGET_MIPS64 ) +case OPC_BPOSGE64 : +check_dsp (ctx); +gen_compute_branch (ctx, op1,4 ,-1 ,-2 , (int32_t )imm <<2 ); + *is_branch =1 ; +break ; +#endif default :/* Invalid */ MIPS_INVAL ("regimm" );generate_exception (ctx,EXCP_RI );
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v7 04/14] target-mips-ase-dsp: Add branch instructions
Quoted 36 lines · Jia Liu
Add MIPS ASE DSP Branch instructions.
Signed-off-by Jia Liu <[email protected]>--- target-mips/translate.c | 50 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-)target-mips/translate.c +14
-0@@ -332,6 +332,14 @@ enum { OPC_DSHD = (0x05 << 6) | OPC_DBSHFL, }; +/* MIPS DSP REGIMM opcodes */ +enum { +OPC_BPOSGE32 = (0x1C <<16 ) |OPC_REGIMM , +#if defined(TARGET_MIPS64 ) +OPC_BPOSGE64 = (0x1D <<16 ) |OPC_REGIMM , +#endif +}; +/* Coprocessor 0 (rs field) */ #define MASK_CP0 (op) MASK_OP_MAJOR(op) | (op & (0x1F << 21))@@ -2841,6 +2849,22 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc, } btgt = ctx->pc + insn_bytes + offset;break ; +case OPC_BPOSGE32 : +#if defined(TARGET_MIPS64 ) +tcg_gen_andi_tl (t0, cpu_dspctrl,0x7F ); +#else +tcg_gen_andi_tl (t0, cpu_dspctrl,0x3F ); +#endif
target-mips/translate.c static void gen_compute_branch (DisasContext *ctx, uint32_t opc, · line 2867
Quoted 10 lines
target-mips/translate.c +10
-0+ bcond_compute =1 ; + btgt = ctx->pc + insn_bytes + offset; +break ; +#if defined(TARGET_MIPS64 ) +case OPC_BPOSGE64 : +tcg_gen_andi_tl (t0, cpu_dspctrl,0x7F ); + bcond_compute =1 ; + btgt = ctx->pc + insn_bytes + offset; +break ; +#endif
For this part of the code, BPOSGE32 is basically the same than BPOSGE64. Therefore this can be written the following way:
| case OPC_BPOSGE32: | #if defined(TARGET_MIPS64) | case OPC_BPOSGE64: | tcg_gen_andi_tl(t0, cpu_dspctrl, 0x7F); | #else | tcg_gen_andi_tl(t0, cpu_dspctrl, 0x3F); | #endif | bcond_compute = 1; | btgt = ctx->pc + insn_bytes + offset; | break;
Quoted 21 lines
target-mips/translate.c +10
-0case OPC_J :case OPC_JAL :case OPC_JALX :@@ -3029,6 +3053,16 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc,tcg_gen_setcondi_tl (TCG_COND_LT , bcond, t0,0 );MIPS_DEBUG ("bltzl %s, " TARGET_FMT_lx, regnames[rs], btgt); goto likely; +case OPC_BPOSGE32 : +tcg_gen_setcondi_tl (TCG_COND_GE , bcond, t0,32 ); +MIPS_DEBUG ("bposge32 %s, " TARGET_FMT_lx, t0, btgt); + goto not_likely; +#if defined(TARGET_MIPS64 ) +case OPC_BPOSGE64 : +tcg_gen_setcondi_tl (TCG_COND_GE , bcond, t0,64 ); +MIPS_DEBUG ("bposge64 %s, " TARGET_FMT_lx, t0, btgt); + goto not_likely; +#endif case OPC_BLTZALS :case OPC_BLTZAL : ctx->hflags |= (opc == OPC_BLTZALS
target-mips/translate.c static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx, · line 11290
Quoted 7 lines
target-mips/translate.c +0
-4@@ -11284,10 +11318,6 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx, (ctx->opcode >> 18) & 0x7, imm << 1); *is_branch =1 ;break ; -case BPOSGE64 : -case BPOSGE32 : -/* MIPS DSP: not implemented */ -/* Fall through */
I don't think this is correct. These are for microMIPS, and AFAIK, DSP ASE instructions can be encoded using microMIPS.
Quoted 9 lines
target-mips/translate.c +2
-0default :MIPS_INVAL ("pool32i" );generate_exception (ctx,EXCP_RI );@@ -12196,6 +12226,18 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)check_insn (env, ctx,ISA_MIPS32R2 );/* Treat as NOP. */ break ; +case OPC_BPOSGE32 :/* MIPS DSP branch */ +check_dsp (ctx);
target-mips/translate.c static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) · line 12240
Quoted 10 lines
target-mips/translate.c +10
-0+gen_compute_branch (ctx, op1,4 ,-1 ,-2 , (int32_t )imm <<2 ); + *is_branch =1 ; +break ; +#if defined(TARGET_MIPS64 ) +case OPC_BPOSGE64 : +check_dsp (ctx); +gen_compute_branch (ctx, op1,4 ,-1 ,-2 , (int32_t )imm <<2 ); + *is_branch =1 ; +break ; +#endif
Same here, this can be written
| case OPC_BPOSGE32: /* MIPS DSP branch */ | #if defined(TARGET_MIPS64) | case OPC_BPOSGE64: | #endif | check_dsp(ctx); | gen_compute_branch(ctx, op1, 4, -1, -2, (int32_t)imm << 2); | *is_branch = 1; | break;
Quoted 7 lines
target-mips/translate.c +0
-0default :/* Invalid */ MIPS_INVAL ("regimm" );generate_exception (ctx,EXCP_RI );Signature · 1 line
1.7.9.5
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH v7 04/14] target-mips-ase-dsp: Add branch instructions
Quoted 104 lines
-----Original Message-----
From: [email protected] [mailto:qemu-devel- [email protected]] On Behalf Of Aurelien Jarno
Sent: Thursday, September 06, 2012 2:11 AM
To: Jia Liu
Cc: [email protected]
Subject: Re: [Qemu-devel] [PATCH v7 04/14] target-mips-ase-dsp: Add branch instructionsQuoted 5 lines · Jia Liu
Add MIPS ASE DSP Branch instructions.
Signed-off-by Jia Liu <[email protected]>--- target-mips/translate.c | 50+++++++++++++++++++++++++++++++++++++++++++----
target-mips/translate.c static void gen_compute_branch (DisasContext *ctx,
Quoted 22 lines
1 file changed, 46 insertions(+), 4 deletions(-)target-mips/translate.c +8
-0@@ -332,6 +332,14 @@ enum { OPC_DSHD = (0x05 << 6) | OPC_DBSHFL, }; +/* MIPS DSP REGIMM opcodes */ +enum { +OPC_BPOSGE32 = (0x1C <<16 ) |OPC_REGIMM , +#if defined(TARGET_MIPS64 ) +OPC_BPOSGE64 = (0x1D <<16 ) |OPC_REGIMM , +#endif +}; +/* Coprocessor 0 (rs field) */ #define MASK_CP0 (op) MASK_OP_MAJOR(op) | (op & (0x1F << 21))@@ -2841,6 +2849,22 @@ static void gen_compute_branch (DisasContext *ctx,
uint32_topc,Quoted 9 lines
target-mips/translate.c +6
-0} btgt = ctx->pc + insn_bytes + offset;break ; +case OPC_BPOSGE32 : +#if defined(TARGET_MIPS64 ) +tcg_gen_andi_tl (t0, cpu_dspctrl,0x7F ); +#else +tcg_gen_andi_tl (t0, cpu_dspctrl,0x3F ); +#endif target-mips/translate.c static void gen_compute_branch (DisasContext *ctx, uint32_t opc, · line 2867
Quoted 10 lines
target-mips/translate.c +10
-0+ bcond_compute =1 ; + btgt = ctx->pc + insn_bytes + offset; +break ; +#if defined(TARGET_MIPS64 ) +case OPC_BPOSGE64 : +tcg_gen_andi_tl (t0, cpu_dspctrl,0x7F ); + bcond_compute =1 ; + btgt = ctx->pc + insn_bytes + offset; +break ; +#endif For this part of the code, BPOSGE32 is basically the same than BPOSGE64. Therefore this can be written the following way:
| case OPC_BPOSGE32: | #if defined(TARGET_MIPS64) | case OPC_BPOSGE64: | tcg_gen_andi_tl(t0, cpu_dspctrl, 0x7F); | #else | tcg_gen_andi_tl(t0, cpu_dspctrl, 0x3F); | #endif | bcond_compute = 1; | btgt = ctx->pc + insn_bytes + offset; | break;target-mips/translate.c static void gen_compute_branch (DisasContext *ctx,
Quoted 4 lines
target-mips/translate.c +0
-0case OPC_J :case OPC_JAL :case OPC_JALX :@@ -3029,6 +3053,16 @@ static void gen_compute_branch (DisasContext *ctx,
uint32_topc,target-mips/translate.c static void decode_micromips32_opc (CPUMIPSState
Quoted 17 lines
target-mips/translate.c +10
-0tcg_gen_setcondi_tl (TCG_COND_LT , bcond, t0,0 );MIPS_DEBUG ("bltzl %s, " TARGET_FMT_lx, regnames[rs], btgt); goto likely; +case OPC_BPOSGE32 : +tcg_gen_setcondi_tl (TCG_COND_GE , bcond, t0,32 ); +MIPS_DEBUG ("bposge32 %s, " TARGET_FMT_lx, t0, btgt); + goto not_likely; +#if defined(TARGET_MIPS64 ) +case OPC_BPOSGE64 : +tcg_gen_setcondi_tl (TCG_COND_GE , bcond, t0,64 ); +MIPS_DEBUG ("bposge64 %s, " TARGET_FMT_lx, t0, btgt); + goto not_likely; +#endif case OPC_BLTZALS :case OPC_BLTZAL : ctx->hflags |= (opc == OPC_BLTZALS@@ -11284,10 +11318,6 @@ static void decode_micromips32_opc (CPUMIPSState*env, DisasContext *ctx,
target-mips/translate.c static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx, · line 11290
Quoted 7 lines
target-mips/translate.c +0
-4(ctx->opcode >> 18) & 0x7, imm << 1); *is_branch =1 ;break ; -case BPOSGE64 : -case BPOSGE32 : -/* MIPS DSP: not implemented */ -/* Fall through */
Quoted 2 lines
I don't think this is correct. These are for microMIPS, and AFAIK, DSP ASE instructions can be encoded using microMIPS.
Yes, the MIPS DSP ASE instructions have microMIPS encodings. They are available on the microAptiv processors.
Quoted 41 lines
target-mips/translate.c static void decode_opc (CPUMIPSState *env,
Quoted 5 lines
target-mips/translate.c +0
-0default :MIPS_INVAL ("pool32i" );generate_exception (ctx,EXCP_RI );@@ -12196,6 +12226,18 @@ static void decode_opc (CPUMIPSState *env,DisasContext *ctx, int
*is_branch)Quoted 5 lines
target-mips/translate.c +2
-0check_insn (env, ctx,ISA_MIPS32R2 );/* Treat as NOP. */ break ; +case OPC_BPOSGE32 :/* MIPS DSP branch */ +check_dsp (ctx);target-mips/translate.c static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) · line 12240
Quoted 10 lines
target-mips/translate.c +10
-0+gen_compute_branch (ctx, op1,4 ,-1 ,-2 , (int32_t )imm <<2 ); + *is_branch =1 ; +break ; +#if defined(TARGET_MIPS64 ) +case OPC_BPOSGE64 : +check_dsp (ctx); +gen_compute_branch (ctx, op1,4 ,-1 ,-2 , (int32_t )imm <<2 ); + *is_branch =1 ; +break ; +#endif Same here, this can be written
| case OPC_BPOSGE32: /* MIPS DSP branch */ | #if defined(TARGET_MIPS64) | case OPC_BPOSGE64: | #endif | check_dsp(ctx); | gen_compute_branch(ctx, op1, 4, -1, -2, (int32_t)imm << 2); | *is_branch = 1; | break;Quoted 7 lines
target-mips/translate.c +0
-1default :/* Invalid */ MIPS_INVAL ("regimm" );generate_exception (ctx,EXCP_RI ); --1.7.9.5
Quoted 3 lines
--
Aurelien Jarno GPG: 1024D/F1BCDB73
[email protected] http://www.aurel32.net
-Eric
PATCH v7 5/14 target-mips-ase-dsp: Add load instructions
In reply to Jia LiuAdd MIPS ASE DSP Load instructions.
--- target-mips/translate.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
target-mips/translate.c +62 -0
@@ -313,6 +313,9 @@ enum {OPC_MODU_G_2E =0x23 |OPC_SPECIAL3 ,OPC_DMOD_G_2E =0x26 |OPC_SPECIAL3 ,OPC_DMODU_G_2E =0x27 |OPC_SPECIAL3 , + +/* MIPS DSP Load */ + OPC_LX_DSP = 0x0A | OPC_SPECIAL3, };/* BSHFL opcodes */
@@ -340,6 +343,17 @@ enum {#endif }; +#define MASK_LX (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +/* MIPS DSP Load */ +enum { +OPC_LBUX = (0x06 <<6 ) |OPC_LX_DSP , +OPC_LHX = (0x04 <<6 ) |OPC_LX_DSP , +OPC_LWX = (0x00 <<6 ) |OPC_LX_DSP , +#if defined(TARGET_MIPS64 ) +OPC_LDX = (0x08 <<6 ) |OPC_LX_DSP , +#endif +}; +/* Coprocessor 0 (rs field) */ #define MASK_CP0 (op) MASK_OP_MAJOR(op) | (op & (0x1F << 21))
@@ -12184,6 +12198,54 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)check_insn (env, ctx,INSN_LOONGSON2E );gen_loongson_integer (ctx, op1, rd, rs, rt);break ; +case OPC_LX_DSP : +check_dsp (ctx); + op2 =MASK_LX (ctx->opcode); +switch (op2) { +case OPC_LBUX : + { +TCGv addr =tcg_temp_new (); + +gen_op_addr_add (ctx, addr, cpu_gpr[rs], cpu_gpr[rt]); +op_ld_lbu (cpu_gpr[rd], addr, ctx); +tcg_temp_free (addr); +break ; + } +case OPC_LHX : + { +TCGv addr =tcg_temp_new (); + +gen_op_addr_add (ctx, addr, cpu_gpr[rs], cpu_gpr[rt]); +op_ld_lh (cpu_gpr[rd], addr, ctx); +tcg_temp_free (addr); +break ; + } +case OPC_LWX : + { +TCGv addr =tcg_temp_new (); + +gen_op_addr_add (ctx, addr, cpu_gpr[rs], cpu_gpr[rt]); +op_ld_lw (cpu_gpr[rd], addr, ctx); +tcg_temp_free (addr); +break ; + } +#if defined(TARGET_MIPS64 ) +case OPC_LDX : + { +TCGv addr =tcg_temp_new (); + +gen_op_addr_add (ctx, addr, cpu_gpr[rs], cpu_gpr[rt]); +op_ld_ld (cpu_gpr[rd], addr, ctx); +tcg_temp_free (addr); +break ; + } +#endif +default :/* Invalid */ +MIPS_INVAL ("MASK LX" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ;#if defined(TARGET_MIPS64 ) case OPC_DEXTM ... OPC_DEXT: case OPC_DINSM ... OPC_DINS:
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v7 05/14] target-mips-ase-dsp: Add load instructions
Quoted 41 lines · Jia Liu
Add MIPS ASE DSP Load instructions.
Signed-off-by Jia Liu <[email protected]>--- target-mips/translate.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)target-mips/translate.c +14
-0@@ -313,6 +313,9 @@ enum {OPC_MODU_G_2E =0x23 |OPC_SPECIAL3 ,OPC_DMOD_G_2E =0x26 |OPC_SPECIAL3 ,OPC_DMODU_G_2E =0x27 |OPC_SPECIAL3 , + +/* MIPS DSP Load */ + OPC_LX_DSP = 0x0A | OPC_SPECIAL3, };/* BSHFL opcodes */ @@ -340,6 +343,17 @@ enum {#endif }; +#define MASK_LX (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +/* MIPS DSP Load */ +enum { +OPC_LBUX = (0x06 <<6 ) |OPC_LX_DSP , +OPC_LHX = (0x04 <<6 ) |OPC_LX_DSP , +OPC_LWX = (0x00 <<6 ) |OPC_LX_DSP , +#if defined(TARGET_MIPS64 ) +OPC_LDX = (0x08 <<6 ) |OPC_LX_DSP , +#endif +}; +/* Coprocessor 0 (rs field) */ #define MASK_CP0 (op) MASK_OP_MAJOR(op) | (op & (0x1F << 21))@@ -12184,6 +12198,54 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)check_insn (env, ctx,INSN_LOONGSON2E );
target-mips/translate.c static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) · line 12208
Quoted 10 lines
target-mips/translate.c +8
-0gen_loongson_integer (ctx, op1, rd, rs, rt);break ; +case OPC_LX_DSP : +check_dsp (ctx); + op2 =MASK_LX (ctx->opcode); +switch (op2) { +case OPC_LBUX : + { +TCGv addr =tcg_temp_new (); +
I think you got my comment on the previous version wrong here. You do need to call op_ld_lbu to save the hflags and the possible btarget, but you don't need to save PC (it can be recovered from TB retranslation).
Thus you need to call (note the 0 as the second argument):
save_cpu_state(ctx, 0);
target-mips/translate.c static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) · line 12217
Quoted 9 lines
target-mips/translate.c +9
-0+gen_op_addr_add (ctx, addr, cpu_gpr[rs], cpu_gpr[rt]); +op_ld_lbu (cpu_gpr[rd], addr, ctx); +tcg_temp_free (addr); +break ; + } +case OPC_LHX : + { +TCGv addr =tcg_temp_new (); +
Ditto
target-mips/translate.c static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) · line 12226
Quoted 9 lines
target-mips/translate.c +9
-0+gen_op_addr_add (ctx, addr, cpu_gpr[rs], cpu_gpr[rt]); +op_ld_lh (cpu_gpr[rd], addr, ctx); +tcg_temp_free (addr); +break ; + } +case OPC_LWX : + { +TCGv addr =tcg_temp_new (); +
Ditto
target-mips/translate.c static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) · line 12236
Quoted 10 lines
target-mips/translate.c +10
-0+gen_op_addr_add (ctx, addr, cpu_gpr[rs], cpu_gpr[rt]); +op_ld_lw (cpu_gpr[rd], addr, ctx); +tcg_temp_free (addr); +break ; + } +#if defined(TARGET_MIPS64 ) +case OPC_LDX : + { +TCGv addr =tcg_temp_new (); +
Ditto
Quoted 19 lines
target-mips/translate.c +12
-0+gen_op_addr_add (ctx, addr, cpu_gpr[rs], cpu_gpr[rt]); +op_ld_ld (cpu_gpr[rd], addr, ctx); +tcg_temp_free (addr); +break ; + } +#endif +default :/* Invalid */ +MIPS_INVAL ("MASK LX" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ;#if defined(TARGET_MIPS64 ) case OPC_DEXTM ... OPC_DEXT: case OPC_DINSM ... OPC_DINS:Signature · 1 line
1.7.9.5
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v7 6/14 target-mips-ase-dsp: Add arithmetic instructions
In reply to Jia LiuAdd MIPS ASE DSP Arithmetic instructions.
--- target-mips/dsp_helper.c | 1929 ++++++++++++++++++++++++++++++++++++++++++++++ target-mips/helper.h | 132 ++++ target-mips/translate.c | 669 +++++++++++++++- 3 files changed, 2727 insertions(+), 3 deletions(-)
target-mips/dsp_helper.c +1929 -0
@@ -1275,3 +1275,1932 @@ static inline int32_t mipsdsp_add_i32(CPUMIPSState *env, int32_t a, int32_t b)return result; }/*** MIPS DSP internal functions end ***/ + +#define MIPSDSP_LHI 0xFFFFFFFF00000000ull +#define MIPSDSP_LLO 0x00000000FFFFFFFFull +#define MIPSDSP_HI 0xFFFF0000 +#define MIPSDSP_LO 0x0000FFFF +#define MIPSDSP_Q3 0xFF000000 +#define MIPSDSP_Q2 0x00FF0000 +#define MIPSDSP_Q1 0x0000FF00 +#define MIPSDSP_Q0 0x000000FF + +/** DSP Arithmetic Sub-class insns **/ +target_ulong helper_addq_ph (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl, temph, templ; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + temph =mipsdsp_add_i16 (env, rsh, rth); + templ =mipsdsp_add_i16 (env, rsl, rtl); + rd = ((unsigned int )temph <<16 ) | ((unsigned int )templ &0xFFFF ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addq_s_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl, temph, templ; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + temph =mipsdsp_sat_add_i16 (env, rsh, rth); + templ =mipsdsp_sat_add_i16 (env, rsl, rtl); + rd = ((uint32_t )temph <<16 ) | ((uint32_t )templ &0xFFFF ); + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_addq_qh (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_add_i16 (env, rs3, rt3); + tempC =mipsdsp_add_i16 (env, rs2, rt2); + tempB =mipsdsp_add_i16 (env, rs1, rt1); + tempA =mipsdsp_add_i16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_addq_s_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sat_add_i16 (env, rs3, rt3); + tempC =mipsdsp_sat_add_i16 (env, rs2, rt2); + tempB =mipsdsp_sat_add_i16 (env, rs1, rt1); + tempA =mipsdsp_sat_add_i16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_addq_s_w (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rd; + rd =mipsdsp_sat_add_i32 (env, rs, rt); +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_addq_pw (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint32_t rs1, rs0; +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_add_i32 (env, rs1, rt1); + tempA =mipsdsp_add_i32 (env, rs0, rt0); + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_addq_s_pw (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rs1, rs0; +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_sat_add_i32 (env, rs1, rt1); + tempA =mipsdsp_sat_add_i32 (env, rs0, rt0); + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_addu_qb (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint32_t rd; +uint8_t rs0, rs1, rs2, rs3; +uint8_t rt0, rt1, rt2, rt3; +uint8_t temp0, temp1, temp2, temp3; + + rs0 = rs &MIPSDSP_Q0 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + + rt0 = rt &MIPSDSP_Q0 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + + temp0 =mipsdsp_add_u8 (env, rs0, rt0); + temp1 =mipsdsp_add_u8 (env, rs1, rt1); + temp2 =mipsdsp_add_u8 (env, rs2, rt2); + temp3 =mipsdsp_add_u8 (env, rs3, rt3); + + rd = (((uint32_t )temp3 <<24 ) &MIPSDSP_Q3 ) | + (((uint32_t )temp2 <<16 ) &MIPSDSP_Q2 ) | + (((uint32_t )temp1 <<8 ) &MIPSDSP_Q1 ) | + ((uint32_t )temp0 &MIPSDSP_Q0 ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addu_s_qb (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rd; +uint8_t rs0, rs1, rs2, rs3; +uint8_t rt0, rt1, rt2, rt3; +uint8_t temp0, temp1, temp2, temp3; + + rs0 = rs &MIPSDSP_Q0 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + + rt0 = rt &MIPSDSP_Q0 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + + temp0 =mipsdsp_sat_add_u8 (env, rs0, rt0); + temp1 =mipsdsp_sat_add_u8 (env, rs1, rt1); + temp2 =mipsdsp_sat_add_u8 (env, rs2, rt2); + temp3 =mipsdsp_sat_add_u8 (env, rs3, rt3); + + rd = (((uint8_t )temp3 <<24 ) &MIPSDSP_Q3 ) | + (((uint8_t )temp2 <<16 ) &MIPSDSP_Q2 ) | + (((uint8_t )temp1 <<8 ) &MIPSDSP_Q1 ) | + ((uint8_t )temp0 &MIPSDSP_Q0 ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_adduh_qb (target_ulong rs,target_ulong rt) +{ +uint32_t rd; +uint8_t rs0, rs1, rs2, rs3; +uint8_t rt0, rt1, rt2, rt3; +uint8_t temp0, temp1, temp2, temp3; + + rs0 = rs &MIPSDSP_Q0 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + + rt0 = rt &MIPSDSP_Q0 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + + temp0 =mipsdsp_rshift1_add_u8 (rs0, rt0); + temp1 =mipsdsp_rshift1_add_u8 (rs1, rt1); + temp2 =mipsdsp_rshift1_add_u8 (rs2, rt2); + temp3 =mipsdsp_rshift1_add_u8 (rs3, rt3); + + rd = (((uint32_t )temp3 <<24 ) &MIPSDSP_Q3 ) | + (((uint32_t )temp2 <<16 ) &MIPSDSP_Q2 ) | + (((uint32_t )temp1 <<8 ) &MIPSDSP_Q1 ) | + ((uint32_t )temp0 &MIPSDSP_Q0 ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_adduh_r_qb (target_ulong rs,target_ulong rt) +{ +uint32_t rd; +uint8_t rs0, rs1, rs2, rs3; +uint8_t rt0, rt1, rt2, rt3; +uint8_t temp0, temp1, temp2, temp3; + + rs0 = rs &MIPSDSP_Q0 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + + rt0 = rt &MIPSDSP_Q0 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + + temp0 =mipsdsp_rrshift1_add_u8 (rs0, rt0); + temp1 =mipsdsp_rrshift1_add_u8 (rs1, rt1); + temp2 =mipsdsp_rrshift1_add_u8 (rs2, rt2); + temp3 =mipsdsp_rrshift1_add_u8 (rs3, rt3); + + rd = (((uint32_t )temp3 <<24 ) &MIPSDSP_Q3 ) | + (((uint32_t )temp2 <<16 ) &MIPSDSP_Q2 ) | + (((uint32_t )temp1 <<8 ) &MIPSDSP_Q1 ) | + ((uint32_t )temp0 &MIPSDSP_Q0 ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addu_ph (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl, temph, templ; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + temph =mipsdsp_add_u16 (env, rsh, rth); + templ =mipsdsp_add_u16 (env, rsl, rtl); + rd = ((uint32_t )temph <<16 ) | ((uint32_t )templ &MIPSDSP_LO ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addu_s_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl, temph, templ; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + temph =mipsdsp_sat_add_u16 (env, rsh, rth); + templ =mipsdsp_sat_add_u16 (env, rsl, rtl); + rd = ((uint32_t )temph <<16 ) | ((uint32_t )templ &MIPSDSP_LO ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addqh_ph (target_ulong rs,target_ulong rt) +{ +uint32_t rd; +int16_t rsh, rsl, rth, rtl, temph, templ; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + temph =mipsdsp_rshift1_add_q16 (rsh, rth); + templ =mipsdsp_rshift1_add_q16 (rsl, rtl); + rd = ((uint32_t )temph <<16 ) | ((uint32_t )templ &MIPSDSP_LO ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addqh_r_ph (target_ulong rs,target_ulong rt) +{ +uint32_t rd; +int16_t rsh, rsl, rth, rtl, temph, templ; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + temph =mipsdsp_rrshift1_add_q16 (rsh, rth); + templ =mipsdsp_rrshift1_add_q16 (rsl, rtl); + rd = ((uint32_t )temph <<16 ) | ((uint32_t )templ &MIPSDSP_LO ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addqh_w (target_ulong rs,target_ulong rt) +{ +uint32_t rd; + + rd =mipsdsp_rshift1_add_q32 (rs, rt); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addqh_r_w (target_ulong rs,target_ulong rt) +{ +uint32_t rd; + + rd =mipsdsp_rrshift1_add_q32 (rs, rt); + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_addu_ob (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_add_u8 (env, rs_t[i], rt_t[i]); + } + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_addu_s_ob (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_sat_add_u8 (env, rs_t[i], rt_t[i]); + } + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_adduh_ob (target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_rshift1_add_u8 (rs_t[i], rt_t[i]); + } + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_adduh_r_ob (target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_rrshift1_add_u8 (rs_t[i], rt_t[i]); + } + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_addu_qh (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_add_u16 (env, rs3, rt3); + tempC =mipsdsp_add_u16 (env, rs2, rt2); + tempB =mipsdsp_add_u16 (env, rs1, rt1); + tempA =mipsdsp_add_u16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_addu_s_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sat_add_u16 (env, rs3, rt3); + tempC =mipsdsp_sat_add_u16 (env, rs2, rt2); + tempB =mipsdsp_sat_add_u16 (env, rs1, rt1); + tempA =mipsdsp_sat_add_u16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_subq_ph (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl; +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_sub_i16 (env, rsh, rth); + tempA =mipsdsp_sub_i16 (env, rsl, rtl); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_subq_s_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl; +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_sat16_sub (env, rsh, rth); + tempA =mipsdsp_sat16_sub (env, rsl, rtl); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_subq_qh (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sub_i16 (env, rs3, rt3); + tempC =mipsdsp_sub_i16 (env, rs2, rt2); + tempB =mipsdsp_sub_i16 (env, rs1, rt1); + tempA =mipsdsp_sub_i16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; +return temp; +} + +target_ulong helper_subq_s_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sat16_sub (env, rs3, rt3); + tempC =mipsdsp_sat16_sub (env, rs2, rt2); + tempB =mipsdsp_sat16_sub (env, rs1, rt1); + tempA =mipsdsp_sat16_sub (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; +return temp; +} +#endif + +target_ulong helper_subq_s_w (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rd; + + rd =mipsdsp_sat32_sub (env, rs, rt); + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_subq_pw (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint32_t rs1, rs0; +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_sub32 (env, rs1, rt1); + tempA =mipsdsp_sub32 (env, rs0, rt0); + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; +return temp; +} + +target_ulong helper_subq_s_pw (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rs1, rs0; +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_sat32_sub (env, rs1, rt1); + tempA =mipsdsp_sat32_sub (env, rs0, rt0); + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; +return temp; +} +#endif + +target_ulong helper_subu_qb (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2, rs1, rs0; +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs0 = rs &MIPSDSP_Q0 ; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_sub_u8 (env, rs3, rt3); + tempC =mipsdsp_sub_u8 (env, rs2, rt2); + tempB =mipsdsp_sub_u8 (env, rs1, rt1); + tempA =mipsdsp_sub_u8 (env, rs0, rt0); + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; +return (target_long )(int32_t )rd; +} + +target_ulong helper_subu_s_qb (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2, rs1, rs0; +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs0 = rs &MIPSDSP_Q0 ; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_satu8_sub (env, rs3, rt3); + tempC =mipsdsp_satu8_sub (env, rs2, rt2); + tempB =mipsdsp_satu8_sub (env, rs1, rt1); + tempA =mipsdsp_satu8_sub (env, rs0, rt0); + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_subuh_qb (target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2, rs1, rs0; +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs0 = rs &MIPSDSP_Q0 ; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD = ((uint16_t )rs3 - (uint16_t )rt3) >>1 ; + tempC = ((uint16_t )rs2 - (uint16_t )rt2) >>1 ; + tempB = ((uint16_t )rs1 - (uint16_t )rt1) >>1 ; + tempA = ((uint16_t )rs0 - (uint16_t )rt0) >>1 ; + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_ulong )rd; +} + +target_ulong helper_subuh_r_qb (target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2, rs1, rs0; +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs0 = rs &MIPSDSP_Q0 ; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD = ((uint16_t )rs3 - (uint16_t )rt3 +1 ) >>1 ; + tempC = ((uint16_t )rs2 - (uint16_t )rt2 +1 ) >>1 ; + tempB = ((uint16_t )rs1 - (uint16_t )rt1 +1 ) >>1 ; + tempA = ((uint16_t )rs0 - (uint16_t )rt0 +1 ) >>1 ; + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_ulong )rd; +} + +target_ulong helper_subu_ph (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_sub_u16_u16 (env, rth, rsh); + tempA =mipsdsp_sub_u16_u16 (env, rtl, rsl); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; +return (target_long )(int32_t )rd; +} + +target_ulong helper_subu_s_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_satu16_sub_u16_u16 (env, rth, rsh); + tempA =mipsdsp_satu16_sub_u16_u16 (env, rtl, rsl); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_subqh_ph (target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl; +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_rshift1_sub_q16 (rsh, rth); + tempA =mipsdsp_rshift1_sub_q16 (rsl, rtl); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_subqh_r_ph (target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl; +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_rrshift1_sub_q16 (rsh, rth); + tempA =mipsdsp_rrshift1_sub_q16 (rsl, rtl); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_subqh_w (target_ulong rs,target_ulong rt) +{ +uint32_t rd; + + rd =mipsdsp_rshift1_sub_q32 (rs, rt); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_subqh_r_w (target_ulong rs,target_ulong rt) +{ +uint32_t rd; + + rd =mipsdsp_rrshift1_sub_q32 (rs, rt); + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_subu_ob (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_sub_u8 (env, rs_t[i], rt_t[i]); + } + +for (i =0 ; i <8 ; i++) { + result += (uint64_t )temp[i] << (i *8 ); + } + +return result; +} + +target_ulong helper_subu_s_ob (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_satu8_sub (env, rs_t[i], rt_t[i]); + } + +for (i =0 ; i <8 ; i++) { + result += (uint64_t )temp[i] << (i *8 ); + } + +return result; +} + +target_ulong helper_subuh_ob (target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] = ((uint16_t )rs_t[i] - (uint16_t )rt_t[i]) >>1 ; + } + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_subuh_r_ob (target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] = ((uint16_t )rs_t[i] - (uint16_t )rt_t[i] +1 ) >>1 ; + } + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_subu_qh (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sub_u16_u16 (env, rs3, rt3); + tempC =mipsdsp_sub_u16_u16 (env, rs2, rt2); + tempB =mipsdsp_sub_u16_u16 (env, rs1, rt1); + tempA =mipsdsp_sub_u16_u16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; +return temp; +} + + +target_ulong helper_subu_s_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_satu16_sub_u16_u16 (env, rs3, rt3); + tempC =mipsdsp_satu16_sub_u16_u16 (env, rs2, rt2); + tempB =mipsdsp_satu16_sub_u16_u16 (env, rs1, rt1); + tempA =mipsdsp_satu16_sub_u16_u16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; +return temp; +} +#endif + +target_ulong helper_addsc (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint32_t rd; +uint64_t temp, tempRs, tempRt; +int32_t flag; + + tempRs = (uint64_t )rs &MIPSDSP_LLO ; + tempRt = (uint64_t )rt &MIPSDSP_LLO ; + + temp = tempRs + tempRt; + flag = (temp &0x0100000000ull ) >>32 ; +set_DSPControl_carryflag (env, flag); + rd = temp &MIPSDSP_LLO ; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addwc (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint32_t rd; +int32_t temp32, temp31; +int64_t rsL, rtL, tempL; + + rsL = (int32_t )rs; + rtL = (int32_t )rt; + tempL = rsL + rtL +get_DSPControl_carryflag (env); + temp31 = (tempL >>31 ) &0x01 ; + temp32 = (tempL >>32 ) &0x01 ; + +if (temp31 != temp32) { +set_DSPControl_overflow_flag (env,1 ,20 ); + } + + rd = tempL &MIPSDSP_LLO ; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_modsub (target_ulong rs,target_ulong rt) +{ +int32_t decr; +uint16_t lastindex; +target_ulong rd; + + decr = rt &MIPSDSP_Q0 ; + lastindex = (rt >>8 ) &MIPSDSP_LO ; + +if ((rs &MIPSDSP_LLO ) ==0x00000000 ) { + rd = (target_ulong )lastindex; + }else { + rd = rs - decr; + } + +return rd; +} + +target_ulong helper_raddu_w_qb (target_ulong rs) +{ +uint8_t rs3, rs2, rs1, rs0; +uint16_t temp; +uint32_t rd; + + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs0 = rs &MIPSDSP_Q0 ; + + temp = (uint16_t )rs3 + (uint16_t )rs2 + (uint16_t )rs1 + (uint16_t )rs0; + rd = temp; + +return (target_ulong )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_raddu_l_ob (target_ulong rs) +{ +int i; +uint16_t rs_t[8 ]; +uint64_t temp; + + temp =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + temp += (uint64_t )rs_t[i]; + } + +return temp; +} +#endif + +target_ulong helper_absq_s_qb (CPUMIPSState *env,target_ulong rt) +{ +uint32_t rd; +int8_t tempD, tempC, tempB, tempA; + + tempD = (rt &MIPSDSP_Q3 ) >>24 ; + tempC = (rt &MIPSDSP_Q2 ) >>16 ; + tempB = (rt &MIPSDSP_Q1 ) >>8 ; + tempA = rt &MIPSDSP_Q0 ; + + rd = (((uint32_t )mipsdsp_sat_abs_u8 (env, tempD) <<24 ) &MIPSDSP_Q3 ) | + (((uint32_t )mipsdsp_sat_abs_u8 (env, tempC) <<16 ) &MIPSDSP_Q2 ) | + (((uint32_t )mipsdsp_sat_abs_u8 (env, tempB) <<8 ) &MIPSDSP_Q1 ) | + ((uint32_t )mipsdsp_sat_abs_u8 (env, tempA) &MIPSDSP_Q0 ); + +return (target_ulong )rd; +} + +target_ulong helper_absq_s_ph (CPUMIPSState *env,target_ulong rt) +{ +uint32_t rd; +int16_t tempA, tempB; + + tempA = (rt &MIPSDSP_HI ) >>16 ; + tempB = rt &MIPSDSP_LO ; + + rd = ((uint32_t )mipsdsp_sat_abs_u16 (env, tempA) <<16 ) | + ((uint32_t )(mipsdsp_sat_abs_u16 (env, tempB)) &0xFFFF ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_absq_s_w (CPUMIPSState *env,target_ulong rt) +{ +uint32_t rd; +int32_t temp; + + temp = rt; + rd =mipsdsp_sat_abs_u32 (env, temp); + +return (target_ulong )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_absq_s_ob (CPUMIPSState *env,target_ulong rt) +{ +uint8_t tempH, tempG, tempF, tempE; +uint8_t tempD, tempC, tempB, tempA; +uint64_t temp; + + tempH = (rt >>56 ) &MIPSDSP_Q0 ; + tempG = (rt >>48 ) &MIPSDSP_Q0 ; + tempF = (rt >>40 ) &MIPSDSP_Q0 ; + tempE = (rt >>32 ) &MIPSDSP_Q0 ; + tempD = (rt >>24 ) &MIPSDSP_Q0 ; + tempC = (rt >>16 ) &MIPSDSP_Q0 ; + tempB = (rt >>8 ) &MIPSDSP_Q0 ; + tempA = rt &MIPSDSP_Q0 ; + + tempH =mipsdsp_sat_abs_u8 (env, tempH); + tempG =mipsdsp_sat_abs_u8 (env, tempG); + tempF =mipsdsp_sat_abs_u8 (env, tempF); + tempE =mipsdsp_sat_abs_u8 (env, tempE); + tempD =mipsdsp_sat_abs_u8 (env, tempD); + tempC =mipsdsp_sat_abs_u8 (env, tempC); + tempB =mipsdsp_sat_abs_u8 (env, tempB); + tempA =mipsdsp_sat_abs_u8 (env, tempA); + + temp = ((uint64_t )tempH <<56 ) | ((uint64_t )tempG <<48 ) | + ((uint64_t )tempF <<40 ) | ((uint64_t )tempE <<32 ) | + ((uint64_t )tempD <<24 ) | ((uint64_t )tempC <<16 ) | + ((uint64_t )tempB <<8 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_absq_s_qh (CPUMIPSState *env,target_ulong rt) +{ +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + tempD = (rt >>48 ) &MIPSDSP_LO ; + tempC = (rt >>32 ) &MIPSDSP_LO ; + tempB = (rt >>16 ) &MIPSDSP_LO ; + tempA = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sat_abs_u16 (env, tempD); + tempC =mipsdsp_sat_abs_u16 (env, tempC); + tempB =mipsdsp_sat_abs_u16 (env, tempB); + tempA =mipsdsp_sat_abs_u16 (env, tempA); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_absq_s_pw (CPUMIPSState *env,target_ulong rt) +{ +uint32_t tempB, tempA; +uint64_t temp; + + tempB = (rt >>32 ) &MIPSDSP_LLO ; + tempA = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_sat_abs_u32 (env, tempB); + tempA =mipsdsp_sat_abs_u32 (env, tempA); + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_precr_qb_ph (target_ulong rs,target_ulong rt) +{ +uint8_t rs2, rs0, rt2, rt0; +uint32_t rd; + + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs0 = rs &MIPSDSP_Q0 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt0 = rt &MIPSDSP_Q0 ; + rd = ((uint32_t )rs2 <<24 ) | ((uint32_t )rs0 <<16 ) | + ((uint32_t )rt2 <<8 ) | (uint32_t )rt0; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_precrq_qb_ph (target_ulong rs,target_ulong rt) +{ +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + tempD = (rs &MIPSDSP_Q3 ) >>24 ; + tempC = (rs &MIPSDSP_Q1 ) >>8 ; + tempB = (rt &MIPSDSP_Q3 ) >>24 ; + tempA = (rt &MIPSDSP_Q1 ) >>8 ; + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_precr_sra_ph_w (uint32_t sa,target_ulong rs, +target_ulong rt) +{ +uint16_t tempB, tempA; + +if (sa ==0 ) { + tempB = rt &MIPSDSP_LO ; + tempA = rs &MIPSDSP_LO ; + }else { + tempB = ((int32_t )rt >> sa) &MIPSDSP_LO ; + tempA = ((int32_t )rs >> sa) &MIPSDSP_LO ; + } + rt = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); + +return (target_long )(int32_t )rt; +} + +target_ulong helper_precr_sra_r_ph_w (uint32_t sa, +target_ulong rs,target_ulong rt) +{ +uint64_t tempB, tempA; + +if (sa ==0 ) { + tempB = (rt &MIPSDSP_LO ) <<1 ; + tempA = (rs &MIPSDSP_LO ) <<1 ; + }else { + tempB = ((int32_t )rt >> (sa -1 )) +1 ; + tempA = ((int32_t )rs >> (sa -1 )) +1 ; + } + rt = (((tempB >>1 ) &MIPSDSP_LO ) <<16 ) | ((tempA >>1 ) &MIPSDSP_LO ); + +return (target_long )(int32_t )rt; +} + +target_ulong helper_precrq_ph_w (target_ulong rs,target_ulong rt) +{ +uint16_t tempB, tempA; +uint32_t rd; + + tempB = (rs &MIPSDSP_HI ) >>16 ; + tempA = (rt &MIPSDSP_HI ) >>16 ; + rd = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_precrq_rs_ph_w (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t tempB, tempA; +uint32_t rd; + + tempB =mipsdsp_trunc16_sat16_round (env, rs); + tempA =mipsdsp_trunc16_sat16_round (env, rt); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_precr_ob_qh (target_ulong rs,target_ulong rt) +{ +uint8_t rs6, rs4, rs2, rs0; +uint8_t rt6, rt4, rt2, rt0; +uint64_t temp; + + rs6 = (rs >>48 ) &MIPSDSP_Q0 ; + rs4 = (rs >>32 ) &MIPSDSP_Q0 ; + rs2 = (rs >>16 ) &MIPSDSP_Q0 ; + rs0 = rs &MIPSDSP_Q0 ; + rt6 = (rt >>48 ) &MIPSDSP_Q0 ; + rt4 = (rt >>32 ) &MIPSDSP_Q0 ; + rt2 = (rt >>16 ) &MIPSDSP_Q0 ; + rt0 = rt &MIPSDSP_Q0 ; + + temp = ((uint64_t )rs6 <<56 ) | ((uint64_t )rs4 <<48 ) | + ((uint64_t )rs2 <<40 ) | ((uint64_t )rs0 <<32 ) | + ((uint64_t )rt6 <<24 ) | ((uint64_t )rt4 <<16 ) | + ((uint64_t )rt2 <<8 ) | (uint64_t )rt0; + +return temp; +} + +target_ulong helper_precr_sra_qh_pw (target_ulong rs,target_ulong rt, +uint32_t sa) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t result; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + +if (sa ==0 ) { + tempD = rt2; + tempC = rt0; + tempB = rs2; + tempA = rs0; + }else { + tempD = (int16_t )rt3 >> sa; + tempC = (int16_t )rt1 >> sa; + tempB = (int16_t )rs3 >> sa; + tempA = (int16_t )rs1 >> sa; + } + + result = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return result; +} + + +target_ulong helper_precr_sra_r_qh_pw (target_ulong rs,target_ulong rt, +uint32_t sa) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t result; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + +if (sa ==0 ) { + tempD = rt2 <<1 ; + tempC = rt0 <<1 ; + tempB = rs2 <<1 ; + tempA = rs0 <<1 ; + }else { + tempD = (((int16_t )rt3 >> sa) +1 ) >>1 ; + tempC = (((int16_t )rt1 >> sa) +1 ) >>1 ; + tempB = (((int16_t )rs3 >> sa) +1 ) >>1 ; + tempA = (((int16_t )rs1 >> sa) +1 ) >>1 ; + } + + result = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return result; +} + +target_ulong helper_precrq_ob_qh (target_ulong rs,target_ulong rt) +{ +uint8_t rs6, rs4, rs2, rs0; +uint8_t rt6, rt4, rt2, rt0; +uint64_t temp; + + rs6 = (rs >>56 ) &MIPSDSP_Q0 ; + rs4 = (rs >>40 ) &MIPSDSP_Q0 ; + rs2 = (rs >>24 ) &MIPSDSP_Q0 ; + rs0 = (rs >>8 ) &MIPSDSP_Q0 ; + rt6 = (rt >>56 ) &MIPSDSP_Q0 ; + rt4 = (rt >>40 ) &MIPSDSP_Q0 ; + rt2 = (rt >>24 ) &MIPSDSP_Q0 ; + rt0 = (rt >>8 ) &MIPSDSP_Q0 ; + + temp = ((uint64_t )rs6 <<56 ) | ((uint64_t )rs4 <<48 ) | + ((uint64_t )rs2 <<40 ) | ((uint64_t )rs0 <<32 ) | + ((uint64_t )rt6 <<24 ) | ((uint64_t )rt4 <<16 ) | + ((uint64_t )rt2 <<8 ) | (uint64_t )rt0; + +return temp; +} + +target_ulong helper_precrq_qh_pw (target_ulong rs,target_ulong rt) +{ +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + tempD = (rs >>48 ) &MIPSDSP_LO ; + tempC = (rs >>16 ) &MIPSDSP_LO ; + tempB = (rt >>48 ) &MIPSDSP_LO ; + tempA = (rt >>16 ) &MIPSDSP_LO ; + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_precrq_rs_qh_pw (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rs2, rs0; +uint32_t rt2, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs2 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt2 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempD =mipsdsp_trunc16_sat16_round (env, rs2); + tempC =mipsdsp_trunc16_sat16_round (env, rs0); + tempB =mipsdsp_trunc16_sat16_round (env, rt2); + tempA =mipsdsp_trunc16_sat16_round (env, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_precrq_pw_l (target_ulong rs,target_ulong rt) +{ +uint32_t tempB, tempA; +uint64_t temp; + + tempB = (rs >>32 ) &MIPSDSP_LLO ; + tempA = (rt >>32 ) &MIPSDSP_LLO ; + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_precrqu_s_qb_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t tempD, tempC, tempB, tempA; +uint16_t rsh, rsl, rth, rtl; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sat8_reduce_precision (env, rsh); + tempC =mipsdsp_sat8_reduce_precision (env, rsl); + tempB =mipsdsp_sat8_reduce_precision (env, rth); + tempA =mipsdsp_sat8_reduce_precision (env, rtl); + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_precrqu_s_ob_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int i; +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + temp[7 ] =mipsdsp_sat8_reduce_precision (env, rs3); + temp[6 ] =mipsdsp_sat8_reduce_precision (env, rs2); + temp[5 ] =mipsdsp_sat8_reduce_precision (env, rs1); + temp[4 ] =mipsdsp_sat8_reduce_precision (env, rs0); + temp[3 ] =mipsdsp_sat8_reduce_precision (env, rt3); + temp[2 ] =mipsdsp_sat8_reduce_precision (env, rt2); + temp[1 ] =mipsdsp_sat8_reduce_precision (env, rt1); + temp[0 ] =mipsdsp_sat8_reduce_precision (env, rt0); + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} +#endif + +target_ulong helper_preceq_w_phl (target_ulong rt) +{ +uint32_t rd; + + rd = rt &MIPSDSP_HI ; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_preceq_w_phr (target_ulong rt) +{ +uint16_t rtl; +uint32_t rd; + + rtl = rt &MIPSDSP_LO ; + rd = rtl <<16 ; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_preceq_pw_qhl (target_ulong rt) +{ +uint16_t tempB, tempA; +uint32_t tempBI, tempAI; +uint64_t temp; + + tempB = (rt >>48 ) &MIPSDSP_LO ; + tempA = (rt >>32 ) &MIPSDSP_LO ; + + tempBI = (uint32_t )tempB <<16 ; + tempAI = (uint32_t )tempA <<16 ; + + temp = ((uint64_t )tempBI <<32 ) | ((uint64_t )tempAI); + +return temp; +} + +target_ulong helper_preceq_pw_qhr (target_ulong rt) +{ +uint16_t tempB, tempA; +uint32_t tempBI, tempAI; +uint64_t temp; + + tempB = (rt >>16 ) &MIPSDSP_LO ; + tempA = rt &MIPSDSP_LO ; + + tempBI = (uint32_t )tempB <<16 ; + tempAI = (uint32_t )tempA <<16 ; + + temp = ((uint64_t )tempBI <<32 ) | ((uint64_t )tempAI); + +return temp; +} + +target_ulong helper_preceq_pw_qhla (target_ulong rt) +{ +uint16_t tempB, tempA; +uint32_t tempBI, tempAI; +uint64_t temp; + + tempB = (rt >>48 ) &MIPSDSP_LO ; + tempA = (rt >>16 ) &MIPSDSP_LO ; + + tempBI = (uint32_t )tempB <<16 ; + tempAI = (uint32_t )tempA <<16 ; + + temp = ((uint64_t )tempBI <<32 ) | ((uint64_t )tempAI); + +return temp; +} + +target_ulong helper_preceq_pw_qhra (target_ulong rt) +{ +uint16_t tempB, tempA; +uint32_t tempBI, tempAI; +uint64_t temp; + + tempB = (rt >>32 ) &MIPSDSP_LO ; + tempA = rt &MIPSDSP_LO ; + + tempBI = (uint32_t )tempB <<16 ; + tempAI = (uint32_t )tempA <<16 ; + + temp = ((uint64_t )tempBI <<32 ) | ((uint64_t )tempAI); + +return temp; +} + +target_ulong helper_preceq_l_pwl (target_ulong rt) +{ +uint64_t temp; + temp = rt &MIPSDSP_LHI ; +return temp; +} + +target_ulong helper_preceq_l_pwr (target_ulong rt) +{ +uint64_t temp; + temp = rt <<32 ; +return temp; +} +#endif + +target_ulong helper_precequ_ph_qbl (target_ulong rt) +{ +uint8_t rt3, rt2; +uint16_t tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + + tempB = (uint16_t )rt3 <<7 ; + tempA = (uint16_t )rt2 <<7 ; + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_precequ_ph_qbr (target_ulong rt) +{ +uint8_t rt1, rt0; +uint16_t tempB, tempA; +uint32_t rd; + + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + tempB = (uint16_t )rt1 <<7 ; + tempA = (uint16_t )rt0 <<7 ; + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_precequ_ph_qbla (target_ulong rt) +{ +uint8_t rt3, rt1; +uint16_t tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + + tempB = (uint16_t )rt3 <<7 ; + tempA = (uint16_t )rt1 <<7 ; + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_precequ_ph_qbra (target_ulong rt) +{ +uint8_t rt2, rt0; +uint16_t tempB, tempA; +uint32_t rd; + + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt0 = rt &MIPSDSP_Q0 ; + tempB = (uint16_t )rt2 <<7 ; + tempA = (uint16_t )rt0 <<7 ; + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_precequ_qh_obl (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>56 ) &MIPSDSP_Q0 ; + tempCC = (rt >>48 ) &MIPSDSP_Q0 ; + tempBC = (rt >>40 ) &MIPSDSP_Q0 ; + tempAC = (rt >>32 ) &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC <<7 ; + tempCS = (uint16_t )tempCC <<7 ; + tempBS = (uint16_t )tempBC <<7 ; + tempAS = (uint16_t )tempAC <<7 ; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} + +target_ulong helper_precequ_qh_obr (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>24 ) &MIPSDSP_Q0 ; + tempCC = (rt >>16 ) &MIPSDSP_Q0 ; + tempBC = (rt >>8 ) &MIPSDSP_Q0 ; + tempAC = rt &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC <<7 ; + tempCS = (uint16_t )tempCC <<7 ; + tempBS = (uint16_t )tempBC <<7 ; + tempAS = (uint16_t )tempAC <<7 ; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} + +target_ulong helper_precequ_qh_obla (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>56 ) &MIPSDSP_Q0 ; + tempCC = (rt >>40 ) &MIPSDSP_Q0 ; + tempBC = (rt >>24 ) &MIPSDSP_Q0 ; + tempAC = (rt >>8 ) &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC <<7 ; + tempCS = (uint16_t )tempCC <<7 ; + tempBS = (uint16_t )tempBC <<7 ; + tempAS = (uint16_t )tempAC <<7 ; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} + +target_ulong helper_precequ_qh_obra (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>48 ) &MIPSDSP_Q0 ; + tempCC = (rt >>32 ) &MIPSDSP_Q0 ; + tempBC = (rt >>16 ) &MIPSDSP_Q0 ; + tempAC = rt &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC <<7 ; + tempCS = (uint16_t )tempCC <<7 ; + tempBS = (uint16_t )tempBC <<7 ; + tempAS = (uint16_t )tempAC <<7 ; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} +#endif + +target_ulong helper_preceu_ph_qbl (target_ulong rt) +{ +uint8_t rt3, rt2; +uint16_t tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + tempB = (uint16_t ) rt3; + tempA = (uint16_t ) rt2; + rd = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_preceu_ph_qbr (target_ulong rt) +{ +uint8_t rt1, rt0; +uint16_t tempB, tempA; +uint32_t rd; + + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + tempB = (uint16_t ) rt1; + tempA = (uint16_t ) rt0; + rd = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); +return (target_long )(int32_t )rd; +} + +target_ulong helper_preceu_ph_qbla (target_ulong rt) +{ +uint8_t rt3, rt1; +uint16_t tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + tempB = (uint16_t ) rt3; + tempA = (uint16_t ) rt1; + rd = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_preceu_ph_qbra (target_ulong rt) +{ +uint8_t rt2, rt0; +uint16_t tempB, tempA; +uint32_t rd; + + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt0 = rt &MIPSDSP_Q0 ; + tempB = (uint16_t )rt2; + tempA = (uint16_t )rt0; + rd = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_preceu_qh_obl (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>56 ) &MIPSDSP_Q0 ; + tempCC = (rt >>48 ) &MIPSDSP_Q0 ; + tempBC = (rt >>40 ) &MIPSDSP_Q0 ; + tempAC = (rt >>32 ) &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC; + tempCS = (uint16_t )tempCC; + tempBS = (uint16_t )tempBC; + tempAS = (uint16_t )tempAC; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} + +target_ulong helper_preceu_qh_obr (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>24 ) &MIPSDSP_Q0 ; + tempCC = (rt >>16 ) &MIPSDSP_Q0 ; + tempBC = (rt >>8 ) &MIPSDSP_Q0 ; + tempAC = rt &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC; + tempCS = (uint16_t )tempCC; + tempBS = (uint16_t )tempBC; + tempAS = (uint16_t )tempAC; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} + +target_ulong helper_preceu_qh_obla (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>56 ) &MIPSDSP_Q0 ; + tempCC = (rt >>40 ) &MIPSDSP_Q0 ; + tempBC = (rt >>24 ) &MIPSDSP_Q0 ; + tempAC = (rt >>8 ) &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC; + tempCS = (uint16_t )tempCC; + tempBS = (uint16_t )tempBC; + tempAS = (uint16_t )tempAC; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} + +target_ulong helper_preceu_qh_obra (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>48 ) &MIPSDSP_Q0 ; + tempCC = (rt >>32 ) &MIPSDSP_Q0 ; + tempBC = (rt >>16 ) &MIPSDSP_Q0 ; + tempAC = rt &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC; + tempCS = (uint16_t )tempCC; + tempBS = (uint16_t )tempBC; + tempAS = (uint16_t )tempAC; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} +#endif + +#undef MIPSDSP_LHI +#undef MIPSDSP_LLO +#undef MIPSDSP_HI +#undef MIPSDSP_LO +#undef MIPSDSP_Q3 +#undef MIPSDSP_Q2 +#undef MIPSDSP_Q1 +#undef MIPSDSP_Q0
target-mips/helper.h +132 -0
136 lines not on this page · raw message
target-mips/translate.c +666 -3
700 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v7 06/14] target-mips-ase-dsp: Add arithmetic instructions
Quoted 34 lines · Jia Liu
Add MIPS ASE DSP Arithmetic instructions.
Signed-off-by Jia Liu <[email protected]>--- target-mips/dsp_helper.c | 1929 ++++++++++++++++++++++++++++++++++++++++++++++ target-mips/helper.h | 132 ++++ target-mips/translate.c | 669 +++++++++++++++- 3 files changed, 2727 insertions(+), 3 deletions(-)target-mips/dsp_helper.c +17
-0@@ -1275,3 +1275,1932 @@ static inline int32_t mipsdsp_add_i32(CPUMIPSState *env, int32_t a, int32_t b)return result; }/*** MIPS DSP internal functions end ***/ + +#define MIPSDSP_LHI 0xFFFFFFFF00000000ull +#define MIPSDSP_LLO 0x00000000FFFFFFFFull +#define MIPSDSP_HI 0xFFFF0000 +#define MIPSDSP_LO 0x0000FFFF +#define MIPSDSP_Q3 0xFF000000 +#define MIPSDSP_Q2 0x00FF0000 +#define MIPSDSP_Q1 0x0000FF00 +#define MIPSDSP_Q0 0x000000FF + +/** DSP Arithmetic Sub-class insns **/ +target_ulong helper_addq_ph (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl, temph, templ; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ;
target-mips/dsp_helper.c static inline int32_t mipsdsp_add_i32(CPUMIPSState *env, int32_t a, int32_t b) · line 1304
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+ rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + temph =mipsdsp_add_i16 (env, rsh, rth); + templ =mipsdsp_add_i16 (env, rsl, rtl); + rd = ((unsigned int )temph <<16 ) | ((unsigned int )templ &0xFFFF ); + +return (target_long )(int32_t )rd; +}
I think you can directly define rd as int32_t and remove the cast later.
Quoted 6 lines
target-mips/dsp_helper.c +6
-0+target_ulong helper_addq_s_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl, temph, templ; +uint32_t rd; +
target-mips/dsp_helper.c static inline int32_t mipsdsp_add_i32(CPUMIPSState *env, int32_t a, int32_t b) · line 1321
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+ rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + temph =mipsdsp_sat_add_i16 (env, rsh, rth); + templ =mipsdsp_sat_add_i16 (env, rsl, rtl); + rd = ((uint32_t )temph <<16 ) | ((uint32_t )templ &0xFFFF ); + +return (target_long )(int32_t )rd;
Ditto
Quoted 18 lines
target-mips/dsp_helper.c +18
-0+} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_addq_qh (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ;
target-mips/dsp_helper.c static inline int32_t mipsdsp_add_i32(CPUMIPSState *env, int32_t a, int32_t b) · line 1349
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+ + tempD =mipsdsp_add_i16 (env, rs3, rt3); + tempC =mipsdsp_add_i16 (env, rs2, rt2); + tempB =mipsdsp_add_i16 (env, rs1, rt1); + tempA =mipsdsp_add_i16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp;
You can get rid of temp by directly returning the variable.
Quoted 19 lines
target-mips/dsp_helper.c +19
-0+} + +target_ulong helper_addq_s_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; +
target-mips/dsp_helper.c static inline int32_t mipsdsp_add_i32(CPUMIPSState *env, int32_t a, int32_t b) · line 1378
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+ tempD =mipsdsp_sat_add_i16 (env, rs3, rt3); + tempC =mipsdsp_sat_add_i16 (env, rs2, rt2); + tempB =mipsdsp_sat_add_i16 (env, rs1, rt1); + tempA =mipsdsp_sat_add_i16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +}
Ditto
Quoted 20 lines
target-mips/dsp_helper.c +20
-0+#endif + +target_ulong helper_addq_s_w (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rd; + rd =mipsdsp_sat_add_i32 (env, rs, rt); +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_addq_pw (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint32_t rs1, rs0; +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ;
target-mips/dsp_helper.c static inline int32_t mipsdsp_add_i32(CPUMIPSState *env, int32_t a, int32_t b) · line 1408
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+ rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_add_i32 (env, rs1, rt1); + tempA =mipsdsp_add_i32 (env, rs0, rt0); + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +}
Ditto. And so on below.
Quoted 1,104 lines
target-mips/dsp_helper.c +1104
-0+ +target_ulong helper_addq_s_pw (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rs1, rs0; +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_sat_add_i32 (env, rs1, rt1); + tempA =mipsdsp_sat_add_i32 (env, rs0, rt0); + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_addu_qb (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint32_t rd; +uint8_t rs0, rs1, rs2, rs3; +uint8_t rt0, rt1, rt2, rt3; +uint8_t temp0, temp1, temp2, temp3; + + rs0 = rs &MIPSDSP_Q0 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + + rt0 = rt &MIPSDSP_Q0 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + + temp0 =mipsdsp_add_u8 (env, rs0, rt0); + temp1 =mipsdsp_add_u8 (env, rs1, rt1); + temp2 =mipsdsp_add_u8 (env, rs2, rt2); + temp3 =mipsdsp_add_u8 (env, rs3, rt3); + + rd = (((uint32_t )temp3 <<24 ) &MIPSDSP_Q3 ) | + (((uint32_t )temp2 <<16 ) &MIPSDSP_Q2 ) | + (((uint32_t )temp1 <<8 ) &MIPSDSP_Q1 ) | + ((uint32_t )temp0 &MIPSDSP_Q0 ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addu_s_qb (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rd; +uint8_t rs0, rs1, rs2, rs3; +uint8_t rt0, rt1, rt2, rt3; +uint8_t temp0, temp1, temp2, temp3; + + rs0 = rs &MIPSDSP_Q0 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + + rt0 = rt &MIPSDSP_Q0 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + + temp0 =mipsdsp_sat_add_u8 (env, rs0, rt0); + temp1 =mipsdsp_sat_add_u8 (env, rs1, rt1); + temp2 =mipsdsp_sat_add_u8 (env, rs2, rt2); + temp3 =mipsdsp_sat_add_u8 (env, rs3, rt3); + + rd = (((uint8_t )temp3 <<24 ) &MIPSDSP_Q3 ) | + (((uint8_t )temp2 <<16 ) &MIPSDSP_Q2 ) | + (((uint8_t )temp1 <<8 ) &MIPSDSP_Q1 ) | + ((uint8_t )temp0 &MIPSDSP_Q0 ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_adduh_qb (target_ulong rs,target_ulong rt) +{ +uint32_t rd; +uint8_t rs0, rs1, rs2, rs3; +uint8_t rt0, rt1, rt2, rt3; +uint8_t temp0, temp1, temp2, temp3; + + rs0 = rs &MIPSDSP_Q0 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + + rt0 = rt &MIPSDSP_Q0 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + + temp0 =mipsdsp_rshift1_add_u8 (rs0, rt0); + temp1 =mipsdsp_rshift1_add_u8 (rs1, rt1); + temp2 =mipsdsp_rshift1_add_u8 (rs2, rt2); + temp3 =mipsdsp_rshift1_add_u8 (rs3, rt3); + + rd = (((uint32_t )temp3 <<24 ) &MIPSDSP_Q3 ) | + (((uint32_t )temp2 <<16 ) &MIPSDSP_Q2 ) | + (((uint32_t )temp1 <<8 ) &MIPSDSP_Q1 ) | + ((uint32_t )temp0 &MIPSDSP_Q0 ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_adduh_r_qb (target_ulong rs,target_ulong rt) +{ +uint32_t rd; +uint8_t rs0, rs1, rs2, rs3; +uint8_t rt0, rt1, rt2, rt3; +uint8_t temp0, temp1, temp2, temp3; + + rs0 = rs &MIPSDSP_Q0 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + + rt0 = rt &MIPSDSP_Q0 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + + temp0 =mipsdsp_rrshift1_add_u8 (rs0, rt0); + temp1 =mipsdsp_rrshift1_add_u8 (rs1, rt1); + temp2 =mipsdsp_rrshift1_add_u8 (rs2, rt2); + temp3 =mipsdsp_rrshift1_add_u8 (rs3, rt3); + + rd = (((uint32_t )temp3 <<24 ) &MIPSDSP_Q3 ) | + (((uint32_t )temp2 <<16 ) &MIPSDSP_Q2 ) | + (((uint32_t )temp1 <<8 ) &MIPSDSP_Q1 ) | + ((uint32_t )temp0 &MIPSDSP_Q0 ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addu_ph (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl, temph, templ; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + temph =mipsdsp_add_u16 (env, rsh, rth); + templ =mipsdsp_add_u16 (env, rsl, rtl); + rd = ((uint32_t )temph <<16 ) | ((uint32_t )templ &MIPSDSP_LO ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addu_s_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl, temph, templ; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + temph =mipsdsp_sat_add_u16 (env, rsh, rth); + templ =mipsdsp_sat_add_u16 (env, rsl, rtl); + rd = ((uint32_t )temph <<16 ) | ((uint32_t )templ &MIPSDSP_LO ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addqh_ph (target_ulong rs,target_ulong rt) +{ +uint32_t rd; +int16_t rsh, rsl, rth, rtl, temph, templ; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + temph =mipsdsp_rshift1_add_q16 (rsh, rth); + templ =mipsdsp_rshift1_add_q16 (rsl, rtl); + rd = ((uint32_t )temph <<16 ) | ((uint32_t )templ &MIPSDSP_LO ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addqh_r_ph (target_ulong rs,target_ulong rt) +{ +uint32_t rd; +int16_t rsh, rsl, rth, rtl, temph, templ; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + temph =mipsdsp_rrshift1_add_q16 (rsh, rth); + templ =mipsdsp_rrshift1_add_q16 (rsl, rtl); + rd = ((uint32_t )temph <<16 ) | ((uint32_t )templ &MIPSDSP_LO ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addqh_w (target_ulong rs,target_ulong rt) +{ +uint32_t rd; + + rd =mipsdsp_rshift1_add_q32 (rs, rt); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addqh_r_w (target_ulong rs,target_ulong rt) +{ +uint32_t rd; + + rd =mipsdsp_rrshift1_add_q32 (rs, rt); + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_addu_ob (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_add_u8 (env, rs_t[i], rt_t[i]); + } + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_addu_s_ob (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_sat_add_u8 (env, rs_t[i], rt_t[i]); + } + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_adduh_ob (target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_rshift1_add_u8 (rs_t[i], rt_t[i]); + } + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_adduh_r_ob (target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_rrshift1_add_u8 (rs_t[i], rt_t[i]); + } + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_addu_qh (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_add_u16 (env, rs3, rt3); + tempC =mipsdsp_add_u16 (env, rs2, rt2); + tempB =mipsdsp_add_u16 (env, rs1, rt1); + tempA =mipsdsp_add_u16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_addu_s_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sat_add_u16 (env, rs3, rt3); + tempC =mipsdsp_sat_add_u16 (env, rs2, rt2); + tempB =mipsdsp_sat_add_u16 (env, rs1, rt1); + tempA =mipsdsp_sat_add_u16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_subq_ph (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl; +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_sub_i16 (env, rsh, rth); + tempA =mipsdsp_sub_i16 (env, rsl, rtl); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_subq_s_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl; +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_sat16_sub (env, rsh, rth); + tempA =mipsdsp_sat16_sub (env, rsl, rtl); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_subq_qh (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sub_i16 (env, rs3, rt3); + tempC =mipsdsp_sub_i16 (env, rs2, rt2); + tempB =mipsdsp_sub_i16 (env, rs1, rt1); + tempA =mipsdsp_sub_i16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; +return temp; +} + +target_ulong helper_subq_s_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sat16_sub (env, rs3, rt3); + tempC =mipsdsp_sat16_sub (env, rs2, rt2); + tempB =mipsdsp_sat16_sub (env, rs1, rt1); + tempA =mipsdsp_sat16_sub (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; +return temp; +} +#endif + +target_ulong helper_subq_s_w (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rd; + + rd =mipsdsp_sat32_sub (env, rs, rt); + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_subq_pw (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint32_t rs1, rs0; +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_sub32 (env, rs1, rt1); + tempA =mipsdsp_sub32 (env, rs0, rt0); + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; +return temp; +} + +target_ulong helper_subq_s_pw (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rs1, rs0; +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_sat32_sub (env, rs1, rt1); + tempA =mipsdsp_sat32_sub (env, rs0, rt0); + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; +return temp; +} +#endif + +target_ulong helper_subu_qb (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2, rs1, rs0; +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs0 = rs &MIPSDSP_Q0 ; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_sub_u8 (env, rs3, rt3); + tempC =mipsdsp_sub_u8 (env, rs2, rt2); + tempB =mipsdsp_sub_u8 (env, rs1, rt1); + tempA =mipsdsp_sub_u8 (env, rs0, rt0); + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; +return (target_long )(int32_t )rd; +} + +target_ulong helper_subu_s_qb (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2, rs1, rs0; +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs0 = rs &MIPSDSP_Q0 ; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_satu8_sub (env, rs3, rt3); + tempC =mipsdsp_satu8_sub (env, rs2, rt2); + tempB =mipsdsp_satu8_sub (env, rs1, rt1); + tempA =mipsdsp_satu8_sub (env, rs0, rt0); + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_subuh_qb (target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2, rs1, rs0; +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs0 = rs &MIPSDSP_Q0 ; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD = ((uint16_t )rs3 - (uint16_t )rt3) >>1 ; + tempC = ((uint16_t )rs2 - (uint16_t )rt2) >>1 ; + tempB = ((uint16_t )rs1 - (uint16_t )rt1) >>1 ; + tempA = ((uint16_t )rs0 - (uint16_t )rt0) >>1 ; + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_ulong )rd; +} + +target_ulong helper_subuh_r_qb (target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2, rs1, rs0; +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs0 = rs &MIPSDSP_Q0 ; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD = ((uint16_t )rs3 - (uint16_t )rt3 +1 ) >>1 ; + tempC = ((uint16_t )rs2 - (uint16_t )rt2 +1 ) >>1 ; + tempB = ((uint16_t )rs1 - (uint16_t )rt1 +1 ) >>1 ; + tempA = ((uint16_t )rs0 - (uint16_t )rt0 +1 ) >>1 ; + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_ulong )rd; +} + +target_ulong helper_subu_ph (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_sub_u16_u16 (env, rth, rsh); + tempA =mipsdsp_sub_u16_u16 (env, rtl, rsl); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; +return (target_long )(int32_t )rd; +} + +target_ulong helper_subu_s_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_satu16_sub_u16_u16 (env, rth, rsh); + tempA =mipsdsp_satu16_sub_u16_u16 (env, rtl, rsl); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_subqh_ph (target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl; +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_rshift1_sub_q16 (rsh, rth); + tempA =mipsdsp_rshift1_sub_q16 (rsl, rtl); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_subqh_r_ph (target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl; +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_rrshift1_sub_q16 (rsh, rth); + tempA =mipsdsp_rrshift1_sub_q16 (rsl, rtl); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_subqh_w (target_ulong rs,target_ulong rt) +{ +uint32_t rd; + + rd =mipsdsp_rshift1_sub_q32 (rs, rt); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_subqh_r_w (target_ulong rs,target_ulong rt) +{ +uint32_t rd; + + rd =mipsdsp_rrshift1_sub_q32 (rs, rt); + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_subu_ob (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_sub_u8 (env, rs_t[i], rt_t[i]); + } + +for (i =0 ; i <8 ; i++) { + result += (uint64_t )temp[i] << (i *8 ); + } + +return result; +} + +target_ulong helper_subu_s_ob (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_satu8_sub (env, rs_t[i], rt_t[i]); + } + +for (i =0 ; i <8 ; i++) { + result += (uint64_t )temp[i] << (i *8 ); + } + +return result; +} + +target_ulong helper_subuh_ob (target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] = ((uint16_t )rs_t[i] - (uint16_t )rt_t[i]) >>1 ; + } + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_subuh_r_ob (target_ulong rs,target_ulong rt) +{ +int i; +uint8_t rs_t[8 ], rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] = ((uint16_t )rs_t[i] - (uint16_t )rt_t[i] +1 ) >>1 ; + } + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_subu_qh (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sub_u16_u16 (env, rs3, rt3); + tempC =mipsdsp_sub_u16_u16 (env, rs2, rt2); + tempB =mipsdsp_sub_u16_u16 (env, rs1, rt1); + tempA =mipsdsp_sub_u16_u16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; +return temp; +} + + +target_ulong helper_subu_s_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_satu16_sub_u16_u16 (env, rs3, rt3); + tempC =mipsdsp_satu16_sub_u16_u16 (env, rs2, rt2); + tempB =mipsdsp_satu16_sub_u16_u16 (env, rs1, rt1); + tempA =mipsdsp_satu16_sub_u16_u16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; +return temp; +} +#endif + +target_ulong helper_addsc (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint32_t rd; +uint64_t temp, tempRs, tempRt; +int32_t flag; + + tempRs = (uint64_t )rs &MIPSDSP_LLO ; + tempRt = (uint64_t )rt &MIPSDSP_LLO ; + + temp = tempRs + tempRt; + flag = (temp &0x0100000000ull ) >>32 ; +set_DSPControl_carryflag (env, flag); + rd = temp &MIPSDSP_LLO ; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_addwc (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint32_t rd; +int32_t temp32, temp31; +int64_t rsL, rtL, tempL; + + rsL = (int32_t )rs; + rtL = (int32_t )rt; + tempL = rsL + rtL +get_DSPControl_carryflag (env); + temp31 = (tempL >>31 ) &0x01 ; + temp32 = (tempL >>32 ) &0x01 ; + +if (temp31 != temp32) { +set_DSPControl_overflow_flag (env,1 ,20 ); + } + + rd = tempL &MIPSDSP_LLO ; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_modsub (target_ulong rs,target_ulong rt) +{ +int32_t decr; +uint16_t lastindex; +target_ulong rd; + + decr = rt &MIPSDSP_Q0 ; + lastindex = (rt >>8 ) &MIPSDSP_LO ; + +if ((rs &MIPSDSP_LLO ) ==0x00000000 ) { + rd = (target_ulong )lastindex; + }else { + rd = rs - decr; + } + +return rd; +} + +target_ulong helper_raddu_w_qb (target_ulong rs) +{ +uint8_t rs3, rs2, rs1, rs0; +uint16_t temp; +uint32_t rd; + + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs0 = rs &MIPSDSP_Q0 ; + + temp = (uint16_t )rs3 + (uint16_t )rs2 + (uint16_t )rs1 + (uint16_t )rs0; + rd = temp; + +return (target_ulong )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_raddu_l_ob (target_ulong rs) +{ +int i; +uint16_t rs_t[8 ]; +uint64_t temp; + + temp =0 ; + +for (i =0 ; i <8 ; i++) { + rs_t[i] = (rs >> (8 * i)) &MIPSDSP_Q0 ; + temp += (uint64_t )rs_t[i]; + } + +return temp; +} +#endif + +target_ulong helper_absq_s_qb (CPUMIPSState *env,target_ulong rt) +{ +uint32_t rd; +int8_t tempD, tempC, tempB, tempA; + + tempD = (rt &MIPSDSP_Q3 ) >>24 ; + tempC = (rt &MIPSDSP_Q2 ) >>16 ; + tempB = (rt &MIPSDSP_Q1 ) >>8 ; + tempA = rt &MIPSDSP_Q0 ; + + rd = (((uint32_t )mipsdsp_sat_abs_u8 (env, tempD) <<24 ) &MIPSDSP_Q3 ) | + (((uint32_t )mipsdsp_sat_abs_u8 (env, tempC) <<16 ) &MIPSDSP_Q2 ) | + (((uint32_t )mipsdsp_sat_abs_u8 (env, tempB) <<8 ) &MIPSDSP_Q1 ) | + ((uint32_t )mipsdsp_sat_abs_u8 (env, tempA) &MIPSDSP_Q0 ); + +return (target_ulong )rd; +} + +target_ulong helper_absq_s_ph (CPUMIPSState *env,target_ulong rt) +{ +uint32_t rd; +int16_t tempA, tempB; + + tempA = (rt &MIPSDSP_HI ) >>16 ; + tempB = rt &MIPSDSP_LO ; + + rd = ((uint32_t )mipsdsp_sat_abs_u16 (env, tempA) <<16 ) | + ((uint32_t )(mipsdsp_sat_abs_u16 (env, tempB)) &0xFFFF ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_absq_s_w (CPUMIPSState *env,target_ulong rt) +{ +uint32_t rd; +int32_t temp; + + temp = rt; + rd =mipsdsp_sat_abs_u32 (env, temp); + +return (target_ulong )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_absq_s_ob (CPUMIPSState *env,target_ulong rt) +{ +uint8_t tempH, tempG, tempF, tempE; +uint8_t tempD, tempC, tempB, tempA; +uint64_t temp; + + tempH = (rt >>56 ) &MIPSDSP_Q0 ; + tempG = (rt >>48 ) &MIPSDSP_Q0 ; + tempF = (rt >>40 ) &MIPSDSP_Q0 ; + tempE = (rt >>32 ) &MIPSDSP_Q0 ; + tempD = (rt >>24 ) &MIPSDSP_Q0 ; + tempC = (rt >>16 ) &MIPSDSP_Q0 ; + tempB = (rt >>8 ) &MIPSDSP_Q0 ; + tempA = rt &MIPSDSP_Q0 ; + + tempH =mipsdsp_sat_abs_u8 (env, tempH); + tempG =mipsdsp_sat_abs_u8 (env, tempG); + tempF =mipsdsp_sat_abs_u8 (env, tempF); + tempE =mipsdsp_sat_abs_u8 (env, tempE); + tempD =mipsdsp_sat_abs_u8 (env, tempD); + tempC =mipsdsp_sat_abs_u8 (env, tempC); + tempB =mipsdsp_sat_abs_u8 (env, tempB); + tempA =mipsdsp_sat_abs_u8 (env, tempA); + + temp = ((uint64_t )tempH <<56 ) | ((uint64_t )tempG <<48 ) | + ((uint64_t )tempF <<40 ) | ((uint64_t )tempE <<32 ) | + ((uint64_t )tempD <<24 ) | ((uint64_t )tempC <<16 ) | + ((uint64_t )tempB <<8 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_absq_s_qh (CPUMIPSState *env,target_ulong rt) +{ +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + tempD = (rt >>48 ) &MIPSDSP_LO ; + tempC = (rt >>32 ) &MIPSDSP_LO ; + tempB = (rt >>16 ) &MIPSDSP_LO ; + tempA = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sat_abs_u16 (env, tempD); + tempC =mipsdsp_sat_abs_u16 (env, tempC); + tempB =mipsdsp_sat_abs_u16 (env, tempB); + tempA =mipsdsp_sat_abs_u16 (env, tempA); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_absq_s_pw (CPUMIPSState *env,target_ulong rt) +{ +uint32_t tempB, tempA; +uint64_t temp; + + tempB = (rt >>32 ) &MIPSDSP_LLO ; + tempA = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_sat_abs_u32 (env, tempB); + tempA =mipsdsp_sat_abs_u32 (env, tempA); + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_precr_qb_ph (target_ulong rs,target_ulong rt) +{ +uint8_t rs2, rs0, rt2, rt0; +uint32_t rd; + + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rs0 = rs &MIPSDSP_Q0 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt0 = rt &MIPSDSP_Q0 ; + rd = ((uint32_t )rs2 <<24 ) | ((uint32_t )rs0 <<16 ) | + ((uint32_t )rt2 <<8 ) | (uint32_t )rt0; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_precrq_qb_ph (target_ulong rs,target_ulong rt) +{ +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + tempD = (rs &MIPSDSP_Q3 ) >>24 ; + tempC = (rs &MIPSDSP_Q1 ) >>8 ; + tempB = (rt &MIPSDSP_Q3 ) >>24 ; + tempA = (rt &MIPSDSP_Q1 ) >>8 ; + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_precr_sra_ph_w (uint32_t sa,target_ulong rs, +target_ulong rt)
target-mips/dsp_helper.c static inline int32_t mipsdsp_add_i32(CPUMIPSState *env, int32_t a, int32_t b) · line 2522
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+{ +uint16_t tempB, tempA; + +if (sa ==0 ) { + tempB = rt &MIPSDSP_LO ; + tempA = rs &MIPSDSP_LO ; + }else { + tempB = ((int32_t )rt >> sa) &MIPSDSP_LO ; + tempA = ((int32_t )rs >> sa) &MIPSDSP_LO ; + }
You don't need to test for sa = 0, a shift with value 0 is perfectly defined.
Quoted 7 lines
target-mips/dsp_helper.c +7
-0+ rt = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); + +return (target_long )(int32_t )rt; +} + +target_ulong helper_precr_sra_r_ph_w (uint32_t sa, +target_ulong rs,target_ulong rt)
target-mips/dsp_helper.c static inline int32_t mipsdsp_add_i32(CPUMIPSState *env, int32_t a, int32_t b) · line 2539
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+{ +uint64_t tempB, tempA; + +if (sa ==0 ) { + tempB = (rt &MIPSDSP_LO ) <<1 ; + tempA = (rs &MIPSDSP_LO ) <<1 ; + }else { + tempB = ((int32_t )rt >> (sa -1 )) +1 ; + tempA = ((int32_t )rs >> (sa -1 )) +1 ; + }
Same here.
Quoted 72 lines
target-mips/dsp_helper.c +72
-0+ rt = (((tempB >>1 ) &MIPSDSP_LO ) <<16 ) | ((tempA >>1 ) &MIPSDSP_LO ); + +return (target_long )(int32_t )rt; +} + +target_ulong helper_precrq_ph_w (target_ulong rs,target_ulong rt) +{ +uint16_t tempB, tempA; +uint32_t rd; + + tempB = (rs &MIPSDSP_HI ) >>16 ; + tempA = (rt &MIPSDSP_HI ) >>16 ; + rd = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_precrq_rs_ph_w (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t tempB, tempA; +uint32_t rd; + + tempB =mipsdsp_trunc16_sat16_round (env, rs); + tempA =mipsdsp_trunc16_sat16_round (env, rt); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_precr_ob_qh (target_ulong rs,target_ulong rt) +{ +uint8_t rs6, rs4, rs2, rs0; +uint8_t rt6, rt4, rt2, rt0; +uint64_t temp; + + rs6 = (rs >>48 ) &MIPSDSP_Q0 ; + rs4 = (rs >>32 ) &MIPSDSP_Q0 ; + rs2 = (rs >>16 ) &MIPSDSP_Q0 ; + rs0 = rs &MIPSDSP_Q0 ; + rt6 = (rt >>48 ) &MIPSDSP_Q0 ; + rt4 = (rt >>32 ) &MIPSDSP_Q0 ; + rt2 = (rt >>16 ) &MIPSDSP_Q0 ; + rt0 = rt &MIPSDSP_Q0 ; + + temp = ((uint64_t )rs6 <<56 ) | ((uint64_t )rs4 <<48 ) | + ((uint64_t )rs2 <<40 ) | ((uint64_t )rs0 <<32 ) | + ((uint64_t )rt6 <<24 ) | ((uint64_t )rt4 <<16 ) | + ((uint64_t )rt2 <<8 ) | (uint64_t )rt0; + +return temp; +} + +target_ulong helper_precr_sra_qh_pw (target_ulong rs,target_ulong rt, +uint32_t sa) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t result; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + +if (sa ==0 ) {
target-mips/dsp_helper.c static inline int32_t mipsdsp_add_i32(CPUMIPSState *env, int32_t a, int32_t b) · line 2621
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+ tempD = rt2; + tempC = rt0; + tempB = rs2; + tempA = rs0; + }else { + tempD = (int16_t )rt3 >> sa; + tempC = (int16_t )rt1 >> sa; + tempB = (int16_t )rs3 >> sa; + tempA = (int16_t )rs1 >> sa; + }
And there.
Quoted 27 lines
target-mips/dsp_helper.c +27
-0+ + result = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return result; +} + + +target_ulong helper_precr_sra_r_qh_pw (target_ulong rs,target_ulong rt, +uint32_t sa) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t result; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + +if (sa ==0 ) { + tempD = rt2 <<1 ;
target-mips/dsp_helper.c static inline int32_t mipsdsp_add_i32(CPUMIPSState *env, int32_t a, int32_t b) · line 2658
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+ tempC = rt0 <<1 ; + tempB = rs2 <<1 ; + tempA = rs0 <<1 ; + }else { + tempD = (((int16_t )rt3 >> sa) +1 ) >>1 ; + tempC = (((int16_t )rt1 >> sa) +1 ) >>1 ; + tempB = (((int16_t )rs3 >> sa) +1 ) >>1 ; + tempA = (((int16_t )rs1 >> sa) +1 ) >>1 ; + } +
And there
Quoted 866 lines
target-mips/dsp_helper.c +548
-0+ result = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return result; +} + +target_ulong helper_precrq_ob_qh (target_ulong rs,target_ulong rt) +{ +uint8_t rs6, rs4, rs2, rs0; +uint8_t rt6, rt4, rt2, rt0; +uint64_t temp; + + rs6 = (rs >>56 ) &MIPSDSP_Q0 ; + rs4 = (rs >>40 ) &MIPSDSP_Q0 ; + rs2 = (rs >>24 ) &MIPSDSP_Q0 ; + rs0 = (rs >>8 ) &MIPSDSP_Q0 ; + rt6 = (rt >>56 ) &MIPSDSP_Q0 ; + rt4 = (rt >>40 ) &MIPSDSP_Q0 ; + rt2 = (rt >>24 ) &MIPSDSP_Q0 ; + rt0 = (rt >>8 ) &MIPSDSP_Q0 ; + + temp = ((uint64_t )rs6 <<56 ) | ((uint64_t )rs4 <<48 ) | + ((uint64_t )rs2 <<40 ) | ((uint64_t )rs0 <<32 ) | + ((uint64_t )rt6 <<24 ) | ((uint64_t )rt4 <<16 ) | + ((uint64_t )rt2 <<8 ) | (uint64_t )rt0; + +return temp; +} + +target_ulong helper_precrq_qh_pw (target_ulong rs,target_ulong rt) +{ +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + tempD = (rs >>48 ) &MIPSDSP_LO ; + tempC = (rs >>16 ) &MIPSDSP_LO ; + tempB = (rt >>48 ) &MIPSDSP_LO ; + tempA = (rt >>16 ) &MIPSDSP_LO ; + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_precrq_rs_qh_pw (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rs2, rs0; +uint32_t rt2, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs2 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt2 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempD =mipsdsp_trunc16_sat16_round (env, rs2); + tempC =mipsdsp_trunc16_sat16_round (env, rs0); + tempB =mipsdsp_trunc16_sat16_round (env, rt2); + tempA =mipsdsp_trunc16_sat16_round (env, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_precrq_pw_l (target_ulong rs,target_ulong rt) +{ +uint32_t tempB, tempA; +uint64_t temp; + + tempB = (rs >>32 ) &MIPSDSP_LLO ; + tempA = (rt >>32 ) &MIPSDSP_LLO ; + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_precrqu_s_qb_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t tempD, tempC, tempB, tempA; +uint16_t rsh, rsl, rth, rtl; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sat8_reduce_precision (env, rsh); + tempC =mipsdsp_sat8_reduce_precision (env, rsl); + tempB =mipsdsp_sat8_reduce_precision (env, rth); + tempA =mipsdsp_sat8_reduce_precision (env, rtl); + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_precrqu_s_ob_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int i; +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + temp[7 ] =mipsdsp_sat8_reduce_precision (env, rs3); + temp[6 ] =mipsdsp_sat8_reduce_precision (env, rs2); + temp[5 ] =mipsdsp_sat8_reduce_precision (env, rs1); + temp[4 ] =mipsdsp_sat8_reduce_precision (env, rs0); + temp[3 ] =mipsdsp_sat8_reduce_precision (env, rt3); + temp[2 ] =mipsdsp_sat8_reduce_precision (env, rt2); + temp[1 ] =mipsdsp_sat8_reduce_precision (env, rt1); + temp[0 ] =mipsdsp_sat8_reduce_precision (env, rt0); + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} +#endif + +target_ulong helper_preceq_w_phl (target_ulong rt) +{ +uint32_t rd; + + rd = rt &MIPSDSP_HI ; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_preceq_w_phr (target_ulong rt) +{ +uint16_t rtl; +uint32_t rd; + + rtl = rt &MIPSDSP_LO ; + rd = rtl <<16 ; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_preceq_pw_qhl (target_ulong rt) +{ +uint16_t tempB, tempA; +uint32_t tempBI, tempAI; +uint64_t temp; + + tempB = (rt >>48 ) &MIPSDSP_LO ; + tempA = (rt >>32 ) &MIPSDSP_LO ; + + tempBI = (uint32_t )tempB <<16 ; + tempAI = (uint32_t )tempA <<16 ; + + temp = ((uint64_t )tempBI <<32 ) | ((uint64_t )tempAI); + +return temp; +} + +target_ulong helper_preceq_pw_qhr (target_ulong rt) +{ +uint16_t tempB, tempA; +uint32_t tempBI, tempAI; +uint64_t temp; + + tempB = (rt >>16 ) &MIPSDSP_LO ; + tempA = rt &MIPSDSP_LO ; + + tempBI = (uint32_t )tempB <<16 ; + tempAI = (uint32_t )tempA <<16 ; + + temp = ((uint64_t )tempBI <<32 ) | ((uint64_t )tempAI); + +return temp; +} + +target_ulong helper_preceq_pw_qhla (target_ulong rt) +{ +uint16_t tempB, tempA; +uint32_t tempBI, tempAI; +uint64_t temp; + + tempB = (rt >>48 ) &MIPSDSP_LO ; + tempA = (rt >>16 ) &MIPSDSP_LO ; + + tempBI = (uint32_t )tempB <<16 ; + tempAI = (uint32_t )tempA <<16 ; + + temp = ((uint64_t )tempBI <<32 ) | ((uint64_t )tempAI); + +return temp; +} + +target_ulong helper_preceq_pw_qhra (target_ulong rt) +{ +uint16_t tempB, tempA; +uint32_t tempBI, tempAI; +uint64_t temp; + + tempB = (rt >>32 ) &MIPSDSP_LO ; + tempA = rt &MIPSDSP_LO ; + + tempBI = (uint32_t )tempB <<16 ; + tempAI = (uint32_t )tempA <<16 ; + + temp = ((uint64_t )tempBI <<32 ) | ((uint64_t )tempAI); + +return temp; +} + +target_ulong helper_preceq_l_pwl (target_ulong rt) +{ +uint64_t temp; + temp = rt &MIPSDSP_LHI ; +return temp; +} + +target_ulong helper_preceq_l_pwr (target_ulong rt) +{ +uint64_t temp; + temp = rt <<32 ; +return temp; +} +#endif + +target_ulong helper_precequ_ph_qbl (target_ulong rt) +{ +uint8_t rt3, rt2; +uint16_t tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + + tempB = (uint16_t )rt3 <<7 ; + tempA = (uint16_t )rt2 <<7 ; + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_precequ_ph_qbr (target_ulong rt) +{ +uint8_t rt1, rt0; +uint16_t tempB, tempA; +uint32_t rd; + + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + tempB = (uint16_t )rt1 <<7 ; + tempA = (uint16_t )rt0 <<7 ; + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_precequ_ph_qbla (target_ulong rt) +{ +uint8_t rt3, rt1; +uint16_t tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + + tempB = (uint16_t )rt3 <<7 ; + tempA = (uint16_t )rt1 <<7 ; + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_precequ_ph_qbra (target_ulong rt) +{ +uint8_t rt2, rt0; +uint16_t tempB, tempA; +uint32_t rd; + + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt0 = rt &MIPSDSP_Q0 ; + tempB = (uint16_t )rt2 <<7 ; + tempA = (uint16_t )rt0 <<7 ; + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_precequ_qh_obl (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>56 ) &MIPSDSP_Q0 ; + tempCC = (rt >>48 ) &MIPSDSP_Q0 ; + tempBC = (rt >>40 ) &MIPSDSP_Q0 ; + tempAC = (rt >>32 ) &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC <<7 ; + tempCS = (uint16_t )tempCC <<7 ; + tempBS = (uint16_t )tempBC <<7 ; + tempAS = (uint16_t )tempAC <<7 ; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} + +target_ulong helper_precequ_qh_obr (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>24 ) &MIPSDSP_Q0 ; + tempCC = (rt >>16 ) &MIPSDSP_Q0 ; + tempBC = (rt >>8 ) &MIPSDSP_Q0 ; + tempAC = rt &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC <<7 ; + tempCS = (uint16_t )tempCC <<7 ; + tempBS = (uint16_t )tempBC <<7 ; + tempAS = (uint16_t )tempAC <<7 ; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} + +target_ulong helper_precequ_qh_obla (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>56 ) &MIPSDSP_Q0 ; + tempCC = (rt >>40 ) &MIPSDSP_Q0 ; + tempBC = (rt >>24 ) &MIPSDSP_Q0 ; + tempAC = (rt >>8 ) &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC <<7 ; + tempCS = (uint16_t )tempCC <<7 ; + tempBS = (uint16_t )tempBC <<7 ; + tempAS = (uint16_t )tempAC <<7 ; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} + +target_ulong helper_precequ_qh_obra (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>48 ) &MIPSDSP_Q0 ; + tempCC = (rt >>32 ) &MIPSDSP_Q0 ; + tempBC = (rt >>16 ) &MIPSDSP_Q0 ; + tempAC = rt &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC <<7 ; + tempCS = (uint16_t )tempCC <<7 ; + tempBS = (uint16_t )tempBC <<7 ; + tempAS = (uint16_t )tempAC <<7 ; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} +#endif + +target_ulong helper_preceu_ph_qbl (target_ulong rt) +{ +uint8_t rt3, rt2; +uint16_t tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + tempB = (uint16_t ) rt3; + tempA = (uint16_t ) rt2; + rd = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_preceu_ph_qbr (target_ulong rt) +{ +uint8_t rt1, rt0; +uint16_t tempB, tempA; +uint32_t rd; + + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + tempB = (uint16_t ) rt1; + tempA = (uint16_t ) rt0; + rd = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); +return (target_long )(int32_t )rd; +} + +target_ulong helper_preceu_ph_qbla (target_ulong rt) +{ +uint8_t rt3, rt1; +uint16_t tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + tempB = (uint16_t ) rt3; + tempA = (uint16_t ) rt1; + rd = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_preceu_ph_qbra (target_ulong rt) +{ +uint8_t rt2, rt0; +uint16_t tempB, tempA; +uint32_t rd; + + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt0 = rt &MIPSDSP_Q0 ; + tempB = (uint16_t )rt2; + tempA = (uint16_t )rt0; + rd = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_preceu_qh_obl (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>56 ) &MIPSDSP_Q0 ; + tempCC = (rt >>48 ) &MIPSDSP_Q0 ; + tempBC = (rt >>40 ) &MIPSDSP_Q0 ; + tempAC = (rt >>32 ) &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC; + tempCS = (uint16_t )tempCC; + tempBS = (uint16_t )tempBC; + tempAS = (uint16_t )tempAC; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} + +target_ulong helper_preceu_qh_obr (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>24 ) &MIPSDSP_Q0 ; + tempCC = (rt >>16 ) &MIPSDSP_Q0 ; + tempBC = (rt >>8 ) &MIPSDSP_Q0 ; + tempAC = rt &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC; + tempCS = (uint16_t )tempCC; + tempBS = (uint16_t )tempBC; + tempAS = (uint16_t )tempAC; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} + +target_ulong helper_preceu_qh_obla (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>56 ) &MIPSDSP_Q0 ; + tempCC = (rt >>40 ) &MIPSDSP_Q0 ; + tempBC = (rt >>24 ) &MIPSDSP_Q0 ; + tempAC = (rt >>8 ) &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC; + tempCS = (uint16_t )tempCC; + tempBS = (uint16_t )tempBC; + tempAS = (uint16_t )tempAC; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} + +target_ulong helper_preceu_qh_obra (target_ulong rt) +{ +uint8_t tempDC, tempCC, tempBC, tempAC; +uint16_t tempDS, tempCS, tempBS, tempAS; +uint64_t temp; + + tempDC = (rt >>48 ) &MIPSDSP_Q0 ; + tempCC = (rt >>32 ) &MIPSDSP_Q0 ; + tempBC = (rt >>16 ) &MIPSDSP_Q0 ; + tempAC = rt &MIPSDSP_Q0 ; + + tempDS = (uint16_t )tempDC; + tempCS = (uint16_t )tempCC; + tempBS = (uint16_t )tempBC; + tempAS = (uint16_t )tempAC; + + temp = ((uint64_t )tempDS <<48 ) | ((uint64_t )tempCS <<32 ) | + ((uint64_t )tempBS <<16 ) | (uint64_t )tempAS; +return temp; +} +#endif + +#undef MIPSDSP_LHI +#undef MIPSDSP_LLO +#undef MIPSDSP_HI +#undef MIPSDSP_LO +#undef MIPSDSP_Q3 +#undef MIPSDSP_Q2 +#undef MIPSDSP_Q1 +#undef MIPSDSP_Q0target-mips/helper.h +132
-0@@ -297,4 +297,136 @@ DEF_HELPER_0(rdhwr_ccres, tl) DEF_HELPER_1(pmon, void, int)DEF_HELPER_0 (wait, void) +/*** MIPS DSP ***/ +/* DSP Arithmetic Sub-class insns */ +DEF_HELPER_FLAGS_3(addq_ph, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(addq_s_ph, 0, tl, env, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(addq_qh, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(addq_s_qh, 0, tl, env, tl, tl) +#endif +DEF_HELPER_FLAGS_3(addq_s_w, 0, tl, env, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(addq_pw, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(addq_s_pw, 0, tl, env, tl, tl) +#endif +DEF_HELPER_FLAGS_3(addu_qb, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(addu_s_qb, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_2(adduh_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(adduh_r_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_3(addu_ph, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(addu_s_ph, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_2(addqh_ph, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(addqh_r_ph, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(addqh_w, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(addqh_r_w, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(addu_ob, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(addu_s_ob, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_2(adduh_ob, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(adduh_r_ob, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_3(addu_qh, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(addu_s_qh, 0, tl, env, tl, tl) +#endif +DEF_HELPER_FLAGS_3(subq_ph, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(subq_s_ph, 0, tl, env, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(subq_qh, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(subq_s_qh, 0, tl, env, tl, tl) +#endif +DEF_HELPER_FLAGS_3(subq_s_w, 0, tl, env, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(subq_pw, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(subq_s_pw, 0, tl, env, tl, tl) +#endif +DEF_HELPER_FLAGS_3(subu_qb, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(subu_s_qb, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_2(subuh_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(subuh_r_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_3(subu_ph, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(subu_s_ph, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_2(subqh_ph, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(subqh_r_ph, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(subqh_w, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(subqh_r_w, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(subu_ob, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(subu_s_ob, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_2(subuh_ob, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(subuh_r_ob, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_3(subu_qh, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(subu_s_qh, 0, tl, env, tl, tl) +#endif +DEF_HELPER_FLAGS_3(addsc, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(addwc, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_2(modsub, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_1(raddu_w_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_1(raddu_l_ob, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +#endif +DEF_HELPER_FLAGS_2(absq_s_qb, 0, tl, env, tl) +DEF_HELPER_FLAGS_2(absq_s_ph, 0, tl, env, tl) +DEF_HELPER_FLAGS_2(absq_s_w, 0, tl, env, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_2(absq_s_ob, 0, tl, env, tl) +DEF_HELPER_FLAGS_2(absq_s_qh, 0, tl, env, tl) +DEF_HELPER_FLAGS_2(absq_s_pw, 0, tl, env, tl) +#endif +DEF_HELPER_FLAGS_2(precr_qb_ph, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(precrq_qb_ph, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_3 (precr_sra_ph_w,TCG_CALL_CONST |TCG_CALL_PURE , + tl, i32, tl, tl) +DEF_HELPER_FLAGS_3 (precr_sra_r_ph_w,TCG_CALL_CONST |TCG_CALL_PURE , + tl, i32, tl, tl) +DEF_HELPER_FLAGS_2(precrq_ph_w, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_3(precrq_rs_ph_w, 0, tl, env, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_2(precr_ob_qh, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_3 (precr_sra_qh_pw, + TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl, i32) +DEF_HELPER_FLAGS_3 (precr_sra_r_qh_pw, + TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl, i32) +DEF_HELPER_FLAGS_2(precrq_ob_qh, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(precrq_qh_pw, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_3 (precrq_rs_qh_pw, + TCG_CALL_CONST | TCG_CALL_PURE, tl, env, tl, tl) +DEF_HELPER_FLAGS_2(precrq_pw_l, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +#endif +DEF_HELPER_FLAGS_3(precrqu_s_qb_ph, 0, tl, env, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3 (precrqu_s_ob_qh, + TCG_CALL_CONST | TCG_CALL_PURE, tl, env, tl, tl) + +#endif +DEF_HELPER_FLAGS_1(preceq_w_phl, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(preceq_w_phr, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_1(preceq_pw_qhl, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(preceq_pw_qhr, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(preceq_pw_qhla, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(preceq_pw_qhra, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(preceq_l_pwl, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(preceq_l_pwr, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +#endif +DEF_HELPER_FLAGS_1(precequ_ph_qbl, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(precequ_ph_qbr, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(precequ_ph_qbla, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(precequ_ph_qbra, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_1(precequ_qh_obl, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(precequ_qh_obr, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(precequ_qh_obla, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(precequ_qh_obra, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +#endif +DEF_HELPER_FLAGS_1(preceu_ph_qbl, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(preceu_ph_qbr, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(preceu_ph_qbla, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(preceu_ph_qbra, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_1(preceu_qh_obl, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(preceu_qh_obr, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(preceu_qh_obla, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_1(preceu_qh_obra, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +#endif +#include "def-helper.h" target-mips/translate.c +153
-1@@ -316,6 +316,21 @@ enum {/* MIPS DSP Load */ OPC_LX_DSP = 0x0A | OPC_SPECIAL3, +/* MIPS DSP Arithmetic */ + OPC_ADDU_QB_DSP = 0x10 | OPC_SPECIAL3, +#if defined(TARGET_MIPS64) + OPC_ADDU_OB_DSP = 0x14 | OPC_SPECIAL3, +#endif + OPC_ABSQ_S_PH_DSP = 0x12 | OPC_SPECIAL3, +#if defined(TARGET_MIPS64) + OPC_ABSQ_S_QH_DSP = 0x16 | OPC_SPECIAL3, +#endif + /* OPC_ADDUH_QB_DSP is same as OPC_MULT_G_2E. */ + /* OPC_ADDUH_QB_DSP = 0x18 | OPC_SPECIAL3, */ + OPC_CMPU_EQ_QB_DSP = 0x11 | OPC_SPECIAL3, +#if defined(TARGET_MIPS64) + OPC_CMPU_EQ_OB_DSP = 0x15 | OPC_SPECIAL3, +#endif }; /* BSHFL opcodes */@@ -354,6 +369,144 @@ enum {#endif }; +#define MASK_ADDU_QB (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* MIPS DSP Arithmetic Sub-class */ +OPC_ADDQ_PH = (0x0A <<6 ) |OPC_ADDU_QB_DSP , +OPC_ADDQ_S_PH = (0x0E <<6 ) |OPC_ADDU_QB_DSP , +OPC_ADDQ_S_W = (0x16 <<6 ) |OPC_ADDU_QB_DSP , +OPC_ADDU_QB = (0x00 <<6 ) |OPC_ADDU_QB_DSP , +OPC_ADDU_S_QB = (0x04 <<6 ) |OPC_ADDU_QB_DSP , +OPC_ADDU_PH = (0x08 <<6 ) |OPC_ADDU_QB_DSP , +OPC_ADDU_S_PH = (0x0C <<6 ) |OPC_ADDU_QB_DSP , +OPC_SUBQ_PH = (0x0B <<6 ) |OPC_ADDU_QB_DSP , +OPC_SUBQ_S_PH = (0x0F <<6 ) |OPC_ADDU_QB_DSP , +OPC_SUBQ_S_W = (0x17 <<6 ) |OPC_ADDU_QB_DSP , +OPC_SUBU_QB = (0x01 <<6 ) |OPC_ADDU_QB_DSP , +OPC_SUBU_S_QB = (0x05 <<6 ) |OPC_ADDU_QB_DSP , +OPC_SUBU_PH = (0x09 <<6 ) |OPC_ADDU_QB_DSP , +OPC_SUBU_S_PH = (0x0D <<6 ) |OPC_ADDU_QB_DSP , +OPC_ADDSC = (0x10 <<6 ) |OPC_ADDU_QB_DSP , +OPC_ADDWC = (0x11 <<6 ) |OPC_ADDU_QB_DSP , +OPC_MODSUB = (0x12 <<6 ) |OPC_ADDU_QB_DSP , +OPC_RADDU_W_QB = (0x14 <<6 ) |OPC_ADDU_QB_DSP , +}; + +#define OPC_ADDUH_QB_DSP OPC_MULT_G_2E +#define MASK_ADDUH_QB (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* MIPS DSP Arithmetic Sub-class */ +OPC_ADDUH_QB = (0x00 <<6 ) |OPC_ADDUH_QB_DSP , +OPC_ADDUH_R_QB = (0x02 <<6 ) |OPC_ADDUH_QB_DSP , +OPC_ADDQH_PH = (0x08 <<6 ) |OPC_ADDUH_QB_DSP , +OPC_ADDQH_R_PH = (0x0A <<6 ) |OPC_ADDUH_QB_DSP , +OPC_ADDQH_W = (0x10 <<6 ) |OPC_ADDUH_QB_DSP , +OPC_ADDQH_R_W = (0x12 <<6 ) |OPC_ADDUH_QB_DSP , +OPC_SUBUH_QB = (0x01 <<6 ) |OPC_ADDUH_QB_DSP , +OPC_SUBUH_R_QB = (0x03 <<6 ) |OPC_ADDUH_QB_DSP , +OPC_SUBQH_PH = (0x09 <<6 ) |OPC_ADDUH_QB_DSP , +OPC_SUBQH_R_PH = (0x0B <<6 ) |OPC_ADDUH_QB_DSP , +OPC_SUBQH_W = (0x11 <<6 ) |OPC_ADDUH_QB_DSP , +OPC_SUBQH_R_W = (0x13 <<6 ) |OPC_ADDUH_QB_DSP , +}; + +#define MASK_ABSQ_S_PH (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* MIPS DSP Arithmetic Sub-class */ +OPC_ABSQ_S_QB = (0x01 <<6 ) |OPC_ABSQ_S_PH_DSP , +OPC_ABSQ_S_PH = (0x09 <<6 ) |OPC_ABSQ_S_PH_DSP , +OPC_ABSQ_S_W = (0x11 <<6 ) |OPC_ABSQ_S_PH_DSP , +OPC_PRECEQ_W_PHL = (0x0C <<6 ) |OPC_ABSQ_S_PH_DSP , +OPC_PRECEQ_W_PHR = (0x0D <<6 ) |OPC_ABSQ_S_PH_DSP , +OPC_PRECEQU_PH_QBL = (0x04 <<6 ) |OPC_ABSQ_S_PH_DSP , +OPC_PRECEQU_PH_QBR = (0x05 <<6 ) |OPC_ABSQ_S_PH_DSP , +OPC_PRECEQU_PH_QBLA = (0x06 <<6 ) |OPC_ABSQ_S_PH_DSP , +OPC_PRECEQU_PH_QBRA = (0x07 <<6 ) |OPC_ABSQ_S_PH_DSP , +OPC_PRECEU_PH_QBL = (0x1C <<6 ) |OPC_ABSQ_S_PH_DSP , +OPC_PRECEU_PH_QBR = (0x1D <<6 ) |OPC_ABSQ_S_PH_DSP , +OPC_PRECEU_PH_QBLA = (0x1E <<6 ) |OPC_ABSQ_S_PH_DSP , +OPC_PRECEU_PH_QBRA = (0x1F <<6 ) |OPC_ABSQ_S_PH_DSP , +}; + +#define MASK_CMPU_EQ_QB (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* MIPS DSP Arithmetic Sub-class */ +OPC_PRECR_QB_PH = (0x0D <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_PRECRQ_QB_PH = (0x0C <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_PRECR_SRA_PH_W = (0x1E <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_PRECR_SRA_R_PH_W = (0x1F <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_PRECRQ_PH_W = (0x14 <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_PRECRQ_RS_PH_W = (0x15 <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_PRECRQU_S_QB_PH = (0x0F <<6 ) |OPC_CMPU_EQ_QB_DSP , +}; + +#if defined(TARGET_MIPS64 ) +#define MASK_ABSQ_S_QH (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* MIPS DSP Arithmetic Sub-class */ +OPC_PRECEQ_L_PWL = (0x14 <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_PRECEQ_L_PWR = (0x15 <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_PRECEQ_PW_QHL = (0x0C <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_PRECEQ_PW_QHR = (0x0D <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_PRECEQ_PW_QHLA = (0x0E <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_PRECEQ_PW_QHRA = (0x0F <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_PRECEQU_QH_OBL = (0x04 <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_PRECEQU_QH_OBR = (0x05 <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_PRECEQU_QH_OBLA = (0x06 <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_PRECEQU_QH_OBRA = (0x07 <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_PRECEU_QH_OBL = (0x1C <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_PRECEU_QH_OBR = (0x1D <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_PRECEU_QH_OBLA = (0x1E <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_PRECEU_QH_OBRA = (0x1F <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_ABSQ_S_OB = (0x01 <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_ABSQ_S_PW = (0x11 <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_ABSQ_S_QH = (0x09 <<6 ) |OPC_ABSQ_S_QH_DSP , +}; +#endif + +#if defined(TARGET_MIPS64 ) +#define MASK_ADDU_OB (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* MIPS DSP Arithmetic Sub-class */ +OPC_RADDU_L_OB = (0x14 <<6 ) |OPC_ADDU_OB_DSP , +OPC_SUBQ_PW = (0x13 <<6 ) |OPC_ADDU_OB_DSP , +OPC_SUBQ_S_PW = (0x17 <<6 ) |OPC_ADDU_OB_DSP , +OPC_SUBQ_QH = (0x0B <<6 ) |OPC_ADDU_OB_DSP , +OPC_SUBQ_S_QH = (0x0F <<6 ) |OPC_ADDU_OB_DSP , +OPC_SUBU_OB = (0x01 <<6 ) |OPC_ADDU_OB_DSP , +OPC_SUBU_S_OB = (0x05 <<6 ) |OPC_ADDU_OB_DSP , +OPC_SUBU_QH = (0x09 <<6 ) |OPC_ADDU_OB_DSP , +OPC_SUBU_S_QH = (0x0D <<6 ) |OPC_ADDU_OB_DSP , +OPC_SUBUH_OB = (0x19 <<6 ) |OPC_ADDU_OB_DSP , +OPC_SUBUH_R_OB = (0x1B <<6 ) |OPC_ADDU_OB_DSP , +OPC_ADDQ_PW = (0x12 <<6 ) |OPC_ADDU_OB_DSP , +OPC_ADDQ_S_PW = (0x16 <<6 ) |OPC_ADDU_OB_DSP , +OPC_ADDQ_QH = (0x0A <<6 ) |OPC_ADDU_OB_DSP , +OPC_ADDQ_S_QH = (0x0E <<6 ) |OPC_ADDU_OB_DSP , +OPC_ADDU_OB = (0x00 <<6 ) |OPC_ADDU_OB_DSP , +OPC_ADDU_S_OB = (0x04 <<6 ) |OPC_ADDU_OB_DSP , +OPC_ADDU_QH = (0x08 <<6 ) |OPC_ADDU_OB_DSP , +OPC_ADDU_S_QH = (0x0C <<6 ) |OPC_ADDU_OB_DSP , +OPC_ADDUH_OB = (0x18 <<6 ) |OPC_ADDU_OB_DSP , +OPC_ADDUH_R_OB = (0x1A <<6 ) |OPC_ADDU_OB_DSP , +}; +#endif + +#if defined(TARGET_MIPS64 ) +#define MASK_CMPU_EQ_OB (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* MIPS DSP Arithmetic Sub-class */ +OPC_PRECR_OB_QH = (0x0D <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_PRECR_SRA_QH_PW = (0x1E <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_PRECR_SRA_R_QH_PW = (0x1F <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_PRECRQ_OB_QH = (0x0C <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_PRECRQ_PW_L = (0x1C <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_PRECRQ_QH_PW = (0x14 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_PRECRQ_RS_QH_PW = (0x15 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_PRECRQU_S_OB_QH = (0x0F <<6 ) |OPC_CMPU_EQ_OB_DSP , +}; +#endif +/* Coprocessor 0 (rs field) */ #define MASK_CP0 (op) MASK_OP_MAJOR(op) | (op & (0x1F << 21))@@ -12193,10 +12346,64 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) }break ; case OPC_DIV_G_2E ... OPC_DIVU_G_2E: - case OPC_MULT_G_2E ... OPC_MULTU_G_2E: case OPC_MOD_G_2E ... OPC_MODU_G_2E:
target-mips/translate.c static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) · line 12357
Quoted 10 lines
target-mips/translate.c +8
-2-check_insn (env, ctx,INSN_LOONGSON2E ); -gen_loongson_integer (ctx, op1, rd, rs, rt); + case OPC_MULT_G_2E ... OPC_MULTU_G_2E: +/* OPC_MULT_G_2E, OPC_ADDUH_QB_DSP, OPC_MUL_PH_DSP have +* the same mask and op1. */ +if ((env->insn_flags &ASE_DSPR2 ) && (op1 ==OPC_MULT_G_2E )) { +check_dspr2 (ctx); + op2 =MASK_ADDUH_QB (ctx->opcode); +switch (op2) { +case OPC_ADDUH_QB :
Minor nitpick: don't use double space between case and the value.
Quoted 39 lines
target-mips/translate.c +39
-0+gen_helper_adduh_qb (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDUH_R_QB : +gen_helper_adduh_r_qb (cpu_gpr[rd], + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDQH_PH : +gen_helper_addqh_ph (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDQH_R_PH : +gen_helper_addqh_r_ph (cpu_gpr[rd], cpu_gpr[rs], + cpu_gpr[rt]); +break ; +case OPC_ADDQH_W : +gen_helper_addqh_w (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDQH_R_W : +gen_helper_addqh_r_w (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBUH_QB : +gen_helper_subuh_qb (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBUH_R_QB : +gen_helper_subuh_r_qb (cpu_gpr[rd], + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBQH_PH : +gen_helper_subqh_ph (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBQH_R_PH : +gen_helper_subqh_r_ph (cpu_gpr[rd], + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBQH_W : +gen_helper_subqh_w (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBQH_R_W : +gen_helper_subqh_r_w (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ;
target-mips/translate.c static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) · line 12406
Quoted 10 lines
target-mips/translate.c +10
-0+default : +MIPS_INVAL ("MASK ADDUH.QB" ); +generate_exception (ctx,EXCP_RI ); +break ; + } + }else if (env->insn_flags &INSN_LOONGSON2E ) { +gen_loongson_integer (ctx, op1, rd, rs, rt); + }else { +generate_exception (ctx,EXCP_RI ); + }
Thanks for the fix, this is now correctly done.
Quoted 477 lines
target-mips/translate.c +456
-0break ;case OPC_LX_DSP :check_dsp (ctx);@@ -12246,6 +12453,213 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)break ; }break ; +case OPC_ABSQ_S_PH_DSP : + op2 =MASK_ABSQ_S_PH (ctx->opcode); +switch (op2) { +case OPC_ABSQ_S_QB : +check_dspr2 (ctx); +gen_helper_absq_s_qb (cpu_gpr[rd], cpu_env, cpu_gpr[rt]); +break ; +case OPC_ABSQ_S_PH : +check_dsp (ctx); +gen_helper_absq_s_ph (cpu_gpr[rd], cpu_env, cpu_gpr[rt]); +break ; +case OPC_ABSQ_S_W : +check_dsp (ctx); +gen_helper_absq_s_w (cpu_gpr[rd], cpu_env, cpu_gpr[rt]); +break ; +case OPC_PRECEQ_W_PHL : +check_dsp (ctx); +gen_helper_preceq_w_phl (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEQ_W_PHR : +check_dsp (ctx); +gen_helper_preceq_w_phr (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEQU_PH_QBL : +check_dsp (ctx); +gen_helper_precequ_ph_qbl (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEQU_PH_QBR : +check_dsp (ctx); +gen_helper_precequ_ph_qbr (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEQU_PH_QBLA : +check_dsp (ctx); +gen_helper_precequ_ph_qbla (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEQU_PH_QBRA : +check_dsp (ctx); +gen_helper_precequ_ph_qbra (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEU_PH_QBL : +check_dsp (ctx); +gen_helper_preceu_ph_qbl (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEU_PH_QBR : +check_dsp (ctx); +gen_helper_preceu_ph_qbr (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEU_PH_QBLA : +check_dsp (ctx); +gen_helper_preceu_ph_qbla (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEU_PH_QBRA : +check_dsp (ctx); +gen_helper_preceu_ph_qbra (cpu_gpr[rd], cpu_gpr[rt]); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK ABSQ_S.PH" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ; +case OPC_ADDU_QB_DSP : + op2 =MASK_ADDU_QB (ctx->opcode); +switch (op2) { +case OPC_ADDQ_PH : +check_dsp (ctx); +gen_helper_addq_ph (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDQ_S_PH : +check_dsp (ctx); +gen_helper_addq_s_ph (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDQ_S_W : +check_dsp (ctx); +gen_helper_addq_s_w (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDU_QB : +check_dsp (ctx); +gen_helper_addu_qb (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDU_S_QB : +check_dsp (ctx); +gen_helper_addu_s_qb (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDU_PH : +check_dspr2 (ctx); +gen_helper_addu_ph (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDU_S_PH : +check_dspr2 (ctx); +gen_helper_addu_s_ph (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBQ_PH : +check_dsp (ctx); +gen_helper_subq_ph (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBQ_S_PH : +check_dsp (ctx); +gen_helper_subq_s_ph (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBQ_S_W : +check_dsp (ctx); +gen_helper_subq_s_w (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBU_QB : +check_dsp (ctx); +gen_helper_subu_qb (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBU_S_QB : +check_dsp (ctx); +gen_helper_subu_s_qb (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBU_PH : +check_dspr2 (ctx); +gen_helper_subu_ph (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBU_S_PH : +check_dspr2 (ctx); +gen_helper_subu_s_ph (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDSC : +check_dsp (ctx); +gen_helper_addsc (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDWC : +check_dsp (ctx); +gen_helper_addwc (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_MODSUB : +check_dsp (ctx); +gen_helper_modsub (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_RADDU_W_QB : +check_dsp (ctx); +gen_helper_raddu_w_qb (cpu_gpr[rd], cpu_gpr[rs]); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK ADDU.QB" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ; +case OPC_CMPU_EQ_QB_DSP : + op2 =MASK_CMPU_EQ_QB (ctx->opcode); +switch (op2) { +case OPC_PRECR_QB_PH : +check_dspr2 (ctx); +gen_helper_precr_qb_ph (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_PRECRQ_QB_PH : +check_dsp (ctx); +gen_helper_precrq_qb_ph (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_PRECR_SRA_PH_W : +check_dspr2 (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_precr_sra_ph_w (cpu_gpr[rt], temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_PRECR_SRA_R_PH_W : +check_dspr2 (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_precr_sra_r_ph_w (cpu_gpr[rt], temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_PRECRQ_PH_W : +check_dsp (ctx); +gen_helper_precrq_ph_w (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_PRECRQ_RS_PH_W : +check_dsp (ctx); +gen_helper_precrq_rs_ph_w (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_PRECRQU_S_QB_PH : +check_dsp (ctx); +gen_helper_precrqu_s_qb_ph (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK CMPU.EQ.QB" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ;#if defined(TARGET_MIPS64 ) case OPC_DEXTM ... OPC_DEXT: case OPC_DINSM ... OPC_DINS:@@ -12266,6 +12680,255 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)gen_loongson_integer (ctx, op1, rd, rs, rt);break ;#endif +#if defined(TARGET_MIPS64 ) +case OPC_ABSQ_S_QH_DSP : + op2 =MASK_ABSQ_S_QH (ctx->opcode); +switch (op2) { +case OPC_PRECEQ_L_PWL : +check_dsp (ctx); +gen_helper_preceq_l_pwl (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEQ_L_PWR : +check_dsp (ctx); +gen_helper_preceq_l_pwr (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEQ_PW_QHL : +check_dsp (ctx); +gen_helper_preceq_pw_qhl (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEQ_PW_QHR : +check_dsp (ctx); +gen_helper_preceq_pw_qhr (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEQ_PW_QHLA : +check_dsp (ctx); +gen_helper_preceq_pw_qhla (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEQ_PW_QHRA : +check_dsp (ctx); +gen_helper_preceq_pw_qhra (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEQU_QH_OBL : +check_dsp (ctx); +gen_helper_precequ_qh_obl (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEQU_QH_OBR : +check_dsp (ctx); +gen_helper_precequ_qh_obr (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEQU_QH_OBLA : +check_dsp (ctx); +gen_helper_precequ_qh_obla (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEQU_QH_OBRA : +check_dsp (ctx); +gen_helper_precequ_qh_obra (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEU_QH_OBL : +check_dsp (ctx); +gen_helper_preceu_qh_obl (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEU_QH_OBR : +check_dsp (ctx); +gen_helper_preceu_qh_obr (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEU_QH_OBLA : +check_dsp (ctx); +gen_helper_preceu_qh_obla (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_PRECEU_QH_OBRA : +check_dsp (ctx); +gen_helper_preceu_qh_obra (cpu_gpr[rd], cpu_gpr[rt]); +break ; +case OPC_ABSQ_S_OB : +check_dspr2 (ctx); +gen_helper_absq_s_ob (cpu_gpr[rd], cpu_env, cpu_gpr[rt]); +break ; +case OPC_ABSQ_S_PW : +check_dsp (ctx); +gen_helper_absq_s_pw (cpu_gpr[rd], cpu_env, cpu_gpr[rt]); +break ; +case OPC_ABSQ_S_QH : +check_dsp (ctx); +gen_helper_absq_s_qh (cpu_gpr[rd], cpu_env, cpu_gpr[rt]); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK ABSQ_S.QH" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ; +#endif +#if defined(TARGET_MIPS64 ) +case OPC_ADDU_OB_DSP : + op2 =MASK_ADDU_OB (ctx->opcode); +switch (op2) { +case OPC_RADDU_L_OB : +check_dsp (ctx); +gen_helper_raddu_l_ob (cpu_gpr[rd], cpu_gpr[rs]); +break ; +case OPC_SUBQ_PW : +check_dsp (ctx); +gen_helper_subq_pw (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBQ_S_PW : +check_dsp (ctx); +gen_helper_subq_s_pw (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBQ_QH : +check_dsp (ctx); +gen_helper_subq_qh (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBQ_S_QH : +check_dsp (ctx); +gen_helper_subq_s_qh (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBU_OB : +check_dsp (ctx); +gen_helper_subu_ob (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBU_S_OB : +check_dsp (ctx); +gen_helper_subu_s_ob (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBU_QH : +check_dspr2 (ctx); +gen_helper_subu_qh (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBU_S_QH : +check_dspr2 (ctx); +gen_helper_subu_s_qh (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBUH_OB : +check_dspr2 (ctx); +gen_helper_subuh_ob (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SUBUH_R_OB : +check_dspr2 (ctx); +gen_helper_subuh_r_ob (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDQ_PW : +check_dsp (ctx); +gen_helper_addq_pw (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDQ_S_PW : +check_dsp (ctx); +gen_helper_addq_s_pw (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDQ_QH : +check_dsp (ctx); +gen_helper_addq_qh (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDQ_S_QH : +check_dsp (ctx); +gen_helper_addq_s_qh (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDU_OB : +check_dsp (ctx); +gen_helper_addu_ob (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDU_S_OB : +check_dsp (ctx); +gen_helper_addu_s_ob (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDU_QH : +check_dspr2 (ctx); +gen_helper_addu_qh (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDU_S_QH : +check_dspr2 (ctx); +gen_helper_addu_s_qh (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDUH_OB : +check_dspr2 (ctx); +gen_helper_adduh_ob (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_ADDUH_R_OB : +check_dspr2 (ctx); +gen_helper_adduh_r_ob (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK ADDU.OB" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ; +#endif +#if defined(TARGET_MIPS64 ) +case OPC_CMPU_EQ_OB_DSP : + op2 =MASK_CMPU_EQ_OB (ctx->opcode); +switch (op2) { +case OPC_PRECR_OB_QH : +check_dspr2 (ctx); +gen_helper_precr_ob_qh (cpu_gpr[rd], cpu_gpr[rs], + cpu_gpr[rt]); +break ; +case OPC_PRECR_SRA_QH_PW : +check_dspr2 (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (rd); +gen_helper_precr_sra_qh_pw (cpu_gpr[rt], cpu_gpr[rs], + cpu_gpr[rt], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_PRECR_SRA_R_QH_PW : +check_dspr2 (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (rd); +gen_helper_precr_sra_r_qh_pw (cpu_gpr[rt], cpu_gpr[rs], + cpu_gpr[rt], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_PRECRQ_OB_QH : +check_dsp (ctx); +gen_helper_precrq_ob_qh (cpu_gpr[rd], cpu_gpr[rs], + cpu_gpr[rt]); +break ; +case OPC_PRECRQ_PW_L : +check_dsp (ctx); +gen_helper_precrq_pw_l (cpu_gpr[rd], cpu_gpr[rs], + cpu_gpr[rt]); +break ; +case OPC_PRECRQ_QH_PW : +check_dsp (ctx); +gen_helper_precrq_qh_pw (cpu_gpr[rd], cpu_gpr[rs], + cpu_gpr[rt]); +break ; +case OPC_PRECRQ_RS_QH_PW : +check_dsp (ctx); +gen_helper_precrq_rs_qh_pw (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_PRECRQU_S_OB_QH : +check_dsp (ctx); +gen_helper_precrqu_s_ob_qh (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK CMPU.EQ.OB" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ; +#endif default :/* Invalid */ MIPS_INVAL ("special3" );generate_exception (ctx,EXCP_RI );Signature · 1 line
1.7.9.5
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v7 7/14 target-mips-ase-dsp: Add GPR-based shift instructions
In reply to Jia LiuAdd MIPS ASE DSP GPR-Based Shift instructions.
--- target-mips/dsp_helper.c | 991 ++++++++++++++++++++++++++++++++++++++++++++++ target-mips/helper.h | 62 +++ target-mips/translate.c | 359 +++++++++++++++++ 3 files changed, 1412 insertions(+)
target-mips/dsp_helper.c +991 -0
@@ -3196,6 +3196,997 @@ target_ulong helper_preceu_qh_obra(target_ulong rt) }#endif +/** DSP GPR-Based Shift Sub-class insns **/ +target_ulong helper_shll_qb (CPUMIPSState *env,uint32_t sa,target_ulong rt) +{ +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_lshift8 (env, rt3, sa); + tempC =mipsdsp_lshift8 (env, rt2, sa); + tempB =mipsdsp_lshift8 (env, rt1, sa); + tempA =mipsdsp_lshift8 (env, rt0, sa); + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | ((uint32_t )tempA); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shllv_qb (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs2_0; +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs2_0 = rs &0x07 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_lshift8 (env, rt3, rs2_0); + tempC =mipsdsp_lshift8 (env, rt2, rs2_0); + tempB =mipsdsp_lshift8 (env, rt1, rs2_0); + tempA =mipsdsp_lshift8 (env, rt0, rs2_0); + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_shll_ob (CPUMIPSState *env,target_ulong rt,uint32_t sa) +{ +int i; +uint8_t rt_t[8 ]; +uint8_t temp_t[8 ]; +uint64_t temp; + + sa = sa &0x07 ; + temp =0 ; + +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp_t[i] =mipsdsp_lshift8 (env, rt_t[i], sa); + + temp |= (uint64_t )temp_t[i] << (8 * i); + } + +return temp; +} + +target_ulong helper_shllv_ob (CPUMIPSState *env, +target_ulong rt,target_ulong sa) +{ +int i; +uint8_t rt_t[8 ]; +uint8_t temp_t[8 ]; +uint64_t temp; + + sa = sa &0x07 ; + temp =0 ; + +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp_t[i] =mipsdsp_lshift8 (env, rt_t[i], sa); + + temp |= (uint64_t )temp_t[i] << (8 * i); + } + +return temp; +} +#endif + +target_ulong helper_shll_ph (CPUMIPSState *env,uint32_t sa,target_ulong rt) +{ +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_lshift16 (env, rth, sa); + tempA =mipsdsp_lshift16 (env, rtl, sa); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shllv_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs3_0; +uint16_t rth, rtl, tempB, tempA; +uint32_t rd; + + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + rs3_0 = rs &0x0F ; + + tempB =mipsdsp_lshift16 (env, rth, rs3_0); + tempA =mipsdsp_lshift16 (env, rtl, rs3_0); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shll_s_ph (CPUMIPSState *env,uint32_t sa,target_ulong rt) +{ +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_sat16_lshift (env, rth, sa); + tempA =mipsdsp_sat16_lshift (env, rtl, sa); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shllv_s_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs3_0; +uint16_t rth, rtl, tempB, tempA; +uint32_t rd; + + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + rs3_0 = rs &0x0F ; + + tempB =mipsdsp_sat16_lshift (env, rth, rs3_0); + tempA =mipsdsp_sat16_lshift (env, rtl, rs3_0); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_shll_qh (CPUMIPSState *env,target_ulong rt,uint32_t sa) +{ +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + sa = sa &0x0F ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_lshift16 (env, rt3, sa); + tempC =mipsdsp_lshift16 (env, rt2, sa); + tempB =mipsdsp_lshift16 (env, rt1, sa); + tempA =mipsdsp_lshift16 (env, rt0, sa); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_shllv_qh (CPUMIPSState *env, +target_ulong rt,target_ulong sa) +{ +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + sa = sa &0x0F ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_lshift16 (env, rt3, sa); + tempC =mipsdsp_lshift16 (env, rt2, sa); + tempB =mipsdsp_lshift16 (env, rt1, sa); + tempA =mipsdsp_lshift16 (env, rt0, sa); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_shll_s_qh (CPUMIPSState *env,target_ulong rt,uint32_t sa) +{ +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + sa = sa &0x0F ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sat16_lshift (env, rt3, sa); + tempC =mipsdsp_sat16_lshift (env, rt2, sa); + tempB =mipsdsp_sat16_lshift (env, rt1, sa); + tempA =mipsdsp_sat16_lshift (env, rt0, sa); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_shllv_s_qh (CPUMIPSState *env, +target_ulong rt,target_ulong sa) +{ +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + sa = sa &0x0F ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sat16_lshift (env, rt3, sa); + tempC =mipsdsp_sat16_lshift (env, rt2, sa); + tempB =mipsdsp_sat16_lshift (env, rt1, sa); + tempA =mipsdsp_sat16_lshift (env, rt0, sa); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_shll_s_w (CPUMIPSState *env,uint32_t sa,target_ulong rt) +{ +uint32_t temp, rd; + + temp =mipsdsp_sat32_lshift (env, rt, sa); + rd = temp; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shllv_s_w (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs4_0; +uint32_t rd; + + rs4_0 = rs &0x1F ; + rd =mipsdsp_sat32_lshift (env, rt, rs4_0); + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_shll_pw (CPUMIPSState *env,target_ulong rt,uint32_t sa) +{ +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_lshift32 (env, rt1, sa); + tempA =mipsdsp_lshift32 (env, rt0, sa); + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_shllv_pw (CPUMIPSState *env, +target_ulong rt,target_ulong sa) +{ +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + sa = sa &0x1F ; + + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_lshift32 (env, rt1, sa); + tempA =mipsdsp_lshift32 (env, rt0, sa); + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_shll_s_pw (CPUMIPSState *env,target_ulong rt,uint32_t sa) +{ +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_sat32_lshift (env, rt1, sa); + tempA =mipsdsp_sat32_lshift (env, rt0, sa); + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_shllv_s_pw (CPUMIPSState *env, +target_ulong rt,target_ulong sa) +{ +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + sa = sa &0x1F ; + + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_sat32_lshift (env, rt1, sa); + tempA =mipsdsp_sat32_lshift (env, rt0, sa); + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_shrl_qb (uint32_t sa,target_ulong rt) +{ +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_rshift8 (rt3, sa); + tempC =mipsdsp_rshift8 (rt2, sa); + tempB =mipsdsp_rshift8 (rt1, sa); + tempA =mipsdsp_rshift8 (rt0, sa); + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrlv_qb (target_ulong rs,target_ulong rt) +{ +uint8_t rs2_0; +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs2_0 = rs &0x07 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_rshift8 (rt3, rs2_0); + tempC =mipsdsp_rshift8 (rt2, rs2_0); + tempB =mipsdsp_rshift8 (rt1, rs2_0); + tempA =mipsdsp_rshift8 (rt0, rs2_0); + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrl_ph (uint32_t sa,target_ulong rt) +{ +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB = rth >> sa; + tempA = rtl >> sa; + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrlv_ph (target_ulong rs,target_ulong rt) +{ +uint8_t rs3_0; +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rs3_0 = rs &0x0F ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB = rth >> rs3_0; + tempA = rtl >> rs3_0; + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_shrl_ob (target_ulong rt,uint32_t sa) +{ +int i; +uint8_t rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + sa = sa &0x07 ; + result =0 ; + +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_rshift8 (rt_t[i], sa); + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_shrlv_ob (target_ulong rt,target_ulong sa) +{ +int i; +uint8_t rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + sa = sa &0x07 ; + result =0 ; + +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_rshift8 (rt_t[i], sa); + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_shrl_qh (target_ulong rt,uint32_t sa) +{ +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + sa = sa &0x0F ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD = rt3 >> sa; + tempC = rt2 >> sa; + tempB = rt1 >> sa; + tempA = rt0 >> sa; + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_shrlv_qh (target_ulong rt,target_ulong sa) +{ +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + sa = sa &0x0F ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD = rt3 >> sa; + tempC = rt2 >> sa; + tempB = rt1 >> sa; + tempA = rt0 >> sa; + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_shra_qb (uint32_t sa,target_ulong rt) +{ +int8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD = rt3 >> sa; + tempC = rt2 >> sa; + tempB = rt1 >> sa; + tempA = rt0 >> sa; + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shra_r_qb (uint32_t sa,target_ulong rt) +{ +int8_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + +if (sa ==0 ) { + tempD = rt3 &0x00FF ; + tempC = rt2 &0x00FF ; + tempB = rt1 &0x00FF ; + tempA = rt0 &0x00FF ; + }else { + tempD = ((int16_t )rt3 >> (sa -1 )) +1 ; + tempC = ((int16_t )rt2 >> (sa -1 )) +1 ; + tempB = ((int16_t )rt1 >> (sa -1 )) +1 ; + tempA = ((int16_t )rt0 >> (sa -1 )) +1 ; + } + + rd = ((uint32_t )((tempD >>1 ) &0x00FF ) <<24 ) | + ((uint32_t )((tempC >>1 ) &0x00FF ) <<16 ) | + ((uint32_t )((tempB >>1 ) &0x00FF ) <<8 ) | + (uint32_t )((tempA >>1 ) &0x00FF ) ; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrav_qb (target_ulong rs,target_ulong rt) +{ +uint8_t rs2_0; +int8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs2_0 = rs &0x07 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + +if (rs2_0 ==0 ) { + tempD = rt3; + tempC = rt2; + tempB = rt1; + tempA = rt0; + }else { + tempD = rt3 >> rs2_0; + tempC = rt2 >> rs2_0; + tempB = rt1 >> rs2_0; + tempA = rt0 >> rs2_0; + } + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrav_r_qb (target_ulong rs,target_ulong rt) +{ +uint8_t rs2_0; +int8_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs2_0 = rs &0x07 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + +if (rs2_0 ==0 ) { + tempD = (int16_t )rt3 <<1 ; + tempC = (int16_t )rt2 <<1 ; + tempB = (int16_t )rt1 <<1 ; + tempA = (int16_t )rt0 <<1 ; + }else { + tempD = ((int16_t )rt3 >> (rs2_0 -1 )) +1 ; + tempC = ((int16_t )rt2 >> (rs2_0 -1 )) +1 ; + tempB = ((int16_t )rt1 >> (rs2_0 -1 )) +1 ; + tempA = ((int16_t )rt0 >> (rs2_0 -1 )) +1 ; + } + + rd = ((uint32_t )((tempD >>1 ) &0x00FF ) <<24 ) | + ((uint32_t )((tempC >>1 ) &0x00FF ) <<16 ) | + ((uint32_t )((tempB >>1 ) &0x00FF ) <<8 ) | + (uint32_t )((tempA >>1 ) &0x00FF ) ; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_shra_ob (target_ulong rt,uint32_t sa) +{ +int i; +int8_t rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + sa = sa &0x07 ; + +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] = rt_t[i] >> sa; + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_shrav_ob (target_ulong rt,target_ulong sa) +{ +int i; +int8_t rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + sa = sa &0x07 ; + +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] = rt_t[i] >> sa; + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_shra_r_ob (target_ulong rt,uint32_t sa) +{ +int i; +int8_t rt_t[8 ]; +int16_t rt_t_S[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + sa = sa &0x07 ; + +if (sa ==0 ) { + result = rt; + }else { +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + rt_t_S[i] = ((int16_t )rt_t[i] >> (sa -1 )) +1 ; + temp[i] = (rt_t_S[i] >>1 ) &MIPSDSP_Q0 ; + result |= (uint64_t )temp[i] << (8 * i); + } + } + +return result; +} + +target_ulong helper_shrav_r_ob (target_ulong rt,target_ulong sa) +{ +int i; +int8_t rt_t[8 ]; +int16_t rt_t_S[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + sa = sa &0x07 ; + +if (sa ==0 ) { + result = rt; + }else { +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + rt_t_S[i] = ((int16_t )rt_t[i] >> (sa -1 )) +1 ; + temp[i] = (rt_t_S[i] >>1 ) &MIPSDSP_Q0 ; + result |= (uint64_t )temp[i] << (8 * i); + } + } + +return result; +} +#endif + +target_ulong helper_shra_ph (uint32_t sa,target_ulong rt) +{ +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_rashift16 (rth, sa); + tempA =mipsdsp_rashift16 (rtl, sa); + rd = ((uint32_t )tempB <<16 ) | (uint32_t ) tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrav_ph (target_ulong rs,target_ulong rt) +{ +uint8_t rs3_0; +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rs3_0 = rs &0x0F ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_rashift16 (rth, rs3_0); + tempA =mipsdsp_rashift16 (rtl, rs3_0); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shra_r_ph (uint32_t sa,target_ulong rt) +{ +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_rnd16_rashift (rth, sa); + tempA =mipsdsp_rnd16_rashift (rtl, sa); + rd = ((uint32_t )tempB <<16 ) | (uint32_t ) tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrav_r_ph (target_ulong rs,target_ulong rt) +{ +uint8_t rs3_0; +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rs3_0 = rs &0x0F ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_rnd16_rashift (rth, rs3_0); + tempA =mipsdsp_rnd16_rashift (rtl, rs3_0); + + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shra_r_w (uint32_t sa,target_ulong rt) +{ +uint32_t rd; + + rd =mipsdsp_rnd32_rashift (rt, sa); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrav_r_w (target_ulong rs,target_ulong rt) +{ +uint8_t rs4_0; +uint32_t rd; + + rs4_0 = rs &0x1F ; + rd =mipsdsp_rnd32_rashift (rt, rs4_0); + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_shra_qh (target_ulong rt,uint32_t sa) +{ +int32_t rt3, rt2, rt1, rt0; +uint32_t tempD, tempC, tempB, tempA; +uint64_t result; + + result =0 ; + sa = sa &0xF ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_rashift16 (rt3, sa); + tempC =mipsdsp_rashift16 (rt2, sa); + tempB =mipsdsp_rashift16 (rt1, sa); + tempA =mipsdsp_rashift16 (rt0, sa); + + result = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return result; +} + +target_ulong helper_shrav_qh (target_ulong rt,target_ulong sa) +{ +int32_t rt3, rt2, rt1, rt0; +uint32_t tempD, tempC, tempB, tempA; +uint64_t result; + + result =0 ; + sa = sa &0xF ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_rashift16 (rt3, sa); + tempC =mipsdsp_rashift16 (rt2, sa); + tempB =mipsdsp_rashift16 (rt1, sa); + tempA =mipsdsp_rashift16 (rt0, sa); + + result = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return result; +} + + +target_ulong helper_shra_r_qh (target_ulong rt,uint32_t sa) +{ +int32_t rt3, rt2, rt1, rt0; +uint32_t tempD, tempC, tempB, tempA; +uint64_t result; + + result =0 ; + sa = sa &0xF ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_rnd16_rashift (rt3, sa); + tempC =mipsdsp_rnd16_rashift (rt2, sa); + tempB =mipsdsp_rnd16_rashift (rt1, sa); + tempA =mipsdsp_rnd16_rashift (rt0, sa); + + result = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return result; +} + +target_ulong helper_shrav_r_qh (target_ulong rt,target_ulong sa) +{ +int32_t rt3, rt2, rt1, rt0; +uint32_t tempD, tempC, tempB, tempA; +uint64_t result; + + result =0 ; + sa = sa &0xF ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_rnd16_rashift (rt3, sa); + tempC =mipsdsp_rnd16_rashift (rt2, sa); + tempB =mipsdsp_rnd16_rashift (rt1, sa); + tempA =mipsdsp_rnd16_rashift (rt0, sa); + + result = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return result; +} + +target_ulong helper_shra_pw (target_ulong rt,uint32_t sa) +{ +int32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t result; + + result =0 ; + +/* FIXME, it seems like document error. */ + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_rashift32 (rt1, sa); + tempA =mipsdsp_rashift32 (rt0, sa); + + result = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return result; +} + +target_ulong helper_shrav_pw (target_ulong rt,target_ulong sa) +{ +int32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t result; + + result =0 ; + sa = sa &0x1F ; + +/* FIXME, it seems like document error. */ + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_rashift32 (rt1, sa); + tempA =mipsdsp_rashift32 (rt0, sa); + + result = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return result; +} + +target_ulong helper_shra_r_pw (target_ulong rt,uint32_t sa) +{ +int32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t result; + + result =0 ; + + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_rnd32_rashift (rt1, sa); + tempA =mipsdsp_rnd32_rashift (rt0, sa); + + result = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return result; +} + +target_ulong helper_shrav_r_pw (target_ulong rt,target_ulong sa) +{ +int32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t result; + + result =0 ; + sa = sa &0x1F ; + + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_rnd32_rashift (rt1, sa); + tempA =mipsdsp_rnd32_rashift (rt0, sa); + + result = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return result; +} +#endif +#undef MIPSDSP_LHI#undef MIPSDSP_LLO#undef MIPSDSP_HI
target-mips/helper.h +62 -0
66 lines not on this page · raw message
target-mips/translate.c +359 -0
389 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v7 07/14] target-mips-ase-dsp: Add GPR-based shift instructions
Quoted 8 lines · Jia Liu
Add MIPS ASE DSP GPR-Based Shift instructions.
Signed-off-by Jia Liu <[email protected]>--- target-mips/dsp_helper.c | 991 ++++++++++++++++++++++++++++++++++++++++++++++ target-mips/helper.h | 62 +++ target-mips/translate.c | 359 +++++++++++++++++ 3 files changed, 1412 insertions(+)
Quoted 1,475 lines
target-mips/dsp_helper.c +991
-0@@ -3196,6 +3196,997 @@ target_ulong helper_preceu_qh_obra(target_ulong rt) }#endif +/** DSP GPR-Based Shift Sub-class insns **/ +target_ulong helper_shll_qb (CPUMIPSState *env,uint32_t sa,target_ulong rt) +{ +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_lshift8 (env, rt3, sa); + tempC =mipsdsp_lshift8 (env, rt2, sa); + tempB =mipsdsp_lshift8 (env, rt1, sa); + tempA =mipsdsp_lshift8 (env, rt0, sa); + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | ((uint32_t )tempA); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shllv_qb (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs2_0; +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs2_0 = rs &0x07 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_lshift8 (env, rt3, rs2_0); + tempC =mipsdsp_lshift8 (env, rt2, rs2_0); + tempB =mipsdsp_lshift8 (env, rt1, rs2_0); + tempA =mipsdsp_lshift8 (env, rt0, rs2_0); + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_shll_ob (CPUMIPSState *env,target_ulong rt,uint32_t sa) +{ +int i; +uint8_t rt_t[8 ]; +uint8_t temp_t[8 ]; +uint64_t temp; + + sa = sa &0x07 ; + temp =0 ; + +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp_t[i] =mipsdsp_lshift8 (env, rt_t[i], sa); + + temp |= (uint64_t )temp_t[i] << (8 * i); + } + +return temp; +} + +target_ulong helper_shllv_ob (CPUMIPSState *env, +target_ulong rt,target_ulong sa) +{ +int i; +uint8_t rt_t[8 ]; +uint8_t temp_t[8 ]; +uint64_t temp; + + sa = sa &0x07 ; + temp =0 ; + +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp_t[i] =mipsdsp_lshift8 (env, rt_t[i], sa); + + temp |= (uint64_t )temp_t[i] << (8 * i); + } + +return temp; +} +#endif + +target_ulong helper_shll_ph (CPUMIPSState *env,uint32_t sa,target_ulong rt) +{ +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_lshift16 (env, rth, sa); + tempA =mipsdsp_lshift16 (env, rtl, sa); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shllv_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs3_0; +uint16_t rth, rtl, tempB, tempA; +uint32_t rd; + + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + rs3_0 = rs &0x0F ; + + tempB =mipsdsp_lshift16 (env, rth, rs3_0); + tempA =mipsdsp_lshift16 (env, rtl, rs3_0); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shll_s_ph (CPUMIPSState *env,uint32_t sa,target_ulong rt) +{ +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_sat16_lshift (env, rth, sa); + tempA =mipsdsp_sat16_lshift (env, rtl, sa); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shllv_s_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs3_0; +uint16_t rth, rtl, tempB, tempA; +uint32_t rd; + + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + rs3_0 = rs &0x0F ; + + tempB =mipsdsp_sat16_lshift (env, rth, rs3_0); + tempA =mipsdsp_sat16_lshift (env, rtl, rs3_0); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_shll_qh (CPUMIPSState *env,target_ulong rt,uint32_t sa) +{ +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + sa = sa &0x0F ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_lshift16 (env, rt3, sa); + tempC =mipsdsp_lshift16 (env, rt2, sa); + tempB =mipsdsp_lshift16 (env, rt1, sa); + tempA =mipsdsp_lshift16 (env, rt0, sa); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_shllv_qh (CPUMIPSState *env, +target_ulong rt,target_ulong sa) +{ +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + sa = sa &0x0F ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_lshift16 (env, rt3, sa); + tempC =mipsdsp_lshift16 (env, rt2, sa); + tempB =mipsdsp_lshift16 (env, rt1, sa); + tempA =mipsdsp_lshift16 (env, rt0, sa); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_shll_s_qh (CPUMIPSState *env,target_ulong rt,uint32_t sa) +{ +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + sa = sa &0x0F ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sat16_lshift (env, rt3, sa); + tempC =mipsdsp_sat16_lshift (env, rt2, sa); + tempB =mipsdsp_sat16_lshift (env, rt1, sa); + tempA =mipsdsp_sat16_lshift (env, rt0, sa); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_shllv_s_qh (CPUMIPSState *env, +target_ulong rt,target_ulong sa) +{ +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + sa = sa &0x0F ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sat16_lshift (env, rt3, sa); + tempC =mipsdsp_sat16_lshift (env, rt2, sa); + tempB =mipsdsp_sat16_lshift (env, rt1, sa); + tempA =mipsdsp_sat16_lshift (env, rt0, sa); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_shll_s_w (CPUMIPSState *env,uint32_t sa,target_ulong rt) +{ +uint32_t temp, rd; + + temp =mipsdsp_sat32_lshift (env, rt, sa); + rd = temp; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shllv_s_w (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs4_0; +uint32_t rd; + + rs4_0 = rs &0x1F ; + rd =mipsdsp_sat32_lshift (env, rt, rs4_0); + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_shll_pw (CPUMIPSState *env,target_ulong rt,uint32_t sa) +{ +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_lshift32 (env, rt1, sa); + tempA =mipsdsp_lshift32 (env, rt0, sa); + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_shllv_pw (CPUMIPSState *env, +target_ulong rt,target_ulong sa) +{ +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + sa = sa &0x1F ; + + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_lshift32 (env, rt1, sa); + tempA =mipsdsp_lshift32 (env, rt0, sa); + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_shll_s_pw (CPUMIPSState *env,target_ulong rt,uint32_t sa) +{ +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_sat32_lshift (env, rt1, sa); + tempA =mipsdsp_sat32_lshift (env, rt0, sa); + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_shllv_s_pw (CPUMIPSState *env, +target_ulong rt,target_ulong sa) +{ +uint32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t temp; + + sa = sa &0x1F ; + + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_sat32_lshift (env, rt1, sa); + tempA =mipsdsp_sat32_lshift (env, rt0, sa); + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_shrl_qb (uint32_t sa,target_ulong rt) +{ +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_rshift8 (rt3, sa); + tempC =mipsdsp_rshift8 (rt2, sa); + tempB =mipsdsp_rshift8 (rt1, sa); + tempA =mipsdsp_rshift8 (rt0, sa); + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrlv_qb (target_ulong rs,target_ulong rt) +{ +uint8_t rs2_0; +uint8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs2_0 = rs &0x07 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_rshift8 (rt3, rs2_0); + tempC =mipsdsp_rshift8 (rt2, rs2_0); + tempB =mipsdsp_rshift8 (rt1, rs2_0); + tempA =mipsdsp_rshift8 (rt0, rs2_0); + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrl_ph (uint32_t sa,target_ulong rt) +{ +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB = rth >> sa; + tempA = rtl >> sa; + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrlv_ph (target_ulong rs,target_ulong rt) +{ +uint8_t rs3_0; +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rs3_0 = rs &0x0F ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB = rth >> rs3_0; + tempA = rtl >> rs3_0; + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_shrl_ob (target_ulong rt,uint32_t sa) +{ +int i; +uint8_t rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + sa = sa &0x07 ; + result =0 ; + +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_rshift8 (rt_t[i], sa); + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_shrlv_ob (target_ulong rt,target_ulong sa) +{ +int i; +uint8_t rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + sa = sa &0x07 ; + result =0 ; + +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_rshift8 (rt_t[i], sa); + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_shrl_qh (target_ulong rt,uint32_t sa) +{ +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + sa = sa &0x0F ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD = rt3 >> sa; + tempC = rt2 >> sa; + tempB = rt1 >> sa; + tempA = rt0 >> sa; + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_shrlv_qh (target_ulong rt,target_ulong sa) +{ +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + sa = sa &0x0F ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD = rt3 >> sa; + tempC = rt2 >> sa; + tempB = rt1 >> sa; + tempA = rt0 >> sa; + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_shra_qb (uint32_t sa,target_ulong rt) +{ +int8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD = rt3 >> sa; + tempC = rt2 >> sa; + tempB = rt1 >> sa; + tempA = rt0 >> sa; + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shra_r_qb (uint32_t sa,target_ulong rt) +{ +int8_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + +if (sa ==0 ) { + tempD = rt3 &0x00FF ; + tempC = rt2 &0x00FF ; + tempB = rt1 &0x00FF ; + tempA = rt0 &0x00FF ; + }else { + tempD = ((int16_t )rt3 >> (sa -1 )) +1 ; + tempC = ((int16_t )rt2 >> (sa -1 )) +1 ; + tempB = ((int16_t )rt1 >> (sa -1 )) +1 ; + tempA = ((int16_t )rt0 >> (sa -1 )) +1 ; + } + + rd = ((uint32_t )((tempD >>1 ) &0x00FF ) <<24 ) | + ((uint32_t )((tempC >>1 ) &0x00FF ) <<16 ) | + ((uint32_t )((tempB >>1 ) &0x00FF ) <<8 ) | + (uint32_t )((tempA >>1 ) &0x00FF ) ; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrav_qb (target_ulong rs,target_ulong rt) +{ +uint8_t rs2_0; +int8_t rt3, rt2, rt1, rt0; +uint8_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs2_0 = rs &0x07 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + +if (rs2_0 ==0 ) { + tempD = rt3; + tempC = rt2; + tempB = rt1; + tempA = rt0; + }else { + tempD = rt3 >> rs2_0; + tempC = rt2 >> rs2_0; + tempB = rt1 >> rs2_0; + tempA = rt0 >> rs2_0; + } + + rd = ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrav_r_qb (target_ulong rs,target_ulong rt) +{ +uint8_t rs2_0; +int8_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint32_t rd; + + rs2_0 = rs &0x07 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = rt &MIPSDSP_Q0 ; + +if (rs2_0 ==0 ) { + tempD = (int16_t )rt3 <<1 ; + tempC = (int16_t )rt2 <<1 ; + tempB = (int16_t )rt1 <<1 ; + tempA = (int16_t )rt0 <<1 ; + }else { + tempD = ((int16_t )rt3 >> (rs2_0 -1 )) +1 ; + tempC = ((int16_t )rt2 >> (rs2_0 -1 )) +1 ; + tempB = ((int16_t )rt1 >> (rs2_0 -1 )) +1 ; + tempA = ((int16_t )rt0 >> (rs2_0 -1 )) +1 ; + } + + rd = ((uint32_t )((tempD >>1 ) &0x00FF ) <<24 ) | + ((uint32_t )((tempC >>1 ) &0x00FF ) <<16 ) | + ((uint32_t )((tempB >>1 ) &0x00FF ) <<8 ) | + (uint32_t )((tempA >>1 ) &0x00FF ) ; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_shra_ob (target_ulong rt,uint32_t sa) +{ +int i; +int8_t rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + sa = sa &0x07 ; + +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] = rt_t[i] >> sa; + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_shrav_ob (target_ulong rt,target_ulong sa) +{ +int i; +int8_t rt_t[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + sa = sa &0x07 ; + +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] = rt_t[i] >> sa; + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_shra_r_ob (target_ulong rt,uint32_t sa) +{ +int i; +int8_t rt_t[8 ]; +int16_t rt_t_S[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + sa = sa &0x07 ; + +if (sa ==0 ) { + result = rt; + }else { +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + rt_t_S[i] = ((int16_t )rt_t[i] >> (sa -1 )) +1 ; + temp[i] = (rt_t_S[i] >>1 ) &MIPSDSP_Q0 ; + result |= (uint64_t )temp[i] << (8 * i); + } + } + +return result; +} + +target_ulong helper_shrav_r_ob (target_ulong rt,target_ulong sa) +{ +int i; +int8_t rt_t[8 ]; +int16_t rt_t_S[8 ]; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + sa = sa &0x07 ; + +if (sa ==0 ) { + result = rt; + }else { +for (i =0 ; i <8 ; i++) { + rt_t[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + rt_t_S[i] = ((int16_t )rt_t[i] >> (sa -1 )) +1 ; + temp[i] = (rt_t_S[i] >>1 ) &MIPSDSP_Q0 ; + result |= (uint64_t )temp[i] << (8 * i); + } + } + +return result; +} +#endif + +target_ulong helper_shra_ph (uint32_t sa,target_ulong rt) +{ +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_rashift16 (rth, sa); + tempA =mipsdsp_rashift16 (rtl, sa); + rd = ((uint32_t )tempB <<16 ) | (uint32_t ) tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrav_ph (target_ulong rs,target_ulong rt) +{ +uint8_t rs3_0; +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rs3_0 = rs &0x0F ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_rashift16 (rth, rs3_0); + tempA =mipsdsp_rashift16 (rtl, rs3_0); + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shra_r_ph (uint32_t sa,target_ulong rt) +{ +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_rnd16_rashift (rth, sa); + tempA =mipsdsp_rnd16_rashift (rtl, sa); + rd = ((uint32_t )tempB <<16 ) | (uint32_t ) tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrav_r_ph (target_ulong rs,target_ulong rt) +{ +uint8_t rs3_0; +uint16_t rth, rtl; +uint16_t tempB, tempA; +uint32_t rd; + + rs3_0 = rs &0x0F ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_rnd16_rashift (rth, rs3_0); + tempA =mipsdsp_rnd16_rashift (rtl, rs3_0); + + rd = ((uint32_t )tempB <<16 ) | (uint32_t )tempA; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shra_r_w (uint32_t sa,target_ulong rt) +{ +uint32_t rd; + + rd =mipsdsp_rnd32_rashift (rt, sa); + +return (target_long )(int32_t )rd; +} + +target_ulong helper_shrav_r_w (target_ulong rs,target_ulong rt) +{ +uint8_t rs4_0; +uint32_t rd; + + rs4_0 = rs &0x1F ; + rd =mipsdsp_rnd32_rashift (rt, rs4_0); + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_shra_qh (target_ulong rt,uint32_t sa) +{ +int32_t rt3, rt2, rt1, rt0; +uint32_t tempD, tempC, tempB, tempA; +uint64_t result; + + result =0 ; + sa = sa &0xF ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_rashift16 (rt3, sa); + tempC =mipsdsp_rashift16 (rt2, sa); + tempB =mipsdsp_rashift16 (rt1, sa); + tempA =mipsdsp_rashift16 (rt0, sa); + + result = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return result; +} + +target_ulong helper_shrav_qh (target_ulong rt,target_ulong sa) +{ +int32_t rt3, rt2, rt1, rt0; +uint32_t tempD, tempC, tempB, tempA; +uint64_t result; + + result =0 ; + sa = sa &0xF ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_rashift16 (rt3, sa); + tempC =mipsdsp_rashift16 (rt2, sa); + tempB =mipsdsp_rashift16 (rt1, sa); + tempA =mipsdsp_rashift16 (rt0, sa); + + result = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return result; +} + + +target_ulong helper_shra_r_qh (target_ulong rt,uint32_t sa) +{ +int32_t rt3, rt2, rt1, rt0; +uint32_t tempD, tempC, tempB, tempA; +uint64_t result; + + result =0 ; + sa = sa &0xF ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_rnd16_rashift (rt3, sa); + tempC =mipsdsp_rnd16_rashift (rt2, sa); + tempB =mipsdsp_rnd16_rashift (rt1, sa); + tempA =mipsdsp_rnd16_rashift (rt0, sa); + + result = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return result; +} + +target_ulong helper_shrav_r_qh (target_ulong rt,target_ulong sa) +{ +int32_t rt3, rt2, rt1, rt0; +uint32_t tempD, tempC, tempB, tempA; +uint64_t result; + + result =0 ; + sa = sa &0xF ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_rnd16_rashift (rt3, sa); + tempC =mipsdsp_rnd16_rashift (rt2, sa); + tempB =mipsdsp_rnd16_rashift (rt1, sa); + tempA =mipsdsp_rnd16_rashift (rt0, sa); + + result = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return result; +} + +target_ulong helper_shra_pw (target_ulong rt,uint32_t sa) +{ +int32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t result; + + result =0 ; + +/* FIXME, it seems like document error. */ + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_rashift32 (rt1, sa); + tempA =mipsdsp_rashift32 (rt0, sa); + + result = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return result; +} + +target_ulong helper_shrav_pw (target_ulong rt,target_ulong sa) +{ +int32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t result; + + result =0 ; + sa = sa &0x1F ; + +/* FIXME, it seems like document error. */ + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_rashift32 (rt1, sa); + tempA =mipsdsp_rashift32 (rt0, sa); + + result = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return result; +} + +target_ulong helper_shra_r_pw (target_ulong rt,uint32_t sa) +{ +int32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t result; + + result =0 ; + + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_rnd32_rashift (rt1, sa); + tempA =mipsdsp_rnd32_rashift (rt0, sa); + + result = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return result; +} + +target_ulong helper_shrav_r_pw (target_ulong rt,target_ulong sa) +{ +int32_t rt1, rt0; +uint32_t tempB, tempA; +uint64_t result; + + result =0 ; + sa = sa &0x1F ; + + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB =mipsdsp_rnd32_rashift (rt1, sa); + tempA =mipsdsp_rnd32_rashift (rt0, sa); + + result = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return result; +} +#endif +#undef MIPSDSP_LHI#undef MIPSDSP_LLO#undef MIPSDSP_HItarget-mips/helper.h +62
-0@@ -429,4 +429,66 @@ DEF_HELPER_FLAGS_1(preceu_qh_obla, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) DEF_HELPER_FLAGS_1(preceu_qh_obra, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl)#endif +/* DSP GPR-Based Shift Sub-class insns */ +DEF_HELPER_FLAGS_3(shll_qb, 0, tl, env, i32, tl) +DEF_HELPER_FLAGS_3(shllv_qb, 0, tl, env, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(shll_ob, 0, tl, env, tl, i32) +DEF_HELPER_FLAGS_3(shllv_ob, 0, tl, env, tl, tl) +#endif +DEF_HELPER_FLAGS_3(shll_ph, 0, tl, env, i32, tl) +DEF_HELPER_FLAGS_3(shllv_ph, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(shll_s_ph, 0, tl, env, i32, tl) +DEF_HELPER_FLAGS_3(shllv_s_ph, 0, tl, env, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(shll_qh, 0, tl, env, tl, i32) +DEF_HELPER_FLAGS_3(shllv_qh, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(shll_s_qh, 0, tl, env, tl, i32) +DEF_HELPER_FLAGS_3(shllv_s_qh, 0, tl, env, tl, tl) +#endif +DEF_HELPER_FLAGS_3(shll_s_w, 0, tl, env, i32, tl) +DEF_HELPER_FLAGS_3(shllv_s_w, 0, tl, env, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(shll_pw, 0, tl, env, tl, i32) +DEF_HELPER_FLAGS_3(shllv_pw, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(shll_s_pw, 0, tl, env, tl, i32) +DEF_HELPER_FLAGS_3(shllv_s_pw, 0, tl, env, tl, tl) +#endif +DEF_HELPER_FLAGS_2(shrl_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, i32, tl) +DEF_HELPER_FLAGS_2(shrlv_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(shrl_ph, TCG_CALL_CONST | TCG_CALL_PURE, tl, i32, tl) +DEF_HELPER_FLAGS_2(shrlv_ph, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_2(shrl_ob, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, i32) +DEF_HELPER_FLAGS_2(shrlv_ob, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(shrl_qh, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, i32) +DEF_HELPER_FLAGS_2(shrlv_qh, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +#endif +DEF_HELPER_FLAGS_2(shra_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, i32, tl) +DEF_HELPER_FLAGS_2(shra_r_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, i32, tl) +DEF_HELPER_FLAGS_2(shrav_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(shrav_r_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_2(shra_ob, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, i32) +DEF_HELPER_FLAGS_2(shrav_ob, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(shra_r_ob, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, i32) +DEF_HELPER_FLAGS_2(shrav_r_ob, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +#endif +DEF_HELPER_FLAGS_2(shra_ph, TCG_CALL_CONST | TCG_CALL_PURE, tl, i32, tl) +DEF_HELPER_FLAGS_2(shrav_ph, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(shra_r_ph, TCG_CALL_CONST | TCG_CALL_PURE, tl, i32, tl) +DEF_HELPER_FLAGS_2(shrav_r_ph, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(shra_r_w, TCG_CALL_CONST | TCG_CALL_PURE, tl, i32, tl) +DEF_HELPER_FLAGS_2(shrav_r_w, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_2(shra_qh, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, i32) +DEF_HELPER_FLAGS_2(shrav_qh, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(shra_r_qh, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, i32) +DEF_HELPER_FLAGS_2(shrav_r_qh, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(shra_pw, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, i32) +DEF_HELPER_FLAGS_2(shrav_pw, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(shra_r_pw, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, i32) +DEF_HELPER_FLAGS_2(shrav_r_pw, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +#endif +#include "def-helper.h" target-mips/translate.c +359
-0@@ -331,6 +331,18 @@ enum {#if defined(TARGET_MIPS64 ) OPC_CMPU_EQ_OB_DSP = 0x15 | OPC_SPECIAL3, #endif + /* MIPS DSP GPR-Based Shift Sub-class */ + OPC_SHLL_QB_DSP = 0x13 | OPC_SPECIAL3, +#if defined(TARGET_MIPS64) + OPC_SHLL_OB_DSP = 0x17 | OPC_SPECIAL3, +#endif +/* MIPS DSP Multiply Sub-class insns */ +/* OPC_MUL_PH_DSP is same as OPC_ADDUH_QB_DSP. */ +/* OPC_MUL_PH_DSP = 0x18 | OPC_SPECIAL3, */ + OPC_DPA_W_PH_DSP = 0x30 | OPC_SPECIAL3, +#if defined(TARGET_MIPS64 ) + OPC_DPAQ_W_QH_DSP = 0x34 | OPC_SPECIAL3, +#endif };/* BSHFL opcodes */ @@ -439,6 +451,32 @@ enum {OPC_PRECRQ_RS_PH_W = (0x15 <<6 ) |OPC_CMPU_EQ_QB_DSP , OPC_PRECRQU_S_QB_PH = (0x0F << 6) | OPC_CMPU_EQ_QB_DSP, }; +#define MASK_SHLL_QB (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* MIPS DSP GPR-Based Shift Sub-class */ +OPC_SHLL_QB = (0x00 <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHLLV_QB = (0x02 <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHLL_PH = (0x08 <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHLLV_PH = (0x0A <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHLL_S_PH = (0x0C <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHLLV_S_PH = (0x0E <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHLL_S_W = (0x14 <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHLLV_S_W = (0x16 <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHRL_QB = (0x01 <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHRLV_QB = (0x03 <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHRL_PH = (0x19 <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHRLV_PH = (0x1B <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHRA_QB = (0x04 <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHRA_R_QB = (0x05 <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHRAV_QB = (0x06 <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHRAV_R_QB = (0x07 <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHRA_PH = (0x09 <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHRAV_PH = (0x0B <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHRA_R_PH = (0x0D <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHRAV_R_PH = (0x0F <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHRA_R_W = (0x15 <<6 ) |OPC_SHLL_QB_DSP , +OPC_SHRAV_R_W = (0x17 <<6 ) |OPC_SHLL_QB_DSP , +};#if defined(TARGET_MIPS64 )#define MASK_ABSQ_S_QH (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))@@ -507,6 +545,39 @@ enum { };#endif +#if defined(TARGET_MIPS64 ) +#define MASK_SHLL_OB (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* MIPS DSP GPR-Based Shift Sub-class */ +OPC_SHLL_PW = (0x10 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHLL_S_PW = (0x14 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHLLV_OB = (0x02 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHLLV_PW = (0x12 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHLLV_S_PW = (0x16 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHLLV_QH = (0x0A <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHLLV_S_QH = (0x0E <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRA_PW = (0x11 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRA_R_PW = (0x15 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRAV_OB = (0x06 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRAV_R_OB = (0x07 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRAV_PW = (0x13 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRAV_R_PW = (0x17 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRAV_QH = (0x0B <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRAV_R_QH = (0x0F <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRLV_OB = (0x03 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRLV_QH = (0x1B <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHLL_OB = (0x00 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHLL_QH = (0x08 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHLL_S_QH = (0x0C <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRA_OB = (0x04 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRA_R_OB = (0x05 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRA_QH = (0x09 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRA_R_QH = (0x0D <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRL_OB = (0x01 <<6 ) |OPC_SHLL_OB_DSP , +OPC_SHRL_QH = (0x19 <<6 ) |OPC_SHLL_OB_DSP , +}; +#endif +/* Coprocessor 0 (rs field) */ #define MASK_CP0 (op) MASK_OP_MAJOR(op) | (op & (0x1F << 21))@@ -12660,6 +12731,117 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)break ; }break ; +case OPC_SHLL_QB_DSP : + { +TCGv_i32 temp_rs =tcg_const_i32 (rs); + op2 =MASK_SHLL_QB (ctx->opcode); +switch (op2) { +case OPC_SHLL_QB : +check_dsp (ctx); +gen_helper_shll_qb (cpu_gpr[rd], cpu_env, + temp_rs, cpu_gpr[rt]); +break ; +case OPC_SHLLV_QB : +check_dsp (ctx); +gen_helper_shllv_qb (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SHLL_PH : +check_dsp (ctx); +gen_helper_shll_ph (cpu_gpr[rd], cpu_env, + temp_rs, cpu_gpr[rt]); +break ; +case OPC_SHLLV_PH : +check_dsp (ctx); +gen_helper_shllv_ph (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SHLL_S_PH : +check_dsp (ctx); +gen_helper_shll_s_ph (cpu_gpr[rd], cpu_env, + temp_rs, cpu_gpr[rt]); +break ; +case OPC_SHLLV_S_PH : +check_dsp (ctx); +gen_helper_shllv_s_ph (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SHLL_S_W : +check_dsp (ctx); +gen_helper_shll_s_w (cpu_gpr[rd], cpu_env, + temp_rs, cpu_gpr[rt]); +break ; +case OPC_SHLLV_S_W : +check_dsp (ctx); +gen_helper_shllv_s_w (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SHRL_QB : +check_dsp (ctx); +gen_helper_shrl_qb (cpu_gpr[rd], temp_rs, cpu_gpr[rt]); +break ; +case OPC_SHRLV_QB : +check_dsp (ctx); +gen_helper_shrlv_qb (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SHRL_PH : +check_dspr2 (ctx); +gen_helper_shrl_ph (cpu_gpr[rd], temp_rs, cpu_gpr[rt]); +break ; +case OPC_SHRLV_PH : +check_dspr2 (ctx); +gen_helper_shrlv_ph (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SHRA_QB : +check_dspr2 (ctx); +gen_helper_shra_qb (cpu_gpr[rd], temp_rs, cpu_gpr[rt]); +break ; +case OPC_SHRA_R_QB : +check_dspr2 (ctx); +gen_helper_shra_r_qb (cpu_gpr[rd], temp_rs, cpu_gpr[rt]); +break ; +case OPC_SHRAV_QB : +check_dspr2 (ctx); +gen_helper_shrav_qb (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SHRAV_R_QB : +check_dspr2 (ctx); +gen_helper_shrav_r_qb (cpu_gpr[rd], cpu_gpr[rs], + cpu_gpr[rt]); +break ; +case OPC_SHRA_PH : +check_dsp (ctx); +gen_helper_shra_ph (cpu_gpr[rd], temp_rs, cpu_gpr[rt]); +break ; +case OPC_SHRA_R_PH : +check_dsp (ctx); +gen_helper_shra_r_ph (cpu_gpr[rd], temp_rs, cpu_gpr[rt]); +break ; +case OPC_SHRAV_PH : +check_dsp (ctx); +gen_helper_shrav_ph (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_SHRAV_R_PH : +check_dsp (ctx); +gen_helper_shrav_r_ph (cpu_gpr[rd], cpu_gpr[rs], + cpu_gpr[rt]); +break ; +case OPC_SHRA_R_W : +check_dsp (ctx); +gen_helper_shra_r_w (cpu_gpr[rd], temp_rs, cpu_gpr[rt]); +break ; +case OPC_SHRAV_R_W : +check_dsp (ctx); +gen_helper_shrav_r_w (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK SHLL.QB" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +tcg_temp_free_i32 (temp_rs); +break ; + }#if defined(TARGET_MIPS64 ) case OPC_DEXTM ... OPC_DEXT: case OPC_DINSM ... OPC_DINS:@@ -12929,6 +13111,183 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) }break ;#endif +#if defined(TARGET_MIPS64 ) +case OPC_SHLL_OB_DSP : + op2 =MASK_SHLL_OB (ctx->opcode); +switch (op2) { +case OPC_SHLL_PW : +check_dsp (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (rs); +gen_helper_shll_pw (cpu_gpr[rd], cpu_env, + cpu_gpr[rt], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_SHLLV_PW : +check_dsp (ctx); +gen_helper_shllv_pw (cpu_gpr[rd], cpu_env, + cpu_gpr[rt], cpu_gpr[rs]); +break ; +case OPC_SHLL_S_PW : +check_dsp (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (rs); +gen_helper_shll_s_pw (cpu_gpr[rd], cpu_env, + cpu_gpr[rt], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_SHLLV_S_PW : +check_dsp (ctx); +gen_helper_shllv_s_pw (cpu_gpr[rd], cpu_env, + cpu_gpr[rt], cpu_gpr[rs]); +break ; +case OPC_SHLL_OB : +check_dsp (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (rs); +gen_helper_shll_ob (cpu_gpr[rd], cpu_env, + cpu_gpr[rt], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_SHLLV_OB : +check_dsp (ctx); +gen_helper_shllv_ob (cpu_gpr[rd], cpu_env, + cpu_gpr[rt], cpu_gpr[rs]); +break ; +case OPC_SHLL_QH : +check_dsp (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (rs); +gen_helper_shll_qh (cpu_gpr[rd], cpu_env, + cpu_gpr[rt], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_SHLLV_QH : +check_dsp (ctx); +gen_helper_shllv_qh (cpu_gpr[rd], cpu_env, + cpu_gpr[rt], cpu_gpr[rs]); +break ; +case OPC_SHLL_S_QH : +check_dsp (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (rs); +gen_helper_shll_s_qh (cpu_gpr[rd], cpu_env, + cpu_gpr[rt], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_SHLLV_S_QH : +check_dsp (ctx); +gen_helper_shllv_s_qh (cpu_gpr[rd], cpu_env, + cpu_gpr[rt], cpu_gpr[rs]); +break ; +case OPC_SHRA_OB : +check_dspr2 (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (rs); +gen_helper_shra_ob (cpu_gpr[rd], cpu_gpr[rt], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_SHRAV_OB : +check_dspr2 (ctx); +gen_helper_shrav_ob (cpu_gpr[rd], cpu_gpr[rt], cpu_gpr[rs]); +break ; +case OPC_SHRA_R_OB : +check_dspr2 (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (rs); +gen_helper_shra_r_ob (cpu_gpr[rd], cpu_gpr[rt], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_SHRAV_R_OB : +check_dspr2 (ctx); +gen_helper_shrav_r_ob (cpu_gpr[rd], cpu_gpr[rt], cpu_gpr[rs]); +break ; +case OPC_SHRA_PW : +check_dsp (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (rs); +gen_helper_shra_pw (cpu_gpr[rd], cpu_gpr[rt], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_SHRAV_PW : +check_dsp (ctx); +gen_helper_shrav_pw (cpu_gpr[rd], cpu_gpr[rt], cpu_gpr[rs]); +break ; +case OPC_SHRA_R_PW : +check_dsp (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (rs); +gen_helper_shra_r_pw (cpu_gpr[rd], cpu_gpr[rt], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_SHRAV_R_PW : +check_dsp (ctx); +gen_helper_shrav_r_pw (cpu_gpr[rd], cpu_gpr[rt], cpu_gpr[rs]); +break ; +case OPC_SHRA_QH : +check_dsp (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (rs); +gen_helper_shra_qh (cpu_gpr[rd], cpu_gpr[rt], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_SHRAV_QH : +check_dsp (ctx); +gen_helper_shrav_qh (cpu_gpr[rd], cpu_gpr[rt], cpu_gpr[rs]); +break ; +case OPC_SHRA_R_QH : +check_dsp (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (rs); +gen_helper_shra_r_qh (cpu_gpr[rd], cpu_gpr[rt], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_SHRAV_R_QH : +check_dsp (ctx); +gen_helper_shrav_r_qh (cpu_gpr[rd], cpu_gpr[rt], cpu_gpr[rs]); +break ; +case OPC_SHRL_OB : +check_dsp (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (rs); +gen_helper_shrl_ob (cpu_gpr[rd], cpu_gpr[rt], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_SHRLV_OB : +check_dsp (ctx); +gen_helper_shrlv_ob (cpu_gpr[rd], cpu_gpr[rt], cpu_gpr[rs]); +break ; +case OPC_SHRL_QH : +check_dspr2 (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (rs); +gen_helper_shrl_qh (cpu_gpr[rd], cpu_gpr[rt], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_SHRLV_QH : +check_dspr2 (ctx); +gen_helper_shrlv_qh (cpu_gpr[rd], cpu_gpr[rt], cpu_gpr[rs]); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK SHLL.OB" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ; +#endif default :/* Invalid */ MIPS_INVAL ("special3" );generate_exception (ctx,EXCP_RI );Signature · 1 line
1.7.9.5
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v7 8/14 target-mips-ase-dsp: Add multiply instructions
In reply to Jia LiuAdd MIPS ASE DSP Multiply instructions.
--- target-mips/dsp_helper.c | 2024 ++++++++++++++++++++++++++++++++++++++++++++++ target-mips/helper.h | 91 +++ target-mips/translate.c | 503 ++++++++++++ 3 files changed, 2618 insertions(+)
target-mips/dsp_helper.c +2024 -0
@@ -4187,6 +4187,2030 @@ target_ulong helper_shrav_r_pw(target_ulong rt, target_ulong sa) }#endif +/** DSP Multiply Sub-class insns **/ +target_ulong helper_muleu_s_ph_qbl (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2; +uint16_t tempB, tempA, rth, rtl; +uint32_t temp; +uint32_t rd; + + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_mul_u8_u16 (env, rs3, rth); + tempA =mipsdsp_mul_u8_u16 (env, rs2, rtl); + temp = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); + rd = temp; +return (target_long )(int32_t )rd; +} + +target_ulong helper_muleu_s_ph_qbr (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs1, rs0; +uint16_t tempB, tempA; +uint16_t rth, rtl; +uint32_t temp; +uint32_t rd; + + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs0 = rs &MIPSDSP_Q0 ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_u8_u16 (env, rs1, rth); + tempA =mipsdsp_mul_u8_u16 (env, rs0, rtl); + temp = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); + rd = temp; +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_muleu_s_qh_obl (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>56 ) &MIPSDSP_Q0 ; + rs2 = (rs >>48 ) &MIPSDSP_Q0 ; + rs1 = (rs >>40 ) &MIPSDSP_Q0 ; + rs0 = (rs >>32 ) &MIPSDSP_Q0 ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_mul_u8_u16 (env, rs3, rt3); + tempC =mipsdsp_mul_u8_u16 (env, rs2, rt2); + tempB =mipsdsp_mul_u8_u16 (env, rs1, rt1); + tempA =mipsdsp_mul_u8_u16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; +return temp; +} + +target_ulong helper_muleu_s_qh_obr (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>24 ) &MIPSDSP_Q0 ; + rs2 = (rs >>16 ) &MIPSDSP_Q0 ; + rs1 = (rs >>8 ) &MIPSDSP_Q0 ; + rs0 = rs &MIPSDSP_Q0 ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_mul_u8_u16 (env, rs3, rt3); + tempC =mipsdsp_mul_u8_u16 (env, rs2, rt2); + tempB =mipsdsp_mul_u8_u16 (env, rs1, rt1); + tempA =mipsdsp_mul_u8_u16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_mulq_rs_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int16_t tempB, tempA, rsh, rsl, rth, rtl; +int32_t temp; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_rndq15_mul_q15_q15 (env, rsh, rth); + tempA =mipsdsp_rndq15_mul_q15_q15 (env, rsl, rtl); + temp = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); + rd = temp; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_mulq_rs_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_rndq15_mul_q15_q15 (env, rs3, rt3); + tempC =mipsdsp_rndq15_mul_q15_q15 (env, rs2, rt2); + tempB =mipsdsp_rndq15_mul_q15_q15 (env, rs1, rt1); + tempA =mipsdsp_rndq15_mul_q15_q15 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; +return temp; +} +#endif + +target_ulong helper_muleq_s_w_phl (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int16_t rsh, rth; +int32_t temp; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rth = (rt &MIPSDSP_HI ) >>16 ; + temp =mipsdsp_mul_q15_q15_overflowflag21 (env, rsh, rth); + rd = temp; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_muleq_s_w_phr (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int16_t rsl, rtl; +int32_t temp; +uint32_t rd; + + rsl = rs &MIPSDSP_LO ; + rtl = rt &MIPSDSP_LO ; + temp =mipsdsp_mul_q15_q15_overflowflag21 (env, rsl, rtl); + rd = temp; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_muleq_s_pw_qhl (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rsB, rsA; +uint16_t rtB, rtA; +uint32_t tempB, tempA; +uint64_t temp; + + rsB = (rs >>48 ) &MIPSDSP_LO ; + rsA = (rs >>32 ) &MIPSDSP_LO ; + rtB = (rt >>48 ) &MIPSDSP_LO ; + rtA = (rt >>32 ) &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env,5 , rsB, rtB); + tempA =mipsdsp_mul_q15_q15 (env,5 , rsA, rtA); + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_muleq_s_pw_qhr (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rsB, rsA; +uint16_t rtB, rtA; +uint32_t tempB, tempA; +uint64_t temp; + + rsB = (rs >>16 ) &MIPSDSP_LO ; + rsA = rs &MIPSDSP_LO ; + rtB = (rt >>16 ) &MIPSDSP_LO ; + rtA = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env,5 , rsB, rtB); + tempA =mipsdsp_mul_q15_q15 (env,5 , rsA, rtA); + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} +#endif + +void helper_dpau_h_qbl (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2; +uint8_t rt3, rt2; +uint16_t tempB, tempA; +uint64_t tempC, tempBL, tempAL, dotp; + + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + tempB =mipsdsp_mul_u8_u8 (rs3, rt3); + tempA =mipsdsp_mul_u8_u8 (rs2, rt2); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + tempC = (((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO )) + dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempC &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempC &MIPSDSP_LLO ); +} + +void helper_dpau_h_qbr (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint8_t rs1, rs0; +uint8_t rt1, rt0; +uint16_t tempB, tempA; +uint64_t tempC, tempBL, tempAL, dotp; + + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rs0 = (rs &MIPSDSP_Q0 ); + rt0 = (rt &MIPSDSP_Q0 ); + tempB =mipsdsp_mul_u8_u8 (rs1, rt1); + tempA =mipsdsp_mul_u8_u8 (rs0, rt0); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + tempC = (((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO )) + dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempC &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempC &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dpau_h_obl (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +uint8_t rs7, rs6, rs5, rs4; +uint8_t rt7, rt6, rt5, rt4; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp[2 ]; +uint64_t acc[2 ]; +uint64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs7 = (rs >>56 ) &MIPSDSP_Q0 ; + rs6 = (rs >>48 ) &MIPSDSP_Q0 ; + rs5 = (rs >>40 ) &MIPSDSP_Q0 ; + rs4 = (rs >>32 ) &MIPSDSP_Q0 ; + rt7 = (rt >>56 ) &MIPSDSP_Q0 ; + rt6 = (rt >>48 ) &MIPSDSP_Q0 ; + rt5 = (rt >>40 ) &MIPSDSP_Q0 ; + rt4 = (rt >>32 ) &MIPSDSP_Q0 ; + + tempD =mipsdsp_mul_u8_u8 (rs7, rt7); + tempC =mipsdsp_mul_u8_u8 (rs6, rt6); + tempB =mipsdsp_mul_u8_u8 (rs5, rt5); + tempA =mipsdsp_mul_u8_u8 (rs4, rt4); + + temp[0 ] = (uint64_t )tempD + (uint64_t )tempC + + (uint64_t )tempB + (uint64_t )tempA; + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; + +if (temp_sum < acc[0 ] && temp_sum < temp[0 ]) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} + +void helper_dpau_h_obr (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +uint8_t rs3, rs2, rs1, rs0; +uint8_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp[2 ]; +uint64_t acc[2 ]; +uint64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs3 = (rs >>24 ) &MIPSDSP_Q0 ; + rs2 = (rs >>16 ) &MIPSDSP_Q0 ; + rs1 = (rs >>8 ) &MIPSDSP_Q0 ; + rs0 = rs &MIPSDSP_Q0 ; + rt3 = (rt >>24 ) &MIPSDSP_Q0 ; + rt2 = (rt >>16 ) &MIPSDSP_Q0 ; + rt1 = (rt >>8 ) &MIPSDSP_Q0 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_mul_u8_u8 (rs3, rt3); + tempC =mipsdsp_mul_u8_u8 (rs2, rt2); + tempB =mipsdsp_mul_u8_u8 (rs1, rt1); + tempA =mipsdsp_mul_u8_u8 (rs0, rt0); + + temp[0 ] = (uint64_t )tempD + (uint64_t )tempC + + (uint64_t )tempB + (uint64_t )tempA; + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; + +if (temp_sum < acc[0 ] && temp_sum < temp[0 ]) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} +#endif + +void helper_dpsu_h_qbl (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2, rt3, rt2; +uint16_t tempB, tempA; +uint64_t dotp, tempBL, tempAL, tempC; + + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + + tempB =mipsdsp_mul_u8_u8 (rs3, rt3); + tempA =mipsdsp_mul_u8_u8 (rs2, rt2); + tempBL = tempB &0xFFFF ; + tempAL = tempA &0xFFFF ; + + dotp = tempBL + tempAL; + tempC = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempC -= dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempC &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempC &MIPSDSP_LLO ); +} + +void helper_dpsu_h_qbr (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint8_t rs1, rs0, rt1, rt0; +uint16_t tempB, tempA; +uint64_t dotp, tempBL, tempAL, tempC; + + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs0 = (rs &MIPSDSP_Q0 ); + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = (rt &MIPSDSP_Q0 ); + + tempB =mipsdsp_mul_u8_u8 (rs1, rt1); + tempA =mipsdsp_mul_u8_u8 (rs0, rt0); + tempBL = tempB &0xFFFF ; + tempAL = tempA &0xFFFF ; + + dotp = tempBL + tempAL; + tempC = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempC -= dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempC &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempC &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dpsu_h_obl (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +uint8_t rs7, rs6, rs5, rs4; +uint8_t rt7, rt6, rt5, rt4; +uint16_t tempD, tempC, tempB, tempA; +uint64_t acc[2 ]; +uint64_t temp[2 ]; +uint64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs7 = (rs >>56 ) &MIPSDSP_Q0 ; + rs6 = (rs >>48 ) &MIPSDSP_Q0 ; + rs5 = (rs >>40 ) &MIPSDSP_Q0 ; + rs4 = (rs >>32 ) &MIPSDSP_Q0 ; + rt7 = (rt >>56 ) &MIPSDSP_Q0 ; + rt6 = (rt >>48 ) &MIPSDSP_Q0 ; + rt5 = (rt >>40 ) &MIPSDSP_Q0 ; + rt4 = (rt >>32 ) &MIPSDSP_Q0 ; + + tempD =mipsdsp_mul_u8_u8 (rs7, rt7); + tempC =mipsdsp_mul_u8_u8 (rs6, rt6); + tempB =mipsdsp_mul_u8_u8 (rs5, rt5); + tempA =mipsdsp_mul_u8_u8 (rs4, rt4); + + temp[0 ] = (uint64_t )tempD + (uint64_t )tempC + + (uint64_t )tempB + (uint64_t )tempA; + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] - temp[0 ]; +if (temp_sum > acc[0 ]) { + acc[1 ] -=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] -= temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_dpsu_h_obr (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +uint8_t rs3, rs2, rs1, rs0; +uint8_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t acc[2 ]; +uint64_t temp[2 ]; +uint64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs3 = (rs >>24 ) &MIPSDSP_Q0 ; + rs2 = (rs >>16 ) &MIPSDSP_Q0 ; + rs1 = (rs >>8 ) &MIPSDSP_Q0 ; + rs0 = rs &MIPSDSP_Q0 ; + rt3 = (rt >>24 ) &MIPSDSP_Q0 ; + rt2 = (rt >>16 ) &MIPSDSP_Q0 ; + rt1 = (rt >>8 ) &MIPSDSP_Q0 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_mul_u8_u8 (rs3, rt3); + tempC =mipsdsp_mul_u8_u8 (rs2, rt2); + tempB =mipsdsp_mul_u8_u8 (rs1, rt1); + tempA =mipsdsp_mul_u8_u8 (rs0, rt0); + + temp[0 ] = (uint64_t )tempD + (uint64_t )tempC + + (uint64_t )tempB + (uint64_t )tempA; + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] - temp[0 ]; +if (temp_sum > acc[0 ]) { + acc[1 ] -=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] -= temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} +#endif + +void helper_dpa_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +int32_t tempA, tempB; +int64_t acc, tempAL, tempBL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB = (int32_t )rsh * (int32_t )rth; + tempA = (int32_t )rsl * (int32_t )rtl; + tempBL = tempB; + tempAL = tempA; + + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc += tempBL + tempAL; + + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dpa_w_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs3, rs2, rs1, rs0; +int32_t rt3, rt2, rt1, rt0; +int32_t tempD, tempC, tempB, tempA; +int64_t acc[2 ]; +int64_t temp[2 ]; +int64_t temp_sum; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD = rs3 * rt3; + tempC = rs2 * rt2; + tempB = rs1 * rt1; + tempA = rs0 * rt0; + + temp[0 ] = (int64_t )tempD + (int64_t )tempC + + (int64_t )tempB + (int64_t )tempA; + temp[0 ] = (int64_t )(temp[0 ] <<31 ) >>31 ; + +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[1 ] = env->active_tc.HI[ac]; + acc[0 ] = env->active_tc.LO[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )acc[0 ]) && + ((uint64_t )temp_sum < (uint64_t )temp[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} +#endif + +void helper_dpax_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t acc, dotp, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB = (uint32_t )rsh * (uint32_t )rth; + tempA = (uint32_t )rsl * (uint32_t )rtl; + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc += dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +void helper_dpaq_s_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t acc, dotp, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env, ac, rsh, rth); + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rtl); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc += dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dpaq_s_w_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs3, rs2, rs1, rs0; +int32_t rt3, rt2, rt1, rt0; +int32_t tempD, tempC, tempB, tempA; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_mul_q15_q15 (env, ac, rs3, rt3); + tempC =mipsdsp_mul_q15_q15 (env, ac, rs2, rt2); + tempB =mipsdsp_mul_q15_q15 (env, ac, rs1, rt1); + tempA =mipsdsp_mul_q15_q15 (env, ac, rs0, rt0); + + temp[0 ] = (int64_t )tempD + (int64_t )tempC + + (int64_t )tempB + (int64_t )tempA; +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = temp[0 ] + acc[0 ]; +if ((temp_sum < temp[0 ]) && (temp_sum < acc[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} +#endif + +void helper_dpaqx_s_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t acc, dotp, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env, ac, rsh, rtl); + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rth); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc += dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +void helper_dpaqx_sa_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA, tempC62_31, tempC63; +int64_t acc, dotp, tempBL, tempAL, tempC; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env, ac, rsh, rtl); + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rth); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempC = acc + dotp; + tempC63 = (tempC >>63 ) &0x01 ; + tempC62_31 = (tempC >>31 ) &0xFFFFFFFF ; + +if ((tempC63 ==0 ) && (tempC62_31 !=0x00000000 )) { + tempC =0x7FFFFFFF ; +set_DSPControl_overflow_flag (env,1 ,16 + ac); + } + +if ((tempC63 ==1 ) && (tempC62_31 !=0xFFFFFFFF )) { + tempC =0xFFFFFFFF80000000ull ; +set_DSPControl_overflow_flag (env,1 ,16 + ac); + } + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempC &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempC &MIPSDSP_LLO ); +} + +void helper_dps_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t acc, dotp, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB = (int32_t )rsh * (int32_t )rth; + tempA = (int32_t )rsl * (int32_t )rtl; + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc -= dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dps_w_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs3, rs2, rs1, rs0; +int16_t rt3, rt2, rt1, rt0; +int32_t tempD, tempC, tempB, tempA; +int64_t acc[2 ]; +int64_t temp[2 ]; +int64_t temp_sum; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD = (int32_t )rs3 * (int32_t )rt3; + tempC = (int32_t )rs2 * (int32_t )rt2; + tempB = (int32_t )rs1 * (int32_t )rt1; + tempA = (int32_t )rs0 * (int32_t )rt0; + + temp[0 ] = (int64_t )tempD + (int64_t )tempC + + (int64_t )tempB + (int64_t )tempA; + + temp[0 ] = (int64_t )(temp[0 ] <<31 ) >>31 ; +if (((temp[0 ] >>32 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] - temp[0 ]; +if ((uint64_t )temp_sum > (uint64_t )acc[0 ]) { + acc[1 ] -=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] -= temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} +#endif + +void helper_dpsx_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t acc, dotp, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB = (int32_t )rsh * (int32_t )rtl; + tempA = (int32_t )rsl * (int32_t )rth; + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc -= dotp; + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +void helper_dpsq_s_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t acc, dotp, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env, ac, rsh, rth); + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rtl); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc -= dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dpsq_s_w_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs3, rs2, rs1, rs0; +int16_t rt3, rt2, rt1, rt0; +int32_t tempD, tempC, tempB, tempA; +int64_t acc[2 ]; +int64_t temp[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_mul_q15_q15 (env, ac, rs3, rt3); + tempC =mipsdsp_mul_q15_q15 (env, ac, rs2, rt2); + tempB =mipsdsp_mul_q15_q15 (env, ac, rs1, rt1); + tempA =mipsdsp_mul_q15_q15 (env, ac, rs0, rt0); + + temp[0 ] = (int64_t )tempD + (int64_t )tempC + + (int64_t )tempB + (int64_t )tempA; +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] - temp[0 ]; +if ((uint64_t )temp_sum > (uint64_t )acc[0 ]) { + acc[1 ] -=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] -= temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} +#endif + +void helper_dpsqx_s_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t dotp, tempC, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env, ac, rsh, rtl); + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rth); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + tempC = (((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO )) - dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempC &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempC &MIPSDSP_LLO ); +} + +void helper_dpsqx_sa_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA, tempC63, tempC62_31; +int64_t dotp, tempBL, tempAL, tempC; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_mul_q15_q15 (env, ac, rsh, rtl); + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rth); + + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + tempC = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempC -= dotp; + + tempC63 = (tempC >>63 ) &0x01 ; + tempC62_31 = (tempC >>31 ) &0xFFFFFFFF ; + +if ((tempC63 ==0 ) && (tempC62_31 !=0 )) { + tempC =0x7FFFFFFF ; +set_DSPControl_overflow_flag (env,1 ,16 + ac); + } + +if ((tempC63 ==1 ) && (tempC62_31 !=0xFFFFFFFF )) { + tempC =0xFFFFFFFF80000000ull ; +set_DSPControl_overflow_flag (env,1 ,16 + ac); + } + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempC &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempC &MIPSDSP_LLO ); +} + +void helper_mulsaq_s_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t tempBL, tempAL, acc, dotp; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env, ac, rsh, rth); + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rtl); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL - tempAL; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + dotp = dotp + acc; + env->active_tc.HI[ac] = (target_long)(int32_t)((dotp &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(dotp &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_mulsaq_s_w_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs3, rs2, rs1, rs0; +int16_t rt3, rt2, rt1, rt0; +int32_t tempD, tempC, tempB, tempA; +int64_t acc[2 ]; +int64_t temp[2 ]; +int64_t temp_sum; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_mul_q15_q15 (env, ac, rs3, rt3); + tempC =mipsdsp_mul_q15_q15 (env, ac, rs2, rt2); + tempB =mipsdsp_mul_q15_q15 (env, ac, rs1, rt1); + tempA =mipsdsp_mul_q15_q15 (env, ac, rs0, rt0); + + temp[0 ] = ((int32_t )tempD - (int32_t )tempC) + + ((int32_t )tempB - (int32_t )tempA); + temp[0 ] = (int64_t )(temp[0 ] <<30 ) >>30 ; +if (((temp[0 ] >>33 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )acc[0 ]) && + ((uint64_t )temp_sum < (uint64_t )temp[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} +#endif + +void helper_dpaq_sa_l_w (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int32_t temp64, temp63, tempacc63, tempdotp63, tempDL63; +int64_t dotp, acc; +int64_t tempDL[2 ]; +uint64_t temp; + + dotp =mipsdsp_mul_q31_q31 (env, ac, rs, rt); + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempDL[0 ] = acc + dotp; + + tempacc63 = (acc >>63 ) &0x01 ; + tempdotp63 = (dotp >>63 ) &0x01 ; + tempDL63 = (tempDL[0 ] >>63 ) &0x01 ; + +if (((tempacc63 ==1 ) && (tempdotp63 ==1 )) | + (((tempacc63 ==1 ) || (tempdotp63 ==1 )) && tempDL63 ==0 )) { + tempDL[1 ] =1 ; + }else { + tempDL[1 ] =0 ; + } + + temp = tempDL[0 ]; + temp64 = tempDL[1 ] &0x01 ; + temp63 = (tempDL[0 ] >>63 ) &0x01 ; + +if (temp64 != temp63) { +if (temp64 ==1 ) { + temp =0x8000000000000000ull ; + }else { + temp =0x7FFFFFFFFFFFFFFFull ; + } + +set_DSPControl_overflow_flag (env,1 ,16 + ac); + } + + env->active_tc.HI[ac] = (target_long)(int32_t)((temp &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(temp &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dpaq_sa_l_pw (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs1, rs0; +int32_t rt1, rt0; +int64_t tempB[2 ], tempA[2 ]; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs1, rt1); + tempA[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs0, rt0); + +if (((tempB[0 ] >>63 ) &0x01 ) ==0 ) { + tempB[1 ] =0x00 ; + }else { + tempB[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + +if (((tempA[0 ] >>63 ) &0x01 ) ==0 ) { + tempA[1 ] =0x00 ; + }else { + tempA[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + temp_sum = tempB[0 ] + tempA[0 ]; +if (((uint64_t )temp_sum < (uint64_t )tempB[0 ]) && + ((uint64_t )temp_sum < (uint64_t )tempA[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += tempB[1 ] + tempA[1 ]; + +mipsdsp_sat64_acc_add_q63 (env, acc, ac, temp); + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} +#endif + +void helper_dpsq_sa_l_w (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int32_t temp64, temp63, tempacc63, tempdotp63, tempDL63; +int64_t dotp, acc; +int64_t tempDL[2 ]; +uint64_t temp; + + dotp =mipsdsp_mul_q31_q31 (env, ac, rs, rt); + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempDL[0 ] = acc - dotp; + + tempacc63 = (acc >>63 ) &0x01 ; + tempdotp63 = (dotp >>63 ) &0x01 ; + tempDL63 = (tempDL[0 ] >>63 ) &0x01 ; + +if (((tempacc63 ==1 ) && (tempdotp63 ==0 )) | + (((tempacc63 ==1 ) || (tempdotp63 ==0 )) && tempDL63 ==0 )) { + tempDL[1 ] =1 ; + }else { + tempDL[1 ] =0 ; + } + + temp = tempDL[0 ]; + temp64 = tempDL[1 ] &0x01 ; + temp63 = (tempDL[0 ] >>63 ) &0x01 ; +if (temp64 != temp63) { +if (temp64 ==1 ) { + temp =0x8000000000000000ull ; + }else { + temp =0x7FFFFFFFFFFFFFFFull ; + } +set_DSPControl_overflow_flag (env,1 , ac +16 ); + } + + env->active_tc.HI[ac] = (target_long)(int32_t)((temp &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(temp &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dpsq_sa_l_pw (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs1, rs0; +int32_t rt1, rt0; +int64_t tempB[2 ], tempA[2 ]; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0x00 ; + temp[1 ] =0x00 ; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs1, rt1); + tempA[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs0, rt0); + +if (((tempB[0 ] >>31 ) &0x01 ) ==0 ) { + tempB[1 ] =0x00 ; + }else { + tempB[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + +if (((tempA[0 ] >>31 ) &0x01 ) ==0 ) { + tempA[1 ] =0x00 ; + }else { + tempA[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + temp_sum = tempB[0 ] + tempA[0 ]; +if (((uint64_t )temp_sum < (uint64_t )tempB[0 ]) && + ((uint64_t )temp_sum < (uint64_t )tempA[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += tempA[1 ] + tempB[1 ]; + +mipsdsp_sat64_acc_sub_q63 (env, acc, ac, temp); + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_mulsaq_s_l_pw (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs1, rs0; +int32_t rt1, rt0; +int64_t tempB[2 ], tempA[2 ]; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs1, rt1); + tempA[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs0, rt0); + +if (((tempB[0 ] >>63 ) &0x01 ) ==0 ) { + tempB[1 ] =0x00 ; + }else { + tempB[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + +if (((tempA[0 ] >>63 ) &0x01 ) ==0 ) { + tempA[1 ] =0x00 ; + }else { + tempA[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = tempB[0 ] - tempA[0 ]; +if ((uint64_t )temp_sum > (uint64_t )tempB[0 ]) { + tempB[1 ] -=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] = tempB[1 ] - tempA[1 ]; + +if ((temp[1 ] &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )acc[0 ]) && + ((uint64_t )temp_sum < (uint64_t )temp[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} +#endif + +void helper_maq_s_w_phl (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rth; +int32_t tempA; +int64_t tempL, tempAL, acc; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rth = (rt &MIPSDSP_HI ) >>16 ; + tempA =mipsdsp_mul_q15_q15 (env, ac, rsh, rth); + tempAL = tempA; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempL = tempAL + acc; + env->active_tc.HI[ac] = (target_long)(int32_t)((tempL &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempL &MIPSDSP_LLO ); +} + +void helper_maq_s_w_phr (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsl, rtl; +int32_t tempA; +int64_t tempL, tempAL, acc; + + rsl = rs &MIPSDSP_LO ; + rtl = rt &MIPSDSP_LO ; + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rtl); + tempAL = tempA; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempL = tempAL + acc; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempL &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempL &MIPSDSP_LLO ); +} + +void helper_maq_sa_w_phl (CPUMIPSState *env,uint32_t ac, +target_ulong rs,target_ulong rt) +{ +int16_t rsh, rth; +int32_t tempA; +int64_t tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rth = (rt &MIPSDSP_HI ) >>16 ; + tempA =mipsdsp_mul_q15_q15 (env, ac, rsh, rth); + tempA =mipsdsp_sat32_acc_q31 (env, ac, tempA); + tempAL = tempA; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempAL &MIPSDSP_LHI ) >> +32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempAL &MIPSDSP_LLO ); +} + +void helper_maq_sa_w_phr (CPUMIPSState *env,uint32_t ac, +target_ulong rs,target_ulong rt) +{ +int16_t rsl, rtl; +int32_t tempA; +int64_t tempAL; + + rsl = rs &MIPSDSP_LO ; + rtl = rt &MIPSDSP_LO ; + + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rtl); + tempA =mipsdsp_sat32_acc_q31 (env, ac, tempA); + tempAL = tempA; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempAL &MIPSDSP_LHI ) >> +32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempAL &MIPSDSP_LLO ); +} + +/*************************************************************** +* In manual, GPR[rd](..0) <- tempB(15..0) || tempA(15..0), +* I'm not sure its means zero extend or sign extend. +* Now treat it as zero extend. +***************************************************************/ +target_ulong helper_mul_ph (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_mul_i16_i16 (env, rsh, rth); + tempA =mipsdsp_mul_i16_i16 (env, rsl, rtl); + + rd = ((tempB &MIPSDSP_LO ) <<16 ) | (tempA &MIPSDSP_LO ); + +return (target_ulong )rd; +} + +/*************************************************************** +* In manual, GPR[rd](..0) <- tempB(15..0) || tempA(15..0), +* I'm not sure its means zero extend or sign extend. +* Now treat it as zero extend. +***************************************************************/ +target_ulong helper_mul_s_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_sat16_mul_i16_i16 (env, rsh, rth); + tempA =mipsdsp_sat16_mul_i16_i16 (env, rsl, rtl); + + rd = ((tempB &MIPSDSP_LO ) <<16 ) | (tempA &MIPSDSP_LO ); + +return (target_ulong )rd; +} + +target_ulong helper_mulq_s_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t temp, tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_sat16_mul_q15_q15 (env, rsh, rth); + tempA =mipsdsp_sat16_mul_q15_q15 (env, rsl, rtl); + temp = ((tempB &MIPSDSP_LO ) <<16 ) | (tempA &MIPSDSP_LO ); + rd = temp; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_mulq_s_w (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rd; +int32_t tempI; +int64_t tempL; + +if ((rs ==0x80000000 ) && (rt ==0x80000000 )) { + tempL =0x7FFFFFFF00000000ull ; +set_DSPControl_overflow_flag (env,1 ,21 ); + }else { + tempL = ((int64_t )rs * (int64_t )rt) <<1 ; + } + tempI = (tempL &MIPSDSP_LHI ) >>32 ; + rd = tempI; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_mulq_rs_w (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rd; +uint32_t rs_t, rt_t; +uint32_t tempI; +int64_t tempL; + + rs_t = rs &MIPSDSP_LLO ; + rt_t = rt &MIPSDSP_LLO ; + +if ((rs_t ==0x80000000 ) && (rt_t ==0x80000000 )) { + tempL =0x7FFFFFFF00000000ull ; +set_DSPControl_overflow_flag (env,1 ,21 ); + }else { + tempL = ((int64_t )rs_t * (int64_t )rt_t) <<1 ; + tempL +=0x80000000ull ; + } + tempI = (tempL &MIPSDSP_LHI ) >>32 ; + rd = tempI; + +return (target_long )(int32_t )rd; +} + +void helper_mulsa_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t dotp, acc, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB = (int32_t )rsh * (int32_t )rth; + tempA = (int32_t )rsl * (int32_t )rtl; + tempBL = tempB; + tempAL = tempA; + + dotp = tempBL - tempAL; + acc = ((int64_t )env->active_tc.HI[ac] <<32 ) | + ((int64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc = acc + dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_maq_s_w_qhll (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp_mul; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs_t = (rs >>48 ) &MIPSDSP_LO ; + rt_t = (rt >>48 ) &MIPSDSP_LO ; + temp_mul =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + + temp[0 ] = (int64_t )temp_mul; +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )acc[0 ]) && + ((uint64_t )temp_sum < (uint64_t )temp[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_s_w_qhlr (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp_mul; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs_t = (rs >>32 ) &MIPSDSP_LO ; + rt_t = (rt >>32 ) &MIPSDSP_LO ; + temp_mul =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + + temp[0 ] = (int64_t )temp_mul; +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )acc[0 ]) && + ((uint64_t )temp_sum < (uint64_t )temp[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_s_w_qhrl (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp_mul; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs_t = (rs >>16 ) &MIPSDSP_LO ; + rt_t = (rt >>16 ) &MIPSDSP_LO ; + temp_mul =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + + temp[0 ] = (int64_t )temp_mul; +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )acc[0 ]) && + ((uint64_t )temp_sum < (uint64_t )temp[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_s_w_qhrr (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp_mul; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs_t = rs &MIPSDSP_LO ; + rt_t = rt &MIPSDSP_LO ; + temp_mul =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + + temp[0 ] = (int64_t )temp_mul; +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )acc[0 ]) && + ((uint64_t )temp_sum < (uint64_t )temp[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_sa_w_qhll (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp; +int64_t acc[2 ]; + + rs_t = (rs >>48 ) &MIPSDSP_LO ; + rt_t = (rt >>48 ) &MIPSDSP_LO ; + temp =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + temp =mipsdsp_sat32_acc_q31 (env, ac, temp); + + acc[0 ] = (int64_t )(int32_t )temp; +if (((acc[0 ] >>63 ) &0x01 ) ==0 ) { + acc[1 ] =0x00 ; + }else { + acc[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_sa_w_qhlr (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp; +int64_t acc[2 ]; + + rs_t = (rs >>32 ) &MIPSDSP_LO ; + rt_t = (rt >>32 ) &MIPSDSP_LO ; + temp =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + temp =mipsdsp_sat32_acc_q31 (env, ac, temp); + + acc[0 ] = (int64_t )temp; +if (((acc[0 ] >>63 ) &0x01 ) ==0 ) { + acc[1 ] =0x00 ; + }else { + acc[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_sa_w_qhrl (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp; +int64_t acc[2 ]; + + rs_t = (rs >>16 ) &MIPSDSP_LO ; + rt_t = (rt >>16 ) &MIPSDSP_LO ; + temp =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + temp =mipsdsp_sat32_acc_q31 (env, ac, temp); + + acc[0 ] = (int64_t )temp; +if (((acc[0 ] >>63 ) &0x01 ) ==0 ) { + acc[1 ] =0x00 ; + }else { + acc[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_sa_w_qhrr (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp; +int64_t acc[2 ]; + + rs_t = rs &MIPSDSP_LO ; + rt_t = rt &MIPSDSP_LO ; + temp =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + temp =mipsdsp_sat32_acc_q31 (env, ac, temp); + + acc[0 ] = (int64_t )temp; +if (((acc[0 ] >>63 ) &0x01 ) ==0 ) { + acc[1 ] =0x00 ; + }else { + acc[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_s_l_pwl (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs_t, rt_t; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs_t = (rs >>32 ) &MIPSDSP_LLO ; + rt_t = (rt >>32 ) &MIPSDSP_LLO ; + + temp[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs_t, rt_t); +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )temp[0 ]) && + ((uint64_t )temp_sum < (uint64_t )acc[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_s_l_pwr (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs_t, rt_t; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs_t = rs &MIPSDSP_LLO ; + rt_t = rt &MIPSDSP_LLO ; + + temp[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs_t, rt_t); +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )temp[0 ]) && + ((uint64_t )temp_sum < (uint64_t )acc[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_dmadd (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs1, rs0; +int32_t rt1, rt0; +int32_t tempB, tempA; +int64_t tempBL[2 ], tempAL[2 ]; +int64_t acc[2 ]; +int64_t temp[2 ]; +int64_t temp_sum; + + temp[0 ] =0x00 ; + temp[1 ] =0x00 ; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB = rs1 * rt1; + tempA = rs0 * rt0; + + tempBL[0 ] = (int64_t )tempB; + tempAL[0 ] = (int64_t )tempA; + +if (((tempBL[0 ] >>63 ) &0x01 ) ==0 ) { + tempBL[1 ] =0x0 ; + }else { + tempBL[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + +if (((tempAL[0 ] >>63 ) &0x01 ) ==0 ) { + tempAL[1 ] =0x0 ; + }else { + tempAL[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[1 ] = env->active_tc.HI[ac]; + acc[0 ] = env->active_tc.LO[ac]; + + temp_sum = tempBL[0 ] + tempAL[0 ]; +if (((uint64_t )temp_sum < (uint64_t )tempBL[0 ]) && + ((uint64_t )temp_sum < (uint64_t )tempAL[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += tempBL[1 ] + tempAL[1 ]; + + temp_sum = temp[0 ] + acc[0 ]; +if (((uint64_t )temp_sum < (uint64_t )temp[0 ]) && + ((uint64_t )temp_sum < (uint64_t )acc[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} + +void helper_dmaddu (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +uint32_t rs1, rs0; +uint32_t rt1, rt0; +uint64_t tempBL[2 ], tempAL[2 ]; +uint64_t acc[2 ]; +uint64_t temp[2 ]; +uint64_t temp_sum; + + temp[0 ] =0x00 ; + temp[1 ] =0x00 ; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempBL[0 ] =mipsdsp_mul_u32_u32 (env, rs1, rt1); + tempAL[0 ] =mipsdsp_mul_u32_u32 (env, rs0, rt0); + tempBL[1 ] =0 ; + tempAL[1 ] =0 ; + + acc[1 ] = env->active_tc.HI[ac]; + acc[0 ] = env->active_tc.LO[ac]; + + temp_sum = tempBL[0 ] + tempAL[0 ]; +if ((temp_sum < tempBL[0 ]) && (temp_sum < tempAL[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += tempBL[1 ] + tempAL[1 ]; + + temp_sum = temp[0 ] + acc[0 ]; +if ((temp_sum < temp[0 ]) && (temp_sum < acc[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} + +void helper_dmsub (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs1, rs0; +int32_t rt1, rt0; +int32_t tempB, tempA; +int64_t tempBL[2 ], tempAL[2 ]; +int64_t acc[2 ]; +int64_t temp[2 ]; +int64_t temp_sum; + + temp[0 ] =0x00 ; + temp[1 ] =0x00 ; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB = rs1 * rt1; + tempA = rs0 * rt0; + + tempBL[0 ] = (int64_t )tempB; + tempAL[0 ] = (int64_t )tempA; + +if (((tempBL[0 ] >>63 ) &0x01 ) ==0 ) { + tempBL[1 ] =0x0 ; + }else { + tempBL[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + +if (((tempAL[0 ] >>63 ) &0x01 ) ==0 ) { + tempAL[1 ] =0x0 ; + }else { + tempAL[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[1 ] = env->active_tc.HI[ac]; + acc[0 ] = env->active_tc.LO[ac]; + + temp_sum = acc[0 ] - tempBL[0 ]; +if ((uint64_t )temp_sum > (uint64_t )acc[0 ]) { + temp[1 ] -=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ] - tempBL[1 ]; + + temp_sum = temp[0 ] - tempAL[0 ]; +if ((uint64_t )temp_sum > (uint64_t )temp[0 ]) { + temp[1 ] -=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] -= tempAL[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} + +void helper_dmsubu (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +uint32_t rs1, rs0; +uint32_t rt1, rt0; +uint64_t tempBL[2 ], tempAL[2 ]; +uint64_t acc[2 ]; +uint64_t temp[2 ]; +uint64_t temp_sum; + + temp[0 ] =0x00 ; + temp[1 ] =0x00 ; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempBL[0 ] =mipsdsp_mul_u32_u32 (env, rs1, rt1); + tempAL[0 ] =mipsdsp_mul_u32_u32 (env, rs0, rt0); + tempBL[1 ] =0 ; + tempAL[1 ] =0 ; + + acc[1 ] = env->active_tc.HI[ac]; + acc[0 ] = env->active_tc.LO[ac]; + + temp_sum = acc[0 ] - tempBL[0 ]; +if (temp_sum > acc[0 ]) { + temp[1 ] -=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ] - tempBL[1 ]; + + temp_sum = temp[0 ] - tempAL[0 ]; +if ((uint64_t )temp_sum > (uint64_t )temp[0 ]) { + temp[1 ] -=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] -= tempAL[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} +#endif +#undef MIPSDSP_LHI#undef MIPSDSP_LLO#undef MIPSDSP_HI
target-mips/helper.h +91 -0
95 lines not on this page · raw message
target-mips/translate.c +503 -0
569 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v7 08/14] target-mips-ase-dsp: Add multiply instructions
Quoted 26 lines · Jia Liu
Add MIPS ASE DSP Multiply instructions.
Signed-off-by Jia Liu <[email protected]>--- target-mips/dsp_helper.c | 2024 ++++++++++++++++++++++++++++++++++++++++++++++ target-mips/helper.h | 91 +++ target-mips/translate.c | 503 ++++++++++++ 3 files changed, 2618 insertions(+)target-mips/dsp_helper.c +9
-0@@ -4187,6 +4187,2030 @@ target_ulong helper_shrav_r_pw(target_ulong rt, target_ulong sa) }#endif +/** DSP Multiply Sub-class insns **/ +target_ulong helper_muleu_s_ph_qbl (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2; +uint16_t tempB, tempA, rth, rtl; +uint32_t temp; +uint32_t rd; +
target-mips/dsp_helper.c target_ulong helper_shrav_r_pw(target_ulong rt, target_ulong sa) · line 4208
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+ rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_mul_u8_u16 (env, rs3, rth); + tempA =mipsdsp_mul_u8_u16 (env, rs2, rtl); + temp = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); + rd = temp; +return (target_long )(int32_t )rd; +}
Why using the variable rd here?
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+target_ulong helper_muleu_s_ph_qbr (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs1, rs0; +uint16_t tempB, tempA; +uint16_t rth, rtl; +uint32_t temp; +uint32_t rd; + + rs1 = (rs &MIPSDSP_Q1 ) >>8 ;
target-mips/dsp_helper.c target_ulong helper_shrav_r_pw(target_ulong rt, target_ulong sa) · line 4229
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+ rs0 = rs &MIPSDSP_Q0 ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_u8_u16 (env, rs1, rth); + tempA =mipsdsp_mul_u8_u16 (env, rs0, rtl); + temp = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); + rd = temp; +return (target_long )(int32_t )rd; +}
Ditto
Quoted 66 lines
target-mips/dsp_helper.c +66
-0+#if defined(TARGET_MIPS64 ) +target_ulong helper_muleu_s_qh_obl (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>56 ) &MIPSDSP_Q0 ; + rs2 = (rs >>48 ) &MIPSDSP_Q0 ; + rs1 = (rs >>40 ) &MIPSDSP_Q0 ; + rs0 = (rs >>32 ) &MIPSDSP_Q0 ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_mul_u8_u16 (env, rs3, rt3); + tempC =mipsdsp_mul_u8_u16 (env, rs2, rt2); + tempB =mipsdsp_mul_u8_u16 (env, rs1, rt1); + tempA =mipsdsp_mul_u8_u16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; +return temp; +} + +target_ulong helper_muleu_s_qh_obr (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>24 ) &MIPSDSP_Q0 ; + rs2 = (rs >>16 ) &MIPSDSP_Q0 ; + rs1 = (rs >>8 ) &MIPSDSP_Q0 ; + rs0 = rs &MIPSDSP_Q0 ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_mul_u8_u16 (env, rs3, rt3); + tempC =mipsdsp_mul_u8_u16 (env, rs2, rt2); + tempB =mipsdsp_mul_u8_u16 (env, rs1, rt1); + tempA =mipsdsp_mul_u8_u16 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; + +return temp; +} +#endif + +target_ulong helper_mulq_rs_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int16_t tempB, tempA, rsh, rsl, rth, rtl; +int32_t temp; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ;
target-mips/dsp_helper.c target_ulong helper_shrav_r_pw(target_ulong rt, target_ulong sa) · line 4306
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+ rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_rndq15_mul_q15_q15 (env, rsh, rth); + tempA =mipsdsp_rndq15_mul_q15_q15 (env, rsl, rtl); + temp = ((uint32_t )tempB <<16 ) | ((uint32_t )tempA &MIPSDSP_LO ); + rd = temp; + +return (target_long )(int32_t )rd; +}
Same here.
Quoted 2,597 lines
target-mips/dsp_helper.c +1906
-0+#if defined(TARGET_MIPS64 ) +target_ulong helper_mulq_rs_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_rndq15_mul_q15_q15 (env, rs3, rt3); + tempC =mipsdsp_rndq15_mul_q15_q15 (env, rs2, rt2); + tempB =mipsdsp_rndq15_mul_q15_q15 (env, rs1, rt1); + tempA =mipsdsp_rndq15_mul_q15_q15 (env, rs0, rt0); + + temp = ((uint64_t )tempD <<48 ) | ((uint64_t )tempC <<32 ) | + ((uint64_t )tempB <<16 ) | (uint64_t )tempA; +return temp; +} +#endif + +target_ulong helper_muleq_s_w_phl (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int16_t rsh, rth; +int32_t temp; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rth = (rt &MIPSDSP_HI ) >>16 ; + temp =mipsdsp_mul_q15_q15_overflowflag21 (env, rsh, rth); + rd = temp; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_muleq_s_w_phr (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int16_t rsl, rtl; +int32_t temp; +uint32_t rd; + + rsl = rs &MIPSDSP_LO ; + rtl = rt &MIPSDSP_LO ; + temp =mipsdsp_mul_q15_q15_overflowflag21 (env, rsl, rtl); + rd = temp; + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_muleq_s_pw_qhl (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rsB, rsA; +uint16_t rtB, rtA; +uint32_t tempB, tempA; +uint64_t temp; + + rsB = (rs >>48 ) &MIPSDSP_LO ; + rsA = (rs >>32 ) &MIPSDSP_LO ; + rtB = (rt >>48 ) &MIPSDSP_LO ; + rtA = (rt >>32 ) &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env,5 , rsB, rtB); + tempA =mipsdsp_mul_q15_q15 (env,5 , rsA, rtA); + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} + +target_ulong helper_muleq_s_pw_qhr (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint16_t rsB, rsA; +uint16_t rtB, rtA; +uint32_t tempB, tempA; +uint64_t temp; + + rsB = (rs >>16 ) &MIPSDSP_LO ; + rsA = rs &MIPSDSP_LO ; + rtB = (rt >>16 ) &MIPSDSP_LO ; + rtA = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env,5 , rsB, rtB); + tempA =mipsdsp_mul_q15_q15 (env,5 , rsA, rtA); + + temp = ((uint64_t )tempB <<32 ) | (uint64_t )tempA; + +return temp; +} +#endif + +void helper_dpau_h_qbl (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2; +uint8_t rt3, rt2; +uint16_t tempB, tempA; +uint64_t tempC, tempBL, tempAL, dotp; + + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + tempB =mipsdsp_mul_u8_u8 (rs3, rt3); + tempA =mipsdsp_mul_u8_u8 (rs2, rt2); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + tempC = (((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO )) + dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempC &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempC &MIPSDSP_LLO ); +} + +void helper_dpau_h_qbr (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint8_t rs1, rs0; +uint8_t rt1, rt0; +uint16_t tempB, tempA; +uint64_t tempC, tempBL, tempAL, dotp; + + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rs0 = (rs &MIPSDSP_Q0 ); + rt0 = (rt &MIPSDSP_Q0 ); + tempB =mipsdsp_mul_u8_u8 (rs1, rt1); + tempA =mipsdsp_mul_u8_u8 (rs0, rt0); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + tempC = (((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO )) + dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempC &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempC &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dpau_h_obl (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +uint8_t rs7, rs6, rs5, rs4; +uint8_t rt7, rt6, rt5, rt4; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp[2 ]; +uint64_t acc[2 ]; +uint64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs7 = (rs >>56 ) &MIPSDSP_Q0 ; + rs6 = (rs >>48 ) &MIPSDSP_Q0 ; + rs5 = (rs >>40 ) &MIPSDSP_Q0 ; + rs4 = (rs >>32 ) &MIPSDSP_Q0 ; + rt7 = (rt >>56 ) &MIPSDSP_Q0 ; + rt6 = (rt >>48 ) &MIPSDSP_Q0 ; + rt5 = (rt >>40 ) &MIPSDSP_Q0 ; + rt4 = (rt >>32 ) &MIPSDSP_Q0 ; + + tempD =mipsdsp_mul_u8_u8 (rs7, rt7); + tempC =mipsdsp_mul_u8_u8 (rs6, rt6); + tempB =mipsdsp_mul_u8_u8 (rs5, rt5); + tempA =mipsdsp_mul_u8_u8 (rs4, rt4); + + temp[0 ] = (uint64_t )tempD + (uint64_t )tempC + + (uint64_t )tempB + (uint64_t )tempA; + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; + +if (temp_sum < acc[0 ] && temp_sum < temp[0 ]) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} + +void helper_dpau_h_obr (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +uint8_t rs3, rs2, rs1, rs0; +uint8_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t temp[2 ]; +uint64_t acc[2 ]; +uint64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs3 = (rs >>24 ) &MIPSDSP_Q0 ; + rs2 = (rs >>16 ) &MIPSDSP_Q0 ; + rs1 = (rs >>8 ) &MIPSDSP_Q0 ; + rs0 = rs &MIPSDSP_Q0 ; + rt3 = (rt >>24 ) &MIPSDSP_Q0 ; + rt2 = (rt >>16 ) &MIPSDSP_Q0 ; + rt1 = (rt >>8 ) &MIPSDSP_Q0 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_mul_u8_u8 (rs3, rt3); + tempC =mipsdsp_mul_u8_u8 (rs2, rt2); + tempB =mipsdsp_mul_u8_u8 (rs1, rt1); + tempA =mipsdsp_mul_u8_u8 (rs0, rt0); + + temp[0 ] = (uint64_t )tempD + (uint64_t )tempC + + (uint64_t )tempB + (uint64_t )tempA; + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; + +if (temp_sum < acc[0 ] && temp_sum < temp[0 ]) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} +#endif + +void helper_dpsu_h_qbl (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint8_t rs3, rs2, rt3, rt2; +uint16_t tempB, tempA; +uint64_t dotp, tempBL, tempAL, tempC; + + rs3 = (rs &MIPSDSP_Q3 ) >>24 ; + rs2 = (rs &MIPSDSP_Q2 ) >>16 ; + rt3 = (rt &MIPSDSP_Q3 ) >>24 ; + rt2 = (rt &MIPSDSP_Q2 ) >>16 ; + + tempB =mipsdsp_mul_u8_u8 (rs3, rt3); + tempA =mipsdsp_mul_u8_u8 (rs2, rt2); + tempBL = tempB &0xFFFF ; + tempAL = tempA &0xFFFF ; + + dotp = tempBL + tempAL; + tempC = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempC -= dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempC &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempC &MIPSDSP_LLO ); +} + +void helper_dpsu_h_qbr (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint8_t rs1, rs0, rt1, rt0; +uint16_t tempB, tempA; +uint64_t dotp, tempBL, tempAL, tempC; + + rs1 = (rs &MIPSDSP_Q1 ) >>8 ; + rs0 = (rs &MIPSDSP_Q0 ); + rt1 = (rt &MIPSDSP_Q1 ) >>8 ; + rt0 = (rt &MIPSDSP_Q0 ); + + tempB =mipsdsp_mul_u8_u8 (rs1, rt1); + tempA =mipsdsp_mul_u8_u8 (rs0, rt0); + tempBL = tempB &0xFFFF ; + tempAL = tempA &0xFFFF ; + + dotp = tempBL + tempAL; + tempC = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempC -= dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempC &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempC &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dpsu_h_obl (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +uint8_t rs7, rs6, rs5, rs4; +uint8_t rt7, rt6, rt5, rt4; +uint16_t tempD, tempC, tempB, tempA; +uint64_t acc[2 ]; +uint64_t temp[2 ]; +uint64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs7 = (rs >>56 ) &MIPSDSP_Q0 ; + rs6 = (rs >>48 ) &MIPSDSP_Q0 ; + rs5 = (rs >>40 ) &MIPSDSP_Q0 ; + rs4 = (rs >>32 ) &MIPSDSP_Q0 ; + rt7 = (rt >>56 ) &MIPSDSP_Q0 ; + rt6 = (rt >>48 ) &MIPSDSP_Q0 ; + rt5 = (rt >>40 ) &MIPSDSP_Q0 ; + rt4 = (rt >>32 ) &MIPSDSP_Q0 ; + + tempD =mipsdsp_mul_u8_u8 (rs7, rt7); + tempC =mipsdsp_mul_u8_u8 (rs6, rt6); + tempB =mipsdsp_mul_u8_u8 (rs5, rt5); + tempA =mipsdsp_mul_u8_u8 (rs4, rt4); + + temp[0 ] = (uint64_t )tempD + (uint64_t )tempC + + (uint64_t )tempB + (uint64_t )tempA; + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] - temp[0 ]; +if (temp_sum > acc[0 ]) { + acc[1 ] -=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] -= temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_dpsu_h_obr (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +uint8_t rs3, rs2, rs1, rs0; +uint8_t rt3, rt2, rt1, rt0; +uint16_t tempD, tempC, tempB, tempA; +uint64_t acc[2 ]; +uint64_t temp[2 ]; +uint64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs3 = (rs >>24 ) &MIPSDSP_Q0 ; + rs2 = (rs >>16 ) &MIPSDSP_Q0 ; + rs1 = (rs >>8 ) &MIPSDSP_Q0 ; + rs0 = rs &MIPSDSP_Q0 ; + rt3 = (rt >>24 ) &MIPSDSP_Q0 ; + rt2 = (rt >>16 ) &MIPSDSP_Q0 ; + rt1 = (rt >>8 ) &MIPSDSP_Q0 ; + rt0 = rt &MIPSDSP_Q0 ; + + tempD =mipsdsp_mul_u8_u8 (rs3, rt3); + tempC =mipsdsp_mul_u8_u8 (rs2, rt2); + tempB =mipsdsp_mul_u8_u8 (rs1, rt1); + tempA =mipsdsp_mul_u8_u8 (rs0, rt0); + + temp[0 ] = (uint64_t )tempD + (uint64_t )tempC + + (uint64_t )tempB + (uint64_t )tempA; + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] - temp[0 ]; +if (temp_sum > acc[0 ]) { + acc[1 ] -=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] -= temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} +#endif + +void helper_dpa_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +int32_t tempA, tempB; +int64_t acc, tempAL, tempBL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB = (int32_t )rsh * (int32_t )rth; + tempA = (int32_t )rsl * (int32_t )rtl; + tempBL = tempB; + tempAL = tempA; + + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc += tempBL + tempAL; + + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dpa_w_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs3, rs2, rs1, rs0; +int32_t rt3, rt2, rt1, rt0; +int32_t tempD, tempC, tempB, tempA; +int64_t acc[2 ]; +int64_t temp[2 ]; +int64_t temp_sum; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD = rs3 * rt3; + tempC = rs2 * rt2; + tempB = rs1 * rt1; + tempA = rs0 * rt0; + + temp[0 ] = (int64_t )tempD + (int64_t )tempC + + (int64_t )tempB + (int64_t )tempA; + temp[0 ] = (int64_t )(temp[0 ] <<31 ) >>31 ; + +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[1 ] = env->active_tc.HI[ac]; + acc[0 ] = env->active_tc.LO[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )acc[0 ]) && + ((uint64_t )temp_sum < (uint64_t )temp[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} +#endif + +void helper_dpax_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t acc, dotp, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB = (uint32_t )rsh * (uint32_t )rth; + tempA = (uint32_t )rsl * (uint32_t )rtl; + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc += dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +void helper_dpaq_s_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t acc, dotp, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env, ac, rsh, rth); + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rtl); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc += dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dpaq_s_w_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs3, rs2, rs1, rs0; +int32_t rt3, rt2, rt1, rt0; +int32_t tempD, tempC, tempB, tempA; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_mul_q15_q15 (env, ac, rs3, rt3); + tempC =mipsdsp_mul_q15_q15 (env, ac, rs2, rt2); + tempB =mipsdsp_mul_q15_q15 (env, ac, rs1, rt1); + tempA =mipsdsp_mul_q15_q15 (env, ac, rs0, rt0); + + temp[0 ] = (int64_t )tempD + (int64_t )tempC + + (int64_t )tempB + (int64_t )tempA; +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = temp[0 ] + acc[0 ]; +if ((temp_sum < temp[0 ]) && (temp_sum < acc[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} +#endif + +void helper_dpaqx_s_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t acc, dotp, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env, ac, rsh, rtl); + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rth); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc += dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +void helper_dpaqx_sa_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA, tempC62_31, tempC63; +int64_t acc, dotp, tempBL, tempAL, tempC; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env, ac, rsh, rtl); + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rth); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempC = acc + dotp; + tempC63 = (tempC >>63 ) &0x01 ; + tempC62_31 = (tempC >>31 ) &0xFFFFFFFF ; + +if ((tempC63 ==0 ) && (tempC62_31 !=0x00000000 )) { + tempC =0x7FFFFFFF ; +set_DSPControl_overflow_flag (env,1 ,16 + ac); + } + +if ((tempC63 ==1 ) && (tempC62_31 !=0xFFFFFFFF )) { + tempC =0xFFFFFFFF80000000ull ; +set_DSPControl_overflow_flag (env,1 ,16 + ac); + } + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempC &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempC &MIPSDSP_LLO ); +} + +void helper_dps_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t acc, dotp, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB = (int32_t )rsh * (int32_t )rth; + tempA = (int32_t )rsl * (int32_t )rtl; + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc -= dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dps_w_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs3, rs2, rs1, rs0; +int16_t rt3, rt2, rt1, rt0; +int32_t tempD, tempC, tempB, tempA; +int64_t acc[2 ]; +int64_t temp[2 ]; +int64_t temp_sum; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD = (int32_t )rs3 * (int32_t )rt3; + tempC = (int32_t )rs2 * (int32_t )rt2; + tempB = (int32_t )rs1 * (int32_t )rt1; + tempA = (int32_t )rs0 * (int32_t )rt0; + + temp[0 ] = (int64_t )tempD + (int64_t )tempC + + (int64_t )tempB + (int64_t )tempA; + + temp[0 ] = (int64_t )(temp[0 ] <<31 ) >>31 ; +if (((temp[0 ] >>32 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] - temp[0 ]; +if ((uint64_t )temp_sum > (uint64_t )acc[0 ]) { + acc[1 ] -=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] -= temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} +#endif + +void helper_dpsx_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t acc, dotp, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB = (int32_t )rsh * (int32_t )rtl; + tempA = (int32_t )rsl * (int32_t )rth; + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc -= dotp; + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +void helper_dpsq_s_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t acc, dotp, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env, ac, rsh, rth); + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rtl); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc -= dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dpsq_s_w_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs3, rs2, rs1, rs0; +int16_t rt3, rt2, rt1, rt0; +int32_t tempD, tempC, tempB, tempA; +int64_t acc[2 ]; +int64_t temp[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_mul_q15_q15 (env, ac, rs3, rt3); + tempC =mipsdsp_mul_q15_q15 (env, ac, rs2, rt2); + tempB =mipsdsp_mul_q15_q15 (env, ac, rs1, rt1); + tempA =mipsdsp_mul_q15_q15 (env, ac, rs0, rt0); + + temp[0 ] = (int64_t )tempD + (int64_t )tempC + + (int64_t )tempB + (int64_t )tempA; +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] - temp[0 ]; +if ((uint64_t )temp_sum > (uint64_t )acc[0 ]) { + acc[1 ] -=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] -= temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} +#endif + +void helper_dpsqx_s_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t dotp, tempC, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env, ac, rsh, rtl); + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rth); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + tempC = (((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO )) - dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempC &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempC &MIPSDSP_LLO ); +} + +void helper_dpsqx_sa_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA, tempC63, tempC62_31; +int64_t dotp, tempBL, tempAL, tempC; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_mul_q15_q15 (env, ac, rsh, rtl); + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rth); + + tempBL = tempB; + tempAL = tempA; + dotp = tempBL + tempAL; + tempC = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempC -= dotp; + + tempC63 = (tempC >>63 ) &0x01 ; + tempC62_31 = (tempC >>31 ) &0xFFFFFFFF ; + +if ((tempC63 ==0 ) && (tempC62_31 !=0 )) { + tempC =0x7FFFFFFF ; +set_DSPControl_overflow_flag (env,1 ,16 + ac); + } + +if ((tempC63 ==1 ) && (tempC62_31 !=0xFFFFFFFF )) { + tempC =0xFFFFFFFF80000000ull ; +set_DSPControl_overflow_flag (env,1 ,16 + ac); + } + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempC &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempC &MIPSDSP_LLO ); +} + +void helper_mulsaq_s_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t tempBL, tempAL, acc, dotp; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_mul_q15_q15 (env, ac, rsh, rth); + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rtl); + tempBL = tempB; + tempAL = tempA; + dotp = tempBL - tempAL; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + dotp = dotp + acc; + env->active_tc.HI[ac] = (target_long)(int32_t)((dotp &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(dotp &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_mulsaq_s_w_qh (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs3, rs2, rs1, rs0; +int16_t rt3, rt2, rt1, rt0; +int32_t tempD, tempC, tempB, tempA; +int64_t acc[2 ]; +int64_t temp[2 ]; +int64_t temp_sum; + + rs3 = (rs >>48 ) &MIPSDSP_LO ; + rs2 = (rs >>32 ) &MIPSDSP_LO ; + rs1 = (rs >>16 ) &MIPSDSP_LO ; + rs0 = rs &MIPSDSP_LO ; + rt3 = (rt >>48 ) &MIPSDSP_LO ; + rt2 = (rt >>32 ) &MIPSDSP_LO ; + rt1 = (rt >>16 ) &MIPSDSP_LO ; + rt0 = rt &MIPSDSP_LO ; + + tempD =mipsdsp_mul_q15_q15 (env, ac, rs3, rt3); + tempC =mipsdsp_mul_q15_q15 (env, ac, rs2, rt2); + tempB =mipsdsp_mul_q15_q15 (env, ac, rs1, rt1); + tempA =mipsdsp_mul_q15_q15 (env, ac, rs0, rt0); + + temp[0 ] = ((int32_t )tempD - (int32_t )tempC) + + ((int32_t )tempB - (int32_t )tempA); + temp[0 ] = (int64_t )(temp[0 ] <<30 ) >>30 ; +if (((temp[0 ] >>33 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )acc[0 ]) && + ((uint64_t )temp_sum < (uint64_t )temp[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} +#endif + +void helper_dpaq_sa_l_w (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int32_t temp64, temp63, tempacc63, tempdotp63, tempDL63; +int64_t dotp, acc; +int64_t tempDL[2 ]; +uint64_t temp; + + dotp =mipsdsp_mul_q31_q31 (env, ac, rs, rt); + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempDL[0 ] = acc + dotp; + + tempacc63 = (acc >>63 ) &0x01 ; + tempdotp63 = (dotp >>63 ) &0x01 ; + tempDL63 = (tempDL[0 ] >>63 ) &0x01 ; + +if (((tempacc63 ==1 ) && (tempdotp63 ==1 )) | + (((tempacc63 ==1 ) || (tempdotp63 ==1 )) && tempDL63 ==0 )) { + tempDL[1 ] =1 ; + }else { + tempDL[1 ] =0 ; + } + + temp = tempDL[0 ]; + temp64 = tempDL[1 ] &0x01 ; + temp63 = (tempDL[0 ] >>63 ) &0x01 ; + +if (temp64 != temp63) { +if (temp64 ==1 ) { + temp =0x8000000000000000ull ; + }else { + temp =0x7FFFFFFFFFFFFFFFull ; + } + +set_DSPControl_overflow_flag (env,1 ,16 + ac); + } + + env->active_tc.HI[ac] = (target_long)(int32_t)((temp &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(temp &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dpaq_sa_l_pw (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs1, rs0; +int32_t rt1, rt0; +int64_t tempB[2 ], tempA[2 ]; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs1, rt1); + tempA[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs0, rt0); + +if (((tempB[0 ] >>63 ) &0x01 ) ==0 ) { + tempB[1 ] =0x00 ; + }else { + tempB[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + +if (((tempA[0 ] >>63 ) &0x01 ) ==0 ) { + tempA[1 ] =0x00 ; + }else { + tempA[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + temp_sum = tempB[0 ] + tempA[0 ]; +if (((uint64_t )temp_sum < (uint64_t )tempB[0 ]) && + ((uint64_t )temp_sum < (uint64_t )tempA[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += tempB[1 ] + tempA[1 ]; + +mipsdsp_sat64_acc_add_q63 (env, acc, ac, temp); + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} +#endif + +void helper_dpsq_sa_l_w (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int32_t temp64, temp63, tempacc63, tempdotp63, tempDL63; +int64_t dotp, acc; +int64_t tempDL[2 ]; +uint64_t temp; + + dotp =mipsdsp_mul_q31_q31 (env, ac, rs, rt); + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempDL[0 ] = acc - dotp; + + tempacc63 = (acc >>63 ) &0x01 ; + tempdotp63 = (dotp >>63 ) &0x01 ; + tempDL63 = (tempDL[0 ] >>63 ) &0x01 ; + +if (((tempacc63 ==1 ) && (tempdotp63 ==0 )) | + (((tempacc63 ==1 ) || (tempdotp63 ==0 )) && tempDL63 ==0 )) { + tempDL[1 ] =1 ; + }else { + tempDL[1 ] =0 ; + } + + temp = tempDL[0 ]; + temp64 = tempDL[1 ] &0x01 ; + temp63 = (tempDL[0 ] >>63 ) &0x01 ; +if (temp64 != temp63) { +if (temp64 ==1 ) { + temp =0x8000000000000000ull ; + }else { + temp =0x7FFFFFFFFFFFFFFFull ; + } +set_DSPControl_overflow_flag (env,1 , ac +16 ); + } + + env->active_tc.HI[ac] = (target_long)(int32_t)((temp &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(temp &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dpsq_sa_l_pw (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs1, rs0; +int32_t rt1, rt0; +int64_t tempB[2 ], tempA[2 ]; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0x00 ; + temp[1 ] =0x00 ; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs1, rt1); + tempA[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs0, rt0); + +if (((tempB[0 ] >>31 ) &0x01 ) ==0 ) { + tempB[1 ] =0x00 ; + }else { + tempB[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + +if (((tempA[0 ] >>31 ) &0x01 ) ==0 ) { + tempA[1 ] =0x00 ; + }else { + tempA[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + temp_sum = tempB[0 ] + tempA[0 ]; +if (((uint64_t )temp_sum < (uint64_t )tempB[0 ]) && + ((uint64_t )temp_sum < (uint64_t )tempA[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += tempA[1 ] + tempB[1 ]; + +mipsdsp_sat64_acc_sub_q63 (env, acc, ac, temp); + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_mulsaq_s_l_pw (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs1, rs0; +int32_t rt1, rt0; +int64_t tempB[2 ], tempA[2 ]; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs1, rt1); + tempA[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs0, rt0); + +if (((tempB[0 ] >>63 ) &0x01 ) ==0 ) { + tempB[1 ] =0x00 ; + }else { + tempB[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + +if (((tempA[0 ] >>63 ) &0x01 ) ==0 ) { + tempA[1 ] =0x00 ; + }else { + tempA[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = tempB[0 ] - tempA[0 ]; +if ((uint64_t )temp_sum > (uint64_t )tempB[0 ]) { + tempB[1 ] -=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] = tempB[1 ] - tempA[1 ]; + +if ((temp[1 ] &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )acc[0 ]) && + ((uint64_t )temp_sum < (uint64_t )temp[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} +#endif + +void helper_maq_s_w_phl (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rth; +int32_t tempA; +int64_t tempL, tempAL, acc; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rth = (rt &MIPSDSP_HI ) >>16 ; + tempA =mipsdsp_mul_q15_q15 (env, ac, rsh, rth); + tempAL = tempA; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempL = tempAL + acc; + env->active_tc.HI[ac] = (target_long)(int32_t)((tempL &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempL &MIPSDSP_LLO ); +} + +void helper_maq_s_w_phr (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +int16_t rsl, rtl; +int32_t tempA; +int64_t tempL, tempAL, acc; + + rsl = rs &MIPSDSP_LO ; + rtl = rt &MIPSDSP_LO ; + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rtl); + tempAL = tempA; + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + tempL = tempAL + acc; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempL &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempL &MIPSDSP_LLO ); +} + +void helper_maq_sa_w_phl (CPUMIPSState *env,uint32_t ac, +target_ulong rs,target_ulong rt) +{ +int16_t rsh, rth; +int32_t tempA; +int64_t tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rth = (rt &MIPSDSP_HI ) >>16 ; + tempA =mipsdsp_mul_q15_q15 (env, ac, rsh, rth); + tempA =mipsdsp_sat32_acc_q31 (env, ac, tempA); + tempAL = tempA; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempAL &MIPSDSP_LHI ) >> +32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempAL &MIPSDSP_LLO ); +} + +void helper_maq_sa_w_phr (CPUMIPSState *env,uint32_t ac, +target_ulong rs,target_ulong rt) +{ +int16_t rsl, rtl; +int32_t tempA; +int64_t tempAL; + + rsl = rs &MIPSDSP_LO ; + rtl = rt &MIPSDSP_LO ; + + tempA =mipsdsp_mul_q15_q15 (env, ac, rsl, rtl); + tempA =mipsdsp_sat32_acc_q31 (env, ac, tempA); + tempAL = tempA; + + env->active_tc.HI[ac] = (target_long)(int32_t)((tempAL &MIPSDSP_LHI ) >> +32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(tempAL &MIPSDSP_LLO ); +} + +/*************************************************************** +* In manual, GPR[rd](..0) <- tempB(15..0) || tempA(15..0), +* I'm not sure its means zero extend or sign extend. +* Now treat it as zero extend. +***************************************************************/ +target_ulong helper_mul_ph (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_mul_i16_i16 (env, rsh, rth); + tempA =mipsdsp_mul_i16_i16 (env, rsl, rtl); + + rd = ((tempB &MIPSDSP_LO ) <<16 ) | (tempA &MIPSDSP_LO ); + +return (target_ulong )rd; +} + +/*************************************************************** +* In manual, GPR[rd](..0) <- tempB(15..0) || tempA(15..0), +* I'm not sure its means zero extend or sign extend. +* Now treat it as zero extend. +***************************************************************/ +target_ulong helper_mul_s_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + tempB =mipsdsp_sat16_mul_i16_i16 (env, rsh, rth); + tempA =mipsdsp_sat16_mul_i16_i16 (env, rsl, rtl); + + rd = ((tempB &MIPSDSP_LO ) <<16 ) | (tempA &MIPSDSP_LO ); + +return (target_ulong )rd; +} + +target_ulong helper_mulq_s_ph (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +int16_t rsh, rsl, rth, rtl; +int32_t temp, tempB, tempA; +uint32_t rd; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB =mipsdsp_sat16_mul_q15_q15 (env, rsh, rth); + tempA =mipsdsp_sat16_mul_q15_q15 (env, rsl, rtl); + temp = ((tempB &MIPSDSP_LO ) <<16 ) | (tempA &MIPSDSP_LO ); + rd = temp; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_mulq_s_w (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rd; +int32_t tempI; +int64_t tempL; + +if ((rs ==0x80000000 ) && (rt ==0x80000000 )) { + tempL =0x7FFFFFFF00000000ull ; +set_DSPControl_overflow_flag (env,1 ,21 ); + }else { + tempL = ((int64_t )rs * (int64_t )rt) <<1 ; + } + tempI = (tempL &MIPSDSP_LHI ) >>32 ; + rd = tempI; + +return (target_long )(int32_t )rd; +} + +target_ulong helper_mulq_rs_w (CPUMIPSState *env, +target_ulong rs,target_ulong rt) +{ +uint32_t rd; +uint32_t rs_t, rt_t; +uint32_t tempI; +int64_t tempL; + + rs_t = rs &MIPSDSP_LLO ; + rt_t = rt &MIPSDSP_LLO ; + +if ((rs_t ==0x80000000 ) && (rt_t ==0x80000000 )) { + tempL =0x7FFFFFFF00000000ull ; +set_DSPControl_overflow_flag (env,1 ,21 ); + }else { + tempL = ((int64_t )rs_t * (int64_t )rt_t) <<1 ; + tempL +=0x80000000ull ; + } + tempI = (tempL &MIPSDSP_LHI ) >>32 ; + rd = tempI; + +return (target_long )(int32_t )rd; +} + +void helper_mulsa_w_ph (CPUMIPSState *env, +uint32_t ac,target_ulong rs,target_ulong rt) +{ +uint16_t rsh, rsl, rth, rtl; +int32_t tempB, tempA; +int64_t dotp, acc, tempBL, tempAL; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempB = (int32_t )rsh * (int32_t )rth; + tempA = (int32_t )rsl * (int32_t )rtl; + tempBL = tempB; + tempAL = tempA; + + dotp = tempBL - tempAL; + acc = ((int64_t )env->active_tc.HI[ac] <<32 ) | + ((int64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + acc = acc + dotp; + + env->active_tc.HI[ac] = (target_long)(int32_t)((acc &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_long)(int32_t)(acc &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_maq_s_w_qhll (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp_mul; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs_t = (rs >>48 ) &MIPSDSP_LO ; + rt_t = (rt >>48 ) &MIPSDSP_LO ; + temp_mul =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + + temp[0 ] = (int64_t )temp_mul; +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )acc[0 ]) && + ((uint64_t )temp_sum < (uint64_t )temp[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_s_w_qhlr (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp_mul; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs_t = (rs >>32 ) &MIPSDSP_LO ; + rt_t = (rt >>32 ) &MIPSDSP_LO ; + temp_mul =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + + temp[0 ] = (int64_t )temp_mul; +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )acc[0 ]) && + ((uint64_t )temp_sum < (uint64_t )temp[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_s_w_qhrl (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp_mul; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs_t = (rs >>16 ) &MIPSDSP_LO ; + rt_t = (rt >>16 ) &MIPSDSP_LO ; + temp_mul =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + + temp[0 ] = (int64_t )temp_mul; +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )acc[0 ]) && + ((uint64_t )temp_sum < (uint64_t )temp[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_s_w_qhrr (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp_mul; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs_t = rs &MIPSDSP_LO ; + rt_t = rt &MIPSDSP_LO ; + temp_mul =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + + temp[0 ] = (int64_t )temp_mul; +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )acc[0 ]) && + ((uint64_t )temp_sum < (uint64_t )temp[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_sa_w_qhll (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp; +int64_t acc[2 ]; + + rs_t = (rs >>48 ) &MIPSDSP_LO ; + rt_t = (rt >>48 ) &MIPSDSP_LO ; + temp =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + temp =mipsdsp_sat32_acc_q31 (env, ac, temp); + + acc[0 ] = (int64_t )(int32_t )temp; +if (((acc[0 ] >>63 ) &0x01 ) ==0 ) { + acc[1 ] =0x00 ; + }else { + acc[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_sa_w_qhlr (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp; +int64_t acc[2 ]; + + rs_t = (rs >>32 ) &MIPSDSP_LO ; + rt_t = (rt >>32 ) &MIPSDSP_LO ; + temp =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + temp =mipsdsp_sat32_acc_q31 (env, ac, temp); + + acc[0 ] = (int64_t )temp; +if (((acc[0 ] >>63 ) &0x01 ) ==0 ) { + acc[1 ] =0x00 ; + }else { + acc[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_sa_w_qhrl (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp; +int64_t acc[2 ]; + + rs_t = (rs >>16 ) &MIPSDSP_LO ; + rt_t = (rt >>16 ) &MIPSDSP_LO ; + temp =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + temp =mipsdsp_sat32_acc_q31 (env, ac, temp); + + acc[0 ] = (int64_t )temp; +if (((acc[0 ] >>63 ) &0x01 ) ==0 ) { + acc[1 ] =0x00 ; + }else { + acc[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_sa_w_qhrr (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int16_t rs_t, rt_t; +int32_t temp; +int64_t acc[2 ]; + + rs_t = rs &MIPSDSP_LO ; + rt_t = rt &MIPSDSP_LO ; + temp =mipsdsp_mul_q15_q15 (env, ac, rs_t, rt_t); + temp =mipsdsp_sat32_acc_q31 (env, ac, temp); + + acc[0 ] = (int64_t )temp; +if (((acc[0 ] >>63 ) &0x01 ) ==0 ) { + acc[1 ] =0x00 ; + }else { + acc[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_s_l_pwl (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs_t, rt_t; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs_t = (rs >>32 ) &MIPSDSP_LLO ; + rt_t = (rt >>32 ) &MIPSDSP_LLO ; + + temp[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs_t, rt_t); +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )temp[0 ]) && + ((uint64_t )temp_sum < (uint64_t )acc[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_maq_s_l_pwr (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs_t, rt_t; +int64_t temp[2 ]; +int64_t acc[2 ]; +int64_t temp_sum; + + temp[0 ] =0 ; + temp[1 ] =0 ; + + rs_t = rs &MIPSDSP_LLO ; + rt_t = rt &MIPSDSP_LLO ; + + temp[0 ] =mipsdsp_mul_q31_q31 (env, ac, rs_t, rt_t); +if (((temp[0 ] >>63 ) &0x01 ) ==0 ) { + temp[1 ] =0x00 ; + }else { + temp[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; + + temp_sum = acc[0 ] + temp[0 ]; +if (((uint64_t )temp_sum < (uint64_t )temp[0 ]) && + ((uint64_t )temp_sum < (uint64_t )acc[0 ])) { + acc[1 ] +=1 ; + } + acc[0 ] = temp_sum; + acc[1 ] += temp[1 ]; + + env->active_tc.HI[ac] = acc[1 ]; + env->active_tc.LO[ac] = acc[0 ]; +} + +void helper_dmadd (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs1, rs0; +int32_t rt1, rt0; +int32_t tempB, tempA; +int64_t tempBL[2 ], tempAL[2 ]; +int64_t acc[2 ]; +int64_t temp[2 ]; +int64_t temp_sum; + + temp[0 ] =0x00 ; + temp[1 ] =0x00 ; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB = rs1 * rt1; + tempA = rs0 * rt0; + + tempBL[0 ] = (int64_t )tempB; + tempAL[0 ] = (int64_t )tempA; + +if (((tempBL[0 ] >>63 ) &0x01 ) ==0 ) { + tempBL[1 ] =0x0 ; + }else { + tempBL[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + +if (((tempAL[0 ] >>63 ) &0x01 ) ==0 ) { + tempAL[1 ] =0x0 ; + }else { + tempAL[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[1 ] = env->active_tc.HI[ac]; + acc[0 ] = env->active_tc.LO[ac]; + + temp_sum = tempBL[0 ] + tempAL[0 ]; +if (((uint64_t )temp_sum < (uint64_t )tempBL[0 ]) && + ((uint64_t )temp_sum < (uint64_t )tempAL[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += tempBL[1 ] + tempAL[1 ]; + + temp_sum = temp[0 ] + acc[0 ]; +if (((uint64_t )temp_sum < (uint64_t )temp[0 ]) && + ((uint64_t )temp_sum < (uint64_t )acc[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} + +void helper_dmaddu (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +uint32_t rs1, rs0; +uint32_t rt1, rt0; +uint64_t tempBL[2 ], tempAL[2 ]; +uint64_t acc[2 ]; +uint64_t temp[2 ]; +uint64_t temp_sum; + + temp[0 ] =0x00 ; + temp[1 ] =0x00 ; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempBL[0 ] =mipsdsp_mul_u32_u32 (env, rs1, rt1); + tempAL[0 ] =mipsdsp_mul_u32_u32 (env, rs0, rt0); + tempBL[1 ] =0 ; + tempAL[1 ] =0 ; + + acc[1 ] = env->active_tc.HI[ac]; + acc[0 ] = env->active_tc.LO[ac]; + + temp_sum = tempBL[0 ] + tempAL[0 ]; +if ((temp_sum < tempBL[0 ]) && (temp_sum < tempAL[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += tempBL[1 ] + tempAL[1 ]; + + temp_sum = temp[0 ] + acc[0 ]; +if ((temp_sum < temp[0 ]) && (temp_sum < acc[0 ])) { + temp[1 ] +=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} + +void helper_dmsub (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +int32_t rs1, rs0; +int32_t rt1, rt0; +int32_t tempB, tempA; +int64_t tempBL[2 ], tempAL[2 ]; +int64_t acc[2 ]; +int64_t temp[2 ]; +int64_t temp_sum; + + temp[0 ] =0x00 ; + temp[1 ] =0x00 ; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempB = rs1 * rt1; + tempA = rs0 * rt0; + + tempBL[0 ] = (int64_t )tempB; + tempAL[0 ] = (int64_t )tempA; + +if (((tempBL[0 ] >>63 ) &0x01 ) ==0 ) { + tempBL[1 ] =0x0 ; + }else { + tempBL[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + +if (((tempAL[0 ] >>63 ) &0x01 ) ==0 ) { + tempAL[1 ] =0x0 ; + }else { + tempAL[1 ] =0xFFFFFFFFFFFFFFFFull ; + } + + acc[1 ] = env->active_tc.HI[ac]; + acc[0 ] = env->active_tc.LO[ac]; + + temp_sum = acc[0 ] - tempBL[0 ]; +if ((uint64_t )temp_sum > (uint64_t )acc[0 ]) { + temp[1 ] -=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ] - tempBL[1 ]; + + temp_sum = temp[0 ] - tempAL[0 ]; +if ((uint64_t )temp_sum > (uint64_t )temp[0 ]) { + temp[1 ] -=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] -= tempAL[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} + +void helper_dmsubu (CPUMIPSState *env, +target_ulong rs,target_ulong rt,uint32_t ac) +{ +uint32_t rs1, rs0; +uint32_t rt1, rt0; +uint64_t tempBL[2 ], tempAL[2 ]; +uint64_t acc[2 ]; +uint64_t temp[2 ]; +uint64_t temp_sum; + + temp[0 ] =0x00 ; + temp[1 ] =0x00 ; + + rs1 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempBL[0 ] =mipsdsp_mul_u32_u32 (env, rs1, rt1); + tempAL[0 ] =mipsdsp_mul_u32_u32 (env, rs0, rt0); + tempBL[1 ] =0 ; + tempAL[1 ] =0 ; + + acc[1 ] = env->active_tc.HI[ac]; + acc[0 ] = env->active_tc.LO[ac]; + + temp_sum = acc[0 ] - tempBL[0 ]; +if (temp_sum > acc[0 ]) { + temp[1 ] -=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] += acc[1 ] - tempBL[1 ]; + + temp_sum = temp[0 ] - tempAL[0 ]; +if ((uint64_t )temp_sum > (uint64_t )temp[0 ]) { + temp[1 ] -=1 ; + } + temp[0 ] = temp_sum; + temp[1 ] -= tempAL[1 ]; + + env->active_tc.HI[ac] = temp[1 ]; + env->active_tc.LO[ac] = temp[0 ]; +} +#endif +#undef MIPSDSP_LHI#undef MIPSDSP_LLO#undef MIPSDSP_HItarget-mips/helper.h +91
-0@@ -491,4 +491,95 @@ DEF_HELPER_FLAGS_2(shra_r_pw, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, i32) DEF_HELPER_FLAGS_2(shrav_r_pw, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl)#endif +/* DSP Multiply Sub-class insns */ +DEF_HELPER_FLAGS_3(muleu_s_ph_qbl, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(muleu_s_ph_qbr, 0, tl, env, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(muleu_s_qh_obl, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(muleu_s_qh_obr, 0, tl, env, tl, tl) +#endif +DEF_HELPER_FLAGS_3(mulq_rs_ph, 0, tl, env, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(mulq_rs_qh, 0, tl, env, tl, tl) +#endif +DEF_HELPER_FLAGS_3(muleq_s_w_phl, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(muleq_s_w_phr, 0, tl, env, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(muleq_s_pw_qhl, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(muleq_s_pw_qhr, 0, tl, env, tl, tl) +#endif +DEF_HELPER_FLAGS_4(dpau_h_qbl, 0, void, env, i32, tl, tl) +DEF_HELPER_FLAGS_4(dpau_h_qbr, 0, void, env, i32, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dpau_h_obl, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(dpau_h_obr, 0, void, env, tl, tl, i32) +#endif +DEF_HELPER_FLAGS_4(dpsu_h_qbl, 0, void, env, i32, tl, tl) +DEF_HELPER_FLAGS_4(dpsu_h_qbr, 0, void, env, i32, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dpsu_h_obl, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(dpsu_h_obr, 0, void, env, tl, tl, i32) +#endif +DEF_HELPER_FLAGS_4(dpa_w_ph, 0, void, env, i32, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dpa_w_qh, 0, void, env, tl, tl, i32) +#endif +DEF_HELPER_FLAGS_4(dpax_w_ph, 0, void, env, i32, tl, tl) +DEF_HELPER_FLAGS_4(dpaq_s_w_ph, 0, void, env, i32, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dpaq_s_w_qh, 0, void, env, tl, tl, i32) +#endif +DEF_HELPER_FLAGS_4(dpaqx_s_w_ph, 0, void, env, i32, tl, tl) +DEF_HELPER_FLAGS_4(dpaqx_sa_w_ph, 0, void, env, i32, tl, tl) +DEF_HELPER_FLAGS_4(dps_w_ph, 0, void, env, i32, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dps_w_qh, 0, void, env, tl, tl, i32) +#endif +DEF_HELPER_FLAGS_4(dpsx_w_ph, 0, void, env, i32, tl, tl) +DEF_HELPER_FLAGS_4(dpsq_s_w_ph, 0, void, env, i32, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dpsq_s_w_qh, 0, void, env, tl, tl, i32) +#endif +DEF_HELPER_FLAGS_4(dpsqx_s_w_ph, 0, void, env, i32, tl, tl) +DEF_HELPER_FLAGS_4(dpsqx_sa_w_ph, 0, void, env, i32, tl, tl) +DEF_HELPER_FLAGS_4(mulsaq_s_w_ph, 0, void, env, i32, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(mulsaq_s_w_qh, 0, void, env, tl, tl, i32) +#endif +DEF_HELPER_FLAGS_4(dpaq_sa_l_w, 0, void, env, i32, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dpaq_sa_l_pw, 0, void, env, tl, tl, i32) +#endif +DEF_HELPER_FLAGS_4(dpsq_sa_l_w, 0, void, env, i32, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dpsq_sa_l_pw, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(mulsaq_s_l_pw, 0, void, env, tl, tl, i32) +#endif +DEF_HELPER_FLAGS_4(maq_s_w_phl, 0, void, env, i32, tl, tl) +DEF_HELPER_FLAGS_4(maq_s_w_phr, 0, void, env, i32, tl, tl) +DEF_HELPER_FLAGS_4(maq_sa_w_phl, 0, void, env, i32, tl, tl) +DEF_HELPER_FLAGS_4(maq_sa_w_phr, 0, void, env, i32, tl, tl) +DEF_HELPER_FLAGS_3(mul_ph, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(mul_s_ph, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(mulq_s_ph, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(mulq_s_w, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_3(mulq_rs_w, 0, tl, env, tl, tl) +DEF_HELPER_FLAGS_4(mulsa_w_ph, 0, void, env, i32, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(maq_s_w_qhll, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(maq_s_w_qhlr, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(maq_s_w_qhrl, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(maq_s_w_qhrr, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(maq_sa_w_qhll, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(maq_sa_w_qhlr, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(maq_sa_w_qhrl, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(maq_sa_w_qhrr, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(maq_s_l_pwl, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(maq_s_l_pwr, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(dmadd, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(dmaddu, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(dmsub, 0, void, env, tl, tl, i32) +DEF_HELPER_FLAGS_4(dmsubu, 0, void, env, tl, tl, i32) +#endif +#include "def-helper.h" target-mips/translate.c +503
-0@@ -402,6 +402,13 @@ enum {OPC_ADDWC = (0x11 <<6 ) |OPC_ADDU_QB_DSP ,OPC_MODSUB = (0x12 <<6 ) |OPC_ADDU_QB_DSP ,OPC_RADDU_W_QB = (0x14 <<6 ) |OPC_ADDU_QB_DSP , +/* MIPS DSP Multiply Sub-class insns */ +OPC_MULEU_S_PH_QBL = (0x06 <<6 ) |OPC_ADDU_QB_DSP , +OPC_MULEU_S_PH_QBR = (0x07 <<6 ) |OPC_ADDU_QB_DSP , +OPC_MULQ_RS_PH = (0x1F <<6 ) |OPC_ADDU_QB_DSP , +OPC_MULEQ_S_W_PHL = (0x1C <<6 ) |OPC_ADDU_QB_DSP , +OPC_MULEQ_S_W_PHR = (0x1D <<6 ) |OPC_ADDU_QB_DSP , + OPC_MULQ_S_PH = (0x1E << 6) | OPC_ADDU_QB_DSP, };#define OPC_ADDUH_QB_DSP OPC_MULT_G_2E@@ -420,6 +427,11 @@ enum {OPC_SUBQH_R_PH = (0x0B <<6 ) |OPC_ADDUH_QB_DSP ,OPC_SUBQH_W = (0x11 <<6 ) |OPC_ADDUH_QB_DSP ,OPC_SUBQH_R_W = (0x13 <<6 ) |OPC_ADDUH_QB_DSP , +/* MIPS DSP Multiply Sub-class insns */ +OPC_MUL_PH = (0x0C <<6 ) |OPC_ADDUH_QB_DSP , +OPC_MUL_S_PH = (0x0E <<6 ) |OPC_ADDUH_QB_DSP , +OPC_MULQ_S_W = (0x16 <<6 ) |OPC_ADDUH_QB_DSP , + OPC_MULQ_RS_W = (0x17 << 6) | OPC_ADDUH_QB_DSP, };#define MASK_ABSQ_S_PH (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))@@ -451,6 +463,7 @@ enum {OPC_PRECRQ_RS_PH_W = (0x15 <<6 ) |OPC_CMPU_EQ_QB_DSP , OPC_PRECRQU_S_QB_PH = (0x0F << 6) | OPC_CMPU_EQ_QB_DSP, }; +#define MASK_SHLL_QB (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))enum { /* MIPS DSP GPR-Based Shift Sub-class */@@ -478,6 +491,33 @@ enum { OPC_SHRAV_R_W = (0x17 << 6) | OPC_SHLL_QB_DSP, }; +#define MASK_DPA_W_PH (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* MIPS DSP Multiply Sub-class insns */ +OPC_DPAU_H_QBL = (0x03 <<6 ) |OPC_DPA_W_PH_DSP , +OPC_DPAU_H_QBR = (0x07 <<6 ) |OPC_DPA_W_PH_DSP , +OPC_DPSU_H_QBL = (0x0B <<6 ) |OPC_DPA_W_PH_DSP , +OPC_DPSU_H_QBR = (0x0F <<6 ) |OPC_DPA_W_PH_DSP , +OPC_DPA_W_PH = (0x00 <<6 ) |OPC_DPA_W_PH_DSP , +OPC_DPAX_W_PH = (0x08 <<6 ) |OPC_DPA_W_PH_DSP , +OPC_DPAQ_S_W_PH = (0x04 <<6 ) |OPC_DPA_W_PH_DSP , +OPC_DPAQX_S_W_PH = (0x18 <<6 ) |OPC_DPA_W_PH_DSP , +OPC_DPAQX_SA_W_PH = (0x1A <<6 ) |OPC_DPA_W_PH_DSP , +OPC_DPS_W_PH = (0x01 <<6 ) |OPC_DPA_W_PH_DSP , +OPC_DPSX_W_PH = (0x09 <<6 ) |OPC_DPA_W_PH_DSP , +OPC_DPSQ_S_W_PH = (0x05 <<6 ) |OPC_DPA_W_PH_DSP , +OPC_DPSQX_S_W_PH = (0x19 <<6 ) |OPC_DPA_W_PH_DSP , +OPC_DPSQX_SA_W_PH = (0x1B <<6 ) |OPC_DPA_W_PH_DSP , +OPC_MULSAQ_S_W_PH = (0x06 <<6 ) |OPC_DPA_W_PH_DSP , +OPC_DPAQ_SA_L_W = (0x0C <<6 ) |OPC_DPA_W_PH_DSP , +OPC_DPSQ_SA_L_W = (0x0D <<6 ) |OPC_DPA_W_PH_DSP , +OPC_MAQ_S_W_PHL = (0x14 <<6 ) |OPC_DPA_W_PH_DSP , +OPC_MAQ_S_W_PHR = (0x16 <<6 ) |OPC_DPA_W_PH_DSP , +OPC_MAQ_SA_W_PHL = (0x10 <<6 ) |OPC_DPA_W_PH_DSP , +OPC_MAQ_SA_W_PHR = (0x12 <<6 ) |OPC_DPA_W_PH_DSP , +OPC_MULSA_W_PH = (0x02 <<6 ) |OPC_DPA_W_PH_DSP , +}; +#if defined(TARGET_MIPS64 )#define MASK_ABSQ_S_QH (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) enum {@@ -505,6 +545,12 @@ enum {#if defined(TARGET_MIPS64 )#define MASK_ADDU_OB (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))enum { +/* MIPS DSP Multiply Sub-class insns */ +OPC_MULEQ_S_PW_QHL = (0x1C <<6 ) |OPC_ADDU_OB_DSP , +OPC_MULEQ_S_PW_QHR = (0x1D <<6 ) |OPC_ADDU_OB_DSP , +OPC_MULEU_S_QH_OBL = (0x06 <<6 ) |OPC_ADDU_OB_DSP , +OPC_MULEU_S_QH_OBR = (0x07 <<6 ) |OPC_ADDU_OB_DSP , +OPC_MULQ_RS_QH = (0x1F <<6 ) |OPC_ADDU_OB_DSP ,/* MIPS DSP Arithmetic Sub-class */ OPC_RADDU_L_OB = (0x14 <<6 ) |OPC_ADDU_OB_DSP , OPC_SUBQ_PW = (0x13 << 6) | OPC_ADDU_OB_DSP,@@ -546,6 +592,39 @@ enum {#endif #if defined(TARGET_MIPS64 ) +#define MASK_DPAQ_W_QH (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* MIPS DSP Multiply Sub-class insns */ +OPC_DMADD = (0x19 <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_DMADDU = (0x1D <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_DMSUB = (0x1B <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_DMSUBU = (0x1F <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_DPA_W_QH = (0x00 <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_DPAQ_S_W_QH = (0x04 <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_DPAQ_SA_L_PW = (0x0C <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_DPAU_H_OBL = (0x03 <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_DPAU_H_OBR = (0x07 <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_DPS_W_QH = (0x01 <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_DPSQ_S_W_QH = (0x05 <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_DPSQ_SA_L_PW = (0x0D <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_DPSU_H_OBL = (0x0B <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_DPSU_H_OBR = (0x0F <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_MAQ_S_L_PWL = (0x1C <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_MAQ_S_L_PWR = (0x1E <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_MAQ_S_W_QHLL = (0x14 <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_MAQ_SA_W_QHLL = (0x10 <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_MAQ_S_W_QHLR = (0x15 <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_MAQ_SA_W_QHLR = (0x11 <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_MAQ_S_W_QHRL = (0x16 <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_MAQ_SA_W_QHRL = (0x12 <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_MAQ_S_W_QHRR = (0x17 <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_MAQ_SA_W_QHRR = (0x13 <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_MULSAQ_S_L_PW = (0x0E <<6 ) |OPC_DPAQ_W_QH_DSP , +OPC_MULSAQ_S_W_QH = (0x06 <<6 ) |OPC_DPAQ_W_QH_DSP , +}; +#endif + +#if defined(TARGET_MIPS64 )#define MASK_SHLL_OB (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))enum { /* MIPS DSP GPR-Based Shift Sub-class */@@ -12465,6 +12544,22 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)case OPC_SUBQH_R_W :gen_helper_subqh_r_w (cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]);break ; +case OPC_MUL_PH : +gen_helper_mul_ph (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_MUL_S_PH : +gen_helper_mul_s_ph (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_MULQ_S_W : +gen_helper_mulq_s_w (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_MULQ_RS_W : +gen_helper_mulq_rs_w (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ;default :MIPS_INVAL ("MASK ADDUH.QB" );generate_exception (ctx,EXCP_RI );@@ -12676,6 +12771,36 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)check_dsp (ctx);gen_helper_raddu_w_qb (cpu_gpr[rd], cpu_gpr[rs]);break ; +case OPC_MULEU_S_PH_QBL : +check_dsp (ctx); +gen_helper_muleu_s_ph_qbl (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_MULEU_S_PH_QBR : +check_dsp (ctx); +gen_helper_muleu_s_ph_qbr (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_MULQ_RS_PH : +check_dsp (ctx); +gen_helper_mulq_rs_ph (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_MULEQ_S_W_PHL : +check_dsp (ctx); +gen_helper_muleq_s_w_phl (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_MULEQ_S_W_PHR : +check_dsp (ctx); +gen_helper_muleq_s_w_phr (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_MULQ_S_PH : +check_dspr2 (ctx); +gen_helper_mulq_s_ph (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ;default :/* Invalid */ MIPS_INVAL ("MASK ADDU.QB" );generate_exception (ctx,EXCP_RI );@@ -12842,6 +12967,213 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)tcg_temp_free_i32 (temp_rs);break ; } +case OPC_DPA_W_PH_DSP : + op2 =MASK_DPA_W_PH (ctx->opcode); +switch (op2) { +case OPC_DPAU_H_QBL : +check_dsp (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dpau_h_qbl (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_DPAU_H_QBR : +check_dsp (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dpau_h_qbr (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_DPSU_H_QBL : +check_dsp (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dpsu_h_qbl (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_DPSU_H_QBR : +check_dsp (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dpsu_h_qbr (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_DPA_W_PH : +check_dspr2 (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dpa_w_ph (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_DPAX_W_PH : +check_dspr2 (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dpax_w_ph (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_DPAQ_S_W_PH : +check_dsp (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dpaq_s_w_ph (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_DPAQX_S_W_PH : +check_dspr2 (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dpaqx_s_w_ph (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_DPAQX_SA_W_PH : +check_dspr2 (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dpaqx_sa_w_ph (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_DPS_W_PH : +check_dspr2 (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dps_w_ph (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_DPSX_W_PH : +check_dspr2 (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dpsx_w_ph (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_DPSQ_S_W_PH : +check_dsp (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dpsq_s_w_ph (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_DPSQX_S_W_PH : +check_dspr2 (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dpsqx_s_w_ph (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_DPSQX_SA_W_PH : +check_dspr2 (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dpsqx_sa_w_ph (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_MULSAQ_S_W_PH : +check_dsp (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_mulsaq_s_w_ph (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_DPAQ_SA_L_W : +check_dsp (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dpaq_sa_l_w (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_DPSQ_SA_L_W : +check_dsp (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_dpsq_sa_l_w (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_MAQ_S_W_PHL : +check_dsp (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_maq_s_w_phl (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_MAQ_S_W_PHR : +check_dsp (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_maq_s_w_phr (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_MAQ_SA_W_PHL : +check_dsp (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_maq_sa_w_phl (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_MAQ_SA_W_PHR : +check_dsp (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_maq_sa_w_phr (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +case OPC_MULSA_W_PH : +check_dspr2 (ctx); + { +TCGv_i32 temp_rd =tcg_const_i32 (rd); +gen_helper_mulsa_w_ph (cpu_env, temp_rd, + cpu_gpr[rs], cpu_gpr[rt]); +tcg_temp_free_i32 (temp_rd); +break ; + } +default :/* Invalid */ +MIPS_INVAL ("MASK DPAW.PH" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ;#if defined(TARGET_MIPS64 ) case OPC_DEXTM ... OPC_DEXT: case OPC_DINSM ... OPC_DINS:@@ -12945,6 +13277,31 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)case OPC_ADDU_OB_DSP : op2 =MASK_ADDU_OB (ctx->opcode);switch (op2) { +case OPC_MULEQ_S_PW_QHL : +check_dsp (ctx); +gen_helper_muleq_s_pw_qhl (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_MULEQ_S_PW_QHR : +check_dsp (ctx); +gen_helper_muleq_s_pw_qhr (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_MULEU_S_QH_OBL : +check_dsp (ctx); +gen_helper_muleu_s_qh_obl (cpu_gpr[rd], + cpu_env, cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_MULEU_S_QH_OBR : +check_dsp (ctx); +gen_helper_muleu_s_qh_obr (cpu_gpr[rd], + cpu_env, cpu_gpr[rs], cpu_gpr[rt]); +break ; +case OPC_MULQ_RS_QH : +check_dsp (ctx); +gen_helper_mulq_rs_qh (cpu_gpr[rd], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ;case OPC_RADDU_L_OB :check_dsp (ctx);gen_helper_raddu_l_ob (cpu_gpr[rd], cpu_gpr[rs]);@@ -13112,6 +13469,152 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)break ;#endif #if defined(TARGET_MIPS64 ) +case OPC_DPAQ_W_QH_DSP : + { +int ac = rd &0x03 ; +TCGv_i32 ac_v =tcg_const_i32 (ac); + + op2 =MASK_DPAQ_W_QH (ctx->opcode); + +switch (op2) { +case OPC_DMADD : +check_dsp (ctx); +gen_helper_dmadd (cpu_env, cpu_gpr[rs], cpu_gpr[rt], ac_v); +break ; +case OPC_DMADDU : +check_dsp (ctx); +gen_helper_dmaddu (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_DMSUB : +check_dsp (ctx); +gen_helper_dmsub (cpu_env, cpu_gpr[rs], cpu_gpr[rt], ac_v); +break ; +case OPC_DMSUBU : +check_dsp (ctx); +gen_helper_dmsubu (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_DPA_W_QH : +check_dspr2 (ctx); +gen_helper_dpa_w_qh (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_DPAQ_S_W_QH : +check_dsp (ctx); +gen_helper_dpaq_s_w_qh (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_DPAQ_SA_L_PW : +check_dsp (ctx); +gen_helper_dpaq_sa_l_pw (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_DPAU_H_OBL : +check_dsp (ctx); +gen_helper_dpau_h_obl (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_DPAU_H_OBR : +check_dsp (ctx); +gen_helper_dpau_h_obr (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_DPS_W_QH : +check_dspr2 (ctx); +gen_helper_dps_w_qh (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_DPSQ_S_W_QH : +check_dsp (ctx); +gen_helper_dpsq_s_w_qh (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_DPSQ_SA_L_PW : +check_dsp (ctx); +gen_helper_dpsq_sa_l_pw (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_DPSU_H_OBL : +check_dsp (ctx); +gen_helper_dpsu_h_obl (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_DPSU_H_OBR : +check_dsp (ctx); +gen_helper_dpsu_h_obr (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_MAQ_S_L_PWL : +check_dsp (ctx); +gen_helper_maq_s_l_pwl (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_MAQ_S_L_PWR : +check_dsp (ctx); +gen_helper_maq_s_l_pwr (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_MAQ_S_W_QHLL : +check_dsp (ctx); +gen_helper_maq_s_w_qhll (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_MAQ_SA_W_QHLL : +check_dsp (ctx); +gen_helper_maq_sa_w_qhll (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_MAQ_S_W_QHLR : +check_dsp (ctx); +gen_helper_maq_s_w_qhlr (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_MAQ_SA_W_QHLR : +check_dsp (ctx); +gen_helper_maq_sa_w_qhlr (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_MAQ_S_W_QHRL : +check_dsp (ctx); +gen_helper_maq_s_w_qhrl (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_MAQ_SA_W_QHRL : +check_dsp (ctx); +gen_helper_maq_sa_w_qhrl (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_MAQ_S_W_QHRR : +check_dsp (ctx); +gen_helper_maq_s_w_qhrr (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_MAQ_SA_W_QHRR : +check_dsp (ctx); +gen_helper_maq_sa_w_qhrr (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_MULSAQ_S_L_PW : +check_dsp (ctx); +gen_helper_mulsaq_s_l_pw (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +case OPC_MULSAQ_S_W_QH : +check_dsp (ctx); +gen_helper_mulsaq_s_w_qh (cpu_env, cpu_gpr[rs], + cpu_gpr[rt], ac_v); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK DPAQ.W.QH" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +tcg_temp_free_i32 (ac_v); +break ; + } +#endif +#if defined(TARGET_MIPS64 )case OPC_SHLL_OB_DSP : op2 =MASK_SHLL_OB (ctx->opcode);switch (op2) {Signature · 1 line
1.7.9.5
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v7 9/14 target-mips-ase-dsp: Add bit/manipulation instructions
In reply to Jia LiuAdd MIPS ASE DSP Bit/Manipulation instructions.
--- target-mips/dsp_helper.c | 79 ++++++++++++++ target-mips/helper.h | 7 ++ target-mips/translate.c | 268 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 353 insertions(+), 1 deletion(-)
target-mips/dsp_helper.c +79 -0
@@ -6211,6 +6211,85 @@ void helper_dmsubu(CPUMIPSState *env, }#endif +/** DSP Bit/Manipulation Sub-class insns **/ +target_ulong helper_bitrev (target_ulong rt) +{ +int32_t temp; +uint32_t rd; +int i, last; + + temp = rt &MIPSDSP_LO ; + rd =0 ; +for (i =0 ; i <16 ; i++) { + last = temp %2 ; + temp = temp >>1 ; + rd = rd | (last << (15 - i)); + } + +return (target_ulong )rd; +} + +target_ulong helper_insv (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +uint32_t pos, size, msb, lsb, rs_f, rt_f; +uint32_t temp, temprs, temprt; +uint32_t rs_notword, rt_notword; +target_ulong dspc; + + dspc = env->active_tc.DSPControl; + pos = dspc &0x1F ; + size = (dspc >>7 ) &0x1F ; + msb = pos + size -1 ; + lsb = pos; + + rs_notword =not_word_value (rs); + rt_notword =not_word_value (rt); + +if ((lsb > msb) || (rs_notword ==1 ) || (rt_notword ==1 )) { +return rt; + } + + rs_f = (((int32_t )0x01 << (msb - lsb +1 +1 )) -1 ) << lsb; + rt_f = rs_f ^0xFFFFFFFF ; + temprs = rs & rs_f; + temprt = rt & rt_f; + temp = temprs | temprt; + +return (target_long )(int32_t )temp; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_dinsv (CPUMIPSState *env,target_ulong rs,target_ulong rt) +{ +target_ulong dspctrl; +target_ulong filter; +uint8_t pos, size; +uint8_t msb, lsb; +uint64_t temp; + + temp = rt; + dspctrl = env->active_tc.DSPControl; + pos = dspctrl &0x7F ; + size = (dspctrl >>7 ) &0x3F ; + + msb = pos + size -1 ; + lsb = pos; + +if ((lsb > msb) || (msb >63 )) { +return temp; + } + + temp =0 ; + filter = ((target_ulong )0x01 << size) -1 ; + filter = filter << pos; + + temp |= rs & filter; + temp |= rt & (~filter); + +return temp; +} +#endif +#undef MIPSDSP_LHI#undef MIPSDSP_LLO#undef MIPSDSP_HI
target-mips/helper.h +7 -0
@@ -582,4 +582,11 @@ DEF_HELPER_FLAGS_4(dmsub, 0, void, env, tl, tl, i32) DEF_HELPER_FLAGS_4(dmsubu, 0, void, env, tl, tl, i32)#endif +/* DSP Bit/Manipulation Sub-class insns */ +DEF_HELPER_FLAGS_1(bitrev, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl) +DEF_HELPER_FLAGS_3(insv, 0, tl, env, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3 (dinsv,0 , tl, env, tl, tl); +#endif +#include "def-helper.h"
target-mips/translate.c +267 -1
328 lines not on this page · raw message
Signature · 1 line
1.7.9.5