Hexagon (target/hexagon) Add overrides for S2_asr_r_r_sat/S2_asl_r_r_sat
PATCH 1/1 Hexagon (target/hexagon) Add overrides for S2_asr_r_r_sat/S2_asl_r_r_sat
These instructions will not be generated by idef-parser, so we override them manually.
Test cases added to tests/tcg/hexagon/usr.c
Co-authored-by Matheus Tavares Bernardino <[email protected]>
Signed-off-by Matheus Tavares Bernardino <[email protected]>
Signed-off-by Taylor Simpson <[email protected]>
--- target/hexagon/gen_tcg.h | 10 ++- target/hexagon/genptr.c | 173 +++++++++++++++++++++++++++++++++++++++ tests/tcg/hexagon/usr.c | 30 +++++-- 3 files changed, 206 insertions(+), 7 deletions(-)
target/hexagon/gen_tcg.h +9 -1
@@ -1,5 +1,5 @@/* -* Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved. +* Copyright(c) 2019-2022 Qualcomm Innovation Center, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -612,6 +612,14 @@tcg_temp_free (tmp); \ }while (0 ) +/* r0 = asr(r1, r2):sat */ +#define fGEN_TCG_S2_asr_r_r_sat (SHORTCODE ) \ + gen_asr_r_r_sat(RdV, RsV, RtV) + +/* r0 = asl(r1, r2):sat */ +#define fGEN_TCG_S2_asl_r_r_sat (SHORTCODE ) \ + gen_asl_r_r_sat(RdV, RsV, RtV) +/* Floating point */ #define fGEN_TCG_F2_conv_sf2df (SHORTCODE ) \ gen_helper_conv_sf2df(RddV, cpu_env, RsV)
target/hexagon/genptr.c +173 -0
179 lines not on this page · raw message
tests/tcg/hexagon/usr.c +24 -6
@@ -429,6 +429,7 @@ FUNC_P_OP_P(vabshsat, "%0 = vabsh(%2):sat") FUNC_P_OP_PP(vnavgwr, "%0 = vnavgw(%2, %3):rnd:sat") FUNC_R_OP_RI(round_ri_sat, "%0 = round(%2, #%3):sat") FUNC_R_OP_RR(asr_r_r_sat, "%0 = asr(%2, %3):sat") +FUNC_R_OP_RR(asl_r_r_sat, "%0 = asl(%2, %3):sat")FUNC_XPp_OP_PP (ACS ,"%0, p2 = vacsh(%3, %4)" )
@@ -907,12 +908,29 @@ int main()TEST_R_OP_RI (round_ri_sat,0x0000ffff ,2 ,0x00004000 ,USR_CLEAR );TEST_R_OP_RI (round_ri_sat,0x7fffffff ,2 ,0x1fffffff ,USR_OVF ); -TEST_R_OP_RR (asr_r_r_sat,0x0000ffff ,0x00000002 ,0x00003fff , -USR_CLEAR ); -TEST_R_OP_RR (asr_r_r_sat,0x00ffffff ,0xfffffff5 ,0x7fffffff , -USR_OVF ); -TEST_R_OP_RR (asr_r_r_sat,0x80000000 ,0xfffffff5 ,0x80000000 , -USR_OVF ); +TEST_R_OP_RR (asr_r_r_sat,0x0000ffff ,0x02 ,0x00003fff ,USR_CLEAR ); +TEST_R_OP_RR (asr_r_r_sat,0x80000000 ,0x01 ,0xc0000000 ,USR_CLEAR ); +TEST_R_OP_RR (asr_r_r_sat,0xffffffff ,0x01 ,0xffffffff ,USR_CLEAR ); +TEST_R_OP_RR (asr_r_r_sat,0x00ffffff ,0xf5 ,0x7fffffff ,USR_OVF ); +TEST_R_OP_RR (asr_r_r_sat,0x80000000 ,0xf5 ,0x80000000 ,USR_OVF ); +TEST_R_OP_RR (asr_r_r_sat,0x7fff0000 ,0x42 ,0x7fffffff ,USR_OVF ); +TEST_R_OP_RR (asr_r_r_sat,0xff000000 ,0x42 ,0x80000000 ,USR_OVF ); +TEST_R_OP_RR (asr_r_r_sat,4096 ,32 ,0x00000000 ,USR_CLEAR ); +TEST_R_OP_RR (asr_r_r_sat,4096 ,-32 ,0x7fffffff ,USR_OVF ); +TEST_R_OP_RR (asr_r_r_sat,-4096 ,32 ,0xffffffff ,USR_CLEAR ); +TEST_R_OP_RR (asr_r_r_sat,-4096 ,-32 ,0x80000000 ,USR_OVF ); + +TEST_R_OP_RR (asl_r_r_sat,0x00000000 ,0x40 ,0x00000000 ,USR_CLEAR ); +TEST_R_OP_RR (asl_r_r_sat,0x80000000 ,0xff ,0xc0000000 ,USR_CLEAR ); +TEST_R_OP_RR (asl_r_r_sat,0xffffffff ,0xff ,0xffffffff ,USR_CLEAR ); +TEST_R_OP_RR (asl_r_r_sat,0x00ffffff ,0x0b ,0x7fffffff ,USR_OVF ); +TEST_R_OP_RR (asl_r_r_sat,0x80000000 ,0x0b ,0x80000000 ,USR_OVF ); +TEST_R_OP_RR (asl_r_r_sat,0x7fff0000 ,0xbe ,0x7fffffff ,USR_OVF ); +TEST_R_OP_RR (asl_r_r_sat,0xff000000 ,0xbe ,0x80000000 ,USR_OVF ); +TEST_R_OP_RR (asl_r_r_sat,4096 ,32 ,0x7fffffff ,USR_OVF ); +TEST_R_OP_RR (asl_r_r_sat,4096 ,-32 ,0x00000000 ,USR_CLEAR ); +TEST_R_OP_RR (asl_r_r_sat,-4096 ,32 ,0x80000000 ,USR_OVF ); +TEST_R_OP_RR (asl_r_r_sat,-4096 ,-32 ,0xffffffff ,USR_CLEAR ); TEST_XPp_OP_PP(ACS, 0x0004000300020001ULL, 0x0001000200030004ULL, 0x0000000000000000ULL, 0x0004000300030004ULL, 0xf0,
Signature · 1 line
2.17.1
PATCH 1/1 Hexagon (target/hexagon) Add pkt and insn to DisasContext
This enables us to reduce the number of parameters to many functions In particular, the generated functions previously took all 3 as arguments
Not only does this simplify the code, it improves the translation time
Signed-off-by Taylor Simpson <[email protected]>
--- target/hexagon/gen_tcg_hvx.h | 4 +- target/hexagon/insn.h | 5 +- target/hexagon/macros.h | 10 +-- target/hexagon/mmvec/macros.h | 4 +- target/hexagon/translate.h | 7 +- target/hexagon/genptr.c | 6 +- target/hexagon/translate.c | 120 +++++++++++++++++--------------- target/hexagon/gen_tcg_funcs.py | 15 ++-- 8 files changed, 86 insertions(+), 85 deletions(-)
target/hexagon/gen_tcg_hvx.h +2 -2
@@ -697,7 +697,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, insn, pkt, EA, OsN_off, insn->slot, true); \ + gen_vreg_store(ctx, EA, OsN_off, insn->slot, true); \ INC; \ } while (0)
@@ -736,7 +736,7 @@ static inline void assert_vhist_tmp(DisasContext *ctx)PRED ; \tcg_gen_brcondi_tl (TCG_COND_EQ ,LSB ,0 , false_label); \tcg_temp_free (LSB ); \ -gen_vreg_store (ctx, insn, pkt,EA ,SRCOFF , insn->slot,ALIGN ); \ +gen_vreg_store (ctx,EA ,SRCOFF , insn->slot,ALIGN ); \INC ; \tcg_gen_br (end_label); \gen_set_label (false_label); \
target/hexagon/insn.h +1 -4
@@ -28,10 +28,7 @@ struct Instruction;struct Packet ;struct DisasContext ; -typedef void (*SemanticInsn )(CPUHexagonState *env, -struct DisasContext *ctx, -struct Instruction *insn, -struct Packet *pkt); +typedef void (*SemanticInsn )(struct DisasContext *ctx);struct Instruction {SemanticInsn generate;/* pointer to genptr routine */
target/hexagon/macros.h +5 -5
@@ -94,9 +94,9 @@*/ #define CHECK_NOSHUF (VA ,SIZE ) \ do { \ - if (insn->slot == 0 && pkt->pkt_has_store_s1) { \ + if (insn->slot == 0 && ctx->pkt->pkt_has_store_s1) { \ probe_noshuf_load(VA, SIZE, ctx->mem_idx); \ - process_store(ctx, pkt, 1); \ + process_store(ctx, 1); \ } \ } while (0)
@@ -105,12 +105,12 @@TCGLabel *label =gen_new_label (); \tcg_gen_brcondi_tl (TCG_COND_EQ ,PRED ,0 , label); \GET_EA ; \ -if (insn->slot ==0 && pkt->pkt_has_store_s1) { \ +if (insn->slot ==0 && ctx->pkt->pkt_has_store_s1) { \probe_noshuf_load (EA ,SIZE , ctx->mem_idx); \ } \gen_set_label (label); \ -if (insn->slot ==0 && pkt->pkt_has_store_s1) { \ -process_store (ctx, pkt,1 ); \ +if (insn->slot ==0 && ctx->pkt->pkt_has_store_s1) { \ +process_store (ctx,1 ); \ } \ }while (0 )
target/hexagon/mmvec/macros.h +2 -2
@@ -288,7 +288,7 @@#endif #ifdef QEMU_GENERATE #define fSTOREMMV (EA ,SRC ) \ - gen_vreg_store(ctx, insn, pkt, EA, SRC##_off, insn->slot, true) + gen_vreg_store(ctx, EA, SRC##_off, insn->slot, true)#endif #ifdef QEMU_GENERATE #define fSTOREMMVQ (EA ,SRC ,MASK ) \
@@ -300,7 +300,7 @@#endif #ifdef QEMU_GENERATE #define fSTOREMMVU (EA ,SRC ) \ - gen_vreg_store(ctx, insn, pkt, EA, SRC##_off, insn->slot, false) + gen_vreg_store(ctx, EA, 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 +5 -2
@@ -23,10 +23,13 @@#include "cpu.h" #include "exec/translator.h" #include "tcg/tcg-op.h" +#include "insn.h" #include "internal.h" typedef struct DisasContext { DisasContextBase base; + Packet *pkt; + Insn *insn; uint32_t mem_idx; uint32_t num_packets; uint32_t num_insns;
@@ -147,6 +150,6 @@ extern TCGv hex_vstore_addr[VSTORES_MAX];extern TCGv hex_vstore_size[VSTORES_MAX ];extern TCGv hex_vstore_pending[VSTORES_MAX ]; -bool is_gather_store_insn (Insn *insn,Packet *pkt); -void process_store (DisasContext *ctx,Packet *pkt,int slot_num); +bool is_gather_store_insn (DisasContext *ctx); +void process_store (DisasContext *ctx,int slot_num);#endif
target/hexagon/genptr.c +3 -3
@@ -551,13 +551,13 @@ static void gen_vreg_load(DisasContext *ctx, intptr_t dstoff, TCGv src,tcg_temp_free_i64 (tmp); } -static void gen_vreg_store (DisasContext *ctx,Insn *insn,Packet *pkt, -TCGv EA ,intptr_t srcoff,int slot,bool aligned) +static void gen_vreg_store (DisasContext *ctx,TCGv EA ,intptr_t srcoff, +int slot,bool aligned) { intptr_t dstoff = offsetof(CPUHexagonState, vstore[slot].data); intptr_t maskoff = offsetof(CPUHexagonState, vstore[slot].mask); -if (is_gather_store_insn (insn, pkt)) { +if (is_gather_store_insn (ctx)) {TCGv sl =tcg_constant_tl (slot);gen_helper_gather_store (cpu_env,EA , sl);return ;
target/hexagon/translate.c +63 -57
270 lines not on this page · raw message
target/hexagon/gen_tcg_funcs.py +5 -10
@@ -561,11 +561,7 @@ def genptr_dst_write_opn(f,regtype, regid, tag): ## Generate the TCG code to call the helper ## For A2_add: Rd32=add(Rs32,Rt32), { RdV=RsV+RtV;} ## We produce: -## static void generate_A2_add() -## CPUHexagonState *env -## DisasContext *ctx, -## Insn *insn, -## Packet *pkt) +## static void generate_A2_add(DisasContext *ctx) ## { ## TCGv RdV = tcg_temp_local_new(); ## const int RdN = insn->regno[0];
@@ -584,12 +580,11 @@ def genptr_dst_write_opn(f,regtype, regid, tag): ## <GEN> is gen_helper_A2_add(RdV, cpu_env, RsV, RtV); ## def gen_tcg_func(f, tag, regs, imms): - f.write("static void generate_%s(\n" %tag) - f.write(" CPUHexagonState *env,\n") - f.write(" DisasContext *ctx,\n") - f.write(" Insn *insn,\n") - f.write(" Packet *pkt)\n") + f.write("static void generate_%s(DisasContext *ctx)\n" %tag) f.write('{\n') + + f.write(" Insn *insn __attribute__((unused)) = ctx->insn;\n") + if hex_common.need_ea(tag): gen_decl_ea_tcg(f, tag) i=0 ## Declare all the operands (regs and immediates)
Signature · 1 line
2.17.1