Remove inline included with file tcg_cpu.c, and set it separate
with file target/loongarch/cpu.c
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
target/loongarch/cpu.c | 9 ---------
target/loongarch/tcg/meson.build | 1 +
target/loongarch/tcg/tcg_cpu.c | 13 ++++++++++++-
target/loongarch/tcg/tcg_loongarch.h | 1 +
4 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index 6eb8c3214a..b449ede56d 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -28,11 +28,6 @@
#ifdef CONFIG_KVM
#include <linux/kvm.h>
#endif
-#ifdef CONFIG_TCG
-#include "accel/tcg/cpu-ldst.h"
-#include "accel/tcg/cpu-ops.h"
-#include "tcg/tcg.h"
-#endif
#include "tcg/tcg_loongarch.h"
const char * const regnames[32] = {
@@ -653,10 +648,6 @@ static void loongarch_cpu_dump_state(CPUState *cs, FILE *f, int flags)
}
}
-#ifdef CONFIG_TCG
-#include "tcg/tcg_cpu.c"
-#endif /* CONFIG_TCG */
-
#ifndef CONFIG_USER_ONLY
#include "hw/core/sysemu-cpu-ops.h"
diff --git a/target/loongarch/tcg/meson.build b/target/loongarch/tcg/meson.build
index bdf34f9673..b7adfe46f1 100644
--- a/target/loongarch/tcg/meson.build
+++ b/target/loongarch/tcg/meson.build
@@ -7,6 +7,7 @@ loongarch_ss.add([zlib, gen])
loongarch_ss.add(files(
'fpu_helper.c',
'op_helper.c',
+ 'tcg_cpu.c',
'translate.c',
'vec_helper.c',
))
diff --git a/target/loongarch/tcg/tcg_cpu.c b/target/loongarch/tcg/tcg_cpu.c
index f09a695968..c7f49838e3 100644
--- a/target/loongarch/tcg/tcg_cpu.c
+++ b/target/loongarch/tcg/tcg_cpu.c
@@ -4,6 +4,17 @@
*
* Copyright (c) 2025 Loongson Technology Corporation Limited
*/
+#include "qemu/osdep.h"
+#include "qemu/accel.h"
+#include "qemu/error-report.h"
+#include "qemu/log.h"
+#include "accel/accel-cpu-target.h"
+#include "accel/tcg/cpu-ldst.h"
+#include "accel/tcg/cpu-ops.h"
+#include "exec/translation-block.h"
+#include "exec/target_page.h"
+#include "tcg_loongarch.h"
+#include "internals.h"
#ifndef CONFIG_USER_ONLY
static void loongarch_cpu_do_interrupt(CPUState *cs)
@@ -232,7 +243,7 @@ static int loongarch_cpu_mmu_index(CPUState *cs, bool ifetch)
return MMU_DA_IDX;
}
-static const TCGCPUOps loongarch_tcg_ops = {
+const TCGCPUOps loongarch_tcg_ops = {
.guest_default_memory_order = 0,
.mttcg_supported = true,
diff --git a/target/loongarch/tcg/tcg_loongarch.h b/target/loongarch/tcg/tcg_loongarch.h
index 47702893e3..7fb627f2d6 100644
--- a/target/loongarch/tcg/tcg_loongarch.h
+++ b/target/loongarch/tcg/tcg_loongarch.h
@@ -9,6 +9,7 @@
#include "cpu.h"
#include "cpu-mmu.h"
+extern const TCGCPUOps loongarch_tcg_ops;
void loongarch_csr_translate_init(void);
bool loongarch_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
--
2.39.3
On 9/22/25 00:33, Bibo Mao wrote: > Remove inline included with file tcg_cpu.c, and set it separate > with file target/loongarch/cpu.c > > Signed-off-by: Bibo Mao <maobibo@loongson.cn> > --- > target/loongarch/cpu.c | 9 --------- > target/loongarch/tcg/meson.build | 1 + > target/loongarch/tcg/tcg_cpu.c | 13 ++++++++++++- > target/loongarch/tcg/tcg_loongarch.h | 1 + > 4 files changed, 14 insertions(+), 10 deletions(-) I think this should be squashed with patch 1. The intermediate #include of tcg/tcg_cpu.c was odd. With that, Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~ > > diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c > index 6eb8c3214a..b449ede56d 100644 > --- a/target/loongarch/cpu.c > +++ b/target/loongarch/cpu.c > @@ -28,11 +28,6 @@ > #ifdef CONFIG_KVM > #include <linux/kvm.h> > #endif > -#ifdef CONFIG_TCG > -#include "accel/tcg/cpu-ldst.h" > -#include "accel/tcg/cpu-ops.h" > -#include "tcg/tcg.h" > -#endif > #include "tcg/tcg_loongarch.h" > > const char * const regnames[32] = { > @@ -653,10 +648,6 @@ static void loongarch_cpu_dump_state(CPUState *cs, FILE *f, int flags) > } > } > > -#ifdef CONFIG_TCG > -#include "tcg/tcg_cpu.c" > -#endif /* CONFIG_TCG */ > - > #ifndef CONFIG_USER_ONLY > #include "hw/core/sysemu-cpu-ops.h" > > diff --git a/target/loongarch/tcg/meson.build b/target/loongarch/tcg/meson.build > index bdf34f9673..b7adfe46f1 100644 > --- a/target/loongarch/tcg/meson.build > +++ b/target/loongarch/tcg/meson.build > @@ -7,6 +7,7 @@ loongarch_ss.add([zlib, gen]) > loongarch_ss.add(files( > 'fpu_helper.c', > 'op_helper.c', > + 'tcg_cpu.c', > 'translate.c', > 'vec_helper.c', > )) > diff --git a/target/loongarch/tcg/tcg_cpu.c b/target/loongarch/tcg/tcg_cpu.c > index f09a695968..c7f49838e3 100644 > --- a/target/loongarch/tcg/tcg_cpu.c > +++ b/target/loongarch/tcg/tcg_cpu.c > @@ -4,6 +4,17 @@ > * > * Copyright (c) 2025 Loongson Technology Corporation Limited > */ > +#include "qemu/osdep.h" > +#include "qemu/accel.h" > +#include "qemu/error-report.h" > +#include "qemu/log.h" > +#include "accel/accel-cpu-target.h" > +#include "accel/tcg/cpu-ldst.h" > +#include "accel/tcg/cpu-ops.h" > +#include "exec/translation-block.h" > +#include "exec/target_page.h" > +#include "tcg_loongarch.h" > +#include "internals.h" > > #ifndef CONFIG_USER_ONLY > static void loongarch_cpu_do_interrupt(CPUState *cs) > @@ -232,7 +243,7 @@ static int loongarch_cpu_mmu_index(CPUState *cs, bool ifetch) > return MMU_DA_IDX; > } > > -static const TCGCPUOps loongarch_tcg_ops = { > +const TCGCPUOps loongarch_tcg_ops = { > .guest_default_memory_order = 0, > .mttcg_supported = true, > > diff --git a/target/loongarch/tcg/tcg_loongarch.h b/target/loongarch/tcg/tcg_loongarch.h > index 47702893e3..7fb627f2d6 100644 > --- a/target/loongarch/tcg/tcg_loongarch.h > +++ b/target/loongarch/tcg/tcg_loongarch.h > @@ -9,6 +9,7 @@ > #include "cpu.h" > #include "cpu-mmu.h" > > +extern const TCGCPUOps loongarch_tcg_ops; > void loongarch_csr_translate_init(void); > > bool loongarch_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
On 2025/9/22 下午10:29, Richard Henderson wrote: > On 9/22/25 00:33, Bibo Mao wrote: >> Remove inline included with file tcg_cpu.c, and set it separate >> with file target/loongarch/cpu.c >> >> Signed-off-by: Bibo Mao <maobibo@loongson.cn> >> --- >> target/loongarch/cpu.c | 9 --------- >> target/loongarch/tcg/meson.build | 1 + >> target/loongarch/tcg/tcg_cpu.c | 13 ++++++++++++- >> target/loongarch/tcg/tcg_loongarch.h | 1 + >> 4 files changed, 14 insertions(+), 10 deletions(-) > > I think this should be squashed with patch 1. > The intermediate #include of tcg/tcg_cpu.c was odd. yes, it is actually odd. It is just for code review to do so. Will squashed this with patch 1. Regards Bibo Mao > > With that, > Reviewed-by: Richard Henderson <richard.henderson@linaro.org> > > > r~ > >> >> diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c >> index 6eb8c3214a..b449ede56d 100644 >> --- a/target/loongarch/cpu.c >> +++ b/target/loongarch/cpu.c >> @@ -28,11 +28,6 @@ >> #ifdef CONFIG_KVM >> #include <linux/kvm.h> >> #endif >> -#ifdef CONFIG_TCG >> -#include "accel/tcg/cpu-ldst.h" >> -#include "accel/tcg/cpu-ops.h" >> -#include "tcg/tcg.h" >> -#endif >> #include "tcg/tcg_loongarch.h" >> const char * const regnames[32] = { >> @@ -653,10 +648,6 @@ static void loongarch_cpu_dump_state(CPUState >> *cs, FILE *f, int flags) >> } >> } >> -#ifdef CONFIG_TCG >> -#include "tcg/tcg_cpu.c" >> -#endif /* CONFIG_TCG */ >> - >> #ifndef CONFIG_USER_ONLY >> #include "hw/core/sysemu-cpu-ops.h" >> diff --git a/target/loongarch/tcg/meson.build >> b/target/loongarch/tcg/meson.build >> index bdf34f9673..b7adfe46f1 100644 >> --- a/target/loongarch/tcg/meson.build >> +++ b/target/loongarch/tcg/meson.build >> @@ -7,6 +7,7 @@ loongarch_ss.add([zlib, gen]) >> loongarch_ss.add(files( >> 'fpu_helper.c', >> 'op_helper.c', >> + 'tcg_cpu.c', >> 'translate.c', >> 'vec_helper.c', >> )) >> diff --git a/target/loongarch/tcg/tcg_cpu.c >> b/target/loongarch/tcg/tcg_cpu.c >> index f09a695968..c7f49838e3 100644 >> --- a/target/loongarch/tcg/tcg_cpu.c >> +++ b/target/loongarch/tcg/tcg_cpu.c >> @@ -4,6 +4,17 @@ >> * >> * Copyright (c) 2025 Loongson Technology Corporation Limited >> */ >> +#include "qemu/osdep.h" >> +#include "qemu/accel.h" >> +#include "qemu/error-report.h" >> +#include "qemu/log.h" >> +#include "accel/accel-cpu-target.h" >> +#include "accel/tcg/cpu-ldst.h" >> +#include "accel/tcg/cpu-ops.h" >> +#include "exec/translation-block.h" >> +#include "exec/target_page.h" >> +#include "tcg_loongarch.h" >> +#include "internals.h" >> #ifndef CONFIG_USER_ONLY >> static void loongarch_cpu_do_interrupt(CPUState *cs) >> @@ -232,7 +243,7 @@ static int loongarch_cpu_mmu_index(CPUState *cs, >> bool ifetch) >> return MMU_DA_IDX; >> } >> -static const TCGCPUOps loongarch_tcg_ops = { >> +const TCGCPUOps loongarch_tcg_ops = { >> .guest_default_memory_order = 0, >> .mttcg_supported = true, >> diff --git a/target/loongarch/tcg/tcg_loongarch.h >> b/target/loongarch/tcg/tcg_loongarch.h >> index 47702893e3..7fb627f2d6 100644 >> --- a/target/loongarch/tcg/tcg_loongarch.h >> +++ b/target/loongarch/tcg/tcg_loongarch.h >> @@ -9,6 +9,7 @@ >> #include "cpu.h" >> #include "cpu-mmu.h" >> +extern const TCGCPUOps loongarch_tcg_ops; >> void loongarch_csr_translate_init(void); >> bool loongarch_cpu_tlb_fill(CPUState *cs, vaddr address, int size, >
© 2016 - 2025 Red Hat, Inc.