Skip to content

Commit

Permalink
target-arm: Implement abs_i32 inline rather than as a helper
Browse files Browse the repository at this point in the history
Implement abs_i32 inline (with movcond) rather than using a helper
function.

Reviewed-by: Aurelien Jarno <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
  • Loading branch information
pm215 committed Oct 24, 2012
1 parent ee6fa55 commit 36c91fd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 0 additions & 5 deletions target-arm/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -1562,11 +1562,6 @@ uint32_t HELPER(rbit)(uint32_t x)
return x;
}

uint32_t HELPER(abs)(uint32_t x)
{
return ((int32_t)x < 0) ? -x : x;
}

#if defined(CONFIG_USER_ONLY)

void do_interrupt (CPUARMState *env)
Expand Down
1 change: 0 additions & 1 deletion target-arm/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ DEF_HELPER_2(double_saturate, i32, env, s32)
DEF_HELPER_FLAGS_2(sdiv, TCG_CALL_CONST | TCG_CALL_PURE, s32, s32, s32)
DEF_HELPER_FLAGS_2(udiv, TCG_CALL_CONST | TCG_CALL_PURE, i32, i32, i32)
DEF_HELPER_FLAGS_1(rbit, TCG_CALL_CONST | TCG_CALL_PURE, i32, i32)
DEF_HELPER_FLAGS_1(abs, TCG_CALL_CONST | TCG_CALL_PURE, i32, i32)

#define PAS_OP(pfx) \
DEF_HELPER_3(pfx ## add8, i32, i32, i32, ptr) \
Expand Down
11 changes: 9 additions & 2 deletions target-arm/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,15 @@ static void gen_sar(TCGv dest, TCGv t0, TCGv t1)
tcg_temp_free_i32(tmp1);
}

/* FIXME: Implement this natively. */
#define tcg_gen_abs_i32(t0, t1) gen_helper_abs(t0, t1)
static void tcg_gen_abs_i32(TCGv dest, TCGv src)
{
TCGv c0 = tcg_const_i32(0);
TCGv tmp = tcg_temp_new_i32();
tcg_gen_neg_i32(tmp, src);
tcg_gen_movcond_i32(TCG_COND_GT, dest, src, c0, src, tmp);
tcg_temp_free_i32(c0);
tcg_temp_free_i32(tmp);
}

static void shifter_out_im(TCGv var, int shift)
{
Expand Down

0 comments on commit 36c91fd

Please sign in to comment.