diff --git a/target-arm/helper.c b/target-arm/helper.c index df09778ea8ece703dddef8bad4167394c1a6f09f..236aaed23b81d0ae699d8e4dca3006ed3bb516ba 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -340,6 +340,14 @@ uint32_t HELPER(uxtb16)(uint32_t x) return res; } +uint32_t HELPER(clz)(uint32_t x) +{ + int count; + for (count = 32; x; count--) + x >>= 1; + return count; +} + #if defined(CONFIG_USER_ONLY) void do_interrupt (CPUState *env) diff --git a/target-arm/helpers.h b/target-arm/helpers.h index 577f5ee402e4b20213ff7a4403d1b5a3bec64690..8f2e1291623cd15c7de67eda2d6df6a6e3f45802 100644 --- a/target-arm/helpers.h +++ b/target-arm/helpers.h @@ -2,5 +2,6 @@ #define DEF_HELPER(name, ret, args) ret helper_##name args; #endif +DEF_HELPER(clz, uint32_t, (uint32_t)) DEF_HELPER(sxtb16, uint32_t, (uint32_t)) DEF_HELPER(uxtb16, uint32_t, (uint32_t)) diff --git a/target-arm/op.c b/target-arm/op.c index 9a01675270cccad1438ca0f4f52fd59f538f5364..bf535c8db0ef86b620277a388e4f688124860cea 100644 --- a/target-arm/op.c +++ b/target-arm/op.c @@ -475,15 +475,6 @@ void OPPROTO op_rorl_T1_T0_cc(void) } /* misc */ -void OPPROTO op_clz_T0(void) -{ - int count; - for (count = 32; T0 > 0; count--) - T0 = T0 >> 1; - T0 = count; - FORCE_RET(); -} - #define SIGNBIT (uint32_t)0x80000000 /* saturating arithmetic */ void OPPROTO op_addl_T0_T1_setq(void) diff --git a/target-arm/translate.c b/target-arm/translate.c index ef529eb16109640cacae2fe496dc7e1806680927..8669e9422c7c56725e1369f26b05eb8119cd17bb 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -205,6 +205,9 @@ static void store_reg(DisasContext *s, int reg, TCGv var) #define gen_sxtb16(var) tcg_gen_helper_1_1(HELPER_ADDR(sxtb16), var, var) #define gen_uxtb16(var) tcg_gen_helper_1_1(HELPER_ADDR(uxtb16), var, var) +#define gen_op_clz_T0(var) \ + tcg_gen_helper_1_1(HELPER_ADDR(clz), cpu_T[0], cpu_T[0]) + /* Dual 16-bit add. Result placed in t0 and t1 is marked as dead. tmp = (t0 ^ t1) & 0x8000; t0 &= ~0x8000;