From 870e8d6348e62721704608be1d70c8704e2cdf3a 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 efaa9757acbe..adc8c8939717 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 deab424964d8..d3e54932ed67 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);