Skip to content

Commit

Permalink
Hexagon (target/hexagon) optimize gen_read_greg
Browse files Browse the repository at this point in the history
gregs 0-3 don't need special handling, so generate a TCG move
instead of calling a helper

Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
  • Loading branch information
taylorsimpson authored and androm3da committed Jul 2, 2024
1 parent e0937b9 commit 870e8d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 10 additions & 2 deletions target/hexagon/genptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions target/hexagon/op_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 870e8d6

Please sign in to comment.