Alpha emulation improvements, round two
cover Alpha emulation improvements, round two
There are two -d flags fixes herein, which helps with the rest. Otherwise the improvements are in 3 categories:
(1) Implement the rd/wrunique PALcall in the translator, at least for usermode. There's no reason to break the TB for a register move.
(2) Implement the byte manipulation instructions inline instead of
via helpers. Worst case these expand to about 6 tcg ops. I was
hoping without looking that tcg would do some simple CSE operations
within the block. Of course, cse isn't implemented yet, but there's
no reason that couldn't happen in the future.
A good test case for the cse might be
gcc.c-torture/execute/20040709-2.c, function retmeE:
120001964: 0f 00 50 2c ldq_u t1,15(a0)
120001968: 00 00 30 2c ldq_u t0,0(a0)
12000196c: e4 0e 50 4a insqh a2,a0,t3
120001970: 72 07 50 4a insql a2,a0,a2
120001974: e3 0e 30 4a insqh a1,a0,t2
120001978: 71 07 30 4a insql a1,a0,a1
12000197c: 03 04 72 44 or t2,a2,t2
120001980: 42 0e 50 48 mskqh t1,a0,t1
120001984: 41 06 30 48 mskql t0,a0,t0
120001988: 02 04 44 44 or t1,t3,t1
12000198c: 01 04 31 44 or t0,a1,t0
120001990: 0f 00 50 3c stq_u t1,15(a0)
120001994: 08 00 70 3c stq_u t2,8(a0)
120001998: 00 00 30 3c stq_u t0,0(a0)
Here we've got 6 byte manipulation insns using A0 as an input,
all of which compute at least (A0 & 7) * 8; there's even more
that could be shared in this block.(3) There are three FP correctness fixes.
Not surprisingly from the last, there are now fewer gcc testsuite failures. I suspect that I'll have to tackle the missing rounding mode bits before the rest of the testsuite will work.
r~
Richard Henderson (13):
alpha: Implement missing MVI instructions.
alpha: Fix -d in_asm
alpha: Expand zap/zapnot with immediate inline.
alpha: Rewrite gen_ext_[hl] in terms of zapnot.
alpha: Fix fbcond branch offset.
alpha: Implement RD/WRUNIQUE in the translator
alpha: Expand ins*l inline.
alpha: Expand msk*l inline.
alpha: Expand msk*h inline.
alpha: Expand ins*h inline.
alpha: Fix FMOV.
alpha: Fix double log_cpu_state.
alpha: Implement fp branch/cmov inline.
hw/alpha_palcode.c | 11 +- target-alpha/helper.h | 35 +-- target-alpha/op_helper.c | 228 ++++++++++------ target-alpha/translate.c | 645 +++++++++++++++++++++++++++++++--------------- 4 files changed, 600 insertions(+), 319 deletions(-)
PATCH 1/13 alpha: Implement missing MVI instructions.
--- target-alpha/helper.h | 14 ++++ target-alpha/op_helper.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++ target-alpha/translate.c | 79 +++++++++++++-------- 3 files changed, 231 insertions(+), 30 deletions(-)
target-alpha/helper.h +14 -0
@@ -36,6 +36,20 @@ DEF_HELPER_2(insqh, i64, i64, i64) DEF_HELPER_2(cmpbge, i64, i64, i64) +DEF_HELPER_2(minub8, i64, i64, i64) +DEF_HELPER_2(minsb8, i64, i64, i64) +DEF_HELPER_2(minuw4, i64, i64, i64) +DEF_HELPER_2(minsw4, i64, i64, i64) +DEF_HELPER_2(maxub8, i64, i64, i64) +DEF_HELPER_2(maxsb8, i64, i64, i64) +DEF_HELPER_2(maxuw4, i64, i64, i64) +DEF_HELPER_2(maxsw4, i64, i64, i64) +DEF_HELPER_2(perr, i64, i64, i64) +DEF_HELPER_1(pklb, i64, i64) +DEF_HELPER_1(pkwb, i64, i64) +DEF_HELPER_1(unpkbl, i64, i64) +DEF_HELPER_1(unpkbw, i64, i64) + DEF_HELPER_0(load_fpcr, i64)DEF_HELPER_1 (store_fpcr, void, i64)
target-alpha/op_helper.c +168 -0
174 lines not on this page · raw message
target-alpha/translate.c +49 -30
169 lines not on this page · raw message
PATCH 2/13 alpha: Fix -d in_asm
In reply to Richard HendersonGeneric disassembly was incorrectly keyed on ALPHA_DEBUG_DISAS rather than the generic DEBUG_DISAS. Use qemu_log_mask for additional LOG_DISAS output. Delete some random insn_count logging noise from gen_intermediate_code_internal.
--- target-alpha/translate.c | 19 ++++--------------- 1 files changed, 4 insertions(+), 15 deletions(-)
target-alpha/translate.c +4 -15
@@ -35,7 +35,7 @@#undef ALPHA_DEBUG_DISAS#ifdef ALPHA_DEBUG_DISAS -# define LOG_DISAS (...) qemu_log(__VA_ARGS__) +# define LOG_DISAS (...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)#else # define LOG_DISAS (...) do { } while (0)#endif
@@ -696,8 +696,9 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn) fn7 = (insn >>5 ) &0x0000007F ; fn2 = (insn >>5 ) &0x00000003 ; ret =0 ; -LOG_DISAS ("opc %02x ra %d rb %d rc %d disp16 %04x\n" , +LOG_DISAS ("opc %02x ra %2d rb %2d rc %2d disp16 %6d\n" , opc, ra, rb, rc, disp16); +switch (opc) {case 0x00 :/* CALL_PAL */
@@ -2353,9 +2354,6 @@ static inline void gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb, int search_pc) { -#if definedALPHA_DEBUG_DISAS -static int insn_count; -#endif DisasContext ctx, *ctxp = &ctx;target_ulong pc_start;uint32_t insn;
@@ -2405,16 +2403,7 @@ static inline void gen_intermediate_code_internal(CPUState *env, }if (num_insns +1 == max_insns && (tb->cflags &CF_LAST_IO ))gen_io_start (); -#if definedALPHA_DEBUG_DISAS - insn_count++; -LOG_DISAS ("pc " TARGET_FMT_lx" mem_idx %d\n" , - ctx.pc, ctx.mem_idx); -#endif insn =ldl_code (ctx.pc); -#if definedALPHA_DEBUG_DISAS - insn_count++; -LOG_DISAS ("opcode %08x %d\n" , insn, insn_count); -#endif num_insns++; ctx.pc +=4 ; ret =translate_one (ctxp, insn);
@@ -2459,7 +2448,7 @@ static inline void gen_intermediate_code_internal(CPUState *env, tb->size = ctx.pc - pc_start; tb->icount = num_insns; } -#if definedALPHA_DEBUG_DISAS +#ifdef DEBUG_DISAS log_cpu_state_mask (CPU_LOG_TB_CPU , env,0 );if (qemu_loglevel_mask (CPU_LOG_TB_IN_ASM )) {qemu_log ("IN: %s\n" ,lookup_symbol (pc_start));
PATCH 3/13 alpha: Expand zap/zapnot with immediate inline.
In reply to Richard HendersonThe vast majority of zap instructions have an immediate operand, since zapnot is the canonical method to zero-extend from u16 or u32.
--- target-alpha/translate.c | 61 ++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 59 insertions(+), 2 deletions(-)
target-alpha/translate.c +59 -2
@@ -507,6 +507,65 @@ FCMOV(cmpfge)FCMOV (cmpfle)FCMOV (cmpfgt) +/* Implement zapnot with an immediate operand, which expands to some +form of immediate AND. This is a basic building block in the +definition of many of the other byte manipulation instructions. */ +static inline void gen_zapnoti(int ra, int rc, uint8_t lit) +{ + uint64_t mask; +int i; + + switch (lit) { +case 0x00 : +tcg_gen_movi_i64 (cpu_ir[rc],0 ); +break ; +case 0x01 : +tcg_gen_ext8u_i64 (cpu_ir[rc], cpu_ir[ra]); +break ; +case 0x03 : +tcg_gen_ext16u_i64 (cpu_ir[rc], cpu_ir[ra]); +break ; +case 0x0f : +tcg_gen_ext32u_i64 (cpu_ir[rc], cpu_ir[ra]); +break ; +case 0xff : +tcg_gen_mov_i64 (cpu_ir[rc], cpu_ir[ra]); +break ; +default : +for (mask = i =0 ; i <8 ; ++i) { +if ((lit >> i) &1 ) + mask |=0xffull << (i *8 ); + } +tcg_gen_andi_i64 (cpu_ir[rc], cpu_ir[ra], mask); +break ; + } +} + +static inline void gen_zapnot (int ra,int rb,int rc,int islit,uint8_t lit) +{ +if (unlikely (rc ==31 )) +return ; +else if (unlikely (ra ==31 )) +tcg_gen_movi_i64 (cpu_ir[rc],0 ); +else if (islit) +gen_zapnoti (ra, rc, lit); +else +gen_helper_zapnot (cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]); +} + +static inline void gen_zap (int ra,int rb,int rc,int islit,uint8_t lit) +{ +if (unlikely (rc ==31 )) +return ; +else if (unlikely (ra ==31 )) +tcg_gen_movi_i64 (cpu_ir[rc],0 ); +else if (islit) +gen_zapnoti (ra, rc, ~lit); +else +gen_helper_zap (cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]); +} + +/* EXTWH, EXTWH, EXTLH, EXTQH */ static inline void gen_ext_h (void (*tcg_gen_ext_i64)(TCGv t0,TCGv t1),int ra,int rb,int rc,int islit,uint8_t lit)
@@ -598,8 +657,6 @@ ARITH3(mskwl) ARITH3(inswl) ARITH3(mskll) ARITH3(insll) -ARITH3(zap) -ARITH3(zapnot) ARITH3(mskql) ARITH3(insql) ARITH3(mskwh)
PATCH 4/13 alpha: Rewrite gen_ext_[hl] in terms of zapnot.
In reply to Richard HendersonThe architecture manual specifies the EXT instructions in terms of the ZAPNOT operation; writing it that way in the translator makes things a bit clearer.
--- target-alpha/translate.c | 57 ++++++++++++++++++++------------------------- 1 files changed, 25 insertions(+), 32 deletions(-)
target-alpha/translate.c +25 -32
@@ -567,46 +567,41 @@ static inline void gen_zap(int ra, int rb, int rc, int islit, uint8_t lit)/* EXTWH, EXTWH, EXTLH, EXTQH */ -static inline void gen_ext_h (void (*tcg_gen_ext_i64)(TCGv t0,TCGv t1), -int ra,int rb,int rc,int islit,uint8_t lit) +static inline void gen_ext_h (int ra,int rb,int rc,int islit, +uint8_t lit,uint8_t byte_mask) {if (unlikely (rc ==31 ))return ; - -if (ra !=31 ) { +else if (unlikely (ra ==31 )) +tcg_gen_movi_i64 (cpu_ir[rc],0 ); +else {if (islit) { -if (lit !=0 ) -tcg_gen_shli_i64 (cpu_ir[rc], cpu_ir[ra],64 - ((lit &7 ) *8 )); -else -tcg_gen_mov_i64 (cpu_ir[rc], cpu_ir[ra]); + lit = (64 - (lit &7 ) *8 ) &0x3f ; +tcg_gen_shli_i64 (cpu_ir[rc], cpu_ir[ra], lit); }else { -TCGv tmp1; - tmp1 =tcg_temp_new (); - +TCGv tmp1 =tcg_temp_new ();tcg_gen_andi_i64 (tmp1, cpu_ir[rb],7 );tcg_gen_shli_i64 (tmp1, tmp1,3 );tcg_gen_neg_i64 (tmp1, tmp1);tcg_gen_andi_i64 (tmp1, tmp1,0x3f );tcg_gen_shl_i64 (cpu_ir[rc], cpu_ir[ra], tmp1); -tcg_temp_free (tmp1); } -if (tcg_gen_ext_i64) -tcg_gen_ext_i64 (cpu_ir[rc], cpu_ir[rc]); - }else -tcg_gen_movi_i64 (cpu_ir[rc],0 ); +gen_zapnoti (rc, rc, byte_mask); + } }/* EXTBL, EXTWL, EXTWL, EXTLL, EXTQL */ -static inline void gen_ext_l (void (*tcg_gen_ext_i64)(TCGv t0,TCGv t1), -int ra,int rb,int rc,int islit,uint8_t lit) +static inline void gen_ext_l (int ra,int rb,int rc,int islit, +uint8_t lit,uint8_t byte_mask) {if (unlikely (rc ==31 ))return ; - -if (ra !=31 ) { +else if (unlikely (ra ==31 )) +tcg_gen_movi_i64 (cpu_ir[rc],0 ); +else {if (islit) { -tcg_gen_shri_i64 (cpu_ir[rc], cpu_ir[ra], (lit &7 ) *8 ); +tcg_gen_shri_i64 (cpu_ir[rc], cpu_ir[ra], (lit &7 ) *8 ); }else {TCGv tmp =tcg_temp_new ();tcg_gen_andi_i64 (tmp, cpu_ir[rb],7 );
@@ -614,10 +609,8 @@ static inline void gen_ext_l(void(*tcg_gen_ext_i64)(TCGv t0, TCGv t1),tcg_gen_shr_i64 (cpu_ir[rc], cpu_ir[ra], tmp);tcg_temp_free (tmp); } -if (tcg_gen_ext_i64) -tcg_gen_ext_i64 (cpu_ir[rc], cpu_ir[rc]); - }else -tcg_gen_movi_i64 (cpu_ir[rc],0 ); +gen_zapnoti (rc, rc, byte_mask); + } }/* Code to call arith3 helpers */
@@ -1276,7 +1269,7 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x06 :/* EXTBL */ -gen_ext_l (&tcg_gen_ext8u_i64, ra, rb, rc, islit, lit); +gen_ext_l (ra, rb, rc, islit, lit,0x01 );break ;case 0x0B :/* INSBL */
@@ -1288,7 +1281,7 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x16 :/* EXTWL */ -gen_ext_l (&tcg_gen_ext16u_i64, ra, rb, rc, islit, lit); +gen_ext_l (ra, rb, rc, islit, lit,0x03 );break ;case 0x1B :/* INSWL */
@@ -1300,7 +1293,7 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x26 :/* EXTLL */ -gen_ext_l (&tcg_gen_ext32u_i64, ra, rb, rc, islit, lit); +gen_ext_l (ra, rb, rc, islit, lit,0x0f );break ;case 0x2B :/* INSLL */
@@ -1336,7 +1329,7 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x36 :/* EXTQL */ -gen_ext_l (NULL , ra, rb, rc, islit, lit); +gen_ext_l (ra, rb, rc, islit, lit,0xff );break ;case 0x39 :/* SLL */
@@ -1384,7 +1377,7 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x5A :/* EXTWH */ -gen_ext_h (&tcg_gen_ext16u_i64, ra, rb, rc, islit, lit); +gen_ext_h (ra, rb, rc, islit, lit,0x03 );break ;case 0x62 :/* MSKLH */
@@ -1396,7 +1389,7 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x6A :/* EXTLH */ -gen_ext_h (&tcg_gen_ext32u_i64, ra, rb, rc, islit, lit); +gen_ext_h (ra, rb, rc, islit, lit,0x0f );break ;case 0x72 :/* MSKQH */
@@ -1408,7 +1401,7 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x7A :/* EXTQH */ -gen_ext_h (NULL , ra, rb, rc, islit, lit); +gen_ext_h (ra, rb, rc, islit, lit,0xff );break ;default : goto invalid_opc;
PATCH 5/13 alpha: Fix fbcond branch offset.
In reply to Richard HendersonThe instructions use a disp21 like all other branch insns, not the disp16 that was being passed.
--- target-alpha/translate.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
target-alpha/translate.c +4 -5
@@ -314,8 +314,7 @@ static inline void gen_bcond(DisasContext *ctx, TCGCond cond, int ra,gen_set_label (l2); } -static inline void gen_fbcond (DisasContext *ctx,int opc,int ra, -int32_t disp16) +static inline void gen_fbcond (DisasContext *ctx,int opc,int ra,int32_t disp) {int l1, l2;TCGv tmp;
@@ -356,7 +355,7 @@ static inline void gen_fbcond(DisasContext *ctx, int opc, int ra,tcg_gen_movi_i64 (cpu_pc, ctx->pc);tcg_gen_br (l2);gen_set_label (l1); -tcg_gen_movi_i64 (cpu_pc, ctx->pc + (int64_t )(disp16 <<2 )); +tcg_gen_movi_i64 (cpu_pc, ctx->pc + (int64_t )(disp <<2 ));gen_set_label (l2); }
@@ -2335,7 +2334,7 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)case 0x31 :/* FBEQ */ case 0x32 :/* FBLT */ case 0x33 :/* FBLE */ -gen_fbcond (ctx, opc, ra, disp16); +gen_fbcond (ctx, opc, ra, disp21); ret =1 ;break ;case 0x34 :
@@ -2348,7 +2347,7 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)case 0x35 :/* FBNE */ case 0x36 :/* FBGE */ case 0x37 :/* FBGT */ -gen_fbcond (ctx, opc, ra, disp16); +gen_fbcond (ctx, opc, ra, disp21); ret =1 ;break ;case 0x38 :
PATCH 6/13 alpha: Implement RD/WRUNIQUE in the translator
In reply to Richard HendersonWhen emulating user-mode only, there's no reason to exit the translation block to effect a call_pal. We can generate a move to/from the unique slot directly.
--- hw/alpha_palcode.c | 11 +++++------ target-alpha/translate.c | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 16 deletions(-)
hw/alpha_palcode.c +5 -6
@@ -1060,7 +1060,6 @@ void call_pal (CPUState *env, int palcode) {target_long ret; -qemu_log ("%s: palcode %02x\n" , __func__, palcode);switch (palcode) {case 0x80 :/* BPT */
@@ -1093,14 +1092,14 @@ void call_pal (CPUState *env, int palcode)break ;case 0x9E :/* RDUNIQUE */ - env->ir[IR_V0 ] = env->unique;qemu_log ("RDUNIQUE: " TARGET_FMT_lx"\n" , env->unique); -break ; +/* Handled in the translator for usermode. */ +abort ();case 0x9F :/* WRUNIQUE */ - env->unique = env->ir[IR_A0 ]; -qemu_log ("WRUNIQUE: " TARGET_FMT_lx"\n" , env->unique); -break ; +qemu_log ("WRUNIQUE: " TARGET_FMT_lx"\n" , env->ir[IR_A0 ]); +/* Handled in the translator for usermode. */ +abort ();case 0xAA :/* GENTRAP */ qemu_log ("GENTRAP: " TARGET_FMT_lx"\n" , env->ir[IR_A0 ]);
target-alpha/translate.c +29 -10
@@ -57,6 +57,9 @@ static TCGv cpu_ir[31];static TCGv cpu_fir[31 ];static TCGv cpu_pc;static TCGv cpu_lock; +#ifdef CONFIG_USER_ONLY +static TCGv cpu_uniq; +#endif /* register names */ static char cpu_reg_names[10 *4 +21 *5 +10 *5 +21 *6 ];
@@ -93,6 +96,11 @@ static void alpha_translate_init(void) cpu_lock =tcg_global_mem_new_i64 (TCG_AREG0 , offsetof(CPUState , lock),"lock" ); +#ifdef CONFIG_USER_ONLY + cpu_uniq =tcg_global_mem_new_i64 (TCG_AREG0 , + offsetof(CPUState , unique),"uniq" ); +#endif +/* register helpers */ #define GEN_HELPER 2#include "helper.h"
@@ -751,23 +759,34 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)switch (opc) {case 0x00 :/* CALL_PAL */ +#ifdef CONFIG_USER_ONLY +if (palcode ==0x9E ) { +/* RDUNIQUE */ +tcg_gen_mov_i64 (cpu_ir[IR_V0 ], cpu_uniq); +break ; + }else if (palcode ==0x9F ) { +/* WRUNIQUE */ +tcg_gen_mov_i64 (cpu_uniq, cpu_ir[IR_A0 ]); +break ; + } +#endif if (palcode >=0x80 && palcode <0xC0 ) {/* Unprivileged PAL call */ gen_excp (ctx,EXCP_CALL_PAL + ((palcode &0x3F ) <<6 ),0 ); -#if !defined (CONFIG_USER_ONLY ) - } else if (palcode < 0x40) { + ret =3 ; +break ; + } +#ifndef CONFIG_USER_ONLY +if (palcode <0x40 ) {/* Privileged PAL code */ if (ctx->mem_idx &1 ) goto invalid_opc; -else -gen_excp (ctx,EXCP_CALL_PALP + ((palcode &0x3F ) <<6 ),0 ); -#endif - }else { -/* Invalid PAL call */ - goto invalid_opc; +gen_excp (ctx,EXCP_CALL_PALP + ((palcode &0x3F ) <<6 ),0 ); + ret =3 ; } - ret =3 ; -break ; +#endif +/* Invalid PAL call */ + goto invalid_opc;case 0x01 :/* OPC01 */ goto invalid_opc;
PATCH 7/13 alpha: Expand ins*l inline.
In reply to Richard HendersonSimilar in difficulty to ext*l, already expanded.
--- target-alpha/helper.h | 4 -- target-alpha/op_helper.c | 24 ------------- target-alpha/translate.c | 87 +++++++++++++++++++++++++++++++--------------- 3 files changed, 59 insertions(+), 56 deletions(-)
target-alpha/helper.h +0 -4
@@ -18,15 +18,11 @@ DEF_HELPER_1(ctlz, i64, i64) DEF_HELPER_1(cttz, i64, i64) DEF_HELPER_2(mskbl, i64, i64, i64) -DEF_HELPER_2(insbl, i64, i64, i64) DEF_HELPER_2(mskwl, i64, i64, i64) -DEF_HELPER_2(inswl, i64, i64, i64) DEF_HELPER_2(mskll, i64, i64, i64) -DEF_HELPER_2(insll, i64, i64, i64) DEF_HELPER_2(zap, i64, i64, i64) DEF_HELPER_2(zapnot, i64, i64, i64) DEF_HELPER_2(mskql, i64, i64, i64) -DEF_HELPER_2(insql, i64, i64, i64) DEF_HELPER_2(mskwh, i64, i64, i64) DEF_HELPER_2(inswh, i64, i64, i64)DEF_HELPER_2 (msklh, i64, i64, i64)
target-alpha/op_helper.c +0 -24
@@ -180,34 +180,16 @@ uint64_t helper_mskbl(uint64_t val, uint64_t mask)return byte_zap (val,0x01 << (mask &7 )); } -uint64_t helper_insbl (uint64_t val,uint64_t mask) -{ - val <<= (mask &7 ) *8 ; -return byte_zap (val, ~(0x01 << (mask &7 ))); -} -uint64_t helper_mskwl (uint64_t val,uint64_t mask) {return byte_zap (val,0x03 << (mask &7 )); } -uint64_t helper_inswl (uint64_t val,uint64_t mask) -{ - val <<= (mask &7 ) *8 ; -return byte_zap (val, ~(0x03 << (mask &7 ))); -} -uint64_t helper_mskll (uint64_t val,uint64_t mask) {return byte_zap (val,0x0F << (mask &7 )); } -uint64_t helper_insll (uint64_t val,uint64_t mask) -{ - val <<= (mask &7 ) *8 ; -return byte_zap (val, ~(0x0F << (mask &7 ))); -} -uint64_t helper_zap (uint64_t val,uint64_t mask) {return byte_zap (val, mask);
@@ -223,12 +205,6 @@ uint64_t helper_mskql(uint64_t val, uint64_t mask)return byte_zap (val,0xFF << (mask &7 )); } -uint64_t helper_insql (uint64_t val,uint64_t mask) -{ - val <<= (mask &7 ) *8 ; -return byte_zap (val, ~(0xFF << (mask &7 ))); -} -uint64_t helper_mskwh (uint64_t val,uint64_t mask) {return byte_zap (val, (0x03 << (mask &7 )) >>8 );
target-alpha/translate.c +59 -28
174 lines not on this page · raw message
PATCH 8/13 alpha: Expand msk*l inline.
In reply to Richard HendersonSimilar in difficulty to ext*l, already expanded.
--- target-alpha/helper.h | 4 ---- target-alpha/op_helper.c | 20 -------------------- target-alpha/translate.c | 38 ++++++++++++++++++++++++++++++-------- 3 files changed, 30 insertions(+), 32 deletions(-)
target-alpha/helper.h +0 -4
@@ -17,12 +17,8 @@ DEF_HELPER_1(ctpop, i64, i64) DEF_HELPER_1(ctlz, i64, i64) DEF_HELPER_1(cttz, i64, i64) -DEF_HELPER_2(mskbl, i64, i64, i64) -DEF_HELPER_2(mskwl, i64, i64, i64) -DEF_HELPER_2(mskll, i64, i64, i64) DEF_HELPER_2(zap, i64, i64, i64) DEF_HELPER_2(zapnot, i64, i64, i64) -DEF_HELPER_2(mskql, i64, i64, i64) DEF_HELPER_2(mskwh, i64, i64, i64) DEF_HELPER_2(inswh, i64, i64, i64)DEF_HELPER_2 (msklh, i64, i64, i64)
target-alpha/op_helper.c +0 -20
@@ -175,21 +175,6 @@ static inline uint64_t byte_zap(uint64_t op, uint8_t mskb)return op & ~mask; } -uint64_t helper_mskbl (uint64_t val,uint64_t mask) -{ -return byte_zap (val,0x01 << (mask &7 )); -} - -uint64_t helper_mskwl (uint64_t val,uint64_t mask) -{ -return byte_zap (val,0x03 << (mask &7 )); -} - -uint64_t helper_mskll (uint64_t val,uint64_t mask) -{ -return byte_zap (val,0x0F << (mask &7 )); -} -uint64_t helper_zap (uint64_t val,uint64_t mask) {return byte_zap (val, mask);
@@ -200,11 +185,6 @@ uint64_t helper_zapnot(uint64_t val, uint64_t mask)return byte_zap (val, ~mask); } -uint64_t helper_mskql (uint64_t val,uint64_t mask) -{ -return byte_zap (val,0xFF << (mask &7 )); -} -uint64_t helper_mskwh (uint64_t val,uint64_t mask) {return byte_zap (val, (0x03 << (mask &7 )) >>8 );
target-alpha/translate.c +30 -8
@@ -655,6 +655,32 @@ static inline void gen_ins_l(int ra, int rb, int rc, int islit, } } +/* MSKBL, MSKWL, MSKLL, MSKQL */ +static inline void gen_msk_l (int ra,int rb,int rc,int islit, +uint8_t lit,uint8_t byte_mask) +{ +if (unlikely (rc ==31 )) +return ; +else if (unlikely (ra ==31 )) +tcg_gen_movi_i64 (cpu_ir[rc],0 ); +else if (islit) { +gen_zapnoti (cpu_ir[rc], cpu_ir[ra], ~(byte_mask << (lit &7 ))); + }else { +TCGv shift =tcg_temp_new (); +TCGv mask =tcg_temp_new (); + +tcg_gen_andi_i64 (shift, cpu_ir[rb],7 ); +tcg_gen_shli_i64 (shift, shift,3 ); +tcg_gen_movi_i64 (mask,zapnot_mask (byte_mask)); +tcg_gen_shl_i64 (mask, mask, shift); + +tcg_gen_andc_i64 (cpu_ir[rc], cpu_ir[ra], mask); + +tcg_temp_free (mask); +tcg_temp_free (shift); + } +} +/* Code to call arith3 helpers */ #define ARITH3 (name) \ static inline void glue(gen_, name)(int ra, int rb, int rc, int islit,\
@@ -686,10 +712,6 @@ ARITH3(addlv) ARITH3(sublv) ARITH3(addqv) ARITH3(subqv) -ARITH3(mskbl) -ARITH3(mskwl) -ARITH3(mskll) -ARITH3(mskql) ARITH3(mskwh) ARITH3(inswh) ARITH3(msklh)
@@ -1314,7 +1336,7 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)switch (fn7) {case 0x02 :/* MSKBL */ -gen_mskbl (ra, rb, rc, islit, lit); +gen_msk_l (ra, rb, rc, islit, lit,0x01 );break ;case 0x06 :/* EXTBL */
@@ -1326,7 +1348,7 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x12 :/* MSKWL */ -gen_mskwl (ra, rb, rc, islit, lit); +gen_msk_l (ra, rb, rc, islit, lit,0x03 );break ;case 0x16 :/* EXTWL */
@@ -1338,7 +1360,7 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x22 :/* MSKLL */ -gen_mskll (ra, rb, rc, islit, lit); +gen_msk_l (ra, rb, rc, islit, lit,0x0f );break ;case 0x26 :/* EXTLL */
@@ -1358,7 +1380,7 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x32 :/* MSKQL */ -gen_mskql (ra, rb, rc, islit, lit); +gen_msk_l (ra, rb, rc, islit, lit,0xff );break ;case 0x34 :/* SRL */
PATCH 9/13 alpha: Expand msk*h inline.
In reply to Richard Henderson--- target-alpha/helper.h | 3 -- target-alpha/op_helper.c | 15 ----------- target-alpha/translate.c | 63 +++++++++++++++++++++++++++++++++++---------- 3 files changed, 49 insertions(+), 32 deletions(-)
target-alpha/helper.h +0 -3
@@ -19,11 +19,8 @@ DEF_HELPER_1(cttz, i64, i64) DEF_HELPER_2(zap, i64, i64, i64) DEF_HELPER_2(zapnot, i64, i64, i64) -DEF_HELPER_2(mskwh, i64, i64, i64) DEF_HELPER_2(inswh, i64, i64, i64) -DEF_HELPER_2(msklh, i64, i64, i64) DEF_HELPER_2(inslh, i64, i64, i64) -DEF_HELPER_2(mskqh, i64, i64, i64) DEF_HELPER_2(insqh, i64, i64, i64)DEF_HELPER_2 (cmpbge, i64, i64, i64)
target-alpha/op_helper.c +0 -15
@@ -185,33 +185,18 @@ uint64_t helper_zapnot(uint64_t val, uint64_t mask)return byte_zap (val, ~mask); } -uint64_t helper_mskwh (uint64_t val,uint64_t mask) -{ -return byte_zap (val, (0x03 << (mask &7 )) >>8 ); -} -uint64_t helper_inswh (uint64_t val,uint64_t mask) { val >>=64 - ((mask &7 ) *8 );return byte_zap (val, ~((0x03 << (mask &7 )) >>8 )); } -uint64_t helper_msklh (uint64_t val,uint64_t mask) -{ -return byte_zap (val, (0x0F << (mask &7 )) >>8 ); -} -uint64_t helper_inslh (uint64_t val,uint64_t mask) { val >>=64 - ((mask &7 ) *8 );return byte_zap (val, ~((0x0F << (mask &7 )) >>8 )); } -uint64_t helper_mskqh (uint64_t val,uint64_t mask) -{ -return byte_zap (val, (0xFF << (mask &7 )) >>8 ); -} -uint64_t helper_insqh (uint64_t val,uint64_t mask) { val >>=64 - ((mask &7 ) *8 );
target-alpha/translate.c +49 -14
114 lines not on this page · raw message
PATCH 10/13 alpha: Expand ins*h inline.
In reply to Richard Henderson--- target-alpha/helper.h | 3 -- target-alpha/op_helper.c | 18 ---------------- target-alpha/translate.c | 51 ++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 45 insertions(+), 27 deletions(-)
target-alpha/helper.h +0 -3
@@ -19,9 +19,6 @@ DEF_HELPER_1(cttz, i64, i64) DEF_HELPER_2(zap, i64, i64, i64) DEF_HELPER_2(zapnot, i64, i64, i64) -DEF_HELPER_2(inswh, i64, i64, i64) -DEF_HELPER_2(inslh, i64, i64, i64) -DEF_HELPER_2(insqh, i64, i64, i64)DEF_HELPER_2 (cmpbge, i64, i64, i64)
target-alpha/op_helper.c +0 -18
@@ -185,24 +185,6 @@ uint64_t helper_zapnot(uint64_t val, uint64_t mask)return byte_zap (val, ~mask); } -uint64_t helper_inswh (uint64_t val,uint64_t mask) -{ - val >>=64 - ((mask &7 ) *8 ); -return byte_zap (val, ~((0x03 << (mask &7 )) >>8 )); -} - -uint64_t helper_inslh (uint64_t val,uint64_t mask) -{ - val >>=64 - ((mask &7 ) *8 ); -return byte_zap (val, ~((0x0F << (mask &7 )) >>8 )); -} - -uint64_t helper_insqh (uint64_t val,uint64_t mask) -{ - val >>=64 - ((mask &7 ) *8 ); -return byte_zap (val, ~((0xFF << (mask &7 )) >>8 )); -} -uint64_t helper_cmpbge (uint64_t op1,uint64_t op2) {uint8_t opa, opb, res;
target-alpha/translate.c +45 -6
81 lines not on this page · raw message
PATCH 11/13 alpha: Fix FMOV.
In reply to Richard HendersonProperly handle move from the zero register.
--- target-alpha/translate.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
target-alpha/translate.c +7 -3
@@ -1834,12 +1834,16 @@ static inline int translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x020 :if (likely (rc !=31 )) { -if (ra == rb) +if (ra == rb) {/* FMOV */ -tcg_gen_mov_i64 (cpu_fir[rc], cpu_fir[ra]); -else +if (ra ==31 ) +tcg_gen_movi_i64 (cpu_fir[rc],0 ); +else +tcg_gen_mov_i64 (cpu_fir[rc], cpu_fir[ra]); + }else {/* CPYS */ gen_fcpys (ra, rb, rc); + } }break ;case 0x021 :
PATCH 12/13 alpha: Fix double log_cpu_state.
In reply to Richard HendersonThe proper logging is handled by generic code.
--- target-alpha/translate.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
target-alpha/translate.c +0 -1
@@ -2648,7 +2648,6 @@ static inline void gen_intermediate_code_internal(CPUState *env, tb->icount = num_insns; }#ifdef DEBUG_DISAS -log_cpu_state_mask (CPU_LOG_TB_CPU , env,0 );if (qemu_loglevel_mask (CPU_LOG_TB_IN_ASM )) {qemu_log ("IN: %s\n" ,lookup_symbol (pc_start));log_target_disas (pc_start, ctx.pc - pc_start,1 );
PATCH 13/13 alpha: Implement fp branch/cmov inline.
In reply to Richard HendersonThe old fcmov implementation had a typo:
- tcg_gen_mov_i64(cpu_fir[rc], cpu_fir[ra]);
which moved the condition, not the second source, to the destination.
But it's also easy to implement the simplified fp comparison inline.
--- target-alpha/helper.h | 7 -- target-alpha/op_helper.c | 31 ------- target-alpha/translate.c | 197 ++++++++++++++++++++++++++-------------------- 3 files changed, 110 insertions(+), 125 deletions(-)
target-alpha/helper.h +0 -7
@@ -77,13 +77,6 @@ DEF_HELPER_2(cmpgeq, i64, i64, i64) DEF_HELPER_2(cmpgle, i64, i64, i64) DEF_HELPER_2(cmpglt, i64, i64, i64) -DEF_HELPER_1(cmpfeq, i64, i64) -DEF_HELPER_1(cmpfne, i64, i64) -DEF_HELPER_1(cmpflt, i64, i64) -DEF_HELPER_1(cmpfle, i64, i64) -DEF_HELPER_1(cmpfgt, i64, i64) -DEF_HELPER_1(cmpfge, i64, i64) - DEF_HELPER_2(cpys, i64, i64, i64) DEF_HELPER_2(cpysn, i64, i64, i64)DEF_HELPER_2 (cpyse, i64, i64, i64)
target-alpha/op_helper.c +0 -31
@@ -884,37 +884,6 @@ uint64_t helper_cmpglt(uint64_t a, uint64_t b)return 0 ; } -uint64_t helper_cmpfeq (uint64_t a) -{ -return !(a &0x7FFFFFFFFFFFFFFFULL ); -} - -uint64_t helper_cmpfne (uint64_t a) -{ -return (a &0x7FFFFFFFFFFFFFFFULL ); -} - -uint64_t helper_cmpflt (uint64_t a) -{ -return (a &0x8000000000000000ULL ) && (a &0x7FFFFFFFFFFFFFFFULL ); -} - -uint64_t helper_cmpfle (uint64_t a) -{ -return (a &0x8000000000000000ULL ) || !(a &0x7FFFFFFFFFFFFFFFULL ); -} - -uint64_t helper_cmpfgt (uint64_t a) -{ -return !(a &0x8000000000000000ULL ) && (a &0x7FFFFFFFFFFFFFFFULL ); -} - -uint64_t helper_cmpfge (uint64_t a) -{ -return !(a &0x8000000000000000ULL ) || !(a &0x7FFFFFFFFFFFFFFFULL ); -} - -/* Floating point format conversion */ uint64_t helper_cvtts (uint64_t a) {
target-alpha/translate.c +111 -88
277 lines not on this page · raw message