Hexagon (target/hexagon) update
cover Hexagon (target/hexagon) update
This patch series is a significant update for the Hexagon target
The first 9 patches address feedback from Richard Henderson <[email protected]> The next 6 patches add the remaining instructions for the Hexagon scalar core
The patches are logically independent but are organized as a series to avoid potential confilcts if they are merged out of order.
Taylor Simpson (15):
Hexagon (target/hexagon) TCG generation cleanup
Hexagon (target/hexagon) remove unnecessary inline directives Hexagon (target/hexagon) properly generate TB end for DISAS_NORETURN Hexagon (target/hexagon) decide if pred has been written at TCG gen time Hexagon (target/hexagon) change variables from int to bool when appropriate Hexagon (target/hexagon) utility function changes
Hexagon (target/hexagon) use softfloat default NaN and tininess Hexagon (target/hexagon) replace float32_mul_pow2 with float32_scalbn Hexagon (target/hexagon) use softfloat for float-to-int conversions Hexagon (target/hexagon) instructions with multiple definitions Hexagon (target/hexagon) circular addressing
Hexagon (target/hexagon) bit reverse (brev) addressing
Hexagon (target/hexagon) load and unpack bytes instructions Hexagon (target/hexagon) load into shifted register instructions Hexagon (target/hexagon) CABAC decode bin
fpu/softfloat-specialize.c.inc | 5 + linux-user/hexagon/cpu_loop.c | 2 +- target/hexagon/arch.c | 191 +++++++++++--- target/hexagon/arch.h | 7 +- target/hexagon/conv_emu.c | 177 ------------- target/hexagon/conv_emu.h | 31 --- target/hexagon/cpu.c | 14 +- target/hexagon/cpu.h | 6 +- target/hexagon/cpu_bits.h | 2 +- target/hexagon/decode.c | 80 +++--- target/hexagon/fma_emu.c | 40 +-- target/hexagon/gen_tcg.h | 458 ++++++++++++++++++++++++++++++++ target/hexagon/gen_tcg_funcs.py | 2 +- target/hexagon/genptr.c | 243 ++++++++++++++++- target/hexagon/helper.h | 22 +- target/hexagon/imported/alu.idef | 44 ++++ target/hexagon/imported/encode_pp.def | 30 +++ target/hexagon/imported/float.idef | 32 +++ target/hexagon/imported/ldst.idef | 68 +++++ target/hexagon/imported/macros.def | 47 ++++ target/hexagon/imported/shift.idef | 47 ++++ target/hexagon/insn.h | 21 +- target/hexagon/macros.h | 174 ++++++++++++- target/hexagon/meson.build | 1 - target/hexagon/op_helper.c | 373 ++++++++++++++++++-------- target/hexagon/translate.c | 79 +++--- target/hexagon/translate.h | 7 +- tests/tcg/hexagon/Makefile.target | 5 + tests/tcg/hexagon/brev.c | 185 +++++++++++++ tests/tcg/hexagon/circ.c | 393 ++++++++++++++++++++++++++++ tests/tcg/hexagon/fpstuff.c | 242 +++++++++++++++++ tests/tcg/hexagon/load_align.c | 415 +++++++++++++++++++++++++++++ tests/tcg/hexagon/load_unpack.c | 474 ++++++++++++++++++++++++++++++++++ tests/tcg/hexagon/misc.c | 47 ++++ tests/tcg/hexagon/multi_result.c | 249 ++++++++++++++++++ 35 files changed, 3726 insertions(+), 487 deletions(-) delete mode 100644 target/hexagon/conv_emu.c delete mode 100644 target/hexagon/conv_emu.h create mode 100644 tests/tcg/hexagon/brev.c create mode 100644 tests/tcg/hexagon/circ.c create mode 100644 tests/tcg/hexagon/load_align.c create mode 100644 tests/tcg/hexagon/load_unpack.c create mode 100644 tests/tcg/hexagon/multi_result.c
Signature · 1 line
2.7.4
PATCH 1/15 Hexagon (target/hexagon) TCG generation cleanup
Simplify TCG generation of hex_reg_written
Address feedback from Richard Henderson <[email protected]>
--- target/hexagon/genptr.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
target/hexagon/genptr.c +9 -3
@@ -43,9 +43,15 @@ static inline void gen_log_predicated_reg_write(int rnum, TCGv val, int slot)tcg_gen_movcond_tl (TCG_COND_EQ , hex_new_value[rnum], slot_mask, zero, val, hex_new_value[rnum]);#if HEX_DEBUG -/* Do this so HELPER(debug_commit_end) will know */ -tcg_gen_movcond_tl (TCG_COND_EQ , hex_reg_written[rnum], slot_mask, zero, - one, hex_reg_written[rnum]); +/* +* Do this so HELPER(debug_commit_end) will know +* +* Note that slot_mask indicates the value is not written +* (i.e., slot was cancelled), so we create a true/false value before +* or'ing with hex_reg_written[rnum]. +*/ +tcg_gen_setcond_tl (TCG_COND_EQ , slot_mask, slot_mask, zero); +tcg_gen_or_tl (hex_reg_written[rnum], hex_reg_written[rnum], slot_mask);#endif tcg_temp_free (one);
Signature · 1 line
2.7.4
Re: [PATCH 01/15] Hexagon (target/hexagon) TCG generation cleanup
Quoted 22 lines · Taylor Simpson
Simplify TCG generation of
hex_reg_writtenAddress feedback from Richard Henderson <[email protected]>
Signed-off-by Taylor Simpson <[email protected]>--- target/hexagon/genptr.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)target/hexagon/genptr.c +2
-3@@ -43,9 +43,15 @@ static inline void gen_log_predicated_reg_write(int rnum, TCGv val, int slot)tcg_gen_movcond_tl (TCG_COND_EQ , hex_new_value[rnum], slot_mask, zero, val, hex_new_value[rnum]);#if HEX_DEBUG -/* Do this so HELPER(debug_commit_end) will know */ -tcg_gen_movcond_tl (TCG_COND_EQ , hex_reg_written[rnum], slot_mask, zero, - one, hex_reg_written[rnum]); +/* +* Do this so HELPER(debug_commit_end) will know
target/hexagon/genptr.c static inline void gen_log_predicated_reg_write(int rnum, TCGv val, int slot) · line 57
Quoted 10 lines
target/hexagon/genptr.c +7
-0+* +* Note that slot_mask indicates the value is not written +* (i.e., slot was cancelled), so we create a true/false value before +* or'ing with hex_reg_written[rnum]. +*/ +tcg_gen_setcond_tl (TCG_COND_EQ , slot_mask, slot_mask, zero); +tcg_gen_or_tl (hex_reg_written[rnum], hex_reg_written[rnum], slot_mask);#endif tcg_temp_free (one);
The one variable is no longer used.
r~
PATCH 2/15 Hexagon (target/hexagon) remove unnecessary inline directives
In reply to Taylor SimpsonAddress feedback from Richard Henderson <[email protected]>
--- linux-user/hexagon/cpu_loop.c | 2 +- target/hexagon/cpu.c | 9 ++++----- target/hexagon/cpu.h | 6 ++---- target/hexagon/decode.c | 6 +++--- target/hexagon/fma_emu.c | 39 ++++++++++++++++++++------------------- target/hexagon/op_helper.c | 39 +++++++++++++++++++-------------------- target/hexagon/translate.c | 2 +- 7 files changed, 50 insertions(+), 53 deletions(-)
linux-user/hexagon/cpu_loop.c +1 -1
@@ -25,7 +25,7 @@void cpu_loop (CPUHexagonState *env) { -CPUState *cs =CPU (hexagon_env_get_cpu (env)); +CPUState *cs =CPUSTATE_FROM_ENV (env);int trapnr, signum, sigcode;target_ulong sigaddr;target_ulong syscallnum;
target/hexagon/cpu.c +4 -5
@@ -69,10 +69,9 @@ const char * const hexagon_regnames[TOTAL_PER_THREAD_REGS] = {* stacks at different locations. This is used to compensate so the diff is * cleaner. */ -static inline target_ulong adjust_stack_ptrs (CPUHexagonState *env, -target_ulong addr) +static target_ulong adjust_stack_ptrs (CPUHexagonState *env,target_ulong addr) { -HexagonCPU *cpu =container_of (env, HexagonCPU, env); +HexagonCPU *cpu =HEXAGONCPU_FROM_ENV (env);target_ulong stack_adjust = cpu->lldb_stack_adjust;target_ulong stack_start = env->stack_start;target_ulong stack_size =0x10000 ;
@@ -88,7 +87,7 @@ static inline target_ulong adjust_stack_ptrs(CPUHexagonState *env, }/* HEX_REG_P3_0 (aka C4) is an alias for the predicate registers */ -static inline target_ulong read_p3_0 (CPUHexagonState *env) +static target_ulong read_p3_0 (CPUHexagonState *env) {int32_t control_reg =0 ;int i;
@@ -116,7 +115,7 @@ static void print_reg(FILE *f, CPUHexagonState *env, int regnum)static void hexagon_dump (CPUHexagonState *env,FILE *f) { -HexagonCPU *cpu =container_of (env, HexagonCPU, env); +HexagonCPU *cpu =HEXAGONCPU_FROM_ENV (env);if (cpu->lldb_compat) {/*
target/hexagon/cpu.h +2 -4
@@ -127,10 +127,8 @@ typedef struct HexagonCPU {target_ulong lldb_stack_adjust; } HexagonCPU; -static inline HexagonCPU *hexagon_env_get_cpu (CPUHexagonState *env) -{ -return container_of (env, HexagonCPU, env); -} +#define HEXAGONCPU_FROM_ENV (env) container_of((env), HexagonCPU, env) +#define CPUSTATE_FROM_ENV (env) CPU(HEXAGONCPU_FROM_ENV(env))#include "cpu_bits.h"
target/hexagon/decode.c +3 -3
@@ -354,7 +354,7 @@ static void decode_split_cmpjump(Packet *pkt) } } -static inline int decode_opcode_can_jump (int opcode) +static int decode_opcode_can_jump (int opcode) { if ((GET_ATTRIB(opcode, A_JUMP)) || (GET_ATTRIB(opcode, A_CALL)) ||
@@ -370,7 +370,7 @@ static inline int decode_opcode_can_jump(int opcode)return 0 ; } -static inline int decode_opcode_ends_loop (int opcode) +static int decode_opcode_ends_loop (int opcode) {return GET_ATTRIB (opcode,A_HWLOOP0_END ) ||GET_ATTRIB (opcode,A_HWLOOP1_END );
@@ -764,7 +764,7 @@ static void decode_add_endloop_insn(Insn *insn, int loopnum) } } -static inline int decode_parsebits_is_loopend (uint32_t encoding32) +static int decode_parsebits_is_loopend (uint32_t encoding32) {uint32_t bits =parse_bits (encoding32);return bits ==0x2 ;
target/hexagon/fma_emu.c +20 -19
@@ -64,7 +64,7 @@ typedef union { }; } Float; -static inline uint64_t float64_getmant (float64 f64) +static uint64_t float64_getmant (float64 f64) {Double a = { .i = f64 };if (float64_is_normal (f64)) {
@@ -91,7 +91,7 @@ int32_t float64_getexp(float64 f64)return -1 ; } -static inline uint64_t float32_getmant (float32 f32) +static uint64_t float32_getmant (float32 f32) {Float a = { .i = f32 };if (float32_is_normal (f32)) {
@@ -118,17 +118,17 @@ int32_t float32_getexp(float32 f32)return -1 ; } -static inline uint32_t int128_getw0 (Int128 x) +static uint32_t int128_getw0 (Int128 x) {return int128_getlo (x); } -static inline uint32_t int128_getw1 (Int128 x) +static uint32_t int128_getw1 (Int128 x) {return int128_getlo (x) >>32 ; } -static inline Int128 int128_mul_6464 (uint64_t ai,uint64_t bi) +static Int128 int128_mul_6464 (uint64_t ai,uint64_t bi) {Int128 a, b;uint64_t pp0, pp1a, pp1b, pp1s, pp2;
@@ -152,7 +152,7 @@ static inline Int128 int128_mul_6464(uint64_t ai, uint64_t bi)return int128_make128 (ret_low, pp2 + (pp1s >>32 )); } -static inline Int128 int128_sub_borrow (Int128 a,Int128 b,int borrow) +static Int128 int128_sub_borrow (Int128 a,Int128 b,int borrow) {Int128 ret =int128_sub (a, b);if (borrow !=0 ) {
@@ -170,7 +170,7 @@ typedef struct {uint8_t sticky; } Accum; -static inline void accum_init (Accum *p) +static void accum_init (Accum *p) { p->mant =int128_zero (); p->exp =0 ;
@@ -180,7 +180,7 @@ static inline void accum_init(Accum *p) p->sticky =0 ; } -static inline Accum accum_norm_left (Accum a) +static Accum accum_norm_left (Accum a) { a.exp--; a.mant =int128_lshift (a.mant,1 );
@@ -190,6 +190,7 @@ static inline Accum accum_norm_left(Accum a)return a; } +/* This function is marked inline for performance reasons */ static inline Accum accum_norm_right (Accum a,int amt) {if (amt >130 ) {
@@ -226,7 +227,7 @@ static inline Accum accum_norm_right(Accum a, int amt)*/ static Accum accum_add (Accum a,Accum b); -static inline Accum accum_sub (Accum a,Accum b,int negate) +static Accum accum_sub (Accum a,Accum b,int negate) {Accum ret;accum_init (&ret);
@@ -329,7 +330,7 @@ static Accum accum_add(Accum a, Accum b) }/* Return an infinity with requested sign */ -static inline float64 infinite_float64 (uint8_t sign) +static float64 infinite_float64 (uint8_t sign) {if (sign) {return make_float64 (DF_MINUS_INF );
@@ -339,7 +340,7 @@ static inline float64 infinite_float64(uint8_t sign) }/* Return a maximum finite value with requested sign */ -static inline float64 maxfinite_float64 (uint8_t sign) +static float64 maxfinite_float64 (uint8_t sign) {if (sign) {return make_float64 (DF_MINUS_MAXF );
@@ -349,7 +350,7 @@ static inline float64 maxfinite_float64(uint8_t sign) }/* Return a zero value with requested sign */ -static inline float64 zero_float64 (uint8_t sign) +static float64 zero_float64 (uint8_t sign) {if (sign) {return make_float64 (0x8000000000000000 );
@@ -369,7 +370,7 @@ float32 infinite_float32(uint8_t sign) }/* Return a maximum finite value with the requested sign */ -static inline float32 maxfinite_float32 (uint8_t sign) +static float32 maxfinite_float32 (uint8_t sign) {if (sign) {return make_float32 (SF_MINUS_MAXF );
@@ -379,7 +380,7 @@ static inline float32 maxfinite_float32(uint8_t sign) }/* Return a zero value with requested sign */ -static inline float32 zero_float32 (uint8_t sign) +static float32 zero_float32 (uint8_t sign) {if (sign) {return make_float32 (0x80000000 );
@@ -389,7 +390,7 @@ static inline float32 zero_float32(uint8_t sign) }#define GEN_XF_ROUND (SUFFIX ,MANTBITS ,INF_EXP ,INTERNAL_TYPE ) \ -static inline SUFFIX accum_round_##SUFFIX(Accum a, float_status * fp_status) \ +static SUFFIX accum_round_##SUFFIX(Accum a, float_status * fp_status) \ { \ if ((int128_gethi(a.mant) == 0) && (int128_getlo(a.mant) == 0) \ && ((a.guard | a.round | a.sticky) == 0)) { \
@@ -526,8 +527,8 @@ static bool is_inf_prod(float64 a, float64 b) (float64_is_infinity(b) && is_finite(a) && (!float64_is_zero(a)))); } -static inline float64 special_fma (float64 a,float64 b,float64 c, -float_status *fp_status) +static float64 special_fma (float64 a,float64 b,float64 c, +float_status *fp_status) {float64 ret =make_float64 (0 );
@@ -586,8 +587,8 @@ static inline float64 special_fma(float64 a, float64 b, float64 c,g_assert_not_reached (); } -static inline float32 special_fmaf (float32 a,float32 b,float32 c, -float_status *fp_status) +static float32 special_fmaf (float32 a,float32 b,float32 c, +float_status *fp_status) {float64 aa, bb, cc; aa =float32_to_float64 (a, fp_status);
target/hexagon/op_helper.c +19 -20
@@ -35,7 +35,7 @@ static void QEMU_NORETURN do_raise_exception_err(CPUHexagonState *env, uint32_t exception, uintptr_t pc) { -CPUState *cs =CPU (hexagon_env_get_cpu (env)); +CPUState *cs =CPUSTATE_FROM_ENV (env);qemu_log_mask (CPU_LOG_INT ,"%s: %d\n" , __func__, exception); cs->exception_index = exception;cpu_loop_exit_restore (cs, pc);
@@ -46,8 +46,8 @@ void QEMU_NORETURN HELPER(raise_exception)(CPUHexagonState *env, uint32_t excp)do_raise_exception_err (env, excp,0 ); } -static inline void log_reg_write (CPUHexagonState *env,int rnum, -target_ulong val,uint32_t slot) +static void log_reg_write (CPUHexagonState *env,int rnum, +target_ulong val,uint32_t slot) {HEX_DEBUG_LOG ("log_reg_write[%d] = " TARGET_FMT_ld" (0x" TARGET_FMT_lx")" , rnum, val, val);
@@ -63,8 +63,7 @@ static inline void log_reg_write(CPUHexagonState *env, int rnum,#endif } -static inline void log_pred_write (CPUHexagonState *env,int pnum, -target_ulong val) +static void log_pred_write (CPUHexagonState *env,int pnum,target_ulong val) { HEX_DEBUG_LOG("log_pred_write[%d] = " TARGET_FMT_ld " (0x" TARGET_FMT_lx ")\n",
@@ -79,8 +78,8 @@ static inline void log_pred_write(CPUHexagonState *env, int pnum, } } -static inline void log_store32 (CPUHexagonState *env,target_ulong addr, -target_ulong val,int width,int slot) +static void log_store32 (CPUHexagonState *env,target_ulong addr, +target_ulong val,int width,int slot) { HEX_DEBUG_LOG("log_store%d(0x" TARGET_FMT_lx ", %" PRId32 " [0x08%" PRIx32 "])\n",
@@ -90,8 +89,8 @@ static inline void log_store32(CPUHexagonState *env, target_ulong addr, env->mem_log_stores[slot].data32 = val; } -static inline void log_store64 (CPUHexagonState *env,target_ulong addr, -int64_t val,int width,int slot) +static void log_store64 (CPUHexagonState *env,target_ulong addr, +int64_t val,int width,int slot) { HEX_DEBUG_LOG("log_store%d(0x" TARGET_FMT_lx ", %" PRId64 " [0x016%" PRIx64 "])\n",
@@ -101,7 +100,7 @@ static inline void log_store64(CPUHexagonState *env, target_ulong addr, env->mem_log_stores[slot].data64 = val; } -static inline void write_new_pc (CPUHexagonState *env,target_ulong addr) +static void write_new_pc (CPUHexagonState *env,target_ulong addr) {HEX_DEBUG_LOG ("write_new_pc(0x" TARGET_FMT_lx")\n" , addr);
@@ -132,7 +131,7 @@ void HELPER(debug_start_packet)(CPUHexagonState *env) }#endif -static inline int32_t new_pred_value (CPUHexagonState *env,int pnum) +static int32_t new_pred_value (CPUHexagonState *env,int pnum) {return env->new_pred_value[pnum]; }
@@ -332,8 +331,8 @@ static void check_noshuf(CPUHexagonState *env, uint32_t slot) } } -static inline uint8_t mem_load1 (CPUHexagonState *env,uint32_t slot, -target_ulong vaddr) +static uint8_t mem_load1 (CPUHexagonState *env,uint32_t slot, +target_ulong vaddr) {uint8_t retval;check_noshuf (env, slot);
@@ -341,8 +340,8 @@ static inline uint8_t mem_load1(CPUHexagonState *env, uint32_t slot,return retval; } -static inline uint16_t mem_load2 (CPUHexagonState *env,uint32_t slot, -target_ulong vaddr) +static uint16_t mem_load2 (CPUHexagonState *env,uint32_t slot, +target_ulong vaddr) {uint16_t retval;check_noshuf (env, slot);
@@ -350,8 +349,8 @@ static inline uint16_t mem_load2(CPUHexagonState *env, uint32_t slot,return retval; } -static inline uint32_t mem_load4 (CPUHexagonState *env,uint32_t slot, -target_ulong vaddr) +static uint32_t mem_load4 (CPUHexagonState *env,uint32_t slot, +target_ulong vaddr) {uint32_t retval;check_noshuf (env, slot);
@@ -359,8 +358,8 @@ static inline uint32_t mem_load4(CPUHexagonState *env, uint32_t slot,return retval; } -static inline uint64_t mem_load8 (CPUHexagonState *env,uint32_t slot, -target_ulong vaddr) +static uint64_t mem_load8 (CPUHexagonState *env,uint32_t slot, +target_ulong vaddr) {uint64_t retval;check_noshuf (env, slot);
@@ -939,7 +938,7 @@ float32 HELPER(sffms)(CPUHexagonState *env, float32 RxV,return RxV; } -static inline bool is_inf_prod (int32_t a,int32_t b) +static bool is_inf_prod (int32_t a,int32_t b) {return (float32_is_infinity (a) &&float32_is_infinity (b)) || (float32_is_infinity(a) && is_finite(b) && !float32_is_zero(b)) ||
target/hexagon/translate.c +1 -1
@@ -585,7 +585,7 @@ static void hexagon_tr_translate_packet(DisasContextBase *dcbase, CPUState *cpu)* The CPU log is used to compare against LLDB single stepping, * so end the TLB after every packet. */ -HexagonCPU *hex_cpu =container_of (env, HexagonCPU, env); +HexagonCPU *hex_cpu =HEXAGONCPU_FROM_ENV (env);if (hex_cpu->lldb_compat &&qemu_loglevel_mask (CPU_LOG_TB_CPU )) { ctx->base.is_jmp =DISAS_TOO_MANY ; }
Signature · 1 line
2.7.4
Re: [PATCH 02/15] Hexagon (target/hexagon) remove unnecessary inline directives
Quoted 18 lines · Taylor Simpson
Address feedback from Richard Henderson <[email protected]>
Signed-off-by Taylor Simpson <[email protected]>--- linux-user/hexagon/cpu_loop.c | 2 +- target/hexagon/cpu.c | 9 ++++----- target/hexagon/cpu.h | 6 ++---- target/hexagon/decode.c | 6 +++--- target/hexagon/fma_emu.c | 39 ++++++++++++++++++++------------------- target/hexagon/op_helper.c | 39 +++++++++++++++++++-------------------- target/hexagon/translate.c | 2 +- 7 files changed, 50 insertions(+), 53 deletions(-)linux-user/hexagon/cpu_loop.c +0
-0
linux-user/hexagon/cpu_loop.c line 28
Quoted 5 lines
linux-user/hexagon/cpu_loop.c +1
-1@@ -25,7 +25,7 @@void cpu_loop (CPUHexagonState *env) { -CPUState *cs =CPU (hexagon_env_get_cpu (env)); +CPUState *cs =CPUSTATE_FROM_ENV (env);
This is not removing inlines from functions in c files, so this patch should be split.
linux-user/hexagon/cpu_loop.c
Quoted 6 lines
linux-user/hexagon/cpu_loop.c +2
-4-static inline HexagonCPU *hexagon_env_get_cpu (CPUHexagonState *env) -{ -return container_of (env, HexagonCPU, env); -} +#define HEXAGONCPU_FROM_ENV (env) container_of((env), HexagonCPU, env) +#define CPUSTATE_FROM_ENV (env) CPU(HEXAGONCPU_FROM_ENV(env))
Since a578cdfbdd8f, these should be replaced by env_archcpu and env_cpu respectively.
r~
PATCH 3/15 Hexagon (target/hexagon) properly generate TB end for DISAS_NORETURN
In reply to Taylor SimpsonWhen exiting a TB, generate all the code before returning from hexagon_tr_translate_packet so that nothing needs to be done in hexagon_tr_tb_stop.
Address feedback from Richard Henderson <[email protected]>
--- target/hexagon/translate.c | 62 +++++++++++++++++++++++++--------------------- target/hexagon/translate.h | 3 --- 2 files changed, 34 insertions(+), 31 deletions(-)
target/hexagon/translate.c +34 -28
@@ -54,16 +54,41 @@ static const char * const hexagon_prednames[] = {"p0" ,"p1" ,"p2" ,"p3" }; -void gen_exception (int excp) +static void gen_exception (int excp) {TCGv_i32 helper_tmp =tcg_const_i32 (excp);gen_helper_raise_exception (cpu_env, helper_tmp);tcg_temp_free_i32 (helper_tmp); } -void gen_exception_debug (void ) +static void gen_exec_counters (DisasContext *ctx) +{ +tcg_gen_addi_tl (hex_gpr[HEX_REG_QEMU_PKT_CNT ], + hex_gpr[HEX_REG_QEMU_PKT_CNT ], ctx->num_packets); +tcg_gen_addi_tl (hex_gpr[HEX_REG_QEMU_INSN_CNT ], + hex_gpr[HEX_REG_QEMU_INSN_CNT ], ctx->num_insns); +} + +static void gen_end_tb (DisasContext *ctx) { -gen_exception (EXCP_DEBUG ); +gen_exec_counters (ctx); +tcg_gen_mov_tl (hex_gpr[HEX_REG_PC ], hex_next_PC); +if (ctx->base.singlestep_enabled) { +gen_exception (EXCP_DEBUG ); + }else { +tcg_gen_exit_tb (NULL ,0 ); + } + ctx->base.is_jmp =DISAS_NORETURN ; +} + +static void gen_exception_end_tb (DisasContext *ctx,int excp) +{ +gen_exec_counters (ctx); +tcg_gen_mov_tl (hex_gpr[HEX_REG_PC ], hex_next_PC); +gen_exception (excp); +tcg_gen_exit_tb (NULL ,0 ); + ctx->base.is_jmp =DISAS_NORETURN ; + }#if HEX_DEBUG
@@ -225,8 +250,7 @@ static void gen_insn(CPUHexagonState *env, DisasContext *ctx,mark_implicit_writes (ctx, insn); insn->generate (env, ctx, insn, pkt); }else { -gen_exception (HEX_EXCP_INVALID_OPCODE ); - ctx->base.is_jmp =DISAS_NORETURN ; +gen_exception_end_tb (ctx,HEX_EXCP_INVALID_OPCODE ); } }
@@ -447,14 +471,6 @@ static void update_exec_counters(DisasContext *ctx, Packet *pkt) ctx->num_insns += num_real_insns; } -static void gen_exec_counters (DisasContext *ctx) -{ -tcg_gen_addi_tl (hex_gpr[HEX_REG_QEMU_PKT_CNT ], - hex_gpr[HEX_REG_QEMU_PKT_CNT ], ctx->num_packets); -tcg_gen_addi_tl (hex_gpr[HEX_REG_QEMU_INSN_CNT ], - hex_gpr[HEX_REG_QEMU_INSN_CNT ], ctx->num_insns); -} -static void gen_commit_packet (DisasContext *ctx,Packet *pkt) {gen_reg_writes (ctx);
@@ -478,7 +494,7 @@ static void gen_commit_packet(DisasContext *ctx, Packet *pkt)#endif if (pkt->pkt_has_cof) { - ctx->base.is_jmp =DISAS_NORETURN ; +gen_end_tb (ctx); } }
@@ -491,8 +507,7 @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx) nwords =read_packet_words (env, ctx, words);if (!nwords) { -gen_exception (HEX_EXCP_INVALID_PACKET ); - ctx->base.is_jmp =DISAS_NORETURN ; +gen_exception_end_tb (ctx,HEX_EXCP_INVALID_PACKET );return ; }
@@ -505,8 +520,7 @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx)gen_commit_packet (ctx, &pkt); ctx->base.pc_next += pkt.encod_pkt_size_in_bytes; }else { -gen_exception (HEX_EXCP_INVALID_PACKET ); - ctx->base.is_jmp =DISAS_NORETURN ; +gen_exception_end_tb (ctx,HEX_EXCP_INVALID_PACKET ); } }
@@ -537,8 +551,7 @@ static bool hexagon_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu,DisasContext *ctx =container_of (dcbase, DisasContext, base);tcg_gen_movi_tl (hex_gpr[HEX_REG_PC ], ctx->base.pc_next); - ctx->base.is_jmp =DISAS_NORETURN ; -gen_exception_debug (); +gen_exception_end_tb (ctx,EXCP_DEBUG );/* * The address covered by the breakpoint must be included in * [tb->pc, tb->pc + tb->size) in order to for it to be
@@ -601,19 +614,12 @@ static void hexagon_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)gen_exec_counters (ctx);tcg_gen_movi_tl (hex_gpr[HEX_REG_PC ], ctx->base.pc_next);if (ctx->base.singlestep_enabled) { -gen_exception_debug (); +gen_exception (EXCP_DEBUG ); }else {tcg_gen_exit_tb (NULL ,0 ); }break ;case DISAS_NORETURN : -gen_exec_counters (ctx); -tcg_gen_mov_tl (hex_gpr[HEX_REG_PC ], hex_next_PC); -if (ctx->base.singlestep_enabled) { -gen_exception_debug (); - }else { -tcg_gen_exit_tb (NULL ,0 ); - }break ;default :g_assert_not_reached ();
target/hexagon/translate.h +0 -3
@@ -86,8 +86,5 @@ extern TCGv hex_llsc_addr;extern TCGv hex_llsc_val;extern TCGv_i64 hex_llsc_val_i64; -void gen_exception (int excp); -void gen_exception_debug (void ); -void process_store (DisasContext *ctx,Packet *pkt,int slot_num);#endif
Signature · 1 line
2.7.4
Re: [PATCH 03/15] Hexagon (target/hexagon) properly generate TB end for DISAS_NORETURN
Quoted 17 lines · Taylor Simpson
When exiting a TB, generate all the code before returning from
hexagon_tr_translate_packetso that nothing needs to be done inhexagon_tr_tb_stop.Address feedback from Richard Henderson <[email protected]>
Signed-off-by Taylor Simpson <[email protected]>--- target/hexagon/translate.c | 62 +++++++++++++++++++++++++--------------------- target/hexagon/translate.h | 3 --- 2 files changed, 34 insertions(+), 31 deletions(-)target/hexagon/translate.c +0
-0
target/hexagon/translate.c static const char * const hexagon_prednames[] = { · line 57
Quoted 5 lines
target/hexagon/translate.c +1
-1@@ -54,16 +54,41 @@ static const char * const hexagon_prednames[] = { "p0", "p1", "p2", "p3" }; -void gen_exception (int excp) +static void gen_exception (int excp)
I would call this something like gen_exception_raw or gen_exception_nopc, or something because,
target/hexagon/translate.c static const char * const hexagon_prednames[] = { · line 84
Quoted 1 line
target/hexagon/translate.c +1
-0+static void gen_exception_end_tb (DisasContext *ctx,int excp)
... *all* exceptions end the tb.
target/hexagon/translate.c static const char * const hexagon_prednames[] = { · line 88
Quoted 4 lines
target/hexagon/translate.c +4
-0+{ +gen_exec_counters (ctx); +tcg_gen_mov_tl (hex_gpr[HEX_REG_PC ], hex_next_PC); +gen_exception (excp);
The helper_raise_exception call longjmped away, so
target/hexagon/translate.c static const char * const hexagon_prednames[] = { · line 63
Quoted 1 line
target/hexagon/translate.c +1
-0+tcg_gen_exit_tb (NULL ,0 );
... this exit_tb is dead code.
target/hexagon/translate.c static bool hexagon_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, · line 554
Quoted 7 lines
target/hexagon/translate.c +1
-2@@ -537,8 +551,7 @@ static bool hexagon_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu,DisasContext *ctx =container_of (dcbase, DisasContext, base);tcg_gen_movi_tl (hex_gpr[HEX_REG_PC ], ctx->base.pc_next); - ctx->base.is_jmp =DISAS_NORETURN ; -gen_exception_debug (); +gen_exception_end_tb (ctx,EXCP_DEBUG );
The set of the pc is also redundant?
r~
PATCH 4/15 Hexagon (target/hexagon) decide if pred has been written at TCG gen time
In reply to Taylor SimpsonMultiple writes to the same preg are and'ed together. Rather than generating a runtime check, we can determine at TCG generation time if the predicate has previously been written in the packet.
Test added to tests/tcg/hexagon/misc.c
Address feedback from Richard Henderson <[email protected]>
--- target/hexagon/gen_tcg_funcs.py | 2 +- target/hexagon/genptr.c | 22 +++++++++++++++------- target/hexagon/translate.c | 9 +++++++-- target/hexagon/translate.h | 2 ++ tests/tcg/hexagon/misc.c | 19 +++++++++++++++++++ 5 files changed, 44 insertions(+), 10 deletions(-)
target/hexagon/gen_tcg_funcs.py +1 -1
@@ -316,7 +316,7 @@ def genptr_dst_write(f, tag, regtype, regid): print("Bad register parse: ", regtype, regid) elif (regtype == "P"): if (regid in {"d", "e", "x"}): - f.write(" gen_log_pred_write(%s%sN, %s%sV);\n" % \ + f.write(" gen_log_pred_write(ctx, %s%sN, %s%sV);\n" % \ (regtype, regid, regtype, regid)) f.write(" ctx_log_pred_write(ctx, %s%sN);\n" % \ (regtype, regid))
target/hexagon/genptr.c +15 -7
@@ -122,20 +122,28 @@ static void gen_log_reg_write_pair(int rnum, TCGv_i64 val)#endif } -static inline void gen_log_pred_write (int pnum,TCGv val) +static inline void gen_log_pred_write (DisasContext *ctx,int pnum,TCGv val) {TCGv zero =tcg_const_tl (0 );TCGv base_val =tcg_temp_new ();TCGv and_val =tcg_temp_new ();TCGv pred_written =tcg_temp_new (); -/* Multiple writes to the same preg are and'ed together */ tcg_gen_andi_tl (base_val, val,0xff ); -tcg_gen_and_tl (and_val, base_val, hex_new_pred_value[pnum]); -tcg_gen_andi_tl (pred_written, hex_pred_written,1 << pnum); -tcg_gen_movcond_tl (TCG_COND_NE , hex_new_pred_value[pnum], - pred_written, zero, - and_val, base_val); + +/* +* Section 6.1.3 of the Hexagon V67 Programmer's Reference Manual +* +* Multiple writes to the same preg are and'ed together +* If this is the first predicate write in the packet, do a +* straight assignment. Otherwise, do an and. +*/ +if (!test_bit (pnum, ctx->pregs_written)) { +tcg_gen_mov_tl (hex_new_pred_value[pnum], base_val); + }else { +tcg_gen_and_tl (hex_new_pred_value[pnum], + hex_new_pred_value[pnum], base_val); + }tcg_gen_ori_tl (hex_pred_written, hex_pred_written,1 << pnum);tcg_temp_free (zero);
target/hexagon/translate.c +7 -2
@@ -173,6 +173,7 @@ static void gen_start_packet(DisasContext *ctx, Packet *pkt) ctx->reg_log_idx =0 ;bitmap_zero (ctx->regs_written,TOTAL_PER_THREAD_REGS ); ctx->preg_log_idx =0 ; +bitmap_zero (ctx->pregs_written,NUM_PREGS );for (i =0 ; i <STORES_MAX ; i++) { ctx->store_width[i] =0 ; }
@@ -227,7 +228,7 @@ static void mark_implicit_pred_write(DisasContext *ctx, Insn *insn, } } -static void mark_implicit_writes (DisasContext *ctx,Insn *insn) +static void mark_implicit_reg_writes (DisasContext *ctx,Insn *insn) {mark_implicit_reg_write (ctx, insn,A_IMPLICIT_WRITES_FP ,HEX_REG_FP );mark_implicit_reg_write (ctx, insn,A_IMPLICIT_WRITES_SP ,HEX_REG_SP );
@@ -236,7 +237,10 @@ static void mark_implicit_writes(DisasContext *ctx, Insn *insn)mark_implicit_reg_write (ctx, insn,A_IMPLICIT_WRITES_SA0 ,HEX_REG_SA0 );mark_implicit_reg_write (ctx, insn,A_IMPLICIT_WRITES_LC1 ,HEX_REG_LC1 );mark_implicit_reg_write (ctx, insn,A_IMPLICIT_WRITES_SA1 ,HEX_REG_SA1 ); +} +static void mark_implicit_pred_writes (DisasContext *ctx,Insn *insn) +{mark_implicit_pred_write (ctx, insn,A_IMPLICIT_WRITES_P0 ,0 );mark_implicit_pred_write (ctx, insn,A_IMPLICIT_WRITES_P1 ,1 );mark_implicit_pred_write (ctx, insn,A_IMPLICIT_WRITES_P2 ,2 );
@@ -247,8 +251,9 @@ static void gen_insn(CPUHexagonState *env, DisasContext *ctx, Insn *insn, Packet *pkt) {if (insn->generate) { -mark_implicit_writes (ctx, insn); +mark_implicit_reg_writes (ctx, insn); insn->generate (env, ctx, insn, pkt); +mark_implicit_pred_writes (ctx, insn); }else {gen_exception_end_tb (ctx,HEX_EXCP_INVALID_OPCODE ); }
target/hexagon/translate.h +2 -0
@@ -34,6 +34,7 @@ typedef struct DisasContext {DECLARE_BITMAP (regs_written,TOTAL_PER_THREAD_REGS );int preg_log[PRED_WRITES_MAX ];int preg_log_idx; +DECLARE_BITMAP (pregs_written,NUM_PREGS );uint8_t store_width[STORES_MAX ];uint8_t s1_store_processed; } DisasContext;
@@ -60,6 +61,7 @@ static inline void ctx_log_pred_write(DisasContext *ctx, int pnum) { ctx->preg_log[ctx->preg_log_idx] = pnum; ctx->preg_log_idx++; +set_bit (pnum, ctx->pregs_written); }static inline bool is_preloaded (DisasContext *ctx,int num)
tests/tcg/hexagon/misc.c +19 -0
@@ -264,6 +264,22 @@ static long long creg_pair(int x, int y)return retval; } +/* Check that predicates are auto-and'ed in a packet */ +static int auto_and (void ) +{ +int retval; + asm ("r5 = #1\n\t" +"{\n\t" +" p0 = cmp.eq(r1, #1)\n\t" +" p0 = cmp.eq(r1, #2)\n\t" +"}\n\t" +"%0 = p0\n\t" + :"=r" (retval) + : + :"r5" ,"p0" ); +return retval; +} +int main () {
@@ -375,6 +391,9 @@ int main() res =test_clrtnew (2 ,7 );check (res,7 ); + res =auto_and (); +check (res,0 ); +puts (err ?"FAIL" :"PASS" );return err; }
Signature · 1 line
2.7.4
Re: [PATCH 04/15] Hexagon (target/hexagon) decide if pred has been written at TCG gen time
Quoted 8 lines · Taylor Simpson
Multiple writes to the same preg are and'ed together. Rather than generating a runtime check, we can determine at TCG generation time if the predicate has previously been written in the packet.
Test added to
tests/tcg/hexagon/misc.cAddress feedback from Richard Henderson<[email protected]>
Quoted 8 lines
Signed-off-by Taylor Simpson<[email protected]>--- target/hexagon/gen_tcg_funcs.py | 2 +- target/hexagon/genptr.c | 22 +++++++++++++++------- target/hexagon/translate.c | 9 +++++++-- target/hexagon/translate.h | 2 ++ tests/tcg/hexagon/misc.c | 19 +++++++++++++++++++ 5 files changed, 44 insertions(+), 10 deletions(-)
r~
PATCH 5/15 Hexagon (target/hexagon) change variables from int to bool when appropriate
In reply to Taylor SimpsonAddress feedback from Richard Henderson <[email protected]>
--- target/hexagon/cpu_bits.h | 2 +- target/hexagon/decode.c | 80 +++++++++++++++++++++++----------------------- target/hexagon/insn.h | 21 ++++++------ target/hexagon/op_helper.c | 8 ++--- target/hexagon/translate.c | 6 ++-- target/hexagon/translate.h | 2 +- 6 files changed, 60 insertions(+), 59 deletions(-)
target/hexagon/cpu_bits.h +1 -1
@@ -47,7 +47,7 @@ static inline uint32_t iclass_bits(uint32_t encoding)return iclass; } -static inline int is_packet_end (uint32_t endocing) +static inline bool is_packet_end (uint32_t endocing) {uint32_t bits =parse_bits (endocing);return ((bits ==0x3 ) || (bits ==0x0 ));
target/hexagon/decode.c +40 -40
248 lines not on this page · raw message
target/hexagon/insn.h +11 -10
@@ -40,14 +40,15 @@ struct Instruction { uint32_t iclass:6; uint32_t slot:3; - uint32_t part1:1; /* + uint32_t which_extended:1; /* If has an extender, which immediate */ + uint32_t new_value_producer_slot:4; + +bool part1;/* * cmp-jumps are split into two insns. * set for the compare and clear for the jump */ - uint32_t extension_valid:1; /* Has a constant extender attached */ - uint32_t which_extended:1; /* If has an extender, which immediate */ - uint32_t is_endloop:1; /* This is an end of loop */ - uint32_t new_value_producer_slot:4; +bool extension_valid;/* Has a constant extender attached */ +bool is_endloop;/* This is an end of loop */ int32_t immed[IMMEDS_MAX ];/* immediate field */ };
@@ -58,13 +59,13 @@ struct Packet {uint16_t encod_pkt_size_in_bytes;/* Pre-decodes about COF */ - uint32_t pkt_has_cof:1; /* Has any change-of-flow */ - uint32_t pkt_has_endloop:1; +bool pkt_has_cof;/* Has any change-of-flow */ +bool pkt_has_endloop; - uint32_t pkt_has_dczeroa:1; +bool pkt_has_dczeroa; - uint32_t pkt_has_store_s0:1; - uint32_t pkt_has_store_s1:1; +bool pkt_has_store_s0; +bool pkt_has_store_s1;Insn insn[INSTRUCTIONS_MAX ]; };
target/hexagon/op_helper.c +4 -4
@@ -948,8 +948,8 @@ static bool is_inf_prod(int32_t a, int32_t b)float32 HELPER (sffma_lib )(CPUHexagonState *env,float32 RxV,float32 RsV,float32 RtV) { -int infinp; -int infminusinf; +bool infinp; +bool infminusinf;float32 tmp;arch_fpop_start (env);
@@ -982,8 +982,8 @@ float32 HELPER(sffma_lib)(CPUHexagonState *env, float32 RxV,float32 HELPER (sffms_lib )(CPUHexagonState *env,float32 RxV,float32 RsV,float32 RtV) { -int infinp; -int infminusinf; +bool infinp; +bool infminusinf;float32 tmp;arch_fpop_start (env);
target/hexagon/translate.c +3 -3
@@ -178,7 +178,7 @@ static void gen_start_packet(DisasContext *ctx, Packet *pkt) ctx->store_width[i] =0 ; }tcg_gen_movi_tl (hex_pkt_has_store_s1, pkt->pkt_has_store_s1); - ctx->s1_store_processed =0 ; + ctx->s1_store_processed = false;#if HEX_DEBUG /* Handy place to set a breakpoint before the packet executes */
@@ -211,7 +211,7 @@ static void mark_implicit_reg_write(DisasContext *ctx, Insn *insn, int attrib, int rnum) {if (GET_ATTRIB (insn->opcode, attrib)) { -int is_predicated =GET_ATTRIB (insn->opcode,A_CONDEXEC ); +bool is_predicated =GET_ATTRIB (insn->opcode,A_CONDEXEC );if (is_predicated && !is_preloaded (ctx, rnum)) {tcg_gen_mov_tl (hex_new_value[rnum], hex_gpr[rnum]); }
@@ -355,7 +355,7 @@ void process_store(DisasContext *ctx, Packet *pkt, int slot_num)if (slot_num ==1 && ctx->s1_store_processed) {return ; } - ctx->s1_store_processed =1 ; + ctx->s1_store_processed = true;if (is_predicated) {TCGv cancelled =tcg_temp_new ();
target/hexagon/translate.h +1 -1
@@ -36,7 +36,7 @@ typedef struct DisasContext {int preg_log_idx;DECLARE_BITMAP (pregs_written,NUM_PREGS );uint8_t store_width[STORES_MAX ]; -uint8_t s1_store_processed; +bool s1_store_processed; } DisasContext;static inline void ctx_log_reg_write (DisasContext *ctx,int rnum)
Signature · 1 line
2.7.4
Re: [PATCH 05/15] Hexagon (target/hexagon) change variables from int to bool when appropriate
Hi Taylor,
Quoted 1 line · Taylor Simpson
Address feedback from Richard Henderson <[email protected]>
If you look at the git history, we use the following tags:
- Reported-by: Richard Henderson <[email protected]>
- Suggested-by: Richard Henderson <[email protected]> and tools know how to use them:
https://repo.or.cz/git-dm.git/blob/5ccc4dac6837:/gitdm#l292
(same comment applies to other patches in your series).
That said,
Quoted 10 lines
Signed-off-by Taylor Simpson <[email protected]>--- target/hexagon/cpu_bits.h | 2 +- target/hexagon/decode.c | 80 +++++++++++++++++++++++----------------------- target/hexagon/insn.h | 21 ++++++------ target/hexagon/op_helper.c | 8 ++--- target/hexagon/translate.c | 6 ++-- target/hexagon/translate.h | 2 +- 6 files changed, 60 insertions(+), 59 deletions(-)
Re: [PATCH 05/15] Hexagon (target/hexagon) change variables from int to bool when appropriate
In reply to Taylor SimpsonQuoted 11 lines · Taylor Simpson
Address feedback from Richard Henderson<[email protected]>
Signed-off-by Taylor Simpson<[email protected]>--- target/hexagon/cpu_bits.h | 2 +- target/hexagon/decode.c | 80 +++++++++++++++++++++++----------------------- target/hexagon/insn.h | 21 ++++++------ target/hexagon/op_helper.c | 8 ++--- target/hexagon/translate.c | 6 ++-- target/hexagon/translate.h | 2 +- 6 files changed, 60 insertions(+), 59 deletions(-)
r~
PATCH 6/15 Hexagon (target/hexagon) utility function changes
In reply to Taylor SimpsonRemove unused carry_from_add64 function
Change type of softfloat_roundingmodes
Address feedback from Richard Henderson <[email protected]>
--- target/hexagon/arch.c | 15 +-------------- target/hexagon/arch.h | 1 - target/hexagon/macros.h | 2 -- 3 files changed, 1 insertion(+), 17 deletions(-)
target/hexagon/arch.c +1 -14
@@ -76,19 +76,6 @@ uint64_t deinterleave(uint64_t src)return myeven | (myodd <<32 ); } -uint32_t carry_from_add64 (uint64_t a,uint64_t b,uint32_t c) -{ -uint64_t tmpa, tmpb, tmpc; - tmpa =fGETUWORD (0 , a); - tmpb =fGETUWORD (0 , b); - tmpc = tmpa + tmpb + c; - tmpa =fGETUWORD (1 , a); - tmpb =fGETUWORD (1 , b); - tmpc = tmpa + tmpb +fGETUWORD (1 , tmpc); - tmpc =fGETUWORD (1 , tmpc); -return tmpc; -} -int32_t conv_round (int32_t a,int n) {int64_t val;
@@ -108,7 +95,7 @@ int32_t conv_round(int32_t a, int n)/* Floating Point Stuff */ -static const int softfloat_roundingmodes[] = { +static const FloatRoundMode softfloat_roundingmodes[] = { float_round_nearest_even, float_round_to_zero, float_round_down,
target/hexagon/arch.h +0 -1
@@ -22,7 +22,6 @@uint64_t interleave (uint32_t odd,uint32_t even);uint64_t deinterleave (uint64_t src); -uint32_t carry_from_add64 (uint64_t a,uint64_t b,uint32_t c);int32_t conv_round (int32_t a,int n);void arch_fpop_start (CPUHexagonState *env);void arch_fpop_end (CPUHexagonState *env);
target/hexagon/macros.h +0 -2
@@ -341,8 +341,6 @@ static inline void gen_logical_not(TCGv dest, TCGv src)#define fWRITE_LC0 (VAL ) WRITE_RREG(HEX_REG_LC0, VAL)#define fWRITE_LC1 (VAL ) WRITE_RREG(HEX_REG_LC1, VAL) -#define fCARRY_FROM_ADD (A ,B ,C ) carry_from_add64(A, B, C) -#define fSET_OVERFLOW () SET_USR_FIELD(USR_OVF, 1)#define fSET_LPCFG (VAL ) SET_USR_FIELD(USR_LPCFG, (VAL))#define fGET_LPCFG (GET_USR_FIELD(USR_LPCFG))
Signature · 1 line
2.7.4
Re: [PATCH 06/15] Hexagon (target/hexagon) utility function changes
Quoted 11 lines · Taylor Simpson
Remove unused
carry_from_add64function
Change type ofsoftfloat_roundingmodesAddress feedback from Richard Henderson<[email protected]>
Signed-off-by Taylor Simpson<[email protected]>--- target/hexagon/arch.c | 15 +-------------- target/hexagon/arch.h | 1 - target/hexagon/macros.h | 2 -- 3 files changed, 1 insertion(+), 17 deletions(-)
These are two separate changes.
Split them, and you can have
for each.
r~
PATCH 7/15 Hexagon (target/hexagon) use softfloat default NaN and tininess
In reply to Taylor SimpsonAddress feedback from Richard Henderson <[email protected]>
--- fpu/softfloat-specialize.c.inc | 5 +++++ target/hexagon/cpu.c | 5 +++++ target/hexagon/op_helper.c | 47 ------------------------------------------ 3 files changed, 10 insertions(+), 47 deletions(-)
fpu/softfloat-specialize.c.inc +5 -0
@@ -145,6 +145,9 @@ static FloatParts parts_default_nan(float_status *status) #elif defined(TARGET_HPPA) /* snan_bit_is_one, set msb-1. */ frac = 1ULL << (DECOMPOSED_BINARY_POINT - 2); +#elif defined(TARGET_HEXAGON) + sign = 1; + frac = ~0ULL; #else /* This case is true for Alpha, ARM, MIPS, OpenRISC, PPC, RISC-V, * S390, SH4, TriCore, and Xtensa. I cannot find documentation
@@ -180,6 +183,8 @@ static FloatParts parts_silence_nan(FloatParts a, float_status *status) #if defined(TARGET_HPPA) a.frac &= ~(1ULL << (DECOMPOSED_BINARY_POINT - 1)); a.frac |= 1ULL << (DECOMPOSED_BINARY_POINT - 2); +#elif defined(TARGET_HEXAGON) + return parts_default_nan(status); #else if (snan_bit_is_one(status)) { return parts_default_nan(status);
target/hexagon/cpu.c +5 -0
@@ -23,6 +23,7 @@#include "exec/exec-all.h" #include "qapi/error.h" #include "hw/qdev-properties.h" +#include "fpu/softfloat-helpers.h" static void hexagon_v67_cpu_init (Object *obj) {
@@ -205,8 +206,12 @@ static void hexagon_cpu_reset(DeviceState *dev)CPUState *cs =CPU (dev);HexagonCPU *cpu =HEXAGON_CPU (cs);HexagonCPUClass *mcc =HEXAGON_CPU_GET_CLASS (cpu); +CPUHexagonState *env = &cpu->env; mcc->parent_reset (dev); + +set_default_nan_mode (1 , &env->fp_status); +set_float_detect_tininess (float_tininess_before_rounding, &env->fp_status); }static void hexagon_cpu_disas_set_info (CPUState *s,disassemble_info *info)
target/hexagon/op_helper.c +0 -47
214 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH 07/15] Hexagon (target/hexagon) use softfloat default NaN and tininess
fpu/softfloat-specialize.c.inc static FloatParts parts_silence_nan(FloatParts a, float_status *status) · line 187
Quoted 6 lines · Taylor Simpson
fpu/softfloat-specialize.c.inc +2
-0@@ -180,6 +183,8 @@ static FloatParts parts_silence_nan(FloatParts a, float_status *status) #if defined(TARGET_HPPA) a.frac &= ~(1ULL << (DECOMPOSED_BINARY_POINT - 1)); a.frac |= 1ULL << (DECOMPOSED_BINARY_POINT - 2); +#elif defined(TARGET_HEXAGON) + return parts_default_nan(status);
This part is incorrect. You should be changing no_signaling_nans above, because:
4.3.11.2 Floating-Point Representation
... The ISA does not include IEEE754 signaling NaNs ...
r~
PATCH 8/15 Hexagon (target/hexagon) replace float32_mul_pow2 with float32_scalbn
In reply to Taylor SimpsonAddress feedback from Richard Henderson <[email protected]>
--- target/hexagon/arch.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)
target/hexagon/arch.c +11 -17
@@ -143,12 +143,6 @@ void arch_fpop_end(CPUHexagonState *env) } } -static float32 float32_mul_pow2 (float32 a,uint32_t p,float_status *fp_status) -{ -float32 b =make_float32 ((SF_BIAS + p) <<SF_MANTBITS ); -return float32_mul (a, b, fp_status); -} -int arch_sf_recip_common (float32 *Rs,float32 *Rt,float32 *Rd,int *adjust,float_status *fp_status) {
@@ -217,22 +211,22 @@ int arch_sf_recip_common(float32 *Rs, float32 *Rt, float32 *Rd, int *adjust,if ((n_exp - d_exp +SF_BIAS ) <=SF_MANTBITS ) {/* Near quotient underflow / inexact Q */ PeV =0x80 ; - RtV =float32_mul_pow2 (RtV,-64 , fp_status); - RsV =float32_mul_pow2 (RsV,64 , fp_status); + RtV =float32_scalbn (RtV,-64 , fp_status); + RsV =float32_scalbn (RsV,64 , fp_status); }else if ((n_exp - d_exp +SF_BIAS ) > (SF_MAXEXP -24 )) {/* Near quotient overflow */ PeV =0x40 ; - RtV =float32_mul_pow2 (RtV,32 , fp_status); - RsV =float32_mul_pow2 (RsV,-32 , fp_status); + RtV =float32_scalbn (RtV,32 , fp_status); + RsV =float32_scalbn (RsV,-32 , fp_status); }else if (n_exp <=SF_MANTBITS +2 ) { - RtV =float32_mul_pow2 (RtV,64 , fp_status); - RsV =float32_mul_pow2 (RsV,64 , fp_status); + RtV =float32_scalbn (RtV,64 , fp_status); + RsV =float32_scalbn (RsV,64 , fp_status); }else if (d_exp <=1 ) { - RtV =float32_mul_pow2 (RtV,32 , fp_status); - RsV =float32_mul_pow2 (RsV,32 , fp_status); + RtV =float32_scalbn (RtV,32 , fp_status); + RsV =float32_scalbn (RsV,32 , fp_status); }else if (d_exp >252 ) { - RtV =float32_mul_pow2 (RtV,-32 , fp_status); - RsV =float32_mul_pow2 (RsV,-32 , fp_status); + RtV =float32_scalbn (RtV,-32 , fp_status); + RsV =float32_scalbn (RsV,-32 , fp_status); } RdV =0 ; ret =1 ;
@@ -274,7 +268,7 @@ int arch_sf_invsqrt_common(float32 *Rs, float32 *Rd, int *adjust,/* Basic checks passed */ r_exp =float32_getexp (RsV);if (r_exp <=24 ) { - RsV =float32_mul_pow2 (RsV,64 , fp_status); + RsV =float32_scalbn (RsV,64 , fp_status); PeV =0xe0 ; } RdV =0 ;
Signature · 1 line
2.7.4
Re: [PATCH 08/15] Hexagon (target/hexagon) replace float32_mul_pow2 with float32_scalbn
Quoted 6 lines · Taylor Simpson
Address feedback from Richard Henderson<[email protected]>
Signed-off-by Taylor Simpson<[email protected]>--- target/hexagon/arch.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)
r~
PATCH 9/15 Hexagon (target/hexagon) use softfloat for float-to-int conversions
In reply to Taylor SimpsonUse the proper return for helpers that convert to unsigned Remove target/hexagon/conv_emu.[ch]
Address feedback from Richard Henderson <[email protected]>
--- target/hexagon/conv_emu.c | 177 -------------------------------------------- target/hexagon/conv_emu.h | 31 -------- target/hexagon/fma_emu.c | 1 - target/hexagon/helper.h | 16 ++-- target/hexagon/meson.build | 1 - target/hexagon/op_helper.c | 169 ++++++++++++++++++++++++++++++++---------- tests/tcg/hexagon/fpstuff.c | 145 ++++++++++++++++++++++++++++++++++++ 7 files changed, 281 insertions(+), 259 deletions(-) delete mode 100644 target/hexagon/conv_emu.c delete mode 100644 target/hexagon/conv_emu.h
target/hexagon/conv_emu.c deleted +0 -177
@@ -1,177 +0,0 @@ -/* -* Copyright(c) 2019-2021 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 -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, see <http://www.gnu.org/licenses/>. -*/ - -#include "qemu/osdep.h" -#include "qemu/host-utils.h" -#include "fpu/softfloat.h" -#include "macros.h" -#include "conv_emu.h" - -#define LL_MAX_POS 0x7fffffffffffffffULL -#define MAX_POS 0x7fffffffU - -static uint64_t conv_f64_to_8u_n (float64 in,int will_negate, -float_status *fp_status) -{ -uint8_t sign =float64_is_neg (in); -if (float64_is_infinity (in)) { -float_raise (float_flag_invalid, fp_status); -if (float64_is_neg (in)) { -return 0ULL ; - }else { -return ~0ULL ; - } - } -if (float64_is_any_nan (in)) { -float_raise (float_flag_invalid, fp_status); -return ~0ULL ; - } -if (float64_is_zero (in)) { -return 0 ; - } -if (sign) { -float_raise (float_flag_invalid, fp_status); -return 0 ; - } -if (float64_lt (in, float64_half, fp_status)) { -/* Near zero, captures large fracshifts, denorms, etc */ -float_raise (float_flag_inexact, fp_status); -switch (get_float_rounding_mode (fp_status)) { -case float_round_down: -if (will_negate) { -return 1 ; - }else { -return 0 ; - } -case float_round_up: -if (!will_negate) { -return 1 ; - }else { -return 0 ; - } -default : -return 0 ;/* nearest or towards zero */ - } - } -return float64_to_uint64 (in, fp_status); -} - -static void clr_float_exception_flags (uint8_t flag,float_status *fp_status) -{ -uint8_t flags = fp_status->float_exception_flags; - flags &= ~flag; -set_float_exception_flags (flags, fp_status); -} - -static uint32_t conv_df_to_4u_n (float64 fp64,int will_negate, -float_status *fp_status) -{ -uint64_t tmp; - tmp =conv_f64_to_8u_n (fp64, will_negate, fp_status); -if (tmp >0x00000000ffffffffULL ) { -clr_float_exception_flags (float_flag_inexact, fp_status); -float_raise (float_flag_invalid, fp_status); -return ~0U ; - } -return (uint32_t )tmp; -} - -uint64_t conv_df_to_8u (float64 in,float_status *fp_status) -{ -return conv_f64_to_8u_n (in,0 , fp_status); -} - -uint32_t conv_df_to_4u (float64 in,float_status *fp_status) -{ -return conv_df_to_4u_n (in,0 , fp_status); -} - -int64_t conv_df_to_8s (float64 in,float_status *fp_status) -{ -uint8_t sign =float64_is_neg (in); -uint64_t tmp; -if (float64_is_any_nan (in)) { -float_raise (float_flag_invalid, fp_status); -return -1 ; - } -if (sign) { -float64 minus_fp64 =float64_abs (in); - tmp =conv_f64_to_8u_n (minus_fp64,1 , fp_status); - }else { - tmp =conv_f64_to_8u_n (in,0 , fp_status); - } -if (tmp > (LL_MAX_POS + sign)) { -clr_float_exception_flags (float_flag_inexact, fp_status); -float_raise (float_flag_invalid, fp_status); - tmp = (LL_MAX_POS + sign); - } -if (sign) { -return -tmp; - }else { -return tmp; - } -} - -int32_t conv_df_to_4s (float64 in,float_status *fp_status) -{ -uint8_t sign =float64_is_neg (in); -uint64_t tmp; -if (float64_is_any_nan (in)) { -float_raise (float_flag_invalid, fp_status); -return -1 ; - } -if (sign) { -float64 minus_fp64 =float64_abs (in); - tmp =conv_f64_to_8u_n (minus_fp64,1 , fp_status); - }else { - tmp =conv_f64_to_8u_n (in,0 , fp_status); - } -if (tmp > (MAX_POS + sign)) { -clr_float_exception_flags (float_flag_inexact, fp_status); -float_raise (float_flag_invalid, fp_status); - tmp = (MAX_POS + sign); - } -if (sign) { -return -tmp; - }else { -return tmp; - } -} - -uint64_t conv_sf_to_8u (float32 in,float_status *fp_status) -{ -float64 fp64 =float32_to_float64 (in, fp_status); -return conv_df_to_8u (fp64, fp_status); -} - -uint32_t conv_sf_to_4u (float32 in,float_status *fp_status) -{ -float64 fp64 =float32_to_float64 (in, fp_status); -return conv_df_to_4u (fp64, fp_status); -} - -int64_t conv_sf_to_8s (float32 in,float_status *fp_status) -{ -float64 fp64 =float32_to_float64 (in, fp_status); -return conv_df_to_8s (fp64, fp_status); -} - -int32_t conv_sf_to_4s (float32 in,float_status *fp_status) -{ -float64 fp64 =float32_to_float64 (in, fp_status); -return conv_df_to_4s (fp64, fp_status); -}
target/hexagon/conv_emu.h deleted +0 -31
@@ -1,31 +0,0 @@ -/* -* Copyright(c) 2019-2021 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 -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef HEXAGON_CONV_EMU_H -#define HEXAGON_CONV_EMU_H - -uint64_t conv_sf_to_8u (float32 in,float_status *fp_status); -uint32_t conv_sf_to_4u (float32 in,float_status *fp_status); -int64_t conv_sf_to_8s (float32 in,float_status *fp_status); -int32_t conv_sf_to_4s (float32 in,float_status *fp_status); - -uint64_t conv_df_to_8u (float64 in,float_status *fp_status); -uint32_t conv_df_to_4u (float64 in,float_status *fp_status); -int64_t conv_df_to_8s (float64 in,float_status *fp_status); -int32_t conv_df_to_4s (float64 in,float_status *fp_status); - -#endif
target/hexagon/fma_emu.c +0 -1
@@ -19,7 +19,6 @@#include "qemu/int128.h" #include "fpu/softfloat.h" #include "macros.h" -#include "conv_emu.h" #include "fma_emu.h" #define DF_INF_EXP 0x7ff
target/hexagon/helper.h +8 -8
@@ -38,21 +38,21 @@ DEF_HELPER_2(conv_ud2sf, f32, env, s64) DEF_HELPER_2(conv_ud2df, f64, env, s64) DEF_HELPER_2(conv_d2sf, f32, env, s64) DEF_HELPER_2(conv_d2df, f64, env, s64) -DEF_HELPER_2(conv_sf2uw, s32, env, f32) +DEF_HELPER_2(conv_sf2uw, i32, env, f32) DEF_HELPER_2(conv_sf2w, s32, env, f32) -DEF_HELPER_2(conv_sf2ud, s64, env, f32) +DEF_HELPER_2(conv_sf2ud, i64, env, f32) DEF_HELPER_2(conv_sf2d, s64, env, f32) -DEF_HELPER_2(conv_df2uw, s32, env, f64) +DEF_HELPER_2(conv_df2uw, i32, env, f64) DEF_HELPER_2(conv_df2w, s32, env, f64) -DEF_HELPER_2(conv_df2ud, s64, env, f64) +DEF_HELPER_2(conv_df2ud, i64, env, f64) DEF_HELPER_2(conv_df2d, s64, env, f64) -DEF_HELPER_2(conv_sf2uw_chop, s32, env, f32) +DEF_HELPER_2(conv_sf2uw_chop, i32, env, f32) DEF_HELPER_2(conv_sf2w_chop, s32, env, f32) -DEF_HELPER_2(conv_sf2ud_chop, s64, env, f32) +DEF_HELPER_2(conv_sf2ud_chop, i64, env, f32) DEF_HELPER_2(conv_sf2d_chop, s64, env, f32) -DEF_HELPER_2(conv_df2uw_chop, s32, env, f64) +DEF_HELPER_2(conv_df2uw_chop, i32, env, f64) DEF_HELPER_2(conv_df2w_chop, s32, env, f64) -DEF_HELPER_2(conv_df2ud_chop, s64, env, f64) +DEF_HELPER_2(conv_df2ud_chop, i64, env, f64) DEF_HELPER_2(conv_df2d_chop, s64, env, f64) DEF_HELPER_3(sfadd, f32, env, f32, f32)DEF_HELPER_3 (sfsub, f32, env, f32, f32)
target/hexagon/meson.build +0 -1
@@ -185,7 +185,6 @@ hexagon_ss.add(files( 'printinsn.c', 'arch.c', 'fma_emu.c', - 'conv_emu.c', )) target_arch += {'hexagon': hexagon_ss}
target/hexagon/op_helper.c +128 -41
273 lines not on this page · raw message
tests/tcg/hexagon/fpstuff.c +145 -0
167 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH 09/15] Hexagon (target/hexagon) use softfloat for float-to-int conversions
target/hexagon/op_helper.c int32_t HELPER(conv_sf2w)(CPUHexagonState *env, float32 RsV) · line 465
Quoted 12 lines · Taylor Simpson
target/hexagon/op_helper.c +7
-1@@ -451,16 +456,28 @@ int32_t HELPER(conv_sf2w)(CPUHexagonState *env, float32 RsV) {int32_t RdV;arch_fpop_start (env); - RdV =conv_sf_to_4s (RsV, &env->fp_status); +/* Hexagon returns -1 for NaN */ +if (float32_is_any_nan (RsV)) { +float_raise (float_flag_invalid, &env->fp_status); + RdV =-1 ; + }else { + RdV =float32_to_int32 (RsV, &env->fp_status); + }
So this is interesting.
The 8.3.x Document Bundle, which has the V67 programmer's manual, say the output value is IMPLEMENTATION DEFINED (without saying anything more about defining values for any particular implementation), while the older 2010 manual specifies 0x7fffffff as the result (which is what float32_to_int32 provides).
I must say I find the newer manual very lacking on details, including the non-specification of the Behavior pseudocode functions.
I guess the only thing we can do is document this as matching some particular hardware implementation?
r~
Re: [PATCH 09/15] Hexagon (target/hexagon) use softfloat for float-to-int conversions
Quoted 17 lines · Richard Henderson
target/hexagon/op_helper.c int32_t HELPER(conv_sf2w)(CPUHexagonState *env, float32 · line 466
Quoted 13 lines · Taylor Simpson
target/hexagon/op_helper.c +7
-1@@ -451,16 +456,28 @@ int32_t HELPER(conv_sf2w)(CPUHexagonState *env, float32 RsV) { int32_t RdV; arch_fpop_start(env); - RdV = conv_sf_to_4s(RsV, &env->fp_status); + /* Hexagon returns -1 for NaN */ + if (float32_is_any_nan(RsV)) { + float_raise(float_flag_invalid, &env->fp_status); + RdV = -1; + } else { + RdV = float32_to_int32(RsV, &env->fp_status); + }So this is interesting.
Quoted 1 line
The 8.3.x Document Bundle, which has the V67 programmer's manual, say the output value is IMPLEMENTATION DEFINED (without saying anything more about defining values for any particular implementation), while the older 2010 manual specifies
0x7fffffffas the result (which is whatfloat32_to_int32provides).
OMG, I had the wrong manual open. Ignore me.
r~
PATCH 10/15 Hexagon (target/hexagon) instructions with multiple definitions
In reply to Taylor SimpsonInstructions with multiple definitions require special handling because the generator wants to create a helper, but helpers can only return a single result. Therefore, we must override the generated code.
The following instructions are added
A4_addp_c Rdd32 = add(Rss32, Rtt32, Px4):carry
Add with carry
A4_subp_c Rdd32 = sub(Rss32, Rtt32, Px4):carry
Sub with carry
A5_ACS Rxx32,Pe4 = vacsh(Rss32, Rtt32)
Add compare and select elements of two vectors
A6_vminub_RdP Rdd32,Pe4 = vminub(Rtt32, Rss32)
Vector min of bytes
F2_invsqrta Rd32,Pe4 = sfinvsqrta(Rs32)
Square root approx
F2_sfrecipa Rd32,Pe4 = sfrecipa(Rs32, Rt32)
Recripocal approx
Test cases in tests/tcg/hexagon/multi_result.c FP exception tests added to tests/tcg/hexagon/fpstuff.c
--- target/hexagon/arch.c | 57 +++++++- target/hexagon/arch.h | 2 + target/hexagon/gen_tcg.h | 107 +++++++++++++++ target/hexagon/genptr.c | 111 +++++++++++++++ target/hexagon/helper.h | 6 + target/hexagon/imported/alu.idef | 44 ++++++ target/hexagon/imported/encode_pp.def | 6 + target/hexagon/imported/float.idef | 32 +++++ target/hexagon/macros.h | 41 ++++++ target/hexagon/op_helper.c | 130 ++++++++++++++++++ tests/tcg/hexagon/Makefile.target | 1 + tests/tcg/hexagon/fpstuff.c | 97 +++++++++++++ tests/tcg/hexagon/multi_result.c | 249 ++++++++++++++++++++++++++++++++++ 13 files changed, 879 insertions(+), 4 deletions(-) create mode 100644 tests/tcg/hexagon/multi_result.c
target/hexagon/arch.c +53 -4
@@ -181,12 +181,13 @@ int arch_sf_recip_common(float32 *Rs, float32 *Rt, float32 *Rd, int *adjust,/* or put Inf in num fixup? */ uint8_t RsV_sign =float32_is_neg (RsV);uint8_t RtV_sign =float32_is_neg (RtV); +/* Check that RsV is NOT infinite before we overwrite it */ +if (!float32_is_infinity (RsV)) { +float_raise (float_flag_divbyzero, fp_status); + } RsV =infinite_float32 (RsV_sign ^ RtV_sign); RtV = float32_one; RdV = float32_one; -if (float32_is_infinity (RsV)) { -float_raise (float_flag_divbyzero, fp_status); - } }else if (float32_is_infinity (RtV)) { RsV =make_float32 (0x80000000 & (RsV ^ RtV)); RtV = float32_one;
@@ -246,7 +247,7 @@ int arch_sf_invsqrt_common(float32 *Rs, float32 *Rd, int *adjust,int r_exp;int ret =0 ; RsV = *Rs; -if (float32_is_infinity (RsV)) { +if (float32_is_any_nan (RsV)) {if (extract32 (RsV,22 ,1 ) ==0 ) {float_raise (float_flag_invalid, fp_status); }
@@ -279,3 +280,51 @@ int arch_sf_invsqrt_common(float32 *Rs, float32 *Rd, int *adjust, *adjust = PeV;return ret; } + +int arch_recip_lookup (int index) +{ + index &=0x7f ; +unsigned const int roundrom[128 ] = { +0x0fe ,0x0fa ,0x0f6 ,0x0f2 ,0x0ef ,0x0eb ,0x0e7 ,0x0e4 , +0x0e0 ,0x0dd ,0x0d9 ,0x0d6 ,0x0d2 ,0x0cf ,0x0cc ,0x0c9 , +0x0c6 ,0x0c2 ,0x0bf ,0x0bc ,0x0b9 ,0x0b6 ,0x0b3 ,0x0b1 , +0x0ae ,0x0ab ,0x0a8 ,0x0a5 ,0x0a3 ,0x0a0 ,0x09d ,0x09b , +0x098 ,0x096 ,0x093 ,0x091 ,0x08e ,0x08c ,0x08a ,0x087 , +0x085 ,0x083 ,0x080 ,0x07e ,0x07c ,0x07a ,0x078 ,0x075 , +0x073 ,0x071 ,0x06f ,0x06d ,0x06b ,0x069 ,0x067 ,0x065 , +0x063 ,0x061 ,0x05f ,0x05e ,0x05c ,0x05a ,0x058 ,0x056 , +0x054 ,0x053 ,0x051 ,0x04f ,0x04e ,0x04c ,0x04a ,0x049 , +0x047 ,0x045 ,0x044 ,0x042 ,0x040 ,0x03f ,0x03d ,0x03c , +0x03a ,0x039 ,0x037 ,0x036 ,0x034 ,0x033 ,0x032 ,0x030 , +0x02f ,0x02d ,0x02c ,0x02b ,0x029 ,0x028 ,0x027 ,0x025 , +0x024 ,0x023 ,0x021 ,0x020 ,0x01f ,0x01e ,0x01c ,0x01b , +0x01a ,0x019 ,0x017 ,0x016 ,0x015 ,0x014 ,0x013 ,0x012 , +0x011 ,0x00f ,0x00e ,0x00d ,0x00c ,0x00b ,0x00a ,0x009 , +0x008 ,0x007 ,0x006 ,0x005 ,0x004 ,0x003 ,0x002 ,0x000 , + }; +return roundrom[index]; +}; + +int arch_invsqrt_lookup (int index) +{ + index &=0x7f ; +unsigned const int roundrom[128 ] = { +0x069 ,0x066 ,0x063 ,0x061 ,0x05e ,0x05b ,0x059 ,0x057 , +0x054 ,0x052 ,0x050 ,0x04d ,0x04b ,0x049 ,0x047 ,0x045 , +0x043 ,0x041 ,0x03f ,0x03d ,0x03b ,0x039 ,0x037 ,0x036 , +0x034 ,0x032 ,0x030 ,0x02f ,0x02d ,0x02c ,0x02a ,0x028 , +0x027 ,0x025 ,0x024 ,0x022 ,0x021 ,0x01f ,0x01e ,0x01d , +0x01b ,0x01a ,0x019 ,0x017 ,0x016 ,0x015 ,0x014 ,0x012 , +0x011 ,0x010 ,0x00f ,0x00d ,0x00c ,0x00b ,0x00a ,0x009 , +0x008 ,0x007 ,0x006 ,0x005 ,0x004 ,0x003 ,0x002 ,0x001 , +0x0fe ,0x0fa ,0x0f6 ,0x0f3 ,0x0ef ,0x0eb ,0x0e8 ,0x0e4 , +0x0e1 ,0x0de ,0x0db ,0x0d7 ,0x0d4 ,0x0d1 ,0x0ce ,0x0cb , +0x0c9 ,0x0c6 ,0x0c3 ,0x0c0 ,0x0be ,0x0bb ,0x0b8 ,0x0b6 , +0x0b3 ,0x0b1 ,0x0af ,0x0ac ,0x0aa ,0x0a8 ,0x0a5 ,0x0a3 , +0x0a1 ,0x09f ,0x09d ,0x09b ,0x099 ,0x097 ,0x095 ,0x093 , +0x091 ,0x08f ,0x08d ,0x08b ,0x089 ,0x087 ,0x086 ,0x084 , +0x082 ,0x080 ,0x07f ,0x07d ,0x07b ,0x07a ,0x078 ,0x077 , +0x075 ,0x074 ,0x072 ,0x071 ,0x06f ,0x06e ,0x06c ,0x06b , + }; +return roundrom[index]; +};
target/hexagon/arch.h +2 -0
@@ -29,5 +29,7 @@ int arch_sf_recip_common(float32 *Rs, float32 *Rt, float32 *Rd, int *adjust, float_status *fp_status);int arch_sf_invsqrt_common (float32 *Rs,float32 *Rd,int *adjust,float_status *fp_status); +int arch_recip_lookup (int index); +int arch_invsqrt_lookup (int index);#endif
target/hexagon/gen_tcg.h +107 -0
113 lines not on this page · raw message
target/hexagon/genptr.c +111 -0
122 lines not on this page · raw message
target/hexagon/helper.h +6 -0
@@ -26,6 +26,12 @@ DEF_HELPER_FLAGS_3(debug_commit_end, TCG_CALL_NO_WG, void, env, int, int)#endif DEF_HELPER_2(commit_store, void, env, int) DEF_HELPER_FLAGS_4(fcircadd, TCG_CALL_NO_RWG_SE, s32, s32, s32, s32, s32) +DEF_HELPER_3(sfrecipa_val, f32, env, f32, f32) +DEF_HELPER_3(sfrecipa_pred, s32, env, f32, f32) +DEF_HELPER_2(sfinvsqrta_val, f32, env, f32) +DEF_HELPER_2(sfinvsqrta_pred, s32, env, f32) +DEF_HELPER_4(vacsh_val, s64, env, s64, s64, s64) +DEF_HELPER_4 (vacsh_pred, s32, env, s64, s64, s64) /* Floating point */DEF_HELPER_2 (conv_sf2df, f64, env, f32)
target/hexagon/imported/alu.idef +44 -0
56 lines not on this page · raw message
target/hexagon/imported/encode_pp.def +6 -0
@@ -1017,6 +1017,8 @@ MPY_ENC(M7_dcmpyiwc_acc, "1010","xxxxx","1","0","1","0","10") +MPY_ENC(A5_ACS, "1010","xxxxx","0","1","0","1","ee") +MPY_ENC(A6_vminub_RdP, "1010","ddddd","0","1","1","1","ee") /* */
@@ -1028,6 +1030,7 @@ MPY_ENC(F2_sfmin, "1011","ddddd","0","0","0","1","01") MPY_ENC(F2_sfmpy, "1011","ddddd","0","0","1","0","00") MPY_ENC(F2_sffixupn, "1011","ddddd","0","0","1","1","00") MPY_ENC(F2_sffixupd, "1011","ddddd","0","0","1","1","01") +MPY_ENC(F2_sfrecipa, "1011","ddddd","1","1","1","1","ee") DEF_FIELDROW_DESC32(ICLASS_M" 1100 -------- PP------ --------","[#12] Rd=(Rs,Rt)") DEF_FIELD32(ICLASS_M" 1100 -------- PP------ --!-----",Mc_tH,"Rt is High") /*Rt high */
@@ -1641,6 +1644,7 @@ SH2_RR_ENC(F2_conv_sf2w, "1011","100","-","000","ddddd") SH2_RR_ENC(F2_conv_sf2uw_chop, "1011","011","-","001","ddddd") SH2_RR_ENC(F2_conv_sf2w_chop, "1011","100","-","001","ddddd") SH2_RR_ENC(F2_sffixupr, "1011","101","-","000","ddddd") +SH2_RR_ENC(F2_sfinvsqrta, "1011","111","-","0ee","ddddd") DEF_FIELDROW_DESC32(ICLASS_S2op" 1100 -------- PP------ --------","[#12] Rd=(Rs,#u6)")
@@ -1745,6 +1749,8 @@ SH_RRR_ENC(S4_extractp_rp, "0001","11-","-","10-","ddddd") DEF_FIELDROW_DESC32(ICLASS_S3op" 0010 -------- PP------ --------","[#2] Rdd=(Rss,Rtt,Pu)") SH_RRR_ENC(S2_valignrb, "0010","0--","-","-uu","ddddd") SH_RRR_ENC(S2_vsplicerb, "0010","100","-","-uu","ddddd") +SH_RRR_ENC(A4_addp_c, "0010","110","-","-xx","ddddd") +SH_RRR_ENC(A4_subp_c, "0010","111","-","-xx","ddddd") DEF_FIELDROW_DESC32(ICLASS_S3op" 0011 -------- PP------ --------","[#3] Rdd=(Rss,Rt)")
target/hexagon/imported/float.idef +32 -0
@@ -146,6 +146,22 @@ Q6INSN(F2_sfimm_n,"Rd32=sfmake(#u10):neg",ATTRIBS(), }) +Q6INSN(F2_sfrecipa,"Rd32,Pe4=sfrecipa(Rs32,Rt32)",ATTRIBS(), +"Reciprocal Approximation for Division", +{ + fHIDE(int idx;) + fHIDE(int adjust;) + fHIDE(int mant;) + fHIDE(int exp;) + if (fSF_RECIP_COMMON(RsV,RtV,RdV,adjust)) { + PeV = adjust; + idx = (RtV >> 16) & 0x7f; + mant = (fSF_RECIP_LOOKUP(idx) << 15) | 1; + exp = fSF_BIAS() - (fSF_GETEXP(RtV) - fSF_BIAS()) - 1; + RdV = fMAKESF(fGETBIT(31,RtV),exp,mant); + } +}) + Q6INSN(F2_sffixupn,"Rd32=sffixupn(Rs32,Rt32)",ATTRIBS(), "Fix Up Numerator", {
@@ -162,6 +178,22 @@ Q6INSN(F2_sffixupd,"Rd32=sffixupd(Rs32,Rt32)",ATTRIBS(), RdV = RtV; }) +Q6INSN(F2_sfinvsqrta,"Rd32,Pe4=sfinvsqrta(Rs32)",ATTRIBS(), +"Reciprocal Square Root Approximation", +{ + fHIDE(int idx;) + fHIDE(int adjust;) + fHIDE(int mant;) + fHIDE(int exp;) + if (fSF_INVSQRT_COMMON(RsV,RdV,adjust)) { + PeV = adjust; + idx = (RsV >> 17) & 0x7f; + mant = (fSF_INVSQRT_LOOKUP(idx) << 15); + exp = fSF_BIAS() - ((fSF_GETEXP(RsV) - fSF_BIAS()) >> 1) - 1; + RdV = fMAKESF(fGETBIT(31,RsV),exp,mant); + } +}) + Q6INSN(F2_sffixupr,"Rd32=sffixupr(Rs32)",ATTRIBS(), "Fix Up Radicand", {
target/hexagon/macros.h +41 -0
89 lines not on this page · raw message
target/hexagon/op_helper.c +130 -0
136 lines not on this page · raw message
tests/tcg/hexagon/Makefile.target +1 -0
@@ -39,6 +39,7 @@ HEX_TESTS = first HEX_TESTS += misc HEX_TESTS += preg_alias HEX_TESTS += dual_stores +HEX_TESTS += multi_result HEX_TESTS += mem_noshuf HEX_TESTS += atomics HEX_TESTS += fpstuff
tests/tcg/hexagon/fpstuff.c +97 -0
116 lines not on this page · raw message
tests/tcg/hexagon/multi_result.c new file +249 -0
249 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH 10/15] Hexagon (target/hexagon) instructions with multiple definitions
Quoted 5 lines · Taylor Simpson
Instructions with multiple definitions require special handling because the generator wants to create a helper, but helpers can only return a single result. Therefore, we must override the generated code.
Quoted 13 lines
The following instructions are added
A4_addp_cRdd32 =add(Rss32, Rtt32, Px4):carry
Add with carry
A4_subp_cRdd32 =sub(Rss32, Rtt32, Px4):carry
Sub with carry
A5_ACSRxx32,Pe4 =vacsh(Rss32, Rtt32)
Add compare and select elements of two vectors
A6_vminub_RdPRdd32,Pe4 =vminub(Rtt32, Rss32)
Vector min of bytes
F2_invsqrtaRd32,Pe4 = sfinvsqrta(Rs32)
Square root approx
F2_sfrecipaRd32,Pe4 =sfrecipa(Rs32, Rt32)
Recripocal approx
One thing at a time. This is no longer port bring-up where large patches are unavoidable.
target/hexagon/arch.c int arch_sf_invsqrt_common(float32 *Rs, float32 *Rd, int *adjust, · line 287
Quoted 4 lines
target/hexagon/arch.c +4
-0+int arch_recip_lookup (int index) +{ + index &=0x7f ; +unsigned const int roundrom[128 ] = {
static const uint16_t? or is it in fact all 8-bit data?
target/hexagon/arch.c int arch_sf_invsqrt_common(float32 *Rs, float32 *Rd, int *adjust, · line 311
Quoted 4 lines
target/hexagon/arch.c +4
-0+int arch_invsqrt_lookup (int index) +{ + index &=0x7f ; +unsigned const int roundrom[128 ] = {
Likewise.
Quoted 13 lines
target/hexagon/gen_tcg.h +13
-0+/* +* Add or subtract with carry. +* Predicate register is used as an extra input and output. +* r5:4 = add(r1:0, r3:2, p1):carry +*/ +#define fGEN_TCG_A4_addp_c (SHORTCODE ) \ + do { \ + TCGv LSB = tcg_temp_new(); \ + TCGv_i64 LSB_i64 = tcg_temp_new_i64(); \ + TCGv_i64 tmp_i64 = tcg_temp_new_i64(); \ + TCGv tmp = tcg_temp_new(); \ + tcg_gen_add_i64(RddV, RssV, RttV); \ + fLSBOLD(PxV); \
target/hexagon/gen_tcg.h line 250
Quoted 10 lines
target/hexagon/gen_tcg.h +10
-0+tcg_gen_extu_i32_i64 (LSB_i64,LSB ); \ +tcg_gen_add_i64 (RddV, RddV, LSB_i64); \ +gen_carry_from_add64 (tmp_i64, RssV, RttV, LSB_i64); \ +tcg_gen_extrl_i64_i32 (tmp, tmp_i64); \ +f8BITSOF (PxV, tmp); \ +tcg_temp_free (LSB ); \ +tcg_temp_free_i64 (LSB_i64); \ +tcg_temp_free_i64 (tmp_i64); \ +tcg_temp_free (tmp); \ + }while (0 )
You might as well implement this properly with tcg_gen_add2_i64.
Quoted 4 lines
target/hexagon/gen_tcg.h +4
-0+ +/* r5:4 = sub(r1:0, r3:2, p1):carry */ +#define fGEN_TCG_A4_subp_c (SHORTCODE ) \ + do { \
target/hexagon/gen_tcg.h line 264
Quoted 10 lines
target/hexagon/gen_tcg.h +10
-0+TCGv LSB =tcg_temp_new (); \ +TCGv_i64 LSB_i64 =tcg_temp_new_i64 (); \ +TCGv_i64 tmp_i64 =tcg_temp_new_i64 (); \ +TCGv tmp =tcg_temp_new (); \ +tcg_gen_not_i64 (tmp_i64, RttV); \ +tcg_gen_add_i64 (RddV, RssV, tmp_i64); \ +fLSBOLD (PxV); \ +tcg_gen_extu_i32_i64 (LSB_i64,LSB ); \ +tcg_gen_add_i64 (RddV, RddV, LSB_i64); \ +gen_carry_from_add64 (tmp_i64, RssV, tmp_i64, LSB_i64); \
Likewise.
Ignoring the rest. Too large.
r~
RE: [PATCH 10/15] Hexagon (target/hexagon) instructions with multiple definitions
Quoted 30 lines
-----Original Message-----
From: Richard Henderson <[email protected]>
Sent: Thursday, March 25, 2021 11:25 AM
To: Taylor Simpson <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Brian Cain <[email protected]>
Subject: Re: [PATCH 10/15] Hexagon (target/hexagon) instructions with multiple definitionsQuoted 5 lines · Taylor Simpson
Instructions with multiple definitions require special handling because the generator wants to create a helper, but helpers can only return a single result. Therefore, we must override the generated code.
Quoted 13 lines
The following instructions are added
A4_addp_cRdd32 =add(Rss32, Rtt32, Px4):carry
Add with carry
A4_subp_cRdd32 =sub(Rss32, Rtt32, Px4):carry
Sub with carry
A5_ACSRxx32,Pe4 =vacsh(Rss32, Rtt32)
Add compare and select elements of two vectors
A6_vminub_RdPRdd32,Pe4 =vminub(Rtt32, Rss32)
Vector min of bytes
F2_invsqrtaRd32,Pe4 = sfinvsqrta(Rs32)
Square root approx
F2_sfrecipaRd32,Pe4 =sfrecipa(Rs32, Rt32)
Recripocal approx
Quoted 2 lines
One thing at a time. This is no longer port bring-up where large patches are unavoidable.
I can divide this one up into smaller pieces. However, I'll ask for general leniency since I'm still adding scalar core instructions that were withheld from the original series in order to reduce the initial review burden.
Thanks,
Taylor
PATCH 11/15 Hexagon (target/hexagon) circular addressing
In reply to Taylor SimpsonThe following instructions are added
L2_loadrub_pci Rd32 = memub(Rx32++#s4:0:circ(Mu2))
L2_loadrb_pci Rd32 = memb(Rx32++#s4:0:circ(Mu2))
L2_loadruh_pci Rd32 = memuh(Rx32++#s4:1:circ(Mu2))
L2_loadrh_pci Rd32 = memh(Rx32++#s4:1:circ(Mu2))
L2_loadri_pci Rd32 = memw(Rx32++#s4:2:circ(Mu2))
L2_loadrd_pci Rdd32 = memd(Rx32++#s4:3:circ(Mu2))
S2_storerb_pci memb(Rx32++#s4:0:circ(Mu2)) = Rt32
S2_storerh_pci memh(Rx32++#s4:1:circ(Mu2)) = Rt32
S2_storerf_pci memh(Rx32++#s4:1:circ(Mu2)) = Rt.H32
S2_storeri_pci memw(Rx32++#s4:2:circ(Mu2)) = Rt32
S2_storerd_pci memd(Rx32++#s4:3:circ(Mu2)) = Rtt32
S2_storerbnew_pci memb(Rx32++#s4:0:circ(Mu2)) = Nt8.new
S2_storerhnew_pci memw(Rx32++#s4:1:circ(Mu2)) = Nt8.new
S2_storerinew_pci memw(Rx32++#s4:2:circ(Mu2)) = Nt8.new
L2_loadrub_pcr Rd32 = memub(Rx32++I:circ(Mu2))
L2_loadrb_pcr Rd32 = memb(Rx32++I:circ(Mu2))
L2_loadruh_pcr Rd32 = memuh(Rx32++I:circ(Mu2))
L2_loadrh_pcr Rd32 = memh(Rx32++I:circ(Mu2))
L2_loadri_pcr Rd32 = memw(Rx32++I:circ(Mu2))
L2_loadrd_pcr Rdd32 = memd(Rx32++I:circ(Mu2))
S2_storerb_pcr memb(Rx32++I:circ(Mu2)) = Rt32
S2_storerh_pcr memh(Rx32++I:circ(Mu2)) = Rt32
S2_storerf_pcr memh(Rx32++I:circ(Mu2)) = Rt32.H32
S2_storeri_pcr memw(Rx32++I:circ(Mu2)) = Rt32
S2_storerd_pcr memd(Rx32++I:circ(Mu2)) = Rtt32
S2_storerbnew_pcr memb(Rx32++I:circ(Mu2)) = Nt8.new
S2_storerhnew_pcr memh(Rx32++I:circ(Mu2)) = Nt8.new
S2_storerinew_pcr memw(Rx32++I:circ(Mu2)) = Nt8.newTest cases in tests/tcg/hexagon/circ.c
--- target/hexagon/gen_tcg.h | 127 +++++++++++ target/hexagon/genptr.c | 85 ++++++++ target/hexagon/imported/encode_pp.def | 9 + target/hexagon/imported/ldst.idef | 4 + target/hexagon/imported/macros.def | 26 +++ target/hexagon/macros.h | 87 ++++++++ tests/tcg/hexagon/Makefile.target | 1 + tests/tcg/hexagon/circ.c | 393 ++++++++++++++++++++++++++++++++++ 8 files changed, 732 insertions(+) create mode 100644 tests/tcg/hexagon/circ.c
target/hexagon/gen_tcg.h +127 -0
@@ -38,6 +38,8 @@* _ap absolute set r0 = memw(r1=##variable) * _pr post increment register r0 = memw(r1++m1) * _pi post increment immediate r0 = memb(r1++#1) +* _pci post increment circular immediate r0 = memw(r1++#4:circ(m0)) +* _pcr post increment circular register r0 = memw(r1++I:circ(m0)) */ /* Macros for complex addressing modes */
@@ -56,7 +58,28 @@fEA_REG (RxV); \fPM_I (RxV, siV); \ } while (0) +#define GET_EA_pci \ + do { \ + fEA_REG(RxV); \ + fPM_CIRI(RxV, siV, MuV); \ + } while (0) +#define GET_EA_pcr (SHIFT ) \ + do { \ + fEA_REG(RxV); \ + fPM_CIRR(RxV, fREAD_IREG(MuV, (SHIFT)), MuV); \ + } while (0) +/* +* Many instructions will work with just macro redefinitions +* with the caveat that they need a tmp variable to carry a +* value between them. +*/ +#define fGEN_TCG_tmp (SHORTCODE ) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + SHORTCODE; \ + tcg_temp_free(tmp); \ + } while (0)/* Instructions with multiple definitions */ #define fGEN_TCG_LOAD_AP (RES ,SIZE ,SIGN ) \
@@ -80,6 +103,44 @@#define fGEN_TCG_L4_loadrd_ap (SHORTCODE ) \ fGEN_TCG_LOAD_AP(RddV, 8, u) +#define fGEN_TCG_L2_loadrub_pci (SHORTCODE ) \ + fGEN_TCG_tmp(SHORTCODE) +#define fGEN_TCG_L2_loadrb_pci (SHORTCODE ) \ + fGEN_TCG_tmp(SHORTCODE) +#define fGEN_TCG_L2_loadruh_pci (SHORTCODE ) \ + fGEN_TCG_tmp(SHORTCODE) +#define fGEN_TCG_L2_loadrh_pci (SHORTCODE ) \ + fGEN_TCG_tmp(SHORTCODE) +#define fGEN_TCG_L2_loadri_pci (SHORTCODE ) \ + fGEN_TCG_tmp(SHORTCODE) +#define fGEN_TCG_L2_loadrd_pci (SHORTCODE ) \ + fGEN_TCG_tmp(SHORTCODE) + +#define fGEN_TCG_PCR (SHIFT ,LOAD ) \ + do { \ + TCGv ireg = tcg_temp_new(); \ + TCGv tmp = tcg_temp_new(); \ + fEA_REG(RxV); \ + fREAD_IREG(MuV, SHIFT); \ + gen_helper_fcircadd(RxV, RxV, ireg, MuV, fREAD_CSREG(MuN)); \ + LOAD; \ + tcg_temp_free(tmp); \ + tcg_temp_free(ireg); \ + } while (0) + +#define fGEN_TCG_L2_loadrub_pcr (SHORTCODE ) \ + fGEN_TCG_PCR(0, fLOAD(1, 1, u, EA, RdV)) +#define fGEN_TCG_L2_loadrb_pcr (SHORTCODE ) \ + fGEN_TCG_PCR(0, fLOAD(1, 1, s, EA, RdV)) +#define fGEN_TCG_L2_loadruh_pcr (SHORTCODE ) \ + fGEN_TCG_PCR(1, fLOAD(1, 2, u, EA, RdV)) +#define fGEN_TCG_L2_loadrh_pcr (SHORTCODE ) \ + fGEN_TCG_PCR(1, fLOAD(1, 2, s, EA, RdV)) +#define fGEN_TCG_L2_loadri_pcr (SHORTCODE ) \ + fGEN_TCG_PCR(2, fLOAD(1, 4, u, EA, RdV)) +#define fGEN_TCG_L2_loadrd_pcr (SHORTCODE ) \ + fGEN_TCG_PCR(3, fLOAD(1, 8, u, EA, RddV)) +#define fGEN_TCG_L2_loadrub_pr (SHORTCODE ) SHORTCODE#define fGEN_TCG_L2_loadrub_pi (SHORTCODE ) SHORTCODE#define fGEN_TCG_L2_loadrb_pr (SHORTCODE ) SHORTCODE
@@ -195,6 +256,72 @@#define fGEN_TCG_S4_stored_locked (SHORTCODE ) \ do { SHORTCODE; READ_PREG(PdV, PdN); } while (0) +#define fGEN_TCG_STORE (SHORTCODE ) \ + do { \ + TCGv HALF = tcg_temp_new(); \ + TCGv BYTE = tcg_temp_new(); \ + TCGv tmp = tcg_temp_new(); \ + SHORTCODE; \ + tcg_temp_free(HALF); \ + tcg_temp_free(BYTE); \ + tcg_temp_free(tmp); \ + } while (0) + +#define fGEN_TCG_STORE_pcr (SHIFT ,STORE ) \ + do { \ + TCGv ireg = tcg_temp_new(); \ + TCGv HALF = tcg_temp_new(); \ + TCGv BYTE = tcg_temp_new(); \ + TCGv tmp = tcg_temp_new(); \ + fEA_REG(RxV); \ + fPM_CIRR(RxV, fREAD_IREG(MuV, SHIFT), MuV); \ + STORE; \ + tcg_temp_free(ireg); \ + tcg_temp_free(HALF); \ + tcg_temp_free(BYTE); \ + tcg_temp_free(tmp); \ + } while (0) + +#define fGEN_TCG_S2_storerb_pci (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE) +#define fGEN_TCG_S2_storerb_pcr (SHORTCODE ) \ + fGEN_TCG_STORE_pcr(0, fSTORE(1, 1, EA, fGETBYTE(0, RtV))) + +#define fGEN_TCG_S2_storerh_pci (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE) +#define fGEN_TCG_S2_storerh_pcr (SHORTCODE ) \ + fGEN_TCG_STORE_pcr(1, fSTORE(1, 2, EA, fGETHALF(0, RtV))) + +#define fGEN_TCG_S2_storerf_pci (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE) +#define fGEN_TCG_S2_storerf_pcr (SHORTCODE ) \ + fGEN_TCG_STORE_pcr(1, fSTORE(1, 2, EA, fGETHALF(1, RtV))) + +#define fGEN_TCG_S2_storeri_pci (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE) +#define fGEN_TCG_S2_storeri_pcr (SHORTCODE ) \ + fGEN_TCG_STORE_pcr(2, fSTORE(1, 4, EA, RtV)) + +#define fGEN_TCG_S2_storerd_pci (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE) +#define fGEN_TCG_S2_storerd_pcr (SHORTCODE ) \ + fGEN_TCG_STORE_pcr(3, fSTORE(1, 8, EA, RttV)) + +#define fGEN_TCG_S2_storerbnew_pci (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE) +#define fGEN_TCG_S2_storerbnew_pcr (SHORTCODE ) \ + fGEN_TCG_STORE_pcr(0, fSTORE(1, 1, EA, fGETBYTE(0, NtN))) + +#define fGEN_TCG_S2_storerhnew_pci (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE) +#define fGEN_TCG_S2_storerhnew_pcr (SHORTCODE ) \ + fGEN_TCG_STORE_pcr(1, fSTORE(1, 2, EA, fGETHALF(0, NtN))) + +#define fGEN_TCG_S2_storerinew_pci (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE) +#define fGEN_TCG_S2_storerinew_pcr (SHORTCODE ) \ + fGEN_TCG_STORE_pcr(2, fSTORE(1, 4, EA, NtN)) +/* * Mathematical operations with more than one definition require * special handling
target/hexagon/genptr.c +85 -0
103 lines not on this page · raw message
target/hexagon/imported/encode_pp.def +9 -0
@@ -294,6 +294,7 @@ DEF_CLASS32(ICLASS_LD" ---- -------- PP------ --------",LD) DEF_CLASS32(ICLASS_LD" 0--- -------- PP------ --------",LD_ADDR_ROFFSET) +DEF_CLASS32(ICLASS_LD" 100- -------- PP----0- --------",LD_ADDR_POST_CIRC_IMMED) DEF_CLASS32(ICLASS_LD" 101- -------- PP00---- --------",LD_ADDR_POST_IMMED) DEF_CLASS32(ICLASS_LD" 101- -------- PP01---- --------",LD_ADDR_ABS_UPDATE_V4) DEF_CLASS32(ICLASS_LD" 101- -------- PP1----- --------",LD_ADDR_POST_IMMED_PRED_V2)
@@ -308,18 +309,22 @@ DEF_FIELD32(ICLASS_LD" ---- --!----- PP------ --------",LD_UN,"Unsigned") #define STD_LD_ENC(TAG,OPC) \ DEF_ENC32(L2_load##TAG##_io, ICLASS_LD" 0 ii "OPC" sssss PPiiiiii iiiddddd")\ +DEF_ENC32(L2_load##TAG##_pci, ICLASS_LD" 1 00 "OPC" xxxxx PPu0--0i iiiddddd")\ DEF_ENC32(L2_load##TAG##_pi, ICLASS_LD" 1 01 "OPC" xxxxx PP00---i iiiddddd")\ DEF_ENC32(L4_load##TAG##_ap, ICLASS_LD" 1 01 "OPC" eeeee PP01IIII -IIddddd")\ DEF_ENC32(L2_load##TAG##_pr, ICLASS_LD" 1 10 "OPC" xxxxx PPu0---- 0--ddddd")\ DEF_ENC32(L4_load##TAG##_ur, ICLASS_LD" 1 10 "OPC" ttttt PPi1IIII iIIddddd")\ +DEF_ENC32(L2_load##TAG##_pcr, ICLASS_LD" 1 00 "OPC" xxxxx PPu0--1- 0--ddddd")\ #define STD_LDX_ENC(TAG,OPC) \ DEF_ENC32(L2_load##TAG##_io, ICLASS_LD" 0 ii "OPC" sssss PPiiiiii iiiyyyyy")\ +DEF_ENC32(L2_load##TAG##_pci, ICLASS_LD" 1 00 "OPC" xxxxx PPu0--0i iiiyyyyy")\ DEF_ENC32(L2_load##TAG##_pi, ICLASS_LD" 1 01 "OPC" xxxxx PP00---i iiiyyyyy")\ DEF_ENC32(L4_load##TAG##_ap, ICLASS_LD" 1 01 "OPC" eeeee PP01IIII -IIyyyyy")\ DEF_ENC32(L2_load##TAG##_pr, ICLASS_LD" 1 10 "OPC" xxxxx PPu0---- 0--yyyyy")\ DEF_ENC32(L4_load##TAG##_ur, ICLASS_LD" 1 10 "OPC" ttttt PPi1IIII iIIyyyyy")\ +DEF_ENC32(L2_load##TAG##_pcr, ICLASS_LD" 1 00 "OPC" xxxxx PPu0--1- 0--yyyyy")\ #define STD_PLD_ENC(TAG,OPC) \
@@ -351,6 +356,7 @@ STD_PLD_ENC(rd, "1 110") /* note dest reg field LSB=0, 1 is reserved */ DEF_CLASS32( ICLASS_LD" 0--0 000----- PP------ --------",LD_MISC) DEF_ANTICLASS32(ICLASS_LD" 0--0 000----- PP------ --------",LD_ADDR_ROFFSET) +DEF_ANTICLASS32(ICLASS_LD" 1000 000----- PP------ --------",LD_ADDR_POST_CIRC_IMMED) DEF_ANTICLASS32(ICLASS_LD" 1010 000----- PP------ --------",LD_ADDR_POST_IMMED) DEF_ANTICLASS32(ICLASS_LD" 1100 000----- PP------ --------",LD_ADDR_POST_REG) DEF_ANTICLASS32(ICLASS_LD" 1110 000----- PP------ --------",LD_ADDR_POST_REG)
@@ -397,6 +403,7 @@ DEF_FIELD32(ICLASS_ST" ---! !!------ PP------ --------",ST_Type,"Type") DEF_FIELD32(ICLASS_ST" ---- --!----- PP------ --------",ST_UN,"Unsigned") DEF_CLASS32(ICLASS_ST" 0--1 -------- PP------ --------",ST_ADDR_ROFFSET) +DEF_CLASS32(ICLASS_ST" 1001 -------- PP------ ------0-",ST_ADDR_POST_CIRC_IMMED) DEF_CLASS32(ICLASS_ST" 1011 -------- PP0----- 0-----0-",ST_ADDR_POST_IMMED) DEF_CLASS32(ICLASS_ST" 1011 -------- PP0----- 1-------",ST_ADDR_ABS_UPDATE_V4) DEF_CLASS32(ICLASS_ST" 1011 -------- PP1----- --------",ST_ADDR_POST_IMMED_PRED_V2)
@@ -411,10 +418,12 @@ DEF_CLASS32(ICLASS_ST" 0--0 0------- PP------ --------",ST_MISC_CACHEOP) #define STD_ST_ENC(TAG,OPC,SRC) \ DEF_ENC32(S2_store##TAG##_io, ICLASS_ST" 0 ii "OPC" sssss PPi"SRC" iiiiiiii")\ +DEF_ENC32(S2_store##TAG##_pci, ICLASS_ST" 1 00 "OPC" xxxxx PPu"SRC" 0iiii-0-")\ DEF_ENC32(S2_store##TAG##_pi, ICLASS_ST" 1 01 "OPC" xxxxx PP0"SRC" 0iiii-0-")\ DEF_ENC32(S4_store##TAG##_ap, ICLASS_ST" 1 01 "OPC" eeeee PP0"SRC" 1-IIIIII")\ DEF_ENC32(S2_store##TAG##_pr, ICLASS_ST" 1 10 "OPC" xxxxx PPu"SRC" 0-------")\ DEF_ENC32(S4_store##TAG##_ur, ICLASS_ST" 1 10 "OPC" uuuuu PPi"SRC" 1iIIIIII")\ +DEF_ENC32(S2_store##TAG##_pcr, ICLASS_ST" 1 00 "OPC" xxxxx PPu"SRC" 0-----1-")\ #define STD_PST_ENC(TAG,OPC,SRC) \
target/hexagon/imported/ldst.idef +4 -0
@@ -26,6 +26,8 @@ Q6INSN(L4_##TAG##_ur, OPER"(Rt32<<#u2+#U6)", ATTRIB,DESCR,{fMUST_IM Q6INSN(L4_##TAG##_ap, OPER"(Re32=#U6)", ATTRIB,DESCR,{fMUST_IMMEXT(UiV); fEA_IMM(UiV); SEMANTICS; ReV=UiV; })\ Q6INSN(L2_##TAG##_pr, OPER"(Rx32++Mu2)", ATTRIB,DESCR,{fEA_REG(RxV); fPM_M(RxV,MuV); SEMANTICS;})\ Q6INSN(L2_##TAG##_pi, OPER"(Rx32++#s4:"SHFT")", ATTRIB,DESCR,{fEA_REG(RxV); fPM_I(RxV,siV); SEMANTICS;})\ +Q6INSN(L2_##TAG##_pci, OPER"(Rx32++#s4:"SHFT":circ(Mu2))",ATTRIB,DESCR,{fEA_REG(RxV); fPM_CIRI(RxV,siV,MuV); SEMANTICS;})\ +Q6INSN(L2_##TAG##_pcr, OPER"(Rx32++I:circ(Mu2))", ATTRIB,DESCR,{fEA_REG(RxV); fPM_CIRR(RxV,fREAD_IREG(MuV)<<SCALE,MuV); SEMANTICS;}) /* The set of 32-bit load instructions */ STD_LD_AMODES(loadrub,"Rd32=memub","Load Unsigned Byte",ATTRIBS(A_LOAD),"0",fLOAD(1,1,u,EA,RdV),0)
@@ -42,6 +44,8 @@ Q6INSN(S2_##TAG##_pi, OPER"(Rx32++#s4:"SHFT")="DEST, ATTRIB,DESCR,{fEA_REG( Q6INSN(S4_##TAG##_ap, OPER"(Re32=#U6)="DEST, ATTRIB,DESCR,{fMUST_IMMEXT(UiV); fEA_IMM(UiV); SEMANTICS; ReV=UiV; })\ Q6INSN(S2_##TAG##_pr, OPER"(Rx32++Mu2)="DEST, ATTRIB,DESCR,{fEA_REG(RxV); fPM_M(RxV,MuV); SEMANTICS; })\ Q6INSN(S4_##TAG##_ur, OPER"(Ru32<<#u2+#U6)="DEST, ATTRIB,DESCR,{fMUST_IMMEXT(UiV); fEA_IRs(UiV,RuV,uiV); SEMANTICS;})\ +Q6INSN(S2_##TAG##_pci, OPER"(Rx32++#s4:"SHFT":circ(Mu2))="DEST, ATTRIB,DESCR,{fEA_REG(RxV); fPM_CIRI(RxV,siV,MuV); SEMANTICS;})\ +Q6INSN(S2_##TAG##_pcr, OPER"(Rx32++I:circ(Mu2))="DEST, ATTRIB,DESCR,{fEA_REG(RxV); fPM_CIRR(RxV,fREAD_IREG(MuV)<<SCALE,MuV); SEMANTICS;}) /* The set of 32-bit store instructions */
target/hexagon/imported/macros.def +26 -0
@@ -277,6 +277,12 @@ DEF_MACRO( /*************************************/ DEF_MACRO( + fREAD_IREG, /* read modifier register */ + (fSXTN(11,64,(((VAL) & 0xf0000000)>>21) | ((VAL>>17)&0x7f) )), /* behavior */ + () +) + +DEF_MACRO( fREAD_LR, /* read link register */ (READ_RREG(REG_LR)), /* behavior */ ()
@@ -307,6 +313,12 @@ DEF_MACRO( ) DEF_MACRO( + fREAD_CSREG, /* read CS register */ + (READ_RREG(REG_CSA+N)), /* behavior */ + () +) + +DEF_MACRO( fREAD_LC0, /* read loop count */ (READ_RREG(REG_LC0)), /* behavior */ ()
@@ -825,6 +837,20 @@ DEF_MACRO( ) DEF_MACRO( + fPM_CIRI, /* Post Modify Register using Circular arithmetic by Immediate */ + do { fcirc_add(REG,siV,MuV); } while (0), + () +) + +DEF_MACRO( + fPM_CIRR, /* Post Modify Register using Circular arithmetic by register */ + do { fcirc_add(REG,VAL,MuV); } while (0), + () +) + + + +DEF_MACRO( fSCALE, /* scale by N */ (((size8s_t)(A))<<N), /* optional attributes */
target/hexagon/macros.h +87 -0
132 lines not on this page · raw message
tests/tcg/hexagon/Makefile.target +1 -0
@@ -41,6 +41,7 @@ HEX_TESTS += preg_alias HEX_TESTS += dual_stores HEX_TESTS += multi_result HEX_TESTS += mem_noshuf +HEX_TESTS += circ HEX_TESTS += atomics HEX_TESTS += fpstuff
tests/tcg/hexagon/circ.c new file +393 -0
393 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH 11/15] Hexagon (target/hexagon) circular addressing
target/hexagon/gen_tcg.h line 82
Quoted 11 lines · Taylor Simpson
target/hexagon/gen_tcg.h +11
-0+/* +* Many instructions will work with just macro redefinitions +* with the caveat that they need a tmp variable to carry a +* value between them. +*/ +#define fGEN_TCG_tmp (SHORTCODE ) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + SHORTCODE; \ + tcg_temp_free(tmp); \ + } while (0)
Wow, this is awfully magical. I don't even see "tmp" referenced in the SHORTCODE. What's going on here?
r~
RE: [PATCH 11/15] Hexagon (target/hexagon) circular addressing
Quoted 10 lines
-----Original Message-----
From: Richard Henderson <[email protected]>
Sent: Thursday, March 25, 2021 11:34 AM
To: Taylor Simpson <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Brian Cain <[email protected]>
Subject: Re: [PATCH 11/15] Hexagon (target/hexagon) circular addressingOn 3/24/21 8:50 PM, Taylor Simpson wrote:
Quoted 14 lines
target/hexagon/gen_tcg.h line 82
Quoted 11 lines
target/hexagon/gen_tcg.h +11
-0+/* +* Many instructions will work with just macro redefinitions +* with the caveat that they need a tmp variable to carry a +* value between them. +*/ +#define fGEN_TCG_tmp (SHORTCODE ) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + SHORTCODE; \ + tcg_temp_free(tmp); \ + } while (0)Wow, this is awfully magical. I don't even see "tmp" referenced in the SHORTCODE. What's going on here?
Here's an example:L2_loadrub_pci
Semantics:{fEA_REG(RxV); fPM_CIRI(RxV,siV,MuV); fLOAD(1,1,u,EA,RdV);}
The need for tmp is inside the fPM_CIRI macro
#define fPM_CIRI(REG, IMM, MVAL) \
do { \
TCGv tcgv_siV = tcg_const_tl(siV); \
gen_helper_fcircadd(REG, REG, tcgv_siV, MuV, fREAD_CSREG(MuN)); \
tcg_temp_free(tcgv_siV); \
} while (0)Notice the use of fREAD_CSREG
#define fREAD_CSREG(N) (READ_REG(tmp, HEX_REG_CS0 + N))
So, we're using tmp to carry the value read from the CS reg to the gen_helper_fcircadd call.
I'll go ahead and move the create/free tmp inside the fPM_CIRI macro.
Thanks,
Taylor
PATCH 12/15 Hexagon (target/hexagon) bit reverse (brev) addressing
In reply to Taylor SimpsonThe following instructions are added
L2_loadrub_pbr Rd32 = memub(Rx32++Mu2:brev)
L2_loadrb_pbr Rd32 = memb(Rx32++Mu2:brev)
L2_loadruh_pbr Rd32 = memuh(Rx32++Mu2:brev)
L2_loadrh_pbr Rd32 = memh(Rx32++Mu2:brev)
L2_loadri_pbr Rd32 = memw(Rx32++Mu2:brev)
L2_loadrd_pbr Rdd32 = memd(Rx32++Mu2:brev)
S2_storerb_pbr memb(Rx32++Mu2:brev).=.Rt32
S2_storerh_pbr memh(Rx32++Mu2:brev).=.Rt32
S2_storerf_pbr memh(Rx32++Mu2:brev).=.Rt.H32
S2_storeri_pbr memw(Rx32++Mu2:brev).=.Rt32
S2_storerd_pbr memd(Rx32++Mu2:brev).=.Rt32
S2_storerinew_pbr memw(Rx32++Mu2:brev).=.Nt8.new
S2_storerbnew_pbr memw(Rx32++Mu2:brev).=.Nt8.new
S2_storerhnew_pbr memw(Rx32++Mu2:brev).=.Nt8.newTest cases in tests/tcg/hexagon/brev.c
--- target/hexagon/gen_tcg.h | 28 +++++ target/hexagon/imported/encode_pp.def | 5 + target/hexagon/imported/ldst.idef | 2 + target/hexagon/imported/macros.def | 6 ++ target/hexagon/macros.h | 15 +++ tests/tcg/hexagon/Makefile.target | 1 + tests/tcg/hexagon/brev.c | 185 ++++++++++++++++++++++++++++++++++ 7 files changed, 242 insertions(+) create mode 100644 tests/tcg/hexagon/brev.c
target/hexagon/gen_tcg.h +28 -0
@@ -37,6 +37,7 @@* _sp stack pointer relative r0 = memw(r29+#12) * _ap absolute set r0 = memw(r1=##variable) * _pr post increment register r0 = memw(r1++m1) +* _pbr post increment bit reverse r0 = memw(r1++m1:brev) * _pi post increment immediate r0 = memb(r1++#1) * _pci post increment circular immediate r0 = memw(r1++#4:circ(m0)) * _pcr post increment circular register r0 = memw(r1++I:circ(m0))
@@ -53,6 +54,11 @@fEA_REG (RxV); \fPM_M (RxV, MuV); \ } while (0) +#define GET_EA_pbr \ + do { \ + fEA_BREVR(RxV); \ + fPM_M(RxV, MuV); \ + } while (0)#define GET_EA_pi \ do { \ fEA_REG(RxV); \
@@ -142,16 +148,22 @@ fGEN_TCG_PCR(3, fLOAD(1, 8, u, EA, RddV))#define fGEN_TCG_L2_loadrub_pr (SHORTCODE ) SHORTCODE +#define fGEN_TCG_L2_loadrub_pbr (SHORTCODE ) SHORTCODE#define fGEN_TCG_L2_loadrub_pi (SHORTCODE ) SHORTCODE#define fGEN_TCG_L2_loadrb_pr (SHORTCODE ) SHORTCODE +#define fGEN_TCG_L2_loadrb_pbr (SHORTCODE ) SHORTCODE#define fGEN_TCG_L2_loadrb_pi (SHORTCODE ) SHORTCODE#define fGEN_TCG_L2_loadruh_pr (SHORTCODE ) SHORTCODE +#define fGEN_TCG_L2_loadruh_pbr (SHORTCODE ) SHORTCODE#define fGEN_TCG_L2_loadruh_pi (SHORTCODE ) SHORTCODE#define fGEN_TCG_L2_loadrh_pr (SHORTCODE ) SHORTCODE +#define fGEN_TCG_L2_loadrh_pbr (SHORTCODE ) SHORTCODE#define fGEN_TCG_L2_loadrh_pi (SHORTCODE ) SHORTCODE#define fGEN_TCG_L2_loadri_pr (SHORTCODE ) SHORTCODE +#define fGEN_TCG_L2_loadri_pbr (SHORTCODE ) SHORTCODE#define fGEN_TCG_L2_loadri_pi (SHORTCODE ) SHORTCODE#define fGEN_TCG_L2_loadrd_pr (SHORTCODE ) SHORTCODE +#define fGEN_TCG_L2_loadrd_pbr (SHORTCODE ) SHORTCODE#define fGEN_TCG_L2_loadrd_pi (SHORTCODE ) SHORTCODE/*
@@ -282,41 +294,57 @@tcg_temp_free (tmp); \ } while (0) +#define fGEN_TCG_S2_storerb_pbr (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storerb_pci (SHORTCODE ) \ fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storerb_pcr (SHORTCODE ) \ fGEN_TCG_STORE_pcr(0, fSTORE(1, 1, EA, fGETBYTE(0, RtV))) +#define fGEN_TCG_S2_storerh_pbr (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storerh_pci (SHORTCODE ) \ fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storerh_pcr (SHORTCODE ) \ fGEN_TCG_STORE_pcr(1, fSTORE(1, 2, EA, fGETHALF(0, RtV))) +#define fGEN_TCG_S2_storerf_pbr (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storerf_pci (SHORTCODE ) \ fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storerf_pcr (SHORTCODE ) \ fGEN_TCG_STORE_pcr(1, fSTORE(1, 2, EA, fGETHALF(1, RtV))) +#define fGEN_TCG_S2_storeri_pbr (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storeri_pci (SHORTCODE ) \ fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storeri_pcr (SHORTCODE ) \ fGEN_TCG_STORE_pcr(2, fSTORE(1, 4, EA, RtV)) +#define fGEN_TCG_S2_storerd_pbr (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storerd_pci (SHORTCODE ) \ fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storerd_pcr (SHORTCODE ) \ fGEN_TCG_STORE_pcr(3, fSTORE(1, 8, EA, RttV)) +#define fGEN_TCG_S2_storerbnew_pbr (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storerbnew_pci (SHORTCODE ) \ fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storerbnew_pcr (SHORTCODE ) \ fGEN_TCG_STORE_pcr(0, fSTORE(1, 1, EA, fGETBYTE(0, NtN))) +#define fGEN_TCG_S2_storerhnew_pbr (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storerhnew_pci (SHORTCODE ) \ fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storerhnew_pcr (SHORTCODE ) \ fGEN_TCG_STORE_pcr(1, fSTORE(1, 2, EA, fGETHALF(0, NtN))) +#define fGEN_TCG_S2_storerinew_pbr (SHORTCODE ) \ + fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storerinew_pci (SHORTCODE ) \ fGEN_TCG_STORE(SHORTCODE)#define fGEN_TCG_S2_storerinew_pcr (SHORTCODE ) \
target/hexagon/imported/encode_pp.def +5 -0
@@ -301,6 +301,7 @@ DEF_CLASS32(ICLASS_LD" 101- -------- PP1----- --------",LD_ADDR_POST_IMMED_PRED_ DEF_CLASS32(ICLASS_LD" 110- -------- PP-0---- 0-------",LD_ADDR_POST_REG) DEF_CLASS32(ICLASS_LD" 110- -------- PP-1---- --------",LD_ADDR_ABS_PLUS_REG_V4) DEF_CLASS32(ICLASS_LD" 100- -------- PP----1- --------",LD_ADDR_POST_CREG_V2) +DEF_CLASS32(ICLASS_LD" 111- -------- PP------ 0-------",LD_ADDR_POST_BREV_REG) DEF_CLASS32(ICLASS_LD" 111- -------- PP------ 1-------",LD_ADDR_PRED_ABS_V4) DEF_FIELD32(ICLASS_LD" !!!- -------- PP------ --------",LD_Amode,"Amode")
@@ -315,6 +316,7 @@ DEF_ENC32(L4_load##TAG##_ap, ICLASS_LD" 1 01 "OPC" eeeee PP01IIII -IIddddd" DEF_ENC32(L2_load##TAG##_pr, ICLASS_LD" 1 10 "OPC" xxxxx PPu0---- 0--ddddd")\ DEF_ENC32(L4_load##TAG##_ur, ICLASS_LD" 1 10 "OPC" ttttt PPi1IIII iIIddddd")\ DEF_ENC32(L2_load##TAG##_pcr, ICLASS_LD" 1 00 "OPC" xxxxx PPu0--1- 0--ddddd")\ +DEF_ENC32(L2_load##TAG##_pbr, ICLASS_LD" 1 11 "OPC" xxxxx PPu0---- 0--ddddd") #define STD_LDX_ENC(TAG,OPC) \
@@ -325,6 +327,7 @@ DEF_ENC32(L4_load##TAG##_ap, ICLASS_LD" 1 01 "OPC" eeeee PP01IIII -IIyyyyy" DEF_ENC32(L2_load##TAG##_pr, ICLASS_LD" 1 10 "OPC" xxxxx PPu0---- 0--yyyyy")\ DEF_ENC32(L4_load##TAG##_ur, ICLASS_LD" 1 10 "OPC" ttttt PPi1IIII iIIyyyyy")\ DEF_ENC32(L2_load##TAG##_pcr, ICLASS_LD" 1 00 "OPC" xxxxx PPu0--1- 0--yyyyy")\ +DEF_ENC32(L2_load##TAG##_pbr, ICLASS_LD" 1 11 "OPC" xxxxx PPu0---- 0--yyyyy") #define STD_PLD_ENC(TAG,OPC) \
@@ -411,6 +414,7 @@ DEF_CLASS32(ICLASS_ST" 1111 -------- PP------ 1-------",ST_ADDR_PRED_ABS_V4) DEF_CLASS32(ICLASS_ST" 1101 -------- PP------ 0-------",ST_ADDR_POST_REG) DEF_CLASS32(ICLASS_ST" 1101 -------- PP------ 1-------",ST_ADDR_ABS_PLUS_REG_V4) DEF_CLASS32(ICLASS_ST" 1001 -------- PP------ ------1-",ST_ADDR_POST_CREG_V2) +DEF_CLASS32(ICLASS_ST" 1111 -------- PP------ 0-------",ST_ADDR_POST_BREV_REG) DEF_CLASS32(ICLASS_ST" 0--0 1------- PP------ --------",ST_MISC_STORELIKE) DEF_CLASS32(ICLASS_ST" 1--0 0------- PP------ --------",ST_MISC_BUSOP) DEF_CLASS32(ICLASS_ST" 0--0 0------- PP------ --------",ST_MISC_CACHEOP)
@@ -424,6 +428,7 @@ DEF_ENC32(S4_store##TAG##_ap, ICLASS_ST" 1 01 "OPC" eeeee PP0"SRC" 1-IIIIII DEF_ENC32(S2_store##TAG##_pr, ICLASS_ST" 1 10 "OPC" xxxxx PPu"SRC" 0-------")\ DEF_ENC32(S4_store##TAG##_ur, ICLASS_ST" 1 10 "OPC" uuuuu PPi"SRC" 1iIIIIII")\ DEF_ENC32(S2_store##TAG##_pcr, ICLASS_ST" 1 00 "OPC" xxxxx PPu"SRC" 0-----1-")\ +DEF_ENC32(S2_store##TAG##_pbr, ICLASS_ST" 1 11 "OPC" xxxxx PPu"SRC" 0-------") #define STD_PST_ENC(TAG,OPC,SRC) \
target/hexagon/imported/ldst.idef +2 -0
@@ -25,6 +25,7 @@ Q6INSN(L2_##TAG##_io, OPER"(Rs32+#s11:"SHFT")", ATTRIB,DESCR,{fIMMEXT( Q6INSN(L4_##TAG##_ur, OPER"(Rt32<<#u2+#U6)", ATTRIB,DESCR,{fMUST_IMMEXT(UiV); fEA_IRs(UiV,RtV,uiV); SEMANTICS;})\ Q6INSN(L4_##TAG##_ap, OPER"(Re32=#U6)", ATTRIB,DESCR,{fMUST_IMMEXT(UiV); fEA_IMM(UiV); SEMANTICS; ReV=UiV; })\ Q6INSN(L2_##TAG##_pr, OPER"(Rx32++Mu2)", ATTRIB,DESCR,{fEA_REG(RxV); fPM_M(RxV,MuV); SEMANTICS;})\ +Q6INSN(L2_##TAG##_pbr, OPER"(Rx32++Mu2:brev)", ATTRIB,DESCR,{fEA_BREVR(RxV); fPM_M(RxV,MuV); SEMANTICS;})\ Q6INSN(L2_##TAG##_pi, OPER"(Rx32++#s4:"SHFT")", ATTRIB,DESCR,{fEA_REG(RxV); fPM_I(RxV,siV); SEMANTICS;})\ Q6INSN(L2_##TAG##_pci, OPER"(Rx32++#s4:"SHFT":circ(Mu2))",ATTRIB,DESCR,{fEA_REG(RxV); fPM_CIRI(RxV,siV,MuV); SEMANTICS;})\ Q6INSN(L2_##TAG##_pcr, OPER"(Rx32++I:circ(Mu2))", ATTRIB,DESCR,{fEA_REG(RxV); fPM_CIRR(RxV,fREAD_IREG(MuV)<<SCALE,MuV); SEMANTICS;})
@@ -44,6 +45,7 @@ Q6INSN(S2_##TAG##_pi, OPER"(Rx32++#s4:"SHFT")="DEST, ATTRIB,DESCR,{fEA_REG( Q6INSN(S4_##TAG##_ap, OPER"(Re32=#U6)="DEST, ATTRIB,DESCR,{fMUST_IMMEXT(UiV); fEA_IMM(UiV); SEMANTICS; ReV=UiV; })\ Q6INSN(S2_##TAG##_pr, OPER"(Rx32++Mu2)="DEST, ATTRIB,DESCR,{fEA_REG(RxV); fPM_M(RxV,MuV); SEMANTICS; })\ Q6INSN(S4_##TAG##_ur, OPER"(Ru32<<#u2+#U6)="DEST, ATTRIB,DESCR,{fMUST_IMMEXT(UiV); fEA_IRs(UiV,RuV,uiV); SEMANTICS;})\ +Q6INSN(S2_##TAG##_pbr, OPER"(Rx32++Mu2:brev)="DEST, ATTRIB,DESCR,{fEA_BREVR(RxV); fPM_M(RxV,MuV); SEMANTICS; })\ Q6INSN(S2_##TAG##_pci, OPER"(Rx32++#s4:"SHFT":circ(Mu2))="DEST, ATTRIB,DESCR,{fEA_REG(RxV); fPM_CIRI(RxV,siV,MuV); SEMANTICS;})\ Q6INSN(S2_##TAG##_pcr, OPER"(Rx32++I:circ(Mu2))="DEST, ATTRIB,DESCR,{fEA_REG(RxV); fPM_CIRR(RxV,fREAD_IREG(MuV)<<SCALE,MuV); SEMANTICS;})
target/hexagon/imported/macros.def +6 -0
@@ -819,6 +819,12 @@ DEF_MACRO( ) DEF_MACRO( + fEA_BREVR, /* Calculate EA with bit reversed bottom of REGISTER */ + EA=fbrev(REG), + () +) + +DEF_MACRO( fEA_GPI, /* Calculate EA with Global Poitner + Immediate */ do { EA=fREAD_GP()+IMM; fGP_DOCHKPAGECROSS(fREAD_GP(),EA); } while (0), ()
target/hexagon/macros.h +15 -0
@@ -493,6 +493,21 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift)#ifdef QEMU_GENERATE #define fEA_IMM (IMM ) tcg_gen_movi_tl(EA, IMM)#define fEA_REG (REG ) tcg_gen_mov_tl(EA, REG) +static inline void gen_fbrev (TCGv result,TCGv src) +{ +/* +* Bit reverse the low 16 bits of the address +*/ +TCGv tmp =tcg_temp_new (); +tcg_gen_andi_tl (result, src,0xffff0000 ); +for (int i =0 ; i <16 ; i++) { +tcg_gen_extract_tl (tmp, src, i,1 ); +tcg_gen_deposit_tl (result, result, tmp,15 - i,1 ); + } +tcg_temp_free (tmp); +} + +#define fEA_BREVR (REG ) gen_fbrev(EA, REG)#define fPM_I (REG ,IMM ) tcg_gen_addi_tl(REG, REG, IMM)#define fPM_M (REG ,MVAL ) tcg_gen_add_tl(REG, REG, MVAL)#define fPM_CIRI (REG ,IMM ,MVAL ) \
tests/tcg/hexagon/Makefile.target +1 -0
@@ -42,6 +42,7 @@ HEX_TESTS += dual_stores HEX_TESTS += multi_result HEX_TESTS += mem_noshuf HEX_TESTS += circ +HEX_TESTS += brev HEX_TESTS += atomics HEX_TESTS += fpstuff
tests/tcg/hexagon/brev.c new file +185 -0
185 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH 12/15] Hexagon (target/hexagon) bit reverse (brev) addressing
target/hexagon/macros.h static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift) · line 508
Quoted 13 lines · Taylor Simpson
target/hexagon/macros.h +13
-0+static inline void gen_fbrev (TCGv result,TCGv src) +{ +/* +* Bit reverse the low 16 bits of the address +*/ +TCGv tmp =tcg_temp_new (); +tcg_gen_andi_tl (result, src,0xffff0000 ); +for (int i =0 ; i <16 ; i++) { +tcg_gen_extract_tl (tmp, src, i,1 ); +tcg_gen_deposit_tl (result, result, tmp,15 - i,1 ); + } +tcg_temp_free (tmp); +}
This is very sub-optimal. Coordinate with rev.ng, who added this as well. But even there my suggestion was
uint32_t helper_fbrev(uint32_t x)
{
return deposit32(x, 0, 16, revbit16(x));
}because this operation is fairly large in tcg ops.
r~
PATCH 13/15 Hexagon (target/hexagon) load and unpack bytes instructions
In reply to Taylor SimpsonThe following instructions are added
L2_loadbzw2_io Rd32 = memubh(Rs32+#s11:1)
L2_loadbzw4_io Rdd32 = memubh(Rs32+#s11:1)
L2_loadbsw2_io Rd32 = membh(Rs32+#s11:1)
L2_loadbsw4_io Rdd32 = membh(Rs32+#s11:1) L4_loadbzw2_ur Rd32 = memubh(Rt32<<#u2+#U6)
L4_loadbzw4_ur Rdd32 = memubh(Rt32<<#u2+#U6)
L4_loadbsw2_ur Rd32 = membh(Rt32<<#u2+#U6)
L4_loadbsw4_ur Rdd32 = membh(Rt32<<#u2+#U6) L4_loadbzw2_ap Rd32 = memubh(Re32=#U6)
L4_loadbzw4_ap Rdd32 = memubh(Re32=#U6)
L4_loadbsw2_ap Rd32 = membh(Re32=#U6)
L4_loadbsw4_ap Rdd32 = membh(Re32=#U6) L2_loadbzw2_pr Rd32 = memubh(Rx32++Mu2)
L2_loadbzw4_pr Rdd32 = memubh(Rx32++Mu2)
L2_loadbsw2_pr Rd32 = membh(Rx32++Mu2)
L2_loadbsw4_pr Rdd32 = membh(Rx32++Mu2) L2_loadbzw2_pbr Rd32 = memubh(Rx32++Mu2:brev)
L2_loadbzw4_pbr Rdd32 = memubh(Rx32++Mu2:brev)
L2_loadbsw2_pbr Rd32 = membh(Rx32++Mu2:brev)
L2_loadbsw4_pbr Rdd32 = membh(Rx32++Mu2:brev) L2_loadbzw2_pi Rd32 = memubh(Rx32++#s4:1)
L2_loadbzw4_pi Rdd32 = memubh(Rx32++#s4:1)
L2_loadbsw2_pi Rd32 = membh(Rx32++#s4:1)
L2_loadbsw4_pi Rdd32 = membh(Rx32++#s4:1) L2_loadbzw2_pci Rd32 = memubh(Rx32++#s4:1:circ(Mu2))
L2_loadbzw4_pci Rdd32 = memubh(Rx32++#s4:1:circ(Mu2))
L2_loadbsw2_pci Rd32 = membh(Rx32++#s4:1:circ(Mu2))
L2_loadbsw4_pci Rdd32 = membh(Rx32++#s4:1:circ(Mu2)) L2_loadbzw2_pcr Rd32 = memubh(Rx32++I:circ(Mu2))
L2_loadbzw4_pcr Rdd32 = memubh(Rx32++I:circ(Mu2))
L2_loadbsw2_pcr Rd32 = membh(Rx32++I:circ(Mu2))
L2_loadbsw4_pcr Rdd32 = membh(Rx32++I:circ(Mu2))Test cases in tests/tcg/hexagon/load_unpack.c
--- target/hexagon/gen_tcg.h | 118 +++++++++ target/hexagon/genptr.c | 13 + target/hexagon/imported/encode_pp.def | 6 + target/hexagon/imported/ldst.idef | 43 +++ target/hexagon/macros.h | 27 +- tests/tcg/hexagon/Makefile.target | 1 + tests/tcg/hexagon/load_unpack.c | 474 ++++++++++++++++++++++++++++++++++ 7 files changed, 681 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/hexagon/load_unpack.c
target/hexagon/gen_tcg.h +118 -0
@@ -167,6 +167,124 @@#define fGEN_TCG_L2_loadrd_pi (SHORTCODE ) SHORTCODE/* +* These instructions load 2 bytes and places them in +* two halves of the destination register. +* The GET_EA macro determines the addressing mode. +* The fGB macro determines whether to zero-extend or +* sign-extend. +*/ +#define fGEN_TCG_loadbXw2 (GET_EA , fGB) \ + do { \ + TCGv ireg = tcg_temp_new(); \ + TCGv tmp = tcg_temp_new(); \ + TCGv tmpV = tcg_temp_new(); \ + TCGv BYTE = tcg_temp_new(); \ + int i; \ + GET_EA; \ + fLOAD(1, 2, u, EA, tmpV); \ + tcg_gen_movi_tl(RdV, 0); \ + for (i = 0; i < 2; i++) { \ + fSETHALF(i, RdV, fGB(i, tmpV)); \ + } \ + tcg_temp_free(ireg); \ + tcg_temp_free(tmp); \ + tcg_temp_free(tmpV); \ + tcg_temp_free(BYTE); \ + } while (0) + +#define fGEN_TCG_L2_loadbzw2_io (SHORTCODE ) \ + fGEN_TCG_loadbXw2(fEA_RI(RsV, siV), fGETUBYTE) +#define fGEN_TCG_L4_loadbzw2_ur (SHORTCODE ) \ + fGEN_TCG_loadbXw2(fEA_IRs(UiV, RtV, uiV), fGETUBYTE) +#define fGEN_TCG_L2_loadbsw2_io (SHORTCODE ) \ + fGEN_TCG_loadbXw2(fEA_RI(RsV, siV), fGETBYTE) +#define fGEN_TCG_L4_loadbsw2_ur (SHORTCODE ) \ + fGEN_TCG_loadbXw2(fEA_IRs(UiV, RtV, uiV), fGETBYTE) +#define fGEN_TCG_L4_loadbzw2_ap (SHORTCODE ) \ + fGEN_TCG_loadbXw2(GET_EA_ap, fGETUBYTE) +#define fGEN_TCG_L2_loadbzw2_pr (SHORTCODE ) \ + fGEN_TCG_loadbXw2(GET_EA_pr, fGETUBYTE) +#define fGEN_TCG_L2_loadbzw2_pbr (SHORTCODE ) \ + fGEN_TCG_loadbXw2(GET_EA_pbr, fGETUBYTE) +#define fGEN_TCG_L2_loadbzw2_pi (SHORTCODE ) \ + fGEN_TCG_loadbXw2(GET_EA_pi, fGETUBYTE) +#define fGEN_TCG_L4_loadbsw2_ap (SHORTCODE ) \ + fGEN_TCG_loadbXw2(GET_EA_ap, fGETBYTE) +#define fGEN_TCG_L2_loadbsw2_pr (SHORTCODE ) \ + fGEN_TCG_loadbXw2(GET_EA_pr, fGETBYTE) +#define fGEN_TCG_L2_loadbsw2_pbr (SHORTCODE ) \ + fGEN_TCG_loadbXw2(GET_EA_pbr, fGETBYTE) +#define fGEN_TCG_L2_loadbsw2_pi (SHORTCODE ) \ + fGEN_TCG_loadbXw2(GET_EA_pi, fGETBYTE) +#define fGEN_TCG_L2_loadbzw2_pci (SHORTCODE ) \ + fGEN_TCG_loadbXw2(GET_EA_pci, fGETUBYTE) +#define fGEN_TCG_L2_loadbsw2_pci (SHORTCODE ) \ + fGEN_TCG_loadbXw2(GET_EA_pci, fGETBYTE) +#define fGEN_TCG_L2_loadbzw2_pcr (SHORTCODE ) \ + fGEN_TCG_loadbXw2(GET_EA_pcr(1), fGETUBYTE) +#define fGEN_TCG_L2_loadbsw2_pcr (SHORTCODE ) \ + fGEN_TCG_loadbXw2(GET_EA_pcr(1), fGETBYTE) + +/* +* These instructions load 4 bytes and places them in +* four halves of the destination register pair. +* The GET_EA macro determines the addressing mode. +* The fGB macro determines whether to zero-extend or +* sign-extend. +*/ +#define fGEN_TCG_loadbXw4 (GET_EA , fGB) \ + do { \ + TCGv ireg = tcg_temp_new(); \ + TCGv tmp = tcg_temp_new(); \ + TCGv tmpV = tcg_temp_new(); \ + TCGv BYTE = tcg_temp_new(); \ + int i; \ + GET_EA; \ + fLOAD(1, 4, u, EA, tmpV); \ + tcg_gen_movi_i64(RddV, 0); \ + for (i = 0; i < 4; i++) { \ + fSETHALF(i, RddV, fGB(i, tmpV)); \ + } \ + tcg_temp_free(ireg); \ + tcg_temp_free(tmp); \ + tcg_temp_free(tmpV); \ + tcg_temp_free(BYTE); \ + } while (0) + +#define fGEN_TCG_L2_loadbzw4_io (SHORTCODE ) \ + fGEN_TCG_loadbXw4(fEA_RI(RsV, siV), fGETUBYTE) +#define fGEN_TCG_L4_loadbzw4_ur (SHORTCODE ) \ + fGEN_TCG_loadbXw4(fEA_IRs(UiV, RtV, uiV), fGETUBYTE) +#define fGEN_TCG_L2_loadbsw4_io (SHORTCODE ) \ + fGEN_TCG_loadbXw4(fEA_RI(RsV, siV), fGETBYTE) +#define fGEN_TCG_L4_loadbsw4_ur (SHORTCODE ) \ + fGEN_TCG_loadbXw4(fEA_IRs(UiV, RtV, uiV), fGETBYTE) +#define fGEN_TCG_L2_loadbzw4_pci (SHORTCODE ) \ + fGEN_TCG_loadbXw4(GET_EA_pci, fGETUBYTE) +#define fGEN_TCG_L2_loadbsw4_pci (SHORTCODE ) \ + fGEN_TCG_loadbXw4(GET_EA_pci, fGETBYTE) +#define fGEN_TCG_L2_loadbzw4_pcr (SHORTCODE ) \ + fGEN_TCG_loadbXw4(GET_EA_pcr(2), fGETUBYTE) +#define fGEN_TCG_L2_loadbsw4_pcr (SHORTCODE ) \ + fGEN_TCG_loadbXw4(GET_EA_pcr(2), fGETBYTE) +#define fGEN_TCG_L4_loadbzw4_ap (SHORTCODE ) \ + fGEN_TCG_loadbXw4(GET_EA_ap, fGETUBYTE) +#define fGEN_TCG_L2_loadbzw4_pr (SHORTCODE ) \ + fGEN_TCG_loadbXw4(GET_EA_pr, fGETUBYTE) +#define fGEN_TCG_L2_loadbzw4_pbr (SHORTCODE ) \ + fGEN_TCG_loadbXw4(GET_EA_pbr, fGETUBYTE) +#define fGEN_TCG_L2_loadbzw4_pi (SHORTCODE ) \ + fGEN_TCG_loadbXw4(GET_EA_pi, fGETUBYTE) +#define fGEN_TCG_L4_loadbsw4_ap (SHORTCODE ) \ + fGEN_TCG_loadbXw4(GET_EA_ap, fGETBYTE) +#define fGEN_TCG_L2_loadbsw4_pr (SHORTCODE ) \ + fGEN_TCG_loadbXw4(GET_EA_pr, fGETBYTE) +#define fGEN_TCG_L2_loadbsw4_pbr (SHORTCODE ) \ + fGEN_TCG_loadbXw4(GET_EA_pbr, fGETBYTE) +#define fGEN_TCG_L2_loadbsw4_pi (SHORTCODE ) \ + fGEN_TCG_loadbXw4(GET_EA_pi, fGETBYTE) + +/* * Predicated loads * Here is a primer to understand the tag names *
target/hexagon/genptr.c +13 -0
@@ -308,6 +308,19 @@ static inline TCGv gen_get_half(TCGv result, int N, TCGv src, bool sign)return result; } +static inline void gen_set_half (int N ,TCGv result,TCGv src) +{ +tcg_gen_deposit_tl (result, result, src,N *16 ,16 ); +} + +static inline void gen_set_half_i64 (int N ,TCGv_i64 result,TCGv src) +{ +TCGv_i64 src64 =tcg_temp_new_i64 (); +tcg_gen_extu_i32_i64 (src64, src); +tcg_gen_deposit_i64 (result, result, src64,N *16 ,16 ); +tcg_temp_free_i64 (src64); +} +static inline void gen_set_byte (int N ,TCGv result,TCGv src) {tcg_gen_deposit_tl (result, result, src,N *8 ,8 );
target/hexagon/imported/encode_pp.def +6 -0
@@ -342,6 +342,12 @@ DEF_ENC32(L4_pload##TAG##fnew_abs,ICLASS_LD" 1 11 "OPC" iiiii PP111tti 1--ddd /* 0 000 misc: dealloc,loadw_locked,dcfetch */ +STD_LD_ENC(bzw4,"0 101") +STD_LD_ENC(bzw2,"0 011") + +STD_LD_ENC(bsw4,"0 111") +STD_LD_ENC(bsw2,"0 001") + STD_LD_ENC(rb, "1 000") STD_LD_ENC(rub, "1 001") STD_LD_ENC(rh, "1 010")
target/hexagon/imported/ldst.idef +43 -0
49 lines not on this page · raw message
target/hexagon/macros.h +26 -1
@@ -477,6 +477,21 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift)#define fCAST8S_16S (A ) (int128_exts64(A))#define fCAST16S_8S (A ) (int128_getlo(A)) +#ifdef QEMU_GENERATE +#define fEA_RI (REG ,IMM ) tcg_gen_addi_tl(EA, REG, IMM) +#define fEA_RRs (REG ,REG2 ,SCALE ) \ + do { \ + TCGv tmp = tcg_temp_new(); \ + tcg_gen_shli_tl(tmp, REG2, SCALE); \ + tcg_gen_add_tl(EA, REG, tmp); \ + tcg_temp_free(tmp); \ + } while (0) +#define fEA_IRs (IMM ,REG ,SCALE ) \ + do { \ + tcg_gen_shli_tl(EA, REG, SCALE); \ + tcg_gen_addi_tl(EA, EA, IMM); \ + } while (0) +#else #define fEA_RI (REG ,IMM ) \ do { \ EA = REG + IMM; \
@@ -489,6 +504,7 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val, int shift)do { \EA =IMM + (REG <<SCALE ); \ } while (0) +#endif #ifdef QEMU_GENERATE #define fEA_IMM (IMM ) tcg_gen_movi_tl(EA, IMM)
@@ -636,10 +652,18 @@ static inline void gen_fbrev(TCGv result, TCGv src)#ifdef QEMU_GENERATE #define fGETHALF (N ,SRC ) gen_get_half(HALF, N, SRC, true)#define fGETUHALF (N ,SRC ) gen_get_half(HALF, N, SRC, false) + +#define SETHALF_FUNC (X ) \ + __builtin_choose_expr(TYPE_TCGV(X), \ + gen_set_half, \ + __builtin_choose_expr(TYPE_TCGV_I64(X), \ + gen_set_half_i64, (void)0)) +#define fSETHALF (N ,DST ,VAL ) SETHALF_FUNC(DST)(N, DST, VAL) +#define fSETHALFw (N ,DST ,VAL ) gen_set_half(N, DST, VAL) +#define fSETHALFd (N ,DST ,VAL ) gen_set_half_i64(N, DST, VAL)#else #define fGETHALF (N ,SRC ) ((int16_t)((SRC >> ((N) * 16)) & 0xffff))#define fGETUHALF (N ,SRC ) ((uint16_t)((SRC >> ((N) * 16)) & 0xffff)) -#endif #define fSETHALF (N ,DST ,VAL ) \ do { \ DST = (DST & ~(0x0ffffLL << ((N) * 16))) | \
@@ -647,6 +671,7 @@ static inline void gen_fbrev(TCGv result, TCGv src) } while (0)#define fSETHALFw fSETHALF#define fSETHALFd fSETHALF +#endif #ifdef QEMU_GENERATE #define GETWORD_FUNC (X ) \
tests/tcg/hexagon/Makefile.target +1 -0
@@ -43,6 +43,7 @@ HEX_TESTS += multi_result HEX_TESTS += mem_noshuf HEX_TESTS += circ HEX_TESTS += brev +HEX_TESTS += load_unpack HEX_TESTS += atomics HEX_TESTS += fpstuff
tests/tcg/hexagon/load_unpack.c new file +474 -0
474 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 14/15 Hexagon (target/hexagon) load into shifted register instructions
In reply to Taylor SimpsonThe following instructions are added
L2_loadalignb_io Ryy32 = memb_fifo(Rs32+#s11:1)
L2_loadalignh_io Ryy32 = memh_fifo(Rs32+#s11:1)
L4_loadalignb_ur Ryy32 = memb_fifo(Rt32<<#u2+#U6)
L4_loadalignh_ur Ryy32 = memh_fifo(Rt32<<#u2+#U6)
L4_loadalignb_ap Ryy32 = memb_fifo(Re32=#U6)
L4_loadalignh_ap Ryy32 = memh_fifo(Re32=#U6)
L2_loadalignb_pr Ryy32 = memb_fifo(Rx32++Mu2)
L2_loadalignh_pr Ryy32 = memh_fifo(Rx32++Mu2)
L2_loadalignb_pbr Ryy32 = memb_fifo(Rx32++Mu2:brev)
L2_loadalignh_pbr Ryy32 = memh_fifo(Rx32++Mu2:brev)
L2_loadalignb_pi Ryy32 = memb_fifo(Rx32++#s4:1)
L2_loadalignh_pi Ryy32 = memh_fifo(Rx32++#s4:1)
L2_loadalignb_pci Ryy32 = memb_fifo(Rx32++#s4:1:circ(Mu2))
L2_loadalignh_pci Ryy32 = memh_fifo(Rx32++#s4:1:circ(Mu2))
L2_loadalignb_pcr Ryy32 = memb_fifo(Rx32++I:circ(Mu2))
L2_loadalignh_pcr Ryy32 = memh_fifo(Rx32++I:circ(Mu2))Test cases in tests/tcg/hexagon/load_align.c
--- target/hexagon/gen_tcg.h | 78 +++++++ target/hexagon/imported/encode_pp.def | 3 + target/hexagon/imported/ldst.idef | 19 ++ tests/tcg/hexagon/Makefile.target | 1 + tests/tcg/hexagon/load_align.c | 415 ++++++++++++++++++++++++++++++++++ 5 files changed, 516 insertions(+) create mode 100644 tests/tcg/hexagon/load_align.c
target/hexagon/gen_tcg.h +78 -0
@@ -285,6 +285,84 @@fGEN_TCG_loadbXw4 (GET_EA_pi, fGETBYTE)/* +* These instructions load a half word, shift the destination right by 16 bits +* and place the loaded value in the high half word of the destination pair. +* The GET_EA macro determines the addressing mode. + */ +#define fGEN_TCG_loadalignh (GET_EA ) \ + do { \ + TCGv ireg = tcg_temp_new(); \ + TCGv tmp = tcg_temp_new(); \ + TCGv tmpV = tcg_temp_new(); \ + TCGv_i64 tmp_i64 = tcg_temp_new_i64(); \ + tcg_gen_concat_i32_i64(RyyV, hex_gpr[RyyN], hex_gpr[RyyN + 1]); \ + GET_EA; \ + fLOAD(1, 2, u, EA, tmpV); \ + tcg_gen_extu_i32_i64(tmp_i64, tmpV); \ + tcg_gen_shli_i64(tmp_i64, tmp_i64, 48); \ + tcg_gen_shri_i64(RyyV, RyyV, 16); \ + tcg_gen_or_i64(RyyV, RyyV, tmp_i64); \ + tcg_temp_free(ireg); \ + tcg_temp_free(tmp); \ + tcg_temp_free(tmpV); \ + tcg_temp_free_i64(tmp_i64); \ + } while (0) + +#define fGEN_TCG_L4_loadalignh_ur (SHORTCODE ) \ + fGEN_TCG_loadalignh(fEA_IRs(UiV, RtV, uiV)) +#define fGEN_TCG_L2_loadalignh_io (SHORTCODE ) \ + fGEN_TCG_loadalignh(fEA_RI(RsV, siV)) +#define fGEN_TCG_L2_loadalignh_pci (SHORTCODE ) \ + fGEN_TCG_loadalignh(GET_EA_pci) +#define fGEN_TCG_L2_loadalignh_pcr (SHORTCODE ) \ + fGEN_TCG_loadalignh(GET_EA_pcr(1)) +#define fGEN_TCG_L4_loadalignh_ap (SHORTCODE ) \ + fGEN_TCG_loadalignh(GET_EA_ap) +#define fGEN_TCG_L2_loadalignh_pr (SHORTCODE ) \ + fGEN_TCG_loadalignh(GET_EA_pr) +#define fGEN_TCG_L2_loadalignh_pbr (SHORTCODE ) \ + fGEN_TCG_loadalignh(GET_EA_pbr) +#define fGEN_TCG_L2_loadalignh_pi (SHORTCODE ) \ + fGEN_TCG_loadalignh(GET_EA_pi) + +/* Same as above, but loads a byte instead of half word */ +#define fGEN_TCG_loadalignb (GET_EA ) \ + do { \ + TCGv ireg = tcg_temp_new(); \ + TCGv tmp = tcg_temp_new(); \ + TCGv tmpV = tcg_temp_new(); \ + TCGv_i64 tmp_i64 = tcg_temp_new_i64(); \ + tcg_gen_concat_i32_i64(RyyV, hex_gpr[RyyN], hex_gpr[RyyN + 1]); \ + GET_EA; \ + fLOAD(1, 1, u, EA, tmpV); \ + tcg_gen_extu_i32_i64(tmp_i64, tmpV); \ + tcg_gen_shli_i64(tmp_i64, tmp_i64, 56); \ + tcg_gen_shri_i64(RyyV, RyyV, 8); \ + tcg_gen_or_i64(RyyV, RyyV, tmp_i64); \ + tcg_temp_free(ireg); \ + tcg_temp_free(tmp); \ + tcg_temp_free(tmpV); \ + tcg_temp_free_i64(tmp_i64); \ + } while (0) + +#define fGEN_TCG_L2_loadalignb_io (SHORTCODE ) \ + fGEN_TCG_loadalignb(fEA_RI(RsV, siV)) +#define fGEN_TCG_L4_loadalignb_ur (SHORTCODE ) \ + fGEN_TCG_loadalignb(fEA_IRs(UiV, RtV, uiV)) +#define fGEN_TCG_L2_loadalignb_pci (SHORTCODE ) \ + fGEN_TCG_loadalignb(GET_EA_pci) +#define fGEN_TCG_L2_loadalignb_pcr (SHORTCODE ) \ + fGEN_TCG_loadalignb(GET_EA_pcr(0)) +#define fGEN_TCG_L4_loadalignb_ap (SHORTCODE ) \ + fGEN_TCG_loadalignb(GET_EA_ap) +#define fGEN_TCG_L2_loadalignb_pr (SHORTCODE ) \ + fGEN_TCG_loadalignb(GET_EA_pr) +#define fGEN_TCG_L2_loadalignb_pbr (SHORTCODE ) \ + fGEN_TCG_loadalignb(GET_EA_pbr) +#define fGEN_TCG_L2_loadalignb_pi (SHORTCODE ) \ + fGEN_TCG_loadalignb(GET_EA_pi) + +/* * Predicated loads * Here is a primer to understand the tag names *
target/hexagon/imported/encode_pp.def +3 -0
@@ -348,6 +348,9 @@ STD_LD_ENC(bzw2,"0 011") STD_LD_ENC(bsw4,"0 111") STD_LD_ENC(bsw2,"0 001") +STD_LDX_ENC(alignh,"0 010") +STD_LDX_ENC(alignb,"0 100") + STD_LD_ENC(rb, "1 000") STD_LD_ENC(rub, "1 001") STD_LD_ENC(rh, "1 010")
target/hexagon/imported/ldst.idef +19 -0
@@ -80,6 +80,25 @@ ATTRIBS(A_LOAD),"2", +STD_LD_AMODES(loadalignh, "Ryy32=memh_fifo", "Load Half-word into shifted vector", +ATTRIBS(A_LOAD),"1", +{ + fHIDE(size8u_t tmpV;) + fLOAD(1,2,u,EA,tmpV); + RyyV = (((size8u_t)RyyV)>>16)|(tmpV<<48); +},1) + + +STD_LD_AMODES(loadalignb, "Ryy32=memb_fifo", "Load byte into shifted vector", +ATTRIBS(A_LOAD),"0", +{ + fHIDE(size8u_t tmpV;) + fLOAD(1,1,u,EA,tmpV); + RyyV = (((size8u_t)RyyV)>>8)|(tmpV<<56); +},0) + + + /* The set of addressing modes standard to all Store instructions */ #define STD_ST_AMODES(TAG,DEST,OPER,DESCR,ATTRIB,SHFT,SEMANTICS,SCALE)\
tests/tcg/hexagon/Makefile.target +1 -0
@@ -44,6 +44,7 @@ HEX_TESTS += mem_noshuf HEX_TESTS += circ HEX_TESTS += brev HEX_TESTS += load_unpack +HEX_TESTS += load_align HEX_TESTS += atomics HEX_TESTS += fpstuff
tests/tcg/hexagon/load_align.c new file +415 -0
415 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH 14/15] Hexagon (target/hexagon) load into shifted register instructions
target/hexagon/gen_tcg.h line 304
Quoted 3 lines · Taylor Simpson
target/hexagon/gen_tcg.h +3
-0+tcg_gen_shli_i64 (tmp_i64, tmp_i64,48 ); \ +tcg_gen_shri_i64 (RyyV, RyyV,16 ); \ +tcg_gen_or_i64 (RyyV, RyyV, tmp_i64); \
shr + deposit.
r~
PATCH 15/15 Hexagon (target/hexagon) CABAC decode bin
In reply to Taylor SimpsonThe following instruction is added
S2_cabacdecbin Rdd32=decbin(Rss32,Rtt32)
Test cases added to tests/tcg/hexagon/misc.c
--- target/hexagon/arch.c | 91 +++++++++++++++++++++++++++++++++++ target/hexagon/arch.h | 4 ++ target/hexagon/imported/encode_pp.def | 1 + target/hexagon/imported/macros.def | 15 ++++++ target/hexagon/imported/shift.idef | 47 ++++++++++++++++++ target/hexagon/macros.h | 4 ++ tests/tcg/hexagon/misc.c | 28 +++++++++++ 7 files changed, 190 insertions(+)
target/hexagon/arch.c +91 -0
@@ -27,6 +27,97 @@#define SF_MANTBITS 23#define float32_nan make_float32(0xffffffff) +/* +* These three tables are used by the cabacdecbin instruction +*/ +const uint8_t rLPS_table_64x4[64 ][4 ] = { + {128 ,176 ,208 ,240 }, + {128 ,167 ,197 ,227 }, + {128 ,158 ,187 ,216 }, + {123 ,150 ,178 ,205 }, + {116 ,142 ,169 ,195 }, + {111 ,135 ,160 ,185 }, + {105 ,128 ,152 ,175 }, + {100 ,122 ,144 ,166 }, + {95 ,116 ,137 ,158 }, + {90 ,110 ,130 ,150 }, + {85 ,104 ,123 ,142 }, + {81 ,99 ,117 ,135 }, + {77 ,94 ,111 ,128 }, + {73 ,89 ,105 ,122 }, + {69 ,85 ,100 ,116 }, + {66 ,80 ,95 ,110 }, + {62 ,76 ,90 ,104 }, + {59 ,72 ,86 ,99 }, + {56 ,69 ,81 ,94 }, + {53 ,65 ,77 ,89 }, + {51 ,62 ,73 ,85 }, + {48 ,59 ,69 ,80 }, + {46 ,56 ,66 ,76 }, + {43 ,53 ,63 ,72 }, + {41 ,50 ,59 ,69 }, + {39 ,48 ,56 ,65 }, + {37 ,45 ,54 ,62 }, + {35 ,43 ,51 ,59 }, + {33 ,41 ,48 ,56 }, + {32 ,39 ,46 ,53 }, + {30 ,37 ,43 ,50 }, + {29 ,35 ,41 ,48 }, + {27 ,33 ,39 ,45 }, + {26 ,31 ,37 ,43 }, + {24 ,30 ,35 ,41 }, + {23 ,28 ,33 ,39 }, + {22 ,27 ,32 ,37 }, + {21 ,26 ,30 ,35 }, + {20 ,24 ,29 ,33 }, + {19 ,23 ,27 ,31 }, + {18 ,22 ,26 ,30 }, + {17 ,21 ,25 ,28 }, + {16 ,20 ,23 ,27 }, + {15 ,19 ,22 ,25 }, + {14 ,18 ,21 ,24 }, + {14 ,17 ,20 ,23 }, + {13 ,16 ,19 ,22 }, + {12 ,15 ,18 ,21 }, + {12 ,14 ,17 ,20 }, + {11 ,14 ,16 ,19 }, + {11 ,13 ,15 ,18 }, + {10 ,12 ,15 ,17 }, + {10 ,12 ,14 ,16 }, + {9 ,11 ,13 ,15 }, + {9 ,11 ,12 ,14 }, + {8 ,10 ,12 ,14 }, + {8 ,9 ,11 ,13 }, + {7 ,9 ,11 ,12 }, + {7 ,9 ,10 ,12 }, + {7 ,8 ,10 ,11 }, + {6 ,8 ,9 ,11 }, + {6 ,7 ,9 ,10 }, + {6 ,7 ,8 ,9 }, + {2 ,2 ,2 ,2 } +}; + +const uint8_t AC_next_state_MPS_64[64 ] = { +1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 , +11 ,12 ,13 ,14 ,15 ,16 ,17 ,18 ,19 ,20 , +21 ,22 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,30 , +31 ,32 ,33 ,34 ,35 ,36 ,37 ,38 ,39 ,40 , +41 ,42 ,43 ,44 ,45 ,46 ,47 ,48 ,49 ,50 , +51 ,52 ,53 ,54 ,55 ,56 ,57 ,58 ,59 ,60 , +61 ,62 ,62 ,63 +}; + + +const uint8_t AC_next_state_LPS_64[64 ] = { +0 ,0 ,1 ,2 ,2 ,4 ,4 ,5 ,6 ,7 , +8 ,9 ,9 ,11 ,11 ,12 ,13 ,13 ,15 ,15 , +16 ,16 ,18 ,18 ,19 ,19 ,21 ,21 ,22 ,22 , +23 ,24 ,24 ,25 ,26 ,26 ,27 ,27 ,28 ,29 , +29 ,30 ,30 ,30 ,31 ,32 ,32 ,33 ,33 ,33 , +34 ,34 ,35 ,35 ,35 ,36 ,36 ,36 ,37 ,37 , +37 ,38 ,38 ,63 +}; +#define BITS_MASK_8 0x5555555555555555ULL#define PAIR_MASK_8 0x3333333333333333ULL#define NYBL_MASK_8 0x0f0f0f0f0f0f0f0fULL
target/hexagon/arch.h +4 -0
@@ -20,6 +20,10 @@#include "qemu/int128.h" +extern const uint8_t rLPS_table_64x4[64 ][4 ]; +extern const uint8_t AC_next_state_MPS_64[64 ]; +extern const uint8_t AC_next_state_LPS_64[64 ]; +uint64_t interleave (uint32_t odd,uint32_t even);uint64_t deinterleave (uint64_t src);int32_t conv_round (int32_t a,int n);
target/hexagon/imported/encode_pp.def +1 -0
@@ -1767,6 +1767,7 @@ SH_RRR_ENC(S4_vxsubaddh, "0001","01-","-","110","ddddd") SH_RRR_ENC(S4_vxaddsubhr, "0001","11-","-","00-","ddddd") SH_RRR_ENC(S4_vxsubaddhr, "0001","11-","-","01-","ddddd") SH_RRR_ENC(S4_extractp_rp, "0001","11-","-","10-","ddddd") +SH_RRR_ENC(S2_cabacdecbin, "0001","11-","-","11-","ddddd") /* implicit P0 write */ DEF_FIELDROW_DESC32(ICLASS_S3op" 0010 -------- PP------ --------","[#2] Rdd=(Rss,Rtt,Pu)")
target/hexagon/imported/macros.def +15 -0
@@ -92,6 +92,21 @@ DEF_MACRO( /* attribs */ ) + +DEF_MACRO( + fINSERT_RANGE, + { + int offset=LOWBIT; + int width=HIBIT-LOWBIT+1; + /* clear bits where new bits go */ + INREG &= ~(((fCONSTLL(1)<<width)-1)<<offset); + /* OR in new bits */ + INREG |= ((INVAL & ((fCONSTLL(1)<<width)-1)) << offset); + }, + /* attribs */ +) + + DEF_MACRO( f8BITSOF, ( (VAL) ? 0xff : 0x00),
target/hexagon/imported/shift.idef +47 -0
53 lines not on this page · raw message
target/hexagon/macros.h +4 -0
@@ -226,6 +226,10 @@ static inline void gen_pred_cancel(TCGv pred, int slot_num) (((HIBIT ) - (LOWBIT ) +1 ) ? \extract64 ((INREG ), (LOWBIT ), ((HIBIT ) - (LOWBIT ) +1 )) : \ 0LL) +#define fINSERT_RANGE (INREG ,HIBIT ,LOWBIT ,INVAL ) \ + INREG = (((HIBIT) - (LOWBIT) - 1) ? \ + deposit64((INREG), (LOWBIT), ((HIBIT) - (LOWBIT) + 1), (INVAL)) : \ + INREG)#ifdef QEMU_GENERATE #define f8BITSOF (RES ,VAL ) gen_8bitsof(RES, VAL)
tests/tcg/hexagon/misc.c +28 -0
@@ -231,6 +231,14 @@ static void check(int val, int expect) } } +static void check64 (long long val,long long expect) +{ +if (val != expect) { +printf ("ERROR: 0x%016llx != 0x%016llx\n" , val, expect); + err++; + } +} +uint32_t init[10 ] = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 };uint32_t array[10 ];
@@ -264,6 +272,16 @@ static long long creg_pair(int x, int y)return retval; } +static long long decbin (long long x,long long y,int *pred) +{ +long long retval; + asm ("%0 = decbin(%2, %3)\n\t" +"%1 = p0\n\t" + :"=r" (retval),"=r" (*pred) + :"r" (x),"r" (y)); +return retval; +} +/* Check that predicates are auto-and'ed in a packet */ static int auto_and (void ) {
@@ -282,6 +300,8 @@ static int auto_and(void)int main () { +long long res64; +int pred;memcpy (array, init,sizeof (array));S4_storerhnew_rr (array,4 ,0xffff );
@@ -391,6 +411,14 @@ int main() res =test_clrtnew (2 ,7 );check (res,7 ); + res64 =decbin (0xf0f1f2f3f4f5f6f7LL ,0x7f6f5f4f3f2f1f0fLL , &pred); +check64 (res64,0x357980003700010cLL ); +check (pred,0 ); + + res64 =decbin (0xfLL ,0x1bLL , &pred); +check64 (res64,0x78000100LL ); +check (pred,1 ); + res =auto_and ();check (res,0 );
Signature · 1 line
2.7.4
Re: [PATCH 15/15] Hexagon (target/hexagon) CABAC decode bin
target/hexagon/macros.h static inline void gen_pred_cancel(TCGv pred, int slot_num) · line 232
Quoted 4 lines · Taylor Simpson
target/hexagon/macros.h +4
-0+#define fINSERT_RANGE (INREG ,HIBIT ,LOWBIT ,INVAL ) \ + INREG = (((HIBIT) - (LOWBIT) - 1) ? \ + deposit64((INREG), (LOWBIT), ((HIBIT) - (LOWBIT) + 1), (INVAL)) : \ + INREG)
The -1 and +1 on the length of the field doesn't look right. Which really computes the length of the field?
Did you in fact want the test to be HIBIT >= LOBIT?
r~