From: "Edgar E. Iglesias" <edgar.igles...@amd.com>

Rename and reorder function args to better match with spec
and pseudo code.

No functional change.

Signed-off-by: Edgar E. Iglesias <edgar.igles...@amd.com>
---
 target/microblaze/op_helper.c | 18 +++++++++---------
 target/microblaze/translate.c | 12 ++----------
 2 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c
index 470526ee92..092977b3e1 100644
--- a/target/microblaze/op_helper.c
+++ b/target/microblaze/op_helper.c
@@ -69,9 +69,9 @@ void helper_raise_exception(CPUMBState *env, uint32_t index)
     cpu_loop_exit(cs);
 }
 
-static bool check_divz(CPUMBState *env, uint32_t b, uintptr_t ra)
+static bool check_divz(CPUMBState *env, uint32_t divisor, uintptr_t pc)
 {
-    if (unlikely(b == 0)) {
+    if (unlikely(divisor == 0)) {
         env->msr |= MSR_DZ;
 
         if ((env->msr & MSR_EE) &&
@@ -80,27 +80,27 @@ static bool check_divz(CPUMBState *env, uint32_t b, 
uintptr_t ra)
 
             env->esr = ESR_EC_DIVZERO;
             cs->exception_index = EXCP_HW_EXCP;
-            cpu_loop_exit_restore(cs, ra);
+            cpu_loop_exit_restore(cs, pc);
         }
         return false;
     }
     return true;
 }
 
-uint32_t helper_divs(CPUMBState *env, uint32_t a, uint32_t b)
+uint32_t helper_divs(CPUMBState *env, uint32_t ra, uint32_t rb)
 {
-    if (!check_divz(env, b, GETPC())) {
+    if (!check_divz(env, ra, GETPC())) {
         return 0;
     }
-    return (int32_t)a / (int32_t)b;
+    return (int32_t)rb / (int32_t)ra;
 }
 
-uint32_t helper_divu(CPUMBState *env, uint32_t a, uint32_t b)
+uint32_t helper_divu(CPUMBState *env, uint32_t ra, uint32_t rb)
 {
-    if (!check_divz(env, b, GETPC())) {
+    if (!check_divz(env, ra, GETPC())) {
         return 0;
     }
-    return a / b;
+    return rb / ra;
 }
 
 /* raise FPU exception.  */
diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c
index 5098a1db4d..2f5fd5c271 100644
--- a/target/microblaze/translate.c
+++ b/target/microblaze/translate.c
@@ -450,16 +450,8 @@ DO_TYPEA0_CFG(flt, use_fpu >= 2, true, gen_flt)
 DO_TYPEA0_CFG(fint, use_fpu >= 2, true, gen_fint)
 DO_TYPEA0_CFG(fsqrt, use_fpu >= 2, true, gen_fsqrt)
 
-/* Does not use ENV_WRAPPER3, because arguments are swapped as well. */
-static void gen_idiv(TCGv_i32 out, TCGv_i32 ina, TCGv_i32 inb)
-{
-    gen_helper_divs(out, tcg_env, inb, ina);
-}
-
-static void gen_idivu(TCGv_i32 out, TCGv_i32 ina, TCGv_i32 inb)
-{
-    gen_helper_divu(out, tcg_env, inb, ina);
-}
+ENV_WRAPPER3(gen_idiv, gen_helper_divs)
+ENV_WRAPPER3(gen_idivu, gen_helper_divu)
 
 DO_TYPEA_CFG(idiv, use_div, true, gen_idiv)
 DO_TYPEA_CFG(idivu, use_div, true, gen_idivu)
-- 
2.43.0


Reply via email to