From: "Edgar E. Iglesias" <edgar.iglesias@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.iglesias@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
On 8/25/25 08:27, Edgar E. Iglesias wrote: > From: "Edgar E. Iglesias" <edgar.iglesias@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.iglesias@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) The name GETPC notwithstanding, I don't think ra -> pc is a good rename. PC often gets confused about whether that's a host or guest value. RA (return address) is less so; it gets used often in core tcg. If you really don't like RA, then perhaps "retaddr" (also with quite a bit of usage) or "unwind_pc" (no existing usage, but very descriptive). r~
On 25/8/25 01:32, Richard Henderson wrote: > On 8/25/25 08:27, Edgar E. Iglesias wrote: >> From: "Edgar E. Iglesias" <edgar.iglesias@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.iglesias@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) > > The name GETPC notwithstanding, I don't think ra -> pc is a good rename. > > PC often gets confused about whether that's a host or guest value. > RA (return address) is less so; it gets used often in core tcg. > > If you really don't like RA, then perhaps "retaddr" (also with quite a > bit of usage) or "unwind_pc" (no existing usage, but very descriptive). +1 for 'unwind_pc'. While thinking more about it, I noticed we don't document the prototypes in "exec/cpu-common.h". Doing so we could rename s/pc/unwind_pc/ and document @unwind_pc. Also these helpers would be better declared in a TCG specific header. Anyway, note for Richard, orthogonal to this patch ;)
On Mon, Aug 25, 2025 at 12:11:25PM +0200, Philippe Mathieu-Daudé wrote: > On 25/8/25 01:32, Richard Henderson wrote: > > On 8/25/25 08:27, Edgar E. Iglesias wrote: > > > From: "Edgar E. Iglesias" <edgar.iglesias@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.iglesias@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) > > > > The name GETPC notwithstanding, I don't think ra -> pc is a good rename. > > > > PC often gets confused about whether that's a host or guest value. > > RA (return address) is less so; it gets used often in core tcg. > > > > If you really don't like RA, then perhaps "retaddr" (also with quite a > > bit of usage) or "unwind_pc" (no existing usage, but very descriptive). > > +1 for 'unwind_pc'. Sounds good! Thanks, Edgar
© 2016 - 2025 Red Hat, Inc.