Improve USR handling
cover Improve USR handling
Currently, any instruction that writes USR disables short-circuiting a packet. When the write is implicit, we can allow the short-circuit.
Taylor Simpson (2):
Hexagon (target/hexagon) Add pkt_need_commit argument to arch_fpop_end Hexagon (target/hexagon) Implicit writes to USR don't force packet
commit
target/hexagon/arch.h | 2 +- target/hexagon/gen_tcg.h | 114 ++++++------ target/hexagon/helper.h | 114 ++++++------ target/hexagon/arch.c | 3 +- target/hexagon/op_helper.c | 287 +++++++++++++++++------------ target/hexagon/translate.c | 14 +- target/hexagon/gen_helper_funcs.py | 8 +- target/hexagon/gen_tcg_funcs.py | 4 + 8 files changed, 295 insertions(+), 251 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/2 Hexagon (target/hexagon) Add pkt_need_commit argument to arch_fpop_end
The arch_fpop_end function converts the softfloat fp_status flags to bits set in Hexagon USR. It is hard-coded that the packet must need a commit. We add an argument to the function and update all the helper call sites.
In a subsequent commit, we will change the code that forces a commit when the packet contains an floating point instruction.
--- target/hexagon/arch.h | 2 +- target/hexagon/gen_tcg.h | 114 ++++++------ target/hexagon/helper.h | 114 ++++++------ target/hexagon/arch.c | 3 +- target/hexagon/op_helper.c | 287 +++++++++++++++++------------ target/hexagon/gen_helper_funcs.py | 8 +- target/hexagon/gen_tcg_funcs.py | 4 + 7 files changed, 294 insertions(+), 238 deletions(-)
target/hexagon/arch.h +1 -1
@@ -28,7 +28,7 @@ uint64_t interleave(uint32_t odd, uint32_t even);uint64_t deinterleave (uint64_t src);int32_t conv_round (int32_t a,int n);void arch_fpop_start (CPUHexagonState *env); -void arch_fpop_end (CPUHexagonState *env); +void arch_fpop_end (CPUHexagonState *env,bool pkt_need_commit);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,
target/hexagon/gen_tcg.h +57 -57
193 lines not on this page · raw message
target/hexagon/helper.h +57 -57
129 lines not on this page · raw message
target/hexagon/arch.c +1 -2
@@ -222,9 +222,8 @@ void arch_fpop_start(CPUHexagonState *env) } \ }while (0 ) -void arch_fpop_end(CPUHexagonState *env) +void arch_fpop_end(CPUHexagonState *env, bool pkt_need_commit) { -const bool pkt_need_commit = true;int flags =get_float_exception_flags (&env->fp_status);if (flags !=0 ) {SOFTFLOAT_TEST_FLAG (float_flag_inexact,FPINPF ,FPINPE );
target/hexagon/op_helper.c +171 -116
755 lines not on this page · raw message
target/hexagon/gen_helper_funcs.py +3 -5
@@ -84,11 +84,6 @@ def gen_helper_function(f, tag, tagregs, tagimms): {hex_common.semdict[tag]} """)) - if "A_FPOP" in hex_common.attribdict[tag]: - f.write(hex_common.code_fmt(f"""\ - arch_fpop_end(env); - """)) - ## Return the scalar result for regtype, regid in regs: reg = hex_common.get_register(tag, regtype, regid)
@@ -116,6 +111,9 @@ def main(): ## Skip the guest instructions if "A_GUEST" in hex_common.attribdict[tag]: continue + ## Skip the floating point instructions + if "A_FPOP" in hex_common.attribdict[tag]: + continue ## Skip the diag instructions if tag == "Y6_diag": continue
target/hexagon/gen_tcg_funcs.py +4 -0
@@ -77,6 +77,10 @@ def gen_tcg_func(f, tag, regs, imms): f.write(f" emit_{tag}({arguments});\n") elif hex_common.skip_qemu_helper(tag): + if "A_FPOP" in hex_common.attribdict[tag]: + f.write(" TCGv pkt_need_commit = ") + f.write("tcg_constant_tl(ctx->need_commit);\n") + f.write(f" fGEN_TCG_{tag}({hex_common.semdict[tag]});\n") else: ## Generate the call to the helper
Signature · 1 line
2.43.0
PATCH 2/2 Hexagon (target/hexagon) Implicit writes to USR don't force packet commit
In reply to Taylor SimpsonImplicit writes to USR are only to specific fields of USR to indicate side effects (e.g., saturation overflow, floating point status). In these cases, we don't force a packet commit. This will allow more packets to be short-circuited (avoid writing the results to temporaries).
--- target/hexagon/translate.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
target/hexagon/translate.c +1 -13
@@ -272,12 +272,7 @@ static void mark_implicit_reg_write(DisasContext *ctx, int attrib, int rnum) {uint16_t opcode = ctx->insn->opcode;if (GET_ATTRIB (opcode, attrib)) { -/* -* USR is used to set overflow and FP exceptions, -* so treat it as conditional -*/ -bool is_predicated =GET_ATTRIB (opcode,A_CONDEXEC ) || - rnum ==HEX_REG_USR ; +bool is_predicated =GET_ATTRIB (opcode,A_CONDEXEC );/* LC0/LC1 is conditionally written by endloop instructions */ if ((rnum == HEX_REG_LC0 || rnum == HEX_REG_LC1) &&
@@ -300,8 +295,6 @@ static void mark_implicit_reg_writes(DisasContext *ctx)mark_implicit_reg_write (ctx,A_IMPLICIT_WRITES_SA0 ,HEX_REG_SA0 );mark_implicit_reg_write (ctx,A_IMPLICIT_WRITES_LC1 ,HEX_REG_LC1 );mark_implicit_reg_write (ctx,A_IMPLICIT_WRITES_SA1 ,HEX_REG_SA1 ); -mark_implicit_reg_write (ctx,A_IMPLICIT_WRITES_USR ,HEX_REG_USR ); -mark_implicit_reg_write (ctx,A_FPOP ,HEX_REG_USR ); }static void mark_implicit_pred_write (DisasContext *ctx,int attrib,int pnum)
@@ -351,11 +344,6 @@ static bool need_commit(DisasContext *ctx) } } -/* Floating point instructions are hard-coded to use new_value */ -if (check_for_attrib (pkt,A_FPOP )) { -return true; - } -if (ctx->read_after_write || ctx->has_hvx_overlap) {return true; }
Signature · 1 line
2.43.0