From 07809a8c4824da58996d3160c1994ae8c3b4339b Mon Sep 17 00:00:00 2001 From: Taylor Simpson Date: Wed, 12 Jun 2024 10:54:28 -0600 Subject: [PATCH] Hexagon (target/hexagon) optimize gen_read_greg gregs 0-3 don't need special handling, so generate a TCG move instead of calling a helper Signed-off-by: Taylor Simpson --- target/hexagon/genptr.c | 12 ++++++++++-- target/hexagon/op_helper.c | 8 ++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/target/hexagon/genptr.c b/target/hexagon/genptr.c index efaa9757acbe0..adc8c89397175 100644 --- a/target/hexagon/genptr.c +++ b/target/hexagon/genptr.c @@ -344,12 +344,20 @@ static void gen_read_sreg_pair(TCGv_i64 dst, int reg_num) static void gen_read_greg(TCGv dst, int reg_num) { - gen_helper_greg_read(dst, tcg_env, tcg_constant_tl(reg_num)); + if (reg_num <= HEX_GREG_G3) { + tcg_gen_mov_tl(dst, hex_greg[reg_num]); + } else { + gen_helper_greg_read(dst, tcg_env, tcg_constant_tl(reg_num)); + } } static void gen_read_greg_pair(TCGv_i64 dst, int reg_num) { - gen_helper_greg_read_pair(dst, tcg_env, tcg_constant_tl(reg_num)); + if (reg_num == HEX_GREG_G0 || reg_num == HEX_GREG_G2) { + tcg_gen_concat_i32_i64(dst, hex_greg[reg_num], hex_greg[reg_num + 1]); + } else { + gen_helper_greg_read_pair(dst, tcg_env, tcg_constant_tl(reg_num)); + } } #endif diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c index deab424964d81..d3e54932ed673 100644 --- a/target/hexagon/op_helper.c +++ b/target/hexagon/op_helper.c @@ -2412,16 +2412,16 @@ void HELPER(sreg_write_pair)(CPUHexagonState *env, uint32_t reg, uint64_t val) uint32_t HELPER(greg_read)(CPUHexagonState *env, uint32_t reg) { + /* Check should be done before calling this helper */ + g_assert(reg > HEX_GREG_G3); return hexagon_greg_read(env, reg); } uint64_t HELPER(greg_read_pair)(CPUHexagonState *env, uint32_t reg) { - if (reg == HEX_GREG_G0 || reg == HEX_GREG_G2) { - return (uint64_t)(env->greg[reg]) | - (((uint64_t)(env->greg[reg + 1])) << 32); - } + /* Check should be done before calling this helper */ + g_assert(reg > HEX_GREG_G3); switch (reg) { case HEX_GREG_GPCYCLELO: { target_ulong ssr = ARCH_GET_SYSTEM_REG(env, HEX_SREG_SSR);