QEMU MIPS ASE DSP support
v9 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:
v9:
Addressed Aurelien's review comments:
- group translate actions by opcode
- group helpers using macro
- remove unused function not_word_value
- add absolute macro, overflow check macro, split/combine number macro
- undo delete bposge32/64 from micromips
- add return register 0 check
v8:
Addressed Aurelien's review comments:
- fix HFLAGS check, I hope it is right this time
- make a lot of code more clean
- fix branch instructions
- fix load instructions, I hope it is right this time
- fix bit instructions
- use a macro to deal CMP
- use 74kf instead of mips32dspr2
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 funtions
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 | 27 +- target-mips/dsp_helper.c | 4109 ++++++++++++++++++++++++ target-mips/helper.c | 3 + target-mips/helper.h | 349 ++ target-mips/translate.c | 3074 +++++++++++++++++- target-mips/translate_init.c | 52 + tests/tcg/mips/mips32-dsp/Makefile | 135 + 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_phl.c | 41 + 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 | 305 ++ 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_phl.c | 46 + 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 + 496 files changed, 23383 insertions(+), 111 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_phl.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_phl.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.10.2 (Apple Git-33)
PATCH v9 1/14 target-mips-ase-dsp: Add internal funtions
Add internal functions using by MIPS ASE DSP instructions.
--- target-mips/Makefile.objs | 2 +- target-mips/dsp_helper.c | 1121 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1122 insertions(+), 1 deletion(-) create mode 100644 target-mips/dsp_helper.c
target-mips/Makefile.objs +1 -1
@@ -1,2 +1,2 @@ -obj-y += translate.o op_helper.o lmi_helper.o helper.o cpu.o +obj-y += translate.o dsp_helper.o op_helper.o lmi_helper.o helper.o cpu.o obj-$(CONFIG_SOFTMMU) += machine.o
target-mips/dsp_helper.c new file +1121 -0
1,121 lines not on this page · raw message
Signature · 1 line
1.7.10.2 (Apple Git-33)
Re: [Qemu-devel] [PATCH v9 01/14] target-mips-ase-dsp: Add internal funtions
Quoted 148 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 | 1121 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1122 insertions(+), 1 deletion(-) create mode 100644 target-mips/dsp_helper.ctarget-mips/Makefile.objs +1
-1@@ -1,2 +1,2 @@ -obj-y += translate.o op_helper.o lmi_helper.o helper.o cpu.o +obj-y += translate.o dsp_helper.o op_helper.o lmi_helper.o helper.o cpu.o obj-$(CONFIG_SOFTMMU) += machine.otarget-mips/dsp_helper.c new file +125
-0@@ -0,0 +1,1121 @@ +/* +* 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 ***/ +#define MIPSDSP_ABS (x) (((x) >= 0) ? x : -x) +#define MIPSDSP_OVERFLOW (a, b, c, d) (!(!((a ^ b ^ -1) & (a ^ c) & d))) + +static inline void set_DSPControl_overflow_flag (uint32_t flag,int position, +CPUMIPSState *env) +{ + env->active_tc.DSPControl |= (target_ulong )flag << position; +} + +static inline void set_DSPControl_carryflag (uint32_t flag,CPUMIPSState *env) +{ + env->active_tc.DSPControl |= (target_ulong )flag <<13 ; +} + +static inline uint32_t get_DSPControl_carryflag (CPUMIPSState *env) +{ +return (env->active_tc.DSPControl >>13 ) &0x01 ; +} + +static inline void set_DSPControl_24 (uint32_t flag,int len,CPUMIPSState *env) +{ +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 (int len,CPUMIPSState *env) +{ +uint32_t filter; + + filter = (0x01 << len) -1 ; + +return (env->active_tc.DSPControl >>24 ) & filter; +} + +static inline void set_DSPControl_pos (uint32_t pos,CPUMIPSState *env) +{ +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 (uint32_t flag,CPUMIPSState *env) +{ + env->active_tc.DSPControl &=0xFFFFBFFF ; + env->active_tc.DSPControl |= (target_ulong )flag <<14 ; +} + +/* get abs value */ +static inline int8_t mipsdsp_sat_abs_u8 (int8_t a,CPUMIPSState *env) +{ +if (a ==INT8_MIN ) { +set_DSPControl_overflow_flag (1 ,20 , env); +return 0x7f ; + }else { +return MIPSDSP_ABS (a); + } + +return a; +} + +static inline int16_t mipsdsp_sat_abs_u16 (int16_t a,CPUMIPSState *env) +{ +if (a ==INT16_MIN ) { +set_DSPControl_overflow_flag (1 ,20 , env); +return 0x7fff ; + }else { +return MIPSDSP_ABS (a); + } + +return a; +} + +static inline int32_t mipsdsp_sat_abs_u32 (int32_t a,CPUMIPSState *env)
target-mips/dsp_helper.c line 135
Quoted 10 lines
target-mips/dsp_helper.c new file +10
-0+{ +if (a ==INT32_MIN ) { +set_DSPControl_overflow_flag (1 ,20 , env); +return 0x7FFFFFFF ; + }else { +return MIPSDSP_ABS (a); + } + +return a; +}
The "return a" is useless in the three functions above. Also I don't get why this functions have a u8, u16 and u32 prefix, while they don't work on unsigned number but rather signed number.
Also note that you could replace the 3 functions above by something like:
#define DO_MIPS_SAT_ABS(size) \
static inline int##size##_t mipsdsp_sat_abs_u##size(int##size##a, \
CPUMIPSState *env) \
{ \
if (a == INT##size##_MIN) { \
set_DSPControl_overflow_flag(1, 20, env); \
return INT##size##_MAX; \
} else { \
return MIPSDSP_ABS(a); \
} \
}DO_MIPS_SAT_ABS(8)DO_MIPS_SAT_ABS(16)DO_MIPS_SAT_ABS(32)
#undef DO_MIPS_SAT_ABS
Quoted 246 lines
target-mips/dsp_helper.c new file +246
-0+/* get sum value */ +static inline int16_t mipsdsp_add_i16 (int16_t a,int16_t b,CPUMIPSState *env) +{ +int16_t tempI; + + tempI = a + b; + +if (MIPSDSP_OVERFLOW (a, b, tempI,0x8000 )) { +set_DSPControl_overflow_flag (1 ,20 , env); + } + +return tempI; +} + +static inline int16_t mipsdsp_sat_add_i16 (int16_t a,int16_t b, +CPUMIPSState *env) +{ +int16_t tempS; + + tempS = a + b; + +if (MIPSDSP_OVERFLOW (a, b, tempS,0x8000 )) { +if (a >0 ) { + tempS =0x7FFF ; + }else { + tempS =0x8000 ; + } +set_DSPControl_overflow_flag (1 ,20 , env); + } + +return tempS; +} + +static inline int32_t mipsdsp_sat_add_i32 (int32_t a,int32_t b, +CPUMIPSState *env) +{ +int32_t tempI; + + tempI = a + b; + +if (MIPSDSP_OVERFLOW (a, b, tempI,0x80000000 )) { +if (a >0 ) { + tempI =0x7FFFFFFF ; + }else { + tempI =0x80000000 ; + } +set_DSPControl_overflow_flag (1 ,20 , env); + } + +return tempI; +} + +static inline uint8_t mipsdsp_add_u8 (uint8_t a,uint8_t b,CPUMIPSState *env) +{ +uint16_t temp; + + temp = (uint16_t )a + (uint16_t )b; + +if (temp &0x0100 ) { +set_DSPControl_overflow_flag (1 ,20 , env); + } + +return temp &0xFF ; +} + +static inline uint16_t mipsdsp_add_u16 (uint16_t a,uint16_t b, +CPUMIPSState *env) +{ +uint32_t temp; + + temp = (uint32_t )a + (uint32_t )b; + +if (temp &0x00010000 ) { +set_DSPControl_overflow_flag (1 ,20 , env); + } + +return temp &0xFFFF ; +} + +static inline uint8_t mipsdsp_sat_add_u8 (uint8_t a,uint8_t b, +CPUMIPSState *env) +{ +uint8_t result; +uint16_t temp; + + temp = (uint16_t )a + (uint16_t )b; + result = temp &0xFF ; + +if (0x0100 & temp) { + result =0xFF ; +set_DSPControl_overflow_flag (1 ,20 , env); + } + +return result; +} + +static inline uint16_t mipsdsp_sat_add_u16 (uint16_t a,uint16_t b, +CPUMIPSState *env) +{ +uint16_t result; +uint32_t temp; + + temp = (uint32_t )a + (uint32_t )b; + result = temp &0xFFFF ; + +if (0x00010000 & temp) { + result =0xFFFF ; +set_DSPControl_overflow_flag (1 ,20 , env); + }> + + return result; +} + +static inline int32_t mipsdsp_sat32_acc_q31 (int32_t acc,int32_t a, +CPUMIPSState *env) +{ +int64_t 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 + + temp_sum = (int64_t )a + temp; + + temp32 = (temp_sum >>32 ) &0x01 ; + temp31 = (temp_sum >>31 ) &0x01 ; + result = temp_sum &0xFFFFFFFF ; + +if (temp32 != temp31) { +if (temp32 ==0 ) { + result =0x7FFFFFFF ; + }else { + result =0x80000000 ; + } +set_DSPControl_overflow_flag (1 ,16 + acc, env); + } + +return result; +} + +/* a[0] is LO, a[1] is HI. */ +static inline void mipsdsp_sat64_acc_add_q63 (int64_t *ret, +int32_t ac, +int64_t *a, +CPUMIPSState *env) +{ +int64_t temp[3 ]; +int64_t acc[3 ]; +int64_t temp_sum; + + temp[0 ] = a[0 ]; + temp[1 ] = a[1 ]; +if (temp[1 ] >=0 ) { + temp[2 ] =0x00 ; + }else { + temp[2 ] = ~0ull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; +if (acc[1 ] >=0 ) { + acc[2 ] =0x00 ; + }else { + acc[2 ] = ~0ull ; + } + + 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 ; + } + +if (MIPSDSP_OVERFLOW (temp[1 ], acc[1 ], temp_sum,INT64_MIN )) { +if (temp[1 ] >0 ) { + ret[0 ] =0x0 ; + ret[1 ] =0x7FFFFFFFFFFFFFFFull ; + }else { + ret[0 ] =0x8000000000000000ull ; + ret[1 ] = ~0ull ; + } +set_DSPControl_overflow_flag (1 ,16 + ac, env); + }else { + ret[0 ] = temp[0 ]; + ret[1 ] = temp_sum; + } +} + +/* a[0] is LO, a[1] is HI. */ +static inline void mipsdsp_sat64_acc_sub_q63 (int64_t *ret, +int32_t ac, +int64_t *a, +CPUMIPSState *env) +{ +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 ] >=0 ) { + temp[2 ] =0x00 ; + }else { + temp[2 ] = ~0ull ; + } + + acc[0 ] = env->active_tc.LO[ac]; + acc[1 ] = env->active_tc.HI[ac]; +if (acc[1 ] >=0 ) { + acc[2 ] =0x00 ; + }else { + acc[2 ] = ~0ull ; + } + + temp_sum = acc[0 ] - temp[0 ]; +if ((uint64_t )temp_sum > (uint64_t )acc[0 ]) { + acc[1 ] -=1 ; +if (acc[1 ] == ~0ull ) { + 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 ;
target-mips/dsp_helper.c line 393
Quoted 10 lines
target-mips/dsp_helper.c new file +10
-0+ +if (temp64 != temp63) { +if (temp64 ==1 ) { + ret[0 ] =0x8000000000000000ull ; + ret[1 ] = ~0ull ; + }else { + ret[0 ] =0x0 ; + ret[1 ] =0x7FFFFFFFFFFFFFFFull ; + } +set_DSPControl_overflow_flag (1 ,16 + ac, env);
The overflow there can probably be checked the same way as for 64-bit numbers, using MIPSDSP_OVERFLOW instead of doing 192 bit arithmetic only for one bit.
Quoted 732 lines
target-mips/dsp_helper.c new file +728
-0+ }else { + ret[0 ] = acc[0 ]; + ret[1 ] = acc[1 ]; + } +} + +static inline int32_t mipsdsp_mul_i16_i16 (int16_t a,int16_t b, +CPUMIPSState *env) +{ +int32_t temp; + + temp = (int32_t )a * (int32_t )b; + +if ((temp >0x7FFF ) || (temp <0xFFFF8000 )) { +set_DSPControl_overflow_flag (1 ,21 , env); + } + temp &=0x0000FFFF ; + +return temp; +} + +static inline int32_t mipsdsp_mul_u16_u16 (int32_t a,int32_t b) +{ +return a * b; +} + +static inline int32_t mipsdsp_mul_i32_i32 (int32_t a,int32_t b) +{ +return a * b; +} + +static inline int32_t mipsdsp_sat16_mul_i16_i16 (int16_t a,int16_t b, +CPUMIPSState *env) +{ +int32_t temp; + + temp = (int32_t )a * (int32_t )b; + +if (temp >0x7FFF ) { + temp =0x00007FFF ; +set_DSPControl_overflow_flag (1 ,21 , env); + }else if (temp <0x00007FFF ) { + temp =0xFFFF8000 ; +set_DSPControl_overflow_flag (1 ,21 , env); + } + temp &=0x0000FFFF ; + +return temp; +} + +static inline int32_t mipsdsp_mul_q15_q15_overflowflag21 (uint16_t a,uint16_t b, +CPUMIPSState *env) +{ +int32_t temp; + +if ((a ==0x8000 ) && (b ==0x8000 )) { + temp =0x7FFFFFFF ; +set_DSPControl_overflow_flag (1 ,21 , env); + }else { + temp = ((int32_t )(int16_t )a * (int32_t )(int16_t )b) <<1 ; + } + +return temp; +} + +/* right shift */ +static inline uint8_t mipsdsp_rshift_u8 (uint8_t a,target_ulong mov) +{ +return a >> mov; +} + +static inline uint16_t mipsdsp_rshift_u16 (uint16_t a,target_ulong mov) +{ +return a >> mov; +} + +static inline int8_t mipsdsp_rashift8 (int8_t a,target_ulong mov) +{ +return a >> mov; +} + +static inline int16_t mipsdsp_rashift16 (int16_t a,target_ulong mov) +{ +return a >> mov; +} + +static inline int32_t mipsdsp_rashift32 (int32_t a,target_ulong mov) +{ +return a >> mov; +} + +static inline int16_t mipsdsp_rshift1_add_q16 (int16_t a,int16_t b) +{ +int32_t temp; + + temp = (int32_t )a + (int32_t )b; + +return (temp >>1 ) &0xFFFF ; +} + +/* round right shift */ +static inline int16_t mipsdsp_rrshift1_add_q16 (int16_t a,int16_t b) +{ +int32_t temp; + + temp = (int32_t )a + (int32_t )b; + temp +=1 ; + +return (temp >>1 ) &0xFFFF ; +} + +static inline int32_t mipsdsp_rshift1_add_q32 (int32_t a,int32_t b) +{ +int64_t temp; + + temp = (int64_t )a + (int64_t )b; + +return (temp >>1 ) &0xFFFFFFFF ; +} + +static inline int32_t mipsdsp_rrshift1_add_q32 (int32_t a,int32_t b) +{ +int64_t temp; + + temp = (int64_t )a + (int64_t )b; + temp +=1 ; + +return (temp >>1 ) &0xFFFFFFFF ; +} + +static inline uint8_t mipsdsp_rshift1_add_u8 (uint8_t a,uint8_t b) +{ +uint16_t temp; + + temp = (uint16_t )a + (uint16_t )b; + +return (temp >>1 ) &0x00FF ; +} + +static inline uint8_t mipsdsp_rrshift1_add_u8 (uint8_t a,uint8_t b) +{ +uint16_t temp; + + temp = (uint16_t )a + (uint16_t )b +1 ; + +return (temp >>1 ) &0x00FF ; +} + +static inline uint8_t mipsdsp_rshift1_sub_u8 (uint8_t a,uint8_t b) +{ +uint16_t temp; + + temp = (uint16_t )a - (uint16_t )b; + +return (temp >>1 ) &0x00FF ; +} + +static inline uint8_t mipsdsp_rrshift1_sub_u8 (uint8_t a,uint8_t b) +{ +uint16_t temp; + + temp = (uint16_t )a - (uint16_t )b +1 ; + +return (temp >>1 ) &0x00FF ; +} + +static inline int64_t mipsdsp_rashift_short_acc (int32_t ac, +int32_t shift, +CPUMIPSState *env) +{ +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 (1 ,23 , env); + } + +return temp; +} + +/* 128 bits long. p[0] is LO, p[1] is HI. */ +static inline void mipsdsp_rndrashift_short_acc (int64_t *p, +int32_t ac, +int32_t shift, +CPUMIPSState *env) +{ +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 (uint64_t *p, +uint32_t ac, +uint32_t shift, +CPUMIPSState *env) +{ +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; + } +} + +/* 128 bits long. p[0] is LO, p[1] is HI , p[2] is sign of HI.*/ +static inline void mipsdsp_rndrashift_acc (uint64_t *p, +uint32_t ac, +uint32_t shift, +CPUMIPSState *env) +{ +int64_t tempB, tempA; + + tempB = env->active_tc.HI[ac]; + tempA = env->active_tc.LO[ac]; + shift = shift &0x3F ; + +if (shift ==0 ) { + p[2 ] = tempB >>63 ; + p[1 ] = (tempB <<1 ) | (tempA >>63 ); + p[0 ] = tempA <<1 ; + }else { + p[0 ] = (tempB << (65 - shift)) | (tempA >> (shift -1 )); + p[1 ] = (int64_t )tempB >> (shift -1 ); +if (tempB >=0 ) { + p[2 ] =0x0 ; + }else { + p[2 ] = ~0ull ; + } + } +} + +static inline int32_t mipsdsp_mul_q15_q15 (int32_t ac,uint16_t a,uint16_t b, +CPUMIPSState *env) +{ +int32_t temp; + +if ((a ==0x8000 ) && (b ==0x8000 )) { + temp =0x7FFFFFFF ; +set_DSPControl_overflow_flag (1 ,16 + ac, env); + }else { + temp = ((uint32_t )a * (uint32_t )b) <<1 ; + } + +return temp; +} + +static inline int64_t mipsdsp_mul_q31_q31 (int32_t ac,uint32_t a,uint32_t b, +CPUMIPSState *env) +{ +uint64_t temp; + +if ((a ==0x80000000 ) && (b ==0x80000000 )) { + temp =0x7FFFFFFFFFFFFFFFull ; +set_DSPControl_overflow_flag (1 ,16 + ac, env); + }else { + temp = ((uint64_t )a * (uint64_t )b) <<1 ; + } + +return temp; +} + +static inline uint16_t mipsdsp_mul_u8_u8 (uint8_t a,uint8_t b) +{ +return (uint16_t )a * (uint16_t )b; +} + +static inline uint16_t mipsdsp_mul_u8_u16 (uint8_t a,uint16_t b, +CPUMIPSState *env) +{ +uint32_t tempI; + + tempI = (uint32_t )a * (uint32_t )b; +if (tempI >0x0000FFFF ) { + tempI =0x0000FFFF ; +set_DSPControl_overflow_flag (1 ,21 , env); + } + +return tempI &0x0000FFFF ; +} + +static inline uint64_t mipsdsp_mul_u32_u32 (uint32_t a,uint32_t b) +{ +return (uint64_t )a * (uint64_t )b; +} + +static inline int16_t mipsdsp_rndq15_mul_q15_q15 (uint16_t a,uint16_t b, +CPUMIPSState *env) +{ +uint32_t temp; + +if ((a ==0x8000 ) && (b ==0x8000 )) { + temp =0x7FFF0000 ; +set_DSPControl_overflow_flag (1 ,21 , env); + }else { + temp = (a * b) <<1 ; + temp = temp +0x00008000 ; + } + +return (temp &0xFFFF0000 ) >>16 ; +} + +static inline int32_t mipsdsp_sat16_mul_q15_q15 (uint16_t a,uint16_t b, +CPUMIPSState *env) +{ +int32_t temp; + +if ((a ==0x8000 ) && (b ==0x8000 )) { + temp =0x7FFF0000 ; +set_DSPControl_overflow_flag (1 ,21 , env); + }else { + temp = ((uint32_t )a * (uint32_t )b); + temp = temp <<1 ; + } + +return (temp >>16 ) &0x0000FFFF ; +} + +static inline uint16_t mipsdsp_trunc16_sat16_round (int32_t a, +CPUMIPSState *env) +{ +int64_t temp; + + temp = (int32_t )a +0x00008000 ; + +if (a >0x7fff8000 ) { + temp =0x7FFFFFFF ; +set_DSPControl_overflow_flag (1 ,22 , env); + } + +return (temp >>16 ) &0xFFFF ; +} + +static inline uint8_t mipsdsp_sat8_reduce_precision (uint16_t a, +CPUMIPSState *env) +{ +uint16_t mag; +uint32_t sign; + + sign = (a >>15 ) &0x01 ; + mag = a &0x7FFF ; + +if (sign ==0 ) { +if (mag >0x7F80 ) { +set_DSPControl_overflow_flag (1 ,22 , env); +return 0xFF ; + }else { +return (mag >>7 ) &0xFFFF ; + } + }else { +set_DSPControl_overflow_flag (1 ,22 , env); +return 0x00 ; + } +} + +static inline uint8_t mipsdsp_lshift8 (uint8_t a,uint8_t s,CPUMIPSState *env) +{ +uint8_t sign; +uint8_t discard; + +if (s ==0 ) { +return a; + }else { + sign = (a >>7 ) &0x01 ; +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 (1 ,22 , env); + } +return a << s; + } +} + +static inline uint16_t mipsdsp_lshift16 (uint16_t a,uint8_t s, +CPUMIPSState *env) +{ +uint8_t sign; +uint16_t discard; + +if (s ==0 ) { +return a; + }else { + sign = (a >>15 ) &0x01 ; +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 (1 ,22 , env); + } +return a << s; + } +} + + +static inline uint32_t mipsdsp_lshift32 (uint32_t a,uint8_t s, +CPUMIPSState *env) +{ +uint32_t discard; + +if (s ==0 ) { +return a; + }else { + discard = (int32_t )a >> (31 - (s -1 )); + +if ((discard !=0x00000000 ) && (discard !=0xFFFFFFFF )) { +set_DSPControl_overflow_flag (1 ,22 , env); + } +return a << s; + } +} + +static inline uint16_t mipsdsp_sat16_lshift (uint16_t a,uint8_t s, +CPUMIPSState *env) +{ +uint8_t sign; +uint16_t discard; + +if (s ==0 ) { +return a; + }else { + sign = (a >>15 ) &0x01 ; +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 (1 ,22 , env); +return (sign ==0 ) ?0x7FFF :0x8000 ; + }else { +return a << s; + } + } +} + +static inline uint32_t mipsdsp_sat32_lshift (uint32_t a,uint8_t s, +CPUMIPSState *env) +{ +uint8_t sign; +uint32_t discard; + +if (s ==0 ) { +return a; + }else { + sign = (a >>31 ) &0x01 ; +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 )) { +set_DSPControl_overflow_flag (1 ,22 , env); +return (sign ==0 ) ?0x7FFFFFFF :0x80000000 ; + }else { +return a << s; + } + } +} + +static inline uint8_t mipsdsp_rnd8_rashift (uint8_t a,uint8_t s) +{ +uint32_t temp; + +if (s ==0 ) { + temp = (uint32_t )a <<1 ; + }else { + temp = (int32_t )(int8_t )a >> (s -1 ); + } + +return (temp +1 ) >>1 ; +} + +static inline uint16_t mipsdsp_rnd16_rashift (uint16_t a,uint8_t s) +{ +uint32_t temp; + +if (s ==0 ) { + temp = (uint32_t )a <<1 ; + }else { + temp = (int32_t )(int16_t )a >> (s -1 ); + } + +return (temp +1 ) >>1 ; +} + +static inline uint32_t mipsdsp_rnd32_rashift (uint32_t a,uint8_t s) +{ +int64_t temp; + +if (s ==0 ) { + temp = a <<1 ; + }else { + temp = (int64_t )(int32_t )a >> (s -1 ); + } + temp +=1 ; + +return (temp >>1 ) &0x00000000FFFFFFFFull ; +} + +static inline uint16_t mipsdsp_sub_i16 (int16_t a,int16_t b,CPUMIPSState *env) +{ +int16_t temp; + + temp = a - b; +if (MIPSDSP_OVERFLOW (a, -b, temp,0x8000 )) { +set_DSPControl_overflow_flag (1 ,20 , env); + } + +return temp; +} + +static inline uint16_t mipsdsp_sat16_sub (int16_t a,int16_t b, +CPUMIPSState *env) +{ +int16_t temp; + + temp = a - b; +if (MIPSDSP_OVERFLOW (a, -b, temp,0x8000 )) { +if (a >0 ) { + temp =0x7FFF ; + }else { + temp =0x8000 ; + } +set_DSPControl_overflow_flag (1 ,20 , env); + } + +return temp; +} + +static inline uint32_t mipsdsp_sat32_sub (int32_t a,int32_t b, +CPUMIPSState *env) +{ +int32_t temp; + + temp = a - b; +if (MIPSDSP_OVERFLOW (a, -b, temp,0x80000000 )) { +if (a >0 ) { + temp =0x7FFFFFFF ; + }else { + temp =0x80000000 ; + } +set_DSPControl_overflow_flag (1 ,20 , env); + } + +return temp &0x00000000FFFFFFFFull ; +} + +static inline uint16_t mipsdsp_rshift1_sub_q16 (int16_t a,int16_t b) +{ +int32_t temp; + + temp = (int32_t )a - (int32_t )b; + +return (temp >>1 ) &0x0000FFFF ; +} + +static inline uint16_t mipsdsp_rrshift1_sub_q16 (int16_t a,int16_t b) +{ +int32_t temp; + + temp = (int32_t )a - (int32_t )b; + temp +=1 ; + +return (temp >>1 ) &0x0000FFFF ; +} + +static inline uint32_t mipsdsp_rshift1_sub_q32 (int32_t a,int32_t b) +{ +int64_t temp; + + temp = (int64_t )a - (int64_t )b; + +return (temp >>1 ) &0x00000000FFFFFFFFull ; +} + +static inline uint32_t mipsdsp_rrshift1_sub_q32 (int32_t a,int32_t b) +{ +int64_t temp; + + temp = (int64_t )a - (int64_t )b; + temp +=1 ; + +return (temp >>1 ) &0x00000000FFFFFFFFull ; +} + +static inline uint16_t mipsdsp_sub_u16_u16 (uint16_t a,uint16_t b, +CPUMIPSState *env) +{ +uint8_t temp16; +uint32_t temp; + + temp = (uint32_t )a - (uint32_t )b; + temp16 = (temp >>16 ) &0x01 ; +if (temp16 ==1 ) { +set_DSPControl_overflow_flag (1 ,20 , env); + } +return temp &0x0000FFFF ; +} + +static inline uint16_t mipsdsp_satu16_sub_u16_u16 (uint16_t a,uint16_t b, +CPUMIPSState *env) +{ +uint8_t temp16; +uint32_t temp; + + temp = (uint32_t )a - (uint32_t )b; + temp16 = (temp >>16 ) &0x01 ; + +if (temp16 ==1 ) { + temp =0x0000 ; +set_DSPControl_overflow_flag (1 ,20 , env); + } + +return temp &0x0000FFFF ; +} + +static inline uint8_t mipsdsp_sub_u8 (uint8_t a,uint8_t b,CPUMIPSState *env) +{ +uint8_t temp8; +uint16_t temp; + + temp = (uint16_t )a - (uint16_t )b; + temp8 = (temp >>8 ) &0x01 ; +if (temp8 ==1 ) { +set_DSPControl_overflow_flag (1 ,20 , env); + } + +return temp &0x00FF ; +} + +static inline uint8_t mipsdsp_satu8_sub (uint8_t a,uint8_t b,CPUMIPSState *env) +{ +uint8_t temp8; +uint16_t temp; + + temp = (uint16_t )a - (uint16_t )b; + temp8 = (temp >>8 ) &0x01 ; +if (temp8 ==1 ) { + temp =0x00 ; +set_DSPControl_overflow_flag (1 ,20 , env); + } + +return temp &0x00FF ; +} + +static inline uint32_t mipsdsp_sub32 (int32_t a,int32_t b,CPUMIPSState *env) +{ +int32_t temp; + + temp = a - b; +if (MIPSDSP_OVERFLOW (a, -b, temp,0x80000000 )) { +set_DSPControl_overflow_flag (1 ,20 , env); + } + +return temp; +} + +static inline int32_t mipsdsp_add_i32 (int32_t a,int32_t b,CPUMIPSState *env) +{ +int32_t temp; + + temp = a + b; + +if (MIPSDSP_OVERFLOW (a, b, temp,0x80000000 )) { +set_DSPControl_overflow_flag (1 ,20 , env); + } + +return temp; +} + +static inline int32_t mipsdsp_cmp_eq (uint32_t a,uint32_t b) +{ +return a == b; +} + +static inline int32_t mipsdsp_cmp_le (uint32_t a,uint32_t b) +{ +return a <= b; +} + +static inline int32_t mipsdsp_cmp_lt (uint32_t a,uint32_t b) +{ +return a < b; +} +/*** MIPS DSP internal functions end ***/ Signature · 1 line
1.7.10.2 (Apple Git-33)
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v9 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 | 27 +++++++++++++++++++++++++-- target-mips/helper.c | 3 +++ target-mips/translate.c | 23 +++++++++++++++++++++++ 4 files changed, 57 insertions(+), 2 deletions(-)
linux-user/main.c +6 -0
@@ -2281,6 +2281,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 +25 -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
@@ -772,6 +776,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_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 ; + } + + }else 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 ; + } + + }if (env->insn_flags &ISA_MIPS32R2 ) {if (env->active_fpu.fcr0 & (1 <<FCR0_F64 )) { env->hflags |=MIPS_HFLAG_COP1X ;
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/translate.c +23 -0
@@ -942,6 +942,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)
@@ -13196,6 +13214,11 @@ void cpu_state_reset(CPUMIPSState *env)if (env->CP0_Config1 & (1 <<CP0C1_FP )) { env->CP0_Status |= (1 << CP0St_CU1); } +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 ; + }#else if (env->hflags &MIPS_HFLAG_BMASK ) {/* If the exception was raised from a delay slot,
Signature · 1 line
1.7.10.2 (Apple Git-33)
Re: [Qemu-devel] [PATCH v9 02/14] target-mips-ase-dsp: Add dsp resources access check
Quoted 132 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 | 27 +++++++++++++++++++++++++-- target-mips/helper.c | 3 +++ target-mips/translate.c | 23 +++++++++++++++++++++++ 4 files changed, 57 insertions(+), 2 deletions(-)linux-user/main.c +6
-0@@ -2281,6 +2281,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 +25
-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@@ -772,6 +776,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_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 ; + } + + }else 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 ; + } + + }if (env->insn_flags &ISA_MIPS32R2 ) {if (env->active_fpu.fcr0 & (1 <<FCR0_F64 )) { env->hflags |=MIPS_HFLAG_COP1X ;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/translate.c +18
-0@@ -942,6 +942,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)@@ -13196,6 +13214,11 @@ void cpu_state_reset(CPUMIPSState *env)if (env->CP0_Config1 & (1 <<CP0C1_FP )) {
target-mips/translate.c void cpu_state_reset(CPUMIPSState *env) · line 13224
Quoted 10 lines
target-mips/translate.c +5
-0env->CP0_Status |= (1 << CP0St_CU1); } +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 ; + }#else if (env->hflags &MIPS_HFLAG_BMASK ) {/* If the exception was raised from a delay slot,
Looks fine to me.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v9 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 | 122 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 95 insertions(+), 27 deletions(-)
target-mips/translate.c +95 -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
@@ -2113,33 +2114,75 @@ 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_ext32s_tl (cpu_gpr[reg], cpu_HI[acc]); + } else +#endif + { +tcg_gen_mov_tl (cpu_gpr[reg], cpu_HI[acc]); + } 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_ext32s_tl (cpu_gpr[reg], cpu_LO[acc]); + } else +#endif + { +tcg_gen_mov_tl (cpu_gpr[reg], cpu_LO[acc]); + } 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 (reg !=0 ) { +#if defined(TARGET_MIPS64 ) +if (acc !=0 ) { +tcg_gen_ext32s_tl (cpu_HI[acc], cpu_gpr[reg]); + } else +#endif + { +tcg_gen_mov_tl (cpu_HI[acc], cpu_gpr[reg]); + } + }else { +tcg_gen_movi_tl (cpu_HI[acc],0 ); + } 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 (reg !=0 ) { +#if defined(TARGET_MIPS64 ) +if (acc !=0 ) { +tcg_gen_ext32s_tl (cpu_LO[acc], cpu_gpr[reg]); + } else +#endif + { +tcg_gen_mov_tl (cpu_LO[acc], cpu_gpr[reg]); + } + }else { +tcg_gen_movi_tl (cpu_LO[acc],0 ); + } opn ="mtlo" ;break ; }
@@ -2152,6 +2195,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 :
@@ -2214,6 +2258,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);
@@ -2223,8 +2271,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 ;
@@ -2232,6 +2280,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);
@@ -2243,8 +2295,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 ;
@@ -2291,41 +2343,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 ;
@@ -2333,19 +2393,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 ;
@@ -2353,21 +2417,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.10.2 (Apple Git-33)
Re: [Qemu-devel] [PATCH v9 03/14] target-mips-ase-dsp: Use correct acc value to index cpu_HI/cpu_LO rather than using a fix number
Quoted 260 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 | 122 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 95 insertions(+), 27 deletions(-)target-mips/translate.c +93
-25@@ -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 @@ -2113,33 +2114,75 @@ 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_ext32s_tl (cpu_gpr[reg], cpu_HI[acc]); + } else +#endif + { +tcg_gen_mov_tl (cpu_gpr[reg], cpu_HI[acc]); + } 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_ext32s_tl (cpu_gpr[reg], cpu_LO[acc]); + } else +#endif + { +tcg_gen_mov_tl (cpu_gpr[reg], cpu_LO[acc]); + } 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 (reg !=0 ) { +#if defined(TARGET_MIPS64 ) +if (acc !=0 ) { +tcg_gen_ext32s_tl (cpu_HI[acc], cpu_gpr[reg]); + } else +#endif + { +tcg_gen_mov_tl (cpu_HI[acc], cpu_gpr[reg]); + } + }else { +tcg_gen_movi_tl (cpu_HI[acc],0 ); + } 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 (reg !=0 ) { +#if defined(TARGET_MIPS64 ) +if (acc !=0 ) { +tcg_gen_ext32s_tl (cpu_LO[acc], cpu_gpr[reg]); + } else +#endif + { +tcg_gen_mov_tl (cpu_LO[acc], cpu_gpr[reg]); + } + }else { +tcg_gen_movi_tl (cpu_LO[acc],0 ); + } opn ="mtlo" ;break ; }@@ -2152,6 +2195,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 :@@ -2214,6 +2258,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);@@ -2223,8 +2271,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 ;@@ -2232,6 +2280,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);@@ -2243,8 +2295,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 ;@@ -2291,41 +2343,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 ;@@ -2333,19 +2393,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 ;@@ -2353,21 +2417,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 2441
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 ;
Looks fine to me.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v9 4/14 target-mips-ase-dsp: Add branch instructions
In reply to Jia LiuAdd MIPS ASE DSP Branch instructions.
--- target-mips/translate.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
target-mips/translate.c +36 -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))
@@ -3224,6 +3232,16 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc, } btgt = ctx->pc + insn_bytes + offset;break ; +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 ;case OPC_J :case OPC_JAL :case OPC_JALX :
@@ -3412,6 +3430,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 " TARGET_FMT_lx, btgt); + goto not_likely; +#if defined(TARGET_MIPS64 ) +case OPC_BPOSGE64 : +tcg_gen_setcondi_tl (TCG_COND_GE , bcond, t0,64 ); +MIPS_DEBUG ("bposge64 " TARGET_FMT_lx, btgt); + goto not_likely; +#endif case OPC_BLTZALS :case OPC_BLTZAL : ctx->hflags |= (opc == OPC_BLTZALS
@@ -12582,6 +12610,14 @@ 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 */ +#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 ;default :/* Invalid */ MIPS_INVAL ("regimm" );generate_exception (ctx,EXCP_RI );
Signature · 1 line
1.7.10.2 (Apple Git-33)
Re: [Qemu-devel] [PATCH v9 04/14] target-mips-ase-dsp: Add branch instructions
Quoted 65 lines · Jia Liu
Add MIPS ASE DSP Branch instructions.
Signed-off-by Jia Liu <[email protected]>--- target-mips/translate.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)target-mips/translate.c +29
-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))@@ -3224,6 +3232,16 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc, } btgt = ctx->pc + insn_bytes + offset;break ; +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 ;case OPC_J :case OPC_JAL :case OPC_JALX :@@ -3412,6 +3430,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 " TARGET_FMT_lx, btgt); + goto not_likely; +#if defined(TARGET_MIPS64 ) +case OPC_BPOSGE64 : +tcg_gen_setcondi_tl (TCG_COND_GE , bcond, t0,64 ); +MIPS_DEBUG ("bposge64 " TARGET_FMT_lx, btgt); + goto not_likely; +#endif case OPC_BLTZALS :case OPC_BLTZAL : ctx->hflags |= (opc == OPC_BLTZALS@@ -12582,6 +12610,14 @@ 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 */
target-mips/translate.c static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) · line 12623
Quoted 10 lines
target-mips/translate.c +7
-0+#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 ;default :/* Invalid */ MIPS_INVAL ("regimm" );generate_exception (ctx,EXCP_RI );
Looks fine to me.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v9 5/14 target-mips-ase-dsp: Add load instructions
In reply to Jia LiuAdd MIPS ASE DSP Load instructions.
--- target-mips/translate.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+)
target-mips/translate.c +84 -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))
@@ -12213,6 +12227,58 @@ static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx, int *is_b#endif +/* MIPSDSP functions. */ +static void gen_mipsdsp_ld (CPUMIPSState *env,DisasContext *ctx,uint32_t opc, +int rd,int base,int offset) +{ +const char *opn ="ldx" ; +TCGv t0; + +if (rd ==0 && env->insn_flags & (ASE_DSP |ASE_DSPR2 )) { +/* Loongson CPU uses a load to zero register for prefetch. +We emulate it as a NOP. On other CPU we must perform the +actual memory access. */ +MIPS_DEBUG ("NOP" ); +return ; + } + + t0 =tcg_temp_new (); +gen_op_addr_add (ctx, t0, cpu_gpr[base], cpu_gpr[offset]); +save_cpu_state (ctx,0 ); + +switch (opc) { +case OPC_LBUX : +op_ld_lbu (t0, t0, ctx); +gen_store_gpr (t0, rd); + opn ="lbux" ; +break ; +case OPC_LHX : +op_ld_lh (t0, t0, ctx); +gen_store_gpr (t0, rd); + opn ="lhx" ; +break ; +case OPC_LWX : +op_ld_lw (t0, t0, ctx); +gen_store_gpr (t0, rd); + opn ="lwx" ; +break ; +#if defined(TARGET_MIPS64 ) +case OPC_LDX : +op_ld_ld (t0, t0, ctx); +gen_store_gpr (t0, rd); + opn ="ldx" ; +break ; +#endif + } + (void )opn;/* avoid a compiler warning */ +MIPS_DEBUG ("%s %s, %s(%s)" , opn, + regnames[rd], regnames[offset], regnames[base]); +tcg_temp_free (t0); +} + + +/* End MIPSDSP functions. */ +static void decode_opc (CPUMIPSState *env,DisasContext *ctx,int *is_branch) {int32_t offset;
@@ -12568,6 +12634,24 @@ 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) { +#if defined(TARGET_MIPS64 ) +case OPC_LDX : +#endif +case OPC_LBUX : +case OPC_LHX : +case OPC_LWX : +gen_mipsdsp_ld (env, ctx, op2, rd, rs, rt); +break ; +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.10.2 (Apple Git-33)
Re: [Qemu-devel] [PATCH v9 05/14] target-mips-ase-dsp: Add load instructions
Quoted 47 lines · Jia Liu
Add MIPS ASE DSP Load instructions.
Signed-off-by Jia Liu <[email protected]>--- target-mips/translate.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+)target-mips/translate.c +18
-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))@@ -12213,6 +12227,58 @@ static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx, int *is_b#endif +/* MIPSDSP functions. */ +static void gen_mipsdsp_ld (CPUMIPSState *env,DisasContext *ctx,uint32_t opc, +int rd,int base,int offset) +{
target-mips/translate.c static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx, int *is_b · line 12243
Quoted 10 lines
target-mips/translate.c +10
-0+const char *opn ="ldx" ; +TCGv t0; + +if (rd ==0 && env->insn_flags & (ASE_DSP |ASE_DSPR2 )) { +/* Loongson CPU uses a load to zero register for prefetch. +We emulate it as a NOP. On other CPU we must perform the +actual memory access. */ +MIPS_DEBUG ("NOP" ); +return ; + }
I don't really understand why Loongson is playing a role there. This part should simply be dropped.
target-mips/translate.c static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx, int *is_b · line 12246
Quoted 2 lines
target-mips/translate.c +2
-0+ t0 =tcg_temp_new (); +gen_op_addr_add (ctx, t0, cpu_gpr[base], cpu_gpr[offset]);
base or offset can be register 0, in that case it won't work.
Quoted 39 lines
target-mips/translate.c +35
-0+save_cpu_state (ctx,0 ); + +switch (opc) { +case OPC_LBUX : +op_ld_lbu (t0, t0, ctx); +gen_store_gpr (t0, rd); + opn ="lbux" ; +break ; +case OPC_LHX : +op_ld_lh (t0, t0, ctx); +gen_store_gpr (t0, rd); + opn ="lhx" ; +break ; +case OPC_LWX : +op_ld_lw (t0, t0, ctx); +gen_store_gpr (t0, rd); + opn ="lwx" ; +break ; +#if defined(TARGET_MIPS64 ) +case OPC_LDX : +op_ld_ld (t0, t0, ctx); +gen_store_gpr (t0, rd); + opn ="ldx" ; +break ; +#endif + } + (void )opn;/* avoid a compiler warning */ +MIPS_DEBUG ("%s %s, %s(%s)" , opn, + regnames[rd], regnames[offset], regnames[base]); +tcg_temp_free (t0); +} + + +/* End MIPSDSP functions. */ +static void decode_opc (CPUMIPSState *env,DisasContext *ctx,int *is_branch) {int32_t offset;
target-mips/translate.c static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) · line 12638
Quoted 5 lines
target-mips/translate.c +2
-0@@ -12568,6 +12634,24 @@ 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);
As ctx is passed to gen_mipsdsp_ld(), the check might be moved there.
Quoted 23 lines
target-mips/translate.c +16
-0+ op2 =MASK_LX (ctx->opcode); +switch (op2) { +#if defined(TARGET_MIPS64 ) +case OPC_LDX : +#endif +case OPC_LBUX : +case OPC_LHX : +case OPC_LWX : +gen_mipsdsp_ld (env, ctx, op2, rd, rs, rt); +break ; +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.10.2 (Apple Git-33)
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v9 6/14 target-mips-ase-dsp: Add arithmetic instructions
In reply to Jia LiuAdd MIPS ASE DSP Arithmetic instructions.
--- target-mips/dsp_helper.c | 895 ++++++++++++++++++++++++++++++++++++++++++++++ target-mips/helper.h | 126 +++++++ target-mips/translate.c | 830 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 1848 insertions(+), 3 deletions(-)
target-mips/dsp_helper.c +895 -0
@@ -1119,3 +1119,898 @@ static inline int32_t mipsdsp_cmp_lt(uint32_t a, uint32_t b)return a < b; }/*** 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 + +#define MIPSDSP_SPLIT32_8 (num, a, b, c, d) \ + do { \ + a = (num >> 24) & MIPSDSP_Q0; \ + b = (num >> 16) & MIPSDSP_Q0; \ + c = (num >> 8) & MIPSDSP_Q0; \ + d = num & MIPSDSP_Q0; \ + } while (0) + +#define MIPSDSP_SPLIT32_16 (num, a, b) \ + do { \ + a = (num >> 16) & MIPSDSP_LO; \ + b = num & MIPSDSP_LO; \ + } while (0) + +#define MIPSDSP_RETURN32 (a) ((target_long)(int32_t)a) +#define MIPSDSP_RETURN32_8 (a, b, c, d) ((target_long)(int32_t) \ + (((uint32_t)a << 24) | \ + (((uint32_t)b << 16) | \ + (((uint32_t)c << 8) | \ + ((uint32_t)d & 0xFF))))) +#define MIPSDSP_RETURN32_16 (a, b) ((target_long)(int32_t) \ + (((uint32_t)a << 16) | \ + ((uint32_t)b & 0xFFFF))) + +#ifdef TARGET_MIPS64 +#define MIPSDSP_SPLIT64_16 (num, a, b, c, d) \ + do { \ + a = (num >> 48) & MIPSDSP_LO; \ + b = (num >> 32) & MIPSDSP_LO; \ + c = (num >> 16) & MIPSDSP_LO; \ + d = num & MIPSDSP_LO; \ + } while (0) + +#define MIPSDSP_SPLIT64_32 (num, a, b) \ + do { \ + a = (num >> 32) & MIPSDSP_LLO; \ + b = num & MIPSDSP_LLO; \ + } while (0) + +#define MIPSDSP_RETURN64_16 (a, b, c, d) (((uint64_t)a << 48) | \ + ((uint64_t)b << 32) | \ + ((uint64_t)c << 16) | \ + (uint64_t)d) +#define MIPSDSP_RETURN64_32 (a, b) (((uint64_t)a << 32) | (uint64_t)b) +#endif + +/** DSP Arithmetic Sub-class insns **/ +#define ARITH_PH (name, func) \ +target_ulong helper_##name##_ph(target_ulong rs, target_ulong rt) \ +{ \ + uint16_t rsh, rsl, rth, rtl, temph, templ; \ + \ + MIPSDSP_SPLIT32_16(rs, rsh, rsl); \ + MIPSDSP_SPLIT32_16(rt, rth, rtl); \ + \ + temph = mipsdsp_##func(rsh, rth); \ + templ = mipsdsp_##func(rsl, rtl); \ + \ + return MIPSDSP_RETURN32_16(temph, templ); \ +} + +#define ARITH_PH_ENV (name, func) \ +target_ulong helper_##name##_ph(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint16_t rsh, rsl, rth, rtl, temph, templ; \ + \ + MIPSDSP_SPLIT32_16(rs, rsh, rsl); \ + MIPSDSP_SPLIT32_16(rt, rth, rtl); \ + \ + temph = mipsdsp_##func(rsh, rth, env); \ + templ = mipsdsp_##func(rsl, rtl, env); \ + \ + return MIPSDSP_RETURN32_16(temph, templ); \ +} + + +ARITH_PH_ENV (addq, add_i16); +ARITH_PH_ENV (addq_s, sat_add_i16); +ARITH_PH_ENV (addu, add_u16); +ARITH_PH_ENV (addu_s, sat_add_u16); + +ARITH_PH (addqh, rshift1_add_q16); +ARITH_PH (addqh_r, rrshift1_add_q16); + +ARITH_PH_ENV (subq, sub_i16); +ARITH_PH_ENV (subq_s, sat16_sub); +ARITH_PH_ENV (subu, sub_u16_u16); +ARITH_PH_ENV (subu_s, satu16_sub_u16_u16); + +ARITH_PH (subqh, rshift1_sub_q16); +ARITH_PH (subqh_r, rrshift1_sub_q16); + +#undef ARITH_PH +#undef ARITH_PH_ENV + +#ifdef TARGET_MIPS64 +#define ARITH_QH_ENV (name, func) \ +target_ulong helper_##name##_qh(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint16_t rs3, rs2, rs1, rs0; \ + uint16_t rt3, rt2, rt1, rt0; \ + uint16_t tempD, tempC, tempB, tempA; \ + \ + MIPSDSP_SPLIT64_16(rs, rs3, rs2, rs1, rs0); \ + MIPSDSP_SPLIT64_16(rt, rt3, rt2, rt1, rt0); \ + \ + tempD = mipsdsp_##func(rs3, rt3, env); \ + tempC = mipsdsp_##func(rs2, rt2, env); \ + tempB = mipsdsp_##func(rs1, rt1, env); \ + tempA = mipsdsp_##func(rs0, rt0, env); \ + \ + return MIPSDSP_RETURN64_16(tempD, tempC, tempB, tempA); \ +} + +ARITH_QH_ENV (addq, add_i16); +ARITH_QH_ENV (addq_s, sat_add_i16); +ARITH_QH_ENV (addu, add_u16); +ARITH_QH_ENV (addu_s, sat_add_u16); + +ARITH_QH_ENV (subq, sub_i16); +ARITH_QH_ENV (subq_s, sat16_sub); +ARITH_QH_ENV (subu, sub_u16_u16); +ARITH_QH_ENV (subu_s, satu16_sub_u16_u16); + +#undef ARITH_QH_ENV + +#endif + +#define ARITH_W (name, func) \ +target_ulong helper_##name##_w(target_ulong rs, target_ulong rt) \ +{ \ + uint32_t rd; \ + rd = mipsdsp_##func(rs, rt); \ + return MIPSDSP_RETURN32(rd); \ +} + +#define ARITH_W_ENV (name, func) \ +target_ulong helper_##name##_w(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint32_t rd; \ + rd = mipsdsp_##func(rs, rt, env); \ + return MIPSDSP_RETURN32(rd); \ +} + +ARITH_W_ENV (addq_s, sat_add_i32); + +ARITH_W (addqh, rshift1_add_q32); +ARITH_W (addqh_r, rrshift1_add_q32); + +ARITH_W_ENV (subq_s, sat32_sub); + +ARITH_W (subqh, rshift1_sub_q32); +ARITH_W (subqh_r, rrshift1_sub_q32); + +#undef ARITH_W +#undef ARITH_W_ENV + +target_ulong helper_absq_s_w (target_ulong rt,CPUMIPSState *env) +{ +uint32_t rd; + + rd =mipsdsp_sat_abs_u32 (rt, env); + +return (target_ulong )rd; +} + + +#if defined(TARGET_MIPS64 ) + +#define ARITH_PW_ENV (name, func) \ +target_ulong helper_##name##_pw(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint32_t rs1, rs0; \ + uint32_t rt1, rt0; \ + uint32_t tempB, tempA; \ + \ + MIPSDSP_SPLIT64_32(rs, rs1, rs0); \ + MIPSDSP_SPLIT64_32(rt, rt1, rt0); \ + \ + tempB = mipsdsp_##func(rs1, rt1, env); \ + tempA = mipsdsp_##func(rs0, rt0, env); \ + \ + return MIPSDSP_RETURN64_32(tempB, tempA); \ +} + +ARITH_PW_ENV (addq, add_i32); +ARITH_PW_ENV (addq_s, sat_add_i32); +ARITH_PW_ENV (subq, sub32); +ARITH_PW_ENV (subq_s, sat32_sub); + +#undef ARITH_PW_ENV + +#endif + +#define ARITH_QB (name, func) \ +target_ulong helper_##name##_qb(target_ulong rs, target_ulong rt) \ +{ \ + uint8_t rs0, rs1, rs2, rs3; \ + uint8_t rt0, rt1, rt2, rt3; \ + uint8_t temp0, temp1, temp2, temp3; \ + \ + MIPSDSP_SPLIT32_8(rs, rs3, rs2, rs1, rs0); \ + MIPSDSP_SPLIT32_8(rt, rt3, rt2, rt1, rt0); \ + \ + temp0 = mipsdsp_##func(rs0, rt0); \ + temp1 = mipsdsp_##func(rs1, rt1); \ + temp2 = mipsdsp_##func(rs2, rt2); \ + temp3 = mipsdsp_##func(rs3, rt3); \ + \ + return MIPSDSP_RETURN32_8(temp3, temp2, temp1, temp0); \ +} + +#define ARITH_QB_ENV (name, func) \ +target_ulong helper_##name##_qb(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint8_t rs0, rs1, rs2, rs3; \ + uint8_t rt0, rt1, rt2, rt3; \ + uint8_t temp0, temp1, temp2, temp3; \ + \ + MIPSDSP_SPLIT32_8(rs, rs3, rs2, rs1, rs0); \ + MIPSDSP_SPLIT32_8(rt, rt3, rt2, rt1, rt0); \ + \ + temp0 = mipsdsp_##func(rs0, rt0, env); \ + temp1 = mipsdsp_##func(rs1, rt1, env); \ + temp2 = mipsdsp_##func(rs2, rt2, env); \ + temp3 = mipsdsp_##func(rs3, rt3, env); \ + \ + return MIPSDSP_RETURN32_8(temp3, temp2, temp1, temp0); \ +} + +ARITH_QB (adduh, rshift1_add_u8); +ARITH_QB (adduh_r, rrshift1_add_u8); + +ARITH_QB_ENV (addu, add_u8); +ARITH_QB_ENV (addu_s, sat_add_u8); + +#undef ADDU_QB +#undef ADDU_QB_ENV + +#if defined(TARGET_MIPS64 ) +#define ARITH_OB (name, func) \ +target_ulong helper_##name##_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_##func(rs_t[i], rt_t[i]); \ + result |= (uint64_t)temp[i] << (8 * i); \ + } \ + \ + return result; \ +} + +#define ARITH_OB_ENV (name, func) \ +target_ulong helper_##name##_ob(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + 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_##func(rs_t[i], rt_t[i], env); \ + result |= (uint64_t)temp[i] << (8 * i); \ + } \ + \ + return result; \ +} + +ARITH_OB_ENV (addu, add_u8); +ARITH_OB_ENV (addu_s, sat_add_u8); + +ARITH_OB (adduh, rshift1_add_u8); +ARITH_OB (adduh_r, rrshift1_add_u8); + +ARITH_OB_ENV (subu, sub_u8); +ARITH_OB_ENV (subu_s, satu8_sub); + +ARITH_OB (subuh, rshift1_sub_u8); +ARITH_OB (subuh_r, rrshift1_sub_u8); + +#undef ARITH_OB +#undef ARITH_OB_ENV + +#endif + +#define SUBU_QB (name, func) \ +target_ulong helper_##name##_qb(target_ulong rs, \ + target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint8_t rs3, rs2, rs1, rs0; \ + uint8_t rt3, rt2, rt1, rt0; \ + uint8_t tempD, tempC, tempB, tempA; \ + \ + MIPSDSP_SPLIT32_8(rs, rs3, rs2, rs1, rs0); \ + MIPSDSP_SPLIT32_8(rt, rt3, rt2, rt1, rt0); \ + \ + tempD = mipsdsp_##func(rs3, rt3, env); \ + tempC = mipsdsp_##func(rs2, rt2, env); \ + tempB = mipsdsp_##func(rs1, rt1, env); \ + tempA = mipsdsp_##func(rs0, rt0, env); \ + \ + return MIPSDSP_RETURN32_8(tempD, tempC, tempB, tempA); \ +} + +SUBU_QB (subu, sub_u8); +SUBU_QB (subu_s, satu8_sub); + +#undef SUBU_QB + +#define SUBUH_QB (name, var) \ +target_ulong helper_##name##_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; \ + \ + MIPSDSP_SPLIT32_8(rs, rs3, rs2, rs1, rs0); \ + MIPSDSP_SPLIT32_8(rt, rt3, rt2, rt1, rt0); \ + \ + tempD = ((uint16_t)rs3 - (uint16_t)rt3 + var) >> 1; \ + tempC = ((uint16_t)rs2 - (uint16_t)rt2 + var) >> 1; \ + tempB = ((uint16_t)rs1 - (uint16_t)rt1 + var) >> 1; \ + tempA = ((uint16_t)rs0 - (uint16_t)rt0 + var) >> 1; \ + \ + return ((uint32_t)tempD << 24) | ((uint32_t)tempC << 16) | \ + ((uint32_t)tempB << 8) | (uint32_t)tempA; \ +} + +SUBUH_QB (subuh,0 ); +SUBUH_QB (subuh_r,1 ); + +#undef SUBUH_QB + +target_ulong helper_addsc (target_ulong rs,target_ulong rt,CPUMIPSState *env) +{ +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 (flag, env); + +return (target_long)(int32_t)(temp &MIPSDSP_LLO ); +} + +target_ulong helper_addwc (target_ulong rs,target_ulong rt,CPUMIPSState *env) +{ +uint32_t rd; +int32_t temp32, temp31; +int64_t tempL; + + tempL = (int32_t )rs + (int32_t )rt +get_DSPControl_carryflag (env); + temp31 = (tempL >>31 ) &0x01 ; + temp32 = (tempL >>32 ) &0x01 ; + +if (temp31 != temp32) { +set_DSPControl_overflow_flag (1 ,20 , env); + } + + 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; + +MIPSDSP_SPLIT32_8 (rs, rs3, rs2, rs1, rs0); + + temp = (uint16_t )rs3 + (uint16_t )rs2 + (uint16_t )rs1 + (uint16_t )rs0; + +return (target_ulong )temp; +} + +#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 (target_ulong rt,CPUMIPSState *env) +{ +uint32_t rd; +int8_t tempD, tempC, tempB, tempA; + +MIPSDSP_SPLIT32_8 (rt, tempD, tempC, tempB, tempA); + + rd = (((uint32_t )mipsdsp_sat_abs_u8 (tempD, env) <<24 ) &MIPSDSP_Q3 ) | + (((uint32_t )mipsdsp_sat_abs_u8 (tempC, env) <<16 ) &MIPSDSP_Q2 ) | + (((uint32_t )mipsdsp_sat_abs_u8 (tempB, env) <<8 ) &MIPSDSP_Q1 ) | + ((uint32_t )mipsdsp_sat_abs_u8 (tempA, env) &MIPSDSP_Q0 ); + +return (target_ulong )rd; +} + +target_ulong helper_absq_s_ph (target_ulong rt,CPUMIPSState *env) +{ +uint32_t rd; +int16_t tempB, tempA; + +MIPSDSP_SPLIT32_16 (rt, tempB, tempA); + + rd = ((uint32_t )(uint16_t )mipsdsp_sat_abs_u16 (tempB, env) <<16 ) | + ((uint32_t )((uint16_t )mipsdsp_sat_abs_u16 (tempA, env)) &0xFFFF ); + +return (target_long )(int32_t )rd; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_absq_s_ob (target_ulong rt,CPUMIPSState *env) +{ +int i; +int8_t temp[8 ]; +uint64_t result; + +for (i =0 ; i <8 ; i++) { + temp[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_sat_abs_u8 (temp[i], env); + } + +for (i =0 ; i <8 ; i++) { + result = (uint64_t )(uint8_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_absq_s_qh (target_ulong rt,CPUMIPSState *env) +{ +int16_t tempD, tempC, tempB, tempA; + +MIPSDSP_SPLIT64_16 (rt, tempD, tempC, tempB, tempA); + + tempD =mipsdsp_sat_abs_u16 (tempD, env); + tempC =mipsdsp_sat_abs_u16 (tempC, env); + tempB =mipsdsp_sat_abs_u16 (tempB, env); + tempA =mipsdsp_sat_abs_u16 (tempA, env); + +return MIPSDSP_RETURN64_16 (tempD, tempC, tempB, tempA); +} + +target_ulong helper_absq_s_pw (target_ulong rt,CPUMIPSState *env) +{ +int32_t tempB, tempA; + +MIPSDSP_SPLIT64_32 (rt, tempB, tempA); + + tempB =mipsdsp_sat_abs_u32 (tempB, env); + tempA =mipsdsp_sat_abs_u32 (tempA, env); + +return MIPSDSP_RETURN64_32 (tempB, tempA); +} +#endif + +#define PRECR_QB_PH (name, a, b)\ +target_ulong helper_##name##_qb_ph(target_ulong rs, target_ulong rt) \ +{ \ + uint8_t tempD, tempC, tempB, tempA; \ + \ + tempD = (rs >> a) & MIPSDSP_Q0; \ + tempC = (rs >> b) & MIPSDSP_Q0; \ + tempB = (rt >> a) & MIPSDSP_Q0; \ + tempA = (rt >> b) & MIPSDSP_Q0; \ + \ + return MIPSDSP_RETURN32_8(tempD, tempC, tempB, tempA); \ +} + +PRECR_QB_PH (precr,16 ,0 ); +PRECR_QB_PH (precrq,24 ,8 ); + +#undef PRECR_QB_OH + +target_ulong helper_precr_sra_ph_w (uint32_t sa,target_ulong rs, +target_ulong rt) +{ +uint16_t tempB, tempA; + + tempB = ((int32_t )rt >> sa) &MIPSDSP_LO ; + tempA = ((int32_t )rs >> sa) &MIPSDSP_LO ; + +return MIPSDSP_RETURN32_16 (tempB, tempA); +} + +target_ulong helper_precr_sra_r_ph_w (uint32_t sa, +target_ulong rs,target_ulong rt) +{ +uint64_t tempB, tempA; + +/* If sa = 0, then (sa - 1) = -1 will case shift error, so we need else. */ +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; + + tempB = (rs &MIPSDSP_HI ) >>16 ; + tempA = (rt &MIPSDSP_HI ) >>16 ; + +return MIPSDSP_RETURN32_16 (tempB, tempA); +} + +target_ulong helper_precrq_rs_ph_w (target_ulong rs,target_ulong rt, +CPUMIPSState *env) +{ +uint16_t tempB, tempA; + + tempB =mipsdsp_trunc16_sat16_round (rs, env); + tempA =mipsdsp_trunc16_sat16_round (rt, env); + +return MIPSDSP_RETURN32_16 (tempB, tempA); +} + +#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; +} + +#define PRECR_QH_PW (name, var) \ +target_ulong helper_precr_##name##_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; \ + \ + MIPSDSP_SPLIT64_16(rs, rs3, rs2, rs1, rs0); \ + MIPSDSP_SPLIT64_16(rt, rt3, rt2, rt1, rt0); \ + \ +/* When sa = 0, we use rt2, rt0, rs2, rs0; \ +* when sa != 0, we use rt3, rt1, rs3, rs1. */ \ +if (sa ==0 ) { \ + tempD = rt2 << var; \ + tempC = rt0 << var; \ + tempB = rs2 << var; \ + tempA = rs0 << var; \ + }else { \ + tempD = (((int16_t )rt3 >> sa) + var) >> var; \ + tempC = (((int16_t )rt1 >> sa) + var) >> var; \ + tempB = (((int16_t )rs3 >> sa) + var) >> var; \ + tempA = (((int16_t )rs1 >> sa) + var) >> var; \ + } \ + \ +return MIPSDSP_RETURN64_16 (tempD, tempC, tempB, tempA); \ +} + +PRECR_QH_PW (sra,0 ); +PRECR_QH_PW (sra_r,1 ); + +#undef PRECR_QH_PW + +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; + + tempD = (rs >>48 ) &MIPSDSP_LO ; + tempC = (rs >>16 ) &MIPSDSP_LO ; + tempB = (rt >>48 ) &MIPSDSP_LO ; + tempA = (rt >>16 ) &MIPSDSP_LO ; + +return MIPSDSP_RETURN64_16 (tempD, tempC, tempB, tempA); +} + +target_ulong helper_precrq_rs_qh_pw (target_ulong rs,target_ulong rt, +CPUMIPSState *env) +{ +uint32_t rs2, rs0; +uint32_t rt2, rt0; +uint16_t tempD, tempC, tempB, tempA; + + rs2 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt2 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempD =mipsdsp_trunc16_sat16_round (rs2, env); + tempC =mipsdsp_trunc16_sat16_round (rs0, env); + tempB =mipsdsp_trunc16_sat16_round (rt2, env); + tempA =mipsdsp_trunc16_sat16_round (rt0, env); + +return MIPSDSP_RETURN64_16 (tempD, tempC, tempB, tempA); +} + +target_ulong helper_precrq_pw_l (target_ulong rs,target_ulong rt) +{ +uint32_t tempB, tempA; + + tempB = (rs >>32 ) &MIPSDSP_LLO ; + tempA = (rt >>32 ) &MIPSDSP_LLO ; + +return MIPSDSP_RETURN64_32 (tempB, tempA); +} +#endif + +target_ulong helper_precrqu_s_qb_ph (target_ulong rs,target_ulong rt, +CPUMIPSState *env) +{ +uint8_t tempD, tempC, tempB, tempA; +uint16_t rsh, rsl, rth, rtl; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sat8_reduce_precision (rsh, env); + tempC =mipsdsp_sat8_reduce_precision (rsl, env); + tempB =mipsdsp_sat8_reduce_precision (rth, env); + tempA =mipsdsp_sat8_reduce_precision (rtl, env); + +return MIPSDSP_RETURN32_8 (tempD, tempC, tempB, tempA); +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_precrqu_s_ob_qh (target_ulong rs,target_ulong rt, +CPUMIPSState *env) +{ +int i; +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +MIPSDSP_SPLIT64_16 (rs, rs3, rs2, rs1, rs0); +MIPSDSP_SPLIT64_16 (rt, rt3, rt2, rt1, rt0); + + temp[7 ] =mipsdsp_sat8_reduce_precision (rs3, env); + temp[6 ] =mipsdsp_sat8_reduce_precision (rs2, env); + temp[5 ] =mipsdsp_sat8_reduce_precision (rs1, env); + temp[4 ] =mipsdsp_sat8_reduce_precision (rs0, env); + temp[3 ] =mipsdsp_sat8_reduce_precision (rt3, env); + temp[2 ] =mipsdsp_sat8_reduce_precision (rt2, env); + temp[1 ] =mipsdsp_sat8_reduce_precision (rt1, env); + temp[0 ] =mipsdsp_sat8_reduce_precision (rt0, env); + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +#define PRECEQ_PW (name, a, b) \ +target_ulong helper_preceq_pw_##name(target_ulong rt) \ +{ \ + uint16_t tempB, tempA; \ + uint32_t tempBI, tempAI; \ + \ + tempB = (rt >> a) & MIPSDSP_LO; \ + tempA = (rt >> b) & MIPSDSP_LO; \ + \ + tempBI = (uint32_t)tempB << 16; \ + tempAI = (uint32_t)tempA << 16; \ + \ + return MIPSDSP_RETURN64_32(tempBI, tempAI); \ +} + +PRECEQ_PW (qhl,48 ,32 ); +PRECEQ_PW (qhr,16 ,0 ); +PRECEQ_PW (qhla,48 ,16 ); +PRECEQ_PW (qhra,32 ,0 ); + +#undef PRECEQ_PW + +#endif + +#define PRECEQU_PH (name, a, b) \ +target_ulong helper_precequ_ph_##name(target_ulong rt) \ +{ \ + uint16_t tempB, tempA; \ + \ + tempB = (rt >> a) & MIPSDSP_Q0; \ + tempA = (rt >> b) & MIPSDSP_Q0; \ + \ + tempB = tempB << 7; \ + tempA = tempA << 7; \ + \ + return MIPSDSP_RETURN32_16(tempB, tempA); \ +} + +PRECEQU_PH (qbl,24 ,16 ); +PRECEQU_PH (qbr,8 ,0 ); +PRECEQU_PH (qbla,24 ,8 ); +PRECEQU_PH (qbra,16 ,0 ); + +#undef PRECEQU_PH + +#if defined(TARGET_MIPS64 ) +#define PRECEQU_QH (name, a, b, c, d) \ +target_ulong helper_precequ_qh_##name(target_ulong rt) \ +{ \ + uint16_t tempD, tempC, tempB, tempA; \ + \ + tempD = (rt >> a) & MIPSDSP_Q0; \ + tempC = (rt >> b) & MIPSDSP_Q0; \ + tempB = (rt >> c) & MIPSDSP_Q0; \ + tempA = (rt >> d) & MIPSDSP_Q0; \ + \ + tempD = tempD << 7; \ + tempC = tempC << 7; \ + tempB = tempB << 7; \ + tempA = tempA << 7; \ + \ + return MIPSDSP_RETURN64_16(tempD, tempC, tempB, tempA); \ +} + +PRECEQU_QH (obl,56 ,48 ,40 ,32 ); +PRECEQU_QH (obr,24 ,16 ,8 ,0 ); +PRECEQU_QH (obla,56 ,40 ,24 ,8 ); +PRECEQU_QH (obra,48 ,32 ,16 ,0 ); + +#undef PRECEQU_QH + +#endif + +#define PRECEU_PH (name, a, b) \ +target_ulong helper_preceu_ph_##name(target_ulong rt) \ +{ \ + uint16_t tempB, tempA; \ + \ + tempB = (rt >> a) & MIPSDSP_Q0; \ + tempA = (rt >> b) & MIPSDSP_Q0; \ + \ + return MIPSDSP_RETURN32_16(tempB, tempA); \ +} + +PRECEU_PH (qbl,24 ,16 ); +PRECEU_PH (qbr,8 ,0 ); +PRECEU_PH (qbla,24 ,8 ); +PRECEU_PH (qbra,16 ,0 ); + +#undef PRECEU_PH + +#if defined(TARGET_MIPS64 ) +#define PRECEU_QH (name, a, b, c, d) \ +target_ulong helper_preceu_qh_##name(target_ulong rt) \ +{ \ + uint16_t tempD, tempC, tempB, tempA; \ + \ + tempD = (rt >> a) & MIPSDSP_Q0; \ + tempC = (rt >> b) & MIPSDSP_Q0; \ + tempB = (rt >> c) & MIPSDSP_Q0; \ + tempA = (rt >> d) & MIPSDSP_Q0; \ + \ + return MIPSDSP_RETURN64_16(tempD, tempC, tempB, tempA); \ +} + +PRECEU_QH (obl,56 ,48 ,40 ,32 ); +PRECEU_QH (obr,24 ,16 ,8 ,0 ); +PRECEU_QH (obla,56 ,40 ,24 ,8 ); +PRECEU_QH (obra,48 ,32 ,16 ,0 ); + +#undef PRECEU_QH + +#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 + +#undef MIPSDSP_SPLIT32_8 +#undef MIPSDSP_SPLIT32_16 + +#undef MIPSDSP_RETURN32 +#undef MIPSDSP_RETURN32_8 +#undef MIPSDSP_RETURN32_16 + +#ifdef TARGET_MIPS64 +#undef MIPSDSP_SPLIT64_16 +#undef MIPSDSP_SPLIT64_32 +#undef MIPSDSP_RETURN64_16 +#undef MIPSDSP_RETURN64_32 +#endif
target-mips/helper.h +126 -0
130 lines not on this page · raw message
target-mips/translate.c +827 -3
867 lines not on this page · raw message
Signature · 1 line
1.7.10.2 (Apple Git-33)
Re: [Qemu-devel] [PATCH v9 06/14] target-mips-ase-dsp: Add arithmetic instructions
Quoted 364 lines · Jia Liu
Add MIPS ASE DSP Arithmetic instructions.
Signed-off-by Jia Liu <[email protected]>--- target-mips/dsp_helper.c | 895 ++++++++++++++++++++++++++++++++++++++++++++++ target-mips/helper.h | 126 +++++++ target-mips/translate.c | 830 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 1848 insertions(+), 3 deletions(-)target-mips/dsp_helper.c +347
-0@@ -1119,3 +1119,898 @@ static inline int32_t mipsdsp_cmp_lt(uint32_t a, uint32_t b)return a < b; }/*** 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 + +#define MIPSDSP_SPLIT32_8 (num, a, b, c, d) \ + do { \ + a = (num >> 24) & MIPSDSP_Q0; \ + b = (num >> 16) & MIPSDSP_Q0; \ + c = (num >> 8) & MIPSDSP_Q0; \ + d = num & MIPSDSP_Q0; \ + } while (0) + +#define MIPSDSP_SPLIT32_16 (num, a, b) \ + do { \ + a = (num >> 16) & MIPSDSP_LO; \ + b = num & MIPSDSP_LO; \ + } while (0) + +#define MIPSDSP_RETURN32 (a) ((target_long)(int32_t)a) +#define MIPSDSP_RETURN32_8 (a, b, c, d) ((target_long)(int32_t) \ + (((uint32_t)a << 24) | \ + (((uint32_t)b << 16) | \ + (((uint32_t)c << 8) | \ + ((uint32_t)d & 0xFF))))) +#define MIPSDSP_RETURN32_16 (a, b) ((target_long)(int32_t) \ + (((uint32_t)a << 16) | \ + ((uint32_t)b & 0xFFFF))) + +#ifdef TARGET_MIPS64 +#define MIPSDSP_SPLIT64_16 (num, a, b, c, d) \ + do { \ + a = (num >> 48) & MIPSDSP_LO; \ + b = (num >> 32) & MIPSDSP_LO; \ + c = (num >> 16) & MIPSDSP_LO; \ + d = num & MIPSDSP_LO; \ + } while (0) + +#define MIPSDSP_SPLIT64_32 (num, a, b) \ + do { \ + a = (num >> 32) & MIPSDSP_LLO; \ + b = num & MIPSDSP_LLO; \ + } while (0) + +#define MIPSDSP_RETURN64_16 (a, b, c, d) (((uint64_t)a << 48) | \ + ((uint64_t)b << 32) | \ + ((uint64_t)c << 16) | \ + (uint64_t)d) +#define MIPSDSP_RETURN64_32 (a, b) (((uint64_t)a << 32) | (uint64_t)b) +#endif + +/** DSP Arithmetic Sub-class insns **/ +#define ARITH_PH (name, func) \ +target_ulong helper_##name##_ph(target_ulong rs, target_ulong rt) \ +{ \ + uint16_t rsh, rsl, rth, rtl, temph, templ; \ + \ + MIPSDSP_SPLIT32_16(rs, rsh, rsl); \ + MIPSDSP_SPLIT32_16(rt, rth, rtl); \ + \ + temph = mipsdsp_##func(rsh, rth); \ + templ = mipsdsp_##func(rsl, rtl); \ + \ + return MIPSDSP_RETURN32_16(temph, templ); \ +} + +#define ARITH_PH_ENV (name, func) \ +target_ulong helper_##name##_ph(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint16_t rsh, rsl, rth, rtl, temph, templ; \ + \ + MIPSDSP_SPLIT32_16(rs, rsh, rsl); \ + MIPSDSP_SPLIT32_16(rt, rth, rtl); \ + \ + temph = mipsdsp_##func(rsh, rth, env); \ + templ = mipsdsp_##func(rsl, rtl, env); \ + \ + return MIPSDSP_RETURN32_16(temph, templ); \ +} + + +ARITH_PH_ENV (addq, add_i16); +ARITH_PH_ENV (addq_s, sat_add_i16); +ARITH_PH_ENV (addu, add_u16); +ARITH_PH_ENV (addu_s, sat_add_u16); + +ARITH_PH (addqh, rshift1_add_q16); +ARITH_PH (addqh_r, rrshift1_add_q16); + +ARITH_PH_ENV (subq, sub_i16); +ARITH_PH_ENV (subq_s, sat16_sub); +ARITH_PH_ENV (subu, sub_u16_u16); +ARITH_PH_ENV (subu_s, satu16_sub_u16_u16); + +ARITH_PH (subqh, rshift1_sub_q16); +ARITH_PH (subqh_r, rrshift1_sub_q16); + +#undef ARITH_PH +#undef ARITH_PH_ENV + +#ifdef TARGET_MIPS64 +#define ARITH_QH_ENV (name, func) \ +target_ulong helper_##name##_qh(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint16_t rs3, rs2, rs1, rs0; \ + uint16_t rt3, rt2, rt1, rt0; \ + uint16_t tempD, tempC, tempB, tempA; \ + \ + MIPSDSP_SPLIT64_16(rs, rs3, rs2, rs1, rs0); \ + MIPSDSP_SPLIT64_16(rt, rt3, rt2, rt1, rt0); \ + \ + tempD = mipsdsp_##func(rs3, rt3, env); \ + tempC = mipsdsp_##func(rs2, rt2, env); \ + tempB = mipsdsp_##func(rs1, rt1, env); \ + tempA = mipsdsp_##func(rs0, rt0, env); \ + \ + return MIPSDSP_RETURN64_16(tempD, tempC, tempB, tempA); \ +} + +ARITH_QH_ENV (addq, add_i16); +ARITH_QH_ENV (addq_s, sat_add_i16); +ARITH_QH_ENV (addu, add_u16); +ARITH_QH_ENV (addu_s, sat_add_u16); + +ARITH_QH_ENV (subq, sub_i16); +ARITH_QH_ENV (subq_s, sat16_sub); +ARITH_QH_ENV (subu, sub_u16_u16); +ARITH_QH_ENV (subu_s, satu16_sub_u16_u16); + +#undef ARITH_QH_ENV + +#endif + +#define ARITH_W (name, func) \ +target_ulong helper_##name##_w(target_ulong rs, target_ulong rt) \ +{ \ + uint32_t rd; \ + rd = mipsdsp_##func(rs, rt); \ + return MIPSDSP_RETURN32(rd); \ +} + +#define ARITH_W_ENV (name, func) \ +target_ulong helper_##name##_w(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint32_t rd; \ + rd = mipsdsp_##func(rs, rt, env); \ + return MIPSDSP_RETURN32(rd); \ +} + +ARITH_W_ENV (addq_s, sat_add_i32); + +ARITH_W (addqh, rshift1_add_q32); +ARITH_W (addqh_r, rrshift1_add_q32); + +ARITH_W_ENV (subq_s, sat32_sub); + +ARITH_W (subqh, rshift1_sub_q32); +ARITH_W (subqh_r, rrshift1_sub_q32); + +#undef ARITH_W +#undef ARITH_W_ENV + +target_ulong helper_absq_s_w (target_ulong rt,CPUMIPSState *env) +{ +uint32_t rd; + + rd =mipsdsp_sat_abs_u32 (rt, env); + +return (target_ulong )rd; +} + + +#if defined(TARGET_MIPS64 ) + +#define ARITH_PW_ENV (name, func) \ +target_ulong helper_##name##_pw(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint32_t rs1, rs0; \ + uint32_t rt1, rt0; \ + uint32_t tempB, tempA; \ + \ + MIPSDSP_SPLIT64_32(rs, rs1, rs0); \ + MIPSDSP_SPLIT64_32(rt, rt1, rt0); \ + \ + tempB = mipsdsp_##func(rs1, rt1, env); \ + tempA = mipsdsp_##func(rs0, rt0, env); \ + \ + return MIPSDSP_RETURN64_32(tempB, tempA); \ +} + +ARITH_PW_ENV (addq, add_i32); +ARITH_PW_ENV (addq_s, sat_add_i32); +ARITH_PW_ENV (subq, sub32); +ARITH_PW_ENV (subq_s, sat32_sub); + +#undef ARITH_PW_ENV + +#endif + +#define ARITH_QB (name, func) \ +target_ulong helper_##name##_qb(target_ulong rs, target_ulong rt) \ +{ \ + uint8_t rs0, rs1, rs2, rs3; \ + uint8_t rt0, rt1, rt2, rt3; \ + uint8_t temp0, temp1, temp2, temp3; \ + \ + MIPSDSP_SPLIT32_8(rs, rs3, rs2, rs1, rs0); \ + MIPSDSP_SPLIT32_8(rt, rt3, rt2, rt1, rt0); \ + \ + temp0 = mipsdsp_##func(rs0, rt0); \ + temp1 = mipsdsp_##func(rs1, rt1); \ + temp2 = mipsdsp_##func(rs2, rt2); \ + temp3 = mipsdsp_##func(rs3, rt3); \ + \ + return MIPSDSP_RETURN32_8(temp3, temp2, temp1, temp0); \ +} + +#define ARITH_QB_ENV (name, func) \ +target_ulong helper_##name##_qb(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint8_t rs0, rs1, rs2, rs3; \ + uint8_t rt0, rt1, rt2, rt3; \ + uint8_t temp0, temp1, temp2, temp3; \ + \ + MIPSDSP_SPLIT32_8(rs, rs3, rs2, rs1, rs0); \ + MIPSDSP_SPLIT32_8(rt, rt3, rt2, rt1, rt0); \ + \ + temp0 = mipsdsp_##func(rs0, rt0, env); \ + temp1 = mipsdsp_##func(rs1, rt1, env); \ + temp2 = mipsdsp_##func(rs2, rt2, env); \ + temp3 = mipsdsp_##func(rs3, rt3, env); \ + \ + return MIPSDSP_RETURN32_8(temp3, temp2, temp1, temp0); \ +} + +ARITH_QB (adduh, rshift1_add_u8); +ARITH_QB (adduh_r, rrshift1_add_u8); + +ARITH_QB_ENV (addu, add_u8); +ARITH_QB_ENV (addu_s, sat_add_u8); + +#undef ADDU_QB +#undef ADDU_QB_ENV + +#if defined(TARGET_MIPS64 ) +#define ARITH_OB (name, func) \ +target_ulong helper_##name##_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_##func(rs_t[i], rt_t[i]); \ + result |= (uint64_t)temp[i] << (8 * i); \ + } \ + \ + return result; \ +} + +#define ARITH_OB_ENV (name, func) \ +target_ulong helper_##name##_ob(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + 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_##func(rs_t[i], rt_t[i], env); \ + result |= (uint64_t)temp[i] << (8 * i); \ + } \ + \ + return result; \ +} + +ARITH_OB_ENV (addu, add_u8); +ARITH_OB_ENV (addu_s, sat_add_u8); + +ARITH_OB (adduh, rshift1_add_u8); +ARITH_OB (adduh_r, rrshift1_add_u8); + +ARITH_OB_ENV (subu, sub_u8); +ARITH_OB_ENV (subu_s, satu8_sub); + +ARITH_OB (subuh, rshift1_sub_u8); +ARITH_OB (subuh_r, rrshift1_sub_u8); + +#undef ARITH_OB +#undef ARITH_OB_ENV + +#endif + +#define SUBU_QB (name, func) \ +target_ulong helper_##name##_qb(target_ulong rs, \ + target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint8_t rs3, rs2, rs1, rs0; \ + uint8_t rt3, rt2, rt1, rt0; \ + uint8_t tempD, tempC, tempB, tempA; \ + \ + MIPSDSP_SPLIT32_8(rs, rs3, rs2, rs1, rs0); \ + MIPSDSP_SPLIT32_8(rt, rt3, rt2, rt1, rt0); \ + \ + tempD = mipsdsp_##func(rs3, rt3, env); \ + tempC = mipsdsp_##func(rs2, rt2, env); \ + tempB = mipsdsp_##func(rs1, rt1, env); \ + tempA = mipsdsp_##func(rs0, rt0, env); \ + \ + return MIPSDSP_RETURN32_8(tempD, tempC, tempB, tempA); \ +} + +SUBU_QB (subu, sub_u8); +SUBU_QB (subu_s, satu8_sub); + +#undef SUBU_QB + +#define SUBUH_QB (name, var) \ +target_ulong helper_##name##_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; \ + \ + MIPSDSP_SPLIT32_8(rs, rs3, rs2, rs1, rs0); \ + MIPSDSP_SPLIT32_8(rt, rt3, rt2, rt1, rt0); \
target-mips/dsp_helper.c static inline int32_t mipsdsp_cmp_lt(uint32_t a, uint32_t b) · line 1478
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+ \ + tempD = ((uint16_t )rs3 - (uint16_t )rt3 + var) >>1 ; \ + tempC = ((uint16_t )rs2 - (uint16_t )rt2 + var) >>1 ; \ + tempB = ((uint16_t )rs1 - (uint16_t )rt1 + var) >>1 ; \ + tempA = ((uint16_t )rs0 - (uint16_t )rt0 + var) >>1 ; \ + \ +return ((uint32_t )tempD <<24 ) | ((uint32_t )tempC <<16 ) | \ + ((uint32_t )tempB <<8 ) | (uint32_t )tempA; \ +} +
Why not using (uint32_t)MIPSDSP_RETURN32_8(tempD, tempC, tempB, tempA) here?
Quoted 91 lines
target-mips/dsp_helper.c +91
-0+SUBUH_QB (subuh,0 ); +SUBUH_QB (subuh_r,1 ); + +#undef SUBUH_QB + +target_ulong helper_addsc (target_ulong rs,target_ulong rt,CPUMIPSState *env) +{ +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 (flag, env); + +return (target_long)(int32_t)(temp &MIPSDSP_LLO ); +} + +target_ulong helper_addwc (target_ulong rs,target_ulong rt,CPUMIPSState *env) +{ +uint32_t rd; +int32_t temp32, temp31; +int64_t tempL; + + tempL = (int32_t )rs + (int32_t )rt +get_DSPControl_carryflag (env); + temp31 = (tempL >>31 ) &0x01 ; + temp32 = (tempL >>32 ) &0x01 ; + +if (temp31 != temp32) { +set_DSPControl_overflow_flag (1 ,20 , env); + } + + 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; + +MIPSDSP_SPLIT32_8 (rs, rs3, rs2, rs1, rs0); + + temp = (uint16_t )rs3 + (uint16_t )rs2 + (uint16_t )rs1 + (uint16_t )rs0; + +return (target_ulong )temp; +} + +#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 (target_ulong rt,CPUMIPSState *env) +{ +uint32_t rd; +int8_t tempD, tempC, tempB, tempA;
target-mips/dsp_helper.c static inline int32_t mipsdsp_cmp_lt(uint32_t a, uint32_t b) · line 1579
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+ +MIPSDSP_SPLIT32_8 (rt, tempD, tempC, tempB, tempA); + + rd = (((uint32_t )mipsdsp_sat_abs_u8 (tempD, env) <<24 ) &MIPSDSP_Q3 ) | + (((uint32_t )mipsdsp_sat_abs_u8 (tempC, env) <<16 ) &MIPSDSP_Q2 ) | + (((uint32_t )mipsdsp_sat_abs_u8 (tempB, env) <<8 ) &MIPSDSP_Q1 ) | + ((uint32_t )mipsdsp_sat_abs_u8 (tempA, env) &MIPSDSP_Q0 ); + +return (target_ulong )rd; +}
The result is supposed to be signed extended, so you should use MIPSDSP_RETURN32_8 instead.
target-mips/dsp_helper.c static inline int32_t mipsdsp_cmp_lt(uint32_t a, uint32_t b) · line 1592
Quoted 13 lines
target-mips/dsp_helper.c +13
-0+ +target_ulong helper_absq_s_ph (target_ulong rt,CPUMIPSState *env) +{ +uint32_t rd; +int16_t tempB, tempA; + +MIPSDSP_SPLIT32_16 (rt, tempB, tempA); + + rd = ((uint32_t )(uint16_t )mipsdsp_sat_abs_u16 (tempB, env) <<16 ) | + ((uint32_t )((uint16_t )mipsdsp_sat_abs_u16 (tempA, env)) &0xFFFF ); + +return (target_long )(int32_t )rd; +}
There you can use MIPSDSP_RETURN32_16.
Quoted 1,204 lines
target-mips/dsp_helper.c +423
-0+#if defined(TARGET_MIPS64 ) +target_ulong helper_absq_s_ob (target_ulong rt,CPUMIPSState *env) +{ +int i; +int8_t temp[8 ]; +uint64_t result; + +for (i =0 ; i <8 ; i++) { + temp[i] = (rt >> (8 * i)) &MIPSDSP_Q0 ; + temp[i] =mipsdsp_sat_abs_u8 (temp[i], env); + } + +for (i =0 ; i <8 ; i++) { + result = (uint64_t )(uint8_t )temp[i] << (8 * i); + } + +return result; +} + +target_ulong helper_absq_s_qh (target_ulong rt,CPUMIPSState *env) +{ +int16_t tempD, tempC, tempB, tempA; + +MIPSDSP_SPLIT64_16 (rt, tempD, tempC, tempB, tempA); + + tempD =mipsdsp_sat_abs_u16 (tempD, env); + tempC =mipsdsp_sat_abs_u16 (tempC, env); + tempB =mipsdsp_sat_abs_u16 (tempB, env); + tempA =mipsdsp_sat_abs_u16 (tempA, env); + +return MIPSDSP_RETURN64_16 (tempD, tempC, tempB, tempA); +} + +target_ulong helper_absq_s_pw (target_ulong rt,CPUMIPSState *env) +{ +int32_t tempB, tempA; + +MIPSDSP_SPLIT64_32 (rt, tempB, tempA); + + tempB =mipsdsp_sat_abs_u32 (tempB, env); + tempA =mipsdsp_sat_abs_u32 (tempA, env); + +return MIPSDSP_RETURN64_32 (tempB, tempA); +} +#endif + +#define PRECR_QB_PH (name, a, b)\ +target_ulong helper_##name##_qb_ph(target_ulong rs, target_ulong rt) \ +{ \ + uint8_t tempD, tempC, tempB, tempA; \ + \ + tempD = (rs >> a) & MIPSDSP_Q0; \ + tempC = (rs >> b) & MIPSDSP_Q0; \ + tempB = (rt >> a) & MIPSDSP_Q0; \ + tempA = (rt >> b) & MIPSDSP_Q0; \ + \ + return MIPSDSP_RETURN32_8(tempD, tempC, tempB, tempA); \ +} + +PRECR_QB_PH (precr,16 ,0 ); +PRECR_QB_PH (precrq,24 ,8 ); + +#undef PRECR_QB_OH + +target_ulong helper_precr_sra_ph_w (uint32_t sa,target_ulong rs, +target_ulong rt) +{ +uint16_t tempB, tempA; + + tempB = ((int32_t )rt >> sa) &MIPSDSP_LO ; + tempA = ((int32_t )rs >> sa) &MIPSDSP_LO ; + +return MIPSDSP_RETURN32_16 (tempB, tempA); +} + +target_ulong helper_precr_sra_r_ph_w (uint32_t sa, +target_ulong rs,target_ulong rt) +{ +uint64_t tempB, tempA; + +/* If sa = 0, then (sa - 1) = -1 will case shift error, so we need else. */ +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; + + tempB = (rs &MIPSDSP_HI ) >>16 ; + tempA = (rt &MIPSDSP_HI ) >>16 ; + +return MIPSDSP_RETURN32_16 (tempB, tempA); +} + +target_ulong helper_precrq_rs_ph_w (target_ulong rs,target_ulong rt, +CPUMIPSState *env) +{ +uint16_t tempB, tempA; + + tempB =mipsdsp_trunc16_sat16_round (rs, env); + tempA =mipsdsp_trunc16_sat16_round (rt, env); + +return MIPSDSP_RETURN32_16 (tempB, tempA); +} + +#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; +} + +#define PRECR_QH_PW (name, var) \ +target_ulong helper_precr_##name##_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; \ + \ + MIPSDSP_SPLIT64_16(rs, rs3, rs2, rs1, rs0); \ + MIPSDSP_SPLIT64_16(rt, rt3, rt2, rt1, rt0); \ + \ +/* When sa = 0, we use rt2, rt0, rs2, rs0; \ +* when sa != 0, we use rt3, rt1, rs3, rs1. */ \ +if (sa ==0 ) { \ + tempD = rt2 << var; \ + tempC = rt0 << var; \ + tempB = rs2 << var; \ + tempA = rs0 << var; \ + }else { \ + tempD = (((int16_t )rt3 >> sa) + var) >> var; \ + tempC = (((int16_t )rt1 >> sa) + var) >> var; \ + tempB = (((int16_t )rs3 >> sa) + var) >> var; \ + tempA = (((int16_t )rs1 >> sa) + var) >> var; \ + } \ + \ +return MIPSDSP_RETURN64_16 (tempD, tempC, tempB, tempA); \ +} + +PRECR_QH_PW (sra,0 ); +PRECR_QH_PW (sra_r,1 ); + +#undef PRECR_QH_PW + +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; + + tempD = (rs >>48 ) &MIPSDSP_LO ; + tempC = (rs >>16 ) &MIPSDSP_LO ; + tempB = (rt >>48 ) &MIPSDSP_LO ; + tempA = (rt >>16 ) &MIPSDSP_LO ; + +return MIPSDSP_RETURN64_16 (tempD, tempC, tempB, tempA); +} + +target_ulong helper_precrq_rs_qh_pw (target_ulong rs,target_ulong rt, +CPUMIPSState *env) +{ +uint32_t rs2, rs0; +uint32_t rt2, rt0; +uint16_t tempD, tempC, tempB, tempA; + + rs2 = (rs >>32 ) &MIPSDSP_LLO ; + rs0 = rs &MIPSDSP_LLO ; + rt2 = (rt >>32 ) &MIPSDSP_LLO ; + rt0 = rt &MIPSDSP_LLO ; + + tempD =mipsdsp_trunc16_sat16_round (rs2, env); + tempC =mipsdsp_trunc16_sat16_round (rs0, env); + tempB =mipsdsp_trunc16_sat16_round (rt2, env); + tempA =mipsdsp_trunc16_sat16_round (rt0, env); + +return MIPSDSP_RETURN64_16 (tempD, tempC, tempB, tempA); +} + +target_ulong helper_precrq_pw_l (target_ulong rs,target_ulong rt) +{ +uint32_t tempB, tempA; + + tempB = (rs >>32 ) &MIPSDSP_LLO ; + tempA = (rt >>32 ) &MIPSDSP_LLO ; + +return MIPSDSP_RETURN64_32 (tempB, tempA); +} +#endif + +target_ulong helper_precrqu_s_qb_ph (target_ulong rs,target_ulong rt, +CPUMIPSState *env) +{ +uint8_t tempD, tempC, tempB, tempA; +uint16_t rsh, rsl, rth, rtl; + + rsh = (rs &MIPSDSP_HI ) >>16 ; + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + rtl = rt &MIPSDSP_LO ; + + tempD =mipsdsp_sat8_reduce_precision (rsh, env); + tempC =mipsdsp_sat8_reduce_precision (rsl, env); + tempB =mipsdsp_sat8_reduce_precision (rth, env); + tempA =mipsdsp_sat8_reduce_precision (rtl, env); + +return MIPSDSP_RETURN32_8 (tempD, tempC, tempB, tempA); +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_precrqu_s_ob_qh (target_ulong rs,target_ulong rt, +CPUMIPSState *env) +{ +int i; +uint16_t rs3, rs2, rs1, rs0; +uint16_t rt3, rt2, rt1, rt0; +uint8_t temp[8 ]; +uint64_t result; + + result =0 ; + +MIPSDSP_SPLIT64_16 (rs, rs3, rs2, rs1, rs0); +MIPSDSP_SPLIT64_16 (rt, rt3, rt2, rt1, rt0); + + temp[7 ] =mipsdsp_sat8_reduce_precision (rs3, env); + temp[6 ] =mipsdsp_sat8_reduce_precision (rs2, env); + temp[5 ] =mipsdsp_sat8_reduce_precision (rs1, env); + temp[4 ] =mipsdsp_sat8_reduce_precision (rs0, env); + temp[3 ] =mipsdsp_sat8_reduce_precision (rt3, env); + temp[2 ] =mipsdsp_sat8_reduce_precision (rt2, env); + temp[1 ] =mipsdsp_sat8_reduce_precision (rt1, env); + temp[0 ] =mipsdsp_sat8_reduce_precision (rt0, env); + +for (i =0 ; i <8 ; i++) { + result |= (uint64_t )temp[i] << (8 * i); + } + +return result; +} + +#define PRECEQ_PW (name, a, b) \ +target_ulong helper_preceq_pw_##name(target_ulong rt) \ +{ \ + uint16_t tempB, tempA; \ + uint32_t tempBI, tempAI; \ + \ + tempB = (rt >> a) & MIPSDSP_LO; \ + tempA = (rt >> b) & MIPSDSP_LO; \ + \ + tempBI = (uint32_t)tempB << 16; \ + tempAI = (uint32_t)tempA << 16; \ + \ + return MIPSDSP_RETURN64_32(tempBI, tempAI); \ +} + +PRECEQ_PW (qhl,48 ,32 ); +PRECEQ_PW (qhr,16 ,0 ); +PRECEQ_PW (qhla,48 ,16 ); +PRECEQ_PW (qhra,32 ,0 ); + +#undef PRECEQ_PW + +#endif + +#define PRECEQU_PH (name, a, b) \ +target_ulong helper_precequ_ph_##name(target_ulong rt) \ +{ \ + uint16_t tempB, tempA; \ + \ + tempB = (rt >> a) & MIPSDSP_Q0; \ + tempA = (rt >> b) & MIPSDSP_Q0; \ + \ + tempB = tempB << 7; \ + tempA = tempA << 7; \ + \ + return MIPSDSP_RETURN32_16(tempB, tempA); \ +} + +PRECEQU_PH (qbl,24 ,16 ); +PRECEQU_PH (qbr,8 ,0 ); +PRECEQU_PH (qbla,24 ,8 ); +PRECEQU_PH (qbra,16 ,0 ); + +#undef PRECEQU_PH + +#if defined(TARGET_MIPS64 ) +#define PRECEQU_QH (name, a, b, c, d) \ +target_ulong helper_precequ_qh_##name(target_ulong rt) \ +{ \ + uint16_t tempD, tempC, tempB, tempA; \ + \ + tempD = (rt >> a) & MIPSDSP_Q0; \ + tempC = (rt >> b) & MIPSDSP_Q0; \ + tempB = (rt >> c) & MIPSDSP_Q0; \ + tempA = (rt >> d) & MIPSDSP_Q0; \ + \ + tempD = tempD << 7; \ + tempC = tempC << 7; \ + tempB = tempB << 7; \ + tempA = tempA << 7; \ + \ + return MIPSDSP_RETURN64_16(tempD, tempC, tempB, tempA); \ +} + +PRECEQU_QH (obl,56 ,48 ,40 ,32 ); +PRECEQU_QH (obr,24 ,16 ,8 ,0 ); +PRECEQU_QH (obla,56 ,40 ,24 ,8 ); +PRECEQU_QH (obra,48 ,32 ,16 ,0 ); + +#undef PRECEQU_QH + +#endif + +#define PRECEU_PH (name, a, b) \ +target_ulong helper_preceu_ph_##name(target_ulong rt) \ +{ \ + uint16_t tempB, tempA; \ + \ + tempB = (rt >> a) & MIPSDSP_Q0; \ + tempA = (rt >> b) & MIPSDSP_Q0; \ + \ + return MIPSDSP_RETURN32_16(tempB, tempA); \ +} + +PRECEU_PH (qbl,24 ,16 ); +PRECEU_PH (qbr,8 ,0 ); +PRECEU_PH (qbla,24 ,8 ); +PRECEU_PH (qbra,16 ,0 ); + +#undef PRECEU_PH + +#if defined(TARGET_MIPS64 ) +#define PRECEU_QH (name, a, b, c, d) \ +target_ulong helper_preceu_qh_##name(target_ulong rt) \ +{ \ + uint16_t tempD, tempC, tempB, tempA; \ + \ + tempD = (rt >> a) & MIPSDSP_Q0; \ + tempC = (rt >> b) & MIPSDSP_Q0; \ + tempB = (rt >> c) & MIPSDSP_Q0; \ + tempA = (rt >> d) & MIPSDSP_Q0; \ + \ + return MIPSDSP_RETURN64_16(tempD, tempC, tempB, tempA); \ +} + +PRECEU_QH (obl,56 ,48 ,40 ,32 ); +PRECEU_QH (obr,24 ,16 ,8 ,0 ); +PRECEU_QH (obla,56 ,40 ,24 ,8 ); +PRECEU_QH (obra,48 ,32 ,16 ,0 ); + +#undef PRECEU_QH + +#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 + +#undef MIPSDSP_SPLIT32_8 +#undef MIPSDSP_SPLIT32_16 + +#undef MIPSDSP_RETURN32 +#undef MIPSDSP_RETURN32_8 +#undef MIPSDSP_RETURN32_16 + +#ifdef TARGET_MIPS64 +#undef MIPSDSP_SPLIT64_16 +#undef MIPSDSP_SPLIT64_32 +#undef MIPSDSP_RETURN64_16 +#undef MIPSDSP_RETURN64_32 +#endif target-mips/helper.h +126
-0@@ -362,4 +362,130 @@ DEF_HELPER_FLAGS_2(pasubub, TCG_CALL_CONST | TCG_CALL_PURE, i64, i64, i64) DEF_HELPER_FLAGS_1(biadd, TCG_CALL_CONST | TCG_CALL_PURE, i64, i64)DEF_HELPER_FLAGS_1 (pmovmskb,TCG_CALL_CONST |TCG_CALL_PURE , i64, i64) +/*** MIPS DSP ***/ +/* DSP Arithmetic Sub-class insns */ +DEF_HELPER_FLAGS_3(addq_ph, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(addq_s_ph, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(addq_qh, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(addq_s_qh, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(addq_s_w, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(addq_pw, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(addq_s_pw, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(addu_qb, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(addu_s_qb, 0, tl, tl, tl, env) +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, tl, tl, env) +DEF_HELPER_FLAGS_3(addu_s_ph, 0, tl, tl, tl, env) +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, tl, tl, env) +DEF_HELPER_FLAGS_3(addu_s_ob, 0, tl, tl, tl, env) +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, tl, tl, env) +DEF_HELPER_FLAGS_3(addu_s_qh, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(subq_ph, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(subq_s_ph, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(subq_qh, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(subq_s_qh, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(subq_s_w, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(subq_pw, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(subq_s_pw, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(subu_qb, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(subu_s_qb, 0, tl, tl, tl, env) +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, tl, tl, env) +DEF_HELPER_FLAGS_3(subu_s_ph, 0, tl, tl, tl, env) +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, tl, tl, env) +DEF_HELPER_FLAGS_3(subu_s_ob, 0, tl, tl, tl, env) +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, tl, tl, env) +DEF_HELPER_FLAGS_3(subu_s_qh, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(addsc, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(addwc, 0, tl, tl, tl, env) +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, tl, env) +DEF_HELPER_FLAGS_2(absq_s_ph, 0, tl, tl, env) +DEF_HELPER_FLAGS_2(absq_s_w, 0, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_2(absq_s_ob, 0, tl, tl, env) +DEF_HELPER_FLAGS_2(absq_s_qh, 0, tl, tl, env) +DEF_HELPER_FLAGS_2(absq_s_pw, 0, tl, tl, env) +#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, tl, tl, env) +#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, tl, tl, env) +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, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3 (precrqu_s_ob_qh, + TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl, env) + +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) +#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 +624
-0@@ -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))@@ -12276,6 +12429,494 @@ static void gen_mipsdsp_ld(CPUMIPSState *env, DisasContext *ctx, uint32_t opc,tcg_temp_free (t0); } +static void gen_mipsdsp_arith (DisasContext *ctx,uint32_t op1,uint32_t op2, +int ret,int v1,int v2) +{ +const char *opn ="mipsdsp arith" ; + +if (ret ==0 ) { +/* Treat as NOP. */ +MIPS_DEBUG ("NOP" ); +return ; + } + +switch (op1) { +/* OPC_MULT_G_2E is equal OPC_ADDUH_QB_DSP */ +case OPC_MULT_G_2E : +check_dspr2 (ctx); +switch (op2) { +case OPC_ADDUH_QB : +gen_helper_adduh_qb (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_ADDUH_R_QB : +gen_helper_adduh_r_qb (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_ADDQH_PH : +gen_helper_addqh_ph (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_ADDQH_R_PH : +gen_helper_addqh_r_ph (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_ADDQH_W : +gen_helper_addqh_w (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_ADDQH_R_W : +gen_helper_addqh_r_w (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_SUBUH_QB : +gen_helper_subuh_qb (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_SUBUH_R_QB : +gen_helper_subuh_r_qb (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_SUBQH_PH : +gen_helper_subqh_ph (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_SUBQH_R_PH : +gen_helper_subqh_r_ph (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_SUBQH_W : +gen_helper_subqh_w (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_SUBQH_R_W : +gen_helper_subqh_r_w (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; + } +break ; +case OPC_ABSQ_S_PH_DSP : +switch (op2) { +case OPC_ABSQ_S_QB : +check_dspr2 (ctx); +gen_helper_absq_s_qb (cpu_gpr[ret], cpu_gpr[v2], cpu_env); +break ; +case OPC_ABSQ_S_PH : +check_dsp (ctx); +gen_helper_absq_s_ph (cpu_gpr[ret], cpu_gpr[v2], cpu_env); +break ; +case OPC_ABSQ_S_W : +check_dsp (ctx); +gen_helper_absq_s_w (cpu_gpr[ret], cpu_gpr[v2], cpu_env); +break ; +case OPC_PRECEQ_W_PHL : + { +TCGv temp =tcg_temp_new ();; +check_dsp (ctx); +tcg_gen_andi_tl (temp, cpu_gpr[v2],0xFFFF0000 ); +tcg_gen_ext32s_tl (cpu_gpr[ret], temp); +tcg_temp_free (temp); +break ; + } +case OPC_PRECEQ_W_PHR : + { +TCGv temp =tcg_temp_new ();; +check_dsp (ctx); +tcg_gen_andi_tl (temp, cpu_gpr[v2],0x0000FFFF ); +tcg_gen_shli_tl (temp, temp,16 ); +tcg_gen_ext32s_tl (cpu_gpr[ret], temp); +tcg_temp_free (temp); +break ; + } +case OPC_PRECEQU_PH_QBL : +check_dsp (ctx); +gen_helper_precequ_ph_qbl (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEQU_PH_QBR : +check_dsp (ctx); +gen_helper_precequ_ph_qbr (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEQU_PH_QBLA : +check_dsp (ctx); +gen_helper_precequ_ph_qbla (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEQU_PH_QBRA : +check_dsp (ctx); +gen_helper_precequ_ph_qbra (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEU_PH_QBL : +check_dsp (ctx); +gen_helper_preceu_ph_qbl (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEU_PH_QBR : +check_dsp (ctx); +gen_helper_preceu_ph_qbr (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEU_PH_QBLA : +check_dsp (ctx); +gen_helper_preceu_ph_qbla (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEU_PH_QBRA : +check_dsp (ctx); +gen_helper_preceu_ph_qbra (cpu_gpr[ret], cpu_gpr[v2]); +break ; + } +break ; +case OPC_ADDU_QB_DSP : +switch (op2) { +case OPC_ADDQ_PH : +check_dsp (ctx); +gen_helper_addq_ph (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDQ_S_PH : +check_dsp (ctx); +gen_helper_addq_s_ph (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDQ_S_W : +check_dsp (ctx); +gen_helper_addq_s_w (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDU_QB : +check_dsp (ctx); +gen_helper_addu_qb (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDU_S_QB : +check_dsp (ctx); +gen_helper_addu_s_qb (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDU_PH : +check_dspr2 (ctx); +gen_helper_addu_ph (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDU_S_PH : +check_dspr2 (ctx); +gen_helper_addu_s_ph (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SUBQ_PH : +check_dsp (ctx); +gen_helper_subq_ph (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SUBQ_S_PH : +check_dsp (ctx); +gen_helper_subq_s_ph (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SUBQ_S_W : +check_dsp (ctx); +gen_helper_subq_s_w (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SUBU_QB : +check_dsp (ctx); +gen_helper_subu_qb (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SUBU_S_QB : +check_dsp (ctx); +gen_helper_subu_s_qb (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SUBU_PH : +check_dspr2 (ctx); +gen_helper_subu_ph (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SUBU_S_PH : +check_dspr2 (ctx); +gen_helper_subu_s_ph (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDSC : +check_dsp (ctx); +gen_helper_addsc (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDWC : +check_dsp (ctx); +gen_helper_addwc (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_MODSUB : +check_dsp (ctx); +gen_helper_modsub (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_RADDU_W_QB : +check_dsp (ctx); +gen_helper_raddu_w_qb (cpu_gpr[ret], cpu_gpr[v1]); +break ; + } +break ; +case OPC_CMPU_EQ_QB_DSP : +switch (op2) { +case OPC_PRECR_QB_PH : +check_dspr2 (ctx); +gen_helper_precr_qb_ph (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_PRECRQ_QB_PH : +check_dsp (ctx); +gen_helper_precrq_qb_ph (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_PRECR_SRA_PH_W : +check_dspr2 (ctx); + { +TCGv_i32 sa_t =tcg_const_i32 (v2); +gen_helper_precr_sra_ph_w (cpu_gpr[ret], sa_t, + cpu_gpr[v1], cpu_gpr[ret]); +tcg_temp_free_i32 (sa_t); +break ; + } +case OPC_PRECR_SRA_R_PH_W : +check_dspr2 (ctx); + { +TCGv_i32 sa_t =tcg_const_i32 (v2); +gen_helper_precr_sra_r_ph_w (cpu_gpr[ret], sa_t, + cpu_gpr[v1], cpu_gpr[ret]); +tcg_temp_free_i32 (sa_t); +break ; + } +case OPC_PRECRQ_PH_W : +check_dsp (ctx); +gen_helper_precrq_ph_w (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_PRECRQ_RS_PH_W : +check_dsp (ctx); +gen_helper_precrq_rs_ph_w (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_PRECRQU_S_QB_PH : +check_dsp (ctx); +gen_helper_precrqu_s_qb_ph (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; + } +break ; +#ifdef TARGET_MIPS64 +case OPC_ABSQ_S_QH_DSP : +switch (op2) { +case OPC_PRECEQ_L_PWL : +check_dsp (ctx); +tcg_gen_andi_tl (cpu_gpr[ret], cpu_gpr[v2],0xFFFFFFFF00000000ull ); +break ; +case OPC_PRECEQ_L_PWR : +check_dsp (ctx); +tcg_gen_andi_tl (cpu_gpr[ret], cpu_gpr[v2],0xFFFFFFFFull ); +break ; +case OPC_PRECEQ_PW_QHL : +check_dsp (ctx); +gen_helper_preceq_pw_qhl (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEQ_PW_QHR : +check_dsp (ctx); +gen_helper_preceq_pw_qhr (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEQ_PW_QHLA : +check_dsp (ctx); +gen_helper_preceq_pw_qhla (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEQ_PW_QHRA : +check_dsp (ctx); +gen_helper_preceq_pw_qhra (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEQU_QH_OBL : +check_dsp (ctx); +gen_helper_precequ_qh_obl (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEQU_QH_OBR : +check_dsp (ctx); +gen_helper_precequ_qh_obr (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEQU_QH_OBLA : +check_dsp (ctx); +gen_helper_precequ_qh_obla (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEQU_QH_OBRA : +check_dsp (ctx); +gen_helper_precequ_qh_obra (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEU_QH_OBL : +check_dsp (ctx); +gen_helper_preceu_qh_obl (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEU_QH_OBR : +check_dsp (ctx); +gen_helper_preceu_qh_obr (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEU_QH_OBLA : +check_dsp (ctx); +gen_helper_preceu_qh_obla (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_PRECEU_QH_OBRA : +check_dsp (ctx); +gen_helper_preceu_qh_obra (cpu_gpr[ret], cpu_gpr[v2]); +break ; +case OPC_ABSQ_S_OB : +check_dspr2 (ctx); +gen_helper_absq_s_ob (cpu_gpr[ret], cpu_gpr[v2], cpu_env); +break ; +case OPC_ABSQ_S_PW : +check_dsp (ctx); +gen_helper_absq_s_pw (cpu_gpr[ret], cpu_gpr[v2], cpu_env); +break ; +case OPC_ABSQ_S_QH : +check_dsp (ctx); +gen_helper_absq_s_qh (cpu_gpr[ret], cpu_gpr[v2], cpu_env); +break ; + } +break ; +case OPC_ADDU_OB_DSP : +switch (op2) { +case OPC_RADDU_L_OB : +check_dsp (ctx); +gen_helper_raddu_l_ob (cpu_gpr[ret], cpu_gpr[v1]); +break ; +case OPC_SUBQ_PW : +check_dsp (ctx); +gen_helper_subq_pw (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SUBQ_S_PW : +check_dsp (ctx); +gen_helper_subq_s_pw (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SUBQ_QH : +check_dsp (ctx); +gen_helper_subq_qh (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SUBQ_S_QH : +check_dsp (ctx); +gen_helper_subq_s_qh (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SUBU_OB : +check_dsp (ctx); +gen_helper_subu_ob (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SUBU_S_OB : +check_dsp (ctx); +gen_helper_subu_s_ob (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SUBU_QH : +check_dspr2 (ctx); +gen_helper_subu_qh (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SUBU_S_QH : +check_dspr2 (ctx); +gen_helper_subu_s_qh (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SUBUH_OB : +check_dspr2 (ctx); +gen_helper_subuh_ob (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_SUBUH_R_OB : +check_dspr2 (ctx); +gen_helper_subuh_r_ob (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_ADDQ_PW : +check_dsp (ctx); +gen_helper_addq_pw (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDQ_S_PW : +check_dsp (ctx); +gen_helper_addq_s_pw (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDQ_QH : +check_dsp (ctx); +gen_helper_addq_qh (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDQ_S_QH : +check_dsp (ctx); +gen_helper_addq_s_qh (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDU_OB : +check_dsp (ctx); +gen_helper_addu_ob (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDU_S_OB : +check_dsp (ctx); +gen_helper_addu_s_ob (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDU_QH : +check_dspr2 (ctx); +gen_helper_addu_qh (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDU_S_QH : +check_dspr2 (ctx); +gen_helper_addu_s_qh (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_ADDUH_OB : +check_dspr2 (ctx); +gen_helper_adduh_ob (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_ADDUH_R_OB : +check_dspr2 (ctx); +gen_helper_adduh_r_ob (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; + } +break ; +case OPC_CMPU_EQ_OB_DSP : +switch (op2) { +case OPC_PRECR_OB_QH : +check_dspr2 (ctx); +gen_helper_precr_ob_qh (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_PRECR_SRA_QH_PW : +check_dspr2 (ctx); + { +TCGv_i32 ret_t =tcg_const_i32 (ret); +gen_helper_precr_sra_qh_pw (cpu_gpr[v2], cpu_gpr[v1], + cpu_gpr[v2], ret_t); +tcg_temp_free_i32 (ret_t); +break ; + } +case OPC_PRECR_SRA_R_QH_PW : +check_dspr2 (ctx); + { +TCGv_i32 sa_v =tcg_const_i32 (ret); +gen_helper_precr_sra_r_qh_pw (cpu_gpr[v2], cpu_gpr[v1], + cpu_gpr[v2], sa_v); +tcg_temp_free_i32 (sa_v); +break ; + } +case OPC_PRECRQ_OB_QH : +check_dsp (ctx); +gen_helper_precrq_ob_qh (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_PRECRQ_PW_L : +check_dsp (ctx); +gen_helper_precrq_pw_l (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_PRECRQ_QH_PW : +check_dsp (ctx); +gen_helper_precrq_qh_pw (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_PRECRQ_RS_QH_PW :
target-mips/translate.c static void gen_mipsdsp_ld(CPUMIPSState *env, DisasContext *ctx, uint32_t opc, · line 12912
Quoted 10 lines
target-mips/translate.c +10
-0+check_dsp (ctx); +gen_helper_precrq_rs_qh_pw (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_PRECRQU_S_OB_QH : +check_dsp (ctx); +gen_helper_precrqu_s_ob_qh (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; + }
All these functions should check for v1 and v2 being 0.
Quoted 225 lines
target-mips/translate.c +193
-3+break ; +#endif + } + + (void )opn;/* avoid a compiler warning */ +MIPS_DEBUG ("%s" , opn); +}/* End MIPSDSP functions. */ @@ -12629,10 +13270,37 @@ 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: -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 )) { + op2 =MASK_ADDUH_QB (ctx->opcode); +switch (op2) { +case OPC_ADDUH_QB : +case OPC_ADDUH_R_QB : +case OPC_ADDQH_PH : +case OPC_ADDQH_R_PH : +case OPC_ADDQH_W : +case OPC_ADDQH_R_W : +case OPC_SUBUH_QB : +case OPC_SUBUH_R_QB : +case OPC_SUBQH_PH : +case OPC_SUBQH_R_PH : +case OPC_SUBQH_W : +case OPC_SUBQH_R_W : +gen_mipsdsp_arith (ctx, op1, op2, rd, rs, rt); +break ; +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 ); + }break ;case OPC_LX_DSP :check_dsp (ctx);@@ -12652,6 +13320,80 @@ 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 : +case OPC_ABSQ_S_PH : +case OPC_ABSQ_S_W : +case OPC_PRECEQ_W_PHL : +case OPC_PRECEQ_W_PHR : +case OPC_PRECEQU_PH_QBL : +case OPC_PRECEQU_PH_QBR : +case OPC_PRECEQU_PH_QBLA : +case OPC_PRECEQU_PH_QBRA : +case OPC_PRECEU_PH_QBL : +case OPC_PRECEU_PH_QBR : +case OPC_PRECEU_PH_QBLA : +case OPC_PRECEU_PH_QBRA : +gen_mipsdsp_arith (ctx, op1, op2, rd, rs, rt); +break ; +default : +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 : +case OPC_ADDQ_S_PH : +case OPC_ADDQ_S_W : +case OPC_ADDU_QB : +case OPC_ADDU_S_QB : +case OPC_ADDU_PH : +case OPC_ADDU_S_PH : +case OPC_SUBQ_PH : +case OPC_SUBQ_S_PH : +case OPC_SUBQ_S_W : +case OPC_SUBU_QB : +case OPC_SUBU_S_QB : +case OPC_SUBU_PH : +case OPC_SUBU_S_PH : +case OPC_ADDSC : +case OPC_ADDWC : +case OPC_MODSUB : +case OPC_RADDU_W_QB : +gen_mipsdsp_arith (ctx, op1, op2, rd, rs, rt); +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_SRA_PH_W : +case OPC_PRECR_SRA_R_PH_W : +gen_mipsdsp_arith (ctx, op1, op2, rt, rs, rd); +break ; +case OPC_PRECR_QB_PH : +case OPC_PRECRQ_QB_PH : +case OPC_PRECRQ_PH_W : +case OPC_PRECRQ_RS_PH_W : +case OPC_PRECRQU_S_QB_PH : +gen_mipsdsp_arith (ctx, op1, op2, rd, rs, 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:@@ -12671,6 +13413,88 @@ 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_ABSQ_S_QH_DSP : + op2 =MASK_ABSQ_S_QH (ctx->opcode); +switch (op2) { +case OPC_PRECEQ_L_PWL : +case OPC_PRECEQ_L_PWR : +case OPC_PRECEQ_PW_QHL : +case OPC_PRECEQ_PW_QHR : +case OPC_PRECEQ_PW_QHLA : +case OPC_PRECEQ_PW_QHRA : +case OPC_PRECEQU_QH_OBL : +case OPC_PRECEQU_QH_OBR : +case OPC_PRECEQU_QH_OBLA : +case OPC_PRECEQU_QH_OBRA : +case OPC_PRECEU_QH_OBL : +case OPC_PRECEU_QH_OBR : +case OPC_PRECEU_QH_OBLA : +case OPC_PRECEU_QH_OBRA : +case OPC_ABSQ_S_OB : +case OPC_ABSQ_S_PW : +case OPC_ABSQ_S_QH : +gen_mipsdsp_arith (ctx, op1, op2, rd, rs, rt); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK ABSQ_S.QH" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ; +case OPC_ADDU_OB_DSP : + op2 =MASK_ADDU_OB (ctx->opcode); +switch (op2) { +case OPC_RADDU_L_OB : +case OPC_SUBQ_PW : +case OPC_SUBQ_S_PW : +case OPC_SUBQ_QH : +case OPC_SUBQ_S_QH : +case OPC_SUBU_OB : +case OPC_SUBU_S_OB : +case OPC_SUBU_QH : +case OPC_SUBU_S_QH : +case OPC_SUBUH_OB : +case OPC_SUBUH_R_OB : +case OPC_ADDQ_PW : +case OPC_ADDQ_S_PW : +case OPC_ADDQ_QH : +case OPC_ADDQ_S_QH : +case OPC_ADDU_OB : +case OPC_ADDU_S_OB : +case OPC_ADDU_QH : +case OPC_ADDU_S_QH : +case OPC_ADDUH_OB : +case OPC_ADDUH_R_OB : +gen_mipsdsp_arith (ctx, op1, op2, rd, rs, rt); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK ADDU.OB" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ; +case OPC_CMPU_EQ_OB_DSP : + op2 =MASK_CMPU_EQ_OB (ctx->opcode); +switch (op2) { +case OPC_PRECR_SRA_QH_PW : +case OPC_PRECR_SRA_R_QH_PW : +/* Return value is rt. */ +gen_mipsdsp_arith (ctx, op1, op2, rt, rs, rd); +break ; +case OPC_PRECR_OB_QH : +case OPC_PRECRQ_OB_QH : +case OPC_PRECRQ_PW_L : +case OPC_PRECRQ_QH_PW : +case OPC_PRECRQ_RS_QH_PW : +case OPC_PRECRQU_S_OB_QH : +gen_mipsdsp_arith (ctx, op1, op2, rd, rs, rt); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK CMPU_EQ.OB" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ;#endif default :/* Invalid */ MIPS_INVAL ("special3" );Signature · 1 line
1.7.10.2 (Apple Git-33)
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v9 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 | 256 +++++++++++++++++++++++++++++++++++ target-mips/helper.h | 38 ++++++ target-mips/translate.c | 332 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 626 insertions(+)
target-mips/dsp_helper.c +256 -0
@@ -1992,6 +1992,262 @@ PRECEU_QH(obra, 48, 32, 16, 0);#endif +/** DSP GPR-Based Shift Sub-class insns **/ +#define SHIFT_QB (name, func) \ +target_ulong helper_##name##_qb(target_ulong sa, target_ulong rt) \ +{ \ + uint8_t rt3, rt2, rt1, rt0; \ + \ + sa = sa & 0x07; \ + \ + MIPSDSP_SPLIT32_8(rt, rt3, rt2, rt1, rt0); \ + \ + rt3 = mipsdsp_##func(rt3, sa); \ + rt2 = mipsdsp_##func(rt2, sa); \ + rt1 = mipsdsp_##func(rt1, sa); \ + rt0 = mipsdsp_##func(rt0, sa); \ + \ + return MIPSDSP_RETURN32_8(rt3, rt2, rt1, rt0); \ +} + +#define SHIFT_QB_ENV (name, func) \ +target_ulong helper_##name##_qb(target_ulong sa, target_ulong rt,\ + CPUMIPSState *env) \ +{ \ + uint8_t rt3, rt2, rt1, rt0; \ + \ + sa = sa & 0x07; \ + \ + MIPSDSP_SPLIT32_8(rt, rt3, rt2, rt1, rt0); \ + \ + rt3 = mipsdsp_##func(rt3, sa, env); \ + rt2 = mipsdsp_##func(rt2, sa, env); \ + rt1 = mipsdsp_##func(rt1, sa, env); \ + rt0 = mipsdsp_##func(rt0, sa, env); \ + \ + return MIPSDSP_RETURN32_8(rt3, rt2, rt1, rt0); \ +} + +SHIFT_QB_ENV (shll, lshift8); +SHIFT_QB (shrl, rshift_u8); + +SHIFT_QB (shra, rashift8); +SHIFT_QB (shra_r, rnd8_rashift); + +#undef SHIFT_QB +#undef SHIFT_QB_ENV + +#if defined(TARGET_MIPS64 ) +#define SHIFT_OB (name, func) \ +target_ulong helper_##name##_ob(target_ulong rt, target_ulong sa) \ +{ \ + int i; \ + uint8_t rt_t[8]; \ + uint64_t temp; \ + \ + sa = sa & 0x07; \ + temp = 0; \ + \ + for (i = 0; i < 8; i++) { \ + rt_t[i] = (rt >> (8 * i)) & MIPSDSP_Q0; \ + rt_t[i] = mipsdsp_##func(rt_t[i], sa); \ + temp |= (uint64_t)rt_t[i] << (8 * i); \ + } \ + \ + return temp; \ +} + +#define SHIFT_OB_ENV (name, func) \ +target_ulong helper_##name##_ob(target_ulong rt, target_ulong sa, \ + CPUMIPSState *env) \ +{ \ + int i; \ + uint8_t rt_t[8]; \ + uint64_t temp; \ + \ + sa = sa & 0x07; \ + temp = 0; \ + \ + for (i = 0; i < 8; i++) { \ + rt_t[i] = (rt >> (8 * i)) & MIPSDSP_Q0; \ + rt_t[i] = mipsdsp_##func(rt_t[i], sa, env); \ + temp |= (uint64_t)rt_t[i] << (8 * i); \ + } \ + \ + return temp; \ +} + +SHIFT_OB_ENV (shll, lshift8); +SHIFT_OB (shrl, rshift_u8); + +SHIFT_OB (shra, rashift8); +SHIFT_OB (shra_r, rnd8_rashift); + +#undef SHIFT_OB +#undef SHIFT_OB_ENV + +#endif + +#define SHIFT_PH (name, func) \ +target_ulong helper_##name##_ph(target_ulong sa, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint16_t rth, rtl; \ + \ + sa = sa & 0x0F; \ + \ + MIPSDSP_SPLIT32_16(rt, rth, rtl); \ + \ + rth = mipsdsp_##func(rth, sa, env); \ + rtl = mipsdsp_##func(rtl, sa, env); \ + \ + return MIPSDSP_RETURN32_16(rth, rtl); \ +} + +SHIFT_PH (shll, lshift16); +SHIFT_PH (shll_s, sat16_lshift); + +#undef SHIFT_PH + +#if defined(TARGET_MIPS64 ) +#define SHIFT_QH (name, func) \ +target_ulong helper_##name##_qh(target_ulong rt, target_ulong sa) \ +{ \ + uint16_t rt3, rt2, rt1, rt0; \ + \ + sa = sa & 0x0F; \ + \ + MIPSDSP_SPLIT64_16(rt, rt3, rt2, rt1, rt0); \ + \ + rt3 = mipsdsp_##func(rt3, sa); \ + rt2 = mipsdsp_##func(rt2, sa); \ + rt1 = mipsdsp_##func(rt1, sa); \ + rt0 = mipsdsp_##func(rt0, sa); \ + \ + return MIPSDSP_RETURN64_16(rt3, rt2, rt1, rt0); \ +} + +#define SHIFT_QH_ENV (name, func) \ +target_ulong helper_##name##_qh(target_ulong rt, target_ulong sa, \ + CPUMIPSState *env) \ +{ \ + uint16_t rt3, rt2, rt1, rt0; \ + \ + sa = sa & 0x0F; \ + \ + MIPSDSP_SPLIT64_16(rt, rt3, rt2, rt1, rt0); \ + \ + rt3 = mipsdsp_##func(rt3, sa, env); \ + rt2 = mipsdsp_##func(rt2, sa, env); \ + rt1 = mipsdsp_##func(rt1, sa, env); \ + rt0 = mipsdsp_##func(rt0, sa, env); \ + \ + return MIPSDSP_RETURN64_16(rt3, rt2, rt1, rt0); \ +} + +SHIFT_QH_ENV (shll, lshift16); +SHIFT_QH_ENV (shll_s, sat16_lshift); + +SHIFT_QH (shrl, rshift_u16); +SHIFT_QH (shra, rashift16); +SHIFT_QH (shra_r, rnd16_rashift); + +#undef SHIFT_QH +#undef SHIFT_QH_ENV + +#endif + +#define SHIFT_W (name, func) \ +target_ulong helper_##name##_w(target_ulong sa, target_ulong rt) \ +{ \ + uint32_t temp; \ + \ + sa = sa & 0x1F; \ + temp = mipsdsp_##func(rt, sa); \ + \ + return (target_long)(int32_t)temp; \ +} + +#define SHIFT_W_ENV (name, func) \ +target_ulong helper_##name##_w(target_ulong sa, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint32_t temp; \ + \ + sa = sa & 0x1F; \ + temp = mipsdsp_##func(rt, sa, env); \ + \ + return (target_long)(int32_t)temp; \ +} + +SHIFT_W_ENV (shll_s, sat32_lshift); +SHIFT_W (shra_r, rnd32_rashift); + +#undef SHIFT_W +#undef SHIFT_W_ENV + +#if defined(TARGET_MIPS64 ) +#define SHIFT_PW (name, func) \ +target_ulong helper_##name##_pw(target_ulong rt, target_ulong sa) \ +{ \ + uint32_t rt1, rt0; \ + \ + sa = sa & 0x1F; \ + MIPSDSP_SPLIT64_32(rt, rt1, rt0); \ + \ + rt1 = mipsdsp_##func(rt1, sa); \ + rt0 = mipsdsp_##func(rt0, sa); \ + \ + return MIPSDSP_RETURN64_32(rt1, rt0); \ +} + +#define SHIFT_PW_ENV (name, func) \ +target_ulong helper_##name##_pw(target_ulong rt, target_ulong sa, \ + CPUMIPSState *env) \ +{ \ + uint32_t rt1, rt0; \ + \ + sa = sa & 0x1F; \ + MIPSDSP_SPLIT64_32(rt, rt1, rt0); \ + \ + rt1 = mipsdsp_##func(rt1, sa, env); \ + rt0 = mipsdsp_##func(rt0, sa, env); \ + \ + return MIPSDSP_RETURN64_32(rt1, rt0); \ +} + +SHIFT_PW_ENV (shll, lshift32); +SHIFT_PW_ENV (shll_s, sat32_lshift); + +SHIFT_PW (shra, rashift32); +SHIFT_PW (shra_r, rnd32_rashift); + +#undef SHIFT_PW +#undef SHIFT_PW_ENV + +#endif + +#define SHIFT_PH (name, func) \ +target_ulong helper_##name##_ph(target_ulong sa, target_ulong rt) \ +{ \ + uint16_t rth, rtl; \ + \ + sa = sa & 0x0F; \ + \ + MIPSDSP_SPLIT32_16(rt, rth, rtl); \ + \ + rth = mipsdsp_##func(rth, sa); \ + rtl = mipsdsp_##func(rtl, sa); \ + \ + return MIPSDSP_RETURN32_16(rth, rtl); \ +} + +SHIFT_PH (shrl, rshift_u16); +SHIFT_PH (shra, rashift16); +SHIFT_PH (shra_r, rnd16_rashift); + +#undef SHIFT_PH +#undef MIPSDSP_LHI#undef MIPSDSP_LLO#undef MIPSDSP_HI
target-mips/helper.h +38 -0
@@ -488,4 +488,42 @@ 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, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(shll_ob, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(shll_ph, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(shll_s_ph, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(shll_qh, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(shll_s_qh, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(shll_s_w, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(shll_pw, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(shll_s_pw, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_2(shrl_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(shrl_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, tl) +DEF_HELPER_FLAGS_2(shrl_qh, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +#endif +DEF_HELPER_FLAGS_2(shra_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(shra_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, tl) +DEF_HELPER_FLAGS_2(shra_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, tl, tl) +DEF_HELPER_FLAGS_2(shra_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, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_2(shra_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, tl) +DEF_HELPER_FLAGS_2(shra_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, tl) +#endif +#include "def-helper.h"
target-mips/translate.c +332 -0
368 lines not on this page · raw message
Signature · 1 line
1.7.10.2 (Apple Git-33)
Re: [Qemu-devel] [PATCH v9 07/14] target-mips-ase-dsp: Add GPR-based shift instructions
Quoted 658 lines · Jia Liu
Add MIPS ASE DSP GPR-Based Shift instructions.
Signed-off-by Jia Liu <[email protected]>--- target-mips/dsp_helper.c | 256 +++++++++++++++++++++++++++++++++++ target-mips/helper.h | 38 ++++++ target-mips/translate.c | 332 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 626 insertions(+)target-mips/dsp_helper.c +256
-0@@ -1992,6 +1992,262 @@ PRECEU_QH(obra, 48, 32, 16, 0);#endif +/** DSP GPR-Based Shift Sub-class insns **/ +#define SHIFT_QB (name, func) \ +target_ulong helper_##name##_qb(target_ulong sa, target_ulong rt) \ +{ \ + uint8_t rt3, rt2, rt1, rt0; \ + \ + sa = sa & 0x07; \ + \ + MIPSDSP_SPLIT32_8(rt, rt3, rt2, rt1, rt0); \ + \ + rt3 = mipsdsp_##func(rt3, sa); \ + rt2 = mipsdsp_##func(rt2, sa); \ + rt1 = mipsdsp_##func(rt1, sa); \ + rt0 = mipsdsp_##func(rt0, sa); \ + \ + return MIPSDSP_RETURN32_8(rt3, rt2, rt1, rt0); \ +} + +#define SHIFT_QB_ENV (name, func) \ +target_ulong helper_##name##_qb(target_ulong sa, target_ulong rt,\ + CPUMIPSState *env) \ +{ \ + uint8_t rt3, rt2, rt1, rt0; \ + \ + sa = sa & 0x07; \ + \ + MIPSDSP_SPLIT32_8(rt, rt3, rt2, rt1, rt0); \ + \ + rt3 = mipsdsp_##func(rt3, sa, env); \ + rt2 = mipsdsp_##func(rt2, sa, env); \ + rt1 = mipsdsp_##func(rt1, sa, env); \ + rt0 = mipsdsp_##func(rt0, sa, env); \ + \ + return MIPSDSP_RETURN32_8(rt3, rt2, rt1, rt0); \ +} + +SHIFT_QB_ENV (shll, lshift8); +SHIFT_QB (shrl, rshift_u8); + +SHIFT_QB (shra, rashift8); +SHIFT_QB (shra_r, rnd8_rashift); + +#undef SHIFT_QB +#undef SHIFT_QB_ENV + +#if defined(TARGET_MIPS64 ) +#define SHIFT_OB (name, func) \ +target_ulong helper_##name##_ob(target_ulong rt, target_ulong sa) \ +{ \ + int i; \ + uint8_t rt_t[8]; \ + uint64_t temp; \ + \ + sa = sa & 0x07; \ + temp = 0; \ + \ + for (i = 0; i < 8; i++) { \ + rt_t[i] = (rt >> (8 * i)) & MIPSDSP_Q0; \ + rt_t[i] = mipsdsp_##func(rt_t[i], sa); \ + temp |= (uint64_t)rt_t[i] << (8 * i); \ + } \ + \ + return temp; \ +} + +#define SHIFT_OB_ENV (name, func) \ +target_ulong helper_##name##_ob(target_ulong rt, target_ulong sa, \ + CPUMIPSState *env) \ +{ \ + int i; \ + uint8_t rt_t[8]; \ + uint64_t temp; \ + \ + sa = sa & 0x07; \ + temp = 0; \ + \ + for (i = 0; i < 8; i++) { \ + rt_t[i] = (rt >> (8 * i)) & MIPSDSP_Q0; \ + rt_t[i] = mipsdsp_##func(rt_t[i], sa, env); \ + temp |= (uint64_t)rt_t[i] << (8 * i); \ + } \ + \ + return temp; \ +} + +SHIFT_OB_ENV (shll, lshift8); +SHIFT_OB (shrl, rshift_u8); + +SHIFT_OB (shra, rashift8); +SHIFT_OB (shra_r, rnd8_rashift); + +#undef SHIFT_OB +#undef SHIFT_OB_ENV + +#endif + +#define SHIFT_PH (name, func) \ +target_ulong helper_##name##_ph(target_ulong sa, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint16_t rth, rtl; \ + \ + sa = sa & 0x0F; \ + \ + MIPSDSP_SPLIT32_16(rt, rth, rtl); \ + \ + rth = mipsdsp_##func(rth, sa, env); \ + rtl = mipsdsp_##func(rtl, sa, env); \ + \ + return MIPSDSP_RETURN32_16(rth, rtl); \ +} + +SHIFT_PH (shll, lshift16); +SHIFT_PH (shll_s, sat16_lshift); + +#undef SHIFT_PH + +#if defined(TARGET_MIPS64 ) +#define SHIFT_QH (name, func) \ +target_ulong helper_##name##_qh(target_ulong rt, target_ulong sa) \ +{ \ + uint16_t rt3, rt2, rt1, rt0; \ + \ + sa = sa & 0x0F; \ + \ + MIPSDSP_SPLIT64_16(rt, rt3, rt2, rt1, rt0); \ + \ + rt3 = mipsdsp_##func(rt3, sa); \ + rt2 = mipsdsp_##func(rt2, sa); \ + rt1 = mipsdsp_##func(rt1, sa); \ + rt0 = mipsdsp_##func(rt0, sa); \ + \ + return MIPSDSP_RETURN64_16(rt3, rt2, rt1, rt0); \ +} + +#define SHIFT_QH_ENV (name, func) \ +target_ulong helper_##name##_qh(target_ulong rt, target_ulong sa, \ + CPUMIPSState *env) \ +{ \ + uint16_t rt3, rt2, rt1, rt0; \ + \ + sa = sa & 0x0F; \ + \ + MIPSDSP_SPLIT64_16(rt, rt3, rt2, rt1, rt0); \ + \ + rt3 = mipsdsp_##func(rt3, sa, env); \ + rt2 = mipsdsp_##func(rt2, sa, env); \ + rt1 = mipsdsp_##func(rt1, sa, env); \ + rt0 = mipsdsp_##func(rt0, sa, env); \ + \ + return MIPSDSP_RETURN64_16(rt3, rt2, rt1, rt0); \ +} + +SHIFT_QH_ENV (shll, lshift16); +SHIFT_QH_ENV (shll_s, sat16_lshift); + +SHIFT_QH (shrl, rshift_u16); +SHIFT_QH (shra, rashift16); +SHIFT_QH (shra_r, rnd16_rashift); + +#undef SHIFT_QH +#undef SHIFT_QH_ENV + +#endif + +#define SHIFT_W (name, func) \ +target_ulong helper_##name##_w(target_ulong sa, target_ulong rt) \ +{ \ + uint32_t temp; \ + \ + sa = sa & 0x1F; \ + temp = mipsdsp_##func(rt, sa); \ + \ + return (target_long)(int32_t)temp; \ +} + +#define SHIFT_W_ENV (name, func) \ +target_ulong helper_##name##_w(target_ulong sa, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint32_t temp; \ + \ + sa = sa & 0x1F; \ + temp = mipsdsp_##func(rt, sa, env); \ + \ + return (target_long)(int32_t)temp; \ +} + +SHIFT_W_ENV (shll_s, sat32_lshift); +SHIFT_W (shra_r, rnd32_rashift); + +#undef SHIFT_W +#undef SHIFT_W_ENV + +#if defined(TARGET_MIPS64 ) +#define SHIFT_PW (name, func) \ +target_ulong helper_##name##_pw(target_ulong rt, target_ulong sa) \ +{ \ + uint32_t rt1, rt0; \ + \ + sa = sa & 0x1F; \ + MIPSDSP_SPLIT64_32(rt, rt1, rt0); \ + \ + rt1 = mipsdsp_##func(rt1, sa); \ + rt0 = mipsdsp_##func(rt0, sa); \ + \ + return MIPSDSP_RETURN64_32(rt1, rt0); \ +} + +#define SHIFT_PW_ENV (name, func) \ +target_ulong helper_##name##_pw(target_ulong rt, target_ulong sa, \ + CPUMIPSState *env) \ +{ \ + uint32_t rt1, rt0; \ + \ + sa = sa & 0x1F; \ + MIPSDSP_SPLIT64_32(rt, rt1, rt0); \ + \ + rt1 = mipsdsp_##func(rt1, sa, env); \ + rt0 = mipsdsp_##func(rt0, sa, env); \ + \ + return MIPSDSP_RETURN64_32(rt1, rt0); \ +} + +SHIFT_PW_ENV (shll, lshift32); +SHIFT_PW_ENV (shll_s, sat32_lshift); + +SHIFT_PW (shra, rashift32); +SHIFT_PW (shra_r, rnd32_rashift); + +#undef SHIFT_PW +#undef SHIFT_PW_ENV + +#endif + +#define SHIFT_PH (name, func) \ +target_ulong helper_##name##_ph(target_ulong sa, target_ulong rt) \ +{ \ + uint16_t rth, rtl; \ + \ + sa = sa & 0x0F; \ + \ + MIPSDSP_SPLIT32_16(rt, rth, rtl); \ + \ + rth = mipsdsp_##func(rth, sa); \ + rtl = mipsdsp_##func(rtl, sa); \ + \ + return MIPSDSP_RETURN32_16(rth, rtl); \ +} + +SHIFT_PH (shrl, rshift_u16); +SHIFT_PH (shra, rashift16); +SHIFT_PH (shra_r, rnd16_rashift); + +#undef SHIFT_PH +#undef MIPSDSP_LHI#undef MIPSDSP_LLO#undef MIPSDSP_HItarget-mips/helper.h +38
-0@@ -488,4 +488,42 @@ 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, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(shll_ob, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(shll_ph, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(shll_s_ph, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(shll_qh, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(shll_s_qh, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(shll_s_w, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(shll_pw, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(shll_s_pw, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_2(shrl_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(shrl_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, tl) +DEF_HELPER_FLAGS_2(shrl_qh, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +#endif +DEF_HELPER_FLAGS_2(shra_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(shra_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, tl) +DEF_HELPER_FLAGS_2(shra_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, tl, tl) +DEF_HELPER_FLAGS_2(shra_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, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_2(shra_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, tl) +DEF_HELPER_FLAGS_2(shra_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, tl) +#endif +#include "def-helper.h" target-mips/translate.c +306
-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))@@ -12918,6 +12989,261 @@ static void gen_mipsdsp_arith(DisasContext *ctx, uint32_t op1, uint32_t op2,MIPS_DEBUG ("%s" , opn); } +static void gen_mipsdsp_shift (DisasContext *ctx,uint32_t opc, +int ret,int v1,int v2) +{ +uint32_t op2; +const char *opn ="mipsdsp shift" ; +TCGv t0 =tcg_const_tl (v1); + +if (ret ==0 ) { +/* Treat as NOP. */ +MIPS_DEBUG ("NOP" ); +return ; + } + +switch (opc) { +case OPC_SHLL_QB_DSP : + { + op2 =MASK_SHLL_QB (ctx->opcode); +switch (op2) { +case OPC_SHLL_QB : +check_dsp (ctx); +gen_helper_shll_qb (cpu_gpr[ret], t0, + cpu_gpr[v2], cpu_env); +break ; +case OPC_SHLLV_QB : +check_dsp (ctx); +gen_helper_shll_qb (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SHLL_PH : +check_dsp (ctx); +gen_helper_shll_ph (cpu_gpr[ret], t0, + cpu_gpr[v2], cpu_env); +break ; +case OPC_SHLLV_PH : +check_dsp (ctx); +gen_helper_shll_ph (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SHLL_S_PH : +check_dsp (ctx); +gen_helper_shll_s_ph (cpu_gpr[ret], t0, + cpu_gpr[v2], cpu_env); +break ; +case OPC_SHLLV_S_PH : +check_dsp (ctx); +gen_helper_shll_s_ph (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SHLL_S_W : +check_dsp (ctx); +gen_helper_shll_s_w (cpu_gpr[ret], t0, + cpu_gpr[v2], cpu_env); +break ; +case OPC_SHLLV_S_W : +check_dsp (ctx); +gen_helper_shll_s_w (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_SHRL_QB : +check_dsp (ctx); +gen_helper_shrl_qb (cpu_gpr[ret], t0, cpu_gpr[v2]); +break ; +case OPC_SHRLV_QB : +check_dsp (ctx); +gen_helper_shrl_qb (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_SHRL_PH : +check_dspr2 (ctx); +gen_helper_shrl_ph (cpu_gpr[ret], t0, cpu_gpr[v2]); +break ; +case OPC_SHRLV_PH : +check_dspr2 (ctx); +gen_helper_shrl_ph (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_SHRA_QB : +check_dspr2 (ctx); +gen_helper_shra_qb (cpu_gpr[ret], t0, cpu_gpr[v2]); +break ; +case OPC_SHRA_R_QB : +check_dspr2 (ctx); +gen_helper_shra_r_qb (cpu_gpr[ret], t0, cpu_gpr[v2]); +break ; +case OPC_SHRAV_QB : +check_dspr2 (ctx); +gen_helper_shra_qb (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_SHRAV_R_QB : +check_dspr2 (ctx); +gen_helper_shra_r_qb (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2]); +break ; +case OPC_SHRA_PH : +check_dsp (ctx); +gen_helper_shra_ph (cpu_gpr[ret], t0, cpu_gpr[v2]); +break ; +case OPC_SHRA_R_PH : +check_dsp (ctx); +gen_helper_shra_r_ph (cpu_gpr[ret], t0, cpu_gpr[v2]); +break ; +case OPC_SHRAV_PH : +check_dsp (ctx); +gen_helper_shra_ph (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_SHRAV_R_PH : +check_dsp (ctx); +gen_helper_shra_r_ph (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2]); +break ; +case OPC_SHRA_R_W : +check_dsp (ctx); +gen_helper_shra_r_w (cpu_gpr[ret], t0, cpu_gpr[v2]); +break ; +case OPC_SHRAV_R_W : +check_dsp (ctx); +gen_helper_shra_r_w (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK SHLL.QB" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ; + } +#ifdef TARGET_MIPS64 +case OPC_SHLL_OB_DSP : + op2 =MASK_SHLL_OB (ctx->opcode); +switch (op2) { +case OPC_SHLL_PW : +check_dsp (ctx); +gen_helper_shll_pw (cpu_gpr[ret], cpu_gpr[v2], + t0, cpu_env); +break ; +case OPC_SHLLV_PW : +check_dsp (ctx); +gen_helper_shll_pw (cpu_gpr[ret], cpu_gpr[v2], + cpu_gpr[v1], cpu_env); +break ; +case OPC_SHLL_S_PW : +check_dsp (ctx); +gen_helper_shll_s_pw (cpu_gpr[ret], cpu_gpr[v2], + t0, cpu_env); +break ; +case OPC_SHLLV_S_PW : +check_dsp (ctx); +gen_helper_shll_s_pw (cpu_gpr[ret], cpu_gpr[v2], + cpu_gpr[v1], cpu_env); +break ; +case OPC_SHLL_OB : +check_dsp (ctx); +gen_helper_shll_ob (cpu_gpr[ret], cpu_gpr[v2], + t0, cpu_env); +break ; +case OPC_SHLLV_OB : +check_dsp (ctx); +gen_helper_shll_ob (cpu_gpr[ret], cpu_gpr[v2], + cpu_gpr[v1], cpu_env); +break ; +case OPC_SHLL_QH : +check_dsp (ctx); +gen_helper_shll_qh (cpu_gpr[ret], cpu_gpr[v2], + t0, cpu_env); +break ; +case OPC_SHLLV_QH : +check_dsp (ctx); +gen_helper_shll_qh (cpu_gpr[ret], cpu_gpr[v2], + cpu_gpr[v1], cpu_env); +break ; +case OPC_SHLL_S_QH : +check_dsp (ctx); +gen_helper_shll_s_qh (cpu_gpr[ret], cpu_gpr[v2], + t0, cpu_env); +break ; +case OPC_SHLLV_S_QH : +check_dsp (ctx); +gen_helper_shll_s_qh (cpu_gpr[ret], cpu_gpr[v2], + cpu_gpr[v1], cpu_env); +break ; +case OPC_SHRA_OB : +check_dspr2 (ctx); +gen_helper_shra_ob (cpu_gpr[ret], cpu_gpr[v2], t0); +break ; +case OPC_SHRAV_OB : +check_dspr2 (ctx); +gen_helper_shra_ob (cpu_gpr[ret], cpu_gpr[v2], cpu_gpr[v1]); +break ; +case OPC_SHRA_R_OB : +check_dspr2 (ctx); +gen_helper_shra_r_ob (cpu_gpr[ret], cpu_gpr[v2], t0); +break ; +case OPC_SHRAV_R_OB : +check_dspr2 (ctx); +gen_helper_shra_r_ob (cpu_gpr[ret], cpu_gpr[v2], cpu_gpr[v1]); +break ; +case OPC_SHRA_PW : +check_dsp (ctx); +gen_helper_shra_pw (cpu_gpr[ret], cpu_gpr[v2], t0); +break ; +case OPC_SHRAV_PW : +check_dsp (ctx); +gen_helper_shra_pw (cpu_gpr[ret], cpu_gpr[v2], cpu_gpr[v1]); +break ; +case OPC_SHRA_R_PW : +check_dsp (ctx); +gen_helper_shra_r_pw (cpu_gpr[ret], cpu_gpr[v2], t0); +break ; +case OPC_SHRAV_R_PW : +check_dsp (ctx); +gen_helper_shra_r_pw (cpu_gpr[ret], cpu_gpr[v2], cpu_gpr[v1]); +break ; +case OPC_SHRA_QH : +check_dsp (ctx); +gen_helper_shra_qh (cpu_gpr[ret], cpu_gpr[v2], t0); +break ; +case OPC_SHRAV_QH : +check_dsp (ctx); +gen_helper_shra_qh (cpu_gpr[ret], cpu_gpr[v2], cpu_gpr[v1]); +break ; +case OPC_SHRA_R_QH : +check_dsp (ctx); +gen_helper_shra_r_qh (cpu_gpr[ret], cpu_gpr[v2], t0); +break ; +case OPC_SHRAV_R_QH : +check_dsp (ctx); +gen_helper_shra_r_qh (cpu_gpr[ret], cpu_gpr[v2], cpu_gpr[v1]); +break ; +case OPC_SHRL_OB : +check_dsp (ctx); +gen_helper_shrl_ob (cpu_gpr[ret], cpu_gpr[v2], t0); +break ; +case OPC_SHRLV_OB : +check_dsp (ctx); +gen_helper_shrl_ob (cpu_gpr[ret], cpu_gpr[v2], cpu_gpr[v1]); +break ; +case OPC_SHRL_QH : +check_dspr2 (ctx);
target-mips/translate.c static void gen_mipsdsp_arith(DisasContext *ctx, uint32_t op1, uint32_t op2, · line 13236
Quoted 10 lines
target-mips/translate.c +10
-0+gen_helper_shrl_qh (cpu_gpr[ret], cpu_gpr[v2], t0); +break ; +case OPC_SHRLV_QH : +check_dspr2 (ctx); +gen_helper_shrl_qh (cpu_gpr[ret], cpu_gpr[v2], cpu_gpr[v1]); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK SHLL.OB" ); +generate_exception (ctx,EXCP_RI ); +break ;
All these functions should check for v1 and v2 being 0.
Quoted 37 lines
target-mips/translate.c +16
-0+ } +break ; +#endif + } + +tcg_temp_free (t0); + (void )opn;/* avoid a compiler warning */ +MIPS_DEBUG ("%s" , opn); +} +/* End MIPSDSP functions. */ static void decode_opc (CPUMIPSState *env,DisasContext *ctx,int *is_branch)@@ -13394,6 +13720,9 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)break ; }break ; +case OPC_SHLL_QB_DSP : +gen_mipsdsp_shift (ctx, op1, rd, rs, rt); +break ;#if defined(TARGET_MIPS64 ) case OPC_DEXTM ... OPC_DEXT: case OPC_DINSM ... OPC_DINS:@@ -13495,6 +13824,9 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) break; }break ; +case OPC_SHLL_OB_DSP : +gen_mipsdsp_shift (ctx, op1, rd, rs, rt); +break ;#endif default :/* Invalid */ MIPS_INVAL ("special3" );Signature · 1 line
1.7.10.2 (Apple Git-33)
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v9 8/14 target-mips-ase-dsp: Add multiply instructions
In reply to Jia LiuAdd MIPS ASE DSP Multiply instructions.
--- target-mips/dsp_helper.c | 938 ++++++++++++++++++++++++++++++++++++++++++++++ target-mips/helper.h | 91 +++++ target-mips/translate.c | 531 ++++++++++++++++++++++++++ 3 files changed, 1560 insertions(+)
target-mips/dsp_helper.c +938 -0
@@ -2248,6 +2248,944 @@ SHIFT_PH(shra_r, rnd16_rashift);#undef SHIFT_PH +/** DSP Multiply Sub-class insns **/ +/* Return value made up by two 16bits value. +* FIXME give the macro a better name. +*/ +#define MUL_RETURN32_16_PH (name, func, \ + rsmov1, rsmov2, rsfilter, \ + rtmov1, rtmov2, rtfilter) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint16_t rsB, rsA, rtB, rtA; \ + \ + rsB = (rs >> rsmov1) & rsfilter; \ + rsA = (rs >> rsmov2) & rsfilter; \ + rtB = (rt >> rtmov1) & rtfilter; \ + rtA = (rt >> rtmov2) & rtfilter; \ + \ + rsB = mipsdsp_##func(rsB, rtB, env); \ + rsA = mipsdsp_##func(rsA, rtA, env); \ + \ + return MIPSDSP_RETURN32_16(rsB, rsA); \ +} + +MUL_RETURN32_16_PH (muleu_s_ph_qbl, mul_u8_u16, \ +24 ,16 ,MIPSDSP_Q0 , \ +16 ,0 ,MIPSDSP_LO ); +MUL_RETURN32_16_PH (muleu_s_ph_qbr, mul_u8_u16, \ +8 ,0 ,MIPSDSP_Q0 , \ +16 ,0 ,MIPSDSP_LO ); +MUL_RETURN32_16_PH (mulq_rs_ph, rndq15_mul_q15_q15, \ +16 ,0 ,MIPSDSP_LO , \ +16 ,0 ,MIPSDSP_LO ); +MUL_RETURN32_16_PH (mul_ph, mul_i16_i16, \ +16 ,0 ,MIPSDSP_LO , \ +16 ,0 ,MIPSDSP_LO ); +MUL_RETURN32_16_PH (mul_s_ph, sat16_mul_i16_i16, \ +16 ,0 ,MIPSDSP_LO , \ +16 ,0 ,MIPSDSP_LO ); +MUL_RETURN32_16_PH (mulq_s_ph, sat16_mul_q15_q15, \ +16 ,0 ,MIPSDSP_LO , \ +16 ,0 ,MIPSDSP_LO ); + +#undef MUL_RETURN32_16_PH + +#define MUL_RETURN32_32_ph (name, func, movbits) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int16_t rsh, rth; \ + int32_t temp; \ + \ + rsh = (rs >> movbits) & MIPSDSP_LO; \ + rth = (rt >> movbits) & MIPSDSP_LO; \ + temp = mipsdsp_##func(rsh, rth, env); \ + \ + return (target_long)(int32_t)temp; \ +} + +MUL_RETURN32_32_ph (muleq_s_w_phl, mul_q15_q15_overflowflag21,16 ); +MUL_RETURN32_32_ph (muleq_s_w_phr, mul_q15_q15_overflowflag21,0 ); + +#undef MUL_RETURN32_32_ph + +#define MUL_VOID_PH (name, use_ac_env) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int16_t rsh, rsl, rth, rtl; \ + int32_t tempB, tempA; \ + int64_t acc, dotp; \ + \ + MIPSDSP_SPLIT32_16(rs, rsh, rsl); \ + MIPSDSP_SPLIT32_16(rt, rth, rtl); \ + \ + if (use_ac_env == 1) { \ + tempB = mipsdsp_mul_q15_q15(ac, rsh, rth, env); \ + tempA = mipsdsp_mul_q15_q15(ac, rsl, rtl, env); \ + } else { \ + tempB = mipsdsp_mul_u16_u16(rsh, rth); \ + tempA = mipsdsp_mul_u16_u16(rsl, rtl); \ + } \ + \ + dotp = (int64_t)tempB - (int64_t)tempA; \ + 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); \ +} + +MUL_VOID_PH (mulsaq_s_w_ph,1 ); +MUL_VOID_PH (mulsa_w_ph,0 ); + +#undef MUL_VOID_PH + +#if defined(TARGET_MIPS64 ) +#define MUL_RETURN64_16_QH (name, func, \ + rsmov1, rsmov2, rsmov3, rsmov4, rsfilter, \ + rtmov1, rtmov2, rtmov3, rtmov4, rtfilter) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint16_t rs3, rs2, rs1, rs0; \ + uint16_t rt3, rt2, rt1, rt0; \ + uint16_t tempD, tempC, tempB, tempA; \ + \ + rs3 = (rs >> rsmov1) & rsfilter; \ + rs2 = (rs >> rsmov2) & rsfilter; \ + rs1 = (rs >> rsmov3) & rsfilter; \ + rs0 = (rs >> rsmov4) & rsfilter; \ + rt3 = (rt >> rtmov1) & rtfilter; \ + rt2 = (rt >> rtmov2) & rtfilter; \ + rt1 = (rt >> rtmov3) & rtfilter; \ + rt0 = (rt >> rtmov4) & rtfilter; \ + \ + tempD = mipsdsp_##func(rs3, rt3, env); \ + tempC = mipsdsp_##func(rs2, rt2, env); \ + tempB = mipsdsp_##func(rs1, rt1, env); \ + tempA = mipsdsp_##func(rs0, rt0, env); \ + \ + return MIPSDSP_RETURN64_16(tempD, tempC, tempB, tempA); \ +} + +MUL_RETURN64_16_QH (muleu_s_qh_obl, mul_u8_u16, \ +56 ,48 ,40 ,32 ,MIPSDSP_Q0 , \ +48 ,32 ,16 ,0 ,MIPSDSP_LO ); +MUL_RETURN64_16_QH (muleu_s_qh_obr, mul_u8_u16, \ +24 ,16 ,8 ,0 ,MIPSDSP_Q0 , \ +48 ,32 ,16 ,0 ,MIPSDSP_LO ); +MUL_RETURN64_16_QH (mulq_rs_qh, rndq15_mul_q15_q15, \ +48 ,32 ,16 ,0 ,MIPSDSP_LO , \ +48 ,32 ,16 ,0 ,MIPSDSP_LO ); + +#undef MUL_RETURN64_16_QH + +#define MUL_RETURN64_32_QH (name, \ + rsmov1, rsmov2, \ + rtmov1, rtmov2) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint16_t rsB, rsA; \ + uint16_t rtB, rtA; \ + uint32_t tempB, tempA; \ + \ + rsB = (rs >> rsmov1) & MIPSDSP_LO; \ + rsA = (rs >> rsmov2) & MIPSDSP_LO; \ + rtB = (rt >> rtmov1) & MIPSDSP_LO; \ + rtA = (rt >> rtmov2) & MIPSDSP_LO; \ + \ + tempB = mipsdsp_mul_q15_q15(5, rsB, rtB, env); \ + tempA = mipsdsp_mul_q15_q15(5, rsA, rtA, env); \ + \ + return ((uint64_t)tempB << 32) | (uint64_t)tempA; \ +} + +MUL_RETURN64_32_QH (muleq_s_pw_qhl,48 ,32 ,48 ,32 ); +MUL_RETURN64_32_QH (muleq_s_pw_qhr,16 ,0 ,16 ,0 ); + +#undef MUL_RETURN64_32_QH + +void helper_mulsaq_s_w_qh (target_ulong rs,target_ulong rt,uint32_t ac, +CPUMIPSState *env) +{ +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; + +MIPSDSP_SPLIT64_16 (rs, rs3, rs2, rs1, rs0); +MIPSDSP_SPLIT64_16 (rt, rt3, rt2, rt1, rt0); + + tempD =mipsdsp_mul_q15_q15 (ac, rs3, rt3, env); + tempC =mipsdsp_mul_q15_q15 (ac, rs2, rt2, env); + tempB =mipsdsp_mul_q15_q15 (ac, rs1, rt1, env); + tempA =mipsdsp_mul_q15_q15 (ac, rs0, rt0, env); + + 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 ] = ~0ull ; + } + + 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 + +#define DP_QB (name, func, is_add, rsmov1, rsmov2, rtmov1, rtmov2) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint8_t rs3, rs2; \ + uint8_t rt3, rt2; \ + uint16_t tempB, tempA; \ + uint64_t tempC, dotp; \ + \ + rs3 = (rs >> rsmov1) & MIPSDSP_Q0; \ + rs2 = (rs >> rsmov2) & MIPSDSP_Q0; \ + rt3 = (rt >> rtmov1) & MIPSDSP_Q0; \ + rt2 = (rt >> rtmov2) & MIPSDSP_Q0; \ + tempB = mipsdsp_##func(rs3, rt3); \ + tempA = mipsdsp_##func(rs2, rt2); \ + dotp = (int64_t)tempB + (int64_t)tempA; \ + if (is_add) { \ + tempC = (((uint64_t)env->active_tc.HI[ac] << 32) | \ + ((uint64_t)env->active_tc.LO[ac] & MIPSDSP_LLO)) \ + + dotp; \ + } else { \ + 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); \ +} + +DP_QB (dpau_h_qbl, mul_u8_u8,1 ,24 ,16 ,24 ,16 ); +DP_QB (dpau_h_qbr, mul_u8_u8,1 ,8 ,0 ,8 ,0 ); +DP_QB (dpsu_h_qbl, mul_u8_u8,0 ,24 ,16 ,24 ,16 ); +DP_QB (dpsu_h_qbr, mul_u8_u8,0 ,8 ,0 ,8 ,0 ); + +#undef DP_QB + +#if defined(TARGET_MIPS64 ) +#define DP_OB (name, add_sub, \ + rsmov1, rsmov2, rsmov3, rsmov4, \ + rtmov1, rtmov2, rtmov3, rtmov4) \ +void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \ + CPUMIPSState *env) \ +{ \ + uint8_t rsD, rsC, rsB, rsA; \ + uint8_t rtD, rtC, rtB, rtA; \ + uint16_t tempD, tempC, tempB, tempA; \ + uint64_t temp[2]; \ + uint64_t acc[2]; \ + uint64_t temp_sum; \ + \ + temp[0] = 0; \ + temp[1] = 0; \ + \ + rsD = (rs >> rsmov1) & MIPSDSP_Q0; \ + rsC = (rs >> rsmov2) & MIPSDSP_Q0; \ + rsB = (rs >> rsmov3) & MIPSDSP_Q0; \ + rsA = (rs >> rsmov4) & MIPSDSP_Q0; \ + rtD = (rt >> rtmov1) & MIPSDSP_Q0; \ + rtC = (rt >> rtmov2) & MIPSDSP_Q0; \ + rtB = (rt >> rtmov3) & MIPSDSP_Q0; \ + rtA = (rt >> rtmov4) & MIPSDSP_Q0; \ + \ + tempD = mipsdsp_mul_u8_u8(rsD, rtD); \ + tempC = mipsdsp_mul_u8_u8(rsC, rtC); \ + tempB = mipsdsp_mul_u8_u8(rsB, rtB); \ + tempA = mipsdsp_mul_u8_u8(rsA, rtA); \ + \ + 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]; \ + \ + if (add_sub) { \ + temp_sum = acc[0] + temp[0]; \ + acc[1] = acc[1] + MIPSDSP_OVERFLOW(acc[0], temp[0], temp_sum, \ + 0x8000000000000000ull); \ + temp[0] = temp_sum; \ + temp[1] = acc[1] + temp[1]; \ + } else { \ + temp_sum = acc[0] - temp[0]; \ + acc[1] = acc[1] + MIPSDSP_OVERFLOW(acc[0], -temp[0], temp_sum, \ + 0x8000000000000000ull); \ + temp[0] = temp_sum; \ + temp[1] = acc[1] - temp[1]; \ + } \ + \ + env->active_tc.HI[ac] = temp[1]; \ + env->active_tc.LO[ac] = temp[0]; \ +} + +DP_OB (dpau_h_obl,1 ,56 ,48 ,40 ,32 ,56 ,48 ,40 ,32 ); +DP_OB (dpau_h_obr,1 ,24 ,16 ,8 ,0 ,24 ,16 ,8 ,0 ); +DP_OB (dpsu_h_obl,0 ,56 ,48 ,40 ,32 ,56 ,48 ,40 ,32 ); +DP_OB (dpsu_h_obr,0 ,24 ,16 ,8 ,0 ,24 ,16 ,8 ,0 ); + +#undef DP_OB +#endif + +#define DP_NOFUNC_PH (name, is_add, rsmov1, rsmov2, rtmov1, rtmov2) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint16_t rsB, rsA, rtB, rtA; \ + int32_t tempA, tempB; \ + int64_t acc; \ + \ + rsB = (rs >> rsmov1) & MIPSDSP_LO; \ + rsA = (rs >> rsmov2) & MIPSDSP_LO; \ + rtB = (rt >> rtmov1) & MIPSDSP_LO; \ + rtA = (rt >> rtmov2) & MIPSDSP_LO; \ + \ + tempB = (int32_t)rsB * (int32_t)rtB; \ + tempA = (int32_t)rsA * (int32_t)rtA; \ + \ + acc = ((uint64_t)env->active_tc.HI[ac] << 32) | \ + ((uint64_t)env->active_tc.LO[ac] & MIPSDSP_LLO); \ + \ + if (is_add) { \ + acc = acc + ((int64_t)tempB + (int64_t)tempA); \ + } else { \ + acc = acc - ((int64_t)tempB + (int64_t)tempA); \ + } \ + \ + 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); \ +} + +DP_NOFUNC_PH (dpa_w_ph,1 ,16 ,0 ,16 ,0 ); +DP_NOFUNC_PH (dpax_w_ph,1 ,16 ,0 ,0 ,16 ); +DP_NOFUNC_PH (dps_w_ph,0 ,16 ,0 ,16 ,0 ); +DP_NOFUNC_PH (dpsx_w_ph,0 ,16 ,0 ,0 ,16 ); +#undef DP_NOFUNC_PH + +#define DP_HASFUNC_PH (name, is_add, rsmov1, rsmov2, rtmov1, rtmov2) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int16_t rsB, rsA, rtB, rtA; \ + int32_t tempB, tempA; \ + int64_t acc, dotp; \ + \ + rsB = (rs >> rsmov1) & MIPSDSP_LO; \ + rsA = (rs >> rsmov2) & MIPSDSP_LO; \ + rtB = (rt >> rtmov1) & MIPSDSP_LO; \ + rtA = (rt >> rtmov2) & MIPSDSP_LO; \ + \ + tempB = mipsdsp_mul_q15_q15(ac, rsB, rtB, env); \ + tempA = mipsdsp_mul_q15_q15(ac, rsA, rtA, env); \ + \ + dotp = (int64_t)tempB + (int64_t)tempA; \ + acc = ((uint64_t)env->active_tc.HI[ac] << 32) | \ + ((uint64_t)env->active_tc.LO[ac] & MIPSDSP_LLO); \ + \ + if (is_add) { \ + acc = acc + dotp; \ + } else { \ + 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); \ +} + +DP_HASFUNC_PH (dpaq_s_w_ph,1 ,16 ,0 ,16 ,0 ); +DP_HASFUNC_PH (dpaqx_s_w_ph,1 ,16 ,0 ,0 ,16 ); +DP_HASFUNC_PH (dpsq_s_w_ph,0 ,16 ,0 ,16 ,0 ); +DP_HASFUNC_PH (dpsqx_s_w_ph,0 ,16 ,0 ,0 ,16 ); + +#undef DP_HASFUNC_PH + +#define DP_128OPERATION_PH (name, is_add) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int16_t rsh, rsl, rth, rtl; \ + int32_t tempB, tempA, tempC62_31, tempC63; \ + int64_t acc, dotp, tempC; \ + \ + MIPSDSP_SPLIT32_16(rs, rsh, rsl); \ + MIPSDSP_SPLIT32_16(rt, rth, rtl); \ + \ + tempB = mipsdsp_mul_q15_q15(ac, rsh, rtl, env); \ + tempA = mipsdsp_mul_q15_q15(ac, rsl, rth, env); \ + \ + dotp = (int64_t)tempB + (int64_t)tempA; \ + acc = ((uint64_t)env->active_tc.HI[ac] << 32) | \ + ((uint64_t)env->active_tc.LO[ac] & MIPSDSP_LLO); \ + if (is_add) { \ + tempC = acc + dotp; \ + } else { \ + tempC = acc - dotp; \ + } \ + tempC63 = (tempC >> 63) & 0x01; \ + tempC62_31 = (tempC >> 31) & 0xFFFFFFFF; \ + \ + if ((tempC63 == 0) && (tempC62_31 != 0x00000000)) { \ + tempC = 0x7FFFFFFF; \ + set_DSPControl_overflow_flag(1, 16 + ac, env); \ + } \ + \ + if ((tempC63 == 1) && (tempC62_31 != 0xFFFFFFFF)) { \ + tempC = 0xFFFFFFFF80000000ull; \ + set_DSPControl_overflow_flag(1, 16 + ac, env); \ + } \ + \ + 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); \ +} + +DP_128OPERATION_PH (dpaqx_sa_w_ph,1 ); +DP_128OPERATION_PH (dpsqx_sa_w_ph,0 ); + +#undef DP_128OPERATION_HP + +#if defined(TARGET_MIPS64 ) +#define DP_QH (name, is_add, use_ac_env) \ +void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \ + CPUMIPSState *env) \ +{ \ + 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; \ + \ + MIPSDSP_SPLIT64_16(rs, rs3, rs2, rs1, rs0); \ + MIPSDSP_SPLIT64_16(rt, rt3, rt2, rt1, rt0); \ + \ + if (use_ac_env) { \ + tempD = mipsdsp_mul_q15_q15(ac, rs3, rt3, env); \ + tempC = mipsdsp_mul_q15_q15(ac, rs2, rt2, env); \ + tempB = mipsdsp_mul_q15_q15(ac, rs1, rt1, env); \ + tempA = mipsdsp_mul_q15_q15(ac, rs0, rt0, env); \ + } else { \ + tempD = mipsdsp_mul_u16_u16(rs3, rt3); \ + tempC = mipsdsp_mul_u16_u16(rs2, rt2); \ + tempB = mipsdsp_mul_u16_u16(rs1, rt1); \ + tempA = mipsdsp_mul_u16_u16(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] >= 0) { \ + temp[1] = 0; \ + } else { \ + temp[1] = ~0ull; \ + } \ + \ + acc[1] = env->active_tc.HI[ac]; \ + acc[0] = env->active_tc.LO[ac]; \ + \ + if (is_add) { \ + temp_sum = acc[0] + temp[0]; \ + if (MIPSDSP_OVERFLOW(acc[0], temp[0], temp_sum, \ + 0x8000000000000000ull)) { \ + acc[1] = acc[1] + 1; \ + } \ + temp[0] = temp_sum; \ + temp[1] = acc[1] + temp[1]; \ + } else { \ + temp_sum = acc[0] - temp[0]; \ + if (MIPSDSP_OVERFLOW(acc[0], -temp[0], temp_sum, \ + 0x8000000000000000ull)) { \ + acc[1] = acc[1] - 1; \ + } \ + temp[0] = temp_sum; \ + temp[1] = acc[1] - temp[1]; \ + } \ + \ + env->active_tc.HI[ac] = temp[1]; \ + env->active_tc.LO[ac] = temp[0]; \ +} + +DP_QH (dpa_w_qh,1 ,0 ); +DP_QH (dpaq_s_w_qh,1 ,1 ); +DP_QH (dps_w_qh,0 ,0 ); +DP_QH (dpsq_s_w_qh,0 ,1 ); + +#undef DP_QH + +#endif + +#define DP_L_W (name, is_add) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int32_t temp64, temp63, tempacc63, tempdotp63, tempDL63; \ + int64_t dotp, acc; \ + int64_t tempDL[2]; \ + uint64_t temp; \ + \ + dotp = mipsdsp_mul_q31_q31(ac, rs, rt, env); \ + acc = ((uint64_t)env->active_tc.HI[ac] << 32) | \ + ((uint64_t)env->active_tc.LO[ac] & MIPSDSP_LLO); \ + if (is_add) { \ + tempDL[0] = acc + dotp; \ + } else { \ + 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(1, 16 + ac, env); \ + } \ + \ + 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); \ +} + +DP_L_W (dpaq_sa_l_w,1 ); +DP_L_W (dpsq_sa_l_w,0 ); + +#undef DP_L_W + +#if defined(TARGET_MIPS64 ) +#define DP_L_PW (name, func) \ +void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \ + CPUMIPSState *env) \ +{ \ + 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; \ + \ + MIPSDSP_SPLIT64_32(rs, rs1, rs0); \ + MIPSDSP_SPLIT64_32(rt, rt1, rt0); \ + \ + tempB[0] = mipsdsp_mul_q31_q31(ac, rs1, rt1, env); \ + tempA[0] = mipsdsp_mul_q31_q31(ac, rs0, rt0, env); \ + \ + if (tempB[0] >= 0) { \ + tempB[1] = 0x00; \ + } else { \ + tempB[1] = ~0ull; \ + } \ + \ + if (tempA[0] >= 0) { \ + tempA[1] = 0x00; \ + } else { \ + tempA[1] = ~0ull; \ + } \ + \ + temp_sum = tempB[0] + tempA[0]; \ + if (MIPSDSP_OVERFLOW(tempB[0], tempA[0], temp_sum, \ + 0x8000000000000000ull)) { \ + temp[1] += 1; \ + } \ + temp[0] = temp_sum; \ + temp[1] += tempB[1] + tempA[1]; \ + \ + mipsdsp_##func(acc, ac, temp, env); \ + \ + env->active_tc.HI[ac] = acc[1]; \ + env->active_tc.LO[ac] = acc[0]; \ +} + +DP_L_PW (dpaq_sa_l_pw, sat64_acc_add_q63); +DP_L_PW (dpsq_sa_l_pw, sat64_acc_sub_q63); + +#undef DP_L_PW + +void helper_mulsaq_s_l_pw (target_ulong rs,target_ulong rt,uint32_t ac, +CPUMIPSState *env) +{ +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 (ac, rs1, rt1, env); + tempA[0 ] =mipsdsp_mul_q31_q31 (ac, rs0, rt0, env); + +if (tempB[0 ] >=0 ) { + tempB[1 ] =0x00 ; + }else { + tempB[1 ] = ~0ull ; + } + +if (tempA[0 ] >=0 ) { + tempA[1 ] =0x00 ; + }else { + tempA[1 ] = ~0ull ; + } + + 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 ] = ~0ull ; + } + + 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 + +#define MAQ_S_W (name, mov) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int16_t rsh, rth; \ + int32_t tempA; \ + int64_t tempL, acc; \ + \ + rsh = (rs >> mov) & MIPSDSP_LO; \ + rth = (rt >> mov) & MIPSDSP_LO; \ + tempA = mipsdsp_mul_q15_q15(ac, rsh, rth, env); \ + acc = ((uint64_t)env->active_tc.HI[ac] << 32) | \ + ((uint64_t)env->active_tc.LO[ac] & MIPSDSP_LLO); \ + tempL = (int64_t)tempA + 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); \ +} + +MAQ_S_W (maq_s_w_phl,16 ); +MAQ_S_W (maq_s_w_phr,0 ); + +#undef MAQ_S_W + +#define MAQ_SA_W (name, mov) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int16_t rsh, rth; \ + int32_t tempA; \ + \ + rsh = (rs >> mov) & MIPSDSP_LO; \ + rth = (rt >> mov) & MIPSDSP_LO; \ + tempA = mipsdsp_mul_q15_q15(ac, rsh, rth, env); \ + tempA = mipsdsp_sat32_acc_q31(ac, tempA, env); \ + \ + env->active_tc.HI[ac] = (target_long)(int32_t)(((int64_t)tempA & \ + MIPSDSP_LHI) >> 32); \ + env->active_tc.LO[ac] = (target_long)(int32_t)((int64_t)tempA & \ + MIPSDSP_LLO); \ +} + +MAQ_SA_W (maq_sa_w_phl,16 ); +MAQ_SA_W (maq_sa_w_phr,0 ); + +#undef MAQ_SA_W + +#define MULQ_W (name, addvar) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint32_t rs_t, rt_t; \ + int32_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(1, 21, env); \ + } else { \ + tempL = ((int64_t)rs_t * (int64_t)rt_t) << 1; \ + tempL += addvar; \ + } \ + tempI = (tempL & MIPSDSP_LHI) >> 32; \ + \ + return (target_long)(int32_t)tempI; \ +} + +MULQ_W (mulq_s_w,0 ); +MULQ_W (mulq_rs_w,0x80000000ull ); + +#undef MULQ_W + +#if defined(TARGET_MIPS64 ) + +#define MAQ_S_W_QH (name, mov) \ +void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \ + CPUMIPSState *env) \ +{ \ + 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 >> mov) & MIPSDSP_LO; \ + rt_t = (rt >> mov) & MIPSDSP_LO; \ + temp_mul = mipsdsp_mul_q15_q15(ac, rs_t, rt_t, env); \ + \ + temp[0] = (int64_t)temp_mul; \ + if (temp[0] >= 0) { \ + temp[1] = 0x00; \ + } else { \ + temp[1] = ~0ull; \ + } \ + \ + acc[0] = env->active_tc.LO[ac]; \ + acc[1] = env->active_tc.HI[ac]; \ + \ + temp_sum = acc[0] + temp[0]; \ + if (MIPSDSP_OVERFLOW(acc[0], temp[0], temp_sum, \ + 0x8000000000000000ull)) { \ + 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]; \ +} + +MAQ_S_W_QH (maq_s_w_qhll,48 ); +MAQ_S_W_QH (maq_s_w_qhlr,32 ); +MAQ_S_W_QH (maq_s_w_qhrl,16 ); +MAQ_S_W_QH (maq_s_w_qhrr,0 ); + +#undef MAQ_S_W_QH + +#define MAQ_SA_W (name, mov) \ +void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \ + CPUMIPSState *env) \ +{ \ + int16_t rs_t, rt_t; \ + int32_t temp; \ + int64_t acc[2]; \ + \ + rs_t = (rs >> mov) & MIPSDSP_LO; \ + rt_t = (rt >> mov) & MIPSDSP_LO; \ + temp = mipsdsp_mul_q15_q15(ac, rs_t, rt_t, env); \ + temp = mipsdsp_sat32_acc_q31(ac, temp, env); \ + \ + acc[0] = (int64_t)(int32_t)temp; \ + if (acc[0] >= 0) { \ + acc[1] = 0x00; \ + } else { \ + acc[1] = ~0ull; \ + } \ + \ + env->active_tc.HI[ac] = acc[1]; \ + env->active_tc.LO[ac] = acc[0]; \ +} + +MAQ_SA_W (maq_sa_w_qhll,48 ); +MAQ_SA_W (maq_sa_w_qhlr,32 ); +MAQ_SA_W (maq_sa_w_qhrl,16 ); +MAQ_SA_W (maq_sa_w_qhrr,0 ); + +#undef MAQ_SA_W + +#define MAQ_S_L_PW (name, mov) \ +void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \ + CPUMIPSState *env) \ +{ \ + 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 >> mov) & MIPSDSP_LLO; \ + rt_t = (rt >> mov) & MIPSDSP_LLO; \ + \ + temp[0] = mipsdsp_mul_q31_q31(ac, rs_t, rt_t, env); \ + if (temp[0] >= 0) { \ + temp[1] = 0x00; \ + } else { \ + temp[1] = ~0ull; \ + } \ + \ + acc[0] = env->active_tc.LO[ac]; \ + acc[1] = env->active_tc.HI[ac]; \ + \ + temp_sum = acc[0] + temp[0]; \ + if (MIPSDSP_OVERFLOW(acc[0], temp[0], temp_sum, \ + 0x8000000000000000ull)) { \ + 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]; \ +} + +MAQ_S_L_PW (maq_s_l_pwl,32 ); +MAQ_S_L_PW (maq_s_l_pwr,0 ); + +#undef MAQ_S_L_PW + +#define DM_OPERATE (name, func, is_add, sigext) \ +void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \ + CPUMIPSState *env) \ +{ \ + int32_t rs1, rs0; \ + int32_t rt1, rt0; \ + int64_t tempBL[2], tempAL[2]; \ + int64_t acc[2]; \ + int64_t temp[2]; \ + int64_t temp_sum; \ + \ + temp[0] = 0x00; \ + temp[1] = 0x00; \ + \ + MIPSDSP_SPLIT64_32(rs, rs1, rs0); \ + MIPSDSP_SPLIT64_32(rt, rt1, rt0); \ + \ + if (sigext) { \ + tempBL[0] = (int64_t)mipsdsp_##func(rs1, rt1); \ + tempAL[0] = (int64_t)mipsdsp_##func(rs0, rt0); \ + \ + if (tempBL[0] >= 0) { \ + tempBL[1] = 0x0; \ + } else { \ + tempBL[1] = ~0ull; \ + } \ + \ + if (tempAL[0] >= 0) { \ + tempAL[1] = 0x0; \ + } else { \ + tempAL[1] = ~0ull; \ + } \ + } else { \ + tempBL[0] = mipsdsp_##func(rs1, rt1); \ + tempAL[0] = mipsdsp_##func(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 (MIPSDSP_OVERFLOW(tempBL[0], tempAL[0], temp_sum, \ + 0x8000000000000000ull)) { \ + temp[1] += 1; \ + } \ + temp[0] = temp_sum; \ + temp[1] += tempBL[1] + tempAL[1]; \ + \ + if (is_add) { \ + temp_sum = acc[0] + temp[0]; \ + if (MIPSDSP_OVERFLOW(acc[0], temp[0], temp_sum, \ + 0x8000000000000000ull)) { \ + acc[1] = acc[1] + 1; \ + } \ + temp[0] = temp_sum; \ + temp[1] = acc[1] + temp[1]; \ + } else { \ + temp_sum = acc[0] - temp[0]; \ + if (MIPSDSP_OVERFLOW(acc[0], -temp[0], temp_sum, \ + 0x8000000000000000ull)) { \ + acc[1] = acc[1] - 1; \ + } \ + temp[0] = temp_sum; \ + temp[1] = acc[1] - temp[1]; \ + } \ + \ + env->active_tc.HI[ac] = temp[1]; \ + env->active_tc.LO[ac] = temp[0]; \ +} + +DM_OPERATE (dmadd, mul_i32_i32,1 ,1 ); +DM_OPERATE (dmaddu, mul_u32_u32,1 ,0 ); +DM_OPERATE (dmsub, mul_i32_i32,0 ,1 ); +DM_OPERATE (dmsubu, mul_u32_u32,0 ,0 ); +#undef DM_OPERATE +#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 +531 -0
603 lines not on this page · raw message
Signature · 1 line
1.7.10.2 (Apple Git-33)
Re: [Qemu-devel] [PATCH v9 08/14] target-mips-ase-dsp: Add multiply instructions
Quoted 1,525 lines · Jia Liu
Add MIPS ASE DSP Multiply instructions.
Signed-off-by Jia Liu <[email protected]>--- target-mips/dsp_helper.c | 938 ++++++++++++++++++++++++++++++++++++++++++++++ target-mips/helper.h | 91 +++++ target-mips/translate.c | 531 ++++++++++++++++++++++++++ 3 files changed, 1560 insertions(+)target-mips/dsp_helper.c +938
-0@@ -2248,6 +2248,944 @@ SHIFT_PH(shra_r, rnd16_rashift);#undef SHIFT_PH +/** DSP Multiply Sub-class insns **/ +/* Return value made up by two 16bits value. +* FIXME give the macro a better name. +*/ +#define MUL_RETURN32_16_PH (name, func, \ + rsmov1, rsmov2, rsfilter, \ + rtmov1, rtmov2, rtfilter) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint16_t rsB, rsA, rtB, rtA; \ + \ + rsB = (rs >> rsmov1) & rsfilter; \ + rsA = (rs >> rsmov2) & rsfilter; \ + rtB = (rt >> rtmov1) & rtfilter; \ + rtA = (rt >> rtmov2) & rtfilter; \ + \ + rsB = mipsdsp_##func(rsB, rtB, env); \ + rsA = mipsdsp_##func(rsA, rtA, env); \ + \ + return MIPSDSP_RETURN32_16(rsB, rsA); \ +} + +MUL_RETURN32_16_PH (muleu_s_ph_qbl, mul_u8_u16, \ +24 ,16 ,MIPSDSP_Q0 , \ +16 ,0 ,MIPSDSP_LO ); +MUL_RETURN32_16_PH (muleu_s_ph_qbr, mul_u8_u16, \ +8 ,0 ,MIPSDSP_Q0 , \ +16 ,0 ,MIPSDSP_LO ); +MUL_RETURN32_16_PH (mulq_rs_ph, rndq15_mul_q15_q15, \ +16 ,0 ,MIPSDSP_LO , \ +16 ,0 ,MIPSDSP_LO ); +MUL_RETURN32_16_PH (mul_ph, mul_i16_i16, \ +16 ,0 ,MIPSDSP_LO , \ +16 ,0 ,MIPSDSP_LO ); +MUL_RETURN32_16_PH (mul_s_ph, sat16_mul_i16_i16, \ +16 ,0 ,MIPSDSP_LO , \ +16 ,0 ,MIPSDSP_LO ); +MUL_RETURN32_16_PH (mulq_s_ph, sat16_mul_q15_q15, \ +16 ,0 ,MIPSDSP_LO , \ +16 ,0 ,MIPSDSP_LO ); + +#undef MUL_RETURN32_16_PH + +#define MUL_RETURN32_32_ph (name, func, movbits) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int16_t rsh, rth; \ + int32_t temp; \ + \ + rsh = (rs >> movbits) & MIPSDSP_LO; \ + rth = (rt >> movbits) & MIPSDSP_LO; \ + temp = mipsdsp_##func(rsh, rth, env); \ + \ + return (target_long)(int32_t)temp; \ +} + +MUL_RETURN32_32_ph (muleq_s_w_phl, mul_q15_q15_overflowflag21,16 ); +MUL_RETURN32_32_ph (muleq_s_w_phr, mul_q15_q15_overflowflag21,0 ); + +#undef MUL_RETURN32_32_ph + +#define MUL_VOID_PH (name, use_ac_env) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int16_t rsh, rsl, rth, rtl; \ + int32_t tempB, tempA; \ + int64_t acc, dotp; \ + \ + MIPSDSP_SPLIT32_16(rs, rsh, rsl); \ + MIPSDSP_SPLIT32_16(rt, rth, rtl); \ + \ + if (use_ac_env == 1) { \ + tempB = mipsdsp_mul_q15_q15(ac, rsh, rth, env); \ + tempA = mipsdsp_mul_q15_q15(ac, rsl, rtl, env); \ + } else { \ + tempB = mipsdsp_mul_u16_u16(rsh, rth); \ + tempA = mipsdsp_mul_u16_u16(rsl, rtl); \ + } \ + \ + dotp = (int64_t)tempB - (int64_t)tempA; \ + 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); \ +} + +MUL_VOID_PH (mulsaq_s_w_ph,1 ); +MUL_VOID_PH (mulsa_w_ph,0 ); + +#undef MUL_VOID_PH + +#if defined(TARGET_MIPS64 ) +#define MUL_RETURN64_16_QH (name, func, \ + rsmov1, rsmov2, rsmov3, rsmov4, rsfilter, \ + rtmov1, rtmov2, rtmov3, rtmov4, rtfilter) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint16_t rs3, rs2, rs1, rs0; \ + uint16_t rt3, rt2, rt1, rt0; \ + uint16_t tempD, tempC, tempB, tempA; \ + \ + rs3 = (rs >> rsmov1) & rsfilter; \ + rs2 = (rs >> rsmov2) & rsfilter; \ + rs1 = (rs >> rsmov3) & rsfilter; \ + rs0 = (rs >> rsmov4) & rsfilter; \ + rt3 = (rt >> rtmov1) & rtfilter; \ + rt2 = (rt >> rtmov2) & rtfilter; \ + rt1 = (rt >> rtmov3) & rtfilter; \ + rt0 = (rt >> rtmov4) & rtfilter; \ + \ + tempD = mipsdsp_##func(rs3, rt3, env); \ + tempC = mipsdsp_##func(rs2, rt2, env); \ + tempB = mipsdsp_##func(rs1, rt1, env); \ + tempA = mipsdsp_##func(rs0, rt0, env); \ + \ + return MIPSDSP_RETURN64_16(tempD, tempC, tempB, tempA); \ +} + +MUL_RETURN64_16_QH (muleu_s_qh_obl, mul_u8_u16, \ +56 ,48 ,40 ,32 ,MIPSDSP_Q0 , \ +48 ,32 ,16 ,0 ,MIPSDSP_LO ); +MUL_RETURN64_16_QH (muleu_s_qh_obr, mul_u8_u16, \ +24 ,16 ,8 ,0 ,MIPSDSP_Q0 , \ +48 ,32 ,16 ,0 ,MIPSDSP_LO ); +MUL_RETURN64_16_QH (mulq_rs_qh, rndq15_mul_q15_q15, \ +48 ,32 ,16 ,0 ,MIPSDSP_LO , \ +48 ,32 ,16 ,0 ,MIPSDSP_LO ); + +#undef MUL_RETURN64_16_QH + +#define MUL_RETURN64_32_QH (name, \ + rsmov1, rsmov2, \ + rtmov1, rtmov2) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint16_t rsB, rsA; \ + uint16_t rtB, rtA; \ + uint32_t tempB, tempA; \ + \ + rsB = (rs >> rsmov1) & MIPSDSP_LO; \ + rsA = (rs >> rsmov2) & MIPSDSP_LO; \ + rtB = (rt >> rtmov1) & MIPSDSP_LO; \ + rtA = (rt >> rtmov2) & MIPSDSP_LO; \ + \ + tempB = mipsdsp_mul_q15_q15(5, rsB, rtB, env); \ + tempA = mipsdsp_mul_q15_q15(5, rsA, rtA, env); \ + \ + return ((uint64_t)tempB << 32) | (uint64_t)tempA; \ +} + +MUL_RETURN64_32_QH (muleq_s_pw_qhl,48 ,32 ,48 ,32 ); +MUL_RETURN64_32_QH (muleq_s_pw_qhr,16 ,0 ,16 ,0 ); + +#undef MUL_RETURN64_32_QH + +void helper_mulsaq_s_w_qh (target_ulong rs,target_ulong rt,uint32_t ac, +CPUMIPSState *env) +{ +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; + +MIPSDSP_SPLIT64_16 (rs, rs3, rs2, rs1, rs0); +MIPSDSP_SPLIT64_16 (rt, rt3, rt2, rt1, rt0); + + tempD =mipsdsp_mul_q15_q15 (ac, rs3, rt3, env); + tempC =mipsdsp_mul_q15_q15 (ac, rs2, rt2, env); + tempB =mipsdsp_mul_q15_q15 (ac, rs1, rt1, env); + tempA =mipsdsp_mul_q15_q15 (ac, rs0, rt0, env); + + 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 ] = ~0ull ; + } + + 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 + +#define DP_QB (name, func, is_add, rsmov1, rsmov2, rtmov1, rtmov2) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint8_t rs3, rs2; \ + uint8_t rt3, rt2; \ + uint16_t tempB, tempA; \ + uint64_t tempC, dotp; \ + \ + rs3 = (rs >> rsmov1) & MIPSDSP_Q0; \ + rs2 = (rs >> rsmov2) & MIPSDSP_Q0; \ + rt3 = (rt >> rtmov1) & MIPSDSP_Q0; \ + rt2 = (rt >> rtmov2) & MIPSDSP_Q0; \ + tempB = mipsdsp_##func(rs3, rt3); \ + tempA = mipsdsp_##func(rs2, rt2); \ + dotp = (int64_t)tempB + (int64_t)tempA; \ + if (is_add) { \ + tempC = (((uint64_t)env->active_tc.HI[ac] << 32) | \ + ((uint64_t)env->active_tc.LO[ac] & MIPSDSP_LLO)) \ + + dotp; \ + } else { \ + 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); \ +} + +DP_QB (dpau_h_qbl, mul_u8_u8,1 ,24 ,16 ,24 ,16 ); +DP_QB (dpau_h_qbr, mul_u8_u8,1 ,8 ,0 ,8 ,0 ); +DP_QB (dpsu_h_qbl, mul_u8_u8,0 ,24 ,16 ,24 ,16 ); +DP_QB (dpsu_h_qbr, mul_u8_u8,0 ,8 ,0 ,8 ,0 ); + +#undef DP_QB + +#if defined(TARGET_MIPS64 ) +#define DP_OB (name, add_sub, \ + rsmov1, rsmov2, rsmov3, rsmov4, \ + rtmov1, rtmov2, rtmov3, rtmov4) \ +void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \ + CPUMIPSState *env) \ +{ \ + uint8_t rsD, rsC, rsB, rsA; \ + uint8_t rtD, rtC, rtB, rtA; \ + uint16_t tempD, tempC, tempB, tempA; \ + uint64_t temp[2]; \ + uint64_t acc[2]; \ + uint64_t temp_sum; \ + \ + temp[0] = 0; \ + temp[1] = 0; \ + \ + rsD = (rs >> rsmov1) & MIPSDSP_Q0; \ + rsC = (rs >> rsmov2) & MIPSDSP_Q0; \ + rsB = (rs >> rsmov3) & MIPSDSP_Q0; \ + rsA = (rs >> rsmov4) & MIPSDSP_Q0; \ + rtD = (rt >> rtmov1) & MIPSDSP_Q0; \ + rtC = (rt >> rtmov2) & MIPSDSP_Q0; \ + rtB = (rt >> rtmov3) & MIPSDSP_Q0; \ + rtA = (rt >> rtmov4) & MIPSDSP_Q0; \ + \ + tempD = mipsdsp_mul_u8_u8(rsD, rtD); \ + tempC = mipsdsp_mul_u8_u8(rsC, rtC); \ + tempB = mipsdsp_mul_u8_u8(rsB, rtB); \ + tempA = mipsdsp_mul_u8_u8(rsA, rtA); \ + \ + 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]; \ + \ + if (add_sub) { \ + temp_sum = acc[0] + temp[0]; \ + acc[1] = acc[1] + MIPSDSP_OVERFLOW(acc[0], temp[0], temp_sum, \ + 0x8000000000000000ull); \ + temp[0] = temp_sum; \ + temp[1] = acc[1] + temp[1]; \ + } else { \ + temp_sum = acc[0] - temp[0]; \ + acc[1] = acc[1] + MIPSDSP_OVERFLOW(acc[0], -temp[0], temp_sum, \ + 0x8000000000000000ull); \ + temp[0] = temp_sum; \ + temp[1] = acc[1] - temp[1]; \ + } \ + \ + env->active_tc.HI[ac] = temp[1]; \ + env->active_tc.LO[ac] = temp[0]; \ +} + +DP_OB (dpau_h_obl,1 ,56 ,48 ,40 ,32 ,56 ,48 ,40 ,32 ); +DP_OB (dpau_h_obr,1 ,24 ,16 ,8 ,0 ,24 ,16 ,8 ,0 ); +DP_OB (dpsu_h_obl,0 ,56 ,48 ,40 ,32 ,56 ,48 ,40 ,32 ); +DP_OB (dpsu_h_obr,0 ,24 ,16 ,8 ,0 ,24 ,16 ,8 ,0 ); + +#undef DP_OB +#endif + +#define DP_NOFUNC_PH (name, is_add, rsmov1, rsmov2, rtmov1, rtmov2) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint16_t rsB, rsA, rtB, rtA; \ + int32_t tempA, tempB; \ + int64_t acc; \ + \ + rsB = (rs >> rsmov1) & MIPSDSP_LO; \ + rsA = (rs >> rsmov2) & MIPSDSP_LO; \ + rtB = (rt >> rtmov1) & MIPSDSP_LO; \ + rtA = (rt >> rtmov2) & MIPSDSP_LO; \ + \ + tempB = (int32_t)rsB * (int32_t)rtB; \ + tempA = (int32_t)rsA * (int32_t)rtA; \ + \ + acc = ((uint64_t)env->active_tc.HI[ac] << 32) | \ + ((uint64_t)env->active_tc.LO[ac] & MIPSDSP_LLO); \ + \ + if (is_add) { \ + acc = acc + ((int64_t)tempB + (int64_t)tempA); \ + } else { \ + acc = acc - ((int64_t)tempB + (int64_t)tempA); \ + } \ + \ + 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); \ +} + +DP_NOFUNC_PH (dpa_w_ph,1 ,16 ,0 ,16 ,0 ); +DP_NOFUNC_PH (dpax_w_ph,1 ,16 ,0 ,0 ,16 ); +DP_NOFUNC_PH (dps_w_ph,0 ,16 ,0 ,16 ,0 ); +DP_NOFUNC_PH (dpsx_w_ph,0 ,16 ,0 ,0 ,16 ); +#undef DP_NOFUNC_PH + +#define DP_HASFUNC_PH (name, is_add, rsmov1, rsmov2, rtmov1, rtmov2) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int16_t rsB, rsA, rtB, rtA; \ + int32_t tempB, tempA; \ + int64_t acc, dotp; \ + \ + rsB = (rs >> rsmov1) & MIPSDSP_LO; \ + rsA = (rs >> rsmov2) & MIPSDSP_LO; \ + rtB = (rt >> rtmov1) & MIPSDSP_LO; \ + rtA = (rt >> rtmov2) & MIPSDSP_LO; \ + \ + tempB = mipsdsp_mul_q15_q15(ac, rsB, rtB, env); \ + tempA = mipsdsp_mul_q15_q15(ac, rsA, rtA, env); \ + \ + dotp = (int64_t)tempB + (int64_t)tempA; \ + acc = ((uint64_t)env->active_tc.HI[ac] << 32) | \ + ((uint64_t)env->active_tc.LO[ac] & MIPSDSP_LLO); \ + \ + if (is_add) { \ + acc = acc + dotp; \ + } else { \ + 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); \ +} + +DP_HASFUNC_PH (dpaq_s_w_ph,1 ,16 ,0 ,16 ,0 ); +DP_HASFUNC_PH (dpaqx_s_w_ph,1 ,16 ,0 ,0 ,16 ); +DP_HASFUNC_PH (dpsq_s_w_ph,0 ,16 ,0 ,16 ,0 ); +DP_HASFUNC_PH (dpsqx_s_w_ph,0 ,16 ,0 ,0 ,16 ); + +#undef DP_HASFUNC_PH + +#define DP_128OPERATION_PH (name, is_add) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int16_t rsh, rsl, rth, rtl; \ + int32_t tempB, tempA, tempC62_31, tempC63; \ + int64_t acc, dotp, tempC; \ + \ + MIPSDSP_SPLIT32_16(rs, rsh, rsl); \ + MIPSDSP_SPLIT32_16(rt, rth, rtl); \ + \ + tempB = mipsdsp_mul_q15_q15(ac, rsh, rtl, env); \ + tempA = mipsdsp_mul_q15_q15(ac, rsl, rth, env); \ + \ + dotp = (int64_t)tempB + (int64_t)tempA; \ + acc = ((uint64_t)env->active_tc.HI[ac] << 32) | \ + ((uint64_t)env->active_tc.LO[ac] & MIPSDSP_LLO); \ + if (is_add) { \ + tempC = acc + dotp; \ + } else { \ + tempC = acc - dotp; \ + } \ + tempC63 = (tempC >> 63) & 0x01; \ + tempC62_31 = (tempC >> 31) & 0xFFFFFFFF; \ + \ + if ((tempC63 == 0) && (tempC62_31 != 0x00000000)) { \ + tempC = 0x7FFFFFFF; \ + set_DSPControl_overflow_flag(1, 16 + ac, env); \ + } \ + \ + if ((tempC63 == 1) && (tempC62_31 != 0xFFFFFFFF)) { \ + tempC = 0xFFFFFFFF80000000ull; \ + set_DSPControl_overflow_flag(1, 16 + ac, env); \ + } \ + \ + 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); \ +} + +DP_128OPERATION_PH (dpaqx_sa_w_ph,1 ); +DP_128OPERATION_PH (dpsqx_sa_w_ph,0 ); + +#undef DP_128OPERATION_HP + +#if defined(TARGET_MIPS64 ) +#define DP_QH (name, is_add, use_ac_env) \ +void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \ + CPUMIPSState *env) \ +{ \ + 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; \ + \ + MIPSDSP_SPLIT64_16(rs, rs3, rs2, rs1, rs0); \ + MIPSDSP_SPLIT64_16(rt, rt3, rt2, rt1, rt0); \ + \ + if (use_ac_env) { \ + tempD = mipsdsp_mul_q15_q15(ac, rs3, rt3, env); \ + tempC = mipsdsp_mul_q15_q15(ac, rs2, rt2, env); \ + tempB = mipsdsp_mul_q15_q15(ac, rs1, rt1, env); \ + tempA = mipsdsp_mul_q15_q15(ac, rs0, rt0, env); \ + } else { \ + tempD = mipsdsp_mul_u16_u16(rs3, rt3); \ + tempC = mipsdsp_mul_u16_u16(rs2, rt2); \ + tempB = mipsdsp_mul_u16_u16(rs1, rt1); \ + tempA = mipsdsp_mul_u16_u16(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] >= 0) { \ + temp[1] = 0; \ + } else { \ + temp[1] = ~0ull; \ + } \ + \ + acc[1] = env->active_tc.HI[ac]; \ + acc[0] = env->active_tc.LO[ac]; \ + \ + if (is_add) { \ + temp_sum = acc[0] + temp[0]; \ + if (MIPSDSP_OVERFLOW(acc[0], temp[0], temp_sum, \ + 0x8000000000000000ull)) { \ + acc[1] = acc[1] + 1; \ + } \ + temp[0] = temp_sum; \ + temp[1] = acc[1] + temp[1]; \ + } else { \ + temp_sum = acc[0] - temp[0]; \ + if (MIPSDSP_OVERFLOW(acc[0], -temp[0], temp_sum, \ + 0x8000000000000000ull)) { \ + acc[1] = acc[1] - 1; \ + } \ + temp[0] = temp_sum; \ + temp[1] = acc[1] - temp[1]; \ + } \ + \ + env->active_tc.HI[ac] = temp[1]; \ + env->active_tc.LO[ac] = temp[0]; \ +} + +DP_QH (dpa_w_qh,1 ,0 ); +DP_QH (dpaq_s_w_qh,1 ,1 ); +DP_QH (dps_w_qh,0 ,0 ); +DP_QH (dpsq_s_w_qh,0 ,1 ); + +#undef DP_QH + +#endif + +#define DP_L_W (name, is_add) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int32_t temp64, temp63, tempacc63, tempdotp63, tempDL63; \ + int64_t dotp, acc; \ + int64_t tempDL[2]; \ + uint64_t temp; \ + \ + dotp = mipsdsp_mul_q31_q31(ac, rs, rt, env); \ + acc = ((uint64_t)env->active_tc.HI[ac] << 32) | \ + ((uint64_t)env->active_tc.LO[ac] & MIPSDSP_LLO); \ + if (is_add) { \ + tempDL[0] = acc + dotp; \ + } else { \ + 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(1, 16 + ac, env); \ + } \ + \ + 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); \ +} + +DP_L_W (dpaq_sa_l_w,1 ); +DP_L_W (dpsq_sa_l_w,0 ); + +#undef DP_L_W + +#if defined(TARGET_MIPS64 ) +#define DP_L_PW (name, func) \ +void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \ + CPUMIPSState *env) \ +{ \ + 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; \ + \ + MIPSDSP_SPLIT64_32(rs, rs1, rs0); \ + MIPSDSP_SPLIT64_32(rt, rt1, rt0); \ + \ + tempB[0] = mipsdsp_mul_q31_q31(ac, rs1, rt1, env); \ + tempA[0] = mipsdsp_mul_q31_q31(ac, rs0, rt0, env); \ + \ + if (tempB[0] >= 0) { \ + tempB[1] = 0x00; \ + } else { \ + tempB[1] = ~0ull; \ + } \ + \ + if (tempA[0] >= 0) { \ + tempA[1] = 0x00; \ + } else { \ + tempA[1] = ~0ull; \ + } \ + \ + temp_sum = tempB[0] + tempA[0]; \ + if (MIPSDSP_OVERFLOW(tempB[0], tempA[0], temp_sum, \ + 0x8000000000000000ull)) { \ + temp[1] += 1; \ + } \ + temp[0] = temp_sum; \ + temp[1] += tempB[1] + tempA[1]; \ + \ + mipsdsp_##func(acc, ac, temp, env); \ + \ + env->active_tc.HI[ac] = acc[1]; \ + env->active_tc.LO[ac] = acc[0]; \ +} + +DP_L_PW (dpaq_sa_l_pw, sat64_acc_add_q63); +DP_L_PW (dpsq_sa_l_pw, sat64_acc_sub_q63); + +#undef DP_L_PW + +void helper_mulsaq_s_l_pw (target_ulong rs,target_ulong rt,uint32_t ac, +CPUMIPSState *env) +{ +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 (ac, rs1, rt1, env); + tempA[0 ] =mipsdsp_mul_q31_q31 (ac, rs0, rt0, env); + +if (tempB[0 ] >=0 ) { + tempB[1 ] =0x00 ; + }else { + tempB[1 ] = ~0ull ; + } + +if (tempA[0 ] >=0 ) { + tempA[1 ] =0x00 ; + }else { + tempA[1 ] = ~0ull ; + } + + 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 ] = ~0ull ; + } + + 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 + +#define MAQ_S_W (name, mov) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int16_t rsh, rth; \ + int32_t tempA; \ + int64_t tempL, acc; \ + \ + rsh = (rs >> mov) & MIPSDSP_LO; \ + rth = (rt >> mov) & MIPSDSP_LO; \ + tempA = mipsdsp_mul_q15_q15(ac, rsh, rth, env); \ + acc = ((uint64_t)env->active_tc.HI[ac] << 32) | \ + ((uint64_t)env->active_tc.LO[ac] & MIPSDSP_LLO); \ + tempL = (int64_t)tempA + 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); \ +} + +MAQ_S_W (maq_s_w_phl,16 ); +MAQ_S_W (maq_s_w_phr,0 ); + +#undef MAQ_S_W + +#define MAQ_SA_W (name, mov) \ +void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int16_t rsh, rth; \ + int32_t tempA; \ + \ + rsh = (rs >> mov) & MIPSDSP_LO; \ + rth = (rt >> mov) & MIPSDSP_LO; \ + tempA = mipsdsp_mul_q15_q15(ac, rsh, rth, env); \ + tempA = mipsdsp_sat32_acc_q31(ac, tempA, env); \ + \ + env->active_tc.HI[ac] = (target_long)(int32_t)(((int64_t)tempA & \ + MIPSDSP_LHI) >> 32); \ + env->active_tc.LO[ac] = (target_long)(int32_t)((int64_t)tempA & \ + MIPSDSP_LLO); \ +} + +MAQ_SA_W (maq_sa_w_phl,16 ); +MAQ_SA_W (maq_sa_w_phr,0 ); + +#undef MAQ_SA_W + +#define MULQ_W (name, addvar) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint32_t rs_t, rt_t; \ + int32_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(1, 21, env); \ + } else { \ + tempL = ((int64_t)rs_t * (int64_t)rt_t) << 1; \ + tempL += addvar; \ + } \ + tempI = (tempL & MIPSDSP_LHI) >> 32; \ + \ + return (target_long)(int32_t)tempI; \ +} + +MULQ_W (mulq_s_w,0 ); +MULQ_W (mulq_rs_w,0x80000000ull ); + +#undef MULQ_W + +#if defined(TARGET_MIPS64 ) + +#define MAQ_S_W_QH (name, mov) \ +void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \ + CPUMIPSState *env) \ +{ \ + 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 >> mov) & MIPSDSP_LO; \ + rt_t = (rt >> mov) & MIPSDSP_LO; \ + temp_mul = mipsdsp_mul_q15_q15(ac, rs_t, rt_t, env); \ + \ + temp[0] = (int64_t)temp_mul; \ + if (temp[0] >= 0) { \ + temp[1] = 0x00; \ + } else { \ + temp[1] = ~0ull; \ + } \ + \ + acc[0] = env->active_tc.LO[ac]; \ + acc[1] = env->active_tc.HI[ac]; \ + \ + temp_sum = acc[0] + temp[0]; \ + if (MIPSDSP_OVERFLOW(acc[0], temp[0], temp_sum, \ + 0x8000000000000000ull)) { \ + 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]; \ +} + +MAQ_S_W_QH (maq_s_w_qhll,48 ); +MAQ_S_W_QH (maq_s_w_qhlr,32 ); +MAQ_S_W_QH (maq_s_w_qhrl,16 ); +MAQ_S_W_QH (maq_s_w_qhrr,0 ); + +#undef MAQ_S_W_QH + +#define MAQ_SA_W (name, mov) \ +void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \ + CPUMIPSState *env) \ +{ \ + int16_t rs_t, rt_t; \ + int32_t temp; \ + int64_t acc[2]; \ + \ + rs_t = (rs >> mov) & MIPSDSP_LO; \ + rt_t = (rt >> mov) & MIPSDSP_LO; \ + temp = mipsdsp_mul_q15_q15(ac, rs_t, rt_t, env); \ + temp = mipsdsp_sat32_acc_q31(ac, temp, env); \ + \ + acc[0] = (int64_t)(int32_t)temp; \ + if (acc[0] >= 0) { \ + acc[1] = 0x00; \ + } else { \ + acc[1] = ~0ull; \ + } \ + \ + env->active_tc.HI[ac] = acc[1]; \ + env->active_tc.LO[ac] = acc[0]; \ +} + +MAQ_SA_W (maq_sa_w_qhll,48 ); +MAQ_SA_W (maq_sa_w_qhlr,32 ); +MAQ_SA_W (maq_sa_w_qhrl,16 ); +MAQ_SA_W (maq_sa_w_qhrr,0 ); + +#undef MAQ_SA_W + +#define MAQ_S_L_PW (name, mov) \ +void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \ + CPUMIPSState *env) \ +{ \ + 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 >> mov) & MIPSDSP_LLO; \ + rt_t = (rt >> mov) & MIPSDSP_LLO; \ + \ + temp[0] = mipsdsp_mul_q31_q31(ac, rs_t, rt_t, env); \ + if (temp[0] >= 0) { \ + temp[1] = 0x00; \ + } else { \ + temp[1] = ~0ull; \ + } \ + \ + acc[0] = env->active_tc.LO[ac]; \ + acc[1] = env->active_tc.HI[ac]; \ + \ + temp_sum = acc[0] + temp[0]; \ + if (MIPSDSP_OVERFLOW(acc[0], temp[0], temp_sum, \ + 0x8000000000000000ull)) { \ + 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]; \ +} + +MAQ_S_L_PW (maq_s_l_pwl,32 ); +MAQ_S_L_PW (maq_s_l_pwr,0 ); + +#undef MAQ_S_L_PW + +#define DM_OPERATE (name, func, is_add, sigext) \ +void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \ + CPUMIPSState *env) \ +{ \ + int32_t rs1, rs0; \ + int32_t rt1, rt0; \ + int64_t tempBL[2], tempAL[2]; \ + int64_t acc[2]; \ + int64_t temp[2]; \ + int64_t temp_sum; \ + \ + temp[0] = 0x00; \ + temp[1] = 0x00; \ + \ + MIPSDSP_SPLIT64_32(rs, rs1, rs0); \ + MIPSDSP_SPLIT64_32(rt, rt1, rt0); \ + \ + if (sigext) { \ + tempBL[0] = (int64_t)mipsdsp_##func(rs1, rt1); \ + tempAL[0] = (int64_t)mipsdsp_##func(rs0, rt0); \ + \ + if (tempBL[0] >= 0) { \ + tempBL[1] = 0x0; \ + } else { \ + tempBL[1] = ~0ull; \ + } \ + \ + if (tempAL[0] >= 0) { \ + tempAL[1] = 0x0; \ + } else { \ + tempAL[1] = ~0ull; \ + } \ + } else { \ + tempBL[0] = mipsdsp_##func(rs1, rt1); \ + tempAL[0] = mipsdsp_##func(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 (MIPSDSP_OVERFLOW(tempBL[0], tempAL[0], temp_sum, \ + 0x8000000000000000ull)) { \ + temp[1] += 1; \ + } \ + temp[0] = temp_sum; \ + temp[1] += tempBL[1] + tempAL[1]; \ + \ + if (is_add) { \ + temp_sum = acc[0] + temp[0]; \ + if (MIPSDSP_OVERFLOW(acc[0], temp[0], temp_sum, \ + 0x8000000000000000ull)) { \ + acc[1] = acc[1] + 1; \ + } \ + temp[0] = temp_sum; \ + temp[1] = acc[1] + temp[1]; \ + } else { \ + temp_sum = acc[0] - temp[0]; \ + if (MIPSDSP_OVERFLOW(acc[0], -temp[0], temp_sum, \ + 0x8000000000000000ull)) { \ + acc[1] = acc[1] - 1; \ + } \ + temp[0] = temp_sum; \ + temp[1] = acc[1] - temp[1]; \ + } \ + \ + env->active_tc.HI[ac] = temp[1]; \ + env->active_tc.LO[ac] = temp[0]; \ +} + +DM_OPERATE (dmadd, mul_i32_i32,1 ,1 ); +DM_OPERATE (dmaddu, mul_u32_u32,1 ,0 ); +DM_OPERATE (dmsub, mul_i32_i32,0 ,1 ); +DM_OPERATE (dmsubu, mul_u32_u32,0 ,0 ); +#undef DM_OPERATE +#endif +#undef MIPSDSP_LHI#undef MIPSDSP_LLO#undef MIPSDSP_HItarget-mips/helper.h +91
-0@@ -526,4 +526,95 @@ DEF_HELPER_FLAGS_2(shra_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, tl)#endif +/* DSP Multiply Sub-class insns */ +DEF_HELPER_FLAGS_3(muleu_s_ph_qbl, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(muleu_s_ph_qbr, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(muleu_s_qh_obl, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(muleu_s_qh_obr, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(mulq_rs_ph, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(mulq_rs_qh, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(muleq_s_w_phl, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(muleq_s_w_phr, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(muleq_s_pw_qhl, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(muleq_s_pw_qhr, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_4(dpau_h_qbl, 0, void, i32, tl, tl, env) +DEF_HELPER_FLAGS_4(dpau_h_qbr, 0, void, i32, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dpau_h_obl, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(dpau_h_obr, 0, void, tl, tl, i32, env) +#endif +DEF_HELPER_FLAGS_4(dpsu_h_qbl, 0, void, i32, tl, tl, env) +DEF_HELPER_FLAGS_4(dpsu_h_qbr, 0, void, i32, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dpsu_h_obl, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(dpsu_h_obr, 0, void, tl, tl, i32, env) +#endif +DEF_HELPER_FLAGS_4(dpa_w_ph, 0, void, i32, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dpa_w_qh, 0, void, tl, tl, i32, env) +#endif +DEF_HELPER_FLAGS_4(dpax_w_ph, 0, void, i32, tl, tl, env) +DEF_HELPER_FLAGS_4(dpaq_s_w_ph, 0, void, i32, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dpaq_s_w_qh, 0, void, tl, tl, i32, env) +#endif +DEF_HELPER_FLAGS_4(dpaqx_s_w_ph, 0, void, i32, tl, tl, env) +DEF_HELPER_FLAGS_4(dpaqx_sa_w_ph, 0, void, i32, tl, tl, env) +DEF_HELPER_FLAGS_4(dps_w_ph, 0, void, i32, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dps_w_qh, 0, void, tl, tl, i32, env) +#endif +DEF_HELPER_FLAGS_4(dpsx_w_ph, 0, void, i32, tl, tl, env) +DEF_HELPER_FLAGS_4(dpsq_s_w_ph, 0, void, i32, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dpsq_s_w_qh, 0, void, tl, tl, i32, env) +#endif +DEF_HELPER_FLAGS_4(dpsqx_s_w_ph, 0, void, i32, tl, tl, env) +DEF_HELPER_FLAGS_4(dpsqx_sa_w_ph, 0, void, i32, tl, tl, env) +DEF_HELPER_FLAGS_4(mulsaq_s_w_ph, 0, void, i32, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(mulsaq_s_w_qh, 0, void, tl, tl, i32, env) +#endif +DEF_HELPER_FLAGS_4(dpaq_sa_l_w, 0, void, i32, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dpaq_sa_l_pw, 0, void, tl, tl, i32, env) +#endif +DEF_HELPER_FLAGS_4(dpsq_sa_l_w, 0, void, i32, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(dpsq_sa_l_pw, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(mulsaq_s_l_pw, 0, void, tl, tl, i32, env) +#endif +DEF_HELPER_FLAGS_4(maq_s_w_phl, 0, void, i32, tl, tl, env) +DEF_HELPER_FLAGS_4(maq_s_w_phr, 0, void, i32, tl, tl, env) +DEF_HELPER_FLAGS_4(maq_sa_w_phl, 0, void, i32, tl, tl, env) +DEF_HELPER_FLAGS_4(maq_sa_w_phr, 0, void, i32, tl, tl, env) +DEF_HELPER_FLAGS_3(mul_ph, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(mul_s_ph, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(mulq_s_ph, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(mulq_s_w, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(mulq_rs_w, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_4(mulsa_w_ph, 0, void, i32, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_4(maq_s_w_qhll, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(maq_s_w_qhlr, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(maq_s_w_qhrl, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(maq_s_w_qhrr, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(maq_sa_w_qhll, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(maq_sa_w_qhlr, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(maq_sa_w_qhrl, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(maq_sa_w_qhrr, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(maq_s_l_pwl, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(maq_s_l_pwr, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(dmadd, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(dmaddu, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(dmsub, 0, void, tl, tl, i32, env) +DEF_HELPER_FLAGS_4(dmsubu, 0, void, tl, tl, i32, env) +#endif +#include "def-helper.h" target-mips/translate.c +417
-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 */@@ -13244,6 +13323,365 @@ static void gen_mipsdsp_shift(DisasContext *ctx, uint32_t opc,MIPS_DEBUG ("%s" , opn); } +static void gen_mipsdsp_multiply (DisasContext *ctx,uint32_t op1,uint32_t op2, +int ret,int rs,int rt,int check_ret) +{ +const char *opn ="mipsdsp multiply" ; +TCGv_i32 t0 =tcg_const_i32 (ret); + +if ((ret ==0 ) && (check_ret ==1 )) { +/* Treat as NOP. */ +MIPS_DEBUG ("NOP" ); +return ; + } + +switch (op1) { +/* OPC_MULT_G_2E, OPC_ADDUH_QB_DSP, OPC_MUL_PH_DSP have +* the same mask and op1. */ +case OPC_MULT_G_2E : +switch (op2) { +case OPC_MUL_PH : +gen_helper_mul_ph (cpu_gpr[ret], cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MUL_S_PH : +gen_helper_mul_s_ph (cpu_gpr[ret], cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MULQ_S_W : +gen_helper_mulq_s_w (cpu_gpr[ret], cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MULQ_RS_W : +gen_helper_mulq_rs_w (cpu_gpr[ret], cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; + } +break ; +case OPC_DPA_W_PH_DSP : +switch (op2) { +case OPC_DPAU_H_QBL : +check_dsp (ctx); +gen_helper_dpau_h_qbl (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_DPAU_H_QBR : +check_dsp (ctx); +gen_helper_dpau_h_qbr (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_DPSU_H_QBL : +check_dsp (ctx); +gen_helper_dpsu_h_qbl (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_DPSU_H_QBR : +check_dsp (ctx); +gen_helper_dpsu_h_qbr (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_DPA_W_PH : +check_dspr2 (ctx); +gen_helper_dpa_w_ph (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_DPAX_W_PH : +check_dspr2 (ctx); +gen_helper_dpax_w_ph (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_DPAQ_S_W_PH : +check_dsp (ctx); +gen_helper_dpaq_s_w_ph (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_DPAQX_S_W_PH : +check_dspr2 (ctx); +gen_helper_dpaqx_s_w_ph (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_DPAQX_SA_W_PH : +check_dspr2 (ctx); +gen_helper_dpaqx_sa_w_ph (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_DPS_W_PH : +check_dspr2 (ctx); +gen_helper_dps_w_ph (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_DPSX_W_PH : +check_dspr2 (ctx); +gen_helper_dpsx_w_ph (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_DPSQ_S_W_PH : +check_dsp (ctx); +gen_helper_dpsq_s_w_ph (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_DPSQX_S_W_PH : +check_dspr2 (ctx); +gen_helper_dpsqx_s_w_ph (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_DPSQX_SA_W_PH : +check_dspr2 (ctx); + { +gen_helper_dpsqx_sa_w_ph (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; + } +case OPC_MULSAQ_S_W_PH : +check_dsp (ctx); +gen_helper_mulsaq_s_w_ph (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_DPAQ_SA_L_W : +check_dsp (ctx); +gen_helper_dpaq_sa_l_w (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_DPSQ_SA_L_W : +check_dsp (ctx); +gen_helper_dpsq_sa_l_w (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MAQ_S_W_PHL : +check_dsp (ctx); +gen_helper_maq_s_w_phl (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MAQ_S_W_PHR : +check_dsp (ctx); +gen_helper_maq_s_w_phr (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MAQ_SA_W_PHL : +check_dsp (ctx); +gen_helper_maq_sa_w_phl (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MAQ_SA_W_PHR : +check_dsp (ctx); +gen_helper_maq_sa_w_phr (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MULSA_W_PH : +check_dspr2 (ctx); +gen_helper_mulsa_w_ph (t0, cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; + } +#ifdef TARGET_MIPS64 +case OPC_DPAQ_W_QH_DSP : + { +int ac = ret &0x03 ; +tcg_gen_movi_i32 (t0, ac); + +switch (op2) { +case OPC_DMADD : +check_dsp (ctx); +gen_helper_dmadd (cpu_gpr[rs], cpu_gpr[rt], t0, cpu_env); +break ; +case OPC_DMADDU : +check_dsp (ctx); +gen_helper_dmaddu (cpu_gpr[rs], cpu_gpr[rt], t0, cpu_env); +break ; +case OPC_DMSUB : +check_dsp (ctx); +gen_helper_dmsub (cpu_gpr[rs], cpu_gpr[rt], t0, cpu_env); +break ; +case OPC_DMSUBU : +check_dsp (ctx); +gen_helper_dmsubu (cpu_gpr[rs], cpu_gpr[rt], t0, cpu_env); +break ; +case OPC_DPA_W_QH : +check_dspr2 (ctx); +gen_helper_dpa_w_qh (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_DPAQ_S_W_QH : +check_dsp (ctx); +gen_helper_dpaq_s_w_qh (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_DPAQ_SA_L_PW : +check_dsp (ctx); +gen_helper_dpaq_sa_l_pw (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_DPAU_H_OBL : +check_dsp (ctx); +gen_helper_dpau_h_obl (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_DPAU_H_OBR : +check_dsp (ctx); +gen_helper_dpau_h_obr (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_DPS_W_QH : +check_dspr2 (ctx); +gen_helper_dps_w_qh (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_DPSQ_S_W_QH : +check_dsp (ctx); +gen_helper_dpsq_s_w_qh (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_DPSQ_SA_L_PW : +check_dsp (ctx); +gen_helper_dpsq_sa_l_pw (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_DPSU_H_OBL : +check_dsp (ctx); +gen_helper_dpsu_h_obl (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_DPSU_H_OBR : +check_dsp (ctx); +gen_helper_dpsu_h_obr (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_MAQ_S_L_PWL : +check_dsp (ctx); +gen_helper_maq_s_l_pwl (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_MAQ_S_L_PWR : +check_dsp (ctx); +gen_helper_maq_s_l_pwr (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_MAQ_S_W_QHLL : +check_dsp (ctx); +gen_helper_maq_s_w_qhll (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_MAQ_SA_W_QHLL : +check_dsp (ctx); +gen_helper_maq_sa_w_qhll (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_MAQ_S_W_QHLR : +check_dsp (ctx); +gen_helper_maq_s_w_qhlr (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_MAQ_SA_W_QHLR : +check_dsp (ctx); +gen_helper_maq_sa_w_qhlr (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_MAQ_S_W_QHRL : +check_dsp (ctx); +gen_helper_maq_s_w_qhrl (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_MAQ_SA_W_QHRL : +check_dsp (ctx); +gen_helper_maq_sa_w_qhrl (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_MAQ_S_W_QHRR : +check_dsp (ctx); +gen_helper_maq_s_w_qhrr (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_MAQ_SA_W_QHRR : +check_dsp (ctx); +gen_helper_maq_sa_w_qhrr (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_MULSAQ_S_L_PW : +check_dsp (ctx); +gen_helper_mulsaq_s_l_pw (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; +case OPC_MULSAQ_S_W_QH : +check_dsp (ctx); +gen_helper_mulsaq_s_w_qh (cpu_gpr[rs], cpu_gpr[rt], + t0, cpu_env); +break ; + } + } +break ; +#endif +case OPC_ADDU_QB_DSP : +switch (op2) { +case OPC_MULEU_S_PH_QBL : +check_dsp (ctx); +gen_helper_muleu_s_ph_qbl (cpu_gpr[ret], cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MULEU_S_PH_QBR : +check_dsp (ctx); +gen_helper_muleu_s_ph_qbr (cpu_gpr[ret], cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MULQ_RS_PH : +check_dsp (ctx); +gen_helper_mulq_rs_ph (cpu_gpr[ret], cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MULEQ_S_W_PHL : +check_dsp (ctx); +gen_helper_muleq_s_w_phl (cpu_gpr[ret], cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MULEQ_S_W_PHR : +check_dsp (ctx); +gen_helper_muleq_s_w_phr (cpu_gpr[ret], cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MULQ_S_PH : +check_dspr2 (ctx); +gen_helper_mulq_s_ph (cpu_gpr[ret], cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; + } +#ifdef TARGET_MIPS64 +case OPC_ADDU_OB_DSP : +switch (op2) { +case OPC_MULEQ_S_PW_QHL : +check_dsp (ctx); +gen_helper_muleq_s_pw_qhl (cpu_gpr[ret], cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MULEQ_S_PW_QHR : +check_dsp (ctx); +gen_helper_muleq_s_pw_qhr (cpu_gpr[ret], cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MULEU_S_QH_OBL : +check_dsp (ctx); +gen_helper_muleu_s_qh_obl (cpu_gpr[ret], cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ;
target-mips/translate.c static void gen_mipsdsp_shift(DisasContext *ctx, uint32_t opc, · line 13673
Quoted 10 lines
target-mips/translate.c +10
-0+case OPC_MULEU_S_QH_OBR : +check_dsp (ctx); +gen_helper_muleu_s_qh_obr (cpu_gpr[ret], cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ; +case OPC_MULQ_RS_QH : +check_dsp (ctx); +gen_helper_mulq_rs_qh (cpu_gpr[ret], cpu_gpr[rs], + cpu_gpr[rt], cpu_env); +break ;
All these functions should check for rs and rt being 0.
Quoted 146 lines
target-mips/translate.c +104
-0+ } +#endif +break ; + } +tcg_temp_free_i32 (t0); + + (void )opn;/* avoid a compiler warning */ +MIPS_DEBUG ("%s" , opn); + +} +/* End MIPSDSP functions. */ static void decode_opc (CPUMIPSState *env,DisasContext *ctx,int *is_branch)@@ -13617,6 +14055,12 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)case OPC_SUBQH_R_W :gen_mipsdsp_arith (ctx, op1, op2, rd, rs, rt);break ; +case OPC_MUL_PH : +case OPC_MUL_S_PH : +case OPC_MULQ_S_W : +case OPC_MULQ_RS_W : +gen_mipsdsp_multiply (ctx, op1, op2, rd, rs, rt,1 ); +break ;default :MIPS_INVAL ("MASK ADDUH.QB" );generate_exception (ctx,EXCP_RI );@@ -13693,6 +14137,14 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)case OPC_RADDU_W_QB :gen_mipsdsp_arith (ctx, op1, op2, rd, rs, rt);break ; +case OPC_MULEU_S_PH_QBL : +case OPC_MULEU_S_PH_QBR : +case OPC_MULQ_RS_PH : +case OPC_MULEQ_S_W_PHL : +case OPC_MULEQ_S_W_PHR : +case OPC_MULQ_S_PH : +gen_mipsdsp_multiply (ctx, op1, op2, rd, rs, rt,1 ); +break ;default :/* Invalid */ MIPS_INVAL ("MASK ADDU.QB" );generate_exception (ctx,EXCP_RI );@@ -13723,6 +14175,39 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)case OPC_SHLL_QB_DSP :gen_mipsdsp_shift (ctx, op1, rd, rs, rt);break ; +case OPC_DPA_W_PH_DSP : + op2 =MASK_DPA_W_PH (ctx->opcode); +switch (op2) { +case OPC_DPAU_H_QBL : +case OPC_DPAU_H_QBR : +case OPC_DPSU_H_QBL : +case OPC_DPSU_H_QBR : +case OPC_DPA_W_PH : +case OPC_DPAX_W_PH : +case OPC_DPAQ_S_W_PH : +case OPC_DPAQX_S_W_PH : +case OPC_DPAQX_SA_W_PH : +case OPC_DPS_W_PH : +case OPC_DPSX_W_PH : +case OPC_DPSQ_S_W_PH : +case OPC_DPSQX_S_W_PH : +case OPC_DPSQX_SA_W_PH : +case OPC_MULSAQ_S_W_PH : +case OPC_DPAQ_SA_L_W : +case OPC_DPSQ_SA_L_W : +case OPC_MAQ_S_W_PHL : +case OPC_MAQ_S_W_PHR : +case OPC_MAQ_SA_W_PHL : +case OPC_MAQ_SA_W_PHR : +case OPC_MULSA_W_PH : +gen_mipsdsp_multiply (ctx, op1, op2, rd, rs, rt,0 ); +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:@@ -13796,6 +14281,13 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)case OPC_ADDUH_R_OB :gen_mipsdsp_arith (ctx, op1, op2, rd, rs, rt);break ; +case OPC_MULEQ_S_PW_QHL : +case OPC_MULEQ_S_PW_QHR : +case OPC_MULEU_S_QH_OBL : +case OPC_MULEU_S_QH_OBR : +case OPC_MULQ_RS_QH : +gen_mipsdsp_multiply (ctx, op1, op2, rd, rs, rt,1 ); +break ;default :/* Invalid */ MIPS_INVAL ("MASK ADDU.OB" );generate_exception (ctx,EXCP_RI );@@ -13824,6 +14316,45 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)break ; }break ; +case OPC_DPAQ_W_QH_DSP : + op2 =MASK_DPAQ_W_QH (ctx->opcode); +switch (op2) { +case OPC_DPAU_H_OBL : +case OPC_DPAU_H_OBR : +case OPC_DPSU_H_OBL : +case OPC_DPSU_H_OBR : +case OPC_DPA_W_QH : +case OPC_DPAQ_S_W_QH : +case OPC_DPS_W_QH : +case OPC_DPSQ_S_W_QH : +case OPC_MULSAQ_S_W_QH : +case OPC_DPAQ_SA_L_PW : +case OPC_DPSQ_SA_L_PW : +case OPC_MULSAQ_S_L_PW : +gen_mipsdsp_multiply (ctx, op1, op2, rd, rs, rt,0 ); +break ; +case OPC_MAQ_S_W_QHLL : +case OPC_MAQ_S_W_QHLR : +case OPC_MAQ_S_W_QHRL : +case OPC_MAQ_S_W_QHRR : +case OPC_MAQ_SA_W_QHLL : +case OPC_MAQ_SA_W_QHLR : +case OPC_MAQ_SA_W_QHRL : +case OPC_MAQ_SA_W_QHRR : +case OPC_MAQ_S_L_PWL : +case OPC_MAQ_S_L_PWR : +case OPC_DMADD : +case OPC_DMADDU : +case OPC_DMSUB : +case OPC_DMSUBU : +gen_mipsdsp_multiply (ctx, op1, op2, rd, rs, rt,0 ); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK DPAQ.W.QH" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ;case OPC_SHLL_OB_DSP :gen_mipsdsp_shift (ctx, op1, rd, rs, rt);break ;Signature · 1 line
1.7.10.2 (Apple Git-33)
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v9 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 | 55 ++++++++++ target-mips/helper.h | 7 ++ target-mips/translate.c | 268 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 330 insertions(+)
target-mips/dsp_helper.c +55 -0
@@ -3186,6 +3186,61 @@ DM_OPERATE(dmsubu, mul_u32_u32, 0, 0);#undef DM_OPERATE#endif +/** DSP Bit/Manipulation Sub-class insns **/ +target_ulong helper_bitrev (target_ulong rt) +{ +int32_t temp; +uint32_t rd; +int i; + + temp = rt &MIPSDSP_LO ; + rd =0 ; +for (i =0 ; i <16 ; i++) { + rd = (rd <<1 ) | (temp &1 ); + temp = temp >>1 ; + } + +return (target_ulong )rd; +} + +#define BIT_INSV (name, posfilter, sizefilter, ret_type) \ +target_ulong helper_##name(CPUMIPSState *env, target_ulong rs, \ + target_ulong rt) \ +{ \ + uint32_t pos, size, msb, lsb; \ + target_ulong filter; \ + target_ulong temp, temprs, temprt; \ + target_ulong dspc; \ + \ + dspc = env->active_tc.DSPControl; \ + \ + pos = dspc & posfilter; \ + size = (dspc >> 7) & sizefilter; \ + \ + msb = pos + size - 1; \ + lsb = pos; \ + \ + if (lsb > msb || (msb > TARGET_LONG_BITS)) { \ + return rt; \ + } \ + \ + filter = ((int32_t)0x01 << size) - 1; \ + filter = filter << pos; \ + temprs = rs & filter; \ + temprt = rt & ~filter; \ + temp = temprs | temprt; \ + \ + return (target_long)(ret_type)temp; \ +} + +BIT_INSV (insv,0x1F ,0x1F , int32_t); +#ifdef TARGET_MIPS64 +BIT_INSV (dinsv,0x7F ,0x3F , target_long); +#endif + +#undef BIT_INSV + +#undef MIPSDSP_LHI#undef MIPSDSP_LLO#undef MIPSDSP_HI
target-mips/helper.h +7 -0
@@ -617,4 +617,11 @@ DEF_HELPER_FLAGS_4(dmsub, 0, void, tl, tl, i32, env) DEF_HELPER_FLAGS_4(dmsubu, 0, void, tl, tl, i32, env)#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 +268 -0
328 lines not on this page · raw message
Signature · 1 line
1.7.10.2 (Apple Git-33)
Re: [Qemu-devel] [PATCH v9 09/14] target-mips-ase-dsp: Add bit/manipulation instructions
Quoted 176 lines · Jia Liu
Add MIPS ASE DSP Bit/Manipulation instructions.
Signed-off-by Jia Liu <[email protected]>--- target-mips/dsp_helper.c | 55 ++++++++++ target-mips/helper.h | 7 ++ target-mips/translate.c | 268 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 330 insertions(+)target-mips/dsp_helper.c +55
-0@@ -3186,6 +3186,61 @@ DM_OPERATE(dmsubu, mul_u32_u32, 0, 0);#undef DM_OPERATE#endif +/** DSP Bit/Manipulation Sub-class insns **/ +target_ulong helper_bitrev (target_ulong rt) +{ +int32_t temp; +uint32_t rd; +int i; + + temp = rt &MIPSDSP_LO ; + rd =0 ; +for (i =0 ; i <16 ; i++) { + rd = (rd <<1 ) | (temp &1 ); + temp = temp >>1 ; + } + +return (target_ulong )rd; +} + +#define BIT_INSV (name, posfilter, sizefilter, ret_type) \ +target_ulong helper_##name(CPUMIPSState *env, target_ulong rs, \ + target_ulong rt) \ +{ \ + uint32_t pos, size, msb, lsb; \ + target_ulong filter; \ + target_ulong temp, temprs, temprt; \ + target_ulong dspc; \ + \ + dspc = env->active_tc.DSPControl; \ + \ + pos = dspc & posfilter; \ + size = (dspc >> 7) & sizefilter; \ + \ + msb = pos + size - 1; \ + lsb = pos; \ + \ + if (lsb > msb || (msb > TARGET_LONG_BITS)) { \ + return rt; \ + } \ + \ + filter = ((int32_t)0x01 << size) - 1; \ + filter = filter << pos; \ + temprs = rs & filter; \ + temprt = rt & ~filter; \ + temp = temprs | temprt; \ + \ + return (target_long)(ret_type)temp; \ +} + +BIT_INSV (insv,0x1F ,0x1F , int32_t); +#ifdef TARGET_MIPS64 +BIT_INSV (dinsv,0x7F ,0x3F , target_long); +#endif + +#undef BIT_INSV + +#undef MIPSDSP_LHI#undef MIPSDSP_LLO#undef MIPSDSP_HItarget-mips/helper.h +7
-0@@ -617,4 +617,11 @@ DEF_HELPER_FLAGS_4(dmsub, 0, void, tl, tl, i32, env) DEF_HELPER_FLAGS_4(dmsubu, 0, void, tl, tl, i32, env)#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 +42
-0@@ -343,6 +343,11 @@ enum {#if defined(TARGET_MIPS64 ) OPC_DPAQ_W_QH_DSP = 0x34 | OPC_SPECIAL3, #endif + /* DSP Bit/Manipulation Sub-class */ + OPC_INSV_DSP = 0x0C | OPC_SPECIAL3, +#if defined(TARGET_MIPS64) + OPC_DINSV_DSP = 0x0D | OPC_SPECIAL3, +#endif };/* BSHFL opcodes */ @@ -450,6 +455,12 @@ enum {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 , +/* DSP Bit/Manipulation Sub-class */ +OPC_BITREV = (0x1B <<6 ) |OPC_ABSQ_S_PH_DSP , +OPC_REPL_QB = (0x02 <<6 ) |OPC_ABSQ_S_PH_DSP , +OPC_REPLV_QB = (0x03 <<6 ) |OPC_ABSQ_S_PH_DSP , +OPC_REPL_PH = (0x0A <<6 ) |OPC_ABSQ_S_PH_DSP , + OPC_REPLV_PH = (0x0B << 6) | OPC_ABSQ_S_PH_DSP, };#define MASK_CMPU_EQ_QB (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))@@ -518,6 +529,12 @@ enum { OPC_MULSA_W_PH = (0x02 << 6) | OPC_DPA_W_PH_DSP, }; +#define MASK_INSV (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* DSP Bit/Manipulation Sub-class */ +OPC_INSV = (0x00 <<6 ) |OPC_INSV_DSP , +}; +#if defined(TARGET_MIPS64 )#define MASK_ABSQ_S_QH (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) enum {@@ -539,6 +556,13 @@ enum {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 , +/* DSP Bit/Manipulation Sub-class */ +OPC_REPL_OB = (0x02 <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_REPL_PW = (0x12 <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_REPL_QH = (0x0A <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_REPLV_OB = (0x03 <<6 ) |OPC_ABSQ_S_QH_DSP , +OPC_REPLV_PW = (0x13 <<6 ) |OPC_ABSQ_S_QH_DSP , + OPC_REPLV_QH = (0x0B << 6) | OPC_ABSQ_S_QH_DSP, };#endif @@ -592,6 +616,14 @@ enum {#endif #if defined(TARGET_MIPS64 ) +#define MASK_DINSV (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* DSP Bit/Manipulation Sub-class */ +OPC_DINSV = (0x00 <<6 ) |OPC_DINSV_DSP , +}; +#endif + +#if defined(TARGET_MIPS64 )#define MASK_DPAQ_W_QH (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))enum { /* MIPS DSP Multiply Sub-class insns */@@ -13682,6 +13714,189 @@ static void gen_mipsdsp_multiply(DisasContext *ctx, uint32_t op1, uint32_t op2, } +static void gen_mipsdsp_bitinsn (CPUMIPSState *env,DisasContext *ctx, +uint32_t op1,uint32_t op2, +int ret,int val) +{ +const char *opn ="mipsdsp Bit/ Manipulation" ; +TCGv t0 =tcg_temp_new (); +int16_t imm; + +if (ret ==0 ) { +/* Treat as NOP. */
target-mips/translate.c static void gen_mipsdsp_multiply(DisasContext *ctx, uint32_t op1, uint32_t op2, · line 13736
Quoted 10 lines
target-mips/translate.c +10
-0+MIPS_DEBUG ("NOP" ); +return ; + } + +switch (op1) { +case OPC_ABSQ_S_PH_DSP : +switch (op2) { +case OPC_BITREV : +check_dsp (ctx); +gen_helper_bitrev (cpu_gpr[ret], cpu_gpr[val]);
You should check for val being register 0.
target-mips/translate.c static void gen_mipsdsp_multiply(DisasContext *ctx, uint32_t op1, uint32_t op2, · line 13748
Quoted 12 lines
target-mips/translate.c +12
-0+break ; +case OPC_REPL_QB : +check_dsp (ctx); + { +target_long result; + imm = (ctx->opcode >>16 ) &0xFF ; + result = (uint32_t )imm <<24 | \ + (uint32_t )imm <<16 | \ + (uint32_t )imm <<8 | \ + (uint32_t )imm; +#ifdef TARGET_MIPS64 + result = (target_long)(result <<32 ) >>32 ;
result = (int32_t)result should do it, and doesn't need to be conditional on TARGET_MIPS64.
target-mips/translate.c static void gen_mipsdsp_multiply(DisasContext *ctx, uint32_t op1, uint32_t op2, · line 13761
Quoted 13 lines
target-mips/translate.c +13
-0+#endif +tcg_gen_movi_tl (cpu_gpr[ret], result); + } +break ; +case OPC_REPLV_QB : +check_dsp (ctx); + { +TCGv temp_rd; + + temp_rd =tcg_temp_new (); + +/* we need t0 to save gpr[val] 7..0 bits. */ +tcg_gen_ext8u_tl (t0, cpu_gpr[val]);
val could be register 0.
target-mips/translate.c static void gen_mipsdsp_multiply(DisasContext *ctx, uint32_t op1, uint32_t op2, · line 13771
Quoted 10 lines
target-mips/translate.c +10
-0+tcg_gen_mov_tl (temp_rd, t0); +tcg_gen_shli_tl (t0, t0,8 ); +tcg_gen_or_tl (temp_rd, temp_rd, t0); +tcg_gen_mov_tl (t0, temp_rd); +tcg_gen_shli_tl (t0, t0,16 ); +tcg_gen_or_tl (temp_rd, temp_rd, t0); +#if defined(TARGET_MIPS64 ) +tcg_gen_ext32s_i64 (temp_rd, temp_rd); +#endif +tcg_gen_mov_tl (cpu_gpr[ret], temp_rd);
As previously said, this can be written as:
tcg_gen_ext8u_tl(cpu_gpr[ret], cpu_gpr[val]);
tcg_gen_shli_tl(t0, cpu_gpr[ret], 8);
tcg_gen_or_tl(cpu_gpr[ret], cpu_gpr[ret], t0);
tcg_gen_shli_tl(t0, cpu_gpr[ret], 16);
tcg_gen_or_tl(cpu_gpr[ret], cpu_gpr[ret], t0);
tcg_gen_ext32s_tl(cpu_gpr[ret], cpu_gpr[ret]);(The latest operation being a nop on 32-bit).
Quoted 8 lines
target-mips/translate.c +8
-0+tcg_temp_free (temp_rd); + } +break ; +case OPC_REPL_PH : +check_dsp (ctx); + { + imm = (ctx->opcode >>16 ) &0x03FF ; + tcg_gen_movi_tl(cpu_gpr[ret], \
target-mips/translate.c static void gen_mipsdsp_multiply(DisasContext *ctx, uint32_t op1, uint32_t op2, · line 13790
Quoted 10 lines
target-mips/translate.c +10
-0+ (target_long)((int32_t )imm <<16 | \ + (uint32_t)(uint16_t)imm)); + } +break ; +case OPC_REPLV_PH : +check_dsp (ctx); + { +TCGv temp_rd; + + temp_rd =tcg_temp_new ();
You should check for val being register 0.
target-mips/translate.c static void gen_mipsdsp_multiply(DisasContext *ctx, uint32_t op1, uint32_t op2, · line 13797
Quoted 6 lines
target-mips/translate.c +6
-0+tcg_gen_ext16u_tl (t0, cpu_gpr[val]); +tcg_gen_ext16s_tl (temp_rd, cpu_gpr[val]); +tcg_gen_shli_tl (temp_rd, temp_rd,16 ); +tcg_gen_or_tl (temp_rd, temp_rd, t0); +tcg_gen_mov_tl (cpu_gpr[ret], temp_rd); +
This can be written as:
tcg_gen_ext16u_tl(cpu_gpr[ret], cpu_gpr[val]);
tcg_gen_shli_tl(t0, cpu_gpr[ret], 16);
tcg_gen_or_tl(cpu_gpr[ret], cpu_gpr[ret], t0);
tcg_gen_ext32s_tl(cpu_gpr[ret], cpu_gpr[ret]);Quoted 9 lines
target-mips/translate.c +9
-0+tcg_temp_free (temp_rd); + } +break ; + } +break ; +#ifdef TARGET_MIPS64 +case OPC_ABSQ_S_QH_DSP : +switch (op2) { +case OPC_REPL_OB :
target-mips/translate.c static void gen_mipsdsp_multiply(DisasContext *ctx, uint32_t op1, uint32_t op2, · line 13816
Quoted 10 lines
target-mips/translate.c +10
-0+check_dsp (ctx); + { +target_long temp; + + imm = (ctx->opcode >>16 ) &0xFF ; + temp = imm; + temp = (temp <<8 ) | temp; + temp = (temp <<16 ) | temp; + temp = (temp <<32 ) | temp; +tcg_gen_movi_tl (cpu_gpr[ret], temp);
According to the manual, REPL.OB is working on 64-bit values and thus replicating the value 8 times.
Quoted 34 lines
target-mips/translate.c +34
-0+break ; + } +case OPC_REPL_PW : +check_dsp (ctx); + { +target_long temp; + + imm = (ctx->opcode >>16 ) &0x03FF ; + imm = (int16_t )(imm <<6 ) >>6 ; + temp = ((target_long )imm <<32 ) \ + | ((target_long )imm &0xFFFFFFFF ); +tcg_gen_movi_tl (cpu_gpr[ret], temp); +break ; + } +case OPC_REPL_QH : +check_dsp (ctx); + { +target_long temp; + + imm = (ctx->opcode >>16 ) &0x03FF ; + imm = (int16_t )(imm <<6 ) >>6 ; + + temp = ((uint64_t )(uint16_t )imm <<48 ) | \ + ((uint64_t )(uint16_t )imm <<32 ) | \ + ((uint64_t )(uint16_t )imm <<16 ) | \ + (uint64_t )(uint16_t )imm; +tcg_gen_movi_tl (cpu_gpr[ret], temp); +break ; + } +case OPC_REPLV_OB : +check_dsp (ctx); + { +TCGv temp_rd; +
target-mips/translate.c static void gen_mipsdsp_multiply(DisasContext *ctx, uint32_t op1, uint32_t op2, · line 13860
Quoted 10 lines
target-mips/translate.c +10
-0+ temp_rd =tcg_temp_new (); + +tcg_gen_ext8u_tl (t0, cpu_gpr[val]); +tcg_gen_mov_tl (temp_rd, t0); +tcg_gen_shli_tl (temp_rd, temp_rd,8 ); +tcg_gen_or_tl (temp_rd, temp_rd, t0); +tcg_gen_mov_tl (t0, temp_rd); +tcg_gen_shli_tl (temp_rd, temp_rd,16 ); +tcg_gen_or_tl (temp_rd, temp_rd, t0); +tcg_gen_concat_tl_i64 (temp_rd, temp_rd, temp_rd);
As previously said, tcg_gen_concat_tl_i64 is no the best way to do that as it does a zero extension first, which is not needed here.
This can be written as:
tcg_gen_ext8u_tl(cpu_gpr[ret], cpu_gpr[ret]);
tcg_gen_shli_tl(t0, cpu_gpr[ret], 8);
tcg_gen_or_tl(cpu_gpr[ret], cpu_gpr[ret], t0);
tcg_gen_shli_tl(t0, cpu_gpr[ret], 16);
tcg_gen_or_tl(cpu_gpr[ret], cpu_gpr[ret], t0);
tcg_gen_shli_tl(t0, cpu_gpr[ret], 32);
tcg_gen_or_tl(cpu_gpr[ret], cpu_gpr[ret], t0);target-mips/translate.c static void gen_mipsdsp_multiply(DisasContext *ctx, uint32_t op1, uint32_t op2, · line 13863
Quoted 3 lines
target-mips/translate.c +3
-0+ +gen_store_gpr (temp_rd, ret); +
You can work directly on the gpr (as on the code I have written above), because the check for ret == 0 is already done at the top.
target-mips/translate.c static void gen_mipsdsp_multiply(DisasContext *ctx, uint32_t op1, uint32_t op2, · line 13871
Quoted 8 lines
target-mips/translate.c +8
-0+tcg_temp_free (temp_rd); +break ; + } +case OPC_REPLV_PW : +check_dsp (ctx); + { +tcg_gen_ext32u_i64 (t0, cpu_gpr[val]); +tcg_gen_concat_tl_i64 (cpu_gpr[ret], t0, t0);
concat already does the zero extension and is therefore not needed.
Quoted 5 lines
target-mips/translate.c +5
-0+break ; + } +case OPC_REPLV_QH : +check_dsp (ctx); + {
target-mips/translate.c static void gen_mipsdsp_multiply(DisasContext *ctx, uint32_t op1, uint32_t op2, · line 13886
Quoted 10 lines
target-mips/translate.c +10
-0+TCGv temp_rd; + + temp_rd =tcg_temp_new (); + +tcg_gen_ext16u_tl (t0, cpu_gpr[val]); +tcg_gen_mov_tl (temp_rd, t0); +tcg_gen_shli_tl (temp_rd, temp_rd,16 ); +tcg_gen_or_tl (temp_rd, temp_rd, t0); +tcg_gen_concat_tl_i64 (cpu_gpr[ret], temp_rd, temp_rd); +
This can be written as:
tcg_gen_ext16u_tl(cpu_gpr[ret], cpu_gpr[val]);
tcg_gen_shli_tl(t0, cpu_gpr[ret], 16);
tcg_gen_or_tl(cpu_gpr[ret], cpu_gpr[ret], t0);
tcg_gen_shli_tl(t0, cpu_gpr[ret], 16);
tcg_gen_or_tl(cpu_gpr[ret], cpu_gpr[ret], t0);Quoted 101 lines
target-mips/translate.c +66
-0+tcg_temp_free (temp_rd); + break; + } + } +break ; +#endif + } +tcg_temp_free (t0); + + (void )opn;/* avoid a compiler warning */ +MIPS_DEBUG ("%s" , opn); +} +/* End MIPSDSP functions. */ static void decode_opc (CPUMIPSState *env,DisasContext *ctx,int *is_branch)@@ -14108,6 +14323,13 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)case OPC_PRECEU_PH_QBRA :gen_mipsdsp_arith (ctx, op1, op2, rd, rs, rt);break ; +case OPC_BITREV : +case OPC_REPL_QB : +case OPC_REPLV_QB : +case OPC_REPL_PH : +case OPC_REPLV_PH : +gen_mipsdsp_bitinsn (env, ctx, op1, op2, rd, rt); +break ;default :MIPS_INVAL ("MASK ABSQ_S.PH" );generate_exception (ctx,EXCP_RI );@@ -14208,6 +14430,26 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)break ; }break ; +case OPC_INSV_DSP : + op2 =MASK_INSV (ctx->opcode); +switch (op2) { +case OPC_INSV : +check_dsp (ctx); + { +if (rt ==0 ) { +MIPS_DEBUG ("NOP" ); +break ; + } +gen_helper_insv (cpu_gpr[rt], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; + } +default :/* Invalid */ +MIPS_INVAL ("MASK INSV" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ;#if defined(TARGET_MIPS64 ) case OPC_DEXTM ... OPC_DEXT: case OPC_DINSM ... OPC_DINS:@@ -14249,6 +14491,14 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)case OPC_ABSQ_S_QH :gen_mipsdsp_arith (ctx, op1, op2, rd, rs, rt);break ; +case OPC_REPL_OB : +case OPC_REPL_PW : +case OPC_REPL_QH : +case OPC_REPLV_OB : +case OPC_REPLV_PW : +case OPC_REPLV_QH : +gen_mipsdsp_bitinsn (env, ctx, op1, op2, rd, rt); +break ;default :/* Invalid */ MIPS_INVAL ("MASK ABSQ_S.QH" );generate_exception (ctx,EXCP_RI );@@ -14355,6 +14605,24 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)break ; }break ; +case OPC_DINSV_DSP : + op2 =MASK_INSV (ctx->opcode); +switch (op2) { +case OPC_DINSV : +check_dsp (ctx); +if (rt ==0 ) { +MIPS_DEBUG ("NOP" ); +break ; + } +gen_helper_dinsv (cpu_gpr[rt], cpu_env, + cpu_gpr[rs], cpu_gpr[rt]); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK DINSV" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ;case OPC_SHLL_OB_DSP :gen_mipsdsp_shift (ctx, op1, rd, rs, rt);break ;Signature · 1 line
1.7.10.2 (Apple Git-33)
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v9 10/14 target-mips-ase-dsp: Add compare-pick instructions
In reply to Jia LiuAdd MIPS ASE DSP Compare-Pick instructions.
--- target-mips/dsp_helper.c | 235 ++++++++++++++++++++++++++++++ target-mips/helper.h | 52 +++++++ target-mips/translate.c | 356 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 643 insertions(+)
target-mips/dsp_helper.c +235 -0
@@ -3241,6 +3241,241 @@ BIT_INSV(dinsv, 0x7F, 0x3F, target_long);#undef BIT_INSV +/** DSP Compare-Pick Sub-class insns **/ +#define CMP_HAS_RET (name, func, split_num, filter, bit_size) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt) \ +{ \ + uint32_t rs_t[split_num]; \ + uint32_t rt_t[split_num]; \ + uint8_t cc[split_num]; \ + uint32_t temp = 0; \ + int i; \ + \ + for (i = 0; i < split_num; i++) { \ + rs_t[i] = (rs >> (bit_size * i)) & filter; \ + rt_t[i] = (rt >> (bit_size * i)) & filter; \ + cc[i] = mipsdsp_##func(rs_t[i], rt_t[i]); \ + temp |= cc[i] << i; \ + } \ + \ + return (target_ulong)temp; \ +} + +CMP_HAS_RET (cmpgu_eq_qb, cmp_eq,4 ,MIPSDSP_Q0 ,8 ); +CMP_HAS_RET (cmpgu_lt_qb, cmp_lt,4 ,MIPSDSP_Q0 ,8 ); +CMP_HAS_RET (cmpgu_le_qb, cmp_le,4 ,MIPSDSP_Q0 ,8 ); + +#ifdef TARGET_MIPS64 +CMP_HAS_RET (cmpgu_eq_ob, cmp_eq,8 ,MIPSDSP_Q0 ,8 ); +CMP_HAS_RET (cmpgu_lt_ob, cmp_lt,8 ,MIPSDSP_Q0 ,8 ); +CMP_HAS_RET (cmpgu_le_ob, cmp_le,8 ,MIPSDSP_Q0 ,8 ); +#endif + +#undef CMP_HAS_RET + + +#define CMP_NO_RET (name, func, split_num, filter, bit_size) \ +void helper_##name(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int32_t rs_t[split_num], rt_t[split_num]; \ + int32_t flag = 0; \ + int32_t cc[split_num]; \ + int i; \ + \ + for (i = 0; i < split_num; i++) { \ + rs_t[i] = (rs >> (bit_size * i)) & filter; \ + rt_t[i] = (rt >> (bit_size * i)) & filter; \ + \ + cc[i] = mipsdsp_##func(rs_t[i], rt_t[i]); \ + flag |= cc[i] << i; \ + } \ + \ + set_DSPControl_24(flag, split_num, env); \ +} + +CMP_NO_RET (cmpu_eq_qb, cmp_eq,4 ,MIPSDSP_Q0 ,8 ); +CMP_NO_RET (cmpu_lt_qb, cmp_lt,4 ,MIPSDSP_Q0 ,8 ); +CMP_NO_RET (cmpu_le_qb, cmp_le,4 ,MIPSDSP_Q0 ,8 ); + +CMP_NO_RET (cmp_eq_ph, cmp_eq,2 ,MIPSDSP_LO ,16 ); +CMP_NO_RET (cmp_lt_ph, cmp_lt,2 ,MIPSDSP_LO ,16 ); +CMP_NO_RET (cmp_le_ph, cmp_le,2 ,MIPSDSP_LO ,16 ); + +#ifdef TARGET_MIPS64 +CMP_NO_RET (cmpu_eq_ob, cmp_eq,8 ,MIPSDSP_Q0 ,8 ); +CMP_NO_RET (cmpu_lt_ob, cmp_lt,8 ,MIPSDSP_Q0 ,8 ); +CMP_NO_RET (cmpu_le_ob, cmp_le,8 ,MIPSDSP_Q0 ,8 ); + +CMP_NO_RET (cmp_eq_qh, cmp_eq,4 ,MIPSDSP_LO ,16 ); +CMP_NO_RET (cmp_lt_qh, cmp_lt,4 ,MIPSDSP_LO ,16 ); +CMP_NO_RET (cmp_le_qh, cmp_le,4 ,MIPSDSP_LO ,16 ); + +CMP_NO_RET (cmp_eq_pw, cmp_eq,2 ,MIPSDSP_LLO ,32 ); +CMP_NO_RET (cmp_lt_pw, cmp_lt,2 ,MIPSDSP_LLO ,32 ); +CMP_NO_RET (cmp_le_pw, cmp_le,2 ,MIPSDSP_LLO ,32 ); +#endif +#undef CMP_NO_RET + +#if defined(TARGET_MIPS64 ) + +#define CMPGDU_OB (name) \ +target_ulong helper_cmpgdu_##name##_ob(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int i; \ + uint8_t rs_t[8], rt_t[8]; \ + uint32_t cond; \ + \ + cond = 0; \ + \ + for (i = 0; i < 8; i++) { \ + rs_t[i] = (rs >> (8 * i)) & MIPSDSP_Q0; \ + rt_t[i] = (rt >> (8 * i)) & MIPSDSP_Q0; \ + \ + if (mipsdsp_cmp_##name(rs_t[i], rt_t[i])) { \ + cond |= 0x01 << i; \ + } \ + } \ + \ + set_DSPControl_24(cond, 8, env); \ + \ + return (uint64_t)cond; \ +} + +CMPGDU_OB(eq) +CMPGDU_OB(lt) +CMPGDU_OB(le) +#undef CMPGDU_OB +#endif + +#define PICK_INSN (name, split_num, filter, bit_size, ret32bit) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint32_t rs_t[split_num]; \ + uint32_t rt_t[split_num]; \ + uint32_t cc[split_num]; \ + target_ulong dsp; \ + int i; \ + target_ulong result = 0; \ + \ + dsp = env->active_tc.DSPControl; \ + for (i = 0; i < split_num; i++) { \ + rs_t[i] = (rs >> (bit_size * i)) & filter; \ + rt_t[i] = (rt >> (bit_size * i)) & filter; \ + cc[i] = (dsp >> (24 + i)) & 0x01; \ + cc[i] = cc[i] == 1 ? rs_t[i] : rt_t[i]; \ + \ + result |= (target_ulong)cc[i] << (bit_size * i); \ + } \ + \ + if (ret32bit) { \ + result = (target_long)(int32_t)(result & MIPSDSP_LLO); \ + } \ + \ + return result; \ +} + +PICK_INSN (pick_qb,4 ,MIPSDSP_Q0 ,8 ,1 ); +PICK_INSN (pick_ph,2 ,MIPSDSP_LO ,16 ,1 ); + +#ifdef TARGET_MIPS64 +PICK_INSN (pick_ob,8 ,MIPSDSP_Q0 ,8 ,0 ); +PICK_INSN (pick_qh,4 ,MIPSDSP_LO ,16 ,0 ); +PICK_INSN (pick_pw,2 ,MIPSDSP_LLO ,32 ,0 ); +#endif +#undef PICK_INSN + +#define APPEND_INSN (name, ret_32) \ +target_ulong helper_##name(target_ulong rt, target_ulong rs, uint32_t sa) \ +{ \ + target_ulong temp; \ + \ + if (ret_32) { \ + temp = ((rt & MIPSDSP_LLO) << sa) | \ + ((rs & MIPSDSP_LLO) & ((0x01 << sa) - 1)); \ + temp = (target_long)(int32_t)(temp & MIPSDSP_LLO); \ + } else { \ + temp = (rt << sa) | (rs & ((0x01 << sa) - 1)); \ + } \ + \ + return temp; \ +} + +APPEND_INSN (append,1 ); +#ifdef TARGET_MIPS64 +APPEND_INSN (dappend,0 ); +#endif +#undef APPEND_INSN + +#define PREPEND_INSN (name, or_val, ret_32) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, \ + uint32_t sa) \ +{ \ + sa |= or_val; \ + \ + if (1) { \ + return (target_long)(int32_t)(uint32_t) \ + (((rs & MIPSDSP_LLO) << (32 - sa)) | \ + ((rt & MIPSDSP_LLO) >> sa)); \ + } else { \ + return (rs << (64 - sa)) | (rt >> sa); \ + } \ +} + +PREPEND_INSN (prepend,0 ,1 ); +#ifdef TARGET_MIPS64 +PREPEND_INSN (prependw,0 ,0 ); +PREPEND_INSN (prependd,0x20 ,0 ); +#endif +#undef PREPEND_INSN + +#define BALIGN_INSN (name, filter, ret32) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, uint32_t bp) \ +{ \ + bp = bp & 0x03; \ + \ + if ((bp & 1) == 0) { \ + return rt; \ + } else { \ + if (ret32) { \ + return (target_long)(int32_t)((rt << (8 * bp)) | \ + (rs >> (8 * (4 - bp)))); \ + } else { \ + return (rt << (8 * bp)) | (rs >> (8 * (8 - bp))); \ + } \ + } \ +} + +BALIGN_INSN (balign,0x03 ,1 ); +#if defined(TARGET_MIPS64 ) +BALIGN_INSN (dbalign,0x07 ,0 ); +#endif +#undef BALIGN_INSN + +target_ulong helper_packrl_ph (target_ulong rs,target_ulong rt) +{ +uint32_t rsl, rth; + + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + +return (target_long)(int32_t)((rsl <<16 ) | rth); +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_packrl_pw (target_ulong rs,target_ulong rt) +{ +uint32_t rs0, rt1; + + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + +return ((uint64_t )rs0 <<32 ) | (uint64_t )rt1; +} +#endif +#undef MIPSDSP_LHI#undef MIPSDSP_LLO#undef MIPSDSP_HI
target-mips/helper.h +52 -0
56 lines not on this page · raw message
target-mips/translate.c +356 -0
416 lines not on this page · raw message
Signature · 1 line
1.7.10.2 (Apple Git-33)
Re: [Qemu-devel] [PATCH v9 10/14] target-mips-ase-dsp: Add compare-pick instructions
Quoted 24 lines · Jia Liu
Add MIPS ASE DSP Compare-Pick instructions.
Signed-off-by Jia Liu <[email protected]>--- target-mips/dsp_helper.c | 235 ++++++++++++++++++++++++++++++ target-mips/helper.h | 52 +++++++ target-mips/translate.c | 356 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 643 insertions(+)target-mips/dsp_helper.c +7
-0@@ -3241,6 +3241,241 @@ BIT_INSV(dinsv, 0x7F, 0x3F, target_long);#undef BIT_INSV +/** DSP Compare-Pick Sub-class insns **/ +#define CMP_HAS_RET (name, func, split_num, filter, bit_size) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt) \ +{ \ + uint32_t rs_t[split_num]; \ + uint32_t rt_t[split_num]; \ + uint8_t cc[split_num]; \
target-mips/dsp_helper.c BIT_INSV(dinsv, 0x7F, 0x3F, target_long); · line 3260
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+uint32_t temp =0 ; \ +int i; \ + \ +for (i =0 ; i < split_num; i++) { \ + rs_t[i] = (rs >> (bit_size * i)) & filter; \ + rt_t[i] = (rt >> (bit_size * i)) & filter; \ + cc[i] = mipsdsp_##func(rs_t[i], rt_t[i]); \ + temp |= cc[i] << i; \ + } \ + \
I don't think you need arrays there, as they are only used in the loop.
Quoted 26 lines
target-mips/dsp_helper.c +26
-0+return (target_ulong )temp; \ +} + +CMP_HAS_RET (cmpgu_eq_qb, cmp_eq,4 ,MIPSDSP_Q0 ,8 ); +CMP_HAS_RET (cmpgu_lt_qb, cmp_lt,4 ,MIPSDSP_Q0 ,8 ); +CMP_HAS_RET (cmpgu_le_qb, cmp_le,4 ,MIPSDSP_Q0 ,8 ); + +#ifdef TARGET_MIPS64 +CMP_HAS_RET (cmpgu_eq_ob, cmp_eq,8 ,MIPSDSP_Q0 ,8 ); +CMP_HAS_RET (cmpgu_lt_ob, cmp_lt,8 ,MIPSDSP_Q0 ,8 ); +CMP_HAS_RET (cmpgu_le_ob, cmp_le,8 ,MIPSDSP_Q0 ,8 ); +#endif + +#undef CMP_HAS_RET + + +#define CMP_NO_RET (name, func, split_num, filter, bit_size) \ +void helper_##name(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int32_t rs_t[split_num], rt_t[split_num]; \ + int32_t flag = 0; \ + int32_t cc[split_num]; \ + int i; \ + \ + for (i = 0; i < split_num; i++) { \
target-mips/dsp_helper.c BIT_INSV(dinsv, 0x7F, 0x3F, target_long); · line 3296
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+ rs_t[i] = (rs >> (bit_size * i)) & filter; \ + rt_t[i] = (rt >> (bit_size * i)) & filter; \ + \ + cc[i] = mipsdsp_##func(rs_t[i], rt_t[i]); \ + flag |= cc[i] << i; \ + } \ + \ + set_DSPControl_24(flag, split_num, env); \ +} +
Same there.
Quoted 38 lines
target-mips/dsp_helper.c +38
-0+CMP_NO_RET (cmpu_eq_qb, cmp_eq,4 ,MIPSDSP_Q0 ,8 ); +CMP_NO_RET (cmpu_lt_qb, cmp_lt,4 ,MIPSDSP_Q0 ,8 ); +CMP_NO_RET (cmpu_le_qb, cmp_le,4 ,MIPSDSP_Q0 ,8 ); + +CMP_NO_RET (cmp_eq_ph, cmp_eq,2 ,MIPSDSP_LO ,16 ); +CMP_NO_RET (cmp_lt_ph, cmp_lt,2 ,MIPSDSP_LO ,16 ); +CMP_NO_RET (cmp_le_ph, cmp_le,2 ,MIPSDSP_LO ,16 ); + +#ifdef TARGET_MIPS64 +CMP_NO_RET (cmpu_eq_ob, cmp_eq,8 ,MIPSDSP_Q0 ,8 ); +CMP_NO_RET (cmpu_lt_ob, cmp_lt,8 ,MIPSDSP_Q0 ,8 ); +CMP_NO_RET (cmpu_le_ob, cmp_le,8 ,MIPSDSP_Q0 ,8 ); + +CMP_NO_RET (cmp_eq_qh, cmp_eq,4 ,MIPSDSP_LO ,16 ); +CMP_NO_RET (cmp_lt_qh, cmp_lt,4 ,MIPSDSP_LO ,16 ); +CMP_NO_RET (cmp_le_qh, cmp_le,4 ,MIPSDSP_LO ,16 ); + +CMP_NO_RET (cmp_eq_pw, cmp_eq,2 ,MIPSDSP_LLO ,32 ); +CMP_NO_RET (cmp_lt_pw, cmp_lt,2 ,MIPSDSP_LLO ,32 ); +CMP_NO_RET (cmp_le_pw, cmp_le,2 ,MIPSDSP_LLO ,32 ); +#endif +#undef CMP_NO_RET + +#if defined(TARGET_MIPS64 ) + +#define CMPGDU_OB (name) \ +target_ulong helper_cmpgdu_##name##_ob(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + int i; \ + uint8_t rs_t[8], rt_t[8]; \ + uint32_t cond; \ + \ + cond = 0; \ + \ + for (i = 0; i < 8; i++) { \ + rs_t[i] = (rs >> (8 * i)) & MIPSDSP_Q0; \ + rt_t[i] = (rt >> (8 * i)) & MIPSDSP_Q0; \
target-mips/dsp_helper.c BIT_INSV(dinsv, 0x7F, 0x3F, target_long); · line 3344
Quoted 10 lines
target-mips/dsp_helper.c +10
-0+ \ + if (mipsdsp_cmp_##name(rs_t[i], rt_t[i])) { \ + cond |= 0x01 << i; \ + } \ + } \ + \ + set_DSPControl_24(cond, 8, env); \ + \ + return (uint64_t)cond; \ +}
Ant there.
Quoted 524 lines
target-mips/dsp_helper.c +134
-0+ +CMPGDU_OB(eq) +CMPGDU_OB(lt) +CMPGDU_OB(le) +#undef CMPGDU_OB +#endif + +#define PICK_INSN (name, split_num, filter, bit_size, ret32bit) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, \ + CPUMIPSState *env) \ +{ \ + uint32_t rs_t[split_num]; \ + uint32_t rt_t[split_num]; \ + uint32_t cc[split_num]; \ + target_ulong dsp; \ + int i; \ + target_ulong result = 0; \ + \ + dsp = env->active_tc.DSPControl; \ + for (i = 0; i < split_num; i++) { \ + rs_t[i] = (rs >> (bit_size * i)) & filter; \ + rt_t[i] = (rt >> (bit_size * i)) & filter; \ + cc[i] = (dsp >> (24 + i)) & 0x01; \ + cc[i] = cc[i] == 1 ? rs_t[i] : rt_t[i]; \ + \ + result |= (target_ulong)cc[i] << (bit_size * i); \ + } \ + \ + if (ret32bit) { \ + result = (target_long)(int32_t)(result & MIPSDSP_LLO); \ + } \ + \ + return result; \ +} + +PICK_INSN (pick_qb,4 ,MIPSDSP_Q0 ,8 ,1 ); +PICK_INSN (pick_ph,2 ,MIPSDSP_LO ,16 ,1 ); + +#ifdef TARGET_MIPS64 +PICK_INSN (pick_ob,8 ,MIPSDSP_Q0 ,8 ,0 ); +PICK_INSN (pick_qh,4 ,MIPSDSP_LO ,16 ,0 ); +PICK_INSN (pick_pw,2 ,MIPSDSP_LLO ,32 ,0 ); +#endif +#undef PICK_INSN + +#define APPEND_INSN (name, ret_32) \ +target_ulong helper_##name(target_ulong rt, target_ulong rs, uint32_t sa) \ +{ \ + target_ulong temp; \ + \ + if (ret_32) { \ + temp = ((rt & MIPSDSP_LLO) << sa) | \ + ((rs & MIPSDSP_LLO) & ((0x01 << sa) - 1)); \ + temp = (target_long)(int32_t)(temp & MIPSDSP_LLO); \ + } else { \ + temp = (rt << sa) | (rs & ((0x01 << sa) - 1)); \ + } \ + \ + return temp; \ +} + +APPEND_INSN (append,1 ); +#ifdef TARGET_MIPS64 +APPEND_INSN (dappend,0 ); +#endif +#undef APPEND_INSN + +#define PREPEND_INSN (name, or_val, ret_32) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, \ + uint32_t sa) \ +{ \ + sa |= or_val; \ + \ + if (1) { \ + return (target_long)(int32_t)(uint32_t) \ + (((rs & MIPSDSP_LLO) << (32 - sa)) | \ + ((rt & MIPSDSP_LLO) >> sa)); \ + } else { \ + return (rs << (64 - sa)) | (rt >> sa); \ + } \ +} + +PREPEND_INSN (prepend,0 ,1 ); +#ifdef TARGET_MIPS64 +PREPEND_INSN (prependw,0 ,0 ); +PREPEND_INSN (prependd,0x20 ,0 ); +#endif +#undef PREPEND_INSN + +#define BALIGN_INSN (name, filter, ret32) \ +target_ulong helper_##name(target_ulong rs, target_ulong rt, uint32_t bp) \ +{ \ + bp = bp & 0x03; \ + \ + if ((bp & 1) == 0) { \ + return rt; \ + } else { \ + if (ret32) { \ + return (target_long)(int32_t)((rt << (8 * bp)) | \ + (rs >> (8 * (4 - bp)))); \ + } else { \ + return (rt << (8 * bp)) | (rs >> (8 * (8 - bp))); \ + } \ + } \ +} + +BALIGN_INSN (balign,0x03 ,1 ); +#if defined(TARGET_MIPS64 ) +BALIGN_INSN (dbalign,0x07 ,0 ); +#endif +#undef BALIGN_INSN + +target_ulong helper_packrl_ph (target_ulong rs,target_ulong rt) +{ +uint32_t rsl, rth; + + rsl = rs &MIPSDSP_LO ; + rth = (rt &MIPSDSP_HI ) >>16 ; + +return (target_long)(int32_t)((rsl <<16 ) | rth); +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_packrl_pw (target_ulong rs,target_ulong rt) +{ +uint32_t rs0, rt1; + + rs0 = rs &MIPSDSP_LLO ; + rt1 = (rt >>32 ) &MIPSDSP_LLO ; + +return ((uint64_t )rs0 <<32 ) | (uint64_t )rt1; +} +#endif +#undef MIPSDSP_LHI#undef MIPSDSP_LLO#undef MIPSDSP_HItarget-mips/helper.h +52
-0@@ -624,4 +624,56 @@ DEF_HELPER_FLAGS_3(insv, 0, tl, env, tl, tl)DEF_HELPER_FLAGS_3 (dinsv,0 , tl, env, tl, tl);#endif +/* DSP Compare-Pick Sub-class insns */ +DEF_HELPER_FLAGS_3(cmpu_eq_qb, 0, void, tl, tl, env) +DEF_HELPER_FLAGS_3(cmpu_lt_qb, 0, void, tl, tl, env) +DEF_HELPER_FLAGS_3(cmpu_le_qb, 0, void, tl, tl, env) +DEF_HELPER_FLAGS_2(cmpgu_eq_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(cmpgu_lt_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(cmpgu_le_qb, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_3(cmp_eq_ph, 0, void, tl, tl, env) +DEF_HELPER_FLAGS_3(cmp_lt_ph, 0, void, tl, tl, env) +DEF_HELPER_FLAGS_3(cmp_le_ph, 0, void, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(cmpu_eq_ob, 0, void, tl, tl, env) +DEF_HELPER_FLAGS_3(cmpu_lt_ob, 0, void, tl, tl, env) +DEF_HELPER_FLAGS_3(cmpu_le_ob, 0, void, tl, tl, env) +DEF_HELPER_FLAGS_3(cmpgdu_eq_ob, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(cmpgdu_lt_ob, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(cmpgdu_le_ob, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_2(cmpgu_eq_ob, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(cmpgu_lt_ob, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_2(cmpgu_le_ob, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +DEF_HELPER_FLAGS_3(cmp_eq_qh, 0, void, tl, tl, env) +DEF_HELPER_FLAGS_3(cmp_lt_qh, 0, void, tl, tl, env) +DEF_HELPER_FLAGS_3(cmp_le_qh, 0, void, tl, tl, env) +DEF_HELPER_FLAGS_3(cmp_eq_pw, 0, void, tl, tl, env) +DEF_HELPER_FLAGS_3(cmp_lt_pw, 0, void, tl, tl, env) +DEF_HELPER_FLAGS_3(cmp_le_pw, 0, void, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(pick_qb, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(pick_ph, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(pick_ob, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(pick_qh, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(pick_pw, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(append, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl, i32) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(dappend, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl, i32) +#endif +DEF_HELPER_FLAGS_3(prepend, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl, i32) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(prependd, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl, i32) +DEF_HELPER_FLAGS_3(prependw, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl, i32) +#endif +DEF_HELPER_FLAGS_3(balign, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl, i32) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(dbalign, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl, i32) +#endif +DEF_HELPER_FLAGS_2(packrl_ph, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_2(packrl_pw, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) +#endif +#include "def-helper.h" target-mips/translate.c +283
-0@@ -348,6 +348,11 @@ enum {#if defined(TARGET_MIPS64 ) OPC_DINSV_DSP = 0x0D | OPC_SPECIAL3, #endif + /* MIPS DSP Compare-Pick Sub-class */ + OPC_APPEND_DSP = 0x31 | OPC_SPECIAL3, +#if defined(TARGET_MIPS64) + OPC_DAPPEND_DSP = 0x35 | OPC_SPECIAL3, +#endif };/* BSHFL opcodes */ @@ -473,6 +478,22 @@ enum {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 , +/* DSP Compare-Pick Sub-class */ +OPC_CMPU_EQ_QB = (0x00 <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_CMPU_LT_QB = (0x01 <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_CMPU_LE_QB = (0x02 <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_CMPGU_EQ_QB = (0x04 <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_CMPGU_LT_QB = (0x05 <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_CMPGU_LE_QB = (0x06 <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_CMPGDU_EQ_QB = (0x18 <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_CMPGDU_LT_QB = (0x19 <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_CMPGDU_LE_QB = (0x1A <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_CMP_EQ_PH = (0x08 <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_CMP_LT_PH = (0x09 <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_CMP_LE_PH = (0x0A <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_PICK_QB = (0x03 <<6 ) |OPC_CMPU_EQ_QB_DSP , +OPC_PICK_PH = (0x0B <<6 ) |OPC_CMPU_EQ_QB_DSP , + OPC_PACKRL_PH = (0x0E << 6) | OPC_CMPU_EQ_QB_DSP, };#define MASK_SHLL_QB (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))@@ -535,6 +556,14 @@ enum { OPC_INSV = (0x00 << 6) | OPC_INSV_DSP, }; +#define MASK_APPEND (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* MIPS DSP Compare-Pick Sub-class */ +OPC_APPEND = (0x00 <<6 ) |OPC_APPEND_DSP , +OPC_PREPEND = (0x01 <<6 ) |OPC_APPEND_DSP , +OPC_BALIGN = (0x10 <<6 ) |OPC_APPEND_DSP , +}; +#if defined(TARGET_MIPS64 )#define MASK_ABSQ_S_QH (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) enum {@@ -603,6 +632,26 @@ enum {#if defined(TARGET_MIPS64 )#define MASK_CMPU_EQ_OB (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))enum { +/* DSP Compare-Pick Sub-class */ +OPC_CMP_EQ_PW = (0x10 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_CMP_LT_PW = (0x11 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_CMP_LE_PW = (0x12 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_CMP_EQ_QH = (0x08 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_CMP_LT_QH = (0x09 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_CMP_LE_QH = (0x0A <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_CMPGDU_EQ_OB = (0x18 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_CMPGDU_LT_OB = (0x19 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_CMPGDU_LE_OB = (0x1A <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_CMPGU_EQ_OB = (0x04 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_CMPGU_LT_OB = (0x05 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_CMPGU_LE_OB = (0x06 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_CMPU_EQ_OB = (0x00 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_CMPU_LT_OB = (0x01 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_CMPU_LE_OB = (0x02 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_PACKRL_PW = (0x0E <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_PICK_OB = (0x03 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_PICK_PW = (0x13 <<6 ) |OPC_CMPU_EQ_OB_DSP , +OPC_PICK_QH = (0x0B <<6 ) |OPC_CMPU_EQ_OB_DSP ,/* 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,@@ -616,6 +665,17 @@ enum {#endif #if defined(TARGET_MIPS64 ) +#define MASK_DAPPEND (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* DSP Compare-Pick Sub-class */ +OPC_DAPPEND = (0x00 <<6 ) |OPC_DAPPEND_DSP , +OPC_PREPENDD = (0x03 <<6 ) |OPC_DAPPEND_DSP , +OPC_PREPENDW = (0x01 <<6 ) |OPC_DAPPEND_DSP , +OPC_DBALIGN = (0x10 <<6 ) |OPC_DAPPEND_DSP , +}; +#endif + +#if defined(TARGET_MIPS64 )#define MASK_DINSV (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))enum { /* DSP Bit/Manipulation Sub-class */@@ -13897,6 +13957,250 @@ static void gen_mipsdsp_bitinsn(CPUMIPSState *env, DisasContext *ctx,MIPS_DEBUG ("%s" , opn); } +static void gen_mipsdsp_add_cmp_pick (DisasContext *ctx, +uint32_t op1,uint32_t op2, +int ret,int v1,int v2,int check_ret) +{ +const char *opn ="mipsdsp add compare pick" ; +TCGv_i32 t0 =tcg_temp_new_i32 (); +TCGv t1 =tcg_temp_new (); + +if ((ret ==0 ) && (check_ret ==1 )) { +/* Treat as NOP. */ +MIPS_DEBUG ("NOP" ); +return ; + } + +switch (op1) { +case OPC_APPEND_DSP : +switch (op2) { +case OPC_APPEND : +tcg_gen_movi_i32 (t0, v2); +gen_helper_append (cpu_gpr[ret], cpu_gpr[ret], + cpu_gpr[v1], t0); +break ; +case OPC_PREPEND : +tcg_gen_movi_i32 (t0, v2); +gen_helper_prepend (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[ret], t0); +break ; +case OPC_BALIGN : +tcg_gen_movi_i32 (t0, v2); +gen_helper_balign (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[ret], t0); +break ; +default :/* Invid */ +MIPS_INVAL ("MASK APPEND" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ; +case OPC_CMPU_EQ_QB_DSP : +switch (op2) { +case OPC_CMPU_EQ_QB : +check_dsp (ctx); +gen_helper_cmpu_eq_qb (cpu_gpr[v1], cpu_gpr[v2], cpu_env); +break ; +case OPC_CMPU_LT_QB : +check_dsp (ctx); +gen_helper_cmpu_lt_qb (cpu_gpr[v1], cpu_gpr[v2], cpu_env); +break ; +case OPC_CMPU_LE_QB : +check_dsp (ctx); +gen_helper_cmpu_le_qb (cpu_gpr[v1], cpu_gpr[v2], cpu_env); +break ; +case OPC_CMPGU_EQ_QB : +check_dsp (ctx); +gen_helper_cmpgu_eq_qb (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_CMPGU_LT_QB : +check_dsp (ctx); +gen_helper_cmpgu_lt_qb (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_CMPGU_LE_QB : +check_dsp (ctx); +gen_helper_cmpgu_le_qb (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_CMPGDU_EQ_QB : +check_dspr2 (ctx); +gen_helper_cmpgu_eq_qb (t1, cpu_gpr[v1], cpu_gpr[v2]); +tcg_gen_mov_tl (cpu_gpr[ret], t1); +tcg_gen_andi_tl (cpu_dspctrl, cpu_dspctrl,0xF0FFFFFF ); +tcg_gen_shli_tl (t1, t1,24 ); +tcg_gen_or_tl (cpu_dspctrl, cpu_dspctrl, t1); +break ; +case OPC_CMPGDU_LT_QB : +check_dspr2 (ctx); +gen_helper_cmpgu_lt_qb (t1, cpu_gpr[v1], cpu_gpr[v2]); +tcg_gen_mov_tl (cpu_gpr[ret], t1); +tcg_gen_andi_tl (cpu_dspctrl, cpu_dspctrl,0xF0FFFFFF ); +tcg_gen_shli_tl (t1, t1,24 ); +tcg_gen_or_tl (cpu_dspctrl, cpu_dspctrl, t1); +break ; +case OPC_CMPGDU_LE_QB : +check_dspr2 (ctx); +gen_helper_cmpgu_le_qb (t1, cpu_gpr[v1], cpu_gpr[v2]); +tcg_gen_mov_tl (cpu_gpr[ret], t1); +tcg_gen_andi_tl (cpu_dspctrl, cpu_dspctrl,0xF0FFFFFF ); +tcg_gen_shli_tl (t1, t1,24 ); +tcg_gen_or_tl (cpu_dspctrl, cpu_dspctrl, t1); +break ; +case OPC_CMP_EQ_PH : +check_dsp (ctx); +gen_helper_cmp_eq_ph (cpu_gpr[v1], cpu_gpr[v2], cpu_env); +break ; +case OPC_CMP_LT_PH : +check_dsp (ctx); +gen_helper_cmp_lt_ph (cpu_gpr[v1], cpu_gpr[v2], cpu_env); +break ; +case OPC_CMP_LE_PH : +check_dsp (ctx); +gen_helper_cmp_le_ph (cpu_gpr[v1], cpu_gpr[v2], cpu_env); +break ; +case OPC_PICK_QB : +check_dsp (ctx); +gen_helper_pick_qb (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_PICK_PH : +check_dsp (ctx); +gen_helper_pick_ph (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_PACKRL_PH : +check_dsp (ctx); +gen_helper_packrl_ph (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; + } +break ; +#ifdef TARGET_MIPS64 +case OPC_CMPU_EQ_OB_DSP : +switch (op2) { +case OPC_CMP_EQ_PW : +check_dsp (ctx); +gen_helper_cmp_eq_pw (cpu_gpr[v1], cpu_gpr[v2], cpu_env); +break ; +case OPC_CMP_LT_PW : +check_dsp (ctx); +gen_helper_cmp_lt_pw (cpu_gpr[v1], cpu_gpr[v2], cpu_env); +break ; +case OPC_CMP_LE_PW : +check_dsp (ctx); +gen_helper_cmp_le_pw (cpu_gpr[v1], cpu_gpr[v2], cpu_env); +break ; +case OPC_CMP_EQ_QH : +check_dsp (ctx); +gen_helper_cmp_eq_qh (cpu_gpr[v1], cpu_gpr[v2], cpu_env); +break ; +case OPC_CMP_LT_QH : +check_dsp (ctx); +gen_helper_cmp_lt_qh (cpu_gpr[v1], cpu_gpr[v2], cpu_env); +break ; +case OPC_CMP_LE_QH : +check_dsp (ctx); +gen_helper_cmp_le_qh (cpu_gpr[v1], cpu_gpr[v2], cpu_env); +break ; +case OPC_CMPGDU_EQ_OB : +check_dspr2 (ctx); +gen_helper_cmpgdu_eq_ob (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_CMPGDU_LT_OB : +check_dspr2 (ctx); +gen_helper_cmpgdu_lt_ob (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_CMPGDU_LE_OB : +check_dspr2 (ctx); +gen_helper_cmpgdu_le_ob (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_CMPGU_EQ_OB : +check_dsp (ctx); +gen_helper_cmpgu_eq_ob (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2]); +break ; +case OPC_CMPGU_LT_OB : +check_dsp (ctx); +gen_helper_cmpgu_lt_ob (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2]); +break ; +case OPC_CMPGU_LE_OB : +check_dsp (ctx); +gen_helper_cmpgu_le_ob (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2]); +break ; +case OPC_CMPU_EQ_OB : +check_dsp (ctx); +gen_helper_cmpu_eq_ob (cpu_gpr[v1], cpu_gpr[v2], cpu_env); +break ; +case OPC_CMPU_LT_OB : +check_dsp (ctx); +gen_helper_cmpu_lt_ob (cpu_gpr[v1], cpu_gpr[v2], cpu_env); +break ; +case OPC_CMPU_LE_OB : +check_dsp (ctx); +gen_helper_cmpu_le_ob (cpu_gpr[v1], cpu_gpr[v2], cpu_env); +break ; +case OPC_PACKRL_PW : +check_dsp (ctx); +gen_helper_packrl_pw (cpu_gpr[ret], cpu_gpr[v1], cpu_gpr[v2]); +break ; +case OPC_PICK_OB : +check_dsp (ctx); +gen_helper_pick_ob (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_PICK_PW : +check_dsp (ctx); +gen_helper_pick_pw (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; +case OPC_PICK_QH : +check_dsp (ctx); +gen_helper_pick_qh (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[v2], cpu_env); +break ; + } +break ; +case OPC_DAPPEND_DSP : +switch (op2) { +case OPC_DAPPEND : +tcg_gen_movi_i32 (t0, v2); +gen_helper_dappend (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[ret], t0); +break ; +case OPC_PREPENDD : +tcg_gen_movi_i32 (t0, v2); +gen_helper_prependd (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[ret], t0); +break ; +case OPC_PREPENDW : +tcg_gen_movi_i32 (t0, v2); +gen_helper_prependw (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[ret], t0); +break ;
target-mips/translate.c static void gen_mipsdsp_bitinsn(CPUMIPSState *env, DisasContext *ctx, · line 14192
Quoted 10 lines
target-mips/translate.c +10
-0+case OPC_DBALIGN : +tcg_gen_movi_i32 (t0, v2); +gen_helper_dbalign (cpu_gpr[ret], cpu_gpr[v1], + cpu_gpr[ret], t0); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK DAPPEND" ); +generate_exception (ctx,EXCP_RI ); +break ; + }
In all the functions above, v1 or v2 can be the register 0.
Quoted 97 lines
target-mips/translate.c +63
-0+break ; +#endif + } + +tcg_temp_free_i32 (t0); +tcg_temp_free (t1); + + (void )opn;/* avoid a compiler warning */ +MIPS_DEBUG ("%s" , opn); +} +/* End MIPSDSP functions. */ static void decode_opc (CPUMIPSState *env,DisasContext *ctx,int *is_branch)@@ -14388,6 +14692,25 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)case OPC_PRECRQU_S_QB_PH :gen_mipsdsp_arith (ctx, op1, op2, rd, rs, rt);break ; +case OPC_CMPU_EQ_QB : +case OPC_CMPU_LT_QB : +case OPC_CMPU_LE_QB : +case OPC_CMP_EQ_PH : +case OPC_CMP_LT_PH : +case OPC_CMP_LE_PH : +gen_mipsdsp_add_cmp_pick (ctx, op1, op2, rd, rs, rt,0 ); +break ; +case OPC_CMPGU_EQ_QB : +case OPC_CMPGU_LT_QB : +case OPC_CMPGU_LE_QB : +case OPC_CMPGDU_EQ_QB : +case OPC_CMPGDU_LT_QB : +case OPC_CMPGDU_LE_QB : +case OPC_PICK_QB : +case OPC_PICK_PH : +case OPC_PACKRL_PH : +gen_mipsdsp_add_cmp_pick (ctx, op1, op2, rd, rs, rt,1 ); +break ;default :/* Invalid */ MIPS_INVAL ("MASK CMPU.EQ.QB" );generate_exception (ctx,EXCP_RI );@@ -14450,6 +14773,11 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)break ; }break ; +case OPC_APPEND_DSP : +check_dspr2 (ctx); + op2 =MASK_APPEND (ctx->opcode); +gen_mipsdsp_add_cmp_pick (ctx, op1, op2, rt, rs, rd,1 ); +break ;#if defined(TARGET_MIPS64 ) case OPC_DEXTM ... OPC_DEXT: case OPC_DINSM ... OPC_DINS:@@ -14560,12 +14888,40 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch)case OPC_PRECRQU_S_OB_QH :gen_mipsdsp_arith (ctx, op1, op2, rd, rs, rt);break ; +case OPC_CMPU_EQ_OB : +case OPC_CMPU_LT_OB : +case OPC_CMPU_LE_OB : +case OPC_CMP_EQ_QH : +case OPC_CMP_LT_QH : +case OPC_CMP_LE_QH : +case OPC_CMP_EQ_PW : +case OPC_CMP_LT_PW : +case OPC_CMP_LE_PW : +gen_mipsdsp_add_cmp_pick (ctx, op1, op2, rd, rs, rt,0 ); +break ; +case OPC_CMPGDU_EQ_OB : +case OPC_CMPGDU_LT_OB : +case OPC_CMPGDU_LE_OB : +case OPC_CMPGU_EQ_OB : +case OPC_CMPGU_LT_OB : +case OPC_CMPGU_LE_OB : +case OPC_PACKRL_PW : +case OPC_PICK_OB : +case OPC_PICK_PW : +case OPC_PICK_QH : +gen_mipsdsp_add_cmp_pick (ctx, op1, op2, rd, rs, rt,1 ); +break ;default :/* Invalid */ MIPS_INVAL ("MASK CMPU_EQ.OB" );generate_exception (ctx,EXCP_RI );break ; }break ; +case OPC_DAPPEND_DSP : +check_dspr2 (ctx); + op2 =MASK_DAPPEND (ctx->opcode); +gen_mipsdsp_add_cmp_pick (ctx, op1, op2, rt, rs, rd,1 ); +break ;case OPC_DPAQ_W_QH_DSP : op2 =MASK_DPAQ_W_QH (ctx->opcode);switch (op2) {Signature · 1 line
1.7.10.2 (Apple Git-33)
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v9 11/14 target-mips-ase-dsp: Add DSP accumulator instructions
In reply to Jia LiuAdd MIPS ASE DSP Accumulator and DSPControl Access instructions.
--- target-mips/dsp_helper.c | 609 ++++++++++++++++++++++++++++++++++++++++++++++ target-mips/helper.h | 35 +++ target-mips/translate.c | 340 ++++++++++++++++++++++++++ 3 files changed, 984 insertions(+)
target-mips/dsp_helper.c +609 -0
@@ -3476,6 +3476,615 @@ target_ulong helper_packrl_pw(target_ulong rs, target_ulong rt) }#endif +/** DSP Accumulator and DSPControl Access Sub-class insns **/ +target_ulong helper_extr_w (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +int32_t tempI; +int64_t tempDL[2 ]; + + shift = shift &0x0F ; + +mipsdsp_rndrashift_short_acc (tempDL, ac, shift, env); +if ((tempDL[1 ] !=0 || (tempDL[0 ] &MIPSDSP_LHI ) !=0 ) && + (tempDL[1 ] !=1 || (tempDL[0 ] &MIPSDSP_LHI ) !=MIPSDSP_LHI )) { +set_DSPControl_overflow_flag (1 ,23 , env); + } + + tempI = (tempDL[0 ] >>1 ) &MIPSDSP_LLO ; + + tempDL[0 ] +=1 ; +if (tempDL[0 ] ==0 ) { + tempDL[1 ] +=1 ; + } + +if ((!(tempDL[1 ] ==0 && (tempDL[0 ] &MIPSDSP_LHI ) ==0x00 )) && + (!(tempDL[1 ] ==1 && (tempDL[0 ] &MIPSDSP_LHI ) ==MIPSDSP_LHI ))) { +set_DSPControl_overflow_flag (1 ,23 , env); + } + +return (target_long )tempI; +} + +target_ulong helper_extr_r_w (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +int64_t tempDL[2 ]; + + shift = shift &0x0F ; + +mipsdsp_rndrashift_short_acc (tempDL, ac, shift, env); +if ((tempDL[1 ] !=0 || (tempDL[0 ] &MIPSDSP_LHI ) !=0 ) && + (tempDL[1 ] !=1 || (tempDL[0 ] &MIPSDSP_LHI ) !=MIPSDSP_LHI )) { +set_DSPControl_overflow_flag (1 ,23 , env); + } + + tempDL[0 ] +=1 ; +if (tempDL[0 ] ==0 ) { + tempDL[1 ] +=1 ; + } + +if ((tempDL[1 ] !=0 || (tempDL[0 ] &MIPSDSP_LHI ) !=0 ) && + (tempDL[1 ] !=1 && (tempDL[0 ] &MIPSDSP_LHI ) !=MIPSDSP_LHI )) { +set_DSPControl_overflow_flag (1 ,23 , env); + } + +return (target_long)(int32_t)(tempDL[0 ] >>1 ); +} + +target_ulong helper_extr_rs_w (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +int32_t tempI, temp64; +int64_t tempDL[2 ]; + + shift = shift &0x0F ; + +mipsdsp_rndrashift_short_acc (tempDL, ac, shift, env); +if ((tempDL[1 ] !=0 || (tempDL[0 ] &MIPSDSP_LHI ) !=0 ) && + (tempDL[1 ] !=1 || (tempDL[0 ] &MIPSDSP_LHI ) !=MIPSDSP_LHI )) { +set_DSPControl_overflow_flag (1 ,23 , env); + } + tempDL[0 ] +=1 ; +if (tempDL[0 ] ==0 ) { + tempDL[1 ] +=1 ; + } + tempI = tempDL[0 ] >>1 ; + +if ((tempDL[1 ] !=0 || (tempDL[0 ] &MIPSDSP_LHI ) !=0 ) && + (tempDL[1 ] !=1 || (tempDL[0 ] &MIPSDSP_LHI ) !=MIPSDSP_LHI )) { + temp64 = tempDL[1 ]; +if (temp64 ==0 ) { + tempI =0x7FFFFFFF ; + }else { + tempI =0x80000000 ; + } +set_DSPControl_overflow_flag (1 ,23 , env); + } + +return (target_long )tempI; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_dextr_w (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +uint64_t temp[3 ]; + + shift = shift &0x3F ; + +mipsdsp_rndrashift_acc (temp, ac, shift, env); + +return (int64_t )(int32_t )(temp[0 ] >>1 ); +} + +target_ulong helper_dextr_r_w (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +uint64_t temp[3 ]; +uint32_t temp128; + + shift = shift &0x3F ; +mipsdsp_rndrashift_acc (temp, ac, shift, env); + + temp[0 ] +=1 ; +if (temp[0 ] ==0 ) { + temp[1 ] +=1 ; +if (temp[1 ] ==0 ) { + temp[2 ] +=1 ; + } + } + + temp128 = temp[2 ] &0x01 ; + +if ((temp128 !=0 || temp[1 ] !=0 ) && + (temp128 !=1 || temp[1 ] != ~0ull )) { +set_DSPControl_overflow_flag (1 ,23 , env); + } + +return (int64_t )(int32_t )(temp[0 ] >>1 ); +} + +target_ulong helper_dextr_rs_w (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +uint64_t temp[3 ]; +uint32_t temp128; + + shift = shift &0x3F ; +mipsdsp_rndrashift_acc (temp, ac, shift, env); + + temp[0 ] +=1 ; +if (temp[0 ] ==0 ) { + temp[1 ] +=1 ; +if (temp[1 ] ==0 ) { + temp[2 ] +=1 ; + } + } + + temp128 = temp[2 ] &0x01 ; + +if ((temp128 !=0 || temp[1 ] !=0 ) && + (temp128 !=1 || temp[1 ] != ~0ull )) { +if (temp128 ==0 ) { + temp[0 ] =0x0FFFFFFFF ; + }else { + temp[0 ] =0x0100000000 ; + } +set_DSPControl_overflow_flag (1 ,23 , env); + } + +return (int64_t )(int32_t )(temp[0 ] >>1 ); +} + +target_ulong helper_dextr_l (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +uint64_t temp[3 ]; +target_ulong result; + + shift = shift &0x3F ; + +mipsdsp_rndrashift_acc (temp, ac, shift, env); + result = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); + +return result; +} + +target_ulong helper_dextr_r_l (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +uint64_t temp[3 ]; +uint32_t temp128; +target_ulong result; + + shift = shift &0x3F ; +mipsdsp_rndrashift_acc (temp, ac, shift, env); + + temp[0 ] +=1 ; +if (temp[0 ] ==0 ) { + temp[1 ] +=1 ; +if (temp[1 ] ==0 ) { + temp[2 ] +=1 ; + } + } + + temp128 = temp[2 ] &0x01 ; + +if ((temp128 !=0 || temp[1 ] !=0 ) && + (temp128 !=1 || temp[1 ] != ~0ull )) { +set_DSPControl_overflow_flag (1 ,23 , env); + } + + result = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); + +return result; +} + +target_ulong helper_dextr_rs_l (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +uint64_t temp[3 ]; +uint32_t temp128; +target_ulong result; + + shift = shift &0x3F ; +mipsdsp_rndrashift_acc (temp, ac, shift, env); + + temp[0 ] +=1 ; +if (temp[0 ] ==0 ) { + temp[1 ] +=1 ; +if (temp[1 ] ==0 ) { + temp[2 ] +=1 ; + } + } + + temp128 = temp[2 ] &0x01 ; + +if ((temp128 !=0 || temp[1 ] !=0 ) && + (temp128 !=1 || temp[1 ] != ~0ull )) { +if (temp128 ==0 ) { + temp[1 ] &=0xFFFFFFFFFFFFFFFEull ; + temp[0 ] |=0xFFFFFFFFFFFFFFFEull ; + }else { + temp[1 ] |=0x01 ; + temp[0 ] &=0x01 ; + } +set_DSPControl_overflow_flag (1 ,23 , env); + } + result = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); + +return result; +} +#endif + +target_ulong helper_extr_s_h (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +int64_t temp; + + shift = shift &0x0F ; + + temp =mipsdsp_rashift_short_acc (ac, shift, env); +if (temp >0x0000000000007FFFull ) { + temp =0x00007FFF ; +set_DSPControl_overflow_flag (1 ,23 , env); + }else if (temp <0xFFFFFFFFFFFF8000ull ) { + temp =0xFFFF8000 ; +set_DSPControl_overflow_flag (1 ,23 , env); + } + +return (target_long)(int32_t)(temp &0xFFFFFFFF ); +} + + +#if defined(TARGET_MIPS64 ) +target_ulong helper_dextr_s_h (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +int64_t temp[2 ]; +uint32_t temp127; + + shift = shift &0x1F ; + +mipsdsp_rashift_acc ((uint64_t *)temp, ac, shift, env); + + temp127 = (temp[1 ] >>63 ) &0x01 ; + +if ((temp127 ==0 ) && (temp[1 ] >0 || temp[0 ] >32767 )) { + temp[0 ] &=0xFFFF0000 ; + temp[0 ] |=0x00007FFF ; +set_DSPControl_overflow_flag (1 ,23 , env); + }else if ((temp127 ==1 ) && + (temp[1 ] <0xFFFFFFFFFFFFFFFFll + || temp[0 ] <0xFFFFFFFFFFFF1000ll )) { + temp[0 ] &=0xFFFF0000 ; + temp[0 ] |=0x00008000 ; +set_DSPControl_overflow_flag (1 ,23 , env); + } + +return (int64_t )(int16_t )(temp[0 ] &MIPSDSP_LO ); +} + +#endif + +target_ulong helper_extp (target_ulong ac,target_ulong size,CPUMIPSState *env) +{ +int32_t start_pos; +int sub; +uint32_t temp; +uint64_t acc; + + size = size &0x1F ; + + temp =0 ; + start_pos =get_DSPControl_pos (env); + sub = start_pos - (size +1 ); +if (sub >=-1 ) { + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + temp = (acc >> (start_pos - size)) & + (((uint32_t )0x01 << (size +1 )) -1 ); +set_DSPControl_efi (0 , env); + }else { +set_DSPControl_efi (1 , env); + } + +return (target_ulong )temp; +} + +target_ulong helper_extpdp (target_ulong ac,target_ulong size, +CPUMIPSState *env) +{ +int32_t start_pos; +int sub; +uint32_t temp; +uint64_t acc; + + size = size &0x1F ; + temp =0 ; + start_pos =get_DSPControl_pos (env); + sub = start_pos - (size +1 ); +if (sub >=-1 ) { + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + temp = (acc >> (start_pos - size)) & + (((uint32_t )0x01 << (size +1 )) -1 ); + +set_DSPControl_pos (start_pos - (size +1 ), env); +set_DSPControl_efi (0 , env); + }else { +set_DSPControl_efi (1 , env); + } + +return (target_ulong )temp; +} + + +#if defined(TARGET_MIPS64 ) +target_ulong helper_dextp (target_ulong ac,target_ulong size,CPUMIPSState *env) +{ +int start_pos; +int len; +int sub; +uint64_t tempB, tempA; +uint64_t temp; + + temp =0 ; + + size = size &0x3F ; + start_pos =get_DSPControl_pos (env); + len = start_pos - size; + tempB = env->active_tc.HI[ac]; + tempA = env->active_tc.LO[ac]; + + sub = start_pos - (size +1 ); + +if (sub >=-1 ) { + temp = (tempB << (64 - len)) | (tempA >> len); + temp = temp & ((0x01 << (size +1 )) -1 ); +set_DSPControl_efi (0 , env); + }else { +set_DSPControl_efi (1 , env); + } + +return temp; +} + +target_ulong helper_dextpdp (target_ulong ac,target_ulong size, +CPUMIPSState *env) +{ +int start_pos; +int len; +int sub; +uint64_t tempB, tempA; +uint64_t temp; + + temp =0 ; + size = size &0x3F ; + start_pos =get_DSPControl_pos (env); + len = start_pos - size; + tempB = env->active_tc.HI[ac]; + tempA = env->active_tc.LO[ac]; + + sub = start_pos - (size +1 ); + +if (sub >=-1 ) { + temp = (tempB << (64 - len)) | (tempA >> len); + temp = temp & ((0x01 << (size +1 )) -1 ); +set_DSPControl_pos (sub, env); +set_DSPControl_efi (0 , env); + }else { +set_DSPControl_efi (1 , env); + } + +return temp; +} + +#endif + +void helper_shilo (target_ulong ac,target_ulong rs,CPUMIPSState *env) +{ +int8_t rs5_0; +uint64_t temp, acc; + + rs5_0 = rs &0x3F ; + rs5_0 = (int8_t )(rs5_0 <<2 ) >>2 ; + rs5_0 =MIPSDSP_ABS (rs5_0); + acc = (((uint64_t )env->active_tc.HI[ac] <<32 ) &MIPSDSP_LHI ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); +if (rs5_0 ==0 ) { + temp = acc; + }else { +if (rs5_0 >0 ) { + temp = acc >> rs5_0; + }else { + temp = acc << rs5_0; + } + } + + env->active_tc.HI[ac] = (target_ulong)(int32_t)((temp &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_ulong)(int32_t)(temp &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dshilo (target_ulong shift,target_ulong ac,CPUMIPSState *env) +{ +int8_t shift_t; +uint64_t tempB, tempA; + + shift_t = (uint8_t )(shift <<1 ) >>1 ; + shift_t =MIPSDSP_ABS (shift_t); + + tempB = env->active_tc.HI[ac]; + tempA = env->active_tc.LO[ac]; + +if (shift_t !=0 ) { +if (shift_t >=0 ) { + tempA = (tempB << (64 - shift)) | (tempA >> shift); + tempB = tempB >> shift; + }else { + tempB = (tempB << shift) | (tempA >> (64 - shift)); + tempA = tempA << shift; + } + } + + env->active_tc.HI[ac] = tempB; + env->active_tc.LO[ac] = tempA; +} + +#endif +void helper_mthlip (target_ulong ac,target_ulong rs,CPUMIPSState *env) +{ +int32_t tempA, tempB, pos; + + tempA = rs; + tempB = env->active_tc.LO[ac]; + env->active_tc.HI[ac] = (target_long )tempB; + env->active_tc.LO[ac] = (target_long )tempA; + pos =get_DSPControl_pos (env); + +if (pos >32 ) { +return ; + }else { +set_DSPControl_pos (pos +32 , env); + } +} + +#if defined(TARGET_MIPS64 ) +void helper_dmthlip (target_ulong rs,target_ulong ac,CPUMIPSState *env) +{ +uint8_t ac_t; +uint8_t pos; +uint64_t tempB, tempA; + + ac_t = ac &0x3 ; + + tempA = rs; + tempB = env->active_tc.LO[ac_t]; + + env->active_tc.HI[ac_t] = tempB; + env->active_tc.LO[ac_t] = tempA; + + pos =get_DSPControl_pos (env); + +if (pos <=64 ) { + pos = pos +64 ; +set_DSPControl_pos (pos, env); + } +} +#endif + +void helper_wrdsp (target_ulong rs,target_ulong mask_num,CPUMIPSState *env) +{ +uint8_t mask[6 ]; +uint8_t i; +uint32_t newbits, overwrite; +target_ulong dsp; + + newbits =0x00 ; + overwrite =0xFFFFFFFF ; + dsp = env->active_tc.DSPControl; + +for (i =0 ; i <6 ; i++) { + mask[i] = (mask_num >> i) &0x01 ; + } + +if (mask[0 ] ==1 ) { +#if defined(TARGET_MIPS64 ) + overwrite &=0xFFFFFF80 ; + newbits &=0xFFFFFF80 ; + newbits |=0x0000007F & rs; +#else + overwrite &=0xFFFFFFC0 ; + newbits &=0xFFFFFFC0 ; + newbits |=0x0000003F & rs; +#endif + } + +if (mask[1 ] ==1 ) { + overwrite &=0xFFFFE07F ; + newbits &=0xFFFFE07F ; + newbits |=0x00001F80 & rs; + } + +if (mask[2 ] ==1 ) { + overwrite &=0xFFFFDFFF ; + newbits &=0xFFFFDFFF ; + newbits |=0x00002000 & rs; + } + +if (mask[3 ] ==1 ) { + overwrite &=0xFF00FFFF ; + newbits &=0xFF00FFFF ; + newbits |=0x00FF0000 & rs; + } + +if (mask[4 ] ==1 ) { + overwrite &=0x00FFFFFF ; + newbits &=0x00FFFFFF ; + newbits |=0xFF000000 & rs; + } + +if (mask[5 ] ==1 ) { + overwrite &=0xFFFFBFFF ; + newbits &=0xFFFFBFFF ; + newbits |=0x00004000 & rs; + } + + dsp = dsp & overwrite; + dsp = dsp | newbits; + env->active_tc.DSPControl = dsp; +} + +target_ulong helper_rddsp (target_ulong masknum,CPUMIPSState *env) +{ +uint8_t mask[6 ]; +uint32_t ruler, i; +target_ulong temp; +target_ulong dsp; + + ruler =0x01 ; +for (i =0 ; i <6 ; i++) { + mask[i] = (masknum & ruler) >> i ; + ruler = ruler <<1 ; + } + + temp =0x00 ; + dsp = env->active_tc.DSPControl; + +if (mask[0 ] ==1 ) { +#if defined(TARGET_MIPS64 ) + temp |= dsp &0x7F ; +#else + temp |= dsp &0x3F ; +#endif + } + +if (mask[1 ] ==1 ) { + temp |= dsp &0x1F80 ; + } + +if (mask[2 ] ==1 ) { + temp |= dsp &0x2000 ; + } + +if (mask[3 ] ==1 ) { + temp |= dsp &0x00FF0000 ; + } + +if (mask[4 ] ==1 ) { + temp |= dsp &0xFF000000 ; + } + +if (mask[5 ] ==1 ) { + temp |= dsp &0x4000 ; + } + +return temp; +} + +#undef MIPSDSP_LHI#undef MIPSDSP_LLO#undef MIPSDSP_HI
target-mips/helper.h +35 -0
@@ -676,4 +676,39 @@ DEF_HELPER_FLAGS_2(packrl_ph, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) DEF_HELPER_FLAGS_2(packrl_pw, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl)#endif +/* DSP Accumulator and DSPControl Access Sub-class insns */ +DEF_HELPER_FLAGS_3(extr_w, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(extr_r_w, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(extr_rs_w, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(dextr_w, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(dextr_r_w, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(dextr_rs_w, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(dextr_l, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(dextr_r_l, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(dextr_rs_l, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(extr_s_h, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(dextr_s_h, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(extp, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(extpdp, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(dextp, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(dextpdp, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(shilo, 0, void, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(dshilo, 0, void, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(mthlip, 0, void, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(dmthlip, 0, void, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(wrdsp, 0, void, tl, tl, env) +DEF_HELPER_FLAGS_2(rddsp, 0, tl, tl, env) + + +#include "def-helper.h"
target-mips/translate.c +340 -0
376 lines not on this page · raw message
Signature · 1 line
1.7.10.2 (Apple Git-33)
Re: [Qemu-devel] [PATCH v9 11/14] target-mips-ase-dsp: Add DSP accumulator instructions
Quoted 954 lines · Jia Liu
Add MIPS ASE DSP Accumulator and DSPControl Access instructions.
Signed-off-by Jia Liu <[email protected]>--- target-mips/dsp_helper.c | 609 ++++++++++++++++++++++++++++++++++++++++++++++ target-mips/helper.h | 35 +++ target-mips/translate.c | 340 ++++++++++++++++++++++++++ 3 files changed, 984 insertions(+)target-mips/dsp_helper.c +609
-0@@ -3476,6 +3476,615 @@ target_ulong helper_packrl_pw(target_ulong rs, target_ulong rt) }#endif +/** DSP Accumulator and DSPControl Access Sub-class insns **/ +target_ulong helper_extr_w (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +int32_t tempI; +int64_t tempDL[2 ]; + + shift = shift &0x0F ; + +mipsdsp_rndrashift_short_acc (tempDL, ac, shift, env); +if ((tempDL[1 ] !=0 || (tempDL[0 ] &MIPSDSP_LHI ) !=0 ) && + (tempDL[1 ] !=1 || (tempDL[0 ] &MIPSDSP_LHI ) !=MIPSDSP_LHI )) { +set_DSPControl_overflow_flag (1 ,23 , env); + } + + tempI = (tempDL[0 ] >>1 ) &MIPSDSP_LLO ; + + tempDL[0 ] +=1 ; +if (tempDL[0 ] ==0 ) { + tempDL[1 ] +=1 ; + } + +if ((!(tempDL[1 ] ==0 && (tempDL[0 ] &MIPSDSP_LHI ) ==0x00 )) && + (!(tempDL[1 ] ==1 && (tempDL[0 ] &MIPSDSP_LHI ) ==MIPSDSP_LHI ))) { +set_DSPControl_overflow_flag (1 ,23 , env); + } + +return (target_long )tempI; +} + +target_ulong helper_extr_r_w (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +int64_t tempDL[2 ]; + + shift = shift &0x0F ; + +mipsdsp_rndrashift_short_acc (tempDL, ac, shift, env); +if ((tempDL[1 ] !=0 || (tempDL[0 ] &MIPSDSP_LHI ) !=0 ) && + (tempDL[1 ] !=1 || (tempDL[0 ] &MIPSDSP_LHI ) !=MIPSDSP_LHI )) { +set_DSPControl_overflow_flag (1 ,23 , env); + } + + tempDL[0 ] +=1 ; +if (tempDL[0 ] ==0 ) { + tempDL[1 ] +=1 ; + } + +if ((tempDL[1 ] !=0 || (tempDL[0 ] &MIPSDSP_LHI ) !=0 ) && + (tempDL[1 ] !=1 && (tempDL[0 ] &MIPSDSP_LHI ) !=MIPSDSP_LHI )) { +set_DSPControl_overflow_flag (1 ,23 , env); + } + +return (target_long)(int32_t)(tempDL[0 ] >>1 ); +} + +target_ulong helper_extr_rs_w (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +int32_t tempI, temp64; +int64_t tempDL[2 ]; + + shift = shift &0x0F ; + +mipsdsp_rndrashift_short_acc (tempDL, ac, shift, env); +if ((tempDL[1 ] !=0 || (tempDL[0 ] &MIPSDSP_LHI ) !=0 ) && + (tempDL[1 ] !=1 || (tempDL[0 ] &MIPSDSP_LHI ) !=MIPSDSP_LHI )) { +set_DSPControl_overflow_flag (1 ,23 , env); + } + tempDL[0 ] +=1 ; +if (tempDL[0 ] ==0 ) { + tempDL[1 ] +=1 ; + } + tempI = tempDL[0 ] >>1 ; + +if ((tempDL[1 ] !=0 || (tempDL[0 ] &MIPSDSP_LHI ) !=0 ) && + (tempDL[1 ] !=1 || (tempDL[0 ] &MIPSDSP_LHI ) !=MIPSDSP_LHI )) { + temp64 = tempDL[1 ]; +if (temp64 ==0 ) { + tempI =0x7FFFFFFF ; + }else { + tempI =0x80000000 ; + } +set_DSPControl_overflow_flag (1 ,23 , env); + } + +return (target_long )tempI; +} + +#if defined(TARGET_MIPS64 ) +target_ulong helper_dextr_w (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +uint64_t temp[3 ]; + + shift = shift &0x3F ; + +mipsdsp_rndrashift_acc (temp, ac, shift, env); + +return (int64_t )(int32_t )(temp[0 ] >>1 ); +} + +target_ulong helper_dextr_r_w (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +uint64_t temp[3 ]; +uint32_t temp128; + + shift = shift &0x3F ; +mipsdsp_rndrashift_acc (temp, ac, shift, env); + + temp[0 ] +=1 ; +if (temp[0 ] ==0 ) { + temp[1 ] +=1 ; +if (temp[1 ] ==0 ) { + temp[2 ] +=1 ; + } + } + + temp128 = temp[2 ] &0x01 ; + +if ((temp128 !=0 || temp[1 ] !=0 ) && + (temp128 !=1 || temp[1 ] != ~0ull )) { +set_DSPControl_overflow_flag (1 ,23 , env); + } + +return (int64_t )(int32_t )(temp[0 ] >>1 ); +} + +target_ulong helper_dextr_rs_w (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +uint64_t temp[3 ]; +uint32_t temp128; + + shift = shift &0x3F ; +mipsdsp_rndrashift_acc (temp, ac, shift, env); + + temp[0 ] +=1 ; +if (temp[0 ] ==0 ) { + temp[1 ] +=1 ; +if (temp[1 ] ==0 ) { + temp[2 ] +=1 ; + } + } + + temp128 = temp[2 ] &0x01 ; + +if ((temp128 !=0 || temp[1 ] !=0 ) && + (temp128 !=1 || temp[1 ] != ~0ull )) { +if (temp128 ==0 ) { + temp[0 ] =0x0FFFFFFFF ; + }else { + temp[0 ] =0x0100000000 ; + } +set_DSPControl_overflow_flag (1 ,23 , env); + } + +return (int64_t )(int32_t )(temp[0 ] >>1 ); +} + +target_ulong helper_dextr_l (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +uint64_t temp[3 ]; +target_ulong result; + + shift = shift &0x3F ; + +mipsdsp_rndrashift_acc (temp, ac, shift, env); + result = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); + +return result; +} + +target_ulong helper_dextr_r_l (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +uint64_t temp[3 ]; +uint32_t temp128; +target_ulong result; + + shift = shift &0x3F ; +mipsdsp_rndrashift_acc (temp, ac, shift, env); + + temp[0 ] +=1 ; +if (temp[0 ] ==0 ) { + temp[1 ] +=1 ; +if (temp[1 ] ==0 ) { + temp[2 ] +=1 ; + } + } + + temp128 = temp[2 ] &0x01 ; + +if ((temp128 !=0 || temp[1 ] !=0 ) && + (temp128 !=1 || temp[1 ] != ~0ull )) { +set_DSPControl_overflow_flag (1 ,23 , env); + } + + result = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); + +return result; +} + +target_ulong helper_dextr_rs_l (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +uint64_t temp[3 ]; +uint32_t temp128; +target_ulong result; + + shift = shift &0x3F ; +mipsdsp_rndrashift_acc (temp, ac, shift, env); + + temp[0 ] +=1 ; +if (temp[0 ] ==0 ) { + temp[1 ] +=1 ; +if (temp[1 ] ==0 ) { + temp[2 ] +=1 ; + } + } + + temp128 = temp[2 ] &0x01 ; + +if ((temp128 !=0 || temp[1 ] !=0 ) && + (temp128 !=1 || temp[1 ] != ~0ull )) { +if (temp128 ==0 ) { + temp[1 ] &=0xFFFFFFFFFFFFFFFEull ; + temp[0 ] |=0xFFFFFFFFFFFFFFFEull ; + }else { + temp[1 ] |=0x01 ; + temp[0 ] &=0x01 ; + } +set_DSPControl_overflow_flag (1 ,23 , env); + } + result = (temp[1 ] <<63 ) | (temp[0 ] >>1 ); + +return result; +} +#endif + +target_ulong helper_extr_s_h (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +int64_t temp; + + shift = shift &0x0F ; + + temp =mipsdsp_rashift_short_acc (ac, shift, env); +if (temp >0x0000000000007FFFull ) { + temp =0x00007FFF ; +set_DSPControl_overflow_flag (1 ,23 , env); + }else if (temp <0xFFFFFFFFFFFF8000ull ) { + temp =0xFFFF8000 ; +set_DSPControl_overflow_flag (1 ,23 , env); + } + +return (target_long)(int32_t)(temp &0xFFFFFFFF ); +} + + +#if defined(TARGET_MIPS64 ) +target_ulong helper_dextr_s_h (target_ulong ac,target_ulong shift, +CPUMIPSState *env) +{ +int64_t temp[2 ]; +uint32_t temp127; + + shift = shift &0x1F ; + +mipsdsp_rashift_acc ((uint64_t *)temp, ac, shift, env); + + temp127 = (temp[1 ] >>63 ) &0x01 ; + +if ((temp127 ==0 ) && (temp[1 ] >0 || temp[0 ] >32767 )) { + temp[0 ] &=0xFFFF0000 ; + temp[0 ] |=0x00007FFF ; +set_DSPControl_overflow_flag (1 ,23 , env); + }else if ((temp127 ==1 ) && + (temp[1 ] <0xFFFFFFFFFFFFFFFFll + || temp[0 ] <0xFFFFFFFFFFFF1000ll )) { + temp[0 ] &=0xFFFF0000 ; + temp[0 ] |=0x00008000 ; +set_DSPControl_overflow_flag (1 ,23 , env); + } + +return (int64_t )(int16_t )(temp[0 ] &MIPSDSP_LO ); +} + +#endif + +target_ulong helper_extp (target_ulong ac,target_ulong size,CPUMIPSState *env) +{ +int32_t start_pos; +int sub; +uint32_t temp; +uint64_t acc; + + size = size &0x1F ; + + temp =0 ; + start_pos =get_DSPControl_pos (env); + sub = start_pos - (size +1 ); +if (sub >=-1 ) { + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + temp = (acc >> (start_pos - size)) & + (((uint32_t )0x01 << (size +1 )) -1 ); +set_DSPControl_efi (0 , env); + }else { +set_DSPControl_efi (1 , env); + } + +return (target_ulong )temp; +} + +target_ulong helper_extpdp (target_ulong ac,target_ulong size, +CPUMIPSState *env) +{ +int32_t start_pos; +int sub; +uint32_t temp; +uint64_t acc; + + size = size &0x1F ; + temp =0 ; + start_pos =get_DSPControl_pos (env); + sub = start_pos - (size +1 ); +if (sub >=-1 ) { + acc = ((uint64_t )env->active_tc.HI[ac] <<32 ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); + temp = (acc >> (start_pos - size)) & + (((uint32_t )0x01 << (size +1 )) -1 ); + +set_DSPControl_pos (start_pos - (size +1 ), env); +set_DSPControl_efi (0 , env); + }else { +set_DSPControl_efi (1 , env); + } + +return (target_ulong )temp; +} + + +#if defined(TARGET_MIPS64 ) +target_ulong helper_dextp (target_ulong ac,target_ulong size,CPUMIPSState *env) +{ +int start_pos; +int len; +int sub; +uint64_t tempB, tempA; +uint64_t temp; + + temp =0 ; + + size = size &0x3F ; + start_pos =get_DSPControl_pos (env); + len = start_pos - size; + tempB = env->active_tc.HI[ac]; + tempA = env->active_tc.LO[ac]; + + sub = start_pos - (size +1 ); + +if (sub >=-1 ) { + temp = (tempB << (64 - len)) | (tempA >> len); + temp = temp & ((0x01 << (size +1 )) -1 ); +set_DSPControl_efi (0 , env); + }else { +set_DSPControl_efi (1 , env); + } + +return temp; +} + +target_ulong helper_dextpdp (target_ulong ac,target_ulong size, +CPUMIPSState *env) +{ +int start_pos; +int len; +int sub; +uint64_t tempB, tempA; +uint64_t temp; + + temp =0 ; + size = size &0x3F ; + start_pos =get_DSPControl_pos (env); + len = start_pos - size; + tempB = env->active_tc.HI[ac]; + tempA = env->active_tc.LO[ac]; + + sub = start_pos - (size +1 ); + +if (sub >=-1 ) { + temp = (tempB << (64 - len)) | (tempA >> len); + temp = temp & ((0x01 << (size +1 )) -1 ); +set_DSPControl_pos (sub, env); +set_DSPControl_efi (0 , env); + }else { +set_DSPControl_efi (1 , env); + } + +return temp; +} + +#endif + +void helper_shilo (target_ulong ac,target_ulong rs,CPUMIPSState *env) +{ +int8_t rs5_0; +uint64_t temp, acc; + + rs5_0 = rs &0x3F ; + rs5_0 = (int8_t )(rs5_0 <<2 ) >>2 ; + rs5_0 =MIPSDSP_ABS (rs5_0); + acc = (((uint64_t )env->active_tc.HI[ac] <<32 ) &MIPSDSP_LHI ) | + ((uint64_t )env->active_tc.LO[ac] &MIPSDSP_LLO ); +if (rs5_0 ==0 ) { + temp = acc; + }else { +if (rs5_0 >0 ) { + temp = acc >> rs5_0; + }else { + temp = acc << rs5_0; + } + } + + env->active_tc.HI[ac] = (target_ulong)(int32_t)((temp &MIPSDSP_LHI ) >>32 ); + env->active_tc.LO[ac] = (target_ulong)(int32_t)(temp &MIPSDSP_LLO ); +} + +#if defined(TARGET_MIPS64 ) +void helper_dshilo (target_ulong shift,target_ulong ac,CPUMIPSState *env) +{ +int8_t shift_t; +uint64_t tempB, tempA; + + shift_t = (uint8_t )(shift <<1 ) >>1 ; + shift_t =MIPSDSP_ABS (shift_t); + + tempB = env->active_tc.HI[ac]; + tempA = env->active_tc.LO[ac]; + +if (shift_t !=0 ) { +if (shift_t >=0 ) { + tempA = (tempB << (64 - shift)) | (tempA >> shift); + tempB = tempB >> shift; + }else { + tempB = (tempB << shift) | (tempA >> (64 - shift)); + tempA = tempA << shift; + } + } + + env->active_tc.HI[ac] = tempB; + env->active_tc.LO[ac] = tempA; +} + +#endif +void helper_mthlip (target_ulong ac,target_ulong rs,CPUMIPSState *env) +{ +int32_t tempA, tempB, pos; + + tempA = rs; + tempB = env->active_tc.LO[ac]; + env->active_tc.HI[ac] = (target_long )tempB; + env->active_tc.LO[ac] = (target_long )tempA; + pos =get_DSPControl_pos (env); + +if (pos >32 ) { +return ; + }else { +set_DSPControl_pos (pos +32 , env); + } +} + +#if defined(TARGET_MIPS64 ) +void helper_dmthlip (target_ulong rs,target_ulong ac,CPUMIPSState *env) +{ +uint8_t ac_t; +uint8_t pos; +uint64_t tempB, tempA; + + ac_t = ac &0x3 ; + + tempA = rs; + tempB = env->active_tc.LO[ac_t]; + + env->active_tc.HI[ac_t] = tempB; + env->active_tc.LO[ac_t] = tempA; + + pos =get_DSPControl_pos (env); + +if (pos <=64 ) { + pos = pos +64 ; +set_DSPControl_pos (pos, env); + } +} +#endif + +void helper_wrdsp (target_ulong rs,target_ulong mask_num,CPUMIPSState *env) +{ +uint8_t mask[6 ]; +uint8_t i; +uint32_t newbits, overwrite; +target_ulong dsp; + + newbits =0x00 ; + overwrite =0xFFFFFFFF ; + dsp = env->active_tc.DSPControl; + +for (i =0 ; i <6 ; i++) { + mask[i] = (mask_num >> i) &0x01 ; + } + +if (mask[0 ] ==1 ) { +#if defined(TARGET_MIPS64 ) + overwrite &=0xFFFFFF80 ; + newbits &=0xFFFFFF80 ; + newbits |=0x0000007F & rs; +#else + overwrite &=0xFFFFFFC0 ; + newbits &=0xFFFFFFC0 ; + newbits |=0x0000003F & rs; +#endif + } + +if (mask[1 ] ==1 ) { + overwrite &=0xFFFFE07F ; + newbits &=0xFFFFE07F ; + newbits |=0x00001F80 & rs; + } + +if (mask[2 ] ==1 ) { + overwrite &=0xFFFFDFFF ; + newbits &=0xFFFFDFFF ; + newbits |=0x00002000 & rs; + } + +if (mask[3 ] ==1 ) { + overwrite &=0xFF00FFFF ; + newbits &=0xFF00FFFF ; + newbits |=0x00FF0000 & rs; + } + +if (mask[4 ] ==1 ) { + overwrite &=0x00FFFFFF ; + newbits &=0x00FFFFFF ; + newbits |=0xFF000000 & rs; + } + +if (mask[5 ] ==1 ) { + overwrite &=0xFFFFBFFF ; + newbits &=0xFFFFBFFF ; + newbits |=0x00004000 & rs; + } + + dsp = dsp & overwrite; + dsp = dsp | newbits; + env->active_tc.DSPControl = dsp; +} + +target_ulong helper_rddsp (target_ulong masknum,CPUMIPSState *env) +{ +uint8_t mask[6 ]; +uint32_t ruler, i; +target_ulong temp; +target_ulong dsp; + + ruler =0x01 ; +for (i =0 ; i <6 ; i++) { + mask[i] = (masknum & ruler) >> i ; + ruler = ruler <<1 ; + } + + temp =0x00 ; + dsp = env->active_tc.DSPControl; + +if (mask[0 ] ==1 ) { +#if defined(TARGET_MIPS64 ) + temp |= dsp &0x7F ; +#else + temp |= dsp &0x3F ; +#endif + } + +if (mask[1 ] ==1 ) { + temp |= dsp &0x1F80 ; + } + +if (mask[2 ] ==1 ) { + temp |= dsp &0x2000 ; + } + +if (mask[3 ] ==1 ) { + temp |= dsp &0x00FF0000 ; + } + +if (mask[4 ] ==1 ) { + temp |= dsp &0xFF000000 ; + } + +if (mask[5 ] ==1 ) { + temp |= dsp &0x4000 ; + } + +return temp; +} + +#undef MIPSDSP_LHI#undef MIPSDSP_LLO#undef MIPSDSP_HItarget-mips/helper.h +35
-0@@ -676,4 +676,39 @@ DEF_HELPER_FLAGS_2(packrl_ph, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl) DEF_HELPER_FLAGS_2(packrl_pw, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl, tl)#endif +/* DSP Accumulator and DSPControl Access Sub-class insns */ +DEF_HELPER_FLAGS_3(extr_w, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(extr_r_w, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(extr_rs_w, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(dextr_w, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(dextr_r_w, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(dextr_rs_w, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(dextr_l, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(dextr_r_l, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(dextr_rs_l, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(extr_s_h, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(dextr_s_h, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(extp, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(extpdp, 0, tl, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(dextp, 0, tl, tl, tl, env) +DEF_HELPER_FLAGS_3(dextpdp, 0, tl, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(shilo, 0, void, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(dshilo, 0, void, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(mthlip, 0, void, tl, tl, env) +#if defined(TARGET_MIPS64 ) +DEF_HELPER_FLAGS_3(dmthlip, 0, void, tl, tl, env) +#endif +DEF_HELPER_FLAGS_3(wrdsp, 0, void, tl, tl, env) +DEF_HELPER_FLAGS_2(rddsp, 0, tl, tl, env) + + +#include "def-helper.h" target-mips/translate.c +252
-0@@ -353,6 +353,11 @@ enum {#if defined(TARGET_MIPS64 ) OPC_DAPPEND_DSP = 0x35 | OPC_SPECIAL3, #endif + /* MIPS DSP Accumulator and DSPControl Access Sub-class */ + OPC_EXTR_W_DSP = 0x38 | OPC_SPECIAL3, +#if defined(TARGET_MIPS64) + OPC_DEXTR_W_DSP = 0x3C | OPC_SPECIAL3, +#endif };/* BSHFL opcodes */ @@ -564,6 +569,30 @@ enum { OPC_BALIGN = (0x10 << 6) | OPC_APPEND_DSP, }; +#define MASK_EXTR_W (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* MIPS DSP Accumulator and DSPControl Access Sub-class */ +OPC_EXTR_W = (0x00 <<6 ) |OPC_EXTR_W_DSP , +OPC_EXTR_R_W = (0x04 <<6 ) |OPC_EXTR_W_DSP , +OPC_EXTR_RS_W = (0x06 <<6 ) |OPC_EXTR_W_DSP , +OPC_EXTR_S_H = (0x0E <<6 ) |OPC_EXTR_W_DSP , +OPC_EXTRV_S_H = (0x0F <<6 ) |OPC_EXTR_W_DSP , +OPC_EXTRV_W = (0x01 <<6 ) |OPC_EXTR_W_DSP , +OPC_EXTRV_R_W = (0x05 <<6 ) |OPC_EXTR_W_DSP , +OPC_EXTRV_RS_W = (0x07 <<6 ) |OPC_EXTR_W_DSP , +OPC_EXTP = (0x02 <<6 ) |OPC_EXTR_W_DSP , +OPC_EXTPV = (0x03 <<6 ) |OPC_EXTR_W_DSP , +OPC_EXTPDP = (0x0A <<6 ) |OPC_EXTR_W_DSP , +OPC_EXTPDPV = (0x0B <<6 ) |OPC_EXTR_W_DSP , +OPC_SHILO = (0x1A <<6 ) |OPC_EXTR_W_DSP , +OPC_SHILOV = (0x1B <<6 ) |OPC_EXTR_W_DSP , +OPC_MTHLIP = (0x1F <<6 ) |OPC_EXTR_W_DSP , +OPC_WRDSP = (0x13 <<6 ) |OPC_EXTR_W_DSP , +OPC_RDDSP = (0x12 <<6 ) |OPC_EXTR_W_DSP , +}; + + +#if defined(TARGET_MIPS64 )#define MASK_ABSQ_S_QH (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) enum {@@ -676,6 +705,32 @@ enum {#endif #if defined(TARGET_MIPS64 ) +#define MASK_DEXTR_W (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6))) +enum { +/* MIPS DSP Accumulator and DSPControl Access Sub-class */ +OPC_DMTHLIP = (0x1F <<6 ) |OPC_DEXTR_W_DSP , +OPC_DSHILO = (0x1A <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTP = (0x02 <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTPDP = (0x0A <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTPDPV = (0x0B <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTPV = (0x03 <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTR_L = (0x10 <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTR_R_L = (0x14 <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTR_RS_L = (0x16 <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTR_W = (0x00 <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTR_R_W = (0x04 <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTR_RS_W = (0x06 <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTR_S_H = (0x0E <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTRV_L = (0x11 <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTRV_R_L = (0x15 <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTRV_RS_L = (0x17 <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTRV_S_H = (0x0F <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTRV_W = (0x01 <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTRV_R_W = (0x05 <<6 ) |OPC_DEXTR_W_DSP , +OPC_DEXTRV_RS_W = (0x07 <<6 ) |OPC_DEXTR_W_DSP , +OPC_DSHILOV = (0x1B <<6 ) |OPC_DEXTR_W_DSP , +}; +#define MASK_DINSV (op) (MASK_SPECIAL3(op) | (op & (0x1F << 6)))enum { /* DSP Bit/Manipulation Sub-class */@@ -14201,6 +14256,225 @@ static void gen_mipsdsp_add_cmp_pick(DisasContext *ctx,MIPS_DEBUG ("%s" , opn); } +static void gen_mipsdsp_accinsn (DisasContext *ctx,uint32_t op1,uint32_t op2, +int ret,int v1,int v2,int check_ret) + +{ +const char *opn ="mipsdsp accumulator" ; +TCGv t0 =tcg_temp_new (); +TCGv t1 =tcg_temp_new (); +int16_t imm; + +if ((ret ==0 ) && (check_ret ==1 )) { +/* Treat as NOP. */ +MIPS_DEBUG ("NOP" ); +return ; + } + +switch (op1) { +case OPC_EXTR_W_DSP : +check_dsp (ctx); +switch (op2) { +case OPC_EXTR_W : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); +gen_helper_extr_w (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_EXTR_R_W : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); +gen_helper_extr_r_w (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_EXTR_RS_W : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); +gen_helper_extr_rs_w (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_EXTR_S_H : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); +gen_helper_extr_s_h (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_EXTRV_S_H : +tcg_gen_movi_tl (t0, v2); +gen_helper_extr_s_h (cpu_gpr[ret], t0, cpu_gpr[v1], cpu_env); +break ; +case OPC_EXTRV_W : +tcg_gen_movi_tl (t0, v2); +gen_helper_extr_w (cpu_gpr[ret], t0, cpu_gpr[v1], cpu_env); +break ; +case OPC_EXTRV_R_W : +tcg_gen_movi_tl (t0, v2); +gen_helper_extr_r_w (cpu_gpr[ret], t0, cpu_gpr[v1], cpu_env); +break ; +case OPC_EXTRV_RS_W : +tcg_gen_movi_tl (t0, v2); +gen_helper_extr_rs_w (cpu_gpr[ret], t0, cpu_gpr[v1], cpu_env); +break ; +case OPC_EXTP : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); +gen_helper_extp (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_EXTPV : +tcg_gen_movi_tl (t0, v2); +gen_helper_extp (cpu_gpr[ret], t0, cpu_gpr[v1], cpu_env); +break ; +case OPC_EXTPDP : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); +gen_helper_extpdp (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_EXTPDPV : +tcg_gen_movi_tl (t0, v2); +gen_helper_extpdp (cpu_gpr[ret], t0, cpu_gpr[v1], cpu_env); +break ; +case OPC_SHILO : + imm = (ctx->opcode >>20 ) &0x3F ; +tcg_gen_movi_tl (t0, ret); +tcg_gen_movi_tl (t1, imm); +gen_helper_shilo (t0, t1, cpu_env); +break ; +case OPC_SHILOV : +tcg_gen_movi_tl (t0, ret); +gen_helper_shilo (t0, cpu_gpr[v1], cpu_env); +break ; +case OPC_MTHLIP : +tcg_gen_movi_tl (t0, ret); +gen_helper_mthlip (t0, cpu_gpr[v1], cpu_env); +break ; +case OPC_WRDSP : + imm = (ctx->opcode >>11 ) &0x3FF ; +tcg_gen_movi_tl (t0, imm); +gen_helper_wrdsp (cpu_gpr[v1], t0, cpu_env); +break ; +case OPC_RDDSP : + imm = (ctx->opcode >>16 ) &0x03FF ; +tcg_gen_movi_tl (t0, imm); +gen_helper_rddsp (cpu_gpr[ret], t0, cpu_env); +break ; + } +break ; +#ifdef TARGET_MIPS64 +case OPC_DEXTR_W_DSP : +check_dsp (ctx); +switch (op2) { +case OPC_DMTHLIP : +tcg_gen_movi_tl (t0, ret); +gen_helper_dmthlip (cpu_gpr[v1], t0, cpu_env); +break ; +case OPC_DSHILO : + { +int shift = (ctx->opcode >>19 ) &0x7F ; +int ac = (ctx->opcode >>11 ) &0x03 ; +tcg_gen_movi_tl (t0, shift); +tcg_gen_movi_tl (t1, ac); +gen_helper_dshilo (t0, t1, cpu_env); +break ; + } +case OPC_DSHILOV : + { +int ac = (ctx->opcode >>11 ) &0x03 ; +tcg_gen_movi_tl (t0, ac); +gen_helper_dshilo (cpu_gpr[v1], t0, cpu_env); +break ; + } +case OPC_DEXTP : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); + +gen_helper_dextp (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_DEXTPV : +tcg_gen_movi_tl (t0, v2); +gen_helper_dextp (cpu_gpr[ret], t0, cpu_gpr[v1], cpu_env); +break ; +case OPC_DEXTPDP : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); +gen_helper_dextpdp (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_DEXTPDPV : +tcg_gen_movi_tl (t0, v2); +gen_helper_dextpdp (cpu_gpr[ret], t0, cpu_gpr[v1], cpu_env); +break ; +case OPC_DEXTR_L : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); +gen_helper_dextr_l (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_DEXTR_R_L : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); +gen_helper_dextr_r_l (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_DEXTR_RS_L : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); +gen_helper_dextr_rs_l (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_DEXTR_W : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); +gen_helper_dextr_w (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_DEXTR_R_W : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); +gen_helper_dextr_r_w (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_DEXTR_RS_W : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); +gen_helper_dextr_rs_w (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_DEXTR_S_H : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); +gen_helper_dextr_s_h (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_DEXTRV_S_H : +tcg_gen_movi_tl (t0, v2); +tcg_gen_movi_tl (t1, v1); +gen_helper_dextr_s_h (cpu_gpr[ret], t0, t1, cpu_env); +break ; +case OPC_DEXTRV_L : +tcg_gen_movi_tl (t0, v2); +gen_helper_dextr_l (cpu_gpr[ret], t0, cpu_gpr[v1], cpu_env); +break ; +case OPC_DEXTRV_R_L : +tcg_gen_movi_tl (t0, v2); +gen_helper_dextr_r_l (cpu_gpr[ret], t0, cpu_gpr[v1], cpu_env); +break ; +case OPC_DEXTRV_RS_L : +tcg_gen_movi_tl (t0, v2); +gen_helper_dextr_rs_l (cpu_gpr[ret], t0, cpu_gpr[v1], cpu_env); +break ; +case OPC_DEXTRV_W : +tcg_gen_movi_tl (t0, v2); +gen_helper_dextr_w (cpu_gpr[ret], t0, cpu_gpr[v1], cpu_env);
target-mips/translate.c static void gen_mipsdsp_add_cmp_pick(DisasContext *ctx, · line 14465
Quoted 10 lines
target-mips/translate.c +10
-0+break ; +case OPC_DEXTRV_R_W : +tcg_gen_movi_tl (t0, v2); +gen_helper_dextr_r_w (cpu_gpr[ret], t0, cpu_gpr[v1], cpu_env); +break ; +case OPC_DEXTRV_RS_W : +tcg_gen_movi_tl (t0, v2); +gen_helper_dextr_rs_w (cpu_gpr[ret], t0, cpu_gpr[v1], cpu_env); +break ; + }
In all the functions above, v0 and v1 can be the zero register.
Quoted 99 lines
target-mips/translate.c +78
-0+break ; +#endif + } + + +tcg_temp_free (t0); +tcg_temp_free (t1); + + (void )opn;/* avoid a compiler warning */ +MIPS_DEBUG ("%s" , opn); +} +/* End MIPSDSP functions. */ static void decode_opc (CPUMIPSState *env,DisasContext *ctx,int *is_branch)@@ -14778,6 +15052,38 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) op2 =MASK_APPEND (ctx->opcode);gen_mipsdsp_add_cmp_pick (ctx, op1, op2, rt, rs, rd,1 );break ; +case OPC_EXTR_W_DSP : + op2 =MASK_EXTR_W (ctx->opcode); +switch (op2) { +case OPC_EXTR_W : +case OPC_EXTR_R_W : +case OPC_EXTR_RS_W : +case OPC_EXTR_S_H : +case OPC_EXTRV_S_H : +case OPC_EXTRV_W : +case OPC_EXTRV_R_W : +case OPC_EXTRV_RS_W : +case OPC_EXTP : +case OPC_EXTPV : +case OPC_EXTPDP : +case OPC_EXTPDPV : +gen_mipsdsp_accinsn (ctx, op1, op2, rt, rs, rd,1 ); +break ; +case OPC_RDDSP : +gen_mipsdsp_accinsn (ctx, op1, op2, rd, rs, rt,1 ); +break ; +case OPC_SHILO : +case OPC_SHILOV : +case OPC_MTHLIP : +case OPC_WRDSP : +gen_mipsdsp_accinsn (ctx, op1, op2, rd, rs, rt,0 ); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK EXTR.W" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ;#if defined(TARGET_MIPS64 ) case OPC_DEXTM ... OPC_DEXT: case OPC_DINSM ... OPC_DINS:@@ -14922,6 +15228,40 @@ static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) op2 =MASK_DAPPEND (ctx->opcode);gen_mipsdsp_add_cmp_pick (ctx, op1, op2, rt, rs, rd,1 );break ; +case OPC_DEXTR_W_DSP : + op2 =MASK_DEXTR_W (ctx->opcode); +switch (op2) { +case OPC_DEXTP : +case OPC_DEXTPDP : +case OPC_DEXTPDPV : +case OPC_DEXTPV : +case OPC_DEXTR_L : +case OPC_DEXTR_R_L : +case OPC_DEXTR_RS_L : +case OPC_DEXTR_W : +case OPC_DEXTR_R_W : +case OPC_DEXTR_RS_W : +case OPC_DEXTR_S_H : +case OPC_DEXTRV_L : +case OPC_DEXTRV_R_L : +case OPC_DEXTRV_RS_L : +case OPC_DEXTRV_S_H : +case OPC_DEXTRV_W : +case OPC_DEXTRV_R_W : +case OPC_DEXTRV_RS_W : +gen_mipsdsp_accinsn (ctx, op1, op2, rt, rs, rd,1 ); +break ; +case OPC_DMTHLIP : +case OPC_DSHILO : +case OPC_DSHILOV : +gen_mipsdsp_accinsn (ctx, op1, op2, rd, rs, rt,0 ); +break ; +default :/* Invalid */ +MIPS_INVAL ("MASK EXTR.W" ); +generate_exception (ctx,EXCP_RI ); +break ; + } +break ;case OPC_DPAQ_W_QH_DSP : op2 =MASK_DPAQ_W_QH (ctx->opcode);switch (op2) {Signature · 1 line
1.7.10.2 (Apple Git-33)
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH v9 12/14 target-mips-ase-dsp: Add MIPS DSP processors
In reply to Jia LiuAdd 74kf and mips64dspr2-generic-cpu model for test.
--- target-mips/translate_init.c | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
target-mips/translate_init.c +52 -0
@@ -311,6 +311,29 @@ static const mips_def_t mips_defs[] = .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_MT, .mmu_type = MMU_TYPE_R4000, }, + { + .name = "74Kf", + .CP0_PRid = 0x97, + .CP0_Config0 =MIPS_CONFIG0 | (0x1 <<CP0C0_AR ) | + (MMU_TYPE_R4000 << CP0C0_MT), + .CP0_Config1 =MIPS_CONFIG1 | (1 <<CP0C1_FP ) | (15 <<CP0C1_MMU ) | + (0 <<CP0C1_IS ) | (3 <<CP0C1_IL ) | (1 <<CP0C1_IA ) | + (0 <<CP0C1_DS ) | (3 <<CP0C1_DL ) | (1 <<CP0C1_DA ) | + (1 << CP0C1_CA), + .CP0_Config2 = MIPS_CONFIG2, + .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt) | (1 << CP0C3_DSPP), + .CP0_LLAddr_rw_bitmask = 0, + .CP0_LLAddr_shift = 4, + .SYNCI_Step = 32, + .CCRes = 2, + .CP0_Status_rw_bitmask = 0x3778FF1F, + .CP1_fcr0 = (1 <<FCR0_F64 ) | (1 <<FCR0_L ) | (1 <<FCR0_W ) | + (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID), + .SEGBITS = 32, + .PABITS = 32, + .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_DSPR2, + .mmu_type =MMU_TYPE_R4000 , + }, #if defined(TARGET_MIPS64) { .name = "R4000",
@@ -484,6 +507,35 @@ static const mips_def_t mips_defs[] = .insn_flags = CPU_LOONGSON2F, .mmu_type = MMU_TYPE_R4000, }, + { + /* A generic CPU providing MIPS64 ASE DSP 2 features. + FIXME: Eventually this should be replaced by a real CPU model. */ + .name = "mips64dspr2", + .CP0_PRid = 0x00010000, + .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) | + (MMU_TYPE_R4000 << CP0C0_MT), + .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) | + (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) | + (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) | + (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), + .CP0_Config2 = MIPS_CONFIG2, + .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA), + .CP0_LLAddr_rw_bitmask = 0, + .CP0_LLAddr_shift = 0, + .SYNCI_Step = 32, + .CCRes = 2, + .CP0_Status_rw_bitmask = 0x36FBFFFF, + .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_3D) | (1 << FCR0_PS) | + (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) | + (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV), + .SEGBITS = 42, + /* The architectural limit is 59, but we have hardcoded 36 bit + in some places... + .PABITS = 59, */ /* the architectural limit */ + .PABITS = 36, + .insn_flags = CPU_MIPS64R2 | ASE_DSP | ASE_DSPR2, + .mmu_type = MMU_TYPE_R4000, + }, #endif };
Signature · 1 line
1.7.10.2 (Apple Git-33)
Re: [Qemu-devel] [PATCH v9 12/14] target-mips-ase-dsp: Add MIPS DSP processors
Quoted 12 lines · Jia Liu
Add 74kf and mips64dspr2-generic-cpu model for test.
Signed-off-by Jia Liu <[email protected]>--- target-mips/translate_init.c | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)target-mips/translate_init.c +0
-0
target-mips/translate_init.c static const mips_def_t mips_defs[] = · line 316
Quoted 6 lines
target-mips/translate_init.c +3
-0@@ -311,6 +311,29 @@ static const mips_def_t mips_defs[] = .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_MT, .mmu_type = MMU_TYPE_R4000, }, + { + .name = "74Kf", + .CP0_PRid = 0x97,
According to the documentation, this should be 0x00019700;
Quoted 63 lines
target-mips/translate_init.c +49
-0+ .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | + (MMU_TYPE_R4000 << CP0C0_MT), + .CP0_Config1 =MIPS_CONFIG1 | (1 <<CP0C1_FP ) | (15 <<CP0C1_MMU ) | + (0 <<CP0C1_IS ) | (3 <<CP0C1_IL ) | (1 <<CP0C1_IA ) | + (0 <<CP0C1_DS ) | (3 <<CP0C1_DL ) | (1 <<CP0C1_DA ) | + (1 << CP0C1_CA), + .CP0_Config2 = MIPS_CONFIG2, + .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt) | (1 << CP0C3_DSPP), + .CP0_LLAddr_rw_bitmask = 0, + .CP0_LLAddr_shift = 4, + .SYNCI_Step = 32, + .CCRes = 2, + .CP0_Status_rw_bitmask = 0x3778FF1F, + .CP1_fcr0 = (1 <<FCR0_F64 ) | (1 <<FCR0_L ) | (1 <<FCR0_W ) | + (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID), + .SEGBITS = 32, + .PABITS = 32, + .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_DSPR2, + .mmu_type =MMU_TYPE_R4000 , + }, #if defined(TARGET_MIPS64) { .name = "R4000",@@ -484,6 +507,35 @@ static const mips_def_t mips_defs[] = .insn_flags = CPU_LOONGSON2F, .mmu_type = MMU_TYPE_R4000, }, + { + /* A generic CPU providing MIPS64 ASE DSP 2 features. + FIXME: Eventually this should be replaced by a real CPU model. */ + .name = "mips64dspr2", + .CP0_PRid = 0x00010000, + .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) | + (MMU_TYPE_R4000 << CP0C0_MT), + .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) | + (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) | + (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) | + (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), + .CP0_Config2 = MIPS_CONFIG2, + .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA), + .CP0_LLAddr_rw_bitmask = 0, + .CP0_LLAddr_shift = 0, + .SYNCI_Step = 32, + .CCRes = 2, + .CP0_Status_rw_bitmask = 0x36FBFFFF, + .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_3D) | (1 << FCR0_PS) | + (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) | + (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV), + .SEGBITS = 42, + /* The architectural limit is 59, but we have hardcoded 36 bit + in some places... + .PABITS = 59, */ /* the architectural limit */ + .PABITS = 36, + .insn_flags = CPU_MIPS64R2 | ASE_DSP | ASE_DSPR2, + .mmu_type = MMU_TYPE_R4000, + }, #endif };Signature · 1 line
1.7.10.2 (Apple Git-33)
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net