hexagon: Add HVX context
cover hexagon: Add HVX context
Add HVX contexts to Hexagon translation, necessary for system emulation. Change the HVX instruction translation to access the context via a base pointer.
Modeling the HVX context mapping while avoiding the need to copy the context when the OS scheduler decides to remap them required some general TCG gvec changes to enable some more _var forms.
Brian Cain (9):
tcg: split out _var forms of gvec logical, abs and min/max ops
tcg: add base arguments to the gvec 2s, dup_i32 and cmp expanders
tcg: split out _var forms of gvec saturating/mul/shift-immediate ops target/hexagon: raise an exception for HVX with SSR:XE clear target/hexagon: reach the HVX register file through a pointer target/hexagon: carry a base ptr w/HVX reg offsets target/hexagon: move the HVX register file into a QOM object target/hexagon: select the HVX register file with SSR:XA tests/functional/hexagon: add test_hvx_context arch test
include/hw/hexagon/hexagon.h | 1 + include/hw/hexagon/hexagon_hvx_context.h | 27 + include/tcg/tcg-op-gvec-common.h | 97 +++ target/hexagon/cpu.h | 18 +- target/hexagon/cpu_helper.h | 1 + target/hexagon/gen_tcg_hvx.h | 608 ++++++++++--------- target/hexagon/genptr.h | 8 + target/hexagon/mmvec/macros.h | 14 +- target/hexagon/translate.h | 7 +- hw/hexagon/hex-subsys.c | 36 ++ hw/hexagon/hexagon_hvx_context.c | 83 +++ linux-user/hexagon/cpu_loop.c | 2 + linux-user/main.c | 3 + target/hexagon/cpu.c | 39 +- target/hexagon/cpu_helper.c | 72 +++ target/hexagon/gdbstub.c | 16 +- target/hexagon/genptr.c | 102 ++-- target/hexagon/machine.c | 12 + target/hexagon/op_helper.c | 37 +- target/hexagon/translate.c | 73 ++- tcg/tcg-op-gvec.c | 617 ++++++++++++++------ hw/hexagon/meson.build | 1 + target/hexagon/hex_common.py | 180 +++--- tests/functional/hexagon/test_arch_tests.py | 7 + 24 files changed, 1437 insertions(+), 624 deletions(-) create mode 100644 include/hw/hexagon/hexagon_hvx_context.h create mode 100644 hw/hexagon/hexagon_hvx_context.c
Signature · 1 line
2.34.1
PATCH 1/9 tcg: split out _var forms of gvec logical, abs and min/max ops
target/hexagon is about to address its HVX register file through a runtime base pointer rather than a constant offset from env, in order to share one register file between several vCPUs. The gvec ops it needs have no base-parameterized form yet.
Split tcg_gen_gvec_{and,or,xor,andc,orc,not,abs,smin,umin,smax,umax} the same way tcg_gen_gvec_{add,sub,mov,dup_imm} already are: the work moves to a _var function taking a TCGv_ptr base per operand, and the existing entry point becomes a wrapper passing tcg_env.
The aofs == bofs shortcuts also have to compare the bases, since equal offsets into different objects are not the same operand.
--- include/tcg/tcg-op-gvec-common.h | 45 ++++++++ tcg/tcg-op-gvec.c | 184 ++++++++++++++++++++++++------- 2 files changed, 189 insertions(+), 40 deletions(-)
include/tcg/tcg-op-gvec-common.h +45 -0
@@ -287,6 +287,13 @@ void tcg_gen_gvec_mov_var(unsigned vece, TCGv_ptr dbase, uint32_t dofs, TCGv_ptr abase, uint32_t aofs, uint32_t oprsz, uint32_t maxsz); +void tcg_gen_gvec_not_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_abs_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_mov (unsigned vece,uint32_t dofs,uint32_t aofs,uint32_t oprsz,uint32_t maxsz); void tcg_gen_gvec_not(unsigned vece, uint32_t dofs, uint32_t aofs,
@@ -335,6 +342,23 @@ void tcg_gen_gvec_ussub(unsigned vece, uint32_t dofs, uint32_t aofs, uint32_t bofs, uint32_t oprsz, uint32_t maxsz);/* Min/max. */ +void tcg_gen_gvec_smin_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_umin_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_smax_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_umax_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_smin (unsigned vece,uint32_t dofs,uint32_t aofs,uint32_t bofs,uint32_t oprsz,uint32_t maxsz); void tcg_gen_gvec_umin(unsigned vece, uint32_t dofs, uint32_t aofs,
@@ -344,6 +368,27 @@ void tcg_gen_gvec_smax(unsigned vece, uint32_t dofs, uint32_t aofs,void tcg_gen_gvec_umax (unsigned vece,uint32_t dofs,uint32_t aofs,uint32_t bofs,uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_and_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_or_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_xor_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_andc_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_orc_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_and (unsigned vece,uint32_t dofs,uint32_t aofs,uint32_t bofs,uint32_t oprsz,uint32_t maxsz); void tcg_gen_gvec_or(unsigned vece, uint32_t dofs, uint32_t aofs,
tcg/tcg-op-gvec.c +144 -40
299 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH 1/9] tcg: split out _var forms of gvec logical, abs and min/max ops
Quoted 11 lines · Brian Cain
target/hexagon is about to address its HVX register file through a runtime base pointer rather than a constant offset from env, in order to share one register file between several vCPUs. The gvec ops it needs have no base-parameterized form yet.
Split tcg_gen_gvec_{and,or,xor,andc,orc,not,abs,smin,umin,smax,umax} the same way tcg_gen_gvec_{add,sub,mov,dup_imm} already are: the work moves to a
_varfunction taking aTCGv_ptrbase per operand, and the existing entry point becomes a wrapper passingtcg_env.
Quoted 8 lines
The aofs == bofs shortcuts also have to compare the bases, since equal offsets into different objects are not the same operand.
Signed-off-by Brian Cain <[email protected]>--- include/tcg/tcg-op-gvec-common.h | 45 ++++++++ tcg/tcg-op-gvec.c | 184 ++++++++++++++++++++++++------- 2 files changed, 189 insertions(+), 40 deletions(-)
PATCH 2/9 tcg: add base arguments to the gvec 2s, dup_i32 and cmp expanders
In reply to Brian CainThese three families still name tcg_env directly, so they cannot be reached from a _var entry point. Thread a TCGv_ptr base per operand through expand_2s_{i32,i64,vec}, expand_2sh_vec, expand_cmp_{i32,i64,vec} and do_gvec_shifts, and split expand_2i_ool out of tcg_gen_gvec_2i_ool the way expand_2_ool already is, so the out-of-line fallback is reachable too.
Add tcg_gen_gvec_{2s,shls,shrs,sars,dup_i32,cmp}_var; the existing entry points become wrappers passing tcg_env and generate identical code.
Note that the operand swap in tcg_gen_gvec_cmp_var, used when a condition has no helper, now has to swap the bases along with the offsets.
--- include/tcg/tcg-op-gvec-common.h | 21 +++ tcg/tcg-op-gvec.c | 256 +++++++++++++++++++++---------- 2 files changed, 192 insertions(+), 85 deletions(-)
include/tcg/tcg-op-gvec-common.h +21 -0
@@ -237,6 +237,10 @@ void tcg_gen_gvec_2(uint32_t dofs, uint32_t aofs,/* Similarly, expand (env+dofs) = op(env+aofs, c). */ void tcg_gen_gvec_2i (uint32_t dofs,uint32_t aofs,uint32_t oprsz,uint32_t maxsz,int64_t c,const GVecGen2i *op); +/* Expand (dbase+dofs) = op(abase+aofs, s), length @oprsz. */ +void tcg_gen_gvec_2s_var (TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs,uint32_t oprsz, +uint32_t maxsz,TCGv_i64 c,const GVecGen2s *op);/* Similarly, expand (env+dofs) = op(env+aofs, s). */ void tcg_gen_gvec_2s (uint32_t dofs,uint32_t aofs,uint32_t oprsz,uint32_t maxsz,TCGv_i64 c,const GVecGen2s *op);
@@ -433,6 +437,8 @@ void tcg_gen_gvec_dup_i64(unsigned vece, uint32_t dofs, uint32_t s,void tcg_gen_gvec_dup_imm_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs,uint32_t oprsz,uint32_t maxsz,uint64_t imm); +void tcg_gen_gvec_dup_i32_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +uint32_t oprsz,uint32_t maxsz,TCGv_i32 in);void tcg_gen_gvec_shli (unsigned vece,uint32_t dofs,uint32_t aofs,int64_t shift,uint32_t oprsz,uint32_t maxsz);
@@ -445,6 +451,16 @@ void tcg_gen_gvec_rotli(unsigned vece, uint32_t dofs, uint32_t aofs,void tcg_gen_gvec_rotri (unsigned vece,uint32_t dofs,uint32_t aofs,int64_t shift,uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_shls_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_i32 shift,uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_shrs_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_i32 shift,uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_sars_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_i32 shift,uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_shls (unsigned vece,uint32_t dofs,uint32_t aofs,TCGv_i32 shift,uint32_t oprsz,uint32_t maxsz); void tcg_gen_gvec_shrs(unsigned vece, uint32_t dofs, uint32_t aofs,
@@ -471,6 +487,11 @@ void tcg_gen_gvec_rotlv(unsigned vece, uint32_t dofs, uint32_t aofs,void tcg_gen_gvec_rotrv (unsigned vece,uint32_t dofs,uint32_t aofs,uint32_t bofs,uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_cmp_var (TCGCond cond,unsigned vece, +TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz);void tcg_gen_gvec_cmp (TCGCond cond,unsigned vece,uint32_t dofs,uint32_t aofs,uint32_t bofs,uint32_t oprsz,uint32_t maxsz);
tcg/tcg-op-gvec.c +171 -85
566 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH 2/9] tcg: add base arguments to the gvec 2s, dup_i32 and cmp expanders
Quoted 11 lines · Brian Cain
These three families still name
tcg_envdirectly, so they cannot be reached from a_varentry point. Thread aTCGv_ptrbase per operand through expand_2s_{i32,i64,vec},expand_2sh_vec, expand_cmp_{i32,i64,vec} anddo_gvec_shifts, and splitexpand_2i_oolout oftcg_gen_gvec_2i_oolthe wayexpand_2_oolalready is, so the out-of-line fallback is reachable too.Add tcg_gen_gvec_{2s,shls,shrs,sars,dup_i32,cmp}_var; the existing entry points become wrappers passing
tcg_envand generate identical code.
Quoted 8 lines
Note that the operand swap in
tcg_gen_gvec_cmp_var, used when a condition has no helper, now has to swap the bases along with the offsets.Signed-off-by Brian Cain <[email protected]>--- include/tcg/tcg-op-gvec-common.h | 21 +++ tcg/tcg-op-gvec.c | 256 +++++++++++++++++++++---------- 2 files changed, 192 insertions(+), 85 deletions(-)
PATCH 3/9 tcg: split out _var forms of gvec saturating/mul/shift-immediate ops
In reply to Brian Caintarget/hexagon is about to address its HVX register file through a runtime base pointer rather than a constant offset from env, in order to share one register file between several vCPUs. Split the other gvec op families it needs like tcg_gen_gvec_{add,sub,mov,and,etc}.
Add tcg_gen_gvec_{ssadd,sssub,usadd,ussub,mul}_var and tcg_gen_gvec_{shri,sari}_var, plus the tcg_gen_gvec_2i_var plumbing the immediate-shift forms are built on.
--- include/tcg/tcg-op-gvec-common.h | 31 ++++++ tcg/tcg-op-gvec.c | 177 ++++++++++++++++++++++--------- 2 files changed, 160 insertions(+), 48 deletions(-)
include/tcg/tcg-op-gvec-common.h +31 -0
@@ -234,6 +234,10 @@ void tcg_gen_gvec_2_var(TCGv_ptr dbase, uint32_t dofs,/* Similarly, expand (env+dofs) = op(env+aofs). */ void tcg_gen_gvec_2 (uint32_t dofs,uint32_t aofs,uint32_t oprsz,uint32_t maxsz,const GVecGen2 *op); +/* Expand (dbase+dofs) = op(abase+aofs, c), clearing @oprsz..@maxsz. */ +void tcg_gen_gvec_2i_var (TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs,uint32_t oprsz, +uint32_t maxsz,int64_t c,const GVecGen2i *op);/* Similarly, expand (env+dofs) = op(env+aofs, c). */ void tcg_gen_gvec_2i (uint32_t dofs,uint32_t aofs,uint32_t oprsz,uint32_t maxsz,int64_t c,const GVecGen2i *op);
@@ -315,6 +319,10 @@ void tcg_gen_gvec_sub_var(unsigned vece, TCGv_ptr dbase, uint32_t dofs, TCGv_ptr abase, uint32_t aofs, TCGv_ptr bbase, uint32_t bofs, uint32_t oprsz, uint32_t maxsz); +void tcg_gen_gvec_mul_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz);void tcg_gen_gvec_add (unsigned vece,uint32_t dofs,uint32_t aofs,uint32_t bofs,uint32_t oprsz,uint32_t maxsz);
@@ -336,6 +344,23 @@ void tcg_gen_gvec_muls(unsigned vece, uint32_t dofs, uint32_t aofs, TCGv_i64 c, uint32_t oprsz, uint32_t maxsz);/* Saturated arithmetic. */ +void tcg_gen_gvec_ssadd_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_sssub_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_usadd_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_ussub_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_ssadd (unsigned vece,uint32_t dofs,uint32_t aofs,uint32_t bofs,uint32_t oprsz,uint32_t maxsz); void tcg_gen_gvec_sssub(unsigned vece, uint32_t dofs, uint32_t aofs,
@@ -442,8 +467,14 @@ void tcg_gen_gvec_dup_i32_var(unsigned vece, TCGv_ptr dbase, uint32_t dofs,void tcg_gen_gvec_shli (unsigned vece,uint32_t dofs,uint32_t aofs,int64_t shift,uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_shri_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +int64_t shift,uint32_t oprsz,uint32_t maxsz);void tcg_gen_gvec_shri (unsigned vece,uint32_t dofs,uint32_t aofs,int64_t shift,uint32_t oprsz,uint32_t maxsz); +void tcg_gen_gvec_sari_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +int64_t shift,uint32_t oprsz,uint32_t maxsz);void tcg_gen_gvec_sari (unsigned vece,uint32_t dofs,uint32_t aofs,int64_t shift,uint32_t oprsz,uint32_t maxsz); void tcg_gen_gvec_rotli(unsigned vece, uint32_t dofs, uint32_t aofs,
tcg/tcg-op-gvec.c +129 -48
352 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH 3/9] tcg: split out _var forms of gvec saturating/mul/shift-immediate ops
Quoted 10 lines · Brian Cain
target/hexagon is about to address its HVX register file through a runtime base pointer rather than a constant offset from env, in order to share one register file between several vCPUs. Split the other gvec op families it needs like tcg_gen_gvec_{add,sub,mov,and,etc}.
Add tcg_gen_gvec_{ssadd,sssub,usadd,ussub,mul}_var and tcg_gen_gvec_{shri,sari}_var, plus the
tcg_gen_gvec_2i_varplumbing the immediate-shift forms are built on.
Quoted 5 lines
Signed-off-by Brian Cain <[email protected]>--- include/tcg/tcg-op-gvec-common.h | 31 ++++++ tcg/tcg-op-gvec.c | 177 ++++++++++++++++++++++--------- 2 files changed, 160 insertions(+), 48 deletions(-)
PATCH 4/9 target/hexagon: raise an exception for HVX with SSR:XE clear
In reply to Brian CainSSR:XE gates access to the HVX coprocessor: executing an HVX instruction while it is clear must raise a precise exception with cause 0x16, NO_COPROC_ENABLE.
Carry SSR:XE in a TB flag and emit the exception for the first HVX packet of a TB when the coprocessor is disabled.
--- target/hexagon/cpu.h | 1 + target/hexagon/translate.h | 2 ++ target/hexagon/cpu.c | 2 ++ target/hexagon/translate.c | 11 +++++++++++ 4 files changed, 16 insertions(+)
target/hexagon/cpu.h +1 -0
@@ -207,6 +207,7 @@ struct ArchCPU { FIELD(TB_FLAGS, IS_TIGHT_LOOP, 0, 1) FIELD(TB_FLAGS, MMU_INDEX, 1, 3) FIELD(TB_FLAGS, PCYCLE_ENABLED, 4, 1) +FIELD(TB_FLAGS, HVX_COPROC_ENABLED, 5, 1) G_NORETURN void hexagon_raise_exception_err(CPUHexagonState *env, uint32_t exception,
target/hexagon/translate.h +2 -0
@@ -89,6 +89,8 @@ typedef struct DisasContext {TCGv branch_taken;TCGv dczero_addr;bool pcycle_enabled; +bool hvx_coproc_enabled; +bool hvx_check_emitted;uint32_t num_cycles; } DisasContext;
target/hexagon/cpu.c +2 -0
@@ -331,6 +331,8 @@ static TCGTBCPUState hexagon_get_tb_cpu_state(CPUState *cs) hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,MMU_INDEX ,cpu_mmu_index (env_cpu (env), false)); hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,PCYCLE_ENABLED ,1 ); + hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,HVX_COPROC_ENABLED , +GET_SSR_FIELD (SSR_XE , env->t_sreg[HEX_SREG_SSR ]));#else hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,MMU_INDEX ,MMU_USER_IDX );#endif
target/hexagon/translate.c +11 -0
@@ -718,6 +718,14 @@ static void gen_start_packet(DisasContext *ctx) i =find_next_bit (ctx->predicated_tmp_vregs,NUM_VREGS , i +1 ); } } + +#ifndef CONFIG_USER_ONLY +if (ctx->pkt.pkt_has_hvx && !ctx->hvx_coproc_enabled && + !ctx->hvx_check_emitted) { +gen_precise_exception (HEX_CAUSE_NO_COPROC_ENABLE , ctx->pkt.pc); + ctx->hvx_check_emitted = true; + } +#endif }bool is_gather_store_insn (DisasContext *ctx)
@@ -1235,6 +1243,9 @@ static void hexagon_tr_init_disas_context(DisasContextBase *dcbase,#ifndef CONFIG_USER_ONLY ctx->num_cycles =0 ; ctx->pcycle_enabled =FIELD_EX32 (hex_flags,TB_FLAGS ,PCYCLE_ENABLED ); + ctx->hvx_coproc_enabled = +FIELD_EX32 (hex_flags,TB_FLAGS ,HVX_COPROC_ENABLED ); + ctx->hvx_check_emitted = false;#endif }
Signature · 1 line
2.34.1
Re: [PATCH 4/9] target/hexagon: raise an exception for HVX with SSR:XE clear
Quoted 16 lines · Brian Cain
SSR:XE gates access to the HVX coprocessor: executing an HVX instruction while it is clear must raise a precise exception with cause
0x16,NO_COPROC_ENABLE.Carry SSR:XE in a TB flag and emit the exception for the first HVX packet of a TB when the coprocessor is disabled.
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/cpu.h | 1 + target/hexagon/translate.h | 2 ++ target/hexagon/cpu.c | 2 ++ target/hexagon/translate.c | 11 +++++++++++ 4 files changed, 16 insertions(+)
target/hexagon/cpu.c static TCGTBCPUState hexagon_get_tb_cpu_state(CPUState *cs) · line 335
Quoted 2 lines
target/hexagon/cpu.c +2
-0+ hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,HVX_COPROC_ENABLED , +GET_SSR_FIELD (SSR_XE , env->t_sreg[HEX_SREG_SSR ]));
Is it safe to cache SSR.XE? What happens if a thread changes SSR.XE while executing the TB?
Re: [PATCH 4/9] target/hexagon: raise an exception for HVX with SSR:XE clear
Quoted 17 lines · Marco Liebel
Quoted 14 lines · Brian Cain
SSR:XE gates access to the HVX coprocessor: executing an HVX instruction while it is clear must raise a precise exception with cause
0x16,NO_COPROC_ENABLE.Carry SSR:XE in a TB flag and emit the exception for the first HVX packet of a TB when the coprocessor is disabled.
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/cpu.h | 1 + target/hexagon/translate.h | 2 ++ target/hexagon/cpu.c | 2 ++ target/hexagon/translate.c | 11 +++++++++++ 4 files changed, 16 insertions(+)target/hexagon/cpu.c static TCGTBCPUState hexagon_get_tb_cpu_state(CPUState *cs) · line 335
Quoted 2 lines
target/hexagon/cpu.c +2
-0+ hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,HVX_COPROC_ENABLED , +GET_SSR_FIELD (SSR_XE , env->t_sreg[HEX_SREG_SSR ]));
Quoted 2 lines
Is it safe to cache SSR.XE? What happens if a thread changes SSR.XE while executing the TB?
This mechanism leverages the translation cache. Consider these flags like an index into that cache. When it changes, we resolve to a different translation for a given block of code. If it misses, we translate the code again with the given context.
SSR writes cause an end to a TB, so SSR writes cannot occur mid-TB. The SSR register is local to each hw thread/vCPU.
So, I believe it is safe, yes.
-Brian
Marco Liebel
Reviewed-byRe: [PATCH 4/9] target/hexagon: raise an exception for HVX with SSR:XE clear
Quoted 8 lines · Brian Cain
SSR:XE gates access to the HVX coprocessor: executing an HVX instruction while it is clear must raise a precise exception with cause
0x16,NO_COPROC_ENABLE.Carry SSR:XE in a TB flag and emit the exception for the first HVX packet of a TB when the coprocessor is disabled.
Quoted 7 lines
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/cpu.h | 1 + target/hexagon/translate.h | 2 ++ target/hexagon/cpu.c | 2 ++ target/hexagon/translate.c | 11 +++++++++++ 4 files changed, 16 insertions(+)
PATCH 5/9 target/hexagon: reach the HVX register file through a pointer
In reply to Brian CainThe HVX register file belongs to an extension context, not a hw thread. A core has a number of contexts, and each thread's SSR:XA selects the one bound to it.
Group the regs into HexagonHVXContext and reach them through CPUHexagonState::hvx. Later patches move the storage into an object that can be shared by vCPUs.
--- target/hexagon/cpu.h | 10 ++++++++-- linux-user/hexagon/cpu_loop.c | 2 ++ target/hexagon/cpu.c | 15 ++++++++------ target/hexagon/gdbstub.c | 16 +++++++-------- target/hexagon/genptr.c | 4 ++-- target/hexagon/op_helper.c | 37 ++++++++++++++++++----------------- target/hexagon/translate.c | 14 ++++++------- target/hexagon/hex_common.py | 5 +++-- 8 files changed, 58 insertions(+), 45 deletions(-)
target/hexagon/cpu.h +8 -2
@@ -120,6 +120,11 @@ typedef struct {/* Maximum number of vector temps in a packet */ #define VECTOR_TEMPS_MAX 4 +typedef struct HexagonHVXContext { + MMVector VRegs[NUM_VREGS] QEMU_ALIGNED(16); + MMQReg QRegs[NUM_QREGS] QEMU_ALIGNED(16); +}HexagonHVXContext ; + typedef struct CPUArchState { target_ulong gpr[TOTAL_PER_THREAD_REGS]; target_ulong pred[NUM_PREGS];
@@ -159,11 +164,12 @@ typedef struct CPUArchState {target_ulong llsc_val;uint64_t llsc_val_i64; - MMVector VRegs[NUM_VREGS] QEMU_ALIGNED(16); +HexagonHVXContext *hvx; + HexagonHVXContext hvx_ctx QEMU_ALIGNED(16); + MMVector future_VRegs[VECTOR_TEMPS_MAX] QEMU_ALIGNED(16); MMVector tmp_VRegs[VECTOR_TEMPS_MAX] QEMU_ALIGNED(16); - MMQReg QRegs[NUM_QREGS] QEMU_ALIGNED(16); MMQReg future_QRegs[NUM_QREGS] QEMU_ALIGNED(16);/* Temporaries used within instructions */
linux-user/hexagon/cpu_loop.c +2 -0
@@ -33,6 +33,8 @@ void cpu_loop(CPUHexagonState *env)target_ulong syscallnum;target_ulong ret; + env->hvx = &env->hvx_ctx; +for (;;) {cpu_exec_start (cs); trapnr =cpu_exec (cs);
target/hexagon/cpu.c +9 -6
@@ -182,7 +182,7 @@ static void print_vreg(FILE *f, CPUHexagonState *env, int regnum,if (skip_if_zero) {bool nonzero_found = false;for (int i =0 ; i <MAX_VEC_SIZE_BYTES ; i++) { -if (env->VRegs[regnum].ub[i] !=0 ) { +if (env->hvx->VRegs[regnum].ub[i] !=0 ) { nonzero_found = true;break ; }
@@ -193,9 +193,10 @@ static void print_vreg(FILE *f, CPUHexagonState *env, int regnum, }qemu_fprintf (f," v%d = ( " , regnum); -qemu_fprintf (f,"0x%02x" , env->VRegs[regnum].ub[MAX_VEC_SIZE_BYTES -1 ]); +qemu_fprintf (f,"0x%02x" , + env->hvx->VRegs[regnum].ub[MAX_VEC_SIZE_BYTES -1 ]);for (int i =MAX_VEC_SIZE_BYTES -2 ; i >=0 ; i--) { -qemu_fprintf (f,", 0x%02x" , env->VRegs[regnum].ub[i]); +qemu_fprintf (f,", 0x%02x" , env->hvx->VRegs[regnum].ub[i]); }qemu_fprintf (f," )\n" ); }
@@ -211,7 +212,7 @@ static void print_qreg(FILE *f, CPUHexagonState *env, int regnum,if (skip_if_zero) {bool nonzero_found = false;for (int i =0 ; i <MAX_VEC_SIZE_BYTES /8 ; i++) { -if (env->QRegs[regnum].ub[i] !=0 ) { +if (env->hvx->QRegs[regnum].ub[i] !=0 ) { nonzero_found = true;break ; }
@@ -223,9 +224,9 @@ static void print_qreg(FILE *f, CPUHexagonState *env, int regnum,qemu_fprintf (f," q%d = ( " , regnum);qemu_fprintf (f,"0x%02x" , - env->QRegs[regnum].ub[MAX_VEC_SIZE_BYTES /8 -1 ]); + env->hvx->QRegs[regnum].ub[MAX_VEC_SIZE_BYTES /8 -1 ]);for (int i =MAX_VEC_SIZE_BYTES /8 -2 ; i >=0 ; i--) { -qemu_fprintf (f,", 0x%02x" , env->QRegs[regnum].ub[i]); +qemu_fprintf (f,", 0x%02x" , env->hvx->QRegs[regnum].ub[i]); }qemu_fprintf (f," )\n" ); }
@@ -419,6 +420,8 @@ static void hexagon_cpu_reset_hold(Object *obj, ResetType type) mcc->parent_phases.hold (obj, type); } + env->hvx = &env->hvx_ctx; +set_default_nan_mode (1 , &env->fp_status);set_float_detect_tininess (float_tininess_before_rounding, &env->fp_status);/* Default NaN value: sign bit set, all frac bits set */
target/hexagon/gdbstub.c +8 -8
@@ -80,8 +80,8 @@ static int gdb_get_vreg(CPUHexagonState *env, GByteArray *mem_buf, int n) {int total =0 ;int i; -for (i =0 ; i <ARRAY_SIZE (env->VRegs[n].uw); i++) { - total +=gdb_get_reg32 (mem_buf, env->VRegs[n].uw[i]); +for (i =0 ; i <ARRAY_SIZE (env->hvx->VRegs[n].uw); i++) { + total +=gdb_get_reg32 (mem_buf, env->hvx->VRegs[n].uw[i]); }return total; }
@@ -90,8 +90,8 @@ static int gdb_get_qreg(CPUHexagonState *env, GByteArray *mem_buf, int n) {int total =0 ;int i; -for (i =0 ; i <ARRAY_SIZE (env->QRegs[n].uw); i++) { - total +=gdb_get_reg32 (mem_buf, env->QRegs[n].uw[i]); +for (i =0 ; i <ARRAY_SIZE (env->hvx->QRegs[n].uw); i++) { + total +=gdb_get_reg32 (mem_buf, env->hvx->QRegs[n].uw[i]); }return total; }
@@ -116,8 +116,8 @@ int hexagon_hvx_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)static int gdb_put_vreg (CPUHexagonState *env,uint8_t *mem_buf,int n) {int i; -for (i =0 ; i <ARRAY_SIZE (env->VRegs[n].uw); i++) { - env->VRegs[n].uw[i] =ldl_le_p (mem_buf); +for (i =0 ; i <ARRAY_SIZE (env->hvx->VRegs[n].uw); i++) { + env->hvx->VRegs[n].uw[i] =ldl_le_p (mem_buf); mem_buf +=4 ; }return MAX_VEC_SIZE_BYTES ;
@@ -126,8 +126,8 @@ static int gdb_put_vreg(CPUHexagonState *env, uint8_t *mem_buf, int n)static int gdb_put_qreg (CPUHexagonState *env,uint8_t *mem_buf,int n) {int i; -for (i =0 ; i <ARRAY_SIZE (env->QRegs[n].uw); i++) { - env->QRegs[n].uw[i] =ldl_le_p (mem_buf); +for (i =0 ; i <ARRAY_SIZE (env->hvx->QRegs[n].uw); i++) { + env->hvx->QRegs[n].uw[i] =ldl_le_p (mem_buf); mem_buf +=4 ; }return MAX_VEC_SIZE_BYTES /8 ;
target/hexagon/genptr.c +2 -2
@@ -1433,7 +1433,7 @@ static void gen_asr_r_svw_trun(DisasContext *ctx, TCGv RdV,static intptr_t vreg_src_off (DisasContext *ctx,int num) { - intptr_t offset = offsetof(CPUHexagonState, VRegs[num]); + intptr_t offset = offsetof(CPUHexagonState, hvx_ctx.VRegs[num]);if (test_bit (num, ctx->vregs_select)) { offset =ctx_future_vreg_off (ctx, num,1 , false);
@@ -1473,7 +1473,7 @@ static intptr_t get_result_qreg(DisasContext *ctx, int qnum)if (ctx->need_commit) { return offsetof(CPUHexagonState, future_QRegs[qnum]); }else { - return offsetof(CPUHexagonState, QRegs[qnum]); + return offsetof(CPUHexagonState, hvx_ctx.QRegs[qnum]); } }
target/hexagon/op_helper.c +19 -18
@@ -1408,7 +1408,8 @@ void HELPER(vhist)(CPUHexagonState *env)unsigned char regno = value >>3 ;unsigned char element = value &7 ; - env->VRegs[regno].uh[(sizeof (MMVector) /16 ) * lane + element]++; + env->hvx->VRegs[regno] + .uh[(sizeof (MMVector) /16 ) * lane + element]++; } } }
@@ -1424,7 +1425,7 @@ void HELPER(vhistq)(CPUHexagonState *env)unsigned char element = value &7 ;if (fGETQBIT (env->qtmp,sizeof (MMVector) /8 * lane + i)) { - env->VRegs[regno].uh[ + env->hvx->VRegs[regno].uh[ (sizeof (MMVector) /16 ) * lane + element]++; } }
@@ -1441,8 +1442,8 @@ void HELPER(vwhist256)(CPUHexagonState *env)unsigned int vindex = (bucket >>3 ) &0x1F ;unsigned int elindex = ((i >>0 ) & (~7 )) | ((bucket >>0 ) &7 ); - env->VRegs[vindex].uh[elindex] = - env->VRegs[vindex].uh[elindex] + weight; + env->hvx->VRegs[vindex].uh[elindex] = + env->hvx->VRegs[vindex].uh[elindex] + weight; } }
@@ -1457,8 +1458,8 @@ void HELPER(vwhist256q)(CPUHexagonState *env)unsigned int elindex = ((i >>0 ) & (~7 )) | ((bucket >>0 ) &7 );if (fGETQBIT (env->qtmp,2 * i)) { - env->VRegs[vindex].uh[elindex] = - env->VRegs[vindex].uh[elindex] + weight; + env->hvx->VRegs[vindex].uh[elindex] = + env->hvx->VRegs[vindex].uh[elindex] + weight; } } }
@@ -1473,8 +1474,8 @@ void HELPER(vwhist256_sat)(CPUHexagonState *env)unsigned int vindex = (bucket >>3 ) &0x1F ;unsigned int elindex = ((i >>0 ) & (~7 )) | ((bucket >>0 ) &7 ); - env->VRegs[vindex].uh[elindex] = -fVSATUH (env->VRegs[vindex].uh[elindex] + weight); + env->hvx->VRegs[vindex].uh[elindex] = +fVSATUH (env->hvx->VRegs[vindex].uh[elindex] + weight); } }
@@ -1489,8 +1490,8 @@ void HELPER(vwhist256q_sat)(CPUHexagonState *env)unsigned int elindex = ((i >>0 ) & (~7 )) | ((bucket >>0 ) &7 );if (fGETQBIT (env->qtmp,2 * i)) { - env->VRegs[vindex].uh[elindex] = -fVSATUH (env->VRegs[vindex].uh[elindex] + weight); + env->hvx->VRegs[vindex].uh[elindex] = +fVSATUH (env->hvx->VRegs[vindex].uh[elindex] + weight); } } }
@@ -1505,8 +1506,8 @@ void HELPER(vwhist128)(CPUHexagonState *env)unsigned int vindex = (bucket >>3 ) &0x1F ;unsigned int elindex = ((i >>1 ) & (~3 )) | ((bucket >>1 ) &3 ); - env->VRegs[vindex].uw[elindex] = - env->VRegs[vindex].uw[elindex] + weight; + env->hvx->VRegs[vindex].uw[elindex] = + env->hvx->VRegs[vindex].uw[elindex] + weight; } }
@@ -1521,8 +1522,8 @@ void HELPER(vwhist128q)(CPUHexagonState *env)unsigned int elindex = ((i >>1 ) & (~3 )) | ((bucket >>1 ) &3 );if (fGETQBIT (env->qtmp,2 * i)) { - env->VRegs[vindex].uw[elindex] = - env->VRegs[vindex].uw[elindex] + weight; + env->hvx->VRegs[vindex].uw[elindex] = + env->hvx->VRegs[vindex].uw[elindex] + weight; } } }
@@ -1538,8 +1539,8 @@ void HELPER(vwhist128m)(CPUHexagonState *env, int32_t uiV)unsigned int elindex = ((i >>1 ) & (~3 )) | ((bucket >>1 ) &3 );if ((bucket &1 ) == uiV) { - env->VRegs[vindex].uw[elindex] = - env->VRegs[vindex].uw[elindex] + weight; + env->hvx->VRegs[vindex].uw[elindex] = + env->hvx->VRegs[vindex].uw[elindex] + weight; } } }
@@ -1555,8 +1556,8 @@ void HELPER(vwhist128qm)(CPUHexagonState *env, int32_t uiV)unsigned int elindex = ((i >>1 ) & (~3 )) | ((bucket >>1 ) &3 );if (((bucket &1 ) == uiV) &&fGETQBIT (env->qtmp,2 * i)) { - env->VRegs[vindex].uw[elindex] = - env->VRegs[vindex].uw[elindex] + weight; + env->hvx->VRegs[vindex].uw[elindex] = + env->hvx->VRegs[vindex].uw[elindex] + weight; } } }
target/hexagon/translate.c +7 -7
@@ -87,7 +87,7 @@ intptr_t ctx_future_vreg_off(DisasContext *ctx, int regnum,intptr_t offset;if (!ctx->need_commit) { - return offsetof(CPUHexagonState, VRegs[regnum]); + return offsetof(CPUHexagonState, hvx_ctx.VRegs[regnum]); }/* See if it is already allocated */
@@ -697,7 +697,7 @@ static void gen_start_packet(DisasContext *ctx)while (i <NUM_VREGS ) {const intptr_t VdV_off =ctx_future_vreg_off (ctx, i,1 , true); - intptr_t src_off = offsetof(CPUHexagonState, VRegs[i]); + intptr_t src_off = offsetof(CPUHexagonState, hvx_ctx.VRegs[i]); tcg_gen_gvec_mov(MO_64, VdV_off, src_off, sizeof(MMVector),
@@ -710,7 +710,7 @@ static void gen_start_packet(DisasContext *ctx)while (i <NUM_VREGS ) {const intptr_t VdV_off =ctx_tmp_vreg_off (ctx, i,1 , true); - intptr_t src_off = offsetof(CPUHexagonState, VRegs[i]); + intptr_t src_off = offsetof(CPUHexagonState, hvx_ctx.VRegs[i]); tcg_gen_gvec_mov(MO_64, VdV_off, src_off, sizeof(MMVector),
@@ -1012,12 +1012,12 @@ static void gen_commit_hvx(DisasContext *ctx)/* * for (i = 0; i < ctx->vreg_log_idx; i++) { * int rnum = ctx->vreg_log[i]; -* env->VRegs[rnum] = env->future_VRegs[rnum]; +* env->hvx->VRegs[rnum] = env->future_VRegs[rnum]; * } */ for (i =0 ; i < ctx->vreg_log_idx; i++) {int rnum = ctx->vreg_log[i]; - intptr_t dstoff = offsetof(CPUHexagonState, VRegs[rnum]); + intptr_t dstoff = offsetof(CPUHexagonState, hvx_ctx.VRegs[rnum]);intptr_t srcoff =ctx_future_vreg_off (ctx, rnum,1 , false);size_t size =sizeof (MMVector);
@@ -1027,12 +1027,12 @@ static void gen_commit_hvx(DisasContext *ctx)/* * for (i = 0; i < ctx->qreg_log_idx; i++) { * int rnum = ctx->qreg_log[i]; -* env->QRegs[rnum] = env->future_QRegs[rnum]; +* env->hvx->QRegs[rnum] = env->future_QRegs[rnum]; * } */ for (i =0 ; i < ctx->qreg_log_idx; i++) {int rnum = ctx->qreg_log[i]; - intptr_t dstoff = offsetof(CPUHexagonState, QRegs[rnum]); + intptr_t dstoff = offsetof(CPUHexagonState, hvx_ctx.QRegs[rnum]); intptr_t srcoff = offsetof(CPUHexagonState, future_QRegs[rnum]);size_t size =sizeof (MMQReg);
target/hexagon/hex_common.py +3 -2
@@ -1050,7 +1050,7 @@ def decl_tcg(self, f, tag, regno): self.decl_reg_num(f, regno) f.write(code_fmt(f"""\ const intptr_t {self.hvx_off()} = - offsetof(CPUHexagonState, QRegs[{self.reg_num}]); + offsetof(CPUHexagonState, hvx_ctx.QRegs[{self.reg_num}]); """)) if not skip_qemu_helper(tag): f.write(code_fmt(f"""\
@@ -1073,7 +1073,8 @@ def decl_tcg(self, f, tag, regno): const intptr_t {self.hvx_off()} = get_result_qreg(ctx, {self.reg_num}); tcg_gen_gvec_mov(MO_64, {self.hvx_off()}, - offsetof(CPUHexagonState, QRegs[{self.reg_num}]), + offsetof(CPUHexagonState, + hvx_ctx.QRegs[{self.reg_num}]), sizeof(MMQReg), sizeof(MMQReg)); """)) if not skip_qemu_helper(tag):
Signature · 1 line
2.34.1
Re: [PATCH 5/9] target/hexagon: reach the HVX register file through a pointer
Quoted 10 lines · Brian Cain
The HVX register file belongs to an extension context, not a hw thread. A core has a number of contexts, and each thread's SSR:XA selects the one bound to it.
Group the regs into HexagonHVXContext and reach them through
CPUHexagonState::hvx. Later patches move the storage into an object that can be shared by vCPUs.Signed-off-by Brian Cain <[email protected]>
Quoted 10 lines
--- target/hexagon/cpu.h | 10 ++++++++-- linux-user/hexagon/cpu_loop.c | 2 ++ target/hexagon/cpu.c | 15 ++++++++------ target/hexagon/gdbstub.c | 16 +++++++-------- target/hexagon/genptr.c | 4 ++-- target/hexagon/op_helper.c | 37 ++++++++++++++++++----------------- target/hexagon/translate.c | 14 ++++++------- target/hexagon/hex_common.py | 5 +++-- 8 files changed, 58 insertions(+), 45 deletions(-)
PATCH 6/9 target/hexagon: carry a base ptr w/HVX reg offsets
In reply to Brian CainAn HVX register operand was a bare offset from env. That works only while the register file was part of CPUHexagonState. When it moves to an HVX context shared between hardware threads, its address is not a translation-time constant.
While here, fold the repeated helper-argument pointer setup in hex_common.py into Hvx.decl_tcg_ptr().
--- target/hexagon/gen_tcg_hvx.h | 608 +++++++++++++++++++--------------- target/hexagon/genptr.h | 8 + target/hexagon/mmvec/macros.h | 14 +- target/hexagon/translate.h | 5 +- target/hexagon/genptr.c | 102 +++--- target/hexagon/translate.c | 58 ++-- target/hexagon/hex_common.py | 181 +++++----- 7 files changed, 563 insertions(+), 413 deletions(-)
target/hexagon/gen_tcg_hvx.h +338 -270
@@ -49,8 +49,8 @@ static inline void assert_vhist_tmp(DisasContext *ctx) do { \ if (ctx->pre_commit) { \ intptr_t dstoff = offsetof(CPUHexagonState, qtmp); \ - tcg_gen_gvec_mov(MO_64, dstoff, QvV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_mov_var(MO_64, tcg_env, dstoff, QvV_base, QvV_off, \ + sizeof(MMVector), sizeof(MMVector)); \ } else { \ assert_vhist_tmp(ctx); \ gen_helper_vhistq(tcg_env); \
@@ -65,8 +65,8 @@ static inline void assert_vhist_tmp(DisasContext *ctx) do { \ if (ctx->pre_commit) { \ intptr_t dstoff = offsetof(CPUHexagonState, qtmp); \ - tcg_gen_gvec_mov(MO_64, dstoff, QvV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_mov_var(MO_64, tcg_env, dstoff, QvV_base, QvV_off, \ + sizeof(MMVector), sizeof(MMVector)); \ } else { \ assert_vhist_tmp(ctx); \ gen_helper_vwhist256q(tcg_env); \
@@ -81,8 +81,8 @@ static inline void assert_vhist_tmp(DisasContext *ctx) do { \ if (ctx->pre_commit) { \ intptr_t dstoff = offsetof(CPUHexagonState, qtmp); \ - tcg_gen_gvec_mov(MO_64, dstoff, QvV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_mov_var(MO_64, tcg_env, dstoff, QvV_base, QvV_off, \ + sizeof(MMVector), sizeof(MMVector)); \ } else { \ assert_vhist_tmp(ctx); \ gen_helper_vwhist256q_sat(tcg_env); \
@@ -97,8 +97,8 @@ static inline void assert_vhist_tmp(DisasContext *ctx) do { \ if (ctx->pre_commit) { \ intptr_t dstoff = offsetof(CPUHexagonState, qtmp); \ - tcg_gen_gvec_mov(MO_64, dstoff, QvV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_mov_var(MO_64, tcg_env, dstoff, QvV_base, QvV_off, \ + sizeof(MMVector), sizeof(MMVector)); \ } else { \ assert_vhist_tmp(ctx); \ gen_helper_vwhist128q(tcg_env); \
@@ -114,8 +114,8 @@ static inline void assert_vhist_tmp(DisasContext *ctx) do { \ if (ctx->pre_commit) { \ intptr_t dstoff = offsetof(CPUHexagonState, qtmp); \ - tcg_gen_gvec_mov(MO_64, dstoff, QvV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_mov_var(MO_64, tcg_env, dstoff, QvV_base, QvV_off, \ + sizeof(MMVector), sizeof(MMVector)); \ } else { \ TCGv tcgv_uiV = tcg_constant_tl(uiV); \ assert_vhist_tmp(ctx); \
@@ -125,19 +125,20 @@ static inline void assert_vhist_tmp(DisasContext *ctx)#define fGEN_TCG_V6_vassign (SHORTCODE ) \ - tcg_gen_gvec_mov(MO_64, VdV_off, VuV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_mov_var(MO_64, VdV_base, VdV_off, VuV_base, VuV_off, \ + sizeof(MMVector), sizeof(MMVector))#define fGEN_TCG_V6_vassign_tmp (SHORTCODE ) \ - tcg_gen_gvec_mov(MO_64, VdV_off, VuV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_mov_var(MO_64, VdV_base, VdV_off, VuV_base, VuV_off, \ + sizeof(MMVector), sizeof(MMVector))#define fGEN_TCG_V6_vcombine_tmp (SHORTCODE ) \ do { \ - tcg_gen_gvec_mov(MO_64, VddV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ - tcg_gen_gvec_mov(MO_64, VddV_off + sizeof(MMVector), VuV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_mov_var(MO_64, VddV_base, VddV_off, VvV_base, VvV_off, \ + sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_mov_var(MO_64, VddV_base, VddV_off + sizeof(MMVector), \ + VuV_base, VuV_off, sizeof(MMVector), \ + sizeof(MMVector)); \ } while (0)/*
@@ -148,18 +149,20 @@ static inline void assert_vhist_tmp(DisasContext *ctx)#define fGEN_TCG_V6_vcombine (SHORTCODE ) \ do { \ if (VddV_off != VuV_off) { \ - tcg_gen_gvec_mov(MO_64, VddV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ - tcg_gen_gvec_mov(MO_64, VddV_off + sizeof(MMVector), VuV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_mov_var(MO_64, VddV_base, VddV_off, VvV_base, \ + VvV_off, sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_mov_var(MO_64, VddV_base, \ + VddV_off + sizeof(MMVector), VuV_base, \ + VuV_off, sizeof(MMVector), sizeof(MMVector)); \ } else { \ intptr_t tmpoff = offsetof(CPUHexagonState, vtmp); \ - tcg_gen_gvec_mov(MO_64, tmpoff, VuV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ - tcg_gen_gvec_mov(MO_64, VddV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ - tcg_gen_gvec_mov(MO_64, VddV_off + sizeof(MMVector), tmpoff, \ - sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_mov_var(MO_64, tcg_env, tmpoff, VuV_base, VuV_off, \ + sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_mov_var(MO_64, VddV_base, VddV_off, VvV_base, \ + VvV_off, sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_mov_var(MO_64, VddV_base, \ + VddV_off + sizeof(MMVector), tcg_env, tmpoff, \ + sizeof(MMVector), sizeof(MMVector)); \ } \ } while (0)
@@ -170,8 +173,8 @@ static inline void assert_vhist_tmp(DisasContext *ctx)TCGLabel *false_label =gen_new_label (); \tcg_gen_andi_tl (lsb, PsV,1 ); \tcg_gen_brcondi_tl (TCG_COND_NE , lsb,PRED , false_label); \ -tcg_gen_gvec_mov (MO_64 , VdV_off, VuV_off, \ -sizeof (MMVector),sizeof (MMVector)); \ +tcg_gen_gvec_mov_var (MO_64 , VdV_base, VdV_off, VuV_base, VuV_off, \ +sizeof (MMVector),sizeof (MMVector)); \gen_set_label (false_label); \ }while (0 )
@@ -186,231 +189,276 @@ static inline void assert_vhist_tmp(DisasContext *ctx)/* Vector add - various forms */ #define fGEN_TCG_V6_vaddb (SHORTCODE ) \ - tcg_gen_gvec_add(MO_8, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_add_var(MO_8, VdV_base, VdV_off, VuV_base, VuV_off, VvV_base, \ + VvV_off, sizeof(MMVector), sizeof(MMVector))#define fGEN_TCG_V6_vaddh (SHORTCYDE ) \ - tcg_gen_gvec_add(MO_16, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_add_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))#define fGEN_TCG_V6_vaddw (SHORTCODE ) \ - tcg_gen_gvec_add(MO_32, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_add_var(MO_32, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))#define fGEN_TCG_V6_vaddb_dv (SHORTCODE ) \ - tcg_gen_gvec_add(MO_8, VddV_off, VuuV_off, VvvV_off, \ - sizeof(MMVector) * 2, sizeof(MMVector) * 2) + tcg_gen_gvec_add_var(MO_8, VddV_base, VddV_off, VuuV_base, VuuV_off, \ + VvvV_base, VvvV_off, sizeof(MMVector) * 2, \ + sizeof(MMVector) * 2)#define fGEN_TCG_V6_vaddh_dv (SHORTCYDE ) \ - tcg_gen_gvec_add(MO_16, VddV_off, VuuV_off, VvvV_off, \ - sizeof(MMVector) * 2, sizeof(MMVector) * 2) + tcg_gen_gvec_add_var(MO_16, VddV_base, VddV_off, VuuV_base, VuuV_off, \ + VvvV_base, VvvV_off, sizeof(MMVector) * 2, \ + sizeof(MMVector) * 2)#define fGEN_TCG_V6_vaddw_dv (SHORTCODE ) \ - tcg_gen_gvec_add(MO_32, VddV_off, VuuV_off, VvvV_off, \ - sizeof(MMVector) * 2, sizeof(MMVector) * 2) + tcg_gen_gvec_add_var(MO_32, VddV_base, VddV_off, VuuV_base, VuuV_off, \ + VvvV_base, VvvV_off, sizeof(MMVector) * 2, \ + sizeof(MMVector) * 2)/* Vector sub - various forms */ #define fGEN_TCG_V6_vsubb (SHORTCODE ) \ - tcg_gen_gvec_sub(MO_8, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_sub_var(MO_8, VdV_base, VdV_off, VuV_base, VuV_off, VvV_base, \ + VvV_off, sizeof(MMVector), sizeof(MMVector))#define fGEN_TCG_V6_vsubh (SHORTCODE ) \ - tcg_gen_gvec_sub(MO_16, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_sub_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))#define fGEN_TCG_V6_vsubw (SHORTCODE ) \ - tcg_gen_gvec_sub(MO_32, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_sub_var(MO_32, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))#define fGEN_TCG_V6_vsubb_dv (SHORTCODE ) \ - tcg_gen_gvec_sub(MO_8, VddV_off, VuuV_off, VvvV_off, \ - sizeof(MMVector) * 2, sizeof(MMVector) * 2) + tcg_gen_gvec_sub_var(MO_8, VddV_base, VddV_off, VuuV_base, VuuV_off, \ + VvvV_base, VvvV_off, sizeof(MMVector) * 2, \ + sizeof(MMVector) * 2)#define fGEN_TCG_V6_vsubh_dv (SHORTCODE ) \ - tcg_gen_gvec_sub(MO_16, VddV_off, VuuV_off, VvvV_off, \ - sizeof(MMVector) * 2, sizeof(MMVector) * 2) + tcg_gen_gvec_sub_var(MO_16, VddV_base, VddV_off, VuuV_base, VuuV_off, \ + VvvV_base, VvvV_off, sizeof(MMVector) * 2, \ + sizeof(MMVector) * 2)#define fGEN_TCG_V6_vsubw_dv (SHORTCODE ) \ - tcg_gen_gvec_sub(MO_32, VddV_off, VuuV_off, VvvV_off, \ - sizeof(MMVector) * 2, sizeof(MMVector) * 2) + tcg_gen_gvec_sub_var(MO_32, VddV_base, VddV_off, VuuV_base, VuuV_off, \ + VvvV_base, VvvV_off, sizeof(MMVector) * 2, \ + sizeof(MMVector) * 2)#define fGEN_TCG_V6_vaddbsat (SHORTCODE ) \ - tcg_gen_gvec_ssadd(MO_8, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + tcg_gen_gvec_ssadd_var(MO_8, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vaddhsat (SHORTCODE ) \ - tcg_gen_gvec_ssadd(MO_16, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + tcg_gen_gvec_ssadd_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vaddwsat (SHORTCODE ) \ - tcg_gen_gvec_ssadd(MO_32, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + tcg_gen_gvec_ssadd_var(MO_32, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vaddubsat (SHORTCODE ) \ - tcg_gen_gvec_usadd(MO_8, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + tcg_gen_gvec_usadd_var(MO_8, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vadduhsat (SHORTCODE ) \ - tcg_gen_gvec_usadd(MO_16, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + tcg_gen_gvec_usadd_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vadduwsat (SHORTCODE ) \ - tcg_gen_gvec_usadd(MO_32, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + tcg_gen_gvec_usadd_var(MO_32, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) -#define fGEN_TCG_PAIR_ADDSUB (OP ,VECE ,DST ,SRC_A ,SRC_B ) \ - tcg_gen_gvec_##OP(VECE, DST, SRC_A, SRC_B, \ - 2 * VECTOR_SIZE_BYTE, 2 * VECTOR_SIZE_BYTE) +#define fGEN_TCG_PAIR_ADDSUB (OP ,VECE ,DBASE ,DST ,ABASE ,SRC_A ,BBASE ,SRC_B ) \ + tcg_gen_gvec_##OP##_var(VECE, DBASE, DST, ABASE, SRC_A, BBASE, SRC_B, \ + 2 * VECTOR_SIZE_BYTE, 2 * VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vaddbsat_dv (SHORTCODE ) \ - fGEN_TCG_PAIR_ADDSUB(ssadd, MO_8, VddV_off, VuuV_off, VvvV_off) + fGEN_TCG_PAIR_ADDSUB(ssadd, MO_8, VddV_base, VddV_off, \ + VuuV_base, VuuV_off, VvvV_base, VvvV_off)#define fGEN_TCG_V6_vaddhsat_dv (SHORTCODE ) \ - fGEN_TCG_PAIR_ADDSUB(ssadd, MO_16, VddV_off, VuuV_off, VvvV_off) + fGEN_TCG_PAIR_ADDSUB(ssadd, MO_16, VddV_base, VddV_off, \ + VuuV_base, VuuV_off, VvvV_base, VvvV_off)#define fGEN_TCG_V6_vaddwsat_dv (SHORTCODE ) \ - fGEN_TCG_PAIR_ADDSUB(ssadd, MO_32, VddV_off, VuuV_off, VvvV_off) + fGEN_TCG_PAIR_ADDSUB(ssadd, MO_32, VddV_base, VddV_off, \ + VuuV_base, VuuV_off, VvvV_base, VvvV_off)#define fGEN_TCG_V6_vaddubsat_dv (SHORTCODE ) \ - fGEN_TCG_PAIR_ADDSUB(usadd, MO_8, VddV_off, VuuV_off, VvvV_off) + fGEN_TCG_PAIR_ADDSUB(usadd, MO_8, VddV_base, VddV_off, \ + VuuV_base, VuuV_off, VvvV_base, VvvV_off)#define fGEN_TCG_V6_vadduhsat_dv (SHORTCODE ) \ - fGEN_TCG_PAIR_ADDSUB(usadd, MO_16, VddV_off, VuuV_off, VvvV_off) + fGEN_TCG_PAIR_ADDSUB(usadd, MO_16, VddV_base, VddV_off, \ + VuuV_base, VuuV_off, VvvV_base, VvvV_off)#define fGEN_TCG_V6_vadduwsat_dv (SHORTCODE ) \ - fGEN_TCG_PAIR_ADDSUB(usadd, MO_32, VddV_off, VuuV_off, VvvV_off) + fGEN_TCG_PAIR_ADDSUB(usadd, MO_32, VddV_base, VddV_off, \ + VuuV_base, VuuV_off, VvvV_base, VvvV_off)#define fGEN_TCG_V6_vsubbsat (SHORTCODE ) \ - tcg_gen_gvec_sssub(MO_8, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + tcg_gen_gvec_sssub_var(MO_8, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vsubhsat (SHORTCODE ) \ - tcg_gen_gvec_sssub(MO_16, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + tcg_gen_gvec_sssub_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vsubwsat (SHORTCODE ) \ - tcg_gen_gvec_sssub(MO_32, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + tcg_gen_gvec_sssub_var(MO_32, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vsububsat (SHORTCODE ) \ - tcg_gen_gvec_ussub(MO_8, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + tcg_gen_gvec_ussub_var(MO_8, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vsubuhsat (SHORTCODE ) \ - tcg_gen_gvec_ussub(MO_16, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + tcg_gen_gvec_ussub_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vsubuwsat (SHORTCODE ) \ - tcg_gen_gvec_ussub(MO_32, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + tcg_gen_gvec_ussub_var(MO_32, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vsubbsat_dv (SHORTCODE ) \ - fGEN_TCG_PAIR_ADDSUB(sssub, MO_8, VddV_off, VuuV_off, VvvV_off) + fGEN_TCG_PAIR_ADDSUB(sssub, MO_8, VddV_base, VddV_off, \ + VuuV_base, VuuV_off, VvvV_base, VvvV_off)#define fGEN_TCG_V6_vsubhsat_dv (SHORTCODE ) \ - fGEN_TCG_PAIR_ADDSUB(sssub, MO_16, VddV_off, VuuV_off, VvvV_off) + fGEN_TCG_PAIR_ADDSUB(sssub, MO_16, VddV_base, VddV_off, \ + VuuV_base, VuuV_off, VvvV_base, VvvV_off)#define fGEN_TCG_V6_vsubwsat_dv (SHORTCODE ) \ - fGEN_TCG_PAIR_ADDSUB(sssub, MO_32, VddV_off, VuuV_off, VvvV_off) + fGEN_TCG_PAIR_ADDSUB(sssub, MO_32, VddV_base, VddV_off, \ + VuuV_base, VuuV_off, VvvV_base, VvvV_off)#define fGEN_TCG_V6_vsububsat_dv (SHORTCODE ) \ - fGEN_TCG_PAIR_ADDSUB(ussub, MO_8, VddV_off, VuuV_off, VvvV_off) + fGEN_TCG_PAIR_ADDSUB(ussub, MO_8, VddV_base, VddV_off, \ + VuuV_base, VuuV_off, VvvV_base, VvvV_off)#define fGEN_TCG_V6_vsubuhsat_dv (SHORTCODE ) \ - fGEN_TCG_PAIR_ADDSUB(ussub, MO_16, VddV_off, VuuV_off, VvvV_off) + fGEN_TCG_PAIR_ADDSUB(ussub, MO_16, VddV_base, VddV_off, \ + VuuV_base, VuuV_off, VvvV_base, VvvV_off)#define fGEN_TCG_V6_vsubuwsat_dv (SHORTCODE ) \ - fGEN_TCG_PAIR_ADDSUB(ussub, MO_32, VddV_off, VuuV_off, VvvV_off) + fGEN_TCG_PAIR_ADDSUB(ussub, MO_32, VddV_base, VddV_off, \ + VuuV_base, VuuV_off, VvvV_base, VvvV_off)#define fGEN_TCG_V6_vmpyih (SHORTCODE ) \ - tcg_gen_gvec_mul(MO_16, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + tcg_gen_gvec_mul_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vabsdiffub (SHORTCODE ) \ - gen_gvec_uabsdiff(MO_8, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + gen_gvec_uabsdiff_var(MO_8, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vabsdiffuh (SHORTCODE ) \ - gen_gvec_uabsdiff(MO_16, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + gen_gvec_uabsdiff_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vabsdiffh (SHORTCODE ) \ - gen_gvec_sabsdiff(MO_16, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + gen_gvec_sabsdiff_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_V6_vabsdiffw (SHORTCODE ) \ - gen_gvec_sabsdiff(MO_32, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE) + gen_gvec_sabsdiff_var(MO_32, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE)#define fGEN_TCG_VEC_AVG (VECE ,SHIFT_FN ) \ do { \ intptr_t tmpoff = offsetof(CPUHexagonState, vtmp); \ - tcg_gen_gvec_and(MO_64, tmpoff, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ - tcg_gen_gvec_xor(MO_64, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ - SHIFT_FN(VECE, VdV_off, VdV_off, 1, \ + tcg_gen_gvec_and_var(MO_64, tcg_env, tmpoff, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ + tcg_gen_gvec_xor_var(MO_64, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ + SHIFT_FN(VECE, VdV_base, VdV_off, VdV_base, VdV_off, 1, \ VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ - tcg_gen_gvec_add(VECE, VdV_off, tmpoff, VdV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ + tcg_gen_gvec_add_var(VECE, VdV_base, VdV_off, tcg_env, tmpoff, \ + VdV_base, VdV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ } while (0)#define fGEN_TCG_V6_vavgub (SHORTCODE ) \ - fGEN_TCG_VEC_AVG(MO_8, tcg_gen_gvec_shri) + fGEN_TCG_VEC_AVG(MO_8, tcg_gen_gvec_shri_var)#define fGEN_TCG_V6_vavguh (SHORTCODE ) \ - fGEN_TCG_VEC_AVG(MO_16, tcg_gen_gvec_shri) + fGEN_TCG_VEC_AVG(MO_16, tcg_gen_gvec_shri_var)#define fGEN_TCG_V6_vavguw (SHORTCODE ) \ - fGEN_TCG_VEC_AVG(MO_32, tcg_gen_gvec_shri) + fGEN_TCG_VEC_AVG(MO_32, tcg_gen_gvec_shri_var)#define fGEN_TCG_V6_vavgb (SHORTCODE ) \ - fGEN_TCG_VEC_AVG(MO_8, tcg_gen_gvec_sari) + fGEN_TCG_VEC_AVG(MO_8, tcg_gen_gvec_sari_var)#define fGEN_TCG_V6_vavgh (SHORTCODE ) \ - fGEN_TCG_VEC_AVG(MO_16, tcg_gen_gvec_sari) + fGEN_TCG_VEC_AVG(MO_16, tcg_gen_gvec_sari_var)#define fGEN_TCG_V6_vavgw (SHORTCODE ) \ - fGEN_TCG_VEC_AVG(MO_32, tcg_gen_gvec_sari) + fGEN_TCG_VEC_AVG(MO_32, tcg_gen_gvec_sari_var)#define fGEN_TCG_VEC_AVGRND (VECE ,SHIFT_FN ) \ do { \ intptr_t tmpoff = offsetof(CPUHexagonState, vtmp); \ - tcg_gen_gvec_or(MO_64, tmpoff, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ - tcg_gen_gvec_xor(MO_64, VdV_off, VuV_off, VvV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ - SHIFT_FN(VECE, VdV_off, VdV_off, 1, \ + tcg_gen_gvec_or_var(MO_64, tcg_env, tmpoff, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ + tcg_gen_gvec_xor_var(MO_64, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ + SHIFT_FN(VECE, VdV_base, VdV_off, VdV_base, VdV_off, 1, \ VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ - tcg_gen_gvec_sub(VECE, VdV_off, tmpoff, VdV_off, \ - VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ + tcg_gen_gvec_sub_var(VECE, VdV_base, VdV_off, tcg_env, tmpoff, \ + VdV_base, VdV_off, \ + VECTOR_SIZE_BYTE, VECTOR_SIZE_BYTE); \ } while (0)#define fGEN_TCG_V6_vavgubrnd (SHORTCODE ) \ - fGEN_TCG_VEC_AVGRND(MO_8, tcg_gen_gvec_shri) + fGEN_TCG_VEC_AVGRND(MO_8, tcg_gen_gvec_shri_var)#define fGEN_TCG_V6_vavguhrnd (SHORTCODE ) \ - fGEN_TCG_VEC_AVGRND(MO_16, tcg_gen_gvec_shri) + fGEN_TCG_VEC_AVGRND(MO_16, tcg_gen_gvec_shri_var)#define fGEN_TCG_V6_vavguwrnd (SHORTCODE ) \ - fGEN_TCG_VEC_AVGRND(MO_32, tcg_gen_gvec_shri) + fGEN_TCG_VEC_AVGRND(MO_32, tcg_gen_gvec_shri_var)#define fGEN_TCG_V6_vavgbrnd (SHORTCODE ) \ - fGEN_TCG_VEC_AVGRND(MO_8, tcg_gen_gvec_sari) + fGEN_TCG_VEC_AVGRND(MO_8, tcg_gen_gvec_sari_var)#define fGEN_TCG_V6_vavghrnd (SHORTCODE ) \ - fGEN_TCG_VEC_AVGRND(MO_16, tcg_gen_gvec_sari) + fGEN_TCG_VEC_AVGRND(MO_16, tcg_gen_gvec_sari_var)#define fGEN_TCG_V6_vavgwrnd (SHORTCODE ) \ - fGEN_TCG_VEC_AVGRND(MO_32, tcg_gen_gvec_sari) + fGEN_TCG_VEC_AVGRND(MO_32, tcg_gen_gvec_sari_var)/* Vector shift right - various forms */ #define fGEN_TCG_V6_vasrh (SHORTCODE ) \ do { \ TCGv shift = tcg_temp_new(); \ tcg_gen_andi_tl(shift, RtV, 15); \ - tcg_gen_gvec_sars(MO_16, VdV_off, VuV_off, shift, \ - sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_sars_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + shift, sizeof(MMVector), sizeof(MMVector)); \ } while (0)#define fGEN_TCG_V6_vasrh_acc (SHORTCODE ) \
@@ -418,18 +466,19 @@ static inline void assert_vhist_tmp(DisasContext *ctx)intptr_t tmpoff = offsetof(CPUHexagonState , vtmp); \TCGv shift =tcg_temp_new (); \tcg_gen_andi_tl (shift, RtV,15 ); \ -tcg_gen_gvec_sars (MO_16 , tmpoff, VuV_off, shift, \ -sizeof (MMVector),sizeof (MMVector)); \ -tcg_gen_gvec_add (MO_16 , VxV_off, VxV_off, tmpoff, \ -sizeof (MMVector),sizeof (MMVector)); \ +tcg_gen_gvec_sars_var (MO_16 , tcg_env, tmpoff, VuV_base, VuV_off, \ + shift,sizeof (MMVector),sizeof (MMVector)); \ +tcg_gen_gvec_add_var (MO_16 , VxV_base, VxV_off, VxV_base, VxV_off, \ + tcg_env, tmpoff,sizeof (MMVector), \ +sizeof (MMVector)); \ } while (0)#define fGEN_TCG_V6_vasrw (SHORTCODE ) \ do { \ TCGv shift = tcg_temp_new(); \ tcg_gen_andi_tl(shift, RtV, 31); \ - tcg_gen_gvec_sars(MO_32, VdV_off, VuV_off, shift, \ - sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_sars_var(MO_32, VdV_base, VdV_off, VuV_base, VuV_off, \ + shift, sizeof(MMVector), sizeof(MMVector)); \ } while (0)#define fGEN_TCG_V6_vasrw_acc (SHORTCODE ) \
@@ -437,34 +486,35 @@ static inline void assert_vhist_tmp(DisasContext *ctx)intptr_t tmpoff = offsetof(CPUHexagonState , vtmp); \TCGv shift =tcg_temp_new (); \tcg_gen_andi_tl (shift, RtV,31 ); \ -tcg_gen_gvec_sars (MO_32 , tmpoff, VuV_off, shift, \ -sizeof (MMVector),sizeof (MMVector)); \ -tcg_gen_gvec_add (MO_32 , VxV_off, VxV_off, tmpoff, \ -sizeof (MMVector),sizeof (MMVector)); \ +tcg_gen_gvec_sars_var (MO_32 , tcg_env, tmpoff, VuV_base, VuV_off, \ + shift,sizeof (MMVector),sizeof (MMVector)); \ +tcg_gen_gvec_add_var (MO_32 , VxV_base, VxV_off, VxV_base, VxV_off, \ + tcg_env, tmpoff,sizeof (MMVector), \ +sizeof (MMVector)); \ } while (0)#define fGEN_TCG_V6_vlsrb (SHORTCODE ) \ do { \ TCGv shift = tcg_temp_new(); \ tcg_gen_andi_tl(shift, RtV, 7); \ - tcg_gen_gvec_shrs(MO_8, VdV_off, VuV_off, shift, \ - sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_shrs_var(MO_8, VdV_base, VdV_off, VuV_base, VuV_off, \ + shift, sizeof(MMVector), sizeof(MMVector)); \ } while (0)#define fGEN_TCG_V6_vlsrh (SHORTCODE ) \ do { \ TCGv shift = tcg_temp_new(); \ tcg_gen_andi_tl(shift, RtV, 15); \ - tcg_gen_gvec_shrs(MO_16, VdV_off, VuV_off, shift, \ - sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_shrs_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + shift, sizeof(MMVector), sizeof(MMVector)); \ } while (0)#define fGEN_TCG_V6_vlsrw (SHORTCODE ) \ do { \ TCGv shift = tcg_temp_new(); \ tcg_gen_andi_tl(shift, RtV, 31); \ - tcg_gen_gvec_shrs(MO_32, VdV_off, VuV_off, shift, \ - sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_shrs_var(MO_32, VdV_base, VdV_off, VuV_base, VuV_off, \ + shift, sizeof(MMVector), sizeof(MMVector)); \ } while (0)/* Vector shift left - various forms */
@@ -472,16 +522,16 @@ static inline void assert_vhist_tmp(DisasContext *ctx)do { \TCGv shift =tcg_temp_new (); \tcg_gen_andi_tl (shift, RtV,7 ); \ -tcg_gen_gvec_shls (MO_8 , VdV_off, VuV_off, shift, \ -sizeof (MMVector),sizeof (MMVector)); \ +tcg_gen_gvec_shls_var (MO_8 , VdV_base, VdV_off, VuV_base, VuV_off, \ + shift,sizeof (MMVector),sizeof (MMVector)); \ } while (0)#define fGEN_TCG_V6_vaslh (SHORTCODE ) \ do { \ TCGv shift = tcg_temp_new(); \ tcg_gen_andi_tl(shift, RtV, 15); \ - tcg_gen_gvec_shls(MO_16, VdV_off, VuV_off, shift, \ - sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_shls_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + shift, sizeof(MMVector), sizeof(MMVector)); \ } while (0)#define fGEN_TCG_V6_vaslh_acc (SHORTCODE ) \
@@ -489,18 +539,19 @@ static inline void assert_vhist_tmp(DisasContext *ctx)intptr_t tmpoff = offsetof(CPUHexagonState , vtmp); \TCGv shift =tcg_temp_new (); \tcg_gen_andi_tl (shift, RtV,15 ); \ -tcg_gen_gvec_shls (MO_16 , tmpoff, VuV_off, shift, \ -sizeof (MMVector),sizeof (MMVector)); \ -tcg_gen_gvec_add (MO_16 , VxV_off, VxV_off, tmpoff, \ -sizeof (MMVector),sizeof (MMVector)); \ +tcg_gen_gvec_shls_var (MO_16 , tcg_env, tmpoff, VuV_base, VuV_off, \ + shift,sizeof (MMVector),sizeof (MMVector)); \ +tcg_gen_gvec_add_var (MO_16 , VxV_base, VxV_off, VxV_base, VxV_off, \ + tcg_env, tmpoff,sizeof (MMVector), \ +sizeof (MMVector)); \ } while (0)#define fGEN_TCG_V6_vaslw (SHORTCODE ) \ do { \ TCGv shift = tcg_temp_new(); \ tcg_gen_andi_tl(shift, RtV, 31); \ - tcg_gen_gvec_shls(MO_32, VdV_off, VuV_off, shift, \ - sizeof(MMVector), sizeof(MMVector)); \ + tcg_gen_gvec_shls_var(MO_32, VdV_base, VdV_off, VuV_base, VuV_off, \ + shift, sizeof(MMVector), sizeof(MMVector)); \ } while (0)#define fGEN_TCG_V6_vaslw_acc (SHORTCODE ) \
@@ -508,95 +559,109 @@ static inline void assert_vhist_tmp(DisasContext *ctx)intptr_t tmpoff = offsetof(CPUHexagonState , vtmp); \TCGv shift =tcg_temp_new (); \tcg_gen_andi_tl (shift, RtV,31 ); \ -tcg_gen_gvec_shls (MO_32 , tmpoff, VuV_off, shift, \ -sizeof (MMVector),sizeof (MMVector)); \ -tcg_gen_gvec_add (MO_32 , VxV_off, VxV_off, tmpoff, \ -sizeof (MMVector),sizeof (MMVector)); \ +tcg_gen_gvec_shls_var (MO_32 , tcg_env, tmpoff, VuV_base, VuV_off, \ + shift,sizeof (MMVector),sizeof (MMVector)); \ +tcg_gen_gvec_add_var (MO_32 , VxV_base, VxV_off, VxV_base, VxV_off, \ + tcg_env, tmpoff,sizeof (MMVector), \ +sizeof (MMVector)); \ }while (0 ) /* Vector max - various forms */#define fGEN_TCG_V6_vmaxw (SHORTCODE ) \ - tcg_gen_gvec_smax(MO_32, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_smax_var(MO_32, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))#define fGEN_TCG_V6_vmaxh (SHORTCODE ) \ - tcg_gen_gvec_smax(MO_16, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_smax_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))#define fGEN_TCG_V6_vmaxuh (SHORTCODE ) \ - tcg_gen_gvec_umax(MO_16, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_umax_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))#define fGEN_TCG_V6_vmaxb (SHORTCODE ) \ - tcg_gen_gvec_smax(MO_8, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_smax_var(MO_8, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))#define fGEN_TCG_V6_vmaxub (SHORTCODE ) \ - tcg_gen_gvec_umax(MO_8, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_umax_var(MO_8, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))/* Vector min - various forms */ #define fGEN_TCG_V6_vminw (SHORTCODE ) \ - tcg_gen_gvec_smin(MO_32, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_smin_var(MO_32, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))#define fGEN_TCG_V6_vminh (SHORTCODE ) \ - tcg_gen_gvec_smin(MO_16, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_smin_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))#define fGEN_TCG_V6_vminuh (SHORTCODE ) \ - tcg_gen_gvec_umin(MO_16, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_umin_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))#define fGEN_TCG_V6_vminb (SHORTCODE ) \ - tcg_gen_gvec_smin(MO_8, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_smin_var(MO_8, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))#define fGEN_TCG_V6_vminub (SHORTCODE ) \ - tcg_gen_gvec_umin(MO_8, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_umin_var(MO_8, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))/* Vector logical ops */ #define fGEN_TCG_V6_vxor (SHORTCODE ) \ - tcg_gen_gvec_xor(MO_64, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_xor_var(MO_64, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))#define fGEN_TCG_V6_vand (SHORTCODE ) \ - tcg_gen_gvec_and(MO_64, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_and_var(MO_64, VdV_base, VdV_off, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector))#define fGEN_TCG_V6_vor (SHORTCODE ) \ - tcg_gen_gvec_or(MO_64, VdV_off, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_or_var(MO_64, VdV_base, VdV_off, VuV_base, VuV_off, VvV_base, \ + VvV_off, sizeof(MMVector), sizeof(MMVector))#define fGEN_TCG_V6_vnot (SHORTCODE ) \ - tcg_gen_gvec_not(MO_64, VdV_off, VuV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_not_var(MO_64, VdV_base, VdV_off, VuV_base, VuV_off, \ + sizeof(MMVector), sizeof(MMVector))/* Q register logical ops */ #define fGEN_TCG_V6_pred_or (SHORTCODE ) \ - tcg_gen_gvec_or(MO_64, QdV_off, QsV_off, QtV_off, \ - sizeof(MMQReg), sizeof(MMQReg)) + tcg_gen_gvec_or_var(MO_64, QdV_base, QdV_off, QsV_base, QsV_off, QtV_base, \ + QtV_off, sizeof(MMQReg), sizeof(MMQReg))#define fGEN_TCG_V6_pred_and (SHORTCODE ) \ - tcg_gen_gvec_and(MO_64, QdV_off, QsV_off, QtV_off, \ - sizeof(MMQReg), sizeof(MMQReg)) + tcg_gen_gvec_and_var(MO_64, QdV_base, QdV_off, QsV_base, QsV_off, \ + QtV_base, QtV_off, sizeof(MMQReg), sizeof(MMQReg))#define fGEN_TCG_V6_pred_xor (SHORTCODE ) \ - tcg_gen_gvec_xor(MO_64, QdV_off, QsV_off, QtV_off, \ - sizeof(MMQReg), sizeof(MMQReg)) + tcg_gen_gvec_xor_var(MO_64, QdV_base, QdV_off, QsV_base, QsV_off, \ + QtV_base, QtV_off, sizeof(MMQReg), sizeof(MMQReg))#define fGEN_TCG_V6_pred_or_n (SHORTCODE ) \ - tcg_gen_gvec_orc(MO_64, QdV_off, QsV_off, QtV_off, \ - sizeof(MMQReg), sizeof(MMQReg)) + tcg_gen_gvec_orc_var(MO_64, QdV_base, QdV_off, QsV_base, QsV_off, \ + QtV_base, QtV_off, sizeof(MMQReg), sizeof(MMQReg))#define fGEN_TCG_V6_pred_and_n (SHORTCODE ) \ - tcg_gen_gvec_andc(MO_64, QdV_off, QsV_off, QtV_off, \ - sizeof(MMQReg), sizeof(MMQReg)) + tcg_gen_gvec_andc_var(MO_64, QdV_base, QdV_off, QsV_base, QsV_off, \ + QtV_base, QtV_off, sizeof(MMQReg), sizeof(MMQReg))#define fGEN_TCG_V6_pred_not (SHORTCODE ) \ - tcg_gen_gvec_not(MO_64, QdV_off, QsV_off, \ - sizeof(MMQReg), sizeof(MMQReg)) + tcg_gen_gvec_not_var(MO_64, QdV_base, QdV_off, QsV_base, QsV_off, \ + sizeof(MMQReg), sizeof(MMQReg))/* Vector compares */ #define fGEN_TCG_VEC_CMP (COND ,TYPE ,SIZE ) \ do { \ intptr_t tmpoff = offsetof(CPUHexagonState, vtmp); \ - tcg_gen_gvec_cmp(COND, TYPE, tmpoff, VuV_off, VvV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ - vec_to_qvec(SIZE, QdV_off, tmpoff); \ + tcg_gen_gvec_cmp_var(COND, TYPE, tcg_env, tmpoff, VuV_base, VuV_off, \ + VvV_base, VvV_off, sizeof(MMVector), \ + sizeof(MMVector)); \ + vec_to_qvec(SIZE, QdV_base, QdV_off, tcg_env, tmpoff); \ } while (0)#define fGEN_TCG_V6_vgtw (SHORTCODE ) \
@@ -624,100 +689,102 @@ static inline void assert_vhist_tmp(DisasContext *ctx)do { \intptr_t tmpoff = offsetof(CPUHexagonState , vtmp); \intptr_t qoff = offsetof(CPUHexagonState , qtmp); \ -tcg_gen_gvec_cmp (COND ,TYPE , tmpoff, VuV_off, VvV_off, \ -sizeof (MMVector),sizeof (MMVector)); \ -vec_to_qvec (SIZE , qoff, tmpoff); \ -OP (MO_64 , QxV_off, QxV_off, qoff,sizeof (MMQReg),sizeof (MMQReg)); \ +tcg_gen_gvec_cmp_var (COND ,TYPE , tcg_env, tmpoff, VuV_base, VuV_off, \ + VvV_base, VvV_off,sizeof (MMVector), \ +sizeof (MMVector)); \ +vec_to_qvec (SIZE , tcg_env, qoff, tcg_env, tmpoff); \ +OP (MO_64 , QxV_base, QxV_off, QxV_base, QxV_off, tcg_env, qoff, \ +sizeof (MMQReg),sizeof (MMQReg)); \ } while (0)#define fGEN_TCG_V6_vgtw_and (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_32, 4, tcg_gen_gvec_and) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_32, 4, tcg_gen_gvec_and_var)#define fGEN_TCG_V6_vgtw_or (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_32, 4, tcg_gen_gvec_or) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_32, 4, tcg_gen_gvec_or_var)#define fGEN_TCG_V6_vgtw_xor (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_32, 4, tcg_gen_gvec_xor) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_32, 4, tcg_gen_gvec_xor_var)#define fGEN_TCG_V6_vgtuw_and (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_32, 4, tcg_gen_gvec_and) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_32, 4, tcg_gen_gvec_and_var)#define fGEN_TCG_V6_vgtuw_or (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_32, 4, tcg_gen_gvec_or) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_32, 4, tcg_gen_gvec_or_var)#define fGEN_TCG_V6_vgtuw_xor (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_32, 4, tcg_gen_gvec_xor) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_32, 4, tcg_gen_gvec_xor_var)#define fGEN_TCG_V6_vgth_and (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_16, 2, tcg_gen_gvec_and) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_16, 2, tcg_gen_gvec_and_var)#define fGEN_TCG_V6_vgth_or (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_16, 2, tcg_gen_gvec_or) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_16, 2, tcg_gen_gvec_or_var)#define fGEN_TCG_V6_vgth_xor (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_16, 2, tcg_gen_gvec_xor) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_16, 2, tcg_gen_gvec_xor_var)#define fGEN_TCG_V6_vgtuh_and (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_16, 2, tcg_gen_gvec_and) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_16, 2, tcg_gen_gvec_and_var)#define fGEN_TCG_V6_vgtuh_or (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_16, 2, tcg_gen_gvec_or) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_16, 2, tcg_gen_gvec_or_var)#define fGEN_TCG_V6_vgtuh_xor (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_16, 2, tcg_gen_gvec_xor) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_16, 2, tcg_gen_gvec_xor_var)#define fGEN_TCG_V6_vgtb_and (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_8, 1, tcg_gen_gvec_and) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_8, 1, tcg_gen_gvec_and_var)#define fGEN_TCG_V6_vgtb_or (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_8, 1, tcg_gen_gvec_or) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_8, 1, tcg_gen_gvec_or_var)#define fGEN_TCG_V6_vgtb_xor (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_8, 1, tcg_gen_gvec_xor) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GT, MO_8, 1, tcg_gen_gvec_xor_var)#define fGEN_TCG_V6_vgtub_and (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_8, 1, tcg_gen_gvec_and) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_8, 1, tcg_gen_gvec_and_var)#define fGEN_TCG_V6_vgtub_or (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_8, 1, tcg_gen_gvec_or) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_8, 1, tcg_gen_gvec_or_var)#define fGEN_TCG_V6_vgtub_xor (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_8, 1, tcg_gen_gvec_xor) + fGEN_TCG_VEC_CMP_OP(TCG_COND_GTU, MO_8, 1, tcg_gen_gvec_xor_var)#define fGEN_TCG_V6_veqw_and (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_32, 4, tcg_gen_gvec_and) + fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_32, 4, tcg_gen_gvec_and_var)#define fGEN_TCG_V6_veqw_or (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_32, 4, tcg_gen_gvec_or) + fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_32, 4, tcg_gen_gvec_or_var)#define fGEN_TCG_V6_veqw_xor (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_32, 4, tcg_gen_gvec_xor) + fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_32, 4, tcg_gen_gvec_xor_var)#define fGEN_TCG_V6_veqh_and (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_16, 2, tcg_gen_gvec_and) + fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_16, 2, tcg_gen_gvec_and_var)#define fGEN_TCG_V6_veqh_or (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_16, 2, tcg_gen_gvec_or) + fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_16, 2, tcg_gen_gvec_or_var)#define fGEN_TCG_V6_veqh_xor (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_16, 2, tcg_gen_gvec_xor) + fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_16, 2, tcg_gen_gvec_xor_var)#define fGEN_TCG_V6_veqb_and (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_8, 1, tcg_gen_gvec_and) + fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_8, 1, tcg_gen_gvec_and_var)#define fGEN_TCG_V6_veqb_or (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_8, 1, tcg_gen_gvec_or) + fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_8, 1, tcg_gen_gvec_or_var)#define fGEN_TCG_V6_veqb_xor (SHORTCODE ) \ - fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_8, 1, tcg_gen_gvec_xor) + fGEN_TCG_VEC_CMP_OP(TCG_COND_EQ, MO_8, 1, tcg_gen_gvec_xor_var)/* Vector splat - various forms */ #define fGEN_TCG_V6_lvsplatw (SHORTCODE ) \ - tcg_gen_gvec_dup_i32(MO_32, VdV_off, \ - sizeof(MMVector), sizeof(MMVector), RtV) + tcg_gen_gvec_dup_i32_var(MO_32, VdV_base, VdV_off, sizeof(MMVector), \ + sizeof(MMVector), RtV)#define fGEN_TCG_V6_lvsplath (SHORTCODE ) \ - tcg_gen_gvec_dup_i32(MO_16, VdV_off, \ - sizeof(MMVector), sizeof(MMVector), RtV) + tcg_gen_gvec_dup_i32_var(MO_16, VdV_base, VdV_off, sizeof(MMVector), \ + sizeof(MMVector), RtV)#define fGEN_TCG_V6_lvsplatb (SHORTCODE ) \ - tcg_gen_gvec_dup_i32(MO_8, VdV_off, \ - sizeof(MMVector), sizeof(MMVector), RtV) + tcg_gen_gvec_dup_i32_var(MO_8, VdV_base, VdV_off, sizeof(MMVector), \ + sizeof(MMVector), RtV)/* Vector absolute value - various forms */ #define fGEN_TCG_V6_vabsb (SHORTCODE ) \ - tcg_gen_gvec_abs(MO_8, VdV_off, VuV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_abs_var(MO_8, VdV_base, VdV_off, VuV_base, VuV_off, \ + sizeof(MMVector), sizeof(MMVector))#define fGEN_TCG_V6_vabsh (SHORTCODE ) \ - tcg_gen_gvec_abs(MO_16, VdV_off, VuV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_abs_var(MO_16, VdV_base, VdV_off, VuV_base, VuV_off, \ + sizeof(MMVector), sizeof(MMVector))#define fGEN_TCG_V6_vabsw (SHORTCODE ) \ - tcg_gen_gvec_abs(MO_32, VdV_off, VuV_off, \ - sizeof(MMVector), sizeof(MMVector)) + tcg_gen_gvec_abs_var(MO_32, VdV_base, VdV_off, VuV_base, VuV_off, \ + sizeof(MMVector), sizeof(MMVector))/* Vector loads */ #define fGEN_TCG_V6_vL32b_pi (SHORTCODE ) SHORTCODE
@@ -743,14 +810,14 @@ static inline void assert_vhist_tmp(DisasContext *ctx)#define fGEN_TCG_V6_vL32b_nt_tmp_ppu (SHORTCODE ) SHORTCODE/* Predicated vector loads */ -#define fGEN_TCG_PRED_VEC_LOAD (GET_EA ,PRED ,DSTOFF ,INC ) \ +#define fGEN_TCG_PRED_VEC_LOAD (GET_EA ,PRED ,DST ,INC ) \ do { \ TCGv LSB = tcg_temp_new(); \ TCGLabel *false_label = gen_new_label(); \ GET_EA; \ PRED; \ tcg_gen_brcondi_tl(TCG_COND_EQ, LSB, 0, false_label); \ - gen_vreg_load(ctx, DSTOFF, EA, true); \ + gen_vreg_load(ctx, DST##_base, DST##_off, EA, true); \ INC; \ gen_set_label(false_label); \ } while (0)
@@ -758,12 +825,12 @@ static inline void assert_vhist_tmp(DisasContext *ctx)#define fGEN_TCG_PRED_VEC_LOAD_pred_pi \ fGEN_TCG_PRED_VEC_LOAD(fLSBOLD(PvV), \ fEA_REG(RxV), \ - VdV_off, \ + VdV, \ fPM_I(RxV, siV * sizeof(MMVector)))#define fGEN_TCG_PRED_VEC_LOAD_npred_pi \ fGEN_TCG_PRED_VEC_LOAD(fLSBOLDNOT(PvV), \ fEA_REG(RxV), \ - VdV_off, \ + VdV, \ fPM_I(RxV, siV * sizeof(MMVector)))#define fGEN_TCG_V6_vL32b_pred_pi (SHORTCODE ) \
@@ -794,12 +861,12 @@ static inline void assert_vhist_tmp(DisasContext *ctx)#define fGEN_TCG_PRED_VEC_LOAD_pred_ai \ fGEN_TCG_PRED_VEC_LOAD(fLSBOLD(PvV), \ fEA_RI(RtV, siV * sizeof(MMVector)), \ - VdV_off, \ + VdV, \ do {} while (0))#define fGEN_TCG_PRED_VEC_LOAD_npred_ai \ fGEN_TCG_PRED_VEC_LOAD(fLSBOLDNOT(PvV), \ fEA_RI(RtV, siV * sizeof(MMVector)), \ - VdV_off, \ + VdV, \ do {} while (0))#define fGEN_TCG_V6_vL32b_pred_ai (SHORTCODE ) \
@@ -830,12 +897,12 @@ static inline void assert_vhist_tmp(DisasContext *ctx)#define fGEN_TCG_PRED_VEC_LOAD_pred_ppu \ fGEN_TCG_PRED_VEC_LOAD(fLSBOLD(PvV), \ fEA_REG(RxV), \ - VdV_off, \ + VdV, \ fPM_M(RxV, MuV))#define fGEN_TCG_PRED_VEC_LOAD_npred_ppu \ fGEN_TCG_PRED_VEC_LOAD(fLSBOLDNOT(PvV), \ fEA_REG(RxV), \ - VdV_off, \ + VdV, \ fPM_M(RxV, MuV))#define fGEN_TCG_V6_vL32b_pred_ppu (SHORTCODE ) \
@@ -878,7 +945,7 @@ static inline void assert_vhist_tmp(DisasContext *ctx)#define fGEN_TCG_NEWVAL_VEC_STORE (GET_EA ,INC ) \ do { \ GET_EA; \ - gen_vreg_store(ctx, EA, OsN_off, insn->slot, true); \ + gen_vreg_store(ctx, EA, OsN_base, OsN_off, insn->slot, true); \ INC; \ } while (0)
@@ -908,14 +975,15 @@ static inline void assert_vhist_tmp(DisasContext *ctx) fGEN_TCG_NEWVAL_VEC_STORE_ppu /* Predicated vector stores */ -#define fGEN_TCG_PRED_VEC_STORE(GET_EA, PRED, SRCOFF, ALIGN, INC) \ +#define fGEN_TCG_PRED_VEC_STORE (GET_EA ,PRED ,SRC ,ALIGN ,INC ) \ do { \ TCGv LSB = tcg_temp_new(); \ TCGLabel *false_label = gen_new_label(); \ GET_EA; \ PRED; \ tcg_gen_brcondi_tl(TCG_COND_EQ, LSB, 0, false_label); \ -gen_vreg_store (ctx,EA ,SRCOFF , insn->slot,ALIGN ); \ + gen_vreg_store(ctx, EA, SRC##_base, SRC##_off, insn->slot, \ + ALIGN); \ INC; \ gen_set_label(false_label); \ } while (0)
@@ -923,22 +991,22 @@ static inline void assert_vhist_tmp(DisasContext *ctx)#define fGEN_TCG_PRED_VEC_STORE_pred_pi (ALIGN ) \ fGEN_TCG_PRED_VEC_STORE(fLSBOLD(PvV), \ fEA_REG(RxV), \ - VsV_off, ALIGN, \ + VsV, ALIGN, \ fPM_I(RxV, siV * sizeof(MMVector)))#define fGEN_TCG_PRED_VEC_STORE_npred_pi (ALIGN ) \ fGEN_TCG_PRED_VEC_STORE(fLSBOLDNOT(PvV), \ fEA_REG(RxV), \ - VsV_off, ALIGN, \ + VsV, ALIGN, \ fPM_I(RxV, siV * sizeof(MMVector)))#define fGEN_TCG_PRED_VEC_STORE_new_pred_pi \ fGEN_TCG_PRED_VEC_STORE(fLSBOLD(PvV), \ fEA_REG(RxV), \ - OsN_off, true, \ + OsN, true, \ fPM_I(RxV, siV * sizeof(MMVector)))#define fGEN_TCG_PRED_VEC_STORE_new_npred_pi \ fGEN_TCG_PRED_VEC_STORE(fLSBOLDNOT(PvV), \ fEA_REG(RxV), \ - OsN_off, true, \ + OsN, true, \ fPM_I(RxV, siV * sizeof(MMVector)))#define fGEN_TCG_V6_vS32b_pred_pi (SHORTCODE ) \
@@ -965,22 +1033,22 @@ static inline void assert_vhist_tmp(DisasContext *ctx)#define fGEN_TCG_PRED_VEC_STORE_pred_ai (ALIGN ) \ fGEN_TCG_PRED_VEC_STORE(fLSBOLD(PvV), \ fEA_RI(RtV, siV * sizeof(MMVector)), \ - VsV_off, ALIGN, \ + VsV, ALIGN, \ do { } while (0))#define fGEN_TCG_PRED_VEC_STORE_npred_ai (ALIGN ) \ fGEN_TCG_PRED_VEC_STORE(fLSBOLDNOT(PvV), \ fEA_RI(RtV, siV * sizeof(MMVector)), \ - VsV_off, ALIGN, \ + VsV, ALIGN, \ do { } while (0))#define fGEN_TCG_PRED_VEC_STORE_new_pred_ai \ fGEN_TCG_PRED_VEC_STORE(fLSBOLD(PvV), \ fEA_RI(RtV, siV * sizeof(MMVector)), \ - OsN_off, true, \ + OsN, true, \ do { } while (0))#define fGEN_TCG_PRED_VEC_STORE_new_npred_ai \ fGEN_TCG_PRED_VEC_STORE(fLSBOLDNOT(PvV), \ fEA_RI(RtV, siV * sizeof(MMVector)), \ - OsN_off, true, \ + OsN, true, \ do { } while (0))#define fGEN_TCG_V6_vS32b_pred_ai (SHORTCODE ) \
@@ -1007,22 +1075,22 @@ static inline void assert_vhist_tmp(DisasContext *ctx)#define fGEN_TCG_PRED_VEC_STORE_pred_ppu (ALIGN ) \ fGEN_TCG_PRED_VEC_STORE(fLSBOLD(PvV), \ fEA_REG(RxV), \ - VsV_off, ALIGN, \ + VsV, ALIGN, \ fPM_M(RxV, MuV))#define fGEN_TCG_PRED_VEC_STORE_npred_ppu (ALIGN ) \ fGEN_TCG_PRED_VEC_STORE(fLSBOLDNOT(PvV), \ fEA_REG(RxV), \ - VsV_off, ALIGN, \ + VsV, ALIGN, \ fPM_M(RxV, MuV))#define fGEN_TCG_PRED_VEC_STORE_new_pred_ppu \ fGEN_TCG_PRED_VEC_STORE(fLSBOLD(PvV), \ fEA_REG(RxV), \ - OsN_off, true, \ + OsN, true, \ fPM_M(RxV, MuV))#define fGEN_TCG_PRED_VEC_STORE_new_npred_ppu \ fGEN_TCG_PRED_VEC_STORE(fLSBOLDNOT(PvV), \ fEA_REG(RxV), \ - OsN_off, true, \ + OsN, true, \ fPM_M(RxV, MuV))#define fGEN_TCG_V6_vS32b_pred_ppu (SHORTCODE ) \
target/hexagon/genptr.h +8 -0
@@ -59,6 +59,14 @@ TCGv gen_get_half(TCGv result, int N, TCGv src, bool sign);void gen_set_half (int N ,TCGv result,TCGv src);void gen_set_half_i64 (int N ,TCGv_i64 result,TCGv src);void probe_noshuf_load (TCGv va,int s,int mi); +void gen_gvec_sabsdiff_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz); +void gen_gvec_uabsdiff_var (unsigned vece,TCGv_ptr dbase,uint32_t dofs, +TCGv_ptr abase,uint32_t aofs, +TCGv_ptr bbase,uint32_t bofs, +uint32_t oprsz,uint32_t maxsz);void gen_gvec_sabsdiff (unsigned vece,uint32_t dofs,uint32_t aofs,uint32_t bofs,uint32_t oprsz,uint32_t maxsz); void gen_gvec_uabsdiff(unsigned vece, uint32_t dofs, uint32_t aofs,
target/hexagon/mmvec/macros.h +8 -6
@@ -286,26 +286,28 @@fV_AL_CHECK (EA ,fVECSIZE () -1 ); \ } while (0)#ifdef QEMU_GENERATE -#define fLOADMMV (EA ,DST ) gen_vreg_load(ctx, DST##_off, EA, true) +#define fLOADMMV (EA ,DST ) gen_vreg_load(ctx, DST##_base, DST##_off, EA, true)#endif #ifdef QEMU_GENERATE -#define fLOADMMVU (EA ,DST ) gen_vreg_load(ctx, DST##_off, EA, false) +#define fLOADMMVU (EA ,DST ) gen_vreg_load(ctx, DST##_base, DST##_off, EA, false)#endif #ifdef QEMU_GENERATE #define fSTOREMMV (EA ,SRC ) \ - gen_vreg_store(ctx, EA, SRC##_off, insn->slot, true) + gen_vreg_store(ctx, EA, SRC##_base, SRC##_off, insn->slot, true)#endif #ifdef QEMU_GENERATE #define fSTOREMMVQ (EA ,SRC ,MASK ) \ - gen_vreg_masked_store(ctx, EA, SRC##_off, MASK##_off, insn->slot, false) + gen_vreg_masked_store(ctx, EA, SRC##_base, SRC##_off, \ + MASK##_base, MASK##_off, insn->slot, false)#endif #ifdef QEMU_GENERATE #define fSTOREMMVNQ (EA ,SRC ,MASK ) \ - gen_vreg_masked_store(ctx, EA, SRC##_off, MASK##_off, insn->slot, true) + gen_vreg_masked_store(ctx, EA, SRC##_base, SRC##_off, \ + MASK##_base, MASK##_off, insn->slot, true)#endif #ifdef QEMU_GENERATE #define fSTOREMMVU (EA ,SRC ) \ - gen_vreg_store(ctx, EA, SRC##_off, insn->slot, false) + gen_vreg_store(ctx, EA, SRC##_base, SRC##_off, insn->slot, false)#endif #define fVFOREACH (WIDTH ,VAR ) for (VAR = 0; VAR < fVELEM(WIDTH); VAR++)#define fVARRAY_ELEMENT_ACCESS (ARRAY ,TYPE ,INDEX ) \
target/hexagon/translate.h +3 -2
@@ -91,6 +91,7 @@ typedef struct DisasContext {bool pcycle_enabled;bool hvx_coproc_enabled;bool hvx_check_emitted; +TCGv_ptr hvx_base;uint32_t num_cycles; } DisasContext;
@@ -192,9 +193,9 @@ static inline void ctx_log_reg_read_pair(DisasContext *ctx, int rnum) }intptr_t ctx_future_vreg_off (DisasContext *ctx,int regnum, -int num,bool alloc_ok); +int num,bool alloc_ok,TCGv_ptr *base);intptr_t ctx_tmp_vreg_off (DisasContext *ctx,int regnum, -int num,bool alloc_ok); +int num,bool alloc_ok,TCGv_ptr *base);static inline void ctx_start_hvx_insn (DisasContext *ctx) {
target/hexagon/genptr.c +65 -37
204 lines not on this page · raw message
target/hexagon/translate.c +38 -20
114 lines not on this page · raw message
target/hexagon/hex_common.py +103 -78
304 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH 6/9] target/hexagon: carry a base ptr w/HVX reg offsets
Quoted 10 lines · Brian Cain
An HVX register operand was a bare offset from env. That works only while the register file was part of CPUHexagonState. When it moves to an HVX context shared between hardware threads, its address is not a translation-time constant.
While here, fold the repeated helper-argument pointer setup in
hex_common.pyintoHvx.decl_tcg_ptr().Signed-off-by Brian Cain <[email protected]>
Quoted 9 lines
--- target/hexagon/gen_tcg_hvx.h | 608 +++++++++++++++++++--------------- target/hexagon/genptr.h | 8 + target/hexagon/mmvec/macros.h | 14 +- target/hexagon/translate.h | 5 +- target/hexagon/genptr.c | 102 +++--- target/hexagon/translate.c | 58 ++-- target/hexagon/hex_common.py | 181 +++++----- 7 files changed, 563 insertions(+), 413 deletions(-)
PATCH 7/9 target/hexagon: move the HVX register file into a QOM object
In reply to Brian CainEach DSP ordinarily has fewer HVX contexts than hw threads. The thread's SSR:XA selects the one it's bound to.
Add a hexagon-hvx-context device holding the register file. The machine creates as many as the config table specifies, linked to every vCPU. The CPU picks among the links at run time.
The linux-user side keeps one context per CPU, w/o need for a device.
SSR:XA is not consulted yet, the CPU always uses context 0.
--- include/hw/hexagon/hexagon.h | 1 + include/hw/hexagon/hexagon_hvx_context.h | 27 ++++++++ target/hexagon/cpu.h | 9 ++- hw/hexagon/hex-subsys.c | 36 ++++++++++ hw/hexagon/hexagon_hvx_context.c | 83 ++++++++++++++++++++++++ linux-user/hexagon/cpu_loop.c | 2 +- linux-user/main.c | 3 + target/hexagon/cpu.c | 19 +++++- hw/hexagon/meson.build | 1 + 9 files changed, 175 insertions(+), 6 deletions(-) create mode 100644 include/hw/hexagon/hexagon_hvx_context.h create mode 100644 hw/hexagon/hexagon_hvx_context.c
include/hw/hexagon/hexagon.h +1 -0
@@ -162,6 +162,7 @@ struct HexagonCommonMachineState {DeviceState *qtimer;DeviceState *glob_regs;DeviceState *tlb; + unsigned num_hvx_ctx; };#endif
include/hw/hexagon/hexagon_hvx_context.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Hexagon HVX Extension Context QOM Object +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEXAGON_HVX_CONTEXT_H +#define HEXAGON_HVX_CONTEXT_H + +#include "hw/core/sysbus.h" +#include "qom/object.h" +#include "target/hexagon/cpu.h" + +#define TYPE_HEXAGON_HVX_CONTEXT "hexagon-hvx-context" +OBJECT_DECLARE_SIMPLE_TYPE(HexagonHVXContextState, HEXAGON_HVX_CONTEXT) + +struct HexagonHVXContextState { +SysBusDevice parent_obj; + +/* Physical context number, as SSR:XA maps to it. */ +uint32_t index; + +HexagonHVXContext regs; +}; + +#endif /* HEXAGON_HVX_CONTEXT_H */
target/hexagon/cpu.h +7 -2
@@ -29,6 +29,7 @@typedef struct HexagonTLBState HexagonTLBState ;typedef struct HexagonGlobalRegState HexagonGlobalRegState ; +typedef struct HexagonHVXContextState HexagonHVXContextState ;#include "cpu-qom.h" #include "exec/cpu-common.h"
@@ -49,6 +50,7 @@ typedef struct HexagonGlobalRegState HexagonGlobalRegState;#define REG_WRITES_MAX 32#define PRED_WRITES_MAX 5/* 4 insns + endloop */ #define VSTORES_MAX 2 +#define HVX_CONTEXTS_MAX 8#define MAX_TLB_ENTRIES 1024#define THREADS_MAX 8
@@ -165,7 +167,6 @@ typedef struct CPUArchState {uint64_t llsc_val_i64;HexagonHVXContext *hvx; - HexagonHVXContext hvx_ctx QEMU_ALIGNED(16); MMVector future_VRegs[VECTOR_TEMPS_MAX] QEMU_ALIGNED(16); MMVector tmp_VRegs[VECTOR_TEMPS_MAX] QEMU_ALIGNED(16);
@@ -201,7 +202,11 @@ struct ArchCPU {CPUHexagonState env;HexagonCPUConfig cfg; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + HexagonHVXContext hvx_ctx QEMU_ALIGNED(16); +#else +HexagonHVXContextState *hvx_ctx[HVX_CONTEXTS_MAX ]; + HexagonHVXContext hvx_fallback QEMU_ALIGNED(16);HexagonTLBState *tlb;uint32_t boot_addr;HexagonGlobalRegState *globalregs;
hw/hexagon/hex-subsys.c +36 -0
@@ -7,8 +7,10 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/error-report.h" #include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" +#include "hw/hexagon/hexagon_hvx_context.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/intc/hex-l2vic.h" #include "hw/timer/qct-qtimer.h"
@@ -98,6 +100,33 @@ static DeviceState *tlb_create(HexagonCommonMachineState *hms,return tlb; } +/* +* Create the core's HVX extension contexts. There are fewer of them than +* there are hardware threads, and SSR:XA picks which one a thread uses, so +* they belong to the subsystem rather than to any one CPU. +*/ +static void hvx_contexts_create (HexagonCommonMachineState *hms, +const struct hexagon_machine_config *m_cfg) +{ +unsigned n = m_cfg->cfgtable.ext_contexts; +unsigned i; + +if (n >HVX_CONTEXTS_MAX ) { +error_report ("machine declares %u HVX contexts, only %u are usable" , + n,HVX_CONTEXTS_MAX ); +exit (1 ); + } +for (i =0 ; i < n; i++) { +DeviceState *ctx =qdev_new (TYPE_HEXAGON_HVX_CONTEXT ); + g_autofree char *name = g_strdup_printf("hvx-context[%u]", i); + +object_property_add_child (OBJECT (hms), name,OBJECT (ctx)); +qdev_prop_set_uint32 (ctx,"index" , i); +sysbus_realize_and_unref (SYS_BUS_DEVICE (ctx), &error_fatal); + } + hms->num_hvx_ctx = n; +} +static DeviceState *cluster_create (HexagonCommonMachineState *hms) {DeviceState *cluster =qdev_new (TYPE_CPU_CLUSTER );
@@ -140,6 +169,7 @@ void hex_subsys_create(HexagonCommonMachineState *hms, hms->qtimer =qtimer_create (hms, m_cfg); hms->glob_regs =globalreg_create (hms, m_cfg, rev); hms->tlb =tlb_create (hms, m_cfg); +hvx_contexts_create (hms, m_cfg); }void hex_subsys_add_cpu (HexagonCommonMachineState *hms,DeviceState *cpu)
@@ -151,6 +181,12 @@ void hex_subsys_add_cpu(HexagonCommonMachineState *hms, DeviceState *cpu) &error_fatal);object_property_set_link (OBJECT (cpu),"l2vic" ,OBJECT (hms->l2vic), &error_fatal); +for (unsigned i =0 ; i < hms->num_hvx_ctx; i++) { + g_autofree char *name = g_strdup_printf("hvx-context[%u]", i); +Object *ctx =object_resolve_path_component (OBJECT (hms), name); + +object_property_set_link (OBJECT (cpu), name, ctx, &error_fatal); + } }void hex_subsys_realize_cluster (HexagonCommonMachineState *hms)
hw/hexagon/hexagon_hvx_context.c new file +83 -0
83 lines not on this page · raw message
linux-user/hexagon/cpu_loop.c +1 -1
@@ -33,7 +33,7 @@ void cpu_loop(CPUHexagonState *env)target_ulong syscallnum;target_ulong ret; - env->hvx = &env->hvx_ctx; + env->hvx = &HEXAGON_CPU (cs)->hvx_ctx;for (;;) {cpu_exec_start (cs);
linux-user/main.c +3 -0
@@ -244,6 +244,9 @@ CPUArchState *cpu_copy(CPUArchState *env) new_cpu->tcg_cflags = cpu->tcg_cflags;memcpy (new_env, env,sizeof (CPUArchState)); +#if defined(TARGET_HEXAGON ) +HEXAGON_CPU (new_cpu)->hvx_ctx =HEXAGON_CPU (cpu)->hvx_ctx; +#endif #if defined(TARGET_I386 ) || defined(TARGET_X86_64 ) new_env->gdt.base = target_mmap(0, sizeof(uint64_t) * TARGET_GDT_ENTRIES, PROT_READ | PROT_WRITE,
target/hexagon/cpu.c +16 -3
@@ -43,6 +43,7 @@#include "exec/page-protection.h" #include "exec/target_page.h" #include "hw/hexagon/hexagon_globalreg.h" +#include "hw/hexagon/hexagon_hvx_context.h" #endif static ObjectClass *hexagon_cpu_class_by_name (const char *cpu_model)
@@ -412,15 +413,17 @@ static void hexagon_cpu_reset_hold(Object *obj, ResetType type)CPUState *cs =CPU (obj);HexagonCPUClass *mcc =HEXAGON_CPU_GET_CLASS (obj);CPUHexagonState *env =cpu_env (cs); -#ifndef CONFIG_USER_ONLY HexagonCPU *cpu =HEXAGON_CPU (cs); -#endif if (mcc->parent_phases.hold) { mcc->parent_phases.hold (obj, type); } - env->hvx = &env->hvx_ctx; +#ifdef CONFIG_USER_ONLY + env->hvx = &cpu->hvx_ctx; +#else + env->hvx = cpu->hvx_ctx[0 ] ? &cpu->hvx_ctx[0 ]->regs : &cpu->hvx_fallback; +#endif set_default_nan_mode (1 , &env->fp_status);set_float_detect_tininess (float_tininess_before_rounding, &env->fp_status);
@@ -547,7 +550,17 @@ static void hexagon_cpu_init(Object *obj) {#ifndef CONFIG_USER_ONLY HexagonCPU *cpu =HEXAGON_CPU (obj); +int i; +qdev_init_gpio_in (DEVICE (cpu), hexagon_cpu_set_irq,8 ); + +for (i =0 ; i <HVX_CONTEXTS_MAX ; i++) { +object_property_add_link (obj,"hvx-context[*]" , +TYPE_HEXAGON_HVX_CONTEXT , + (Object **)&cpu->hvx_ctx[i], + qdev_prop_allow_set_link_before_realize, +OBJ_PROP_LINK_STRONG ); + }#endif }
hw/hexagon/meson.build +1 -0
@@ -1,6 +1,7 @@ hexagon_ss = ss.source_set() hexagon_ss.add(files('hexagon_tlb.c')) hexagon_ss.add(files('hexagon_globalreg.c')) +hexagon_ss.add(files('hexagon_hvx_context.c')) hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hex-subsys.c')) hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hexagon_dsp.c')) hexagon_ss.add(when: 'CONFIG_HEX_VIRT', if_true: files('virt.c'))
Signature · 1 line
2.34.1
Re: [PATCH 7/9] target/hexagon: move the HVX register file into a QOM object
Quoted 27 lines · Brian Cain
Each DSP ordinarily has fewer HVX contexts than hw threads. The thread's SSR:XA selects the one it's bound to.
Add a hexagon-hvx-context device holding the register file. The machine creates as many as the config table specifies, linked to every vCPU. The CPU picks among the links at run time.
The linux-user side keeps one context per CPU, w/o need for a device.
SSR:XA is not consulted yet, the CPU always uses context 0.
Signed-off-by Brian Cain <[email protected]>--- include/hw/hexagon/hexagon.h | 1 + include/hw/hexagon/hexagon_hvx_context.h | 27 ++++++++ target/hexagon/cpu.h | 9 ++- hw/hexagon/hex-subsys.c | 36 ++++++++++ hw/hexagon/hexagon_hvx_context.c | 83 ++++++++++++++++++++++++ linux-user/hexagon/cpu_loop.c | 2 +- linux-user/main.c | 3 + target/hexagon/cpu.c | 19 +++++- hw/hexagon/meson.build | 1 + 9 files changed, 175 insertions(+), 6 deletions(-) create mode 100644 include/hw/hexagon/hexagon_hvx_context.h create mode 100644 hw/hexagon/hexagon_hvx_context.c
target/hexagon/cpu.h struct ArchCPU { · line 209
Quoted 6 lines
target/hexagon/cpu.h +5
-1-#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + HexagonHVXContext hvx_ctx QEMU_ALIGNED(16); +#else +HexagonHVXContextState *hvx_ctx[HVX_CONTEXTS_MAX ]; + HexagonHVXContext hvx_fallback QEMU_ALIGNED(16);
Why is hvx_fallback needed?
Re: [PATCH 7/9] target/hexagon: move the HVX register file into a QOM object
Quoted 27 lines · Marco Liebel
Quoted 26 lines · Brian Cain
Each DSP ordinarily has fewer HVX contexts than hw threads. The thread's SSR:XA selects the one it's bound to.
Add a hexagon-hvx-context device holding the register file. The machine creates as many as the config table specifies, linked to every vCPU. The CPU picks among the links at run time.
The linux-user side keeps one context per CPU, w/o need for a device.
SSR:XA is not consulted yet, the CPU always uses context 0.
Signed-off-by Brian Cain <[email protected]>--- include/hw/hexagon/hexagon.h | 1 + include/hw/hexagon/hexagon_hvx_context.h | 27 ++++++++ target/hexagon/cpu.h | 9 ++- hw/hexagon/hex-subsys.c | 36 ++++++++++ hw/hexagon/hexagon_hvx_context.c | 83 ++++++++++++++++++++++++ linux-user/hexagon/cpu_loop.c | 2 +- linux-user/main.c | 3 + target/hexagon/cpu.c | 19 +++++- hw/hexagon/meson.build | 1 + 9 files changed, 175 insertions(+), 6 deletions(-)create mode 100644
include/hw/hexagon/hexagon_hvx_context.hcreate mode 100644hw/hexagon/hexagon_hvx_context.c
Quoted 7 lines
target/hexagon/cpu.h struct ArchCPU { · line 209
Quoted 6 lines
target/hexagon/cpu.h +5
-1-#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + HexagonHVXContext hvx_ctx QEMU_ALIGNED(16); +#else +HexagonHVXContextState *hvx_ctx[HVX_CONTEXTS_MAX ]; + HexagonHVXContext hvx_fallback QEMU_ALIGNED(16);Why is
hvx_fallbackneeded?
Tsk, sorry - that's cruft left over from an earlier design. It's not necessary, I'll clean it up in v2.
PATCH 8/9 target/hexagon: select the HVX register file with SSR:XA
In reply to Brian CainAssign env->hvx to the right context when SSR:XA changes.
--- target/hexagon/cpu_helper.h | 1 + target/hexagon/cpu.c | 5 +++ target/hexagon/cpu_helper.c | 72 +++++++++++++++++++++++++++++++++++++ target/hexagon/machine.c | 12 +++++++ 4 files changed, 90 insertions(+)
target/hexagon/cpu_helper.h +1 -0
@@ -15,6 +15,7 @@ void hexagon_peek_memory_range(CPUHexagonState *env, uint32_t start_addr, uint32_t length, uintptr_t retaddr);uint32_t hexagon_get_pmu_counter (CPUHexagonState *cur_env,int index);void hexagon_modify_ssr (CPUHexagonState *env,uint32_t new,uint32_t old); +unsigned hexagon_hvx_select_context (CPUHexagonState *env,uint32_t ssr);int get_cpu_mode (const CPUHexagonState *env);int get_exe_mode (const CPUHexagonState *env);void clear_wait_mode (CPUHexagonState *env);
target/hexagon/cpu.c +5 -0
@@ -320,6 +320,9 @@ static TCGTBCPUState hexagon_get_tb_cpu_state(CPUState *cs)CPUHexagonState *env =cpu_env (cs);vaddr pc = env->gpr[HEX_REG_PC ];uint32_t hex_flags =0 ; +#ifndef CONFIG_USER_ONLY +HexagonCPU *cpu; +#endif if (pc == env->gpr[HEX_REG_SA0 ]) { hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,IS_TIGHT_LOOP ,1 );
@@ -330,10 +333,12 @@ static TCGTBCPUState hexagon_get_tb_cpu_state(CPUState *cs) }#ifndef CONFIG_USER_ONLY + cpu =env_archcpu (env); hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,MMU_INDEX ,cpu_mmu_index (env_cpu (env), false)); hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,PCYCLE_ENABLED ,1 ); hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,HVX_COPROC_ENABLED , + cpu->hvx_ctx[0 ] &&GET_SSR_FIELD (SSR_XE , env->t_sreg[HEX_SREG_SSR ]));#else hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,MMU_INDEX ,MMU_USER_IDX );
target/hexagon/cpu_helper.c +72 -0
90 lines not on this page · raw message
target/hexagon/machine.c +12 -0
@@ -7,11 +7,23 @@#include "qemu/osdep.h" #include "migration/vmstate.h" #include "cpu.h" +#include "cpu_helper.h" + +static int hexagon_cpu_post_load (void *opaque,int version_id) +{ +HexagonCPU *cpu = opaque; +CPUHexagonState *env = &cpu->env; + +hexagon_hvx_select_context (env, env->t_sreg[HEX_SREG_SSR ]); + +return 0 ; +}const VMStateDescription vmstate_hexagon_cpu = { .name ="cpu" , .version_id =2 , .minimum_version_id =2 , + .post_load = hexagon_cpu_post_load, .fields = (const VMStateField []) {VMSTATE_UINT32_ARRAY (env.gpr, HexagonCPU,TOTAL_PER_THREAD_REGS ),VMSTATE_UINT32_ARRAY (env.pred, HexagonCPU,NUM_PREGS ),
Signature · 1 line
2.34.1
Re: [PATCH 8/9] target/hexagon: select the HVX register file with SSR:XA
Quoted 11 lines · Brian Cain
Assign
env->hvxto the right context when SSR:XA changes.Signed-off-by Brian Cain <[email protected]>--- target/hexagon/cpu_helper.h | 1 + target/hexagon/cpu.c | 5 +++ target/hexagon/cpu_helper.c | 72 +++++++++++++++++++++++++++++++++++++ target/hexagon/machine.c | 12 +++++++ 4 files changed, 90 insertions(+)
target/hexagon/cpu_helper.c void hexagon_resume_threads(CPUHexagonState *current_env, uint32_t mask) · line 270
Quoted 9 lines
target/hexagon/cpu_helper.c +9
-0+static unsigned hexagon_hvx_context_index (HexagonCPU *cpu,uint8_t xa) +{ +unsigned n =hexagon_hvx_context_count (cpu); + +if (n ==0 ) { +return 0 ; + } +return xa % n; +}
Why is xa wrapped with % n instead of being used directly?
Re: [PATCH 8/9] target/hexagon: select the HVX register file with SSR:XA
Quoted 11 lines · Marco Liebel
Quoted 10 lines · Brian Cain
Assign
env->hvxto the right context when SSR:XA changes.Signed-off-by Brian Cain <[email protected]>--- target/hexagon/cpu_helper.h | 1 + target/hexagon/cpu.c | 5 +++ target/hexagon/cpu_helper.c | 72 +++++++++++++++++++++++++++++++++++++ target/hexagon/machine.c | 12 +++++++ 4 files changed, 90 insertions(+)
Quoted 10 lines
target/hexagon/cpu_helper.c void hexagon_resume_threads(CPUHexagonState *current_env, uint32_t mask) · line 270
Quoted 9 lines
target/hexagon/cpu_helper.c +9
-0+static unsigned hexagon_hvx_context_index (HexagonCPU *cpu,uint8_t xa) +{ +unsigned n =hexagon_hvx_context_count (cpu); + +if (n ==0 ) { +return 0 ; + } +return xa % n; +}Why is
xawrapped with% ninstead of being used directly?
The behavior for an out-of-range SSR.XA value is unspecified.
Empirically I can see that the reference simulator happens to map these values to some in-range context number, but the behavior varies from arch rev to rev. So - a modulus seems reasonable/appropriate to me.
But in v5 I'll add a GUEST_ERROR when it's out of range here so that users have a way to find out what went wrong.
PATCH 9/9 tests/functional/hexagon: add test_hvx_context arch test
In reply to Brian CainPasses now that HVX raises NO_COPROC_ENABLE when SSR:XE is clear.
--- tests/functional/hexagon/test_arch_tests.py | 7 +++++++ 1 file changed, 7 insertions(+)
tests/functional/hexagon/test_arch_tests.py +7 -0
@@ -98,6 +98,13 @@ def test_user_mode(self) -> None: """ self.run_uart_test("test_user_mode") + def test_hvx_context(self) -> None: + """Tests the HVX coprocessor context: SSR XA context selection + and isolation, vsplat/store, and the NO_COPROC_ENABLE exception + raised when SSR:XE is clear. + """ + self.run_uart_test("test_hvx_context") + if __name__ == "__main__": QemuSystemTest.main()
Signature · 1 line
2.34.1
Re: [PATCH 9/9] tests/functional/hexagon: add test_hvx_context arch test
Quoted 7 lines · Brian Cain
Passes now that HVX raises
NO_COPROC_ENABLEwhen SSR:XE is clear.Signed-off-by Brian Cain <[email protected]>--- tests/functional/hexagon/test_arch_tests.py | 7 +++++++ 1 file changed, 7 insertions(+)