Drop some unnecessary includes. Change the offsetof expressions
to be based on CPUState instead of ArchCPU.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/translator.c | 14 ++++++--------
accel/tcg/meson.build | 2 +-
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index 307a513487..36a6a9e040 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -11,14 +11,13 @@
#include "qemu/bswap.h"
#include "qemu/log.h"
#include "qemu/error-report.h"
-#include "exec/exec-all.h"
#include "exec/cpu-ldst-common.h"
#include "exec/cpu-mmu-index.h"
+#include "exec/target_page.h"
#include "exec/translator.h"
#include "exec/plugin-gen.h"
#include "tcg/tcg-op-common.h"
#include "internal-common.h"
-#include "internal-target.h"
#include "disas/disas.h"
#include "tb-internal.h"
@@ -26,8 +25,7 @@ static void set_can_do_io(DisasContextBase *db, bool val)
{
QEMU_BUILD_BUG_ON(sizeof_field(CPUState, neg.can_do_io) != 1);
tcg_gen_st8_i32(tcg_constant_i32(val), tcg_env,
- offsetof(ArchCPU, parent_obj.neg.can_do_io) -
- offsetof(ArchCPU, env));
+ offsetof(CPUState, neg.can_do_io) - sizeof(CPUState));
}
bool translator_io_start(DisasContextBase *db)
@@ -50,8 +48,8 @@ static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags)
if ((cflags & CF_USE_ICOUNT) || !(cflags & CF_NOIRQ)) {
count = tcg_temp_new_i32();
tcg_gen_ld_i32(count, tcg_env,
- offsetof(ArchCPU, parent_obj.neg.icount_decr.u32)
- - offsetof(ArchCPU, env));
+ offsetof(CPUState, neg.icount_decr.u32) -
+ sizeof(CPUState));
}
if (cflags & CF_USE_ICOUNT) {
@@ -80,8 +78,8 @@ static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags)
if (cflags & CF_USE_ICOUNT) {
tcg_gen_st16_i32(count, tcg_env,
- offsetof(ArchCPU, parent_obj.neg.icount_decr.u16.low)
- - offsetof(ArchCPU, env));
+ offsetof(CPUState, neg.icount_decr.u16.low) -
+ sizeof(CPUState));
}
return icount_start_insn;
diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
index 72d4acfe5e..047afa49a2 100644
--- a/accel/tcg/meson.build
+++ b/accel/tcg/meson.build
@@ -8,6 +8,7 @@ tcg_ss.add(files(
'cpu-exec-common.c',
'tcg-runtime.c',
'tcg-runtime-gvec.c',
+ 'translator.c',
))
if get_option('plugins')
tcg_ss.add(files('plugin-gen.c'))
@@ -22,7 +23,6 @@ tcg_specific_ss.add(files(
'cpu-exec.c',
'tb-maint.c',
'translate-all.c',
- 'translator.c',
))
tcg_specific_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-exec.c'))
specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss)
--
2.43.0
On 3/28/25 13:04, Richard Henderson wrote: > Drop some unnecessary includes. Change the offsetof expressions > to be based on CPUState instead of ArchCPU. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > accel/tcg/translator.c | 14 ++++++-------- > accel/tcg/meson.build | 2 +- > 2 files changed, 7 insertions(+), 9 deletions(-) > > diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c > index 307a513487..36a6a9e040 100644 > --- a/accel/tcg/translator.c > +++ b/accel/tcg/translator.c > @@ -11,14 +11,13 @@ > #include "qemu/bswap.h" > #include "qemu/log.h" > #include "qemu/error-report.h" > -#include "exec/exec-all.h" > #include "exec/cpu-ldst-common.h" > #include "exec/cpu-mmu-index.h" > +#include "exec/target_page.h" > #include "exec/translator.h" > #include "exec/plugin-gen.h" > #include "tcg/tcg-op-common.h" > #include "internal-common.h" > -#include "internal-target.h" > #include "disas/disas.h" > #include "tb-internal.h" > > @@ -26,8 +25,7 @@ static void set_can_do_io(DisasContextBase *db, bool val) > { > QEMU_BUILD_BUG_ON(sizeof_field(CPUState, neg.can_do_io) != 1); > tcg_gen_st8_i32(tcg_constant_i32(val), tcg_env, > - offsetof(ArchCPU, parent_obj.neg.can_do_io) - > - offsetof(ArchCPU, env)); > + offsetof(CPUState, neg.can_do_io) - sizeof(CPUState)); > } > > bool translator_io_start(DisasContextBase *db) > @@ -50,8 +48,8 @@ static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags) > if ((cflags & CF_USE_ICOUNT) || !(cflags & CF_NOIRQ)) { > count = tcg_temp_new_i32(); > tcg_gen_ld_i32(count, tcg_env, > - offsetof(ArchCPU, parent_obj.neg.icount_decr.u32) > - - offsetof(ArchCPU, env)); > + offsetof(CPUState, neg.icount_decr.u32) - > + sizeof(CPUState)); > } > > if (cflags & CF_USE_ICOUNT) { > @@ -80,8 +78,8 @@ static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags) > > if (cflags & CF_USE_ICOUNT) { > tcg_gen_st16_i32(count, tcg_env, > - offsetof(ArchCPU, parent_obj.neg.icount_decr.u16.low) > - - offsetof(ArchCPU, env)); > + offsetof(CPUState, neg.icount_decr.u16.low) - > + sizeof(CPUState)); > } > > return icount_start_insn; > diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build > index 72d4acfe5e..047afa49a2 100644 > --- a/accel/tcg/meson.build > +++ b/accel/tcg/meson.build > @@ -8,6 +8,7 @@ tcg_ss.add(files( > 'cpu-exec-common.c', > 'tcg-runtime.c', > 'tcg-runtime-gvec.c', > + 'translator.c', > )) > if get_option('plugins') > tcg_ss.add(files('plugin-gen.c')) > @@ -22,7 +23,6 @@ tcg_specific_ss.add(files( > 'cpu-exec.c', > 'tb-maint.c', > 'translate-all.c', > - 'translator.c', > )) > tcg_specific_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-exec.c')) > specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss) Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
On 28/3/25 21:04, Richard Henderson wrote: > Drop some unnecessary includes. Change the offsetof expressions > to be based on CPUState instead of ArchCPU. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > accel/tcg/translator.c | 14 ++++++-------- > accel/tcg/meson.build | 2 +- > 2 files changed, 7 insertions(+), 9 deletions(-) Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
© 2016 - 2025 Red Hat, Inc.